@rr0/ufoathome 0.26.0 → 0.28.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/dist-embed/UfoMessages_fr-Hq24iVzT.js +1 -0
- package/dist-embed/UfoRecorderMessages_fr-Dukix9sF.js +1 -0
- package/dist-embed/rr0-ufo-recorder.mjs +212 -194
- package/dist-embed-eyewitness/UfoMessages_fr-Hq24iVzT.js +1 -0
- package/dist-embed-eyewitness/rr0-eyewitness.mjs +207 -196
- package/dist-embed-scene/UfoMessages_fr-Hq24iVzT.js +1 -0
- package/dist-embed-scene/rr0-scene.mjs +204 -193
- package/dist-embed-ufo/UfoMessages_fr-Hq24iVzT.js +1 -0
- package/dist-embed-ufo/rr0-ufo.mjs +8 -1
- package/package.json +1 -1
- package/dist-embed/UfoMessages_fr-NZrwNFCQ.js +0 -1
- package/dist-embed/UfoRecorderMessages_fr-CJJ5bM9F.js +0 -1
- package/dist-embed-eyewitness/UfoMessages_fr-NZrwNFCQ.js +0 -1
- package/dist-embed-scene/UfoMessages_fr-NZrwNFCQ.js +0 -1
- package/dist-embed-ufo/UfoMessages_fr-NZrwNFCQ.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const wd=`
|
|
2
2
|
<div class="stage" id="stage">
|
|
3
3
|
<div class="frame" id="frame">
|
|
4
4
|
<canvas id="scene-canvas"></canvas>
|
|
@@ -6,7 +6,7 @@ const Od=`
|
|
|
6
6
|
<div id="ufo-slot"></div>
|
|
7
7
|
<div id="hover-tooltip" class="hover-tooltip" hidden></div>
|
|
8
8
|
</div>
|
|
9
|
-
`,
|
|
9
|
+
`,Rd=`
|
|
10
10
|
:host {
|
|
11
11
|
display: block;
|
|
12
12
|
}
|
|
@@ -79,7 +79,7 @@ const Od=`
|
|
|
79
79
|
pointer-events: none;
|
|
80
80
|
white-space: nowrap;
|
|
81
81
|
}
|
|
82
|
-
`,
|
|
82
|
+
`,Cd=`
|
|
83
83
|
<div class="stage" id="stage">
|
|
84
84
|
<div class="frame" id="frame">
|
|
85
85
|
<canvas id="canvas" width="640" height="360"></canvas>
|
|
@@ -94,7 +94,7 @@ const Od=`
|
|
|
94
94
|
<button id="loop" type="button" title="Auto-replay" aria-label="Auto-replay" aria-pressed="true">↻</button>
|
|
95
95
|
</div>
|
|
96
96
|
</div>
|
|
97
|
-
`,
|
|
97
|
+
`,Pd=`
|
|
98
98
|
:host {
|
|
99
99
|
display: block;
|
|
100
100
|
font-family: sans-serif;
|
|
@@ -271,6 +271,13 @@ input[type=range] {
|
|
|
271
271
|
cursor: default;
|
|
272
272
|
opacity: 0.4;
|
|
273
273
|
}
|
|
274
|
+
.time-label.switchable {
|
|
275
|
+
cursor: pointer;
|
|
276
|
+
}
|
|
277
|
+
.time-label.switchable:hover,
|
|
278
|
+
.time-label.switchable:focus-visible {
|
|
279
|
+
text-decoration: underline;
|
|
280
|
+
}
|
|
274
281
|
.time-label {
|
|
275
282
|
color: #fff;
|
|
276
283
|
font-variant-numeric: tabular-nums;
|
|
@@ -290,21 +297,21 @@ input[type=range] {
|
|
|
290
297
|
pointer-events: none;
|
|
291
298
|
white-space: nowrap;
|
|
292
299
|
}
|
|
293
|
-
`;class Vt{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/Vt.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 Gd(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 tn(i,e,t){return i+(e-i)*t}function Vl(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 Hd(i){return`#${i.map(e=>Math.round(e).toString(16).padStart(2,"0")).join("")}`}function Vd(i,e,t){const n=Vl(i),s=Vl(e);return!n||!s?t<1?i:e:Hd([tn(n[0],s[0],t),tn(n[1],s[1],t),tn(n[2],s[2],t)])}function Wd(i,e,t){const n={x:tn(i.bounds.x,e.bounds.x,t),y:tn(i.bounds.y,e.bounds.y,t),width:tn(i.bounds.width,e.bounds.width,t),height:tn(i.bounds.height,e.bounds.height,t)},s=tn(i.angle,e.angle,t),r=tn(i.transparency,e.transparency,t),a=tn(i.haloScale,e.haloScale,t),o=Vd(i.color,e.color,t),c=Vt.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:c,behindCloud:t<1?i.behindCloud:e.behindCloud,points:i.points.map((l,h)=>({x:tn(l.x,e.points[h].x,t),y:tn(l.y,e.points[h].y,t)}))}:{...t<1?i:e,bounds:n,angle:s,transparency:r,haloScale:a,color:o,angular:c}}class Ia{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?Wd(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&&Gd(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 Ia;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 Xd(i,e,t){return Math.max(e,Math.min(t,i))}function qd(i,e,t){const n=((e-i)%360+540)%360-180;return((i+n*t)%360+360)%360}function As(i,e,t){return i+(e-i)*t}function Yd(i,e,t){return{lat:i.lat===void 0||e.lat===void 0?void 0:As(i.lat,e.lat,t),lng:i.lng===void 0||e.lng===void 0?void 0:As(i.lng,e.lng,t),elevationM:As(i.elevationM,e.elevationM,t),headingDeg:i.headingDeg===void 0||e.headingDeg===void 0?void 0:qd(i.headingDeg,e.headingDeg,t),pitchDeg:As(i.pitchDeg,e.pitchDeg,t),fovDeg:As(i.fovDeg,e.fovDeg,t)}}class js{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?Yd(n.pose,s.pose,Xd((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 js;for(const n of e.keyframes)t.addKeyframe(n.t,n.pose);return t}}function ws(i,e,t){return i+(e-i)*t}function Kd(i,e,t){const n=((e-i)%360+540)%360-180;return((i+n*t)%360+360)%360}function Zd(i,e,t){return Math.max(e,Math.min(t,i))}function $d(i,e,t){return{cloudCover:ws(i.cloudCover,e.cloudCover,t),cloudDarkness:ws(i.cloudDarkness,e.cloudDarkness,t),cloudBaseM:i.cloudBaseM===void 0||e.cloudBaseM===void 0?void 0:ws(i.cloudBaseM,e.cloudBaseM,t),precipitationType:t<1?i.precipitationType:e.precipitationType,precipitationIntensity:ws(i.precipitationIntensity,e.precipitationIntensity,t),windDirectionDeg:Kd(i.windDirectionDeg,e.windDirectionDeg,t),windSpeed:ws(i.windSpeed,e.windSpeed,t),storm:t<1?i.storm:e.storm}}class er{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?$d(n.weather,s.weather,Zd((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 er;for(const n of e.keyframes)t.addKeyframe(n.t,n.weather);return t}}class tr{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 tr;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 s0=1e3,r0={cloudCover:0,cloudDarkness:0,precipitationType:"none",precipitationIntensity:0,windDirectionDeg:0,windSpeed:0,storm:!1},Jd=100,Qd={kind:"none",volume:0,pitchHz:Jd},Wl=[{id:"eye",name:"Naked eye",projection:"equidistant"},{id:"rectilinear-lens",name:"Camera, rectilinear lens",projection:"rectilinear"}];class jd{static get default(){return Wl[0]}static byId(e){return Wl.find(t=>t.id===e)??this.default}}function Yo(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 Xl(i){return(((i.day??0)*24+(i.hour??0))*60+(i.minute??0))*6e4+(i.second??0)*1e3}const ef=["year","month","day","hour","minute"],tf=["day","hour","minute"];function ql(i,e){return e.filter(t=>i[t]!==void 0).join(",")}function nf(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?ef:tf,n=ql(i.time,t);if(!(n===""||n!==ql(i.endTime,t)))return e?Yo(i.endTime)-Yo(i.time):Xl(i.endTime)-Xl(i.time)}class La{constructor(e,t,n,s,r,a,o,c,l=[],h,d){this.event=e,this.timeline=t,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=d}get instrument(){return jd.byId(this.instrumentId)}static create(e,t,n){return new La({eventType:"sighting",time:e,place:t},new Ia,new js,new er,new tr,n)}}const sf=0,rf=0,af=60;function $s(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:sf,headingDeg:void 0,pitchDeg:rf,fovDeg:af}}function Yl(i,e){return i.weatherTrack.getInterpolatedWeatherAt(e)??i.weather??r0}function of(i,e){return i.soundTrack.getInterpolatedSoundAt(e)??Qd}class cf{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 a0=["nw","n","ne","e","se","s","sw","w"],lf=24,fr=8,hf=3,uf=8;function pr(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 Rs(i){return{x:i.x+i.width/2,y:i.y+i.height/2}}const df={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 Yt{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=Rs(e.bounds),c={};for(const l of Object.keys(a))c[l]=pr(a[l],o,e.angle);return c}static hitTestHandle(e,t,n=8,s=[...a0,"rotate"]){const r=Yt.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=((Yt.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=Rs(e),a=pr(s,r,-t),{x:o,y:c,width:l,height:h}=e,d=df[n];let u=o,p=c,g=o+l,x=c+h;return d.left&&(u=Math.min(a.x,g-fr)),d.right&&(g=Math.max(a.x,u+fr)),d.top&&(p=Math.min(a.y,x-fr)),d.bottom&&(x=Math.max(a.y,p+fr)),{x:u,y:p,width:g-u,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=Yt.resizeBounds(e.bounds,e.angle,t,n);if(e.kind==="oval")return{...e,bounds:a};const o=s===0?1:a.width/s,c=r===0?1:a.height/r;return{...e,bounds:a,points:e.points.map(l=>({x:l.x*o,y:l.y*c}))}}static rotateShape(e,t){const n=Rs(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=Rs(e.bounds);return e.points.map(n=>pr({x:e.bounds.x+n.x,y:e.bounds.y+n.y},t,e.angle))}static hitTestVertex(e,t,n=uf){const s=Yt.vertexPointsFor(e);let r,a=n;return s.forEach((o,c)=>{const l=Math.hypot(t.x-o.x,t.y-o.y);l<=a&&(a=l,r=c)}),r}static toLocalPoint(e,t){const n=Rs(e.bounds),s=pr(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((d,u)=>u===t?Yt.toLocalPoint(e,n):d),r=Math.min(...s.map(d=>d.x)),a=Math.min(...s.map(d=>d.y)),o=Math.max(...s.map(d=>d.x)),c=Math.max(...s.map(d=>d.y)),l={x:e.bounds.x+r,y:e.bounds.y+a,width:o-r,height:c-a},h=s.map(d=>({x:d.x-r,y:d.y-a}));return{...e,bounds:l,points:h}}static insertVertexNear(e,t){const n=Yt.toLocalPoint(e,t),{points:s}=e;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],d=Yt.distanceToSegment(n,l,h);d<a&&(a=d,r=c)}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)),c=t.x+o*s,l=t.y+o*r;return Math.hypot(e.x-c,e.y-l)}static deleteVertex(e,t){return e.points.length<=hf?e:{...e,points:e.points.filter((n,s)=>s!==t)}}}const Ko=6,mr=Ko/2,ff=20,Kl=4;class pf{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=ff*e.haloScale,this.paintBase(e),this.ctx.restore()}paintSelectionHandles(e){this.paintHandleFrame(Yt.handlePointsFor(e),{includeRotate:!0}),e.kind==="polygon"&&this.paintVertexHandles(e)}paintVertexHandles(e){this.ctx.fillStyle="#39f";for(const t of Yt.vertexPointsFor(e))this.ctx.beginPath(),this.ctx.ellipse(t.x,t.y,Kl,Kl,0,0,2*Math.PI),this.ctx.fill()}paintMemberOutline(e){this.paintOutline(Yt.handlePointsFor(e))}paintGroupHandles(e){this.paintHandleFrame(Yt.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 a0){const s=e[n];this.ctx.fillRect(s.x-mr,s.y-mr,Ko,Ko)}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,mr+1,mr+1,0,0,2*Math.PI),this.ctx.fill())}}const Zl=.05,$l=.08,Jl=2,Ql=3,mf=14,gf=.02;class _f{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,Zl);for(const{param:r,ratio:a}of e.pitch)r.setTargetAtTime(Math.min(t.pitchHz*a,n.sampleRate/2-1),s,Zl)}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(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: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*Jl),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*Jl),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*Ql),e.sampleRate),n=t.getChannelData(0),s=Math.max(1,Math.floor(gf*e.sampleRate)),r=Math.round(Ql*mf);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=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,$l/3);const s=n+$l;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 Wa=Math.PI/180,gr=180/Math.PI;class us{constructor(e,t,n){this.kind=e,this.canvasHeightPx=t,this.fovDeg=n;const s=n*Wa/2;this.focalPx=e==="equidistant"?t/2/s:t/2/Math.tan(s)}focalPx;static of(e,t,n){return new us(e.projection,t,n)}degToPx(e){const t=e*Wa;return this.kind==="equidistant"?this.focalPx*t:2*this.focalPx*Math.tan(t/2)}pxToDeg(e){return this.kind==="equidistant"?e/this.focalPx*gr:2*Math.atan(e/(2*this.focalPx))*gr}angleDegToRadiusPx(e){const t=e*Wa;return this.kind==="equidistant"?this.focalPx*t:this.focalPx*Math.tan(t)}radiusPxToAngleDeg(e){return this.kind==="equidistant"?e/this.focalPx*gr:Math.atan(e/this.focalPx)*gr}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(Vt.angularWidthDeg(e))}}class dl{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,c=t.bounds.height===0?1:r/t.bounds.height;return{...t,bounds:a,points:t.points.map(l=>({x:l.x*o,y:l.y*c}))}})}static reproject(e,t){const n=Vt.CANVAS_WIDTH_PX/2,s=Vt.CANVAS_HEIGHT_PX/2;for(const r of[...e.timeline.allKeyframes]){const a=$s(e,r.t)?.fovDeg??this.DEFAULT_FOV_DEG,o=us.of(t,Vt.CANVAS_HEIGHT_PX,a),c=us.of(e.instrument,Vt.CANVAS_HEIGHT_PX,a);e.timeline.addKeyframe(r.t,r.shapes.map(l=>{const{bounds:h}=l.shape,d=h.x+h.width/2-n,u=h.y+h.height/2-s,p=Math.hypot(d,u);if(p===0)return l;const g=c.angleDegToRadiusPx(o.radiusPxToAngleDeg(p))/p,x={...h,x:n+d*g-h.width/2,y:s+u*g-h.height/2};return{...l,shape:{...l.shape,bounds:x}}}))}this.toBounds(e)}static eachKeyframe(e,t){const{timeline:n}=e;for(const s of[...n.allKeyframes]){const r=$s(e,s.t)?.fovDeg??this.DEFAULT_FOV_DEG,a=us.of(e.instrument,Vt.CANVAS_HEIGHT_PX,r);n.addKeyframe(s.t,s.shapes.map(o=>({...o,shape:t(o.shape,a)})))}}}function vf(i){return dl.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 xf(i){const e=new La({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},Ia.fromJSON(i.timeline),i.witnessTrack?js.fromJSON(i.witnessTrack):new js,i.weatherTrack?er.fromJSON(i.weatherTrack):new er,i.soundTrack?tr.fromJSON(i.soundTrack):new tr,i.witness,i.caseId,i.weather,i.decor??[],i.weatherSource,i.instrument);return dl.toBounds(e),e}function fl(i,e){for(const t of i){const n=t.toLowerCase().split("-")[0];if(e.includes(n))return n}return"en"}const Mf="modulepreload",Sf=function(i,e){return new URL(i,e).href},jl={},eh=function(e,t,n){let s=Promise.resolve();if(t&&t.length>0){let a=function(h){return Promise.all(h.map(d=>Promise.resolve(d).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};const o=document.getElementsByTagName("link"),c=document.querySelector("meta[property=csp-nonce]"),l=c?.nonce||c?.getAttribute("nonce");s=a(t.map(h=>{if(h=Sf(h,n),h in jl)return;jl[h]=!0;const d=h.endsWith(".css"),u=d?'[rel="stylesheet"]':"";if(!!n)for(let x=o.length-1;x>=0;x--){const m=o[x];if(m.href===h&&(!d||m.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${u}`))return;const g=document.createElement("link");if(g.rel=d?"stylesheet":Mf,d||(g.as="script"),g.crossOrigin="",g.href=h,l&&g.setAttribute("nonce",l),document.head.appendChild(g),d)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)})},yf=["en","fr"],Ef={en:()=>eh(()=>Promise.resolve().then(()=>Tf),void 0,import.meta.url).then(i=>i.ufoMessages_en),fr:()=>eh(()=>import("./UfoMessages_fr-NZrwNFCQ.js"),[],import.meta.url).then(i=>i.ufoMessages_fr)};function bf(i){return Ef[i]()}const o0={play:"Play",pause:"Pause",noDuration:"No observation duration",autoReplay:"Auto-replay",currentPosition:"Current position",duration:"Duration",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen"},Tf=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:o0},Symbol.toStringTag,{value:"Module"})),th=new Set;class Af extends HTMLElement{static get observedAttributes(){return["src"]}shadow;stageElement;canvas;canvasRenderer;tooltip;toolbar;playPauseButton;loopButton;fullscreenButton;seekInput;timeStartLabel;timeEndLabel;currentSighting=La.create();sightingAudio=new _f;soundPreview;player;loopEnabled=!0;highlightedSourceIds=new Set;occludedSourceIds=th;enableClickToPlay=!0;fullscreenTarget;messages=o0;realDurationMs;realStartMs;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>${kd}</style>${Bd}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new pf(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"),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 vf(this.currentSighting)}set sightingData(e){this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=xf(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??""}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:th;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=Yt.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(of(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 cf(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=fl(navigator.languages,yf);e!=="en"&&this.applyMessages(await bf(e))}applyMessages(e){this.messages=e,this.timeStartLabel.title=e.currentPosition,this.timeEndLabel.title=e.duration,this.loopButton.title=e.autoReplay,this.loopButton.setAttribute("aria-label",e.autoReplay),this.updatePlayPauseButton(),this.updateFullscreenButton()}updateTimeLabels(){const e=this.currentSighting.event,t=nf(e);this.realDurationMs=t!==void 0&&t>0?t:void 0,this.realStartMs=e.time?Yo(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)}formatPosition(e){if(this.realDurationMs===void 0)return _r(e);const t=this.currentSighting.timeline.duration,n=t>0&&e<=t?e/t*this.realDurationMs:e;return this.realStartMs!==void 0?ih(nh(this.realStartMs+n)):_r(n)}formatEndOfTimeline(){return this.realDurationMs===void 0?_r(this.currentSighting.timeline.duration):this.realStartMs!==void 0?ih(nh(this.realStartMs+this.realDurationMs)):_r(this.realDurationMs)}}function nh(i){const e=new Date(i);return{hour:e.getUTCHours(),minute:e.getUTCMinutes(),second:e.getUTCSeconds()}}function ih(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 _r(i){const e=Math.round(i/1e3),t=Math.floor(e/60),n=e%60;return`${t}:${String(n).padStart(2,"0")}`}const Zo="rr0-ufo";function c0(){customElements.get(Zo)||customElements.define(Zo,Af)}/**
|
|
300
|
+
`;class Wt{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/Wt.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 Dd(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 tn(i,e,t){return i+(e-i)*t}function zl(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 Id(i){return`#${i.map(e=>Math.round(e).toString(16).padStart(2,"0")).join("")}`}function Ld(i,e,t){const n=zl(i),s=zl(e);return!n||!s?t<1?i:e:Id([tn(n[0],s[0],t),tn(n[1],s[1],t),tn(n[2],s[2],t)])}function Nd(i,e,t){const n={x:tn(i.bounds.x,e.bounds.x,t),y:tn(i.bounds.y,e.bounds.y,t),width:tn(i.bounds.width,e.bounds.width,t),height:tn(i.bounds.height,e.bounds.height,t)},s=tn(i.angle,e.angle,t),r=tn(i.transparency,e.transparency,t),a=tn(i.haloScale,e.haloScale,t),o=Ld(i.color,e.color,t),c=Wt.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:c,behindCloud:t<1?i.behindCloud:e.behindCloud,points:i.points.map((l,h)=>({x:tn(l.x,e.points[h].x,t),y:tn(l.y,e.points[h].y,t)}))}:{...t<1?i:e,bounds:n,angle:s,transparency:r,haloScale:a,color:o,angular:c}}class wa{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?Nd(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&&Dd(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 wa;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 Ud(i,e,t){return Math.max(e,Math.min(t,i))}function Fd(i,e,t){const n=((e-i)%360+540)%360-180;return((i+n*t)%360+360)%360}function Rs(i,e,t){return i+(e-i)*t}function Od(i,e,t){return{lat:i.lat===void 0||e.lat===void 0?void 0:Rs(i.lat,e.lat,t),lng:i.lng===void 0||e.lng===void 0?void 0:Rs(i.lng,e.lng,t),elevationM:Rs(i.elevationM,e.elevationM,t),headingDeg:i.headingDeg===void 0||e.headingDeg===void 0?void 0:Fd(i.headingDeg,e.headingDeg,t),pitchDeg:Rs(i.pitchDeg,e.pitchDeg,t),fovDeg:Rs(i.fovDeg,e.fovDeg,t)}}class er{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?Od(n.pose,s.pose,Ud((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 er;for(const n of e.keyframes)t.addKeyframe(n.t,n.pose);return t}}function Cs(i,e,t){return i+(e-i)*t}function zd(i,e,t){const n=((e-i)%360+540)%360-180;return((i+n*t)%360+360)%360}function Bd(i,e,t){return Math.max(e,Math.min(t,i))}function kd(i,e,t){return{cloudCover:Cs(i.cloudCover,e.cloudCover,t),cloudDarkness:Cs(i.cloudDarkness,e.cloudDarkness,t),cloudBaseM:i.cloudBaseM===void 0||e.cloudBaseM===void 0?void 0:Cs(i.cloudBaseM,e.cloudBaseM,t),precipitationType:t<1?i.precipitationType:e.precipitationType,precipitationIntensity:Cs(i.precipitationIntensity,e.precipitationIntensity,t),windDirectionDeg:zd(i.windDirectionDeg,e.windDirectionDeg,t),windSpeed:Cs(i.windSpeed,e.windSpeed,t),storm:t<1?i.storm:e.storm}}class tr{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?kd(n.weather,s.weather,Bd((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 tr;for(const n of e.keyframes)t.addKeyframe(n.t,n.weather);return t}}class nr{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 nr;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 Zu=1e3,$u={cloudCover:0,cloudDarkness:0,precipitationType:"none",precipitationIntensity:0,windDirectionDeg:0,windSpeed:0,storm:!1},Gd=100,Hd={kind:"none",volume:0,pitchHz:Gd},Bl=[{id:"eye",name:"Naked eye",projection:"equidistant"},{id:"rectilinear-lens",name:"Camera, rectilinear lens",projection:"rectilinear"}];class Vd{static get default(){return Bl[0]}static byId(e){return Bl.find(t=>t.id===e)??this.default}}function Go(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 kl(i){return(((i.day??0)*24+(i.hour??0))*60+(i.minute??0))*6e4+(i.second??0)*1e3}const Wd=["year","month","day","hour","minute"],Xd=["day","hour","minute"];function Gl(i,e){return e.filter(t=>i[t]!==void 0).join(",")}function qd(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?Wd:Xd,n=Gl(i.time,t);if(!(n===""||n!==Gl(i.endTime,t)))return e?Go(i.endTime)-Go(i.time):kl(i.endTime)-kl(i.time)}class Ra{constructor(e,t,n,s,r,a,o,c,l=[],h,d){this.event=e,this.timeline=t,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=d}get instrument(){return Vd.byId(this.instrumentId)}static create(e,t,n){return new Ra({eventType:"sighting",time:e,place:t},new wa,new er,new tr,new nr,n)}}const Yd=0,Kd=0,Zd=60;function Js(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:Yd,headingDeg:void 0,pitchDeg:Kd,fovDeg:Zd}}function Hl(i,e){return i.weatherTrack.getInterpolatedWeatherAt(e)??i.weather??$u}function $d(i,e){return i.soundTrack.getInterpolatedSoundAt(e)??Hd}class Jd{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 Ju=["nw","n","ne","e","se","s","sw","w"],Qd=24,dr=8,jd=3,ef=8;function fr(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 Ps(i){return{x:i.x+i.width/2,y:i.y+i.height/2}}const tf={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 Kt{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-Qd}},o=Ps(e.bounds),c={};for(const l of Object.keys(a))c[l]=fr(a[l],o,e.angle);return c}static hitTestHandle(e,t,n=8,s=[...Ju,"rotate"]){const r=Kt.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=((Kt.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=Ps(e),a=fr(s,r,-t),{x:o,y:c,width:l,height:h}=e,d=tf[n];let u=o,p=c,g=o+l,M=c+h;return d.left&&(u=Math.min(a.x,g-dr)),d.right&&(g=Math.max(a.x,u+dr)),d.top&&(p=Math.min(a.y,M-dr)),d.bottom&&(M=Math.max(a.y,p+dr)),{x:u,y:p,width:g-u,height:M-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=Kt.resizeBounds(e.bounds,e.angle,t,n);if(e.kind==="oval")return{...e,bounds:a};const o=s===0?1:a.width/s,c=r===0?1:a.height/r;return{...e,bounds:a,points:e.points.map(l=>({x:l.x*o,y:l.y*c}))}}static rotateShape(e,t){const n=Ps(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=Ps(e.bounds);return e.points.map(n=>fr({x:e.bounds.x+n.x,y:e.bounds.y+n.y},t,e.angle))}static hitTestVertex(e,t,n=ef){const s=Kt.vertexPointsFor(e);let r,a=n;return s.forEach((o,c)=>{const l=Math.hypot(t.x-o.x,t.y-o.y);l<=a&&(a=l,r=c)}),r}static toLocalPoint(e,t){const n=Ps(e.bounds),s=fr(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((d,u)=>u===t?Kt.toLocalPoint(e,n):d),r=Math.min(...s.map(d=>d.x)),a=Math.min(...s.map(d=>d.y)),o=Math.max(...s.map(d=>d.x)),c=Math.max(...s.map(d=>d.y)),l={x:e.bounds.x+r,y:e.bounds.y+a,width:o-r,height:c-a},h=s.map(d=>({x:d.x-r,y:d.y-a}));return{...e,bounds:l,points:h}}static insertVertexNear(e,t){const n=Kt.toLocalPoint(e,t),{points:s}=e;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],d=Kt.distanceToSegment(n,l,h);d<a&&(a=d,r=c)}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)),c=t.x+o*s,l=t.y+o*r;return Math.hypot(e.x-c,e.y-l)}static deleteVertex(e,t){return e.points.length<=jd?e:{...e,points:e.points.filter((n,s)=>s!==t)}}}const Ho=6,pr=Ho/2,nf=20,Vl=4;class sf{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=nf*e.haloScale,this.paintBase(e),this.ctx.restore()}paintSelectionHandles(e){this.paintHandleFrame(Kt.handlePointsFor(e),{includeRotate:!0}),e.kind==="polygon"&&this.paintVertexHandles(e)}paintVertexHandles(e){this.ctx.fillStyle="#39f";for(const t of Kt.vertexPointsFor(e))this.ctx.beginPath(),this.ctx.ellipse(t.x,t.y,Vl,Vl,0,0,2*Math.PI),this.ctx.fill()}paintMemberOutline(e){this.paintOutline(Kt.handlePointsFor(e))}paintGroupHandles(e){this.paintHandleFrame(Kt.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 Ju){const s=e[n];this.ctx.fillRect(s.x-pr,s.y-pr,Ho,Ho)}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,pr+1,pr+1,0,0,2*Math.PI),this.ctx.fill())}}const Wl=.05,Xl=.08,ql=2,Yl=3,rf=14,af=.02;class of{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,Wl);for(const{param:r,ratio:a}of e.pitch)r.setTargetAtTime(Math.min(t.pitchHz*a,n.sampleRate/2-1),s,Wl)}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(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: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*ql),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*ql),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*Yl),e.sampleRate),n=t.getChannelData(0),s=Math.max(1,Math.floor(af*e.sampleRate)),r=Math.round(Yl*rf);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=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,Xl/3);const s=n+Xl;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 Ba=Math.PI/180,mr=180/Math.PI;class ds{constructor(e,t,n){this.kind=e,this.canvasHeightPx=t,this.fovDeg=n;const s=n*Ba/2;this.focalPx=e==="equidistant"?t/2/s:t/2/Math.tan(s)}focalPx;static of(e,t,n){return new ds(e.projection,t,n)}degToPx(e){const t=e*Ba;return this.kind==="equidistant"?this.focalPx*t:2*this.focalPx*Math.tan(t/2)}pxToDeg(e){return this.kind==="equidistant"?e/this.focalPx*mr:2*Math.atan(e/(2*this.focalPx))*mr}angleDegToRadiusPx(e){const t=e*Ba;return this.kind==="equidistant"?this.focalPx*t:this.focalPx*Math.tan(t)}radiusPxToAngleDeg(e){return this.kind==="equidistant"?e/this.focalPx*mr:Math.atan(e/this.focalPx)*mr}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(Wt.angularWidthDeg(e))}}class al{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,c=t.bounds.height===0?1:r/t.bounds.height;return{...t,bounds:a,points:t.points.map(l=>({x:l.x*o,y:l.y*c}))}})}static reproject(e,t){const n=Wt.CANVAS_WIDTH_PX/2,s=Wt.CANVAS_HEIGHT_PX/2;for(const r of[...e.timeline.allKeyframes]){const a=Js(e,r.t)?.fovDeg??this.DEFAULT_FOV_DEG,o=ds.of(t,Wt.CANVAS_HEIGHT_PX,a),c=ds.of(e.instrument,Wt.CANVAS_HEIGHT_PX,a);e.timeline.addKeyframe(r.t,r.shapes.map(l=>{const{bounds:h}=l.shape,d=h.x+h.width/2-n,u=h.y+h.height/2-s,p=Math.hypot(d,u);if(p===0)return l;const g=c.angleDegToRadiusPx(o.radiusPxToAngleDeg(p))/p,M={...h,x:n+d*g-h.width/2,y:s+u*g-h.height/2};return{...l,shape:{...l.shape,bounds:M}}}))}this.toBounds(e)}static eachKeyframe(e,t){const{timeline:n}=e;for(const s of[...n.allKeyframes]){const r=Js(e,s.t)?.fovDeg??this.DEFAULT_FOV_DEG,a=ds.of(e.instrument,Wt.CANVAS_HEIGHT_PX,r);n.addKeyframe(s.t,s.shapes.map(o=>({...o,shape:t(o.shape,a)})))}}}function cf(i){return al.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 lf(i){const e=new Ra({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},wa.fromJSON(i.timeline),i.witnessTrack?er.fromJSON(i.witnessTrack):new er,i.weatherTrack?tr.fromJSON(i.weatherTrack):new tr,i.soundTrack?nr.fromJSON(i.soundTrack):new nr,i.witness,i.caseId,i.weather,i.decor??[],i.weatherSource,i.instrument);return al.toBounds(e),e}function ol(i,e){for(const t of i){const n=t.toLowerCase().split("-")[0];if(e.includes(n))return n}return"en"}const hf="modulepreload",uf=function(i,e){return new URL(i,e).href},Kl={},Zl=function(e,t,n){let s=Promise.resolve();if(t&&t.length>0){let a=function(h){return Promise.all(h.map(d=>Promise.resolve(d).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};const o=document.getElementsByTagName("link"),c=document.querySelector("meta[property=csp-nonce]"),l=c?.nonce||c?.getAttribute("nonce");s=a(t.map(h=>{if(h=uf(h,n),h in Kl)return;Kl[h]=!0;const d=h.endsWith(".css"),u=d?'[rel="stylesheet"]':"";if(!!n)for(let M=o.length-1;M>=0;M--){const m=o[M];if(m.href===h&&(!d||m.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${u}`))return;const g=document.createElement("link");if(g.rel=d?"stylesheet":hf,d||(g.as="script"),g.crossOrigin="",g.href=h,l&&g.setAttribute("nonce",l),document.head.appendChild(g),d)return new Promise((M,m)=>{g.addEventListener("load",M),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)})},df=["en","fr"],ff={en:()=>Zl(()=>Promise.resolve().then(()=>mf),void 0,import.meta.url).then(i=>i.ufoMessages_en),fr:()=>Zl(()=>import("./UfoMessages_fr-Hq24iVzT.js"),[],import.meta.url).then(i=>i.ufoMessages_fr)};function pf(i){return ff[i]()}const Qu={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"},mf=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:Qu},Symbol.toStringTag,{value:"Module"})),$l=new Set;class gf extends HTMLElement{static get observedAttributes(){return["src"]}shadow;stageElement;canvas;canvasRenderer;tooltip;toolbar;playPauseButton;loopButton;fullscreenButton;seekInput;timeStartLabel;timeEndLabel;currentSighting=Ra.create();sightingAudio=new of;soundPreview;player;loopEnabled=!0;highlightedSourceIds=new Set;occludedSourceIds=$l;enableClickToPlay=!0;fullscreenTarget;messages=Qu;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>${Pd}</style>${Cd}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new sf(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 cf(this.currentSighting)}set sightingData(e){this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=lf(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:$l;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=Kt.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($d(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 Jd(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=ol(navigator.languages,df);e!=="en"&&this.applyMessages(await pf(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=qd(e);this.realDurationMs=t!==void 0&&t>0?t:void 0,this.realStartMs=e.time?Go(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 gr(e);const t=this.currentSighting.timeline.duration,n=t>0&&e<=t?e/t*this.realDurationMs:e;return this.canShowClockTime?Ql(Jl(this.realStartMs+n)):gr(n)}formatEndOfTimeline(){return this.realDurationMs===void 0?gr(this.currentSighting.timeline.duration):this.canShowClockTime?Ql(Jl(this.realStartMs+this.realDurationMs)):gr(this.realDurationMs)}}function Jl(i){const e=new Date(i);return{hour:e.getUTCHours(),minute:e.getUTCMinutes(),second:e.getUTCSeconds()}}function Ql(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 gr(i){const e=Math.round(i/1e3),t=Math.floor(e/60),n=e%60;return`${t}:${String(n).padStart(2,"0")}`}const Vo="rr0-ufo";function ju(){customElements.get(Vo)||customElements.define(Vo,gf)}/**
|
|
294
301
|
* @license
|
|
295
302
|
* Copyright 2010-2026 Three.js Authors
|
|
296
303
|
* SPDX-License-Identifier: MIT
|
|
297
|
-
*/const pl="185",wf=0,sh=1,Rf=2,Js=1,Cf=2,Ws=3,di=0,Pt=1,zn=2,Gn=0,ds=1,nr=2,rh=3,ah=4,Pf=5,Ei=100,Df=101,If=102,Lf=103,Nf=104,Uf=200,Ff=201,Of=202,zf=203,$o=204,Jo=205,Bf=206,kf=207,Gf=208,Hf=209,Vf=210,Wf=211,Xf=212,qf=213,Yf=214,Qo=0,jo=1,ec=2,vs=3,tc=4,nc=5,ic=6,sc=7,ml=0,Kf=1,Zf=2,Cn=0,l0=1,h0=2,u0=3,d0=4,f0=5,p0=6,m0=7,g0=300,Pi=301,xs=302,Xa=303,qa=304,Na=306,rc=1e3,Bn=1001,ac=1002,Ct=1003,$f=1004,vr=1005,Ut=1006,Ya=1007,Ai=1008,Zt=1009,_0=1010,v0=1011,ir=1012,gl=1013,Pn=1014,wn=1015,Vn=1016,_l=1017,vl=1018,sr=1020,x0=35902,M0=35899,S0=1021,y0=1022,dn=1023,Wn=1026,wi=1027,E0=1028,xl=1029,Di=1030,Ml=1031,Sl=1033,la=33776,ha=33777,ua=33778,da=33779,oc=35840,cc=35841,lc=35842,hc=35843,uc=36196,dc=37492,fc=37496,pc=37488,mc=37489,ga=37490,gc=37491,_c=37808,vc=37809,xc=37810,Mc=37811,Sc=37812,yc=37813,Ec=37814,bc=37815,Tc=37816,Ac=37817,wc=37818,Rc=37819,Cc=37820,Pc=37821,Dc=36492,Ic=36494,Lc=36495,Nc=36283,Uc=36284,_a=36285,Fc=36286,Jf=3200,Oc=0,Qf=1,oi="",nn="srgb",va="srgb-linear",xa="linear",Qe="srgb",Oi=7680,oh=519,jf=512,ep=513,tp=514,yl=515,np=516,ip=517,El=518,sp=519,zc=35044,ch="300 es",Rn=2e3,rr=2001;function rp(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function Ma(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function ap(){const i=Ma("canvas");return i.style.display="block",i}const lh={};function Sa(...i){const e="THREE."+i.shift();console.log(e,...i)}function b0(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 Fe(...i){i=b0(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function Xe(...i){i=b0(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function fs(...i){const e=i.join(" ");e in lh||(lh[e]=!0,Fe(...i))}function op(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 cp={[Qo]:jo,[ec]:ic,[tc]:sc,[vs]:nc,[jo]:Qo,[ic]:ec,[sc]:tc,[nc]:vs};class Ni{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 It=["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"],Ka=Math.PI/180,Bc=180/Math.PI;function hi(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(It[i&255]+It[i>>8&255]+It[i>>16&255]+It[i>>24&255]+"-"+It[e&255]+It[e>>8&255]+"-"+It[e>>16&15|64]+It[e>>24&255]+"-"+It[t&63|128]+It[t>>8&255]+"-"+It[t>>16&255]+It[t>>24&255]+It[n&255]+It[n>>8&255]+It[n>>16&255]+It[n>>24&255]).toLowerCase()}function Ye(i,e,t){return Math.max(e,Math.min(t,i))}function lp(i,e){return(i%e+e)%e}function Za(i,e,t){return(1-t)*i+t*e}function An(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 et(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 Oe{static{Oe.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=Ye(this.x,e.x,t.x),this.y=Ye(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Ye(this.x,e,t),this.y=Ye(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ye(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(Ye(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 Es{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 c=n[s+0],l=n[s+1],h=n[s+2],d=n[s+3],u=r[a+0],p=r[a+1],g=r[a+2],x=r[a+3];if(d!==x||c!==u||l!==p||h!==g){let m=c*u+l*p+h*g+d*x;m<0&&(u=-u,p=-p,g=-g,x=-x,m=-m);let f=1-o;if(m<.9995){const A=Math.acos(m),w=Math.sin(A);f=Math.sin(f*A)/w,o=Math.sin(o*A)/w,c=c*f+u*o,l=l*f+p*o,h=h*f+g*o,d=d*f+x*o}else{c=c*f+u*o,l=l*f+p*o,h=h*f+g*o,d=d*f+x*o;const A=1/Math.sqrt(c*c+l*l+h*h+d*d);c*=A,l*=A,h*=A,d*=A}}e[t]=c,e[t+1]=l,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,n,s,r,a){const o=n[s],c=n[s+1],l=n[s+2],h=n[s+3],d=r[a],u=r[a+1],p=r[a+2],g=r[a+3];return e[t]=o*g+h*d+c*p-l*u,e[t+1]=c*g+h*u+l*d-o*p,e[t+2]=l*g+h*p+o*u-c*d,e[t+3]=h*g-o*d-c*u-l*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,c=Math.sin,l=o(n/2),h=o(s/2),d=o(r/2),u=c(n/2),p=c(s/2),g=c(r/2);switch(a){case"XYZ":this._x=u*h*d+l*p*g,this._y=l*p*d-u*h*g,this._z=l*h*g+u*p*d,this._w=l*h*d-u*p*g;break;case"YXZ":this._x=u*h*d+l*p*g,this._y=l*p*d-u*h*g,this._z=l*h*g-u*p*d,this._w=l*h*d+u*p*g;break;case"ZXY":this._x=u*h*d-l*p*g,this._y=l*p*d+u*h*g,this._z=l*h*g+u*p*d,this._w=l*h*d-u*p*g;break;case"ZYX":this._x=u*h*d-l*p*g,this._y=l*p*d+u*h*g,this._z=l*h*g-u*p*d,this._w=l*h*d+u*p*g;break;case"YZX":this._x=u*h*d+l*p*g,this._y=l*p*d+u*h*g,this._z=l*h*g-u*p*d,this._w=l*h*d-u*p*g;break;case"XZY":this._x=u*h*d-l*p*g,this._y=l*p*d-u*h*g,this._z=l*h*g+u*p*d,this._w=l*h*d+u*p*g;break;default:Fe("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],c=t[9],l=t[2],h=t[6],d=t[10],u=n+o+d;if(u>0){const p=.5/Math.sqrt(u+1);this._w=.25/p,this._x=(h-c)*p,this._y=(r-l)*p,this._z=(a-s)*p}else if(n>o&&n>d){const p=2*Math.sqrt(1+n-o-d);this._w=(h-c)/p,this._x=.25*p,this._y=(s+a)/p,this._z=(r+l)/p}else if(o>d){const p=2*Math.sqrt(1+o-n-d);this._w=(r-l)/p,this._x=(s+a)/p,this._y=.25*p,this._z=(c+h)/p}else{const p=2*Math.sqrt(1+d-n-o);this._w=(a-s)/p,this._x=(r+l)/p,this._y=(c+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(Ye(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,c=t._y,l=t._z,h=t._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(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 c=1-t;if(o<.9995){const l=Math.acos(o),h=Math.sin(l);c=Math.sin(c*l)/h,t=Math.sin(t*l)/h,this._x=this._x*c+n*t,this._y=this._y*c+s*t,this._z=this._z*c+r*t,this._w=this._w*c+a*t,this._onChangeCallback()}else this._x=this._x*c+n*t,this._y=this._y*c+s*t,this._z=this._z*c+r*t,this._w=this._w*c+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(hh.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(hh.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,c=e.w,l=2*(a*s-o*n),h=2*(o*t-r*s),d=2*(r*n-a*t);return this.x=t+c*l+a*d-o*h,this.y=n+c*h+o*l-r*d,this.z=s+c*d+r*h-a*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,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=Ye(this.x,e.x,t.x),this.y=Ye(this.y,e.y,t.y),this.z=Ye(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Ye(this.x,e,t),this.y=Ye(this.y,e,t),this.z=Ye(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ye(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,c=t.z;return this.x=s*c-r*o,this.y=r*a-n*c,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 $a.copy(this).projectOnVector(e),this.sub($a)}reflect(e){return this.sub($a.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(Ye(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 $a=new U,hh=new Es;class ze{static{ze.prototype.isMatrix3=!0}constructor(e,t,n,s,r,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,a,o,c,l)}set(e,t,n,s,r,a,o,c,l){const h=this.elements;return h[0]=e,h[1]=s,h[2]=o,h[3]=t,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(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],c=n[6],l=n[1],h=n[4],d=n[7],u=n[2],p=n[5],g=n[8],x=s[0],m=s[3],f=s[6],A=s[1],w=s[4],M=s[7],y=s[2],b=s[5],R=s[8];return r[0]=a*x+o*A+c*y,r[3]=a*m+o*w+c*b,r[6]=a*f+o*M+c*R,r[1]=l*x+h*A+d*y,r[4]=l*m+h*w+d*b,r[7]=l*f+h*M+d*R,r[2]=u*x+p*A+g*y,r[5]=u*m+p*w+g*b,r[8]=u*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],c=e[6],l=e[7],h=e[8];return t*a*h-t*o*l-n*r*h+n*o*c+s*r*l-s*a*c}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],d=h*a-o*l,u=o*c-h*r,p=l*r-a*c,g=t*d+n*u+s*p;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/g;return e[0]=d*x,e[1]=(s*l-h*n)*x,e[2]=(o*n-s*a)*x,e[3]=u*x,e[4]=(h*t-s*c)*x,e[5]=(s*r-o*t)*x,e[6]=p*x,e[7]=(n*c-l*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 c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*a+l*o)+a+e,-s*l,s*c,-s*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return fs("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Ja.makeScale(e,t)),this}rotate(e){return fs("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Ja.makeRotation(-e)),this}translate(e,t){return fs("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Ja.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 Ja=new ze,uh=new ze().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),dh=new ze().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function hp(){const i={enabled:!0,workingColorSpace:va,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===Qe&&(s.r=Hn(s.r),s.g=Hn(s.g),s.b=Hn(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===Qe&&(s.r=ps(s.r),s.g=ps(s.g),s.b=ps(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===oi?xa: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 fs("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return fs("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({[va]:{primaries:e,whitePoint:n,transfer:xa,toXYZ:uh,fromXYZ:dh,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:nn},outputColorSpaceConfig:{drawingBufferColorSpace:nn}},[nn]:{primaries:e,whitePoint:n,transfer:Qe,toXYZ:uh,fromXYZ:dh,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:nn}}}),i}const qe=hp();function Hn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function ps(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let zi;class up{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{zi===void 0&&(zi=Ma("canvas")),zi.width=e.width,zi.height=e.height;const s=zi.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=zi}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=Ma("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]=Hn(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(Hn(t[n]/255)*255):t[n]=Hn(t[n]);return{data:t,width:e.width,height:e.height}}else return Fe("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let dp=0;class bl{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:dp++}),this.uuid=hi(),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(Qa(s[a].image)):r.push(Qa(s[a]))}else r=Qa(s);n.url=r}return t||(e.images[this.uuid]=n),n}}function Qa(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?up.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(Fe("Texture: Unable to serialize Texture."),{})}let fp=0;const ja=new U;class Ot extends Ni{constructor(e=Ot.DEFAULT_IMAGE,t=Ot.DEFAULT_MAPPING,n=Bn,s=Bn,r=Ut,a=Ai,o=dn,c=Zt,l=Ot.DEFAULT_ANISOTROPY,h=oi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:fp++}),this.uuid=hi(),this.name="",this.source=new bl(e),this.mipmaps=[],this.mapping=t,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 Oe(0,0),this.repeat=new Oe(1,1),this.center=new Oe(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(ja).x}get height(){return this.source.getSize(ja).y}get depth(){return this.source.getSize(ja).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){Fe(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Fe(`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!==g0)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case rc:e.x=e.x-Math.floor(e.x);break;case Bn:e.x=e.x<0?0:1;break;case ac: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 rc:e.y=e.y-Math.floor(e.y);break;case Bn:e.y=e.y<0?0:1;break;case ac: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++}}Ot.DEFAULT_IMAGE=null;Ot.DEFAULT_MAPPING=g0;Ot.DEFAULT_ANISOTROPY=1;class ht{static{ht.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 c=e.elements,l=c[0],h=c[4],d=c[8],u=c[1],p=c[5],g=c[9],x=c[2],m=c[6],f=c[10];if(Math.abs(h-u)<.01&&Math.abs(d-x)<.01&&Math.abs(g-m)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+x)<.1&&Math.abs(g+m)<.1&&Math.abs(l+p+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const w=(l+1)/2,M=(p+1)/2,y=(f+1)/2,b=(h+u)/4,R=(d+x)/4,v=(g+m)/4;return w>M&&w>y?w<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(w),s=b/n,r=R/n):M>y?M<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(M),n=b/s,r=v/s):y<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(y),n=R/r,s=v/r),this.set(n,s,r,t),this}let A=Math.sqrt((m-g)*(m-g)+(d-x)*(d-x)+(u-h)*(u-h));return Math.abs(A)<.001&&(A=1),this.x=(m-g)/A,this.y=(d-x)/A,this.z=(u-h)/A,this.w=Math.acos((l+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=Ye(this.x,e.x,t.x),this.y=Ye(this.y,e.y,t.y),this.z=Ye(this.z,e.z,t.z),this.w=Ye(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Ye(this.x,e,t),this.y=Ye(this.y,e,t),this.z=Ye(this.z,e,t),this.w=Ye(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ye(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 pp extends Ni{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ut,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 ht(0,0,e,t),this.scissorTest=!1,this.viewport=new ht(0,0,e,t),this.textures=[];const s={width:e,height:t,depth:n.depth},r=new Ot(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:Ut,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 bl(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 pn extends pp{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class T0 extends Ot{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=Ct,this.minFilter=Ct,this.wrapR=Bn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class mp extends Ot{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=Ct,this.minFilter=Ct,this.wrapR=Bn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class st{static{st.prototype.isMatrix4=!0}constructor(e,t,n,s,r,a,o,c,l,h,d,u,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,c,l,h,d,u,p,g,x,m)}set(e,t,n,s,r,a,o,c,l,h,d,u,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]=c,f[2]=l,f[6]=h,f[10]=d,f[14]=u,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 st().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/Bi.setFromMatrixColumn(e,0).length(),r=1/Bi.setFromMatrixColumn(e,1).length(),a=1/Bi.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),c=Math.cos(s),l=Math.sin(s),h=Math.cos(r),d=Math.sin(r);if(e.order==="XYZ"){const u=a*h,p=a*d,g=o*h,x=o*d;t[0]=c*h,t[4]=-c*d,t[8]=l,t[1]=p+g*l,t[5]=u-x*l,t[9]=-o*c,t[2]=x-u*l,t[6]=g+p*l,t[10]=a*c}else if(e.order==="YXZ"){const u=c*h,p=c*d,g=l*h,x=l*d;t[0]=u+x*o,t[4]=g*o-p,t[8]=a*l,t[1]=a*d,t[5]=a*h,t[9]=-o,t[2]=p*o-g,t[6]=x+u*o,t[10]=a*c}else if(e.order==="ZXY"){const u=c*h,p=c*d,g=l*h,x=l*d;t[0]=u-x*o,t[4]=-a*d,t[8]=g+p*o,t[1]=p+g*o,t[5]=a*h,t[9]=x-u*o,t[2]=-a*l,t[6]=o,t[10]=a*c}else if(e.order==="ZYX"){const u=a*h,p=a*d,g=o*h,x=o*d;t[0]=c*h,t[4]=g*l-p,t[8]=u*l+x,t[1]=c*d,t[5]=x*l+u,t[9]=p*l-g,t[2]=-l,t[6]=o*c,t[10]=a*c}else if(e.order==="YZX"){const u=a*c,p=a*l,g=o*c,x=o*l;t[0]=c*h,t[4]=x-u*d,t[8]=g*d+p,t[1]=d,t[5]=a*h,t[9]=-o*h,t[2]=-l*h,t[6]=p*d+g,t[10]=u-x*d}else if(e.order==="XZY"){const u=a*c,p=a*l,g=o*c,x=o*l;t[0]=c*h,t[4]=-d,t[8]=l*h,t[1]=u*d+x,t[5]=a*h,t[9]=p*d-g,t[2]=g*d-p,t[6]=o*h,t[10]=x*d+u}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,_p)}lookAt(e,t,n){const s=this.elements;return Xt.subVectors(e,t),Xt.lengthSq()===0&&(Xt.z=1),Xt.normalize(),$n.crossVectors(n,Xt),$n.lengthSq()===0&&(Math.abs(n.z)===1?Xt.x+=1e-4:Xt.z+=1e-4,Xt.normalize(),$n.crossVectors(n,Xt)),$n.normalize(),xr.crossVectors(Xt,$n),s[0]=$n.x,s[4]=xr.x,s[8]=Xt.x,s[1]=$n.y,s[5]=xr.y,s[9]=Xt.y,s[2]=$n.z,s[6]=xr.z,s[10]=Xt.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],c=n[8],l=n[12],h=n[1],d=n[5],u=n[9],p=n[13],g=n[2],x=n[6],m=n[10],f=n[14],A=n[3],w=n[7],M=n[11],y=n[15],b=s[0],R=s[4],v=s[8],E=s[12],P=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*P+c*q+l*Q,r[4]=a*R+o*C+c*F+l*te,r[8]=a*v+o*L+c*W+l*ee,r[12]=a*E+o*X+c*V+l*se,r[1]=h*b+d*P+u*q+p*Q,r[5]=h*R+d*C+u*F+p*te,r[9]=h*v+d*L+u*W+p*ee,r[13]=h*E+d*X+u*V+p*se,r[2]=g*b+x*P+m*q+f*Q,r[6]=g*R+x*C+m*F+f*te,r[10]=g*v+x*L+m*W+f*ee,r[14]=g*E+x*X+m*V+f*se,r[3]=A*b+w*P+M*q+y*Q,r[7]=A*R+w*C+M*F+y*te,r[11]=A*v+w*L+M*W+y*ee,r[15]=A*E+w*X+M*V+y*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],c=e[9],l=e[13],h=e[2],d=e[6],u=e[10],p=e[14],g=e[3],x=e[7],m=e[11],f=e[15],A=c*p-l*u,w=o*p-l*d,M=o*u-c*d,y=a*p-l*h,b=a*u-c*h,R=a*d-o*h;return t*(x*A-m*w+f*M)-n*(g*A-m*y+f*b)+s*(g*w-x*y+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],c=e[2],l=e[6],h=e[10];return t*(a*h-o*l)-n*(r*h-o*c)+s*(r*l-a*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,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],c=e[6],l=e[7],h=e[8],d=e[9],u=e[10],p=e[11],g=e[12],x=e[13],m=e[14],f=e[15],A=t*o-n*a,w=t*c-s*a,M=t*l-r*a,y=n*c-s*o,b=n*l-r*o,R=s*l-r*c,v=h*x-d*g,E=h*m-u*g,P=h*f-p*g,C=d*m-u*x,L=d*f-p*x,X=u*f-p*m,q=A*X-w*L+M*C+y*P-b*E+R*v;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-c*L+l*C)*F,e[1]=(s*L-n*X-r*C)*F,e[2]=(x*R-m*b+f*y)*F,e[3]=(u*b-d*R-p*y)*F,e[4]=(c*P-a*X-l*E)*F,e[5]=(t*X-s*P+r*E)*F,e[6]=(m*M-g*R-f*w)*F,e[7]=(h*R-u*M+p*w)*F,e[8]=(a*L-o*P+l*v)*F,e[9]=(n*P-t*L-r*v)*F,e[10]=(g*b-x*M+f*A)*F,e[11]=(d*M-h*b-p*A)*F,e[12]=(o*E-a*C-c*v)*F,e[13]=(t*C-n*E+s*v)*F,e[14]=(x*w-g*y-m*A)*F,e[15]=(h*y-d*w+u*A)*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,c=e.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(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,c=t._w,l=r+r,h=a+a,d=o+o,u=r*l,p=r*h,g=r*d,x=a*h,m=a*d,f=o*d,A=c*l,w=c*h,M=c*d,y=n.x,b=n.y,R=n.z;return s[0]=(1-(x+f))*y,s[1]=(p+M)*y,s[2]=(g-w)*y,s[3]=0,s[4]=(p-M)*b,s[5]=(1-(u+f))*b,s[6]=(m+A)*b,s[7]=0,s[8]=(g+w)*R,s[9]=(m-A)*R,s[10]=(1-(u+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=Bi.set(s[0],s[1],s[2]).length();const o=Bi.set(s[4],s[5],s[6]).length(),c=Bi.set(s[8],s[9],s[10]).length();r<0&&(a=-a),cn.copy(this);const l=1/a,h=1/o,d=1/c;return cn.elements[0]*=l,cn.elements[1]*=l,cn.elements[2]*=l,cn.elements[4]*=h,cn.elements[5]*=h,cn.elements[6]*=h,cn.elements[8]*=d,cn.elements[9]*=d,cn.elements[10]*=d,t.setFromRotationMatrix(cn),n.x=a,n.y=o,n.z=c,this}makePerspective(e,t,n,s,r,a,o=Rn,c=!1){const l=this.elements,h=2*r/(t-e),d=2*r/(n-s),u=(t+e)/(t-e),p=(n+s)/(n-s);let g,x;if(c)g=r/(a-r),x=a*r/(a-r);else if(o===Rn)g=-(a+r)/(a-r),x=-2*a*r/(a-r);else if(o===rr)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]=u,l[12]=0,l[1]=0,l[5]=d,l[9]=p,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(e,t,n,s,r,a,o=Rn,c=!1){const l=this.elements,h=2/(t-e),d=2/(n-s),u=-(t+e)/(t-e),p=-(n+s)/(n-s);let g,x;if(c)g=1/(a-r),x=a/(a-r);else if(o===Rn)g=-2/(a-r),x=-(a+r)/(a-r);else if(o===rr)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]=u,l[1]=0,l[5]=d,l[9]=0,l[13]=p,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(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 Bi=new U,cn=new st,gp=new U(0,0,0),_p=new U(1,1,1),$n=new U,xr=new U,Xt=new U,fh=new st,ph=new Es;class fi{constructor(e=0,t=0,n=0,s=fi.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],c=s[1],l=s[5],h=s[9],d=s[2],u=s[6],p=s[10];switch(t){case"XYZ":this._y=Math.asin(Ye(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Ye(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-d,r),this._z=0);break;case"ZXY":this._x=Math.asin(Ye(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-d,p),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-Ye(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(u,p),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Ye(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-d,r)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-Ye(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,p),this._y=0);break;default:Fe("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return fh.makeRotationFromQuaternion(e),this.setFromRotationMatrix(fh,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return ph.setFromEuler(this),this.setFromQuaternion(ph,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}}fi.DEFAULT_ORDER="XYZ";class Tl{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 mh=new U,ki=new Es,Dn=new st,Mr=new U,Cs=new U,xp=new U,Mp=new Es,gh=new U(1,0,0),_h=new U(0,1,0),vh=new U(0,0,1),xh={type:"added"},Sp={type:"removed"},Gi={type:"childadded",child:null},eo={type:"childremoved",child:null};class xt extends Ni{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:vp++}),this.uuid=hi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=xt.DEFAULT_UP.clone();const e=new U,t=new fi,n=new Es,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 st},normalMatrix:{value:new ze}}),this.matrix=new st,this.matrixWorld=new st,this.matrixAutoUpdate=xt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=xt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Tl,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 ki.setFromAxisAngle(e,t),this.quaternion.multiply(ki),this}rotateOnWorldAxis(e,t){return ki.setFromAxisAngle(e,t),this.quaternion.premultiply(ki),this}rotateX(e){return this.rotateOnAxis(gh,e)}rotateY(e){return this.rotateOnAxis(_h,e)}rotateZ(e){return this.rotateOnAxis(vh,e)}translateOnAxis(e,t){return mh.copy(e).applyQuaternion(this.quaternion),this.position.add(mh.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(gh,e)}translateY(e){return this.translateOnAxis(_h,e)}translateZ(e){return this.translateOnAxis(vh,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Dn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Mr.copy(e):Mr.set(e,t,n);const s=this.parent;this.updateWorldMatrix(!0,!1),Cs.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Dn.lookAt(Cs,Mr,this.up):Dn.lookAt(Mr,Cs,this.up),this.quaternion.setFromRotationMatrix(Dn),s&&(Dn.extractRotation(s.matrixWorld),ki.setFromRotationMatrix(Dn),this.quaternion.premultiply(ki.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Xe("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(xh),Gi.child=e,this.dispatchEvent(Gi),Gi.child=null):Xe("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(Sp),eo.child=e,this.dispatchEvent(eo),eo.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),Dn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Dn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Dn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(xh),Gi.child=e,this.dispatchEvent(Gi),Gi.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(Cs,e,xp),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Cs,Mp,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,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.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 c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){const d=c[l];r(e.shapes,d)}else r(e.shapes,c)}}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 c=0,l=this.material.length;c<l;c++)o.push(r(e.materials,this.material[c]));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 c=this.animations[o];s.animations.push(r(e.animations,c))}}if(t){const o=a(e.geometries),c=a(e.materials),l=a(e.textures),h=a(e.images),d=a(e.shapes),u=a(e.skeletons),p=a(e.animations),g=a(e.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),d.length>0&&(n.shapes=d),u.length>0&&(n.skeletons=u),p.length>0&&(n.animations=p),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(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}}xt.DEFAULT_UP=new U(0,1,0);xt.DEFAULT_MATRIX_AUTO_UPDATE=!0;xt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class fn extends xt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const yp={type:"move"};class to{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new fn,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 fn,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 fn,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,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(const x of e.hand.values()){const m=t.getJointPose(x,n),f=this._getHandJoint(l,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=l.joints["index-finger-tip"],d=l.joints["thumb-tip"],u=h.position.distanceTo(d.position),p=.02,g=.005;l.inputState.pinching&&u>p+g?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&u<=p-g&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(r=t.getPose(e.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: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),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new fn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.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},Jn={h:0,s:0,l:0},Sr={h:0,s:0,l:0};function no(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=nn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,qe.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=qe.workingColorSpace){return this.r=e,this.g=t,this.b=n,qe.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=qe.workingColorSpace){if(e=lp(e,1),t=Ye(t,0,1),n=Ye(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=no(a,r,e+1/3),this.g=no(a,r,e),this.b=no(a,r,e-1/3)}return qe.colorSpaceToWorking(this,s),this}setStyle(e,t=nn){function n(r){r!==void 0&&parseFloat(r)<1&&Fe("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:Fe("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);Fe("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=nn){const n=A0[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Fe("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=Hn(e.r),this.g=Hn(e.g),this.b=Hn(e.b),this}copyLinearToSRGB(e){return this.r=ps(e.r),this.g=ps(e.g),this.b=ps(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=nn){return qe.workingToColorSpace(Lt.copy(this),e),Math.round(Ye(Lt.r*255,0,255))*65536+Math.round(Ye(Lt.g*255,0,255))*256+Math.round(Ye(Lt.b*255,0,255))}getHexString(e=nn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=qe.workingColorSpace){qe.workingToColorSpace(Lt.copy(this),t);const n=Lt.r,s=Lt.g,r=Lt.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 d=a-o;switch(l=h<=.5?d/(a+o):d/(2-a-o),a){case n:c=(s-r)/d+(s<r?6:0);break;case s:c=(r-n)/d+2;break;case r:c=(n-s)/d+4;break}c/=6}return e.h=c,e.s=l,e.l=h,e}getRGB(e,t=qe.workingColorSpace){return qe.workingToColorSpace(Lt.copy(this),t),e.r=Lt.r,e.g=Lt.g,e.b=Lt.b,e}getStyle(e=nn){qe.workingToColorSpace(Lt.copy(this),e);const t=Lt.r,n=Lt.g,s=Lt.b;return e!==nn?`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(Jn),this.setHSL(Jn.h+e,Jn.s+t,Jn.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(Jn),e.getHSL(Sr);const n=Za(Jn.h,Sr.h,t),s=Za(Jn.s,Sr.s,t),r=Za(Jn.l,Sr.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 Lt=new xe;xe.NAMES=A0;class Al{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 Al(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class w0 extends xt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new fi,this.environmentIntensity=1,this.environmentRotation=new fi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(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 ln=new U,In=new U,io=new U,Ln=new U,Hi=new U,Vi=new U,Mh=new U,so=new U,ro=new U,ao=new U,oo=new ht,co=new ht,lo=new ht;class sn{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),ln.subVectors(e,t),s.cross(ln);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){ln.subVectors(s,t),In.subVectors(n,t),io.subVectors(e,t);const a=ln.dot(ln),o=ln.dot(In),c=ln.dot(io),l=In.dot(In),h=In.dot(io),d=a*l-o*o;if(d===0)return r.set(0,0,0),null;const u=1/d,p=(l*c-o*h)*u,g=(a*h-o*c)*u;return r.set(1-p-g,g,p)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,Ln)===null?!1:Ln.x>=0&&Ln.y>=0&&Ln.x+Ln.y<=1}static getInterpolation(e,t,n,s,r,a,o,c){return this.getBarycoord(e,t,n,s,Ln)===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,Ln.x),c.addScaledVector(a,Ln.y),c.addScaledVector(o,Ln.z),c)}static getInterpolatedAttribute(e,t,n,s,r,a){return oo.setScalar(0),co.setScalar(0),lo.setScalar(0),oo.fromBufferAttribute(e,t),co.fromBufferAttribute(e,n),lo.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(oo,r.x),a.addScaledVector(co,r.y),a.addScaledVector(lo,r.z),a}static isFrontFacing(e,t,n,s){return ln.subVectors(n,t),In.subVectors(e,t),ln.cross(In).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 ln.subVectors(this.c,this.b),In.subVectors(this.a,this.b),ln.cross(In).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return sn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return sn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,r){return sn.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}containsPoint(e){return sn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return sn.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;Hi.subVectors(s,n),Vi.subVectors(r,n),so.subVectors(e,n);const c=Hi.dot(so),l=Vi.dot(so);if(c<=0&&l<=0)return t.copy(n);ro.subVectors(e,s);const h=Hi.dot(ro),d=Vi.dot(ro);if(h>=0&&d<=h)return t.copy(s);const u=c*d-h*l;if(u<=0&&c>=0&&h<=0)return a=c/(c-h),t.copy(n).addScaledVector(Hi,a);ao.subVectors(e,r);const p=Hi.dot(ao),g=Vi.dot(ao);if(g>=0&&p<=g)return t.copy(r);const x=p*l-c*g;if(x<=0&&l>=0&&g<=0)return o=l/(l-g),t.copy(n).addScaledVector(Vi,o);const m=h*g-p*d;if(m<=0&&d-h>=0&&p-g>=0)return Mh.subVectors(r,s),o=(d-h)/(d-h+(p-g)),t.copy(s).addScaledVector(Mh,o);const f=1/(m+x+u);return a=x*f,o=u*f,t.copy(n).addScaledVector(Hi,a).addScaledVector(Vi,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class or{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(hn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(hn.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=hn.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,hn):hn.fromBufferAttribute(r,a),hn.applyMatrix4(e.matrixWorld),this.expandByPoint(hn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),yr.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),yr.copy(n.boundingBox)),yr.applyMatrix4(e.matrixWorld),this.union(yr)}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,hn),hn.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(Ps),Er.subVectors(this.max,Ps),Wi.subVectors(e.a,Ps),Xi.subVectors(e.b,Ps),qi.subVectors(e.c,Ps),Qn.subVectors(Xi,Wi),jn.subVectors(qi,Xi),_i.subVectors(Wi,qi);let t=[0,-Qn.z,Qn.y,0,-jn.z,jn.y,0,-_i.z,_i.y,Qn.z,0,-Qn.x,jn.z,0,-jn.x,_i.z,0,-_i.x,-Qn.y,Qn.x,0,-jn.y,jn.x,0,-_i.y,_i.x,0];return!ho(t,Wi,Xi,qi,Er)||(t=[1,0,0,0,1,0,0,0,1],!ho(t,Wi,Xi,qi,Er))?!1:(br.crossVectors(Qn,jn),t=[br.x,br.y,br.z],ho(t,Wi,Xi,qi,Er))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,hn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(hn).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:(Nn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Nn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Nn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Nn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Nn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Nn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Nn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Nn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Nn),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 Nn=[new U,new U,new U,new U,new U,new U,new U,new U],hn=new U,yr=new or,Wi=new U,Xi=new U,qi=new U,Qn=new U,jn=new U,_i=new U,Ps=new U,Er=new U,br=new U,vi=new U;function ho(i,e,t,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){vi.fromArray(i,r);const o=s.x*Math.abs(vi.x)+s.y*Math.abs(vi.y)+s.z*Math.abs(vi.z),c=e.dot(vi),l=t.dot(vi),h=n.dot(vi);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}const Et=new U,Tr=new Oe;let Ep=0;class lt extends Ni{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:Ep++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=zc,this.updateRanges=[],this.gpuType=wn,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++)Tr.fromBufferAttribute(this,t),Tr.applyMatrix3(e),this.setXY(t,Tr.x,Tr.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=An(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=et(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=An(t,this.array)),t}setX(e,t){return this.normalized&&(t=et(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=An(t,this.array)),t}setY(e,t){return this.normalized&&(t=et(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=An(t,this.array)),t}setZ(e,t){return this.normalized&&(t=et(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=An(t,this.array)),t}setW(e,t){return this.normalized&&(t=et(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=et(t,this.array),n=et(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=et(t,this.array),n=et(n,this.array),s=et(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=et(t,this.array),n=et(n,this.array),s=et(s,this.array),r=et(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!==zc&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class R0 extends lt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class C0 extends lt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Mt extends lt{constructor(e,t,n){super(new Float32Array(e),t,n)}}const bp=new or,Ds=new U,uo=new U;class cr{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):bp.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;Ds.subVectors(e,this.center);const t=Ds.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(Ds,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):(uo.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ds.copy(e.center).add(uo)),this.expandByPoint(Ds.copy(e.center).sub(uo))),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 Tp=0;const Jt=new st,fo=new xt,Yi=new U,qt=new or,Is=new or,At=new U;class St extends Ni{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Tp++}),this.uuid=hi(),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(rp(e)?C0:R0)(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 Jt.makeRotationFromQuaternion(e),this.applyMatrix4(Jt),this}rotateX(e){return Jt.makeRotationX(e),this.applyMatrix4(Jt),this}rotateY(e){return Jt.makeRotationY(e),this.applyMatrix4(Jt),this}rotateZ(e){return Jt.makeRotationZ(e),this.applyMatrix4(Jt),this}translate(e,t,n){return Jt.makeTranslation(e,t,n),this.applyMatrix4(Jt),this}scale(e,t,n){return Jt.makeScale(e,t,n),this.applyMatrix4(Jt),this}lookAt(e){return fo.lookAt(e),fo.updateMatrix(),this.applyMatrix4(fo.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Yi).negate(),this.translate(Yi.x,Yi.y,Yi.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 Mt(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&&Fe("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 or);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Xe("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?(At.addVectors(this.boundingBox.min,qt.min),this.boundingBox.expandByPoint(At),At.addVectors(this.boundingBox.max,qt.max),this.boundingBox.expandByPoint(At)):(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))&&Xe('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 cr);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Xe("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];Is.setFromBufferAttribute(o),this.morphTargetsRelative?(At.addVectors(qt.min,Is.min),qt.expandByPoint(At),At.addVectors(qt.max,Is.max),qt.expandByPoint(At)):(qt.expandByPoint(Is.min),qt.expandByPoint(Is.max))}qt.getCenter(n);let s=0;for(let r=0,a=e.count;r<a;r++)At.fromBufferAttribute(e,r),s=Math.max(s,n.distanceToSquared(At));if(t)for(let r=0,a=t.length;r<a;r++){const o=t[r],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)At.fromBufferAttribute(o,l),c&&(Yi.fromBufferAttribute(e,l),At.add(Yi)),s=Math.max(s,n.distanceToSquared(At))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&Xe('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){Xe("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 lt(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));const o=[],c=[];for(let v=0;v<n.count;v++)o[v]=new U,c[v]=new U;const l=new U,h=new U,d=new U,u=new Oe,p=new Oe,g=new Oe,x=new U,m=new U;function f(v,E,P){l.fromBufferAttribute(n,v),h.fromBufferAttribute(n,E),d.fromBufferAttribute(n,P),u.fromBufferAttribute(r,v),p.fromBufferAttribute(r,E),g.fromBufferAttribute(r,P),h.sub(l),d.sub(l),p.sub(u),g.sub(u);const C=1/(p.x*g.y-g.x*p.y);isFinite(C)&&(x.copy(h).multiplyScalar(g.y).addScaledVector(d,-p.y).multiplyScalar(C),m.copy(d).multiplyScalar(p.x).addScaledVector(h,-g.x).multiplyScalar(C),o[v].add(x),o[E].add(x),o[P].add(x),c[v].add(m),c[E].add(m),c[P].add(m))}let A=this.groups;A.length===0&&(A=[{start:0,count:e.count}]);for(let v=0,E=A.length;v<E;++v){const P=A[v],C=P.start,L=P.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 w=new U,M=new U,y=new U,b=new U;function R(v){y.fromBufferAttribute(s,v),b.copy(y);const E=o[v];w.copy(E),w.sub(y.multiplyScalar(y.dot(E))).normalize(),M.crossVectors(b,E);const C=M.dot(c[v])<0?-1:1;a.setXYZW(v,w.x,w.y,w.z,C)}for(let v=0,E=A.length;v<E;++v){const P=A[v],C=P.start,L=P.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 lt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let u=0,p=n.count;u<p;u++)n.setXYZ(u,0,0,0);const s=new U,r=new U,a=new U,o=new U,c=new U,l=new U,h=new U,d=new U;if(e)for(let u=0,p=e.count;u<p;u+=3){const g=e.getX(u+0),x=e.getX(u+1),m=e.getX(u+2);s.fromBufferAttribute(t,g),r.fromBufferAttribute(t,x),a.fromBufferAttribute(t,m),h.subVectors(a,r),d.subVectors(s,r),h.cross(d),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 u=0,p=t.count;u<p;u+=3)s.fromBufferAttribute(t,u+0),r.fromBufferAttribute(t,u+1),a.fromBufferAttribute(t,u+2),h.subVectors(a,r),d.subVectors(s,r),h.cross(d),n.setXYZ(u+0,h.x,h.y,h.z),n.setXYZ(u+1,h.x,h.y,h.z),n.setXYZ(u+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++)At.fromBufferAttribute(e,t),At.normalize(),e.setXYZ(t,At.x,At.y,At.z)}toNonIndexed(){function e(o,c){const l=o.array,h=o.itemSize,d=o.normalized,u=new l.constructor(c.length*h);let p=0,g=0;for(let x=0,m=c.length;x<m;x++){o.isInterleavedBufferAttribute?p=c[x]*o.data.stride+o.offset:p=c[x]*h;for(let f=0;f<h;f++)u[g++]=l[p++]}return new lt(u,h,d)}if(this.index===null)return Fe("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new St,n=this.index.array,s=this.attributes;for(const o in s){const c=s[o],l=e(c,n);t.setAttribute(o,l)}const r=this.morphAttributes;for(const o in r){const c=[],l=r[o];for(let h=0,d=l.length;h<d;h++){const u=l[h],p=e(u,n);c.push(p)}t.morphAttributes[o]=c}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;o++){const l=a[o];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const c in n){const l=n[c];e.data.attributes[c]=l.toJSON(e.data)}const s={};let r=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],h=[];for(let d=0,u=l.length;d<u;d++){const p=l[d];h.push(p.toJSON(e.data))}h.length>0&&(s[c]=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 l in s){const h=s[l];this.setAttribute(l,h.clone(t))}const r=e.morphAttributes;for(const l in r){const h=[],d=r[l];for(let u=0,p=d.length;u<p;u++)h.push(d[u].clone(t));this.morphAttributes[l]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let l=0,h=a.length;l<h;l++){const d=a[l];this.addGroup(d.start,d.count,d.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Ap{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=zc,this.updateRanges=[],this.version=0,this.uuid=hi()}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=hi()),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=hi()),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 Bt=new U;class ya{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++)Bt.fromBufferAttribute(this,t),Bt.applyMatrix4(e),this.setXYZ(t,Bt.x,Bt.y,Bt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Bt.fromBufferAttribute(this,t),Bt.applyNormalMatrix(e),this.setXYZ(t,Bt.x,Bt.y,Bt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Bt.fromBufferAttribute(this,t),Bt.transformDirection(e),this.setXYZ(t,Bt.x,Bt.y,Bt.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=An(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=et(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=et(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=et(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=et(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=et(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=An(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=An(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=An(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=An(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=et(t,this.array),n=et(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=et(t,this.array),n=et(n,this.array),s=et(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=et(t,this.array),n=et(n,this.array),s=et(s,this.array),r=et(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){Sa("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 lt(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 ya(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){Sa("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 wp=0;class pi extends Ni{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:wp++}),this.uuid=hi(),this.name="",this.type="Material",this.blending=ds,this.side=di,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=$o,this.blendDst=Jo,this.blendEquation=Ei,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new xe(0,0,0),this.blendAlpha=0,this.depthFunc=vs,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=oh,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Oi,this.stencilZFail=Oi,this.stencilZPass=Oi,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){Fe(`Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Fe(`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!==ds&&(n.blending=this.blending),this.side!==di&&(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!==$o&&(n.blendSrc=this.blendSrc),this.blendDst!==Jo&&(n.blendDst=this.blendDst),this.blendEquation!==Ei&&(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!==vs&&(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!==Oi&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Oi&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Oi&&(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(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 Oe().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 Oe().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 Xs extends pi{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 Ki;const Ls=new U,Zi=new U,$i=new U,Ji=new Oe,Ns=new Oe,P0=new st,Ar=new U,Us=new U,wr=new U,Sh=new Oe,po=new Oe,yh=new Oe;class Rr extends xt{constructor(e=new Xs){if(super(),this.isSprite=!0,this.type="Sprite",Ki===void 0){Ki=new St;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 Ap(t,5);Ki.setIndex([0,1,2,0,2,3]),Ki.setAttribute("position",new ya(n,3,0,!1)),Ki.setAttribute("uv",new ya(n,2,3,!1))}this.geometry=Ki,this.material=e,this.center=new Oe(.5,.5),this.count=1}raycast(e,t){e.camera===null&&Xe('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Zi.setFromMatrixScale(this.matrixWorld),P0.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),$i.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Zi.multiplyScalar(-$i.z);const n=this.material.rotation;let s,r;n!==0&&(r=Math.cos(n),s=Math.sin(n));const a=this.center;Cr(Ar.set(-.5,-.5,0),$i,a,Zi,s,r),Cr(Us.set(.5,-.5,0),$i,a,Zi,s,r),Cr(wr.set(.5,.5,0),$i,a,Zi,s,r),Sh.set(0,0),po.set(1,0),yh.set(1,1);let o=e.ray.intersectTriangle(Ar,Us,wr,!1,Ls);if(o===null&&(Cr(Us.set(-.5,.5,0),$i,a,Zi,s,r),po.set(0,1),o=e.ray.intersectTriangle(Ar,wr,Us,!1,Ls),o===null))return;const c=e.ray.origin.distanceTo(Ls);c<e.near||c>e.far||t.push({distance:c,point:Ls.clone(),uv:sn.getInterpolation(Ls,Ar,Us,wr,Sh,po,yh,new Oe),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 Cr(i,e,t,n,s,r){Ji.subVectors(i,t).addScalar(.5).multiply(n),s!==void 0?(Ns.x=r*Ji.x-s*Ji.y,Ns.y=s*Ji.x+r*Ji.y):Ns.copy(Ji),i.copy(e),i.x+=Ns.x,i.y+=Ns.y,i.applyMatrix4(P0)}const Un=new U,mo=new U,Pr=new U,ei=new U,go=new U,Dr=new U,_o=new U;class Ua{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,Un)),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=Un.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Un.copy(this.origin).addScaledVector(this.direction,t),Un.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){mo.copy(e).add(t).multiplyScalar(.5),Pr.copy(t).sub(e).normalize(),ei.copy(this.origin).sub(mo);const r=e.distanceTo(t)*.5,a=-this.direction.dot(Pr),o=ei.dot(this.direction),c=-ei.dot(Pr),l=ei.lengthSq(),h=Math.abs(1-a*a);let d,u,p,g;if(h>0)if(d=a*c-o,u=a*o-c,g=r*h,d>=0)if(u>=-g)if(u<=g){const x=1/h;d*=x,u*=x,p=d*(d+a*u+2*o)+u*(a*d+u+2*c)+l}else u=r,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*c)+l;else u=-r,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*c)+l;else u<=-g?(d=Math.max(0,-(-a*r+o)),u=d>0?-r:Math.min(Math.max(-r,-c),r),p=-d*d+u*(u+2*c)+l):u<=g?(d=0,u=Math.min(Math.max(-r,-c),r),p=u*(u+2*c)+l):(d=Math.max(0,-(a*r+o)),u=d>0?r:Math.min(Math.max(-r,-c),r),p=-d*d+u*(u+2*c)+l);else u=a>0?-r:r,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(mo).addScaledVector(Pr,u),p}intersectSphere(e,t){Un.subVectors(e.center,this.origin);const n=Un.dot(this.direction),s=Un.dot(Un)-n*n,r=e.radius*e.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,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,c;const l=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,u=this.origin;return l>=0?(n=(e.min.x-u.x)*l,s=(e.max.x-u.x)*l):(n=(e.max.x-u.x)*l,s=(e.min.x-u.x)*l),h>=0?(r=(e.min.y-u.y)*h,a=(e.max.y-u.y)*h):(r=(e.max.y-u.y)*h,a=(e.min.y-u.y)*h),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a<s||isNaN(s))&&(s=a),d>=0?(o=(e.min.z-u.z)*d,c=(e.max.z-u.z)*d):(o=(e.max.z-u.z)*d,c=(e.min.z-u.z)*d),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,t)}intersectsBox(e){return this.intersectBox(e,Un)!==null}intersectTriangle(e,t,n,s,r){go.subVectors(t,e),Dr.subVectors(n,e),_o.crossVectors(go,Dr);let a=this.direction.dot(_o),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;ei.subVectors(this.origin,e);const c=o*this.direction.dot(Dr.crossVectors(ei,Dr));if(c<0)return null;const l=o*this.direction.dot(go.cross(ei));if(l<0||c+l>a)return null;const h=-o*ei.dot(_o);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 ar extends pi{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 fi,this.combine=ml,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 Eh=new st,xi=new Ua,Ir=new cr,bh=new U,Lr=new U,Nr=new U,Ur=new U,vo=new U,Fr=new U,Th=new U,Or=new U;class ut extends xt{constructor(e=new St,t=new ar){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){Fr.set(0,0,0);for(let c=0,l=r.length;c<l;c++){const h=o[c],d=r[c];h!==0&&(vo.fromBufferAttribute(d,e),a?Fr.addScaledVector(vo,h):Fr.addScaledVector(vo.sub(t),h))}t.add(Fr)}return t}raycast(e,t){const n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Ir.copy(n.boundingSphere),Ir.applyMatrix4(r),xi.copy(e.ray).recast(e.near),!(Ir.containsPoint(xi.origin)===!1&&(xi.intersectSphere(Ir,bh)===null||xi.origin.distanceToSquared(bh)>(e.far-e.near)**2))&&(Eh.copy(r).invert(),xi.copy(e.ray).applyMatrix4(Eh),!(n.boundingBox!==null&&xi.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,xi)))}_computeIntersections(e,t,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,d=r.attributes.normal,u=r.groups,p=r.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,x=u.length;g<x;g++){const m=u[g],f=a[m.materialIndex],A=Math.max(m.start,p.start),w=Math.min(o.count,Math.min(m.start+m.count,p.start+p.count));for(let M=A,y=w;M<y;M+=3){const b=o.getX(M),R=o.getX(M+1),v=o.getX(M+2);s=zr(this,f,e,n,l,h,d,b,R,v),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 A=o.getX(m),w=o.getX(m+1),M=o.getX(m+2);s=zr(this,a,e,n,l,h,d,A,w,M),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}else if(c!==void 0)if(Array.isArray(a))for(let g=0,x=u.length;g<x;g++){const m=u[g],f=a[m.materialIndex],A=Math.max(m.start,p.start),w=Math.min(c.count,Math.min(m.start+m.count,p.start+p.count));for(let M=A,y=w;M<y;M+=3){const b=M,R=M+1,v=M+2;s=zr(this,f,e,n,l,h,d,b,R,v),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(c.count,p.start+p.count);for(let m=g,f=x;m<f;m+=3){const A=m,w=m+1,M=m+2;s=zr(this,a,e,n,l,h,d,A,w,M),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}}}function Rp(i,e,t,n,s,r,a,o){let c;if(e.side===Pt?c=n.intersectTriangle(a,r,s,!0,o):c=n.intersectTriangle(s,r,a,e.side===di,o),c===null)return null;Or.copy(o),Or.applyMatrix4(i.matrixWorld);const l=t.ray.origin.distanceTo(Or);return l<t.near||l>t.far?null:{distance:l,point:Or.clone(),object:i}}function zr(i,e,t,n,s,r,a,o,c,l){i.getVertexPosition(o,Lr),i.getVertexPosition(c,Nr),i.getVertexPosition(l,Ur);const h=Rp(i,e,t,n,Lr,Nr,Ur,Th);if(h){const d=new U;sn.getBarycoord(Th,Lr,Nr,Ur,d),s&&(h.uv=sn.getInterpolatedAttribute(s,o,c,l,d,new Oe)),r&&(h.uv1=sn.getInterpolatedAttribute(r,o,c,l,d,new Oe)),a&&(h.normal=sn.getInterpolatedAttribute(a,o,c,l,d,new U),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const u={a:o,b:c,c:l,normal:new U,materialIndex:0};sn.getNormal(Lr,Nr,Ur,u.normal),h.face=u,h.barycoord=d}return h}class Cp extends Ot{constructor(e=null,t=1,n=1,s,r,a,o,c,l=Ct,h=Ct,d,u){super(null,a,o,c,l,h,s,r,d,u),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const xo=new U,Pp=new U,Dp=new ze;class yi{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=xo.subVectors(n,t).cross(Pp.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(xo),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||Dp.getNormalMatrix(e),s=this.coplanarPoint(xo).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 Mi=new cr,Ip=new Oe(.5,.5),Br=new U;class wl{constructor(e=new yi,t=new yi,n=new yi,s=new yi,r=new yi,a=new yi){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=Rn,n=!1){const s=this.planes,r=e.elements,a=r[0],o=r[1],c=r[2],l=r[3],h=r[4],d=r[5],u=r[6],p=r[7],g=r[8],x=r[9],m=r[10],f=r[11],A=r[12],w=r[13],M=r[14],y=r[15];if(s[0].setComponents(l-a,p-h,f-g,y-A).normalize(),s[1].setComponents(l+a,p+h,f+g,y+A).normalize(),s[2].setComponents(l+o,p+d,f+x,y+w).normalize(),s[3].setComponents(l-o,p-d,f-x,y-w).normalize(),n)s[4].setComponents(c,u,m,M).normalize(),s[5].setComponents(l-c,p-u,f-m,y-M).normalize();else if(s[4].setComponents(l-c,p-u,f-m,y-M).normalize(),t===Rn)s[5].setComponents(l+c,p+u,f+m,y+M).normalize();else if(t===rr)s[5].setComponents(c,u,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(),Mi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Mi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Mi)}intersectsSprite(e){Mi.center.set(0,0,0);const t=Ip.distanceTo(e.center);return Mi.radius=.7071067811865476+t,Mi.applyMatrix4(e.matrixWorld),this.intersectsSphere(Mi)}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(Br.x=s.normal.x>0?e.max.x:e.min.x,Br.y=s.normal.y>0?e.max.y:e.min.y,Br.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(Br)<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 D0 extends pi{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new xe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Ea=new U,ba=new U,Ah=new st,Fs=new Ua,kr=new cr,Mo=new U,wh=new U;class Lp extends xt{constructor(e=new St,t=new D0){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let s=1,r=t.count;s<r;s++)Ea.fromBufferAttribute(t,s-1),ba.fromBufferAttribute(t,s),n[s]=n[s-1],n[s]+=Ea.distanceTo(ba);e.setAttribute("lineDistance",new Mt(n,1))}else Fe("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,s=this.matrixWorld,r=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),kr.copy(n.boundingSphere),kr.applyMatrix4(s),kr.radius+=r,e.ray.intersectsSphere(kr)===!1)return;Ah.copy(s).invert(),Fs.copy(e.ray).applyMatrix4(Ah);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=this.isLineSegments?2:1,h=n.index,u=n.attributes.position;if(h!==null){const p=Math.max(0,a.start),g=Math.min(h.count,a.start+a.count);for(let x=p,m=g-1;x<m;x+=l){const f=h.getX(x),A=h.getX(x+1),w=Gr(this,e,Fs,c,f,A,x);w&&t.push(w)}if(this.isLineLoop){const x=h.getX(g-1),m=h.getX(p),f=Gr(this,e,Fs,c,x,m,g-1);f&&t.push(f)}}else{const p=Math.max(0,a.start),g=Math.min(u.count,a.start+a.count);for(let x=p,m=g-1;x<m;x+=l){const f=Gr(this,e,Fs,c,x,x+1,x);f&&t.push(f)}if(this.isLineLoop){const x=Gr(this,e,Fs,c,g-1,p,g-1);x&&t.push(x)}}}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 Gr(i,e,t,n,s,r,a){const o=i.geometry.attributes.position;if(Ea.fromBufferAttribute(o,s),ba.fromBufferAttribute(o,r),t.distanceSqToSegment(Ea,ba,Mo,wh)>n)return;Mo.applyMatrix4(i.matrixWorld);const l=e.ray.origin.distanceTo(Mo);if(!(l<e.near||l>e.far))return{distance:l,point:wh.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}const Rh=new U,Ch=new U;class Np extends Lp{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let s=0,r=t.count;s<r;s+=2)Rh.fromBufferAttribute(t,s),Ch.fromBufferAttribute(t,s+1),n[s]=s===0?0:n[s-1],n[s+1]=n[s]+Rh.distanceTo(Ch);e.setAttribute("lineDistance",new Mt(n,1))}else Fe("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class I0 extends pi{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 Ph=new st,kc=new Ua,Hr=new cr,Vr=new U;class fa extends xt{constructor(e=new St,t=new I0){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(),Hr.copy(n.boundingSphere),Hr.applyMatrix4(s),Hr.radius+=r,e.ray.intersectsSphere(Hr)===!1)return;Ph.copy(s).invert(),kc.copy(e.ray).applyMatrix4(Ph);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=n.index,d=n.attributes.position;if(l!==null){const u=Math.max(0,a.start),p=Math.min(l.count,a.start+a.count);for(let g=u,x=p;g<x;g++){const m=l.getX(g);Vr.fromBufferAttribute(d,m),Dh(Vr,m,c,s,e,t,this)}}else{const u=Math.max(0,a.start),p=Math.min(d.count,a.start+a.count);for(let g=u,x=p;g<x;g++)Vr.fromBufferAttribute(d,g),Dh(Vr,g,c,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 Dh(i,e,t,n,s,r,a){const o=kc.distanceSqToPoint(i);if(o<t){const c=new U;kc.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:e,face:null,faceIndex:null,barycoord:null,object:a})}}class L0 extends Ot{constructor(e=[],t=Pi,n,s,r,a,o,c,l,h){super(e,t,n,s,r,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class qn extends Ot{constructor(e,t,n,s,r,a,o,c,l){super(e,t,n,s,r,a,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Ms extends Ot{constructor(e,t,n=Pn,s,r,a,o=Ct,c=Ct,l,h=Wn,d=1){if(h!==Wn&&h!==wi)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const u={width:e,height:t,depth:d};super(u,s,r,a,o,c,h,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new bl(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 Up extends Ms{constructor(e,t=Pn,n=Pi,s,r,a=Ct,o=Ct,c,l=Wn){const h={width:e,height:e,depth:1},d=[h,h,h,h,h,h];super(e,e,t,n,s,r,a,o,c,l),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class N0 extends Ot{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class rn extends St{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 c=[],l=[],h=[],d=[];let u=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(c),this.setAttribute("position",new Mt(l,3)),this.setAttribute("normal",new Mt(h,3)),this.setAttribute("uv",new Mt(d,2));function g(x,m,f,A,w,M,y,b,R,v,E){const P=M/R,C=y/v,L=M/2,X=y/2,q=b/2,F=R+1,W=v+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*P-L;te[x]=Ve*A,te[m]=se*w,te[f]=q,l.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),d.push(ge/R),d.push(1-ee/v),V+=1}}for(let ee=0;ee<v;ee++)for(let se=0;se<R;se++){const ge=u+se+F*ee,Ve=u+se+F*(ee+1),rt=u+(se+1)+F*(ee+1),We=u+(se+1)+F*ee;c.push(ge,Ve,We),c.push(Ve,rt,We),Q+=6}o.addGroup(p,Q,E),p+=Q,u+=V}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new rn(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class Rl extends St{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=[],c=[],l=new U,h=new Oe;a.push(0,0,0),o.push(0,0,1),c.push(.5,.5);for(let d=0,u=3;d<=t;d++,u+=3){const p=n+d/t*s;l.x=e*Math.cos(p),l.y=e*Math.sin(p),a.push(l.x,l.y,l.z),o.push(0,0,1),h.x=(a[u]/e+1)/2,h.y=(a[u+1]/e+1)/2,c.push(h.x,h.y)}for(let d=1;d<=t;d++)r.push(d,d+1,0);this.setIndex(r),this.setAttribute("position",new Mt(a,3)),this.setAttribute("normal",new Mt(o,3)),this.setAttribute("uv",new Mt(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Rl(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class mi extends St{constructor(e=1,t=1,n=1,s=32,r=1,a=!1,o=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,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=[],d=[],u=[],p=[];let g=0;const x=[],m=n/2;let f=0;A(),a===!1&&(e>0&&w(!0),t>0&&w(!1)),this.setIndex(h),this.setAttribute("position",new Mt(d,3)),this.setAttribute("normal",new Mt(u,3)),this.setAttribute("uv",new Mt(p,2));function A(){const M=new U,y=new U;let b=0;const R=(t-e)/n;for(let v=0;v<=r;v++){const E=[],P=v/r,C=P*(t-e)+e;for(let L=0;L<=s;L++){const X=L/s,q=X*c+o,F=Math.sin(q),W=Math.cos(q);y.x=C*F,y.y=-P*n+m,y.z=C*W,d.push(y.x,y.y,y.z),M.set(F,R,W).normalize(),u.push(M.x,M.y,M.z),p.push(X,1-P),E.push(g++)}x.push(E)}for(let v=0;v<s;v++)for(let E=0;E<r;E++){const P=x[E][v],C=x[E+1][v],L=x[E+1][v+1],X=x[E][v+1];(e>0||E!==0)&&(h.push(P,C,X),b+=3),(t>0||E!==r-1)&&(h.push(C,L,X),b+=3)}l.addGroup(f,b,0),f+=b}function w(M){const y=g,b=new Oe,R=new U;let v=0;const E=M===!0?e:t,P=M===!0?1:-1;for(let L=1;L<=s;L++)d.push(0,m*P,0),u.push(0,P,0),p.push(.5,.5),g++;const C=g;for(let L=0;L<=s;L++){const q=L/s*c+o,F=Math.cos(q),W=Math.sin(q);R.x=E*W,R.y=m*P,R.z=E*F,d.push(R.x,R.y,R.z),u.push(0,P,0),b.x=F*.5+.5,b.y=W*.5*P+.5,p.push(b.x,b.y),g++}for(let L=0;L<s;L++){const X=y+L,q=C+L;M===!0?h.push(q,q+1,X):h.push(q+1,q,X),v+=3}l.addGroup(f,v,M===!0?1:2),f+=v}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new mi(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Fa extends mi{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 Fa(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class bs extends St{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),c=Math.floor(s),l=o+1,h=c+1,d=e/o,u=t/c,p=[],g=[],x=[],m=[];for(let f=0;f<h;f++){const A=f*u-a;for(let w=0;w<l;w++){const M=w*d-r;g.push(M,-A,0),x.push(0,0,1),m.push(w/o),m.push(1-f/c)}}for(let f=0;f<c;f++)for(let A=0;A<o;A++){const w=A+l*f,M=A+l*(f+1),y=A+1+l*(f+1),b=A+1+l*f;p.push(w,M,b),p.push(M,y,b)}this.setIndex(p),this.setAttribute("position",new Mt(g,3)),this.setAttribute("normal",new Mt(x,3)),this.setAttribute("uv",new Mt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new bs(e.width,e.height,e.widthSegments,e.heightSegments)}}class Xn extends St{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 c=Math.min(a+o,Math.PI);let l=0;const h=[],d=new U,u=new U,p=[],g=[],x=[],m=[];for(let f=0;f<=n;f++){const A=[],w=f/n,M=a+w*o,y=e*Math.cos(M),b=Math.sqrt(e*e-y*y);let R=0;f===0&&a===0?R=.5/t:f===n&&c===Math.PI&&(R=-.5/t);for(let v=0;v<=t;v++){const E=v/t,P=s+E*r;d.x=-b*Math.cos(P),d.y=y,d.z=b*Math.sin(P),g.push(d.x,d.y,d.z),u.copy(d).normalize(),x.push(u.x,u.y,u.z),m.push(E+R,1-w),A.push(l++)}h.push(A)}for(let f=0;f<n;f++)for(let A=0;A<t;A++){const w=h[f][A+1],M=h[f][A],y=h[f+1][A],b=h[f+1][A+1];(f!==0||a>0)&&p.push(w,M,b),(f!==n-1||c<Math.PI)&&p.push(M,y,b)}this.setIndex(p),this.setAttribute("position",new Mt(g,3)),this.setAttribute("normal",new Mt(x,3)),this.setAttribute("uv",new Mt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Xn(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}function Ss(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const s=i[t][n];if(Ih(s))s.isRenderTargetTexture?(Fe("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(Ih(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 kt(i){const e={};for(let t=0;t<i.length;t++){const n=Ss(i[t]);for(const s in n)e[s]=n[s]}return e}function Ih(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function Fp(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function U0(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:qe.workingColorSpace}const Op={clone:Ss,merge:kt};var zp=`void main() {
|
|
304
|
+
*/const cl="185",_f=0,jl=1,vf=2,Qs=1,xf=2,Xs=3,di=0,Dt=1,An=2,Gn=0,fs=1,ir=2,eh=3,th=4,Mf=5,yi=100,Sf=101,yf=102,Ef=103,bf=104,Tf=200,Af=201,wf=202,Rf=203,Wo=204,Xo=205,Cf=206,Pf=207,Df=208,If=209,Lf=210,Nf=211,Uf=212,Ff=213,Of=214,qo=0,Yo=1,Ko=2,xs=3,Zo=4,$o=5,Jo=6,Qo=7,ll=0,zf=1,Bf=2,Pn=0,e0=1,t0=2,n0=3,i0=4,s0=5,r0=6,a0=7,o0=300,Pi=301,Ms=302,ka=303,Ga=304,Ca=306,jo=1e3,Bn=1001,ec=1002,Pt=1003,kf=1004,_r=1005,Ft=1006,Ha=1007,Ai=1008,$t=1009,c0=1010,l0=1011,sr=1012,hl=1013,Dn=1014,Rn=1015,Vn=1016,ul=1017,dl=1018,rr=1020,h0=35902,u0=35899,d0=1021,f0=1022,dn=1023,Wn=1026,wi=1027,p0=1028,fl=1029,Di=1030,pl=1031,ml=1033,aa=33776,oa=33777,ca=33778,la=33779,tc=35840,nc=35841,ic=35842,sc=35843,rc=36196,ac=37492,oc=37496,cc=37488,lc=37489,fa=37490,hc=37491,uc=37808,dc=37809,fc=37810,pc=37811,mc=37812,gc=37813,_c=37814,vc=37815,xc=37816,Mc=37817,Sc=37818,yc=37819,Ec=37820,bc=37821,Tc=36492,Ac=36494,wc=36495,Rc=36283,Cc=36284,pa=36285,Pc=36286,Gf=3200,Dc=0,Hf=1,oi="",nn="srgb",ma="srgb-linear",ga="linear",Qe="srgb",zi=7680,nh=519,Vf=512,Wf=513,Xf=514,gl=515,qf=516,Yf=517,_l=518,Kf=519,Ic=35044,ih="300 es",Cn=2e3,ar=2001;function Zf(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function _a(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function $f(){const i=_a("canvas");return i.style.display="block",i}const sh={};function va(...i){const e="THREE."+i.shift();console.log(e,...i)}function m0(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=m0(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function Xe(...i){i=m0(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function ps(...i){const e=i.join(" ");e in sh||(sh[e]=!0,Oe(...i))}function Jf(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 Qf={[qo]:Yo,[Ko]:Jo,[Zo]:Qo,[xs]:$o,[Yo]:qo,[Jo]:Ko,[Qo]:Zo,[$o]:xs};class Ni{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 Lt=["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"],Va=Math.PI/180,Lc=180/Math.PI;function hi(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Lt[i&255]+Lt[i>>8&255]+Lt[i>>16&255]+Lt[i>>24&255]+"-"+Lt[e&255]+Lt[e>>8&255]+"-"+Lt[e>>16&15|64]+Lt[e>>24&255]+"-"+Lt[t&63|128]+Lt[t>>8&255]+"-"+Lt[t>>16&255]+Lt[t>>24&255]+Lt[n&255]+Lt[n>>8&255]+Lt[n>>16&255]+Lt[n>>24&255]).toLowerCase()}function Ye(i,e,t){return Math.max(e,Math.min(t,i))}function jf(i,e){return(i%e+e)%e}function Wa(i,e,t){return(1-t)*i+t*e}function wn(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 et(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=Ye(this.x,e.x,t.x),this.y=Ye(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Ye(this.x,e,t),this.y=Ye(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ye(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(Ye(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 Ts{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 c=n[s+0],l=n[s+1],h=n[s+2],d=n[s+3],u=r[a+0],p=r[a+1],g=r[a+2],M=r[a+3];if(d!==M||c!==u||l!==p||h!==g){let m=c*u+l*p+h*g+d*M;m<0&&(u=-u,p=-p,g=-g,M=-M,m=-m);let f=1-o;if(m<.9995){const T=Math.acos(m),w=Math.sin(T);f=Math.sin(f*T)/w,o=Math.sin(o*T)/w,c=c*f+u*o,l=l*f+p*o,h=h*f+g*o,d=d*f+M*o}else{c=c*f+u*o,l=l*f+p*o,h=h*f+g*o,d=d*f+M*o;const T=1/Math.sqrt(c*c+l*l+h*h+d*d);c*=T,l*=T,h*=T,d*=T}}e[t]=c,e[t+1]=l,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,n,s,r,a){const o=n[s],c=n[s+1],l=n[s+2],h=n[s+3],d=r[a],u=r[a+1],p=r[a+2],g=r[a+3];return e[t]=o*g+h*d+c*p-l*u,e[t+1]=c*g+h*u+l*d-o*p,e[t+2]=l*g+h*p+o*u-c*d,e[t+3]=h*g-o*d-c*u-l*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,c=Math.sin,l=o(n/2),h=o(s/2),d=o(r/2),u=c(n/2),p=c(s/2),g=c(r/2);switch(a){case"XYZ":this._x=u*h*d+l*p*g,this._y=l*p*d-u*h*g,this._z=l*h*g+u*p*d,this._w=l*h*d-u*p*g;break;case"YXZ":this._x=u*h*d+l*p*g,this._y=l*p*d-u*h*g,this._z=l*h*g-u*p*d,this._w=l*h*d+u*p*g;break;case"ZXY":this._x=u*h*d-l*p*g,this._y=l*p*d+u*h*g,this._z=l*h*g+u*p*d,this._w=l*h*d-u*p*g;break;case"ZYX":this._x=u*h*d-l*p*g,this._y=l*p*d+u*h*g,this._z=l*h*g-u*p*d,this._w=l*h*d+u*p*g;break;case"YZX":this._x=u*h*d+l*p*g,this._y=l*p*d+u*h*g,this._z=l*h*g-u*p*d,this._w=l*h*d-u*p*g;break;case"XZY":this._x=u*h*d-l*p*g,this._y=l*p*d-u*h*g,this._z=l*h*g+u*p*d,this._w=l*h*d+u*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],c=t[9],l=t[2],h=t[6],d=t[10],u=n+o+d;if(u>0){const p=.5/Math.sqrt(u+1);this._w=.25/p,this._x=(h-c)*p,this._y=(r-l)*p,this._z=(a-s)*p}else if(n>o&&n>d){const p=2*Math.sqrt(1+n-o-d);this._w=(h-c)/p,this._x=.25*p,this._y=(s+a)/p,this._z=(r+l)/p}else if(o>d){const p=2*Math.sqrt(1+o-n-d);this._w=(r-l)/p,this._x=(s+a)/p,this._y=.25*p,this._z=(c+h)/p}else{const p=2*Math.sqrt(1+d-n-o);this._w=(a-s)/p,this._x=(r+l)/p,this._y=(c+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(Ye(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,c=t._y,l=t._z,h=t._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(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 c=1-t;if(o<.9995){const l=Math.acos(o),h=Math.sin(l);c=Math.sin(c*l)/h,t=Math.sin(t*l)/h,this._x=this._x*c+n*t,this._y=this._y*c+s*t,this._z=this._z*c+r*t,this._w=this._w*c+a*t,this._onChangeCallback()}else this._x=this._x*c+n*t,this._y=this._y*c+s*t,this._z=this._z*c+r*t,this._w=this._w*c+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(rh.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(rh.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,c=e.w,l=2*(a*s-o*n),h=2*(o*t-r*s),d=2*(r*n-a*t);return this.x=t+c*l+a*d-o*h,this.y=n+c*h+o*l-r*d,this.z=s+c*d+r*h-a*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,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=Ye(this.x,e.x,t.x),this.y=Ye(this.y,e.y,t.y),this.z=Ye(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Ye(this.x,e,t),this.y=Ye(this.y,e,t),this.z=Ye(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ye(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,c=t.z;return this.x=s*c-r*o,this.y=r*a-n*c,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 Xa.copy(this).projectOnVector(e),this.sub(Xa)}reflect(e){return this.sub(Xa.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(Ye(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 Xa=new U,rh=new Ts;class ze{static{ze.prototype.isMatrix3=!0}constructor(e,t,n,s,r,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,a,o,c,l)}set(e,t,n,s,r,a,o,c,l){const h=this.elements;return h[0]=e,h[1]=s,h[2]=o,h[3]=t,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(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],c=n[6],l=n[1],h=n[4],d=n[7],u=n[2],p=n[5],g=n[8],M=s[0],m=s[3],f=s[6],T=s[1],w=s[4],x=s[7],y=s[2],b=s[5],R=s[8];return r[0]=a*M+o*T+c*y,r[3]=a*m+o*w+c*b,r[6]=a*f+o*x+c*R,r[1]=l*M+h*T+d*y,r[4]=l*m+h*w+d*b,r[7]=l*f+h*x+d*R,r[2]=u*M+p*T+g*y,r[5]=u*m+p*w+g*b,r[8]=u*f+p*x+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],c=e[6],l=e[7],h=e[8];return t*a*h-t*o*l-n*r*h+n*o*c+s*r*l-s*a*c}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],d=h*a-o*l,u=o*c-h*r,p=l*r-a*c,g=t*d+n*u+s*p;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const M=1/g;return e[0]=d*M,e[1]=(s*l-h*n)*M,e[2]=(o*n-s*a)*M,e[3]=u*M,e[4]=(h*t-s*c)*M,e[5]=(s*r-o*t)*M,e[6]=p*M,e[7]=(n*c-l*t)*M,e[8]=(a*t-n*r)*M,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 c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*a+l*o)+a+e,-s*l,s*c,-s*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return ps("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(qa.makeScale(e,t)),this}rotate(e){return ps("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(qa.makeRotation(-e)),this}translate(e,t){return ps("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(qa.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 qa=new ze,ah=new ze().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),oh=new ze().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function ep(){const i={enabled:!0,workingColorSpace:ma,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===Qe&&(s.r=Hn(s.r),s.g=Hn(s.g),s.b=Hn(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===Qe&&(s.r=ms(s.r),s.g=ms(s.g),s.b=ms(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===oi?ga: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 ps("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return ps("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({[ma]:{primaries:e,whitePoint:n,transfer:ga,toXYZ:ah,fromXYZ:oh,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:nn},outputColorSpaceConfig:{drawingBufferColorSpace:nn}},[nn]:{primaries:e,whitePoint:n,transfer:Qe,toXYZ:ah,fromXYZ:oh,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:nn}}}),i}const qe=ep();function Hn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function ms(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let Bi;class tp{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{Bi===void 0&&(Bi=_a("canvas")),Bi.width=e.width,Bi.height=e.height;const s=Bi.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=Bi}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=_a("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]=Hn(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(Hn(t[n]/255)*255):t[n]=Hn(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 np=0;class vl{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:np++}),this.uuid=hi(),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(Ya(s[a].image)):r.push(Ya(s[a]))}else r=Ya(s);n.url=r}return t||(e.images[this.uuid]=n),n}}function Ya(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?tp.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 ip=0;const Ka=new U;class zt extends Ni{constructor(e=zt.DEFAULT_IMAGE,t=zt.DEFAULT_MAPPING,n=Bn,s=Bn,r=Ft,a=Ai,o=dn,c=$t,l=zt.DEFAULT_ANISOTROPY,h=oi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:ip++}),this.uuid=hi(),this.name="",this.source=new vl(e),this.mipmaps=[],this.mapping=t,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 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(Ka).x}get height(){return this.source.getSize(Ka).y}get depth(){return this.source.getSize(Ka).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!==o0)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case jo:e.x=e.x-Math.floor(e.x);break;case Bn:e.x=e.x<0?0:1;break;case ec: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 jo:e.y=e.y-Math.floor(e.y);break;case Bn:e.y=e.y<0?0:1;break;case ec: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++}}zt.DEFAULT_IMAGE=null;zt.DEFAULT_MAPPING=o0;zt.DEFAULT_ANISOTROPY=1;class ut{static{ut.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 c=e.elements,l=c[0],h=c[4],d=c[8],u=c[1],p=c[5],g=c[9],M=c[2],m=c[6],f=c[10];if(Math.abs(h-u)<.01&&Math.abs(d-M)<.01&&Math.abs(g-m)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+M)<.1&&Math.abs(g+m)<.1&&Math.abs(l+p+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const w=(l+1)/2,x=(p+1)/2,y=(f+1)/2,b=(h+u)/4,R=(d+M)/4,v=(g+m)/4;return w>x&&w>y?w<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(w),s=b/n,r=R/n):x>y?x<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(x),n=b/s,r=v/s):y<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(y),n=R/r,s=v/r),this.set(n,s,r,t),this}let T=Math.sqrt((m-g)*(m-g)+(d-M)*(d-M)+(u-h)*(u-h));return Math.abs(T)<.001&&(T=1),this.x=(m-g)/T,this.y=(d-M)/T,this.z=(u-h)/T,this.w=Math.acos((l+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=Ye(this.x,e.x,t.x),this.y=Ye(this.y,e.y,t.y),this.z=Ye(this.z,e.z,t.z),this.w=Ye(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Ye(this.x,e,t),this.y=Ye(this.y,e,t),this.z=Ye(this.z,e,t),this.w=Ye(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ye(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 sp extends Ni{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ft,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 ut(0,0,e,t),this.scissorTest=!1,this.viewport=new ut(0,0,e,t),this.textures=[];const s={width:e,height:t,depth:n.depth},r=new zt(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:Ft,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 vl(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 pn extends sp{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class g0 extends zt{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=Pt,this.minFilter=Pt,this.wrapR=Bn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class rp extends zt{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=Pt,this.minFilter=Pt,this.wrapR=Bn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class ot{static{ot.prototype.isMatrix4=!0}constructor(e,t,n,s,r,a,o,c,l,h,d,u,p,g,M,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,c,l,h,d,u,p,g,M,m)}set(e,t,n,s,r,a,o,c,l,h,d,u,p,g,M,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]=c,f[2]=l,f[6]=h,f[10]=d,f[14]=u,f[3]=p,f[7]=g,f[11]=M,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 ot().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/ki.setFromMatrixColumn(e,0).length(),r=1/ki.setFromMatrixColumn(e,1).length(),a=1/ki.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),c=Math.cos(s),l=Math.sin(s),h=Math.cos(r),d=Math.sin(r);if(e.order==="XYZ"){const u=a*h,p=a*d,g=o*h,M=o*d;t[0]=c*h,t[4]=-c*d,t[8]=l,t[1]=p+g*l,t[5]=u-M*l,t[9]=-o*c,t[2]=M-u*l,t[6]=g+p*l,t[10]=a*c}else if(e.order==="YXZ"){const u=c*h,p=c*d,g=l*h,M=l*d;t[0]=u+M*o,t[4]=g*o-p,t[8]=a*l,t[1]=a*d,t[5]=a*h,t[9]=-o,t[2]=p*o-g,t[6]=M+u*o,t[10]=a*c}else if(e.order==="ZXY"){const u=c*h,p=c*d,g=l*h,M=l*d;t[0]=u-M*o,t[4]=-a*d,t[8]=g+p*o,t[1]=p+g*o,t[5]=a*h,t[9]=M-u*o,t[2]=-a*l,t[6]=o,t[10]=a*c}else if(e.order==="ZYX"){const u=a*h,p=a*d,g=o*h,M=o*d;t[0]=c*h,t[4]=g*l-p,t[8]=u*l+M,t[1]=c*d,t[5]=M*l+u,t[9]=p*l-g,t[2]=-l,t[6]=o*c,t[10]=a*c}else if(e.order==="YZX"){const u=a*c,p=a*l,g=o*c,M=o*l;t[0]=c*h,t[4]=M-u*d,t[8]=g*d+p,t[1]=d,t[5]=a*h,t[9]=-o*h,t[2]=-l*h,t[6]=p*d+g,t[10]=u-M*d}else if(e.order==="XZY"){const u=a*c,p=a*l,g=o*c,M=o*l;t[0]=c*h,t[4]=-d,t[8]=l*h,t[1]=u*d+M,t[5]=a*h,t[9]=p*d-g,t[2]=g*d-p,t[6]=o*h,t[10]=M*d+u}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(ap,e,op)}lookAt(e,t,n){const s=this.elements;return qt.subVectors(e,t),qt.lengthSq()===0&&(qt.z=1),qt.normalize(),$n.crossVectors(n,qt),$n.lengthSq()===0&&(Math.abs(n.z)===1?qt.x+=1e-4:qt.z+=1e-4,qt.normalize(),$n.crossVectors(n,qt)),$n.normalize(),vr.crossVectors(qt,$n),s[0]=$n.x,s[4]=vr.x,s[8]=qt.x,s[1]=$n.y,s[5]=vr.y,s[9]=qt.y,s[2]=$n.z,s[6]=vr.z,s[10]=qt.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],c=n[8],l=n[12],h=n[1],d=n[5],u=n[9],p=n[13],g=n[2],M=n[6],m=n[10],f=n[14],T=n[3],w=n[7],x=n[11],y=n[15],b=s[0],R=s[4],v=s[8],E=s[12],P=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*P+c*q+l*Q,r[4]=a*R+o*C+c*F+l*te,r[8]=a*v+o*L+c*W+l*ee,r[12]=a*E+o*X+c*V+l*se,r[1]=h*b+d*P+u*q+p*Q,r[5]=h*R+d*C+u*F+p*te,r[9]=h*v+d*L+u*W+p*ee,r[13]=h*E+d*X+u*V+p*se,r[2]=g*b+M*P+m*q+f*Q,r[6]=g*R+M*C+m*F+f*te,r[10]=g*v+M*L+m*W+f*ee,r[14]=g*E+M*X+m*V+f*se,r[3]=T*b+w*P+x*q+y*Q,r[7]=T*R+w*C+x*F+y*te,r[11]=T*v+w*L+x*W+y*ee,r[15]=T*E+w*X+x*V+y*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],c=e[9],l=e[13],h=e[2],d=e[6],u=e[10],p=e[14],g=e[3],M=e[7],m=e[11],f=e[15],T=c*p-l*u,w=o*p-l*d,x=o*u-c*d,y=a*p-l*h,b=a*u-c*h,R=a*d-o*h;return t*(M*T-m*w+f*x)-n*(g*T-m*y+f*b)+s*(g*w-M*y+f*R)-r*(g*x-M*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],c=e[2],l=e[6],h=e[10];return t*(a*h-o*l)-n*(r*h-o*c)+s*(r*l-a*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,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],c=e[6],l=e[7],h=e[8],d=e[9],u=e[10],p=e[11],g=e[12],M=e[13],m=e[14],f=e[15],T=t*o-n*a,w=t*c-s*a,x=t*l-r*a,y=n*c-s*o,b=n*l-r*o,R=s*l-r*c,v=h*M-d*g,E=h*m-u*g,P=h*f-p*g,C=d*m-u*M,L=d*f-p*M,X=u*f-p*m,q=T*X-w*L+x*C+y*P-b*E+R*v;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-c*L+l*C)*F,e[1]=(s*L-n*X-r*C)*F,e[2]=(M*R-m*b+f*y)*F,e[3]=(u*b-d*R-p*y)*F,e[4]=(c*P-a*X-l*E)*F,e[5]=(t*X-s*P+r*E)*F,e[6]=(m*x-g*R-f*w)*F,e[7]=(h*R-u*x+p*w)*F,e[8]=(a*L-o*P+l*v)*F,e[9]=(n*P-t*L-r*v)*F,e[10]=(g*b-M*x+f*T)*F,e[11]=(d*x-h*b-p*T)*F,e[12]=(o*E-a*C-c*v)*F,e[13]=(t*C-n*E+s*v)*F,e[14]=(M*w-g*y-m*T)*F,e[15]=(h*y-d*w+u*T)*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,c=e.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(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,c=t._w,l=r+r,h=a+a,d=o+o,u=r*l,p=r*h,g=r*d,M=a*h,m=a*d,f=o*d,T=c*l,w=c*h,x=c*d,y=n.x,b=n.y,R=n.z;return s[0]=(1-(M+f))*y,s[1]=(p+x)*y,s[2]=(g-w)*y,s[3]=0,s[4]=(p-x)*b,s[5]=(1-(u+f))*b,s[6]=(m+T)*b,s[7]=0,s[8]=(g+w)*R,s[9]=(m-T)*R,s[10]=(1-(u+M))*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=ki.set(s[0],s[1],s[2]).length();const o=ki.set(s[4],s[5],s[6]).length(),c=ki.set(s[8],s[9],s[10]).length();r<0&&(a=-a),cn.copy(this);const l=1/a,h=1/o,d=1/c;return cn.elements[0]*=l,cn.elements[1]*=l,cn.elements[2]*=l,cn.elements[4]*=h,cn.elements[5]*=h,cn.elements[6]*=h,cn.elements[8]*=d,cn.elements[9]*=d,cn.elements[10]*=d,t.setFromRotationMatrix(cn),n.x=a,n.y=o,n.z=c,this}makePerspective(e,t,n,s,r,a,o=Cn,c=!1){const l=this.elements,h=2*r/(t-e),d=2*r/(n-s),u=(t+e)/(t-e),p=(n+s)/(n-s);let g,M;if(c)g=r/(a-r),M=a*r/(a-r);else if(o===Cn)g=-(a+r)/(a-r),M=-2*a*r/(a-r);else if(o===ar)g=-a/(a-r),M=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=d,l[9]=p,l[13]=0,l[2]=0,l[6]=0,l[10]=g,l[14]=M,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,s,r,a,o=Cn,c=!1){const l=this.elements,h=2/(t-e),d=2/(n-s),u=-(t+e)/(t-e),p=-(n+s)/(n-s);let g,M;if(c)g=1/(a-r),M=a/(a-r);else if(o===Cn)g=-2/(a-r),M=-(a+r)/(a-r);else if(o===ar)g=-1/(a-r),M=-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]=u,l[1]=0,l[5]=d,l[9]=0,l[13]=p,l[2]=0,l[6]=0,l[10]=g,l[14]=M,l[3]=0,l[7]=0,l[11]=0,l[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 ki=new U,cn=new ot,ap=new U(0,0,0),op=new U(1,1,1),$n=new U,vr=new U,qt=new U,ch=new ot,lh=new Ts;class fi{constructor(e=0,t=0,n=0,s=fi.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],c=s[1],l=s[5],h=s[9],d=s[2],u=s[6],p=s[10];switch(t){case"XYZ":this._y=Math.asin(Ye(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Ye(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-d,r),this._z=0);break;case"ZXY":this._x=Math.asin(Ye(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-d,p),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-Ye(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(u,p),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Ye(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-d,r)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-Ye(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,l),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 lh.setFromEuler(this),this.setFromQuaternion(lh,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}}fi.DEFAULT_ORDER="XYZ";class xl{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 cp=0;const hh=new U,Gi=new Ts,In=new ot,xr=new U,Ds=new U,lp=new U,hp=new Ts,uh=new U(1,0,0),dh=new U(0,1,0),fh=new U(0,0,1),ph={type:"added"},up={type:"removed"},Hi={type:"childadded",child:null},Za={type:"childremoved",child:null};class St extends Ni{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:cp++}),this.uuid=hi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=St.DEFAULT_UP.clone();const e=new U,t=new fi,n=new Ts,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 ot},normalMatrix:{value:new ze}}),this.matrix=new ot,this.matrixWorld=new ot,this.matrixAutoUpdate=St.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=St.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new xl,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 Gi.setFromAxisAngle(e,t),this.quaternion.multiply(Gi),this}rotateOnWorldAxis(e,t){return Gi.setFromAxisAngle(e,t),this.quaternion.premultiply(Gi),this}rotateX(e){return this.rotateOnAxis(uh,e)}rotateY(e){return this.rotateOnAxis(dh,e)}rotateZ(e){return this.rotateOnAxis(fh,e)}translateOnAxis(e,t){return hh.copy(e).applyQuaternion(this.quaternion),this.position.add(hh.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(uh,e)}translateY(e){return this.translateOnAxis(dh,e)}translateZ(e){return this.translateOnAxis(fh,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(In.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?xr.copy(e):xr.set(e,t,n);const s=this.parent;this.updateWorldMatrix(!0,!1),Ds.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?In.lookAt(Ds,xr,this.up):In.lookAt(xr,Ds,this.up),this.quaternion.setFromRotationMatrix(In),s&&(In.extractRotation(s.matrixWorld),Gi.setFromRotationMatrix(In),this.quaternion.premultiply(Gi.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Xe("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(ph),Hi.child=e,this.dispatchEvent(Hi),Hi.child=null):Xe("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(up),Za.child=e,this.dispatchEvent(Za),Za.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),In.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),In.multiply(e.parent.matrixWorld)),e.applyMatrix4(In),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(ph),Hi.child=e,this.dispatchEvent(Hi),Hi.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(Ds,e,lp),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ds,hp,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,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.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 c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){const d=c[l];r(e.shapes,d)}else r(e.shapes,c)}}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 c=0,l=this.material.length;c<l;c++)o.push(r(e.materials,this.material[c]));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 c=this.animations[o];s.animations.push(r(e.animations,c))}}if(t){const o=a(e.geometries),c=a(e.materials),l=a(e.textures),h=a(e.images),d=a(e.shapes),u=a(e.skeletons),p=a(e.animations),g=a(e.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),d.length>0&&(n.shapes=d),u.length>0&&(n.skeletons=u),p.length>0&&(n.animations=p),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(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}}St.DEFAULT_UP=new U(0,1,0);St.DEFAULT_MATRIX_AUTO_UPDATE=!0;St.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class fn extends St{constructor(){super(),this.isGroup=!0,this.type="Group"}}const dp={type:"move"};class $a{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new fn,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 fn,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 fn,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,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(const M of e.hand.values()){const m=t.getJointPose(M,n),f=this._getHandJoint(l,M);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=l.joints["index-finger-tip"],d=l.joints["thumb-tip"],u=h.position.distanceTo(d.position),p=.02,g=.005;l.inputState.pinching&&u>p+g?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&u<=p-g&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(r=t.getPose(e.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: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(dp)))}return o!==null&&(o.visible=s!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new fn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const _0={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},Jn={h:0,s:0,l:0},Mr={h:0,s:0,l:0};function Ja(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 Me{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=nn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,qe.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=qe.workingColorSpace){return this.r=e,this.g=t,this.b=n,qe.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=qe.workingColorSpace){if(e=jf(e,1),t=Ye(t,0,1),n=Ye(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=Ja(a,r,e+1/3),this.g=Ja(a,r,e),this.b=Ja(a,r,e-1/3)}return qe.colorSpaceToWorking(this,s),this}setStyle(e,t=nn){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=nn){const n=_0[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=Hn(e.r),this.g=Hn(e.g),this.b=Hn(e.b),this}copyLinearToSRGB(e){return this.r=ms(e.r),this.g=ms(e.g),this.b=ms(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=nn){return qe.workingToColorSpace(Nt.copy(this),e),Math.round(Ye(Nt.r*255,0,255))*65536+Math.round(Ye(Nt.g*255,0,255))*256+Math.round(Ye(Nt.b*255,0,255))}getHexString(e=nn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=qe.workingColorSpace){qe.workingToColorSpace(Nt.copy(this),t);const n=Nt.r,s=Nt.g,r=Nt.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 d=a-o;switch(l=h<=.5?d/(a+o):d/(2-a-o),a){case n:c=(s-r)/d+(s<r?6:0);break;case s:c=(r-n)/d+2;break;case r:c=(n-s)/d+4;break}c/=6}return e.h=c,e.s=l,e.l=h,e}getRGB(e,t=qe.workingColorSpace){return qe.workingToColorSpace(Nt.copy(this),t),e.r=Nt.r,e.g=Nt.g,e.b=Nt.b,e}getStyle(e=nn){qe.workingToColorSpace(Nt.copy(this),e);const t=Nt.r,n=Nt.g,s=Nt.b;return e!==nn?`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(Jn),this.setHSL(Jn.h+e,Jn.s+t,Jn.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(Jn),e.getHSL(Mr);const n=Wa(Jn.h,Mr.h,t),s=Wa(Jn.s,Mr.s,t),r=Wa(Jn.l,Mr.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 Nt=new Me;Me.NAMES=_0;class Ml{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new Me(e),this.near=t,this.far=n}clone(){return new Ml(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class v0 extends St{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new fi,this.environmentIntensity=1,this.environmentRotation=new fi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(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 ln=new U,Ln=new U,Qa=new U,Nn=new U,Vi=new U,Wi=new U,mh=new U,ja=new U,eo=new U,to=new U,no=new ut,io=new ut,so=new ut;class sn{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),ln.subVectors(e,t),s.cross(ln);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){ln.subVectors(s,t),Ln.subVectors(n,t),Qa.subVectors(e,t);const a=ln.dot(ln),o=ln.dot(Ln),c=ln.dot(Qa),l=Ln.dot(Ln),h=Ln.dot(Qa),d=a*l-o*o;if(d===0)return r.set(0,0,0),null;const u=1/d,p=(l*c-o*h)*u,g=(a*h-o*c)*u;return r.set(1-p-g,g,p)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,Nn)===null?!1:Nn.x>=0&&Nn.y>=0&&Nn.x+Nn.y<=1}static getInterpolation(e,t,n,s,r,a,o,c){return this.getBarycoord(e,t,n,s,Nn)===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,Nn.x),c.addScaledVector(a,Nn.y),c.addScaledVector(o,Nn.z),c)}static getInterpolatedAttribute(e,t,n,s,r,a){return no.setScalar(0),io.setScalar(0),so.setScalar(0),no.fromBufferAttribute(e,t),io.fromBufferAttribute(e,n),so.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(no,r.x),a.addScaledVector(io,r.y),a.addScaledVector(so,r.z),a}static isFrontFacing(e,t,n,s){return ln.subVectors(n,t),Ln.subVectors(e,t),ln.cross(Ln).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 ln.subVectors(this.c,this.b),Ln.subVectors(this.a,this.b),ln.cross(Ln).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return sn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return sn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,r){return sn.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}containsPoint(e){return sn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return sn.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;Vi.subVectors(s,n),Wi.subVectors(r,n),ja.subVectors(e,n);const c=Vi.dot(ja),l=Wi.dot(ja);if(c<=0&&l<=0)return t.copy(n);eo.subVectors(e,s);const h=Vi.dot(eo),d=Wi.dot(eo);if(h>=0&&d<=h)return t.copy(s);const u=c*d-h*l;if(u<=0&&c>=0&&h<=0)return a=c/(c-h),t.copy(n).addScaledVector(Vi,a);to.subVectors(e,r);const p=Vi.dot(to),g=Wi.dot(to);if(g>=0&&p<=g)return t.copy(r);const M=p*l-c*g;if(M<=0&&l>=0&&g<=0)return o=l/(l-g),t.copy(n).addScaledVector(Wi,o);const m=h*g-p*d;if(m<=0&&d-h>=0&&p-g>=0)return mh.subVectors(r,s),o=(d-h)/(d-h+(p-g)),t.copy(s).addScaledVector(mh,o);const f=1/(m+M+u);return a=M*f,o=u*f,t.copy(n).addScaledVector(Vi,a).addScaledVector(Wi,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class or{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(hn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(hn.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=hn.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,hn):hn.fromBufferAttribute(r,a),hn.applyMatrix4(e.matrixWorld),this.expandByPoint(hn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Sr.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Sr.copy(n.boundingBox)),Sr.applyMatrix4(e.matrixWorld),this.union(Sr)}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,hn),hn.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(Is),yr.subVectors(this.max,Is),Xi.subVectors(e.a,Is),qi.subVectors(e.b,Is),Yi.subVectors(e.c,Is),Qn.subVectors(qi,Xi),jn.subVectors(Yi,qi),gi.subVectors(Xi,Yi);let t=[0,-Qn.z,Qn.y,0,-jn.z,jn.y,0,-gi.z,gi.y,Qn.z,0,-Qn.x,jn.z,0,-jn.x,gi.z,0,-gi.x,-Qn.y,Qn.x,0,-jn.y,jn.x,0,-gi.y,gi.x,0];return!ro(t,Xi,qi,Yi,yr)||(t=[1,0,0,0,1,0,0,0,1],!ro(t,Xi,qi,Yi,yr))?!1:(Er.crossVectors(Qn,jn),t=[Er.x,Er.y,Er.z],ro(t,Xi,qi,Yi,yr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,hn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(hn).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:(Un[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Un[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Un[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Un[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Un[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Un[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Un[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Un[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Un),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 Un=[new U,new U,new U,new U,new U,new U,new U,new U],hn=new U,Sr=new or,Xi=new U,qi=new U,Yi=new U,Qn=new U,jn=new U,gi=new U,Is=new U,yr=new U,Er=new U,_i=new U;function ro(i,e,t,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){_i.fromArray(i,r);const o=s.x*Math.abs(_i.x)+s.y*Math.abs(_i.y)+s.z*Math.abs(_i.z),c=e.dot(_i),l=t.dot(_i),h=n.dot(_i);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}const Mt=new U,br=new Fe;let fp=0;class lt extends Ni{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:fp++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Ic,this.updateRanges=[],this.gpuType=Rn,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++)br.fromBufferAttribute(this,t),br.applyMatrix3(e),this.setXY(t,br.x,br.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Mt.fromBufferAttribute(this,t),Mt.applyMatrix3(e),this.setXYZ(t,Mt.x,Mt.y,Mt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Mt.fromBufferAttribute(this,t),Mt.applyMatrix4(e),this.setXYZ(t,Mt.x,Mt.y,Mt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Mt.fromBufferAttribute(this,t),Mt.applyNormalMatrix(e),this.setXYZ(t,Mt.x,Mt.y,Mt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Mt.fromBufferAttribute(this,t),Mt.transformDirection(e),this.setXYZ(t,Mt.x,Mt.y,Mt.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=wn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=et(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=wn(t,this.array)),t}setX(e,t){return this.normalized&&(t=et(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=wn(t,this.array)),t}setY(e,t){return this.normalized&&(t=et(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=wn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=et(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=wn(t,this.array)),t}setW(e,t){return this.normalized&&(t=et(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=et(t,this.array),n=et(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=et(t,this.array),n=et(n,this.array),s=et(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=et(t,this.array),n=et(n,this.array),s=et(s,this.array),r=et(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!==Ic&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class x0 extends lt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class M0 extends lt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Et extends lt{constructor(e,t,n){super(new Float32Array(e),t,n)}}const pp=new or,Ls=new U,ao=new U;class Pa{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):pp.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;Ls.subVectors(e,this.center);const t=Ls.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(Ls,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):(ao.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ls.copy(e.center).add(ao)),this.expandByPoint(Ls.copy(e.center).sub(ao))),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 mp=0;const Qt=new ot,oo=new St,Ki=new U,Yt=new or,Ns=new or,At=new U;class yt extends Ni{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:mp++}),this.uuid=hi(),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(Zf(e)?M0:x0)(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 Qt.makeRotationFromQuaternion(e),this.applyMatrix4(Qt),this}rotateX(e){return Qt.makeRotationX(e),this.applyMatrix4(Qt),this}rotateY(e){return Qt.makeRotationY(e),this.applyMatrix4(Qt),this}rotateZ(e){return Qt.makeRotationZ(e),this.applyMatrix4(Qt),this}translate(e,t,n){return Qt.makeTranslation(e,t,n),this.applyMatrix4(Qt),this}scale(e,t,n){return Qt.makeScale(e,t,n),this.applyMatrix4(Qt),this}lookAt(e){return oo.lookAt(e),oo.updateMatrix(),this.applyMatrix4(oo.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ki).negate(),this.translate(Ki.x,Ki.y,Ki.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 Et(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 or);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Xe("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];Yt.setFromBufferAttribute(r),this.morphTargetsRelative?(At.addVectors(this.boundingBox.min,Yt.min),this.boundingBox.expandByPoint(At),At.addVectors(this.boundingBox.max,Yt.max),this.boundingBox.expandByPoint(At)):(this.boundingBox.expandByPoint(Yt.min),this.boundingBox.expandByPoint(Yt.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Xe('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 Pa);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Xe("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(Yt.setFromBufferAttribute(e),t)for(let r=0,a=t.length;r<a;r++){const o=t[r];Ns.setFromBufferAttribute(o),this.morphTargetsRelative?(At.addVectors(Yt.min,Ns.min),Yt.expandByPoint(At),At.addVectors(Yt.max,Ns.max),Yt.expandByPoint(At)):(Yt.expandByPoint(Ns.min),Yt.expandByPoint(Ns.max))}Yt.getCenter(n);let s=0;for(let r=0,a=e.count;r<a;r++)At.fromBufferAttribute(e,r),s=Math.max(s,n.distanceToSquared(At));if(t)for(let r=0,a=t.length;r<a;r++){const o=t[r],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)At.fromBufferAttribute(o,l),c&&(Ki.fromBufferAttribute(e,l),At.add(Ki)),s=Math.max(s,n.distanceToSquared(At))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&Xe('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){Xe("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 lt(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));const o=[],c=[];for(let v=0;v<n.count;v++)o[v]=new U,c[v]=new U;const l=new U,h=new U,d=new U,u=new Fe,p=new Fe,g=new Fe,M=new U,m=new U;function f(v,E,P){l.fromBufferAttribute(n,v),h.fromBufferAttribute(n,E),d.fromBufferAttribute(n,P),u.fromBufferAttribute(r,v),p.fromBufferAttribute(r,E),g.fromBufferAttribute(r,P),h.sub(l),d.sub(l),p.sub(u),g.sub(u);const C=1/(p.x*g.y-g.x*p.y);isFinite(C)&&(M.copy(h).multiplyScalar(g.y).addScaledVector(d,-p.y).multiplyScalar(C),m.copy(d).multiplyScalar(p.x).addScaledVector(h,-g.x).multiplyScalar(C),o[v].add(M),o[E].add(M),o[P].add(M),c[v].add(m),c[E].add(m),c[P].add(m))}let T=this.groups;T.length===0&&(T=[{start:0,count:e.count}]);for(let v=0,E=T.length;v<E;++v){const P=T[v],C=P.start,L=P.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 w=new U,x=new U,y=new U,b=new U;function R(v){y.fromBufferAttribute(s,v),b.copy(y);const E=o[v];w.copy(E),w.sub(y.multiplyScalar(y.dot(E))).normalize(),x.crossVectors(b,E);const C=x.dot(c[v])<0?-1:1;a.setXYZW(v,w.x,w.y,w.z,C)}for(let v=0,E=T.length;v<E;++v){const P=T[v],C=P.start,L=P.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 lt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let u=0,p=n.count;u<p;u++)n.setXYZ(u,0,0,0);const s=new U,r=new U,a=new U,o=new U,c=new U,l=new U,h=new U,d=new U;if(e)for(let u=0,p=e.count;u<p;u+=3){const g=e.getX(u+0),M=e.getX(u+1),m=e.getX(u+2);s.fromBufferAttribute(t,g),r.fromBufferAttribute(t,M),a.fromBufferAttribute(t,m),h.subVectors(a,r),d.subVectors(s,r),h.cross(d),o.fromBufferAttribute(n,g),c.fromBufferAttribute(n,M),l.fromBufferAttribute(n,m),o.add(h),c.add(h),l.add(h),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(M,c.x,c.y,c.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let u=0,p=t.count;u<p;u+=3)s.fromBufferAttribute(t,u+0),r.fromBufferAttribute(t,u+1),a.fromBufferAttribute(t,u+2),h.subVectors(a,r),d.subVectors(s,r),h.cross(d),n.setXYZ(u+0,h.x,h.y,h.z),n.setXYZ(u+1,h.x,h.y,h.z),n.setXYZ(u+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++)At.fromBufferAttribute(e,t),At.normalize(),e.setXYZ(t,At.x,At.y,At.z)}toNonIndexed(){function e(o,c){const l=o.array,h=o.itemSize,d=o.normalized,u=new l.constructor(c.length*h);let p=0,g=0;for(let M=0,m=c.length;M<m;M++){o.isInterleavedBufferAttribute?p=c[M]*o.data.stride+o.offset:p=c[M]*h;for(let f=0;f<h;f++)u[g++]=l[p++]}return new lt(u,h,d)}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 c=s[o],l=e(c,n);t.setAttribute(o,l)}const r=this.morphAttributes;for(const o in r){const c=[],l=r[o];for(let h=0,d=l.length;h<d;h++){const u=l[h],p=e(u,n);c.push(p)}t.morphAttributes[o]=c}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;o++){const l=a[o];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const c in n){const l=n[c];e.data.attributes[c]=l.toJSON(e.data)}const s={};let r=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],h=[];for(let d=0,u=l.length;d<u;d++){const p=l[d];h.push(p.toJSON(e.data))}h.length>0&&(s[c]=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 l in s){const h=s[l];this.setAttribute(l,h.clone(t))}const r=e.morphAttributes;for(const l in r){const h=[],d=r[l];for(let u=0,p=d.length;u<p;u++)h.push(d[u].clone(t));this.morphAttributes[l]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let l=0,h=a.length;l<h;l++){const d=a[l];this.addGroup(d.start,d.count,d.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class gp{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Ic,this.updateRanges=[],this.version=0,this.uuid=hi()}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=hi()),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=hi()),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 kt=new U;class xa{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++)kt.fromBufferAttribute(this,t),kt.applyMatrix4(e),this.setXYZ(t,kt.x,kt.y,kt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)kt.fromBufferAttribute(this,t),kt.applyNormalMatrix(e),this.setXYZ(t,kt.x,kt.y,kt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)kt.fromBufferAttribute(this,t),kt.transformDirection(e),this.setXYZ(t,kt.x,kt.y,kt.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=wn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=et(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=et(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=et(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=et(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=et(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=wn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=wn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=wn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=wn(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=et(t,this.array),n=et(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=et(t,this.array),n=et(n,this.array),s=et(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=et(t,this.array),n=et(n,this.array),s=et(s,this.array),r=et(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){va("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 lt(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 xa(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){va("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 _p=0;class Ui extends Ni{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:_p++}),this.uuid=hi(),this.name="",this.type="Material",this.blending=fs,this.side=di,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Wo,this.blendDst=Xo,this.blendEquation=yi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Me(0,0,0),this.blendAlpha=0,this.depthFunc=xs,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=nh,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!==fs&&(n.blending=this.blending),this.side!==di&&(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!==Wo&&(n.blendSrc=this.blendSrc),this.blendDst!==Xo&&(n.blendDst=this.blendDst),this.blendEquation!==yi&&(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!==xs&&(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!==nh&&(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 c=r[o];delete c.metadata,a.push(c)}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 Me().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 qs extends Ui{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Me(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 Zi;const Us=new U,$i=new U,Ji=new U,Qi=new Fe,Fs=new Fe,S0=new ot,Tr=new U,Os=new U,Ar=new U,gh=new Fe,co=new Fe,_h=new Fe;class wr extends St{constructor(e=new qs){if(super(),this.isSprite=!0,this.type="Sprite",Zi===void 0){Zi=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 gp(t,5);Zi.setIndex([0,1,2,0,2,3]),Zi.setAttribute("position",new xa(n,3,0,!1)),Zi.setAttribute("uv",new xa(n,2,3,!1))}this.geometry=Zi,this.material=e,this.center=new Fe(.5,.5),this.count=1}raycast(e,t){e.camera===null&&Xe('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),$i.setFromMatrixScale(this.matrixWorld),S0.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ji.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&$i.multiplyScalar(-Ji.z);const n=this.material.rotation;let s,r;n!==0&&(r=Math.cos(n),s=Math.sin(n));const a=this.center;Rr(Tr.set(-.5,-.5,0),Ji,a,$i,s,r),Rr(Os.set(.5,-.5,0),Ji,a,$i,s,r),Rr(Ar.set(.5,.5,0),Ji,a,$i,s,r),gh.set(0,0),co.set(1,0),_h.set(1,1);let o=e.ray.intersectTriangle(Tr,Os,Ar,!1,Us);if(o===null&&(Rr(Os.set(-.5,.5,0),Ji,a,$i,s,r),co.set(0,1),o=e.ray.intersectTriangle(Tr,Ar,Os,!1,Us),o===null))return;const c=e.ray.origin.distanceTo(Us);c<e.near||c>e.far||t.push({distance:c,point:Us.clone(),uv:sn.getInterpolation(Us,Tr,Os,Ar,gh,co,_h,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 Rr(i,e,t,n,s,r){Qi.subVectors(i,t).addScalar(.5).multiply(n),s!==void 0?(Fs.x=r*Qi.x-s*Qi.y,Fs.y=s*Qi.x+r*Qi.y):Fs.copy(Qi),i.copy(e),i.x+=Fs.x,i.y+=Fs.y,i.applyMatrix4(S0)}const Fn=new U,lo=new U,Cr=new U,ei=new U,ho=new U,Pr=new U,uo=new U;class Sl{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,Fn)),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=Fn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Fn.copy(this.origin).addScaledVector(this.direction,t),Fn.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){lo.copy(e).add(t).multiplyScalar(.5),Cr.copy(t).sub(e).normalize(),ei.copy(this.origin).sub(lo);const r=e.distanceTo(t)*.5,a=-this.direction.dot(Cr),o=ei.dot(this.direction),c=-ei.dot(Cr),l=ei.lengthSq(),h=Math.abs(1-a*a);let d,u,p,g;if(h>0)if(d=a*c-o,u=a*o-c,g=r*h,d>=0)if(u>=-g)if(u<=g){const M=1/h;d*=M,u*=M,p=d*(d+a*u+2*o)+u*(a*d+u+2*c)+l}else u=r,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*c)+l;else u=-r,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*c)+l;else u<=-g?(d=Math.max(0,-(-a*r+o)),u=d>0?-r:Math.min(Math.max(-r,-c),r),p=-d*d+u*(u+2*c)+l):u<=g?(d=0,u=Math.min(Math.max(-r,-c),r),p=u*(u+2*c)+l):(d=Math.max(0,-(a*r+o)),u=d>0?r:Math.min(Math.max(-r,-c),r),p=-d*d+u*(u+2*c)+l);else u=a>0?-r:r,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(lo).addScaledVector(Cr,u),p}intersectSphere(e,t){Fn.subVectors(e.center,this.origin);const n=Fn.dot(this.direction),s=Fn.dot(Fn)-n*n,r=e.radius*e.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,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,c;const l=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,u=this.origin;return l>=0?(n=(e.min.x-u.x)*l,s=(e.max.x-u.x)*l):(n=(e.max.x-u.x)*l,s=(e.min.x-u.x)*l),h>=0?(r=(e.min.y-u.y)*h,a=(e.max.y-u.y)*h):(r=(e.max.y-u.y)*h,a=(e.min.y-u.y)*h),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a<s||isNaN(s))&&(s=a),d>=0?(o=(e.min.z-u.z)*d,c=(e.max.z-u.z)*d):(o=(e.max.z-u.z)*d,c=(e.min.z-u.z)*d),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,t)}intersectsBox(e){return this.intersectBox(e,Fn)!==null}intersectTriangle(e,t,n,s,r){ho.subVectors(t,e),Pr.subVectors(n,e),uo.crossVectors(ho,Pr);let a=this.direction.dot(uo),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;ei.subVectors(this.origin,e);const c=o*this.direction.dot(Pr.crossVectors(ei,Pr));if(c<0)return null;const l=o*this.direction.dot(ho.cross(ei));if(l<0||c+l>a)return null;const h=-o*ei.dot(uo);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 Ss extends Ui{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Me(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new fi,this.combine=ll,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 vh=new ot,vi=new Sl,Dr=new Pa,xh=new U,Ir=new U,Lr=new U,Nr=new U,fo=new U,Ur=new U,Mh=new U,Fr=new U;class ht extends St{constructor(e=new yt,t=new Ss){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){Ur.set(0,0,0);for(let c=0,l=r.length;c<l;c++){const h=o[c],d=r[c];h!==0&&(fo.fromBufferAttribute(d,e),a?Ur.addScaledVector(fo,h):Ur.addScaledVector(fo.sub(t),h))}t.add(Ur)}return t}raycast(e,t){const n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Dr.copy(n.boundingSphere),Dr.applyMatrix4(r),vi.copy(e.ray).recast(e.near),!(Dr.containsPoint(vi.origin)===!1&&(vi.intersectSphere(Dr,xh)===null||vi.origin.distanceToSquared(xh)>(e.far-e.near)**2))&&(vh.copy(r).invert(),vi.copy(e.ray).applyMatrix4(vh),!(n.boundingBox!==null&&vi.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,vi)))}_computeIntersections(e,t,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,d=r.attributes.normal,u=r.groups,p=r.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,M=u.length;g<M;g++){const m=u[g],f=a[m.materialIndex],T=Math.max(m.start,p.start),w=Math.min(o.count,Math.min(m.start+m.count,p.start+p.count));for(let x=T,y=w;x<y;x+=3){const b=o.getX(x),R=o.getX(x+1),v=o.getX(x+2);s=Or(this,f,e,n,l,h,d,b,R,v),s&&(s.faceIndex=Math.floor(x/3),s.face.materialIndex=m.materialIndex,t.push(s))}}else{const g=Math.max(0,p.start),M=Math.min(o.count,p.start+p.count);for(let m=g,f=M;m<f;m+=3){const T=o.getX(m),w=o.getX(m+1),x=o.getX(m+2);s=Or(this,a,e,n,l,h,d,T,w,x),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}else if(c!==void 0)if(Array.isArray(a))for(let g=0,M=u.length;g<M;g++){const m=u[g],f=a[m.materialIndex],T=Math.max(m.start,p.start),w=Math.min(c.count,Math.min(m.start+m.count,p.start+p.count));for(let x=T,y=w;x<y;x+=3){const b=x,R=x+1,v=x+2;s=Or(this,f,e,n,l,h,d,b,R,v),s&&(s.faceIndex=Math.floor(x/3),s.face.materialIndex=m.materialIndex,t.push(s))}}else{const g=Math.max(0,p.start),M=Math.min(c.count,p.start+p.count);for(let m=g,f=M;m<f;m+=3){const T=m,w=m+1,x=m+2;s=Or(this,a,e,n,l,h,d,T,w,x),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}}}function vp(i,e,t,n,s,r,a,o){let c;if(e.side===Dt?c=n.intersectTriangle(a,r,s,!0,o):c=n.intersectTriangle(s,r,a,e.side===di,o),c===null)return null;Fr.copy(o),Fr.applyMatrix4(i.matrixWorld);const l=t.ray.origin.distanceTo(Fr);return l<t.near||l>t.far?null:{distance:l,point:Fr.clone(),object:i}}function Or(i,e,t,n,s,r,a,o,c,l){i.getVertexPosition(o,Ir),i.getVertexPosition(c,Lr),i.getVertexPosition(l,Nr);const h=vp(i,e,t,n,Ir,Lr,Nr,Mh);if(h){const d=new U;sn.getBarycoord(Mh,Ir,Lr,Nr,d),s&&(h.uv=sn.getInterpolatedAttribute(s,o,c,l,d,new Fe)),r&&(h.uv1=sn.getInterpolatedAttribute(r,o,c,l,d,new Fe)),a&&(h.normal=sn.getInterpolatedAttribute(a,o,c,l,d,new U),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const u={a:o,b:c,c:l,normal:new U,materialIndex:0};sn.getNormal(Ir,Lr,Nr,u.normal),h.face=u,h.barycoord=d}return h}class xp extends zt{constructor(e=null,t=1,n=1,s,r,a,o,c,l=Pt,h=Pt,d,u){super(null,a,o,c,l,h,s,r,d,u),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const po=new U,Mp=new U,Sp=new ze;class Si{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=po.subVectors(n,t).cross(Mp.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(po),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||Sp.getNormalMatrix(e),s=this.coplanarPoint(po).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 xi=new Pa,yp=new Fe(.5,.5),zr=new U;class yl{constructor(e=new Si,t=new Si,n=new Si,s=new Si,r=new Si,a=new Si){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=Cn,n=!1){const s=this.planes,r=e.elements,a=r[0],o=r[1],c=r[2],l=r[3],h=r[4],d=r[5],u=r[6],p=r[7],g=r[8],M=r[9],m=r[10],f=r[11],T=r[12],w=r[13],x=r[14],y=r[15];if(s[0].setComponents(l-a,p-h,f-g,y-T).normalize(),s[1].setComponents(l+a,p+h,f+g,y+T).normalize(),s[2].setComponents(l+o,p+d,f+M,y+w).normalize(),s[3].setComponents(l-o,p-d,f-M,y-w).normalize(),n)s[4].setComponents(c,u,m,x).normalize(),s[5].setComponents(l-c,p-u,f-m,y-x).normalize();else if(s[4].setComponents(l-c,p-u,f-m,y-x).normalize(),t===Cn)s[5].setComponents(l+c,p+u,f+m,y+x).normalize();else if(t===ar)s[5].setComponents(c,u,m,x).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(),xi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),xi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(xi)}intersectsSprite(e){xi.center.set(0,0,0);const t=yp.distanceTo(e.center);return xi.radius=.7071067811865476+t,xi.applyMatrix4(e.matrixWorld),this.intersectsSphere(xi)}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(zr.x=s.normal.x>0?e.max.x:e.min.x,zr.y=s.normal.y>0?e.max.y:e.min.y,zr.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(zr)<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 y0 extends Ui{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Me(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 Sh=new ot,Nc=new Sl,Br=new Pa,kr=new U;class ha extends St{constructor(e=new yt,t=new y0){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(),Br.copy(n.boundingSphere),Br.applyMatrix4(s),Br.radius+=r,e.ray.intersectsSphere(Br)===!1)return;Sh.copy(s).invert(),Nc.copy(e.ray).applyMatrix4(Sh);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=n.index,d=n.attributes.position;if(l!==null){const u=Math.max(0,a.start),p=Math.min(l.count,a.start+a.count);for(let g=u,M=p;g<M;g++){const m=l.getX(g);kr.fromBufferAttribute(d,m),yh(kr,m,c,s,e,t,this)}}else{const u=Math.max(0,a.start),p=Math.min(d.count,a.start+a.count);for(let g=u,M=p;g<M;g++)kr.fromBufferAttribute(d,g),yh(kr,g,c,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 yh(i,e,t,n,s,r,a){const o=Nc.distanceSqToPoint(i);if(o<t){const c=new U;Nc.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:e,face:null,faceIndex:null,barycoord:null,object:a})}}class E0 extends zt{constructor(e=[],t=Pi,n,s,r,a,o,c,l,h){super(e,t,n,s,r,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class qn extends zt{constructor(e,t,n,s,r,a,o,c,l){super(e,t,n,s,r,a,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class ys extends zt{constructor(e,t,n=Dn,s,r,a,o=Pt,c=Pt,l,h=Wn,d=1){if(h!==Wn&&h!==wi)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const u={width:e,height:t,depth:d};super(u,s,r,a,o,c,h,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new vl(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 Ep extends ys{constructor(e,t=Dn,n=Pi,s,r,a=Pt,o=Pt,c,l=Wn){const h={width:e,height:e,depth:1},d=[h,h,h,h,h,h];super(e,e,t,n,s,r,a,o,c,l),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class b0 extends zt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class rn 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 c=[],l=[],h=[],d=[];let u=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(c),this.setAttribute("position",new Et(l,3)),this.setAttribute("normal",new Et(h,3)),this.setAttribute("uv",new Et(d,2));function g(M,m,f,T,w,x,y,b,R,v,E){const P=x/R,C=y/v,L=x/2,X=y/2,q=b/2,F=R+1,W=v+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*P-L;te[M]=Ve*T,te[m]=se*w,te[f]=q,l.push(te.x,te.y,te.z),te[M]=0,te[m]=0,te[f]=b>0?1:-1,h.push(te.x,te.y,te.z),d.push(ge/R),d.push(1-ee/v),V+=1}}for(let ee=0;ee<v;ee++)for(let se=0;se<R;se++){const ge=u+se+F*ee,Ve=u+se+F*(ee+1),st=u+(se+1)+F*(ee+1),We=u+(se+1)+F*ee;c.push(ge,Ve,We),c.push(Ve,st,We),Q+=6}o.addGroup(p,Q,E),p+=Q,u+=V}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new rn(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class El 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=[],c=[],l=new U,h=new Fe;a.push(0,0,0),o.push(0,0,1),c.push(.5,.5);for(let d=0,u=3;d<=t;d++,u+=3){const p=n+d/t*s;l.x=e*Math.cos(p),l.y=e*Math.sin(p),a.push(l.x,l.y,l.z),o.push(0,0,1),h.x=(a[u]/e+1)/2,h.y=(a[u+1]/e+1)/2,c.push(h.x,h.y)}for(let d=1;d<=t;d++)r.push(d,d+1,0);this.setIndex(r),this.setAttribute("position",new Et(a,3)),this.setAttribute("normal",new Et(o,3)),this.setAttribute("uv",new Et(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new El(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class pi extends yt{constructor(e=1,t=1,n=1,s=32,r=1,a=!1,o=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,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=[],d=[],u=[],p=[];let g=0;const M=[],m=n/2;let f=0;T(),a===!1&&(e>0&&w(!0),t>0&&w(!1)),this.setIndex(h),this.setAttribute("position",new Et(d,3)),this.setAttribute("normal",new Et(u,3)),this.setAttribute("uv",new Et(p,2));function T(){const x=new U,y=new U;let b=0;const R=(t-e)/n;for(let v=0;v<=r;v++){const E=[],P=v/r,C=P*(t-e)+e;for(let L=0;L<=s;L++){const X=L/s,q=X*c+o,F=Math.sin(q),W=Math.cos(q);y.x=C*F,y.y=-P*n+m,y.z=C*W,d.push(y.x,y.y,y.z),x.set(F,R,W).normalize(),u.push(x.x,x.y,x.z),p.push(X,1-P),E.push(g++)}M.push(E)}for(let v=0;v<s;v++)for(let E=0;E<r;E++){const P=M[E][v],C=M[E+1][v],L=M[E+1][v+1],X=M[E][v+1];(e>0||E!==0)&&(h.push(P,C,X),b+=3),(t>0||E!==r-1)&&(h.push(C,L,X),b+=3)}l.addGroup(f,b,0),f+=b}function w(x){const y=g,b=new Fe,R=new U;let v=0;const E=x===!0?e:t,P=x===!0?1:-1;for(let L=1;L<=s;L++)d.push(0,m*P,0),u.push(0,P,0),p.push(.5,.5),g++;const C=g;for(let L=0;L<=s;L++){const q=L/s*c+o,F=Math.cos(q),W=Math.sin(q);R.x=E*W,R.y=m*P,R.z=E*F,d.push(R.x,R.y,R.z),u.push(0,P,0),b.x=F*.5+.5,b.y=W*.5*P+.5,p.push(b.x,b.y),g++}for(let L=0;L<s;L++){const X=y+L,q=C+L;x===!0?h.push(q,q+1,X):h.push(q+1,q,X),v+=3}l.addGroup(f,v,x===!0?1:2),f+=v}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new pi(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Da extends pi{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 Da(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class As 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),c=Math.floor(s),l=o+1,h=c+1,d=e/o,u=t/c,p=[],g=[],M=[],m=[];for(let f=0;f<h;f++){const T=f*u-a;for(let w=0;w<l;w++){const x=w*d-r;g.push(x,-T,0),M.push(0,0,1),m.push(w/o),m.push(1-f/c)}}for(let f=0;f<c;f++)for(let T=0;T<o;T++){const w=T+l*f,x=T+l*(f+1),y=T+1+l*(f+1),b=T+1+l*f;p.push(w,x,b),p.push(x,y,b)}this.setIndex(p),this.setAttribute("position",new Et(g,3)),this.setAttribute("normal",new Et(M,3)),this.setAttribute("uv",new Et(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new As(e.width,e.height,e.widthSegments,e.heightSegments)}}class Xn 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 c=Math.min(a+o,Math.PI);let l=0;const h=[],d=new U,u=new U,p=[],g=[],M=[],m=[];for(let f=0;f<=n;f++){const T=[],w=f/n,x=a+w*o,y=e*Math.cos(x),b=Math.sqrt(e*e-y*y);let R=0;f===0&&a===0?R=.5/t:f===n&&c===Math.PI&&(R=-.5/t);for(let v=0;v<=t;v++){const E=v/t,P=s+E*r;d.x=-b*Math.cos(P),d.y=y,d.z=b*Math.sin(P),g.push(d.x,d.y,d.z),u.copy(d).normalize(),M.push(u.x,u.y,u.z),m.push(E+R,1-w),T.push(l++)}h.push(T)}for(let f=0;f<n;f++)for(let T=0;T<t;T++){const w=h[f][T+1],x=h[f][T],y=h[f+1][T],b=h[f+1][T+1];(f!==0||a>0)&&p.push(w,x,b),(f!==n-1||c<Math.PI)&&p.push(x,y,b)}this.setIndex(p),this.setAttribute("position",new Et(g,3)),this.setAttribute("normal",new Et(M,3)),this.setAttribute("uv",new Et(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Xn(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}function Es(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const s=i[t][n];if(Eh(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(Eh(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 Gt(i){const e={};for(let t=0;t<i.length;t++){const n=Es(i[t]);for(const s in n)e[s]=n[s]}return e}function Eh(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function bp(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function T0(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:qe.workingColorSpace}const Tp={clone:Es,merge:Gt};var Ap=`void main() {
|
|
298
305
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
299
|
-
}`,
|
|
306
|
+
}`,wp=`void main() {
|
|
300
307
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
301
|
-
}`;class zt extends pi{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=zp,this.fragmentShader=Bp,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=Ss(e.uniforms),this.uniformsGroups=Fp(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 Oe().fromArray(s.value);break;case"v3":this.uniforms[n].value=new U().fromArray(s.value);break;case"v4":this.uniforms[n].value=new ht().fromArray(s.value);break;case"m3":this.uniforms[n].value=new ze().fromArray(s.value);break;case"m4":this.uniforms[n].value=new st().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 kp extends zt{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class lr extends pi{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=Oc,this.normalScale=new Oe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new fi,this.combine=ml,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 Gp extends pi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Jf,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 Hp extends pi{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 Cl extends xt{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 Vp extends Cl{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(xt.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 So=new st,Lh=new U,Nh=new U;class F0{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 Oe(512,512),this.mapType=Zt,this.map=null,this.mapPass=null,this.matrix=new st,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new wl,this._frameExtents=new Oe(1,1),this._viewportCount=1,this._viewports=[new ht(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;Lh.setFromMatrixPosition(e.matrixWorld),t.position.copy(Lh),Nh.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Nh),t.updateMatrixWorld(),So.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(So,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===rr||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(So)}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 Wr=new U,Xr=new Es,vn=new U;class O0 extends xt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new st,this.projectionMatrix=new st,this.projectionMatrixInverse=new st,this.coordinateSystem=Rn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(Wr,Xr,vn),vn.x===1&&vn.y===1&&vn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Wr,Xr,vn.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Wr,Xr,vn),vn.x===1&&vn.y===1&&vn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Wr,Xr,vn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const ti=new U,Uh=new Oe,Fh=new Oe;class Kt extends O0{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=Bc*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Ka*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Bc*2*Math.atan(Math.tan(Ka*.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){ti.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(ti.x,ti.y).multiplyScalar(-e/ti.z),ti.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(ti.x,ti.y).multiplyScalar(-e/ti.z)}getViewSize(e,t){return this.getViewBounds(e,Uh,Fh),t.subVectors(Fh,Uh)}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(Ka*.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 c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*s/c,t-=a.offsetY*n/l,s*=a.width/c,n*=a.height/l}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 Wp extends F0{constructor(){super(new Kt(90,1,.5,500)),this.isPointLightShadow=!0}}class Xp extends Cl{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 Wp}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 Oa extends O0{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,c=s-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,a=r+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class qp extends F0{constructor(){super(new Oa(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Yp extends Cl{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(xt.DEFAULT_UP),this.updateMatrix(),this.target=new xt,this.shadow=new qp}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 Qi=-90,ji=1;class Kp extends xt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new Kt(Qi,ji,e,t);s.layers=this.layers,this.add(s);const r=new Kt(Qi,ji,e,t);r.layers=this.layers,this.add(r);const a=new Kt(Qi,ji,e,t);a.layers=this.layers,this.add(a);const o=new Kt(Qi,ji,e,t);o.layers=this.layers,this.add(o);const c=new Kt(Qi,ji,e,t);c.layers=this.layers,this.add(c);const l=new Kt(Qi,ji,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,s,r,a,o,c]=t;for(const l of t)this.remove(l);if(e===Rn)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(e===rr)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: "+e);for(const l of t)this.add(l),l.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,c,l,h]=this.children,d=e.getRenderTarget(),u=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,c),e.setRenderTarget(n,4,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),n.texture.generateMipmaps=x,e.setRenderTarget(n,5,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(d,u,p),e.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class Zp extends Kt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const Oh=new st;class yo{constructor(e,t,n=0,s=1/0){this.ray=new Ua(e,t),this.near=n,this.far=s,this.camera=null,this.layers=new Tl,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):Xe("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Oh.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Oh),this}intersectObject(e,t=!0,n=[]){return Gc(e,this,n,t),n.sort(zh),n}intersectObjects(e,t=!0,n=[]){for(let s=0,r=e.length;s<r;s++)Gc(e[s],this,n,t);return n.sort(zh),n}}function zh(i,e){return i.distance-e.distance}function Gc(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++)Gc(r[a],e,t,!0)}}class z0{static{z0.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 Bh(i,e,t,n){const s=$p(n);switch(t){case S0:return i*e;case E0:return i*e/s.components*s.byteLength;case xl:return i*e/s.components*s.byteLength;case Di:return i*e*2/s.components*s.byteLength;case Ml:return i*e*2/s.components*s.byteLength;case y0:return i*e*3/s.components*s.byteLength;case dn:return i*e*4/s.components*s.byteLength;case Sl:return i*e*4/s.components*s.byteLength;case la:case ha:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case ua:case da:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case cc:case hc:return Math.max(i,16)*Math.max(e,8)/4;case oc:case lc:return Math.max(i,8)*Math.max(e,8)/2;case uc:case dc:case pc:case mc:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case fc:case ga:case gc:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case _c:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case vc:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case xc:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case Mc:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case Sc:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case yc:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case Ec:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case bc:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case Tc:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case Ac:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case wc:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case Rc:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case Cc:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case Pc:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case Dc:case Ic:case Lc:return Math.ceil(i/4)*Math.ceil(e/4)*16;case Nc:case Uc:return Math.ceil(i/4)*Math.ceil(e/4)*8;case _a:case Fc:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function $p(i){switch(i){case Zt:case _0:return{byteLength:1,components:1};case ir:case v0:case Vn:return{byteLength:2,components:1};case _l:case vl:return{byteLength:2,components:4};case Pn:case gl:case wn:return{byteLength:4,components:1};case x0:case M0: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:pl}}));typeof window<"u"&&(window.__THREE__?Fe("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=pl);/**
|
|
308
|
+
}`;class Bt extends Ui{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Ap,this.fragmentShader=wp,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=Es(e.uniforms),this.uniformsGroups=bp(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 Me().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 ut().fromArray(s.value);break;case"m3":this.uniforms[n].value=new ze().fromArray(s.value);break;case"m4":this.uniforms[n].value=new ot().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 Rp extends Bt{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class cr extends Ui{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Me(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Me(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Dc,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 fi,this.combine=ll,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 Cp extends Ui{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Gf,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 Pp extends Ui{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 bl extends St{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Me(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 Dp extends bl{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(St.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Me(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 mo=new ot,bh=new U,Th=new U;class A0{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=$t,this.map=null,this.mapPass=null,this.matrix=new ot,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new yl,this._frameExtents=new Fe(1,1),this._viewportCount=1,this._viewports=[new ut(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;bh.setFromMatrixPosition(e.matrixWorld),t.position.copy(bh),Th.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Th),t.updateMatrixWorld(),mo.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(mo,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===ar||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(mo)}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 Gr=new U,Hr=new Ts,vn=new U;class w0 extends St{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ot,this.projectionMatrix=new ot,this.projectionMatrixInverse=new ot,this.coordinateSystem=Cn,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(Gr,Hr,vn),vn.x===1&&vn.y===1&&vn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Gr,Hr,vn.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Gr,Hr,vn),vn.x===1&&vn.y===1&&vn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Gr,Hr,vn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const ti=new U,Ah=new Fe,wh=new Fe;class Zt extends w0{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=Lc*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Va*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Lc*2*Math.atan(Math.tan(Va*.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){ti.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(ti.x,ti.y).multiplyScalar(-e/ti.z),ti.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(ti.x,ti.y).multiplyScalar(-e/ti.z)}getViewSize(e,t){return this.getViewBounds(e,Ah,wh),t.subVectors(wh,Ah)}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(Va*.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 c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*s/c,t-=a.offsetY*n/l,s*=a.width/c,n*=a.height/l}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 Ip extends A0{constructor(){super(new Zt(90,1,.5,500)),this.isPointLightShadow=!0}}class Lp extends bl{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 Ip}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 Ia extends w0{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,c=s-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,a=r+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class Np extends A0{constructor(){super(new Ia(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Up extends bl{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(St.DEFAULT_UP),this.updateMatrix(),this.target=new St,this.shadow=new Np}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 ji=-90,es=1;class Fp extends St{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new Zt(ji,es,e,t);s.layers=this.layers,this.add(s);const r=new Zt(ji,es,e,t);r.layers=this.layers,this.add(r);const a=new Zt(ji,es,e,t);a.layers=this.layers,this.add(a);const o=new Zt(ji,es,e,t);o.layers=this.layers,this.add(o);const c=new Zt(ji,es,e,t);c.layers=this.layers,this.add(c);const l=new Zt(ji,es,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,s,r,a,o,c]=t;for(const l of t)this.remove(l);if(e===Cn)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(e===ar)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: "+e);for(const l of t)this.add(l),l.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,c,l,h]=this.children,d=e.getRenderTarget(),u=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const M=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,c),e.setRenderTarget(n,4,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),n.texture.generateMipmaps=M,e.setRenderTarget(n,5,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(d,u,p),e.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class Op extends Zt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const Rh=new ot;class go{constructor(e,t,n=0,s=1/0){this.ray=new Sl(e,t),this.near=n,this.far=s,this.camera=null,this.layers=new xl,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):Xe("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Rh.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Rh),this}intersectObject(e,t=!0,n=[]){return Uc(e,this,n,t),n.sort(Ch),n}intersectObjects(e,t=!0,n=[]){for(let s=0,r=e.length;s<r;s++)Uc(e[s],this,n,t);return n.sort(Ch),n}}function Ch(i,e){return i.distance-e.distance}function Uc(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++)Uc(r[a],e,t,!0)}}class R0{static{R0.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 Ph(i,e,t,n){const s=zp(n);switch(t){case d0:return i*e;case p0:return i*e/s.components*s.byteLength;case fl:return i*e/s.components*s.byteLength;case Di:return i*e*2/s.components*s.byteLength;case pl:return i*e*2/s.components*s.byteLength;case f0:return i*e*3/s.components*s.byteLength;case dn:return i*e*4/s.components*s.byteLength;case ml:return i*e*4/s.components*s.byteLength;case aa:case oa:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case ca:case la:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case nc:case sc:return Math.max(i,16)*Math.max(e,8)/4;case tc:case ic:return Math.max(i,8)*Math.max(e,8)/2;case rc:case ac:case cc:case lc:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case oc:case fa:case hc:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case uc:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case dc:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case fc:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case pc:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case mc:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case gc:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case _c:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case vc:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case xc:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case Mc:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case Sc:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case yc:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case Ec:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case bc:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case Tc:case Ac:case wc:return Math.ceil(i/4)*Math.ceil(e/4)*16;case Rc:case Cc:return Math.ceil(i/4)*Math.ceil(e/4)*8;case pa:case Pc:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function zp(i){switch(i){case $t:case c0:return{byteLength:1,components:1};case sr:case l0:case Vn:return{byteLength:2,components:1};case ul:case dl:return{byteLength:2,components:4};case Dn:case hl:case Rn:return{byteLength:4,components:1};case h0:case u0: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:cl}}));typeof window<"u"&&(window.__THREE__?Oe("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=cl);/**
|
|
302
309
|
* @license
|
|
303
310
|
* Copyright 2010-2026 Three.js Authors
|
|
304
311
|
* SPDX-License-Identifier: MIT
|
|
305
|
-
*/function
|
|
312
|
+
*/function C0(){let i=null,e=!1,t=null,n=null;function s(r,a){t(r,a),n=i.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&i!==null&&(n=i.requestAnimationFrame(s),e=!0)},stop:function(){i!==null&&i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){i=r}}}function Bp(i){const e=new WeakMap;function t(o,c){const l=o.array,h=o.usage,d=l.byteLength,u=i.createBuffer();i.bindBuffer(c,u),i.bufferData(c,l,h),o.onUploadCallback();let p;if(l instanceof Float32Array)p=i.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)p=i.HALF_FLOAT;else if(l instanceof Uint16Array)o.isFloat16BufferAttribute?p=i.HALF_FLOAT:p=i.UNSIGNED_SHORT;else if(l instanceof Int16Array)p=i.SHORT;else if(l instanceof Uint32Array)p=i.UNSIGNED_INT;else if(l instanceof Int32Array)p=i.INT;else if(l instanceof Int8Array)p=i.BYTE;else if(l instanceof Uint8Array)p=i.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)p=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:u,type:p,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:d}}function n(o,c,l){const h=c.array,d=c.updateRanges;if(i.bindBuffer(l,o),d.length===0)i.bufferSubData(l,0,h);else{d.sort((p,g)=>p.start-g.start);let u=0;for(let p=1;p<d.length;p++){const g=d[u],M=d[p];M.start<=g.start+g.count+1?g.count=Math.max(g.count,M.start+M.count-g.start):(++u,d[u]=M)}d.length=u+1;for(let p=0,g=d.length;p<g;p++){const M=d[p];i.bufferSubData(l,M.start*h.BYTES_PER_ELEMENT,h,M.start,M.count)}c.clearUpdateRanges()}c.onUploadCallback()}function s(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);const c=e.get(o);c&&(i.deleteBuffer(c.buffer),e.delete(o))}function a(o,c){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const h=e.get(o);(!h||h.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const l=e.get(o);if(l===void 0)e.set(o,t(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 kp=`#ifdef USE_ALPHAHASH
|
|
306
313
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
307
|
-
#endif`,
|
|
314
|
+
#endif`,Gp=`#ifdef USE_ALPHAHASH
|
|
308
315
|
const float ALPHA_HASH_SCALE = 0.05;
|
|
309
316
|
float hash2D( vec2 value ) {
|
|
310
317
|
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
|
|
@@ -339,20 +346,20 @@ input[type=range] {
|
|
|
339
346
|
: cases.z;
|
|
340
347
|
return clamp( threshold , 1.0e-6, 1.0 );
|
|
341
348
|
}
|
|
342
|
-
#endif`,
|
|
349
|
+
#endif`,Hp=`#ifdef USE_ALPHAMAP
|
|
343
350
|
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
|
344
|
-
#endif`,
|
|
351
|
+
#endif`,Vp=`#ifdef USE_ALPHAMAP
|
|
345
352
|
uniform sampler2D alphaMap;
|
|
346
|
-
#endif`,
|
|
353
|
+
#endif`,Wp=`#ifdef USE_ALPHATEST
|
|
347
354
|
#ifdef ALPHA_TO_COVERAGE
|
|
348
355
|
diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
|
|
349
356
|
if ( diffuseColor.a == 0.0 ) discard;
|
|
350
357
|
#else
|
|
351
358
|
if ( diffuseColor.a < alphaTest ) discard;
|
|
352
359
|
#endif
|
|
353
|
-
#endif`,
|
|
360
|
+
#endif`,Xp=`#ifdef USE_ALPHATEST
|
|
354
361
|
uniform float alphaTest;
|
|
355
|
-
#endif`,
|
|
362
|
+
#endif`,qp=`#ifdef USE_AOMAP
|
|
356
363
|
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
|
|
357
364
|
reflectedLight.indirectDiffuse *= ambientOcclusion;
|
|
358
365
|
#if defined( USE_CLEARCOAT )
|
|
@@ -365,10 +372,10 @@ input[type=range] {
|
|
|
365
372
|
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
|
|
366
373
|
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
|
|
367
374
|
#endif
|
|
368
|
-
#endif`,
|
|
375
|
+
#endif`,Yp=`#ifdef USE_AOMAP
|
|
369
376
|
uniform sampler2D aoMap;
|
|
370
377
|
uniform float aoMapIntensity;
|
|
371
|
-
#endif`,
|
|
378
|
+
#endif`,Kp=`#ifdef USE_BATCHING
|
|
372
379
|
#if ! defined( GL_ANGLE_multi_draw )
|
|
373
380
|
#define gl_DrawID _gl_DrawID
|
|
374
381
|
uniform int _gl_DrawID;
|
|
@@ -402,15 +409,15 @@ input[type=range] {
|
|
|
402
409
|
int y = j / size;
|
|
403
410
|
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
|
|
404
411
|
}
|
|
405
|
-
#endif`,
|
|
412
|
+
#endif`,Zp=`#ifdef USE_BATCHING
|
|
406
413
|
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
|
407
|
-
#endif
|
|
414
|
+
#endif`,$p=`vec3 transformed = vec3( position );
|
|
408
415
|
#ifdef USE_ALPHAHASH
|
|
409
416
|
vPosition = vec3( position );
|
|
410
|
-
#endif`,
|
|
417
|
+
#endif`,Jp=`vec3 objectNormal = vec3( normal );
|
|
411
418
|
#ifdef USE_TANGENT
|
|
412
419
|
vec3 objectTangent = vec3( tangent.xyz );
|
|
413
|
-
#endif`,
|
|
420
|
+
#endif`,Qp=`float G_BlinnPhong_Implicit( ) {
|
|
414
421
|
return 0.25;
|
|
415
422
|
}
|
|
416
423
|
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
|
|
@@ -424,7 +431,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
424
431
|
float G = G_BlinnPhong_Implicit( );
|
|
425
432
|
float D = D_BlinnPhong( shininess, dotNH );
|
|
426
433
|
return F * ( G * D );
|
|
427
|
-
} // validated`,
|
|
434
|
+
} // validated`,jp=`#ifdef USE_IRIDESCENCE
|
|
428
435
|
const mat3 XYZ_TO_REC709 = mat3(
|
|
429
436
|
3.2404542, -0.9692660, 0.0556434,
|
|
430
437
|
-1.5371385, 1.8760108, -0.2040259,
|
|
@@ -487,7 +494,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
487
494
|
}
|
|
488
495
|
return max( I, vec3( 0.0 ) );
|
|
489
496
|
}
|
|
490
|
-
#endif`,
|
|
497
|
+
#endif`,em=`#ifdef USE_BUMPMAP
|
|
491
498
|
uniform sampler2D bumpMap;
|
|
492
499
|
uniform float bumpScale;
|
|
493
500
|
vec2 dHdxy_fwd() {
|
|
@@ -508,7 +515,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
508
515
|
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
|
509
516
|
return normalize( abs( fDet ) * surf_norm - vGrad );
|
|
510
517
|
}
|
|
511
|
-
#endif`,
|
|
518
|
+
#endif`,tm=`#if NUM_CLIPPING_PLANES > 0
|
|
512
519
|
vec4 plane;
|
|
513
520
|
#ifdef ALPHA_TO_COVERAGE
|
|
514
521
|
float distanceToPlane, distanceGradient;
|
|
@@ -554,20 +561,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
554
561
|
if ( clipped ) discard;
|
|
555
562
|
#endif
|
|
556
563
|
#endif
|
|
557
|
-
#endif`,
|
|
564
|
+
#endif`,nm=`#if NUM_CLIPPING_PLANES > 0
|
|
558
565
|
varying vec3 vClipPosition;
|
|
559
566
|
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
|
560
|
-
#endif`,
|
|
567
|
+
#endif`,im=`#if NUM_CLIPPING_PLANES > 0
|
|
561
568
|
varying vec3 vClipPosition;
|
|
562
|
-
#endif`,
|
|
569
|
+
#endif`,sm=`#if NUM_CLIPPING_PLANES > 0
|
|
563
570
|
vClipPosition = - mvPosition.xyz;
|
|
564
|
-
#endif`,
|
|
571
|
+
#endif`,rm=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
|
565
572
|
diffuseColor *= vColor;
|
|
566
|
-
#endif`,
|
|
573
|
+
#endif`,am=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
|
567
574
|
varying vec4 vColor;
|
|
568
|
-
#endif`,
|
|
575
|
+
#endif`,om=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
569
576
|
varying vec4 vColor;
|
|
570
|
-
#endif`,
|
|
577
|
+
#endif`,cm=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
571
578
|
vColor = vec4( 1.0 );
|
|
572
579
|
#endif
|
|
573
580
|
#ifdef USE_COLOR_ALPHA
|
|
@@ -580,7 +587,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
580
587
|
#endif
|
|
581
588
|
#ifdef USE_BATCHING_COLOR
|
|
582
589
|
vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
|
|
583
|
-
#endif`,
|
|
590
|
+
#endif`,lm=`#define PI 3.141592653589793
|
|
584
591
|
#define PI2 6.283185307179586
|
|
585
592
|
#define PI_HALF 1.5707963267948966
|
|
586
593
|
#define RECIPROCAL_PI 0.3183098861837907
|
|
@@ -651,7 +658,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
|
|
|
651
658
|
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
|
652
659
|
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
|
653
660
|
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
|
654
|
-
} // validated`,
|
|
661
|
+
} // validated`,hm=`#ifdef ENVMAP_TYPE_CUBE_UV
|
|
655
662
|
#define cubeUV_minMipLevel 4.0
|
|
656
663
|
#define cubeUV_minTileSize 16.0
|
|
657
664
|
float getFace( vec3 direction ) {
|
|
@@ -744,7 +751,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
|
|
744
751
|
return vec4( mix( color0, color1, mipF ), 1.0 );
|
|
745
752
|
}
|
|
746
753
|
}
|
|
747
|
-
#endif`,
|
|
754
|
+
#endif`,um=`vec3 transformedNormal = objectNormal;
|
|
748
755
|
#ifdef USE_TANGENT
|
|
749
756
|
vec3 transformedTangent = objectTangent;
|
|
750
757
|
#endif
|
|
@@ -770,21 +777,21 @@ transformedNormal = normalMatrix * transformedNormal;
|
|
|
770
777
|
#endif
|
|
771
778
|
#ifdef USE_TANGENT
|
|
772
779
|
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
|
|
773
|
-
#endif`,
|
|
780
|
+
#endif`,dm=`#ifdef USE_DISPLACEMENTMAP
|
|
774
781
|
uniform sampler2D displacementMap;
|
|
775
782
|
uniform float displacementScale;
|
|
776
783
|
uniform float displacementBias;
|
|
777
|
-
#endif`,
|
|
784
|
+
#endif`,fm=`#ifdef USE_DISPLACEMENTMAP
|
|
778
785
|
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
|
779
|
-
#endif`,
|
|
786
|
+
#endif`,pm=`#ifdef USE_EMISSIVEMAP
|
|
780
787
|
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
|
781
788
|
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
|
|
782
789
|
emissiveColor = sRGBTransferEOTF( emissiveColor );
|
|
783
790
|
#endif
|
|
784
791
|
totalEmissiveRadiance *= emissiveColor.rgb;
|
|
785
|
-
#endif`,
|
|
792
|
+
#endif`,mm=`#ifdef USE_EMISSIVEMAP
|
|
786
793
|
uniform sampler2D emissiveMap;
|
|
787
|
-
#endif`,
|
|
794
|
+
#endif`,gm="gl_FragColor = linearToOutputTexel( gl_FragColor );",_m=`vec4 LinearTransferOETF( in vec4 value ) {
|
|
788
795
|
return value;
|
|
789
796
|
}
|
|
790
797
|
vec4 sRGBTransferEOTF( in vec4 value ) {
|
|
@@ -792,7 +799,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {
|
|
|
792
799
|
}
|
|
793
800
|
vec4 sRGBTransferOETF( in vec4 value ) {
|
|
794
801
|
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 );
|
|
795
|
-
}`,
|
|
802
|
+
}`,vm=`#ifdef USE_ENVMAP
|
|
796
803
|
#ifdef ENV_WORLDPOS
|
|
797
804
|
vec3 cameraToFrag;
|
|
798
805
|
if ( isOrthographic ) {
|
|
@@ -819,7 +826,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
819
826
|
outgoingLight += envColor.xyz * specularStrength * reflectivity;
|
|
820
827
|
#endif
|
|
821
828
|
#endif
|
|
822
|
-
#endif`,
|
|
829
|
+
#endif`,xm=`#ifdef USE_ENVMAP
|
|
823
830
|
uniform float envMapIntensity;
|
|
824
831
|
uniform mat3 envMapRotation;
|
|
825
832
|
#ifdef ENVMAP_TYPE_CUBE
|
|
@@ -827,7 +834,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
827
834
|
#else
|
|
828
835
|
uniform sampler2D envMap;
|
|
829
836
|
#endif
|
|
830
|
-
#endif`,
|
|
837
|
+
#endif`,Mm=`#ifdef USE_ENVMAP
|
|
831
838
|
uniform float reflectivity;
|
|
832
839
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
833
840
|
#define ENV_WORLDPOS
|
|
@@ -838,7 +845,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
838
845
|
#else
|
|
839
846
|
varying vec3 vReflect;
|
|
840
847
|
#endif
|
|
841
|
-
#endif`,
|
|
848
|
+
#endif`,Sm=`#ifdef USE_ENVMAP
|
|
842
849
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
843
850
|
#define ENV_WORLDPOS
|
|
844
851
|
#endif
|
|
@@ -849,7 +856,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
849
856
|
varying vec3 vReflect;
|
|
850
857
|
uniform float refractionRatio;
|
|
851
858
|
#endif
|
|
852
|
-
#endif`,
|
|
859
|
+
#endif`,ym=`#ifdef USE_ENVMAP
|
|
853
860
|
#ifdef ENV_WORLDPOS
|
|
854
861
|
vWorldPosition = worldPosition.xyz;
|
|
855
862
|
#else
|
|
@@ -866,18 +873,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
866
873
|
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
|
|
867
874
|
#endif
|
|
868
875
|
#endif
|
|
869
|
-
#endif`,
|
|
876
|
+
#endif`,Em=`#ifdef USE_FOG
|
|
870
877
|
vFogDepth = - mvPosition.z;
|
|
871
|
-
#endif`,
|
|
878
|
+
#endif`,bm=`#ifdef USE_FOG
|
|
872
879
|
varying float vFogDepth;
|
|
873
|
-
#endif`,
|
|
880
|
+
#endif`,Tm=`#ifdef USE_FOG
|
|
874
881
|
#ifdef FOG_EXP2
|
|
875
882
|
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
|
|
876
883
|
#else
|
|
877
884
|
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
|
|
878
885
|
#endif
|
|
879
886
|
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
|
|
880
|
-
#endif`,
|
|
887
|
+
#endif`,Am=`#ifdef USE_FOG
|
|
881
888
|
uniform vec3 fogColor;
|
|
882
889
|
varying float vFogDepth;
|
|
883
890
|
#ifdef FOG_EXP2
|
|
@@ -886,7 +893,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
886
893
|
uniform float fogNear;
|
|
887
894
|
uniform float fogFar;
|
|
888
895
|
#endif
|
|
889
|
-
#endif`,
|
|
896
|
+
#endif`,wm=`#ifdef USE_GRADIENTMAP
|
|
890
897
|
uniform sampler2D gradientMap;
|
|
891
898
|
#endif
|
|
892
899
|
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
@@ -898,12 +905,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
|
898
905
|
vec2 fw = fwidth( coord ) * 0.5;
|
|
899
906
|
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
|
|
900
907
|
#endif
|
|
901
|
-
}`,
|
|
908
|
+
}`,Rm=`#ifdef USE_LIGHTMAP
|
|
902
909
|
uniform sampler2D lightMap;
|
|
903
910
|
uniform float lightMapIntensity;
|
|
904
|
-
#endif`,
|
|
911
|
+
#endif`,Cm=`LambertMaterial material;
|
|
905
912
|
material.diffuseColor = diffuseColor.rgb;
|
|
906
|
-
material.specularStrength = specularStrength;`,
|
|
913
|
+
material.specularStrength = specularStrength;`,Pm=`varying vec3 vViewPosition;
|
|
907
914
|
struct LambertMaterial {
|
|
908
915
|
vec3 diffuseColor;
|
|
909
916
|
float specularStrength;
|
|
@@ -917,7 +924,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
|
|
|
917
924
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
918
925
|
}
|
|
919
926
|
#define RE_Direct RE_Direct_Lambert
|
|
920
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,
|
|
927
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Dm=`uniform bool receiveShadow;
|
|
921
928
|
uniform vec3 ambientLightColor;
|
|
922
929
|
#if defined( USE_LIGHT_PROBES )
|
|
923
930
|
uniform vec3 lightProbe[ 9 ];
|
|
@@ -1034,7 +1041,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
1034
1041
|
return irradiance;
|
|
1035
1042
|
}
|
|
1036
1043
|
#endif
|
|
1037
|
-
#include <lightprobes_pars_fragment>`,
|
|
1044
|
+
#include <lightprobes_pars_fragment>`,Im=`#ifdef USE_ENVMAP
|
|
1038
1045
|
vec3 getIBLIrradiance( const in vec3 normal ) {
|
|
1039
1046
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
1040
1047
|
vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
|
|
@@ -1067,8 +1074,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
1067
1074
|
#endif
|
|
1068
1075
|
}
|
|
1069
1076
|
#endif
|
|
1070
|
-
#endif`,
|
|
1071
|
-
material.diffuseColor = diffuseColor.rgb;`,
|
|
1077
|
+
#endif`,Lm=`ToonMaterial material;
|
|
1078
|
+
material.diffuseColor = diffuseColor.rgb;`,Nm=`varying vec3 vViewPosition;
|
|
1072
1079
|
struct ToonMaterial {
|
|
1073
1080
|
vec3 diffuseColor;
|
|
1074
1081
|
};
|
|
@@ -1080,11 +1087,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
|
|
|
1080
1087
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
1081
1088
|
}
|
|
1082
1089
|
#define RE_Direct RE_Direct_Toon
|
|
1083
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,
|
|
1090
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Um=`BlinnPhongMaterial material;
|
|
1084
1091
|
material.diffuseColor = diffuseColor.rgb;
|
|
1085
1092
|
material.specularColor = specular;
|
|
1086
1093
|
material.specularShininess = shininess;
|
|
1087
|
-
material.specularStrength = specularStrength;`,
|
|
1094
|
+
material.specularStrength = specularStrength;`,Fm=`varying vec3 vViewPosition;
|
|
1088
1095
|
struct BlinnPhongMaterial {
|
|
1089
1096
|
vec3 diffuseColor;
|
|
1090
1097
|
vec3 specularColor;
|
|
@@ -1101,7 +1108,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
|
|
|
1101
1108
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
1102
1109
|
}
|
|
1103
1110
|
#define RE_Direct RE_Direct_BlinnPhong
|
|
1104
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,
|
|
1111
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Om=`PhysicalMaterial material;
|
|
1105
1112
|
material.diffuseColor = diffuseColor.rgb;
|
|
1106
1113
|
material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
|
1107
1114
|
material.metalness = metalnessFactor;
|
|
@@ -1191,7 +1198,7 @@ material.roughness = min( material.roughness, 1.0 );
|
|
|
1191
1198
|
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
|
|
1192
1199
|
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
|
|
1193
1200
|
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
|
|
1194
|
-
#endif
|
|
1201
|
+
#endif`,zm=`uniform sampler2D dfgLUT;
|
|
1195
1202
|
struct PhysicalMaterial {
|
|
1196
1203
|
vec3 diffuseColor;
|
|
1197
1204
|
vec3 diffuseContribution;
|
|
@@ -1551,7 +1558,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
|
|
|
1551
1558
|
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
|
1552
1559
|
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
|
1553
1560
|
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
|
1554
|
-
}`,
|
|
1561
|
+
}`,Bm=`
|
|
1555
1562
|
vec3 geometryPosition = - vViewPosition;
|
|
1556
1563
|
vec3 geometryNormal = normal;
|
|
1557
1564
|
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
@@ -1673,7 +1680,7 @@ IncidentLight directLight;
|
|
|
1673
1680
|
#if defined( RE_IndirectSpecular )
|
|
1674
1681
|
vec3 radiance = vec3( 0.0 );
|
|
1675
1682
|
vec3 clearcoatRadiance = vec3( 0.0 );
|
|
1676
|
-
#endif`,
|
|
1683
|
+
#endif`,km=`#if defined( RE_IndirectDiffuse )
|
|
1677
1684
|
#ifdef USE_LIGHTMAP
|
|
1678
1685
|
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
1679
1686
|
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
|
@@ -1694,7 +1701,7 @@ IncidentLight directLight;
|
|
|
1694
1701
|
#ifdef USE_CLEARCOAT
|
|
1695
1702
|
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
|
|
1696
1703
|
#endif
|
|
1697
|
-
#endif`,
|
|
1704
|
+
#endif`,Gm=`#if defined( RE_IndirectDiffuse )
|
|
1698
1705
|
#if defined( LAMBERT ) || defined( PHONG )
|
|
1699
1706
|
irradiance += iblIrradiance;
|
|
1700
1707
|
#endif
|
|
@@ -1702,7 +1709,7 @@ IncidentLight directLight;
|
|
|
1702
1709
|
#endif
|
|
1703
1710
|
#if defined( RE_IndirectSpecular )
|
|
1704
1711
|
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1705
|
-
#endif`,
|
|
1712
|
+
#endif`,Hm=`#ifdef USE_LIGHT_PROBES_GRID
|
|
1706
1713
|
uniform highp sampler3D probesSH;
|
|
1707
1714
|
uniform vec3 probesMin;
|
|
1708
1715
|
uniform vec3 probesMax;
|
|
@@ -1747,27 +1754,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1747
1754
|
result += c8 * 0.429043 * ( x * x - y * y );
|
|
1748
1755
|
return max( result, vec3( 0.0 ) );
|
|
1749
1756
|
}
|
|
1750
|
-
#endif`,
|
|
1757
|
+
#endif`,Vm=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
1751
1758
|
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
|
1752
|
-
#endif`,
|
|
1759
|
+
#endif`,Wm=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
1753
1760
|
uniform float logDepthBufFC;
|
|
1754
1761
|
varying float vFragDepth;
|
|
1755
1762
|
varying float vIsPerspective;
|
|
1756
|
-
#endif`,
|
|
1763
|
+
#endif`,Xm=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
1757
1764
|
varying float vFragDepth;
|
|
1758
1765
|
varying float vIsPerspective;
|
|
1759
|
-
#endif`,
|
|
1766
|
+
#endif`,qm=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
1760
1767
|
vFragDepth = 1.0 + gl_Position.w;
|
|
1761
1768
|
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
1762
|
-
#endif`,
|
|
1769
|
+
#endif`,Ym=`#ifdef USE_MAP
|
|
1763
1770
|
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
|
1764
1771
|
#ifdef DECODE_VIDEO_TEXTURE
|
|
1765
1772
|
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
|
|
1766
1773
|
#endif
|
|
1767
1774
|
diffuseColor *= sampledDiffuseColor;
|
|
1768
|
-
#endif`,
|
|
1775
|
+
#endif`,Km=`#ifdef USE_MAP
|
|
1769
1776
|
uniform sampler2D map;
|
|
1770
|
-
#endif`,
|
|
1777
|
+
#endif`,Zm=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
1771
1778
|
#if defined( USE_POINTS_UV )
|
|
1772
1779
|
vec2 uv = vUv;
|
|
1773
1780
|
#else
|
|
@@ -1779,7 +1786,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1779
1786
|
#endif
|
|
1780
1787
|
#ifdef USE_ALPHAMAP
|
|
1781
1788
|
diffuseColor.a *= texture2D( alphaMap, uv ).g;
|
|
1782
|
-
#endif
|
|
1789
|
+
#endif`,$m=`#if defined( USE_POINTS_UV )
|
|
1783
1790
|
varying vec2 vUv;
|
|
1784
1791
|
#else
|
|
1785
1792
|
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
@@ -1791,19 +1798,19 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1791
1798
|
#endif
|
|
1792
1799
|
#ifdef USE_ALPHAMAP
|
|
1793
1800
|
uniform sampler2D alphaMap;
|
|
1794
|
-
#endif`,
|
|
1801
|
+
#endif`,Jm=`float metalnessFactor = metalness;
|
|
1795
1802
|
#ifdef USE_METALNESSMAP
|
|
1796
1803
|
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
|
1797
1804
|
metalnessFactor *= texelMetalness.b;
|
|
1798
|
-
#endif`,
|
|
1805
|
+
#endif`,Qm=`#ifdef USE_METALNESSMAP
|
|
1799
1806
|
uniform sampler2D metalnessMap;
|
|
1800
|
-
#endif`,
|
|
1807
|
+
#endif`,jm=`#ifdef USE_INSTANCING_MORPH
|
|
1801
1808
|
float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
1802
1809
|
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
|
|
1803
1810
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1804
1811
|
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
|
|
1805
1812
|
}
|
|
1806
|
-
#endif`,
|
|
1813
|
+
#endif`,eg=`#if defined( USE_MORPHCOLORS )
|
|
1807
1814
|
vColor *= morphTargetBaseInfluence;
|
|
1808
1815
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1809
1816
|
#if defined( USE_COLOR_ALPHA )
|
|
@@ -1812,12 +1819,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1812
1819
|
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
|
|
1813
1820
|
#endif
|
|
1814
1821
|
}
|
|
1815
|
-
#endif`,
|
|
1822
|
+
#endif`,tg=`#ifdef USE_MORPHNORMALS
|
|
1816
1823
|
objectNormal *= morphTargetBaseInfluence;
|
|
1817
1824
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1818
1825
|
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
|
|
1819
1826
|
}
|
|
1820
|
-
#endif`,
|
|
1827
|
+
#endif`,ng=`#ifdef USE_MORPHTARGETS
|
|
1821
1828
|
#ifndef USE_INSTANCING_MORPH
|
|
1822
1829
|
uniform float morphTargetBaseInfluence;
|
|
1823
1830
|
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
@@ -1831,12 +1838,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1831
1838
|
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
|
|
1832
1839
|
return texelFetch( morphTargetsTexture, morphUV, 0 );
|
|
1833
1840
|
}
|
|
1834
|
-
#endif`,
|
|
1841
|
+
#endif`,ig=`#ifdef USE_MORPHTARGETS
|
|
1835
1842
|
transformed *= morphTargetBaseInfluence;
|
|
1836
1843
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1837
1844
|
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
|
|
1838
1845
|
}
|
|
1839
|
-
#endif`,
|
|
1846
|
+
#endif`,sg=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
|
|
1840
1847
|
#ifdef FLAT_SHADED
|
|
1841
1848
|
vec3 fdx = dFdx( vViewPosition );
|
|
1842
1849
|
vec3 fdy = dFdy( vViewPosition );
|
|
@@ -1877,7 +1884,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1877
1884
|
tbn2[1] *= faceDirection;
|
|
1878
1885
|
#endif
|
|
1879
1886
|
#endif
|
|
1880
|
-
vec3 nonPerturbedNormal = normal;`,
|
|
1887
|
+
vec3 nonPerturbedNormal = normal;`,rg=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
1881
1888
|
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|
1882
1889
|
#ifdef FLIP_SIDED
|
|
1883
1890
|
normal = - normal;
|
|
@@ -1895,19 +1902,19 @@ vec3 nonPerturbedNormal = normal;`,_g=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1895
1902
|
normal = normalize( tbn * mapN );
|
|
1896
1903
|
#elif defined( USE_BUMPMAP )
|
|
1897
1904
|
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
|
|
1898
|
-
#endif`,
|
|
1905
|
+
#endif`,ag=`#ifndef FLAT_SHADED
|
|
1899
1906
|
varying vec3 vNormal;
|
|
1900
1907
|
#ifdef USE_TANGENT
|
|
1901
1908
|
varying vec3 vTangent;
|
|
1902
1909
|
varying vec3 vBitangent;
|
|
1903
1910
|
#endif
|
|
1904
|
-
#endif`,
|
|
1911
|
+
#endif`,og=`#ifndef FLAT_SHADED
|
|
1905
1912
|
varying vec3 vNormal;
|
|
1906
1913
|
#ifdef USE_TANGENT
|
|
1907
1914
|
varying vec3 vTangent;
|
|
1908
1915
|
varying vec3 vBitangent;
|
|
1909
1916
|
#endif
|
|
1910
|
-
#endif`,
|
|
1917
|
+
#endif`,cg=`#ifndef FLAT_SHADED
|
|
1911
1918
|
vNormal = normalize( transformedNormal );
|
|
1912
1919
|
#ifdef USE_TANGENT
|
|
1913
1920
|
vTangent = normalize( transformedTangent );
|
|
@@ -1916,7 +1923,7 @@ vec3 nonPerturbedNormal = normal;`,_g=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1916
1923
|
vBitangent = - vBitangent;
|
|
1917
1924
|
#endif
|
|
1918
1925
|
#endif
|
|
1919
|
-
#endif`,
|
|
1926
|
+
#endif`,lg=`#ifdef USE_NORMALMAP
|
|
1920
1927
|
uniform sampler2D normalMap;
|
|
1921
1928
|
uniform vec2 normalScale;
|
|
1922
1929
|
#endif
|
|
@@ -1938,13 +1945,13 @@ vec3 nonPerturbedNormal = normal;`,_g=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1938
1945
|
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
|
|
1939
1946
|
return mat3( T * scale, B * scale, N );
|
|
1940
1947
|
}
|
|
1941
|
-
#endif`,
|
|
1948
|
+
#endif`,hg=`#ifdef USE_CLEARCOAT
|
|
1942
1949
|
vec3 clearcoatNormal = nonPerturbedNormal;
|
|
1943
|
-
#endif`,
|
|
1950
|
+
#endif`,ug=`#ifdef USE_CLEARCOAT_NORMALMAP
|
|
1944
1951
|
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
|
1945
1952
|
clearcoatMapN.xy *= clearcoatNormalScale;
|
|
1946
1953
|
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
|
1947
|
-
#endif`,
|
|
1954
|
+
#endif`,dg=`#ifdef USE_CLEARCOATMAP
|
|
1948
1955
|
uniform sampler2D clearcoatMap;
|
|
1949
1956
|
#endif
|
|
1950
1957
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
@@ -1953,18 +1960,18 @@ vec3 nonPerturbedNormal = normal;`,_g=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1953
1960
|
#endif
|
|
1954
1961
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
1955
1962
|
uniform sampler2D clearcoatRoughnessMap;
|
|
1956
|
-
#endif`,
|
|
1963
|
+
#endif`,fg=`#ifdef USE_IRIDESCENCEMAP
|
|
1957
1964
|
uniform sampler2D iridescenceMap;
|
|
1958
1965
|
#endif
|
|
1959
1966
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
1960
1967
|
uniform sampler2D iridescenceThicknessMap;
|
|
1961
|
-
#endif`,
|
|
1968
|
+
#endif`,pg=`#ifdef OPAQUE
|
|
1962
1969
|
diffuseColor.a = 1.0;
|
|
1963
1970
|
#endif
|
|
1964
1971
|
#ifdef USE_TRANSMISSION
|
|
1965
1972
|
diffuseColor.a *= material.transmissionAlpha;
|
|
1966
1973
|
#endif
|
|
1967
|
-
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,
|
|
1974
|
+
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,mg=`vec3 packNormalToRGB( const in vec3 normal ) {
|
|
1968
1975
|
return normalize( normal ) * 0.5 + 0.5;
|
|
1969
1976
|
}
|
|
1970
1977
|
vec3 unpackRGBToNormal( const in vec3 rgb ) {
|
|
@@ -2043,9 +2050,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
|
|
|
2043
2050
|
#else
|
|
2044
2051
|
return ( near * far ) / ( ( far - near ) * depth - far );
|
|
2045
2052
|
#endif
|
|
2046
|
-
}`,
|
|
2053
|
+
}`,gg=`#ifdef PREMULTIPLIED_ALPHA
|
|
2047
2054
|
gl_FragColor.rgb *= gl_FragColor.a;
|
|
2048
|
-
#endif`,
|
|
2055
|
+
#endif`,_g=`vec4 mvPosition = vec4( transformed, 1.0 );
|
|
2049
2056
|
#ifdef USE_BATCHING
|
|
2050
2057
|
mvPosition = batchingMatrix * mvPosition;
|
|
2051
2058
|
#endif
|
|
@@ -2053,22 +2060,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
|
|
|
2053
2060
|
mvPosition = instanceMatrix * mvPosition;
|
|
2054
2061
|
#endif
|
|
2055
2062
|
mvPosition = modelViewMatrix * mvPosition;
|
|
2056
|
-
gl_Position = projectionMatrix * mvPosition;`,
|
|
2063
|
+
gl_Position = projectionMatrix * mvPosition;`,vg=`#ifdef DITHERING
|
|
2057
2064
|
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
|
2058
|
-
#endif`,
|
|
2065
|
+
#endif`,xg=`#ifdef DITHERING
|
|
2059
2066
|
vec3 dithering( vec3 color ) {
|
|
2060
2067
|
float grid_position = rand( gl_FragCoord.xy );
|
|
2061
2068
|
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
|
|
2062
2069
|
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
|
|
2063
2070
|
return color + dither_shift_RGB;
|
|
2064
2071
|
}
|
|
2065
|
-
#endif`,
|
|
2072
|
+
#endif`,Mg=`float roughnessFactor = roughness;
|
|
2066
2073
|
#ifdef USE_ROUGHNESSMAP
|
|
2067
2074
|
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
|
2068
2075
|
roughnessFactor *= texelRoughness.g;
|
|
2069
|
-
#endif`,
|
|
2076
|
+
#endif`,Sg=`#ifdef USE_ROUGHNESSMAP
|
|
2070
2077
|
uniform sampler2D roughnessMap;
|
|
2071
|
-
#endif`,
|
|
2078
|
+
#endif`,yg=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
2072
2079
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
2073
2080
|
#endif
|
|
2074
2081
|
#if NUM_SPOT_LIGHT_MAPS > 0
|
|
@@ -2268,7 +2275,7 @@ gl_Position = projectionMatrix * mvPosition;`,Pg=`#ifdef DITHERING
|
|
|
2268
2275
|
}
|
|
2269
2276
|
#endif
|
|
2270
2277
|
#endif
|
|
2271
|
-
#endif`,
|
|
2278
|
+
#endif`,Eg=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
2272
2279
|
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
|
|
2273
2280
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
2274
2281
|
#endif
|
|
@@ -2309,7 +2316,7 @@ gl_Position = projectionMatrix * mvPosition;`,Pg=`#ifdef DITHERING
|
|
|
2309
2316
|
};
|
|
2310
2317
|
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
2311
2318
|
#endif
|
|
2312
|
-
#endif`,
|
|
2319
|
+
#endif`,bg=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
|
|
2313
2320
|
#ifdef HAS_NORMAL
|
|
2314
2321
|
vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
|
|
2315
2322
|
#else
|
|
@@ -2345,7 +2352,7 @@ gl_Position = projectionMatrix * mvPosition;`,Pg=`#ifdef DITHERING
|
|
|
2345
2352
|
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
|
|
2346
2353
|
}
|
|
2347
2354
|
#pragma unroll_loop_end
|
|
2348
|
-
#endif`,
|
|
2355
|
+
#endif`,Tg=`float getShadowMask() {
|
|
2349
2356
|
float shadow = 1.0;
|
|
2350
2357
|
#ifdef USE_SHADOWMAP
|
|
2351
2358
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
@@ -2377,12 +2384,12 @@ gl_Position = projectionMatrix * mvPosition;`,Pg=`#ifdef DITHERING
|
|
|
2377
2384
|
#endif
|
|
2378
2385
|
#endif
|
|
2379
2386
|
return shadow;
|
|
2380
|
-
}`,
|
|
2387
|
+
}`,Ag=`#ifdef USE_SKINNING
|
|
2381
2388
|
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
|
2382
2389
|
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
|
2383
2390
|
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
|
2384
2391
|
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
|
2385
|
-
#endif`,
|
|
2392
|
+
#endif`,wg=`#ifdef USE_SKINNING
|
|
2386
2393
|
uniform mat4 bindMatrix;
|
|
2387
2394
|
uniform mat4 bindMatrixInverse;
|
|
2388
2395
|
uniform highp sampler2D boneTexture;
|
|
@@ -2397,7 +2404,7 @@ gl_Position = projectionMatrix * mvPosition;`,Pg=`#ifdef DITHERING
|
|
|
2397
2404
|
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
|
|
2398
2405
|
return mat4( v1, v2, v3, v4 );
|
|
2399
2406
|
}
|
|
2400
|
-
#endif`,
|
|
2407
|
+
#endif`,Rg=`#ifdef USE_SKINNING
|
|
2401
2408
|
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
|
|
2402
2409
|
vec4 skinned = vec4( 0.0 );
|
|
2403
2410
|
skinned += boneMatX * skinVertex * skinWeight.x;
|
|
@@ -2405,7 +2412,7 @@ gl_Position = projectionMatrix * mvPosition;`,Pg=`#ifdef DITHERING
|
|
|
2405
2412
|
skinned += boneMatZ * skinVertex * skinWeight.z;
|
|
2406
2413
|
skinned += boneMatW * skinVertex * skinWeight.w;
|
|
2407
2414
|
transformed = ( bindMatrixInverse * skinned ).xyz;
|
|
2408
|
-
#endif`,
|
|
2415
|
+
#endif`,Cg=`#ifdef USE_SKINNING
|
|
2409
2416
|
mat4 skinMatrix = mat4( 0.0 );
|
|
2410
2417
|
skinMatrix += skinWeight.x * boneMatX;
|
|
2411
2418
|
skinMatrix += skinWeight.y * boneMatY;
|
|
@@ -2416,17 +2423,17 @@ gl_Position = projectionMatrix * mvPosition;`,Pg=`#ifdef DITHERING
|
|
|
2416
2423
|
#ifdef USE_TANGENT
|
|
2417
2424
|
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
|
2418
2425
|
#endif
|
|
2419
|
-
#endif`,
|
|
2426
|
+
#endif`,Pg=`float specularStrength;
|
|
2420
2427
|
#ifdef USE_SPECULARMAP
|
|
2421
2428
|
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
|
2422
2429
|
specularStrength = texelSpecular.r;
|
|
2423
2430
|
#else
|
|
2424
2431
|
specularStrength = 1.0;
|
|
2425
|
-
#endif`,
|
|
2432
|
+
#endif`,Dg=`#ifdef USE_SPECULARMAP
|
|
2426
2433
|
uniform sampler2D specularMap;
|
|
2427
|
-
#endif`,
|
|
2434
|
+
#endif`,Ig=`#if defined( TONE_MAPPING )
|
|
2428
2435
|
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
|
2429
|
-
#endif`,
|
|
2436
|
+
#endif`,Lg=`#ifndef saturate
|
|
2430
2437
|
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|
2431
2438
|
#endif
|
|
2432
2439
|
uniform float toneMappingExposure;
|
|
@@ -2523,7 +2530,7 @@ vec3 NeutralToneMapping( vec3 color ) {
|
|
|
2523
2530
|
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
|
|
2524
2531
|
return mix( color, vec3( newPeak ), g );
|
|
2525
2532
|
}
|
|
2526
|
-
vec3 CustomToneMapping( vec3 color ) { return color; }`,
|
|
2533
|
+
vec3 CustomToneMapping( vec3 color ) { return color; }`,Ng=`#ifdef USE_TRANSMISSION
|
|
2527
2534
|
material.transmission = transmission;
|
|
2528
2535
|
material.transmissionAlpha = 1.0;
|
|
2529
2536
|
material.thickness = thickness;
|
|
@@ -2544,7 +2551,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,qg=`#ifdef USE_TRANSMISS
|
|
|
2544
2551
|
material.attenuationColor, material.attenuationDistance );
|
|
2545
2552
|
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
|
|
2546
2553
|
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
|
|
2547
|
-
#endif`,
|
|
2554
|
+
#endif`,Ug=`#ifdef USE_TRANSMISSION
|
|
2548
2555
|
uniform float transmission;
|
|
2549
2556
|
uniform float thickness;
|
|
2550
2557
|
uniform float attenuationDistance;
|
|
@@ -2670,7 +2677,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,qg=`#ifdef USE_TRANSMISS
|
|
|
2670
2677
|
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
|
|
2671
2678
|
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
|
|
2672
2679
|
}
|
|
2673
|
-
#endif`,
|
|
2680
|
+
#endif`,Fg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2674
2681
|
varying vec2 vUv;
|
|
2675
2682
|
#endif
|
|
2676
2683
|
#ifdef USE_MAP
|
|
@@ -2740,7 +2747,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,qg=`#ifdef USE_TRANSMISS
|
|
|
2740
2747
|
#ifdef USE_THICKNESSMAP
|
|
2741
2748
|
uniform mat3 thicknessMapTransform;
|
|
2742
2749
|
varying vec2 vThicknessMapUv;
|
|
2743
|
-
#endif`,
|
|
2750
|
+
#endif`,Og=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2744
2751
|
varying vec2 vUv;
|
|
2745
2752
|
#endif
|
|
2746
2753
|
#ifdef USE_MAP
|
|
@@ -2834,7 +2841,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,qg=`#ifdef USE_TRANSMISS
|
|
|
2834
2841
|
#ifdef USE_THICKNESSMAP
|
|
2835
2842
|
uniform mat3 thicknessMapTransform;
|
|
2836
2843
|
varying vec2 vThicknessMapUv;
|
|
2837
|
-
#endif
|
|
2844
|
+
#endif`,zg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2838
2845
|
vUv = vec3( uv, 1 ).xy;
|
|
2839
2846
|
#endif
|
|
2840
2847
|
#ifdef USE_MAP
|
|
@@ -2905,7 +2912,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,qg=`#ifdef USE_TRANSMISS
|
|
|
2905
2912
|
#endif
|
|
2906
2913
|
#ifdef USE_THICKNESSMAP
|
|
2907
2914
|
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
|
|
2908
|
-
#endif`,
|
|
2915
|
+
#endif`,Bg=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
|
|
2909
2916
|
vec4 worldPosition = vec4( transformed, 1.0 );
|
|
2910
2917
|
#ifdef USE_BATCHING
|
|
2911
2918
|
worldPosition = batchingMatrix * worldPosition;
|
|
@@ -2914,12 +2921,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,qg=`#ifdef USE_TRANSMISS
|
|
|
2914
2921
|
worldPosition = instanceMatrix * worldPosition;
|
|
2915
2922
|
#endif
|
|
2916
2923
|
worldPosition = modelMatrix * worldPosition;
|
|
2917
|
-
#endif`;const
|
|
2924
|
+
#endif`;const kg=`varying vec2 vUv;
|
|
2918
2925
|
uniform mat3 uvTransform;
|
|
2919
2926
|
void main() {
|
|
2920
2927
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
2921
2928
|
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
|
2922
|
-
}`,
|
|
2929
|
+
}`,Gg=`uniform sampler2D t2D;
|
|
2923
2930
|
uniform float backgroundIntensity;
|
|
2924
2931
|
varying vec2 vUv;
|
|
2925
2932
|
void main() {
|
|
@@ -2931,14 +2938,14 @@ void main() {
|
|
|
2931
2938
|
gl_FragColor = texColor;
|
|
2932
2939
|
#include <tonemapping_fragment>
|
|
2933
2940
|
#include <colorspace_fragment>
|
|
2934
|
-
}`,
|
|
2941
|
+
}`,Hg=`varying vec3 vWorldDirection;
|
|
2935
2942
|
#include <common>
|
|
2936
2943
|
void main() {
|
|
2937
2944
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2938
2945
|
#include <begin_vertex>
|
|
2939
2946
|
#include <project_vertex>
|
|
2940
2947
|
gl_Position.z = gl_Position.w;
|
|
2941
|
-
}`,
|
|
2948
|
+
}`,Vg=`#ifdef ENVMAP_TYPE_CUBE
|
|
2942
2949
|
uniform samplerCube envMap;
|
|
2943
2950
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
2944
2951
|
uniform sampler2D envMap;
|
|
@@ -2960,14 +2967,14 @@ void main() {
|
|
|
2960
2967
|
gl_FragColor = texColor;
|
|
2961
2968
|
#include <tonemapping_fragment>
|
|
2962
2969
|
#include <colorspace_fragment>
|
|
2963
|
-
}`,
|
|
2970
|
+
}`,Wg=`varying vec3 vWorldDirection;
|
|
2964
2971
|
#include <common>
|
|
2965
2972
|
void main() {
|
|
2966
2973
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2967
2974
|
#include <begin_vertex>
|
|
2968
2975
|
#include <project_vertex>
|
|
2969
2976
|
gl_Position.z = gl_Position.w;
|
|
2970
|
-
}`,
|
|
2977
|
+
}`,Xg=`uniform samplerCube tCube;
|
|
2971
2978
|
uniform float tFlip;
|
|
2972
2979
|
uniform float opacity;
|
|
2973
2980
|
varying vec3 vWorldDirection;
|
|
@@ -2977,7 +2984,7 @@ void main() {
|
|
|
2977
2984
|
gl_FragColor.a *= opacity;
|
|
2978
2985
|
#include <tonemapping_fragment>
|
|
2979
2986
|
#include <colorspace_fragment>
|
|
2980
|
-
}`,
|
|
2987
|
+
}`,qg=`#include <common>
|
|
2981
2988
|
#include <batching_pars_vertex>
|
|
2982
2989
|
#include <uv_pars_vertex>
|
|
2983
2990
|
#include <displacementmap_pars_vertex>
|
|
@@ -3004,7 +3011,7 @@ void main() {
|
|
|
3004
3011
|
#include <logdepthbuf_vertex>
|
|
3005
3012
|
#include <clipping_planes_vertex>
|
|
3006
3013
|
vHighPrecisionZW = gl_Position.zw;
|
|
3007
|
-
}`,
|
|
3014
|
+
}`,Yg=`#if DEPTH_PACKING == 3200
|
|
3008
3015
|
uniform float opacity;
|
|
3009
3016
|
#endif
|
|
3010
3017
|
#include <common>
|
|
@@ -3042,7 +3049,7 @@ void main() {
|
|
|
3042
3049
|
#elif DEPTH_PACKING == 3203
|
|
3043
3050
|
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
|
|
3044
3051
|
#endif
|
|
3045
|
-
}`,
|
|
3052
|
+
}`,Kg=`#define DISTANCE
|
|
3046
3053
|
varying vec3 vWorldPosition;
|
|
3047
3054
|
#include <common>
|
|
3048
3055
|
#include <batching_pars_vertex>
|
|
@@ -3069,7 +3076,7 @@ void main() {
|
|
|
3069
3076
|
#include <worldpos_vertex>
|
|
3070
3077
|
#include <clipping_planes_vertex>
|
|
3071
3078
|
vWorldPosition = worldPosition.xyz;
|
|
3072
|
-
}`,
|
|
3079
|
+
}`,Zg=`#define DISTANCE
|
|
3073
3080
|
uniform vec3 referencePosition;
|
|
3074
3081
|
uniform float nearDistance;
|
|
3075
3082
|
uniform float farDistance;
|
|
@@ -3092,13 +3099,13 @@ void main() {
|
|
|
3092
3099
|
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
|
3093
3100
|
dist = saturate( dist );
|
|
3094
3101
|
gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
|
|
3095
|
-
}
|
|
3102
|
+
}`,$g=`varying vec3 vWorldDirection;
|
|
3096
3103
|
#include <common>
|
|
3097
3104
|
void main() {
|
|
3098
3105
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
3099
3106
|
#include <begin_vertex>
|
|
3100
3107
|
#include <project_vertex>
|
|
3101
|
-
}`,
|
|
3108
|
+
}`,Jg=`uniform sampler2D tEquirect;
|
|
3102
3109
|
varying vec3 vWorldDirection;
|
|
3103
3110
|
#include <common>
|
|
3104
3111
|
void main() {
|
|
@@ -3107,7 +3114,7 @@ void main() {
|
|
|
3107
3114
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
3108
3115
|
#include <tonemapping_fragment>
|
|
3109
3116
|
#include <colorspace_fragment>
|
|
3110
|
-
}`,
|
|
3117
|
+
}`,Qg=`uniform float scale;
|
|
3111
3118
|
attribute float lineDistance;
|
|
3112
3119
|
varying float vLineDistance;
|
|
3113
3120
|
#include <common>
|
|
@@ -3129,7 +3136,7 @@ void main() {
|
|
|
3129
3136
|
#include <logdepthbuf_vertex>
|
|
3130
3137
|
#include <clipping_planes_vertex>
|
|
3131
3138
|
#include <fog_vertex>
|
|
3132
|
-
}`,
|
|
3139
|
+
}`,jg=`uniform vec3 diffuse;
|
|
3133
3140
|
uniform float opacity;
|
|
3134
3141
|
uniform float dashSize;
|
|
3135
3142
|
uniform float totalSize;
|
|
@@ -3157,7 +3164,7 @@ void main() {
|
|
|
3157
3164
|
#include <colorspace_fragment>
|
|
3158
3165
|
#include <fog_fragment>
|
|
3159
3166
|
#include <premultiplied_alpha_fragment>
|
|
3160
|
-
}`,
|
|
3167
|
+
}`,e1=`#include <common>
|
|
3161
3168
|
#include <batching_pars_vertex>
|
|
3162
3169
|
#include <uv_pars_vertex>
|
|
3163
3170
|
#include <envmap_pars_vertex>
|
|
@@ -3189,7 +3196,7 @@ void main() {
|
|
|
3189
3196
|
#include <worldpos_vertex>
|
|
3190
3197
|
#include <envmap_vertex>
|
|
3191
3198
|
#include <fog_vertex>
|
|
3192
|
-
}`,
|
|
3199
|
+
}`,t1=`uniform vec3 diffuse;
|
|
3193
3200
|
uniform float opacity;
|
|
3194
3201
|
#ifndef FLAT_SHADED
|
|
3195
3202
|
varying vec3 vNormal;
|
|
@@ -3237,7 +3244,7 @@ void main() {
|
|
|
3237
3244
|
#include <fog_fragment>
|
|
3238
3245
|
#include <premultiplied_alpha_fragment>
|
|
3239
3246
|
#include <dithering_fragment>
|
|
3240
|
-
}`,
|
|
3247
|
+
}`,n1=`#define LAMBERT
|
|
3241
3248
|
varying vec3 vViewPosition;
|
|
3242
3249
|
#include <common>
|
|
3243
3250
|
#include <batching_pars_vertex>
|
|
@@ -3276,7 +3283,7 @@ void main() {
|
|
|
3276
3283
|
#include <envmap_vertex>
|
|
3277
3284
|
#include <shadowmap_vertex>
|
|
3278
3285
|
#include <fog_vertex>
|
|
3279
|
-
}`,
|
|
3286
|
+
}`,i1=`#define LAMBERT
|
|
3280
3287
|
uniform vec3 diffuse;
|
|
3281
3288
|
uniform vec3 emissive;
|
|
3282
3289
|
uniform float opacity;
|
|
@@ -3334,7 +3341,7 @@ void main() {
|
|
|
3334
3341
|
#include <fog_fragment>
|
|
3335
3342
|
#include <premultiplied_alpha_fragment>
|
|
3336
3343
|
#include <dithering_fragment>
|
|
3337
|
-
}`,
|
|
3344
|
+
}`,s1=`#define MATCAP
|
|
3338
3345
|
varying vec3 vViewPosition;
|
|
3339
3346
|
#include <common>
|
|
3340
3347
|
#include <batching_pars_vertex>
|
|
@@ -3368,7 +3375,7 @@ void main() {
|
|
|
3368
3375
|
#include <clipping_planes_vertex>
|
|
3369
3376
|
#include <fog_vertex>
|
|
3370
3377
|
vViewPosition = - mvPosition.xyz;
|
|
3371
|
-
}`,
|
|
3378
|
+
}`,r1=`#define MATCAP
|
|
3372
3379
|
uniform vec3 diffuse;
|
|
3373
3380
|
uniform float opacity;
|
|
3374
3381
|
uniform sampler2D matcap;
|
|
@@ -3414,7 +3421,7 @@ void main() {
|
|
|
3414
3421
|
#include <fog_fragment>
|
|
3415
3422
|
#include <premultiplied_alpha_fragment>
|
|
3416
3423
|
#include <dithering_fragment>
|
|
3417
|
-
}`,
|
|
3424
|
+
}`,a1=`#define NORMAL
|
|
3418
3425
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3419
3426
|
varying vec3 vViewPosition;
|
|
3420
3427
|
#endif
|
|
@@ -3447,7 +3454,7 @@ void main() {
|
|
|
3447
3454
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3448
3455
|
vViewPosition = - mvPosition.xyz;
|
|
3449
3456
|
#endif
|
|
3450
|
-
}`,
|
|
3457
|
+
}`,o1=`#define NORMAL
|
|
3451
3458
|
uniform float opacity;
|
|
3452
3459
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3453
3460
|
varying vec3 vViewPosition;
|
|
@@ -3468,7 +3475,7 @@ void main() {
|
|
|
3468
3475
|
#ifdef OPAQUE
|
|
3469
3476
|
gl_FragColor.a = 1.0;
|
|
3470
3477
|
#endif
|
|
3471
|
-
}`,
|
|
3478
|
+
}`,c1=`#define PHONG
|
|
3472
3479
|
varying vec3 vViewPosition;
|
|
3473
3480
|
#include <common>
|
|
3474
3481
|
#include <batching_pars_vertex>
|
|
@@ -3507,7 +3514,7 @@ void main() {
|
|
|
3507
3514
|
#include <envmap_vertex>
|
|
3508
3515
|
#include <shadowmap_vertex>
|
|
3509
3516
|
#include <fog_vertex>
|
|
3510
|
-
}`,
|
|
3517
|
+
}`,l1=`#define PHONG
|
|
3511
3518
|
uniform vec3 diffuse;
|
|
3512
3519
|
uniform vec3 emissive;
|
|
3513
3520
|
uniform vec3 specular;
|
|
@@ -3567,7 +3574,7 @@ void main() {
|
|
|
3567
3574
|
#include <fog_fragment>
|
|
3568
3575
|
#include <premultiplied_alpha_fragment>
|
|
3569
3576
|
#include <dithering_fragment>
|
|
3570
|
-
}`,
|
|
3577
|
+
}`,h1=`#define STANDARD
|
|
3571
3578
|
varying vec3 vViewPosition;
|
|
3572
3579
|
#ifdef USE_TRANSMISSION
|
|
3573
3580
|
varying vec3 vWorldPosition;
|
|
@@ -3610,7 +3617,7 @@ void main() {
|
|
|
3610
3617
|
#ifdef USE_TRANSMISSION
|
|
3611
3618
|
vWorldPosition = worldPosition.xyz;
|
|
3612
3619
|
#endif
|
|
3613
|
-
}`,
|
|
3620
|
+
}`,u1=`#define STANDARD
|
|
3614
3621
|
#ifdef PHYSICAL
|
|
3615
3622
|
#define IOR
|
|
3616
3623
|
#define USE_SPECULAR
|
|
@@ -3735,7 +3742,7 @@ void main() {
|
|
|
3735
3742
|
#include <fog_fragment>
|
|
3736
3743
|
#include <premultiplied_alpha_fragment>
|
|
3737
3744
|
#include <dithering_fragment>
|
|
3738
|
-
}`,
|
|
3745
|
+
}`,d1=`#define TOON
|
|
3739
3746
|
varying vec3 vViewPosition;
|
|
3740
3747
|
#include <common>
|
|
3741
3748
|
#include <batching_pars_vertex>
|
|
@@ -3772,7 +3779,7 @@ void main() {
|
|
|
3772
3779
|
#include <worldpos_vertex>
|
|
3773
3780
|
#include <shadowmap_vertex>
|
|
3774
3781
|
#include <fog_vertex>
|
|
3775
|
-
}`,
|
|
3782
|
+
}`,f1=`#define TOON
|
|
3776
3783
|
uniform vec3 diffuse;
|
|
3777
3784
|
uniform vec3 emissive;
|
|
3778
3785
|
uniform float opacity;
|
|
@@ -3824,7 +3831,7 @@ void main() {
|
|
|
3824
3831
|
#include <fog_fragment>
|
|
3825
3832
|
#include <premultiplied_alpha_fragment>
|
|
3826
3833
|
#include <dithering_fragment>
|
|
3827
|
-
}`,
|
|
3834
|
+
}`,p1=`uniform float size;
|
|
3828
3835
|
uniform float scale;
|
|
3829
3836
|
#include <common>
|
|
3830
3837
|
#include <color_pars_vertex>
|
|
@@ -3855,7 +3862,7 @@ void main() {
|
|
|
3855
3862
|
#include <clipping_planes_vertex>
|
|
3856
3863
|
#include <worldpos_vertex>
|
|
3857
3864
|
#include <fog_vertex>
|
|
3858
|
-
}`,
|
|
3865
|
+
}`,m1=`uniform vec3 diffuse;
|
|
3859
3866
|
uniform float opacity;
|
|
3860
3867
|
#include <common>
|
|
3861
3868
|
#include <color_pars_fragment>
|
|
@@ -3880,7 +3887,7 @@ void main() {
|
|
|
3880
3887
|
#include <colorspace_fragment>
|
|
3881
3888
|
#include <fog_fragment>
|
|
3882
3889
|
#include <premultiplied_alpha_fragment>
|
|
3883
|
-
}`,
|
|
3890
|
+
}`,g1=`#include <common>
|
|
3884
3891
|
#include <batching_pars_vertex>
|
|
3885
3892
|
#include <fog_pars_vertex>
|
|
3886
3893
|
#include <morphtarget_pars_vertex>
|
|
@@ -3903,7 +3910,7 @@ void main() {
|
|
|
3903
3910
|
#include <worldpos_vertex>
|
|
3904
3911
|
#include <shadowmap_vertex>
|
|
3905
3912
|
#include <fog_vertex>
|
|
3906
|
-
}`,
|
|
3913
|
+
}`,_1=`uniform vec3 color;
|
|
3907
3914
|
uniform float opacity;
|
|
3908
3915
|
#include <common>
|
|
3909
3916
|
#include <fog_pars_fragment>
|
|
@@ -3919,7 +3926,7 @@ void main() {
|
|
|
3919
3926
|
#include <colorspace_fragment>
|
|
3920
3927
|
#include <fog_fragment>
|
|
3921
3928
|
#include <premultiplied_alpha_fragment>
|
|
3922
|
-
}`,
|
|
3929
|
+
}`,v1=`uniform float rotation;
|
|
3923
3930
|
uniform vec2 center;
|
|
3924
3931
|
#include <common>
|
|
3925
3932
|
#include <uv_pars_vertex>
|
|
@@ -3943,7 +3950,7 @@ void main() {
|
|
|
3943
3950
|
#include <logdepthbuf_vertex>
|
|
3944
3951
|
#include <clipping_planes_vertex>
|
|
3945
3952
|
#include <fog_vertex>
|
|
3946
|
-
}`,
|
|
3953
|
+
}`,x1=`uniform vec3 diffuse;
|
|
3947
3954
|
uniform float opacity;
|
|
3948
3955
|
#include <common>
|
|
3949
3956
|
#include <uv_pars_fragment>
|
|
@@ -3968,7 +3975,7 @@ void main() {
|
|
|
3968
3975
|
#include <tonemapping_fragment>
|
|
3969
3976
|
#include <colorspace_fragment>
|
|
3970
3977
|
#include <fog_fragment>
|
|
3971
|
-
}`,Ge={alphahash_fragment:Qp,alphahash_pars_fragment:jp,alphamap_fragment:em,alphamap_pars_fragment:tm,alphatest_fragment:nm,alphatest_pars_fragment:im,aomap_fragment:sm,aomap_pars_fragment:rm,batching_pars_vertex:am,batching_vertex:om,begin_vertex:cm,beginnormal_vertex:lm,bsdfs:hm,iridescence_fragment:um,bumpmap_pars_fragment:dm,clipping_planes_fragment:fm,clipping_planes_pars_fragment:pm,clipping_planes_pars_vertex:mm,clipping_planes_vertex:gm,color_fragment:_m,color_pars_fragment:vm,color_pars_vertex:xm,color_vertex:Mm,common:Sm,cube_uv_reflection_fragment:ym,defaultnormal_vertex:Em,displacementmap_pars_vertex:bm,displacementmap_vertex:Tm,emissivemap_fragment:Am,emissivemap_pars_fragment:wm,colorspace_fragment:Rm,colorspace_pars_fragment:Cm,envmap_fragment:Pm,envmap_common_pars_fragment:Dm,envmap_pars_fragment:Im,envmap_pars_vertex:Lm,envmap_physical_pars_fragment:Wm,envmap_vertex:Nm,fog_vertex:Um,fog_pars_vertex:Fm,fog_fragment:Om,fog_pars_fragment:zm,gradientmap_pars_fragment:Bm,lightmap_pars_fragment:km,lights_lambert_fragment:Gm,lights_lambert_pars_fragment:Hm,lights_pars_begin:Vm,lights_toon_fragment:Xm,lights_toon_pars_fragment:qm,lights_phong_fragment:Ym,lights_phong_pars_fragment:Km,lights_physical_fragment:Zm,lights_physical_pars_fragment:$m,lights_fragment_begin:Jm,lights_fragment_maps:Qm,lights_fragment_end:jm,lightprobes_pars_fragment:eg,logdepthbuf_fragment:tg,logdepthbuf_pars_fragment:ng,logdepthbuf_pars_vertex:ig,logdepthbuf_vertex:sg,map_fragment:rg,map_pars_fragment:ag,map_particle_fragment:og,map_particle_pars_fragment:cg,metalnessmap_fragment:lg,metalnessmap_pars_fragment:hg,morphinstance_vertex:ug,morphcolor_vertex:dg,morphnormal_vertex:fg,morphtarget_pars_vertex:pg,morphtarget_vertex:mg,normal_fragment_begin:gg,normal_fragment_maps:_g,normal_pars_fragment:vg,normal_pars_vertex:xg,normal_vertex:Mg,normalmap_pars_fragment:Sg,clearcoat_normal_fragment_begin:yg,clearcoat_normal_fragment_maps:Eg,clearcoat_pars_fragment:bg,iridescence_pars_fragment:Tg,opaque_fragment:Ag,packing:wg,premultiplied_alpha_fragment:Rg,project_vertex:Cg,dithering_fragment:Pg,dithering_pars_fragment:Dg,roughnessmap_fragment:Ig,roughnessmap_pars_fragment:Lg,shadowmap_pars_fragment:Ng,shadowmap_pars_vertex:Ug,shadowmap_vertex:Fg,shadowmask_pars_fragment:Og,skinbase_vertex:zg,skinning_pars_vertex:Bg,skinning_vertex:kg,skinnormal_vertex:Gg,specularmap_fragment:Hg,specularmap_pars_fragment:Vg,tonemapping_fragment:Wg,tonemapping_pars_fragment:Xg,transmission_fragment:qg,transmission_pars_fragment:Yg,uv_pars_fragment:Kg,uv_pars_vertex:Zg,uv_vertex:$g,worldpos_vertex:Jg,background_vert:Qg,background_frag:jg,backgroundCube_vert:e1,backgroundCube_frag:t1,cube_vert:n1,cube_frag:i1,depth_vert:s1,depth_frag:r1,distance_vert:a1,distance_frag:o1,equirect_vert:c1,equirect_frag:l1,linedashed_vert:h1,linedashed_frag:u1,meshbasic_vert:d1,meshbasic_frag:f1,meshlambert_vert:p1,meshlambert_frag:m1,meshmatcap_vert:g1,meshmatcap_frag:_1,meshnormal_vert:v1,meshnormal_frag:x1,meshphong_vert:M1,meshphong_frag:S1,meshphysical_vert:y1,meshphysical_frag:E1,meshtoon_vert:b1,meshtoon_frag:T1,points_vert:A1,points_frag:w1,shadow_vert:R1,shadow_frag:C1,sprite_vert:P1,sprite_frag:D1},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 Oe(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 Oe(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ze},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0}}},Sn={basic:{uniforms:kt([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.fog]),vertexShader:Ge.meshbasic_vert,fragmentShader:Ge.meshbasic_frag},lambert:{uniforms:kt([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:kt([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:kt([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:kt([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:kt([de.common,de.bumpmap,de.normalmap,de.displacementmap,de.fog,{matcap:{value:null}}]),vertexShader:Ge.meshmatcap_vert,fragmentShader:Ge.meshmatcap_frag},points:{uniforms:kt([de.points,de.fog]),vertexShader:Ge.points_vert,fragmentShader:Ge.points_frag},dashed:{uniforms:kt([de.common,de.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ge.linedashed_vert,fragmentShader:Ge.linedashed_frag},depth:{uniforms:kt([de.common,de.displacementmap]),vertexShader:Ge.depth_vert,fragmentShader:Ge.depth_frag},normal:{uniforms:kt([de.common,de.bumpmap,de.normalmap,de.displacementmap,{opacity:{value:1}}]),vertexShader:Ge.meshnormal_vert,fragmentShader:Ge.meshnormal_frag},sprite:{uniforms:kt([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:kt([de.common,de.displacementmap,{referencePosition:{value:new U},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ge.distance_vert,fragmentShader:Ge.distance_frag},shadow:{uniforms:kt([de.lights,de.fog,{color:{value:new xe(0)},opacity:{value:1}}]),vertexShader:Ge.shadow_vert,fragmentShader:Ge.shadow_frag}};Sn.physical={uniforms:kt([Sn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ze},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ze},clearcoatNormalScale:{value:new Oe(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 Oe},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 Oe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ze}}]),vertexShader:Ge.meshphysical_vert,fragmentShader:Ge.meshphysical_frag};const qr={r:0,b:0,g:0},I1=new st,k0=new ze;k0.set(-1,0,0,0,1,0,0,0,1);function L1(i,e,t,n,s,r){const a=new xe(0);let o=s===!0?0:1,c,l,h=null,d=0,u=null;function p(A){let w=A.isScene===!0?A.background:null;if(w&&w.isTexture){const M=A.backgroundBlurriness>0;w=e.get(w,M)}return w}function g(A){let w=!1;const M=p(A);M===null?m(a,o):M&&M.isColor&&(m(M,1),w=!0);const y=i.xr.getEnvironmentBlendMode();y==="additive"?t.buffers.color.setClear(0,0,0,1,r):y==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(i.autoClear||w)&&(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(A,w){const M=p(w);M&&(M.isCubeTexture||M.mapping===Na)?(l===void 0&&(l=new ut(new rn(1,1,1),new zt({name:"BackgroundCubeMaterial",uniforms:Ss(Sn.backgroundCube.uniforms),vertexShader:Sn.backgroundCube.vertexShader,fragmentShader:Sn.backgroundCube.fragmentShader,side:Pt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(y,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=w.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(I1.makeRotationFromEuler(w.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(k0),l.material.toneMapped=qe.getTransfer(M.colorSpace)!==Qe,(h!==M||d!==M.version||u!==i.toneMapping)&&(l.material.needsUpdate=!0,h=M,d=M.version,u=i.toneMapping),l.layers.enableAll(),A.unshift(l,l.geometry,l.material,0,0,null)):M&&M.isTexture&&(c===void 0&&(c=new ut(new bs(2,2),new zt({name:"BackgroundMaterial",uniforms:Ss(Sn.background.uniforms),vertexShader:Sn.background.vertexShader,fragmentShader:Sn.background.fragmentShader,side:di,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=w.backgroundIntensity,c.material.toneMapped=qe.getTransfer(M.colorSpace)!==Qe,M.matrixAutoUpdate===!0&&M.updateMatrix(),c.material.uniforms.uvTransform.value.copy(M.matrix),(h!==M||d!==M.version||u!==i.toneMapping)&&(c.material.needsUpdate=!0,h=M,d=M.version,u=i.toneMapping),c.layers.enableAll(),A.unshift(c,c.geometry,c.material,0,0,null))}function m(A,w){A.getRGB(qr,U0(i)),t.buffers.color.setClear(qr.r,qr.g,qr.b,w,r)}function f(){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(A,w=1){a.set(A),o=w,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(A){o=A,m(a,o)},render:g,addToRenderList:x,dispose:f}}function N1(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=u(null);let r=s,a=!1;function o(C,L,X,q,F){let W=!1;const V=d(C,q,X,L);r!==V&&(r=V,l(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 c(){return i.createVertexArray()}function l(C){return i.bindVertexArray(C)}function h(C){return i.deleteVertexArray(C)}function d(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=u(c()),te[F]=ee),ee}function u(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 A(){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 w(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 rt=Ve.buffer,We=Ve.type,Z=Ve.bytesPerElement,re=We===i.INT||We===i.UNSIGNED_INT||ee.gpuType===gl;if(ee.isInterleavedBufferAttribute){const ne=ee.data,k=ne.stride,Pe=ee.offset;if(ne.isInstancedInterleavedBuffer){for(let De=0;De<te.locationSize;De++)f(te.location+De,ne.meshPerAttribute);C.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let De=0;De<te.locationSize;De++)m(te.location+De);i.bindBuffer(i.ARRAY_BUFFER,rt);for(let De=0;De<te.locationSize;De++)w(te.location+De,ge/te.locationSize,We,se,k*Z,(Pe+ge/te.locationSize*De)*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,rt);for(let ne=0;ne<te.locationSize;ne++)w(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)}}}}A()}function y(){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 v(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(){P(),a=!0,r!==s&&(r=s,l(r.object))}function P(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:E,resetDefaultState:P,dispose:y,releaseStatesOfGeometry:b,releaseStatesOfObject:v,releaseStatesOfProgram:R,initAttributes:x,enableAttribute:m,disableUnusedAttributes:A}}function U1(i,e,t){let n;function s(c){n=c}function r(c,l){i.drawArrays(n,c,l),t.update(l,n,1)}function a(c,l,h){h!==0&&(i.drawArraysInstanced(n,c,l,h),t.update(l,n,h))}function o(c,l,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,l,0,h);let u=0;for(let p=0;p<h;p++)u+=l[p];t.update(u,n,1)}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function F1(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!==dn&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(R){const v=R===Vn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(R!==Zt&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==wn&&!v)}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=t.precision!==void 0?t.precision:"highp";const h=c(l);h!==l&&(Fe("WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);const d=t.logarithmicDepthBuffer===!0,u=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&u===!1&&Fe("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),A=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),w=i.getParameter(i.MAX_VARYING_VECTORS),M=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),y=i.getParameter(i.MAX_SAMPLES),b=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:d,reversedDepthBuffer:u,maxTextures:p,maxVertexTextures:g,maxTextureSize:x,maxCubemapSize:m,maxAttributes:f,maxVertexUniforms:A,maxVaryings:w,maxFragmentUniforms:M,maxSamples:y,samples:b}}function O1(i){const e=this;let t=null,n=0,s=!1,r=!1;const a=new yi,o=new ze,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){const p=d.length!==0||u||n!==0||s;return s=u,n=d.length,p},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,u){t=h(d,u,0)},this.setState=function(d,u,p){const g=d.clippingPlanes,x=d.clipIntersection,m=d.clipShadows,f=i.get(d);if(!s||g===null||g.length===0||r&&!m)r?h(null):l();else{const A=r?0:n,w=A*4;let M=f.clippingState||null;c.value=M,M=h(g,u,w,p);for(let y=0;y!==w;++y)M[y]=t[y];f.clippingState=M,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=A}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(d,u,p,g){const x=d!==null?d.length:0;let m=null;if(x!==0){if(m=c.value,g!==!0||m===null){const f=p+x*4,A=u.matrixWorldInverse;o.getNormalMatrix(A),(m===null||m.length<f)&&(m=new Float32Array(f));for(let w=0,M=p;w!==x;++w,M+=4)a.copy(d[w]).applyMatrix4(A,o),a.normal.toArray(m,M),m[M+3]=a.constant}c.value=m,c.needsUpdate=!0}return e.numPlanes=x,e.numIntersection=0,m}}const ci=4,kh=[.125,.215,.35,.446,.526,.582],bi=20,z1=256,Os=new Oa,Gh=new xe;let Eo=null,bo=0,To=0,Ao=!1;const B1=new U;class Hh{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=B1}=r;Eo=this._renderer.getRenderTarget(),bo=this._renderer.getActiveCubeFace(),To=this._renderer.getActiveMipmapLevel(),Ao=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,n,s,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Xh(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Wh(),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(Eo,bo,To),this._renderer.xr.enabled=Ao,e.scissorTest=!1,es(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Pi||e.mapping===xs?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Eo=this._renderer.getRenderTarget(),bo=this._renderer.getActiveCubeFace(),To=this._renderer.getActiveMipmapLevel(),Ao=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:Ut,minFilter:Ut,generateMipmaps:!1,type:Vn,format:dn,colorSpace:va,depthBuffer:!1},s=Vh(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Vh(e,t,n);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=k1(r)),this._blurMaterial=H1(r,e,t),this._ggxMaterial=G1(r,e,t)}return s}_compileMaterial(e){const t=new ut(new St,e);this._renderer.compile(t,Os)}_sceneToCubeUV(e,t,n,s,r){const c=new Kt(90,1,t,n),l=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],d=this._renderer,u=d.autoClear,p=d.toneMapping;d.getClearColor(Gh),d.toneMapping=Cn,d.autoClear=!1,d.state.buffers.depth.getReversed()&&(d.setRenderTarget(s),d.clearDepth(),d.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new ut(new rn,new ar({name:"PMREM.Background",side:Pt,depthWrite:!1,depthTest:!1})));const x=this._backgroundBox,m=x.material;let f=!1;const A=e.background;A?A.isColor&&(m.color.copy(A),e.background=null,f=!0):(m.color.copy(Gh),f=!0);for(let w=0;w<6;w++){const M=w%3;M===0?(c.up.set(0,l[w],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x+h[w],r.y,r.z)):M===1?(c.up.set(0,0,l[w]),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y+h[w],r.z)):(c.up.set(0,l[w],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y,r.z+h[w]));const y=this._cubeSize;es(s,M*y,w>2?y:0,y,y),d.setRenderTarget(s),f&&d.render(x,c),d.render(e,c)}d.toneMapping=p,d.autoClear=u,e.background=A}_textureToCubeUV(e,t){const n=this._renderer,s=e.mapping===Pi||e.mapping===xs;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Xh()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Wh());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const c=this._cubeSize;es(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(a,Os)}_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 c=a.uniforms,l=n/(this._lodMeshes.length-1),h=t/(this._lodMeshes.length-1),d=Math.sqrt(l*l-h*h),u=0+l*1.25,p=d*u,{_lodMax:g}=this,x=this._sizeLods[n],m=3*x*(n>g-ci?n-g+ci:0),f=4*(this._cubeSize-x);c.envMap.value=e.texture,c.roughness.value=p,c.mipInt.value=g-t,es(r,m,f,3*x,2*x),s.setRenderTarget(r),s.render(o,Os),c.envMap.value=r.texture,c.roughness.value=0,c.mipInt.value=g-n,es(e,m,f,3*x,2*x),s.setRenderTarget(e),s.render(o,Os)}_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 c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Xe("blur direction must be either latitudinal or longitudinal!");const h=3,d=this._lodMeshes[s];d.material=l;const u=l.uniforms,p=this._sizeLods[n]-1,g=isFinite(r)?Math.PI/(2*p):2*Math.PI/(2*bi-1),x=r/g,m=isFinite(r)?1+Math.floor(h*x):bi;m>bi&&Fe(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${bi}`);const f=[];let A=0;for(let R=0;R<bi;++R){const v=R/x,E=Math.exp(-v*v/2);f.push(E),R===0?A+=E:R<m&&(A+=2*E)}for(let R=0;R<f.length;R++)f[R]=f[R]/A;u.envMap.value=e.texture,u.samples.value=m,u.weights.value=f,u.latitudinal.value=a==="latitudinal",o&&(u.poleAxis.value=o);const{_lodMax:w}=this;u.dTheta.value=g,u.mipInt.value=w-n;const M=this._sizeLods[s],y=3*M*(s>w-ci?s-w+ci:0),b=4*(this._cubeSize-M);es(t,y,b,3*M,2*M),c.setRenderTarget(t),c.render(d,Os)}}function k1(i){const e=[],t=[],n=[];let s=i;const r=i-ci+1+kh.length;for(let a=0;a<r;a++){const o=Math.pow(2,s);e.push(o);let c=1/o;a>i-ci?c=kh[a-i+ci-1]:a===0&&(c=0),t.push(c);const l=1/(o-2),h=-l,d=1+l,u=[h,h,d,h,d,d,h,h,d,d,h,d],p=6,g=6,x=3,m=2,f=1,A=new Float32Array(x*g*p),w=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,v=b>2?0:-1,E=[R,v,0,R+2/3,v,0,R+2/3,v+1,0,R,v,0,R+2/3,v+1,0,R,v+1,0];A.set(E,x*g*b),w.set(u,m*g*b);const P=[b,b,b,b,b,b];M.set(P,f*g*b)}const y=new St;y.setAttribute("position",new lt(A,x)),y.setAttribute("uv",new lt(w,m)),y.setAttribute("faceIndex",new lt(M,f)),n.push(new ut(y,null)),s>ci&&s--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function Vh(i,e,t){const n=new pn(i,e,t);return n.texture.mapping=Na,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function es(i,e,t,n,s){i.viewport.set(e,t,n,s),i.scissor.set(e,t,n,s)}function G1(i,e,t){return new zt({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:z1,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:za(),fragmentShader:`
|
|
3978
|
+
}`,Ge={alphahash_fragment:kp,alphahash_pars_fragment:Gp,alphamap_fragment:Hp,alphamap_pars_fragment:Vp,alphatest_fragment:Wp,alphatest_pars_fragment:Xp,aomap_fragment:qp,aomap_pars_fragment:Yp,batching_pars_vertex:Kp,batching_vertex:Zp,begin_vertex:$p,beginnormal_vertex:Jp,bsdfs:Qp,iridescence_fragment:jp,bumpmap_pars_fragment:em,clipping_planes_fragment:tm,clipping_planes_pars_fragment:nm,clipping_planes_pars_vertex:im,clipping_planes_vertex:sm,color_fragment:rm,color_pars_fragment:am,color_pars_vertex:om,color_vertex:cm,common:lm,cube_uv_reflection_fragment:hm,defaultnormal_vertex:um,displacementmap_pars_vertex:dm,displacementmap_vertex:fm,emissivemap_fragment:pm,emissivemap_pars_fragment:mm,colorspace_fragment:gm,colorspace_pars_fragment:_m,envmap_fragment:vm,envmap_common_pars_fragment:xm,envmap_pars_fragment:Mm,envmap_pars_vertex:Sm,envmap_physical_pars_fragment:Im,envmap_vertex:ym,fog_vertex:Em,fog_pars_vertex:bm,fog_fragment:Tm,fog_pars_fragment:Am,gradientmap_pars_fragment:wm,lightmap_pars_fragment:Rm,lights_lambert_fragment:Cm,lights_lambert_pars_fragment:Pm,lights_pars_begin:Dm,lights_toon_fragment:Lm,lights_toon_pars_fragment:Nm,lights_phong_fragment:Um,lights_phong_pars_fragment:Fm,lights_physical_fragment:Om,lights_physical_pars_fragment:zm,lights_fragment_begin:Bm,lights_fragment_maps:km,lights_fragment_end:Gm,lightprobes_pars_fragment:Hm,logdepthbuf_fragment:Vm,logdepthbuf_pars_fragment:Wm,logdepthbuf_pars_vertex:Xm,logdepthbuf_vertex:qm,map_fragment:Ym,map_pars_fragment:Km,map_particle_fragment:Zm,map_particle_pars_fragment:$m,metalnessmap_fragment:Jm,metalnessmap_pars_fragment:Qm,morphinstance_vertex:jm,morphcolor_vertex:eg,morphnormal_vertex:tg,morphtarget_pars_vertex:ng,morphtarget_vertex:ig,normal_fragment_begin:sg,normal_fragment_maps:rg,normal_pars_fragment:ag,normal_pars_vertex:og,normal_vertex:cg,normalmap_pars_fragment:lg,clearcoat_normal_fragment_begin:hg,clearcoat_normal_fragment_maps:ug,clearcoat_pars_fragment:dg,iridescence_pars_fragment:fg,opaque_fragment:pg,packing:mg,premultiplied_alpha_fragment:gg,project_vertex:_g,dithering_fragment:vg,dithering_pars_fragment:xg,roughnessmap_fragment:Mg,roughnessmap_pars_fragment:Sg,shadowmap_pars_fragment:yg,shadowmap_pars_vertex:Eg,shadowmap_vertex:bg,shadowmask_pars_fragment:Tg,skinbase_vertex:Ag,skinning_pars_vertex:wg,skinning_vertex:Rg,skinnormal_vertex:Cg,specularmap_fragment:Pg,specularmap_pars_fragment:Dg,tonemapping_fragment:Ig,tonemapping_pars_fragment:Lg,transmission_fragment:Ng,transmission_pars_fragment:Ug,uv_pars_fragment:Fg,uv_pars_vertex:Og,uv_vertex:zg,worldpos_vertex:Bg,background_vert:kg,background_frag:Gg,backgroundCube_vert:Hg,backgroundCube_frag:Vg,cube_vert:Wg,cube_frag:Xg,depth_vert:qg,depth_frag:Yg,distance_vert:Kg,distance_frag:Zg,equirect_vert:$g,equirect_frag:Jg,linedashed_vert:Qg,linedashed_frag:jg,meshbasic_vert:e1,meshbasic_frag:t1,meshlambert_vert:n1,meshlambert_frag:i1,meshmatcap_vert:s1,meshmatcap_frag:r1,meshnormal_vert:a1,meshnormal_frag:o1,meshphong_vert:c1,meshphong_frag:l1,meshphysical_vert:h1,meshphysical_frag:u1,meshtoon_vert:d1,meshtoon_frag:f1,points_vert:p1,points_frag:m1,shadow_vert:g1,shadow_frag:_1,sprite_vert:v1,sprite_frag:x1},de={common:{diffuse:{value:new Me(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 Me(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 Me(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 Me(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}}},Sn={basic:{uniforms:Gt([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.fog]),vertexShader:Ge.meshbasic_vert,fragmentShader:Ge.meshbasic_frag},lambert:{uniforms:Gt([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 Me(0)},envMapIntensity:{value:1}}]),vertexShader:Ge.meshlambert_vert,fragmentShader:Ge.meshlambert_frag},phong:{uniforms:Gt([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 Me(0)},specular:{value:new Me(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ge.meshphong_vert,fragmentShader:Ge.meshphong_frag},standard:{uniforms:Gt([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 Me(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ge.meshphysical_vert,fragmentShader:Ge.meshphysical_frag},toon:{uniforms:Gt([de.common,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.gradientmap,de.fog,de.lights,{emissive:{value:new Me(0)}}]),vertexShader:Ge.meshtoon_vert,fragmentShader:Ge.meshtoon_frag},matcap:{uniforms:Gt([de.common,de.bumpmap,de.normalmap,de.displacementmap,de.fog,{matcap:{value:null}}]),vertexShader:Ge.meshmatcap_vert,fragmentShader:Ge.meshmatcap_frag},points:{uniforms:Gt([de.points,de.fog]),vertexShader:Ge.points_vert,fragmentShader:Ge.points_frag},dashed:{uniforms:Gt([de.common,de.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ge.linedashed_vert,fragmentShader:Ge.linedashed_frag},depth:{uniforms:Gt([de.common,de.displacementmap]),vertexShader:Ge.depth_vert,fragmentShader:Ge.depth_frag},normal:{uniforms:Gt([de.common,de.bumpmap,de.normalmap,de.displacementmap,{opacity:{value:1}}]),vertexShader:Ge.meshnormal_vert,fragmentShader:Ge.meshnormal_frag},sprite:{uniforms:Gt([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:Gt([de.common,de.displacementmap,{referencePosition:{value:new U},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ge.distance_vert,fragmentShader:Ge.distance_frag},shadow:{uniforms:Gt([de.lights,de.fog,{color:{value:new Me(0)},opacity:{value:1}}]),vertexShader:Ge.shadow_vert,fragmentShader:Ge.shadow_frag}};Sn.physical={uniforms:Gt([Sn.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 Me(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 Me(0)},specularColor:{value:new Me(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 Vr={r:0,b:0,g:0},M1=new ot,P0=new ze;P0.set(-1,0,0,0,1,0,0,0,1);function S1(i,e,t,n,s,r){const a=new Me(0);let o=s===!0?0:1,c,l,h=null,d=0,u=null;function p(T){let w=T.isScene===!0?T.background:null;if(w&&w.isTexture){const x=T.backgroundBlurriness>0;w=e.get(w,x)}return w}function g(T){let w=!1;const x=p(T);x===null?m(a,o):x&&x.isColor&&(m(x,1),w=!0);const y=i.xr.getEnvironmentBlendMode();y==="additive"?t.buffers.color.setClear(0,0,0,1,r):y==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(i.autoClear||w)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function M(T,w){const x=p(w);x&&(x.isCubeTexture||x.mapping===Ca)?(l===void 0&&(l=new ht(new rn(1,1,1),new Bt({name:"BackgroundCubeMaterial",uniforms:Es(Sn.backgroundCube.uniforms),vertexShader:Sn.backgroundCube.vertexShader,fragmentShader:Sn.backgroundCube.fragmentShader,side:Dt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(y,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=x,l.material.uniforms.backgroundBlurriness.value=w.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(M1.makeRotationFromEuler(w.backgroundRotation)).transpose(),x.isCubeTexture&&x.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(P0),l.material.toneMapped=qe.getTransfer(x.colorSpace)!==Qe,(h!==x||d!==x.version||u!==i.toneMapping)&&(l.material.needsUpdate=!0,h=x,d=x.version,u=i.toneMapping),l.layers.enableAll(),T.unshift(l,l.geometry,l.material,0,0,null)):x&&x.isTexture&&(c===void 0&&(c=new ht(new As(2,2),new Bt({name:"BackgroundMaterial",uniforms:Es(Sn.background.uniforms),vertexShader:Sn.background.vertexShader,fragmentShader:Sn.background.fragmentShader,side:di,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=x,c.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,c.material.toneMapped=qe.getTransfer(x.colorSpace)!==Qe,x.matrixAutoUpdate===!0&&x.updateMatrix(),c.material.uniforms.uvTransform.value.copy(x.matrix),(h!==x||d!==x.version||u!==i.toneMapping)&&(c.material.needsUpdate=!0,h=x,d=x.version,u=i.toneMapping),c.layers.enableAll(),T.unshift(c,c.geometry,c.material,0,0,null))}function m(T,w){T.getRGB(Vr,T0(i)),t.buffers.color.setClear(Vr.r,Vr.g,Vr.b,w,r)}function f(){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(T,w=1){a.set(T),o=w,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(T){o=T,m(a,o)},render:g,addToRenderList:M,dispose:f}}function y1(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=u(null);let r=s,a=!1;function o(C,L,X,q,F){let W=!1;const V=d(C,q,X,L);r!==V&&(r=V,l(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,x(C,L,X,q),F!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(F).buffer))}function c(){return i.createVertexArray()}function l(C){return i.bindVertexArray(C)}function h(C){return i.deleteVertexArray(C)}function d(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=u(c()),te[F]=ee),ee}function u(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 M(){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 T(){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 w(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 x(C,L,X,q){M();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 st=Ve.buffer,We=Ve.type,Z=Ve.bytesPerElement,re=We===i.INT||We===i.UNSIGNED_INT||ee.gpuType===hl;if(ee.isInterleavedBufferAttribute){const ne=ee.data,k=ne.stride,Pe=ee.offset;if(ne.isInstancedInterleavedBuffer){for(let De=0;De<te.locationSize;De++)f(te.location+De,ne.meshPerAttribute);C.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let De=0;De<te.locationSize;De++)m(te.location+De);i.bindBuffer(i.ARRAY_BUFFER,st);for(let De=0;De<te.locationSize;De++)w(te.location+De,ge/te.locationSize,We,se,k*Z,(Pe+ge/te.locationSize*De)*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,st);for(let ne=0;ne<te.locationSize;ne++)w(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)}}}}T()}function y(){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 v(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(){P(),a=!0,r!==s&&(r=s,l(r.object))}function P(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:E,resetDefaultState:P,dispose:y,releaseStatesOfGeometry:b,releaseStatesOfObject:v,releaseStatesOfProgram:R,initAttributes:M,enableAttribute:m,disableUnusedAttributes:T}}function E1(i,e,t){let n;function s(c){n=c}function r(c,l){i.drawArrays(n,c,l),t.update(l,n,1)}function a(c,l,h){h!==0&&(i.drawArraysInstanced(n,c,l,h),t.update(l,n,h))}function o(c,l,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,l,0,h);let u=0;for(let p=0;p<h;p++)u+=l[p];t.update(u,n,1)}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function b1(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!==dn&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(R){const v=R===Vn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(R!==$t&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==Rn&&!v)}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=t.precision!==void 0?t.precision:"highp";const h=c(l);h!==l&&(Oe("WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);const d=t.logarithmicDepthBuffer===!0,u=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&u===!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),M=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),f=i.getParameter(i.MAX_VERTEX_ATTRIBS),T=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),w=i.getParameter(i.MAX_VARYING_VECTORS),x=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),y=i.getParameter(i.MAX_SAMPLES),b=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:d,reversedDepthBuffer:u,maxTextures:p,maxVertexTextures:g,maxTextureSize:M,maxCubemapSize:m,maxAttributes:f,maxVertexUniforms:T,maxVaryings:w,maxFragmentUniforms:x,maxSamples:y,samples:b}}function T1(i){const e=this;let t=null,n=0,s=!1,r=!1;const a=new Si,o=new ze,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){const p=d.length!==0||u||n!==0||s;return s=u,n=d.length,p},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,u){t=h(d,u,0)},this.setState=function(d,u,p){const g=d.clippingPlanes,M=d.clipIntersection,m=d.clipShadows,f=i.get(d);if(!s||g===null||g.length===0||r&&!m)r?h(null):l();else{const T=r?0:n,w=T*4;let x=f.clippingState||null;c.value=x,x=h(g,u,w,p);for(let y=0;y!==w;++y)x[y]=t[y];f.clippingState=x,this.numIntersection=M?this.numPlanes:0,this.numPlanes+=T}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(d,u,p,g){const M=d!==null?d.length:0;let m=null;if(M!==0){if(m=c.value,g!==!0||m===null){const f=p+M*4,T=u.matrixWorldInverse;o.getNormalMatrix(T),(m===null||m.length<f)&&(m=new Float32Array(f));for(let w=0,x=p;w!==M;++w,x+=4)a.copy(d[w]).applyMatrix4(T,o),a.normal.toArray(m,x),m[x+3]=a.constant}c.value=m,c.needsUpdate=!0}return e.numPlanes=M,e.numIntersection=0,m}}const ci=4,Dh=[.125,.215,.35,.446,.526,.582],Ei=20,A1=256,zs=new Ia,Ih=new Me;let _o=null,vo=0,xo=0,Mo=!1;const w1=new U;class Lh{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=w1}=r;_o=this._renderer.getRenderTarget(),vo=this._renderer.getActiveCubeFace(),xo=this._renderer.getActiveMipmapLevel(),Mo=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,n,s,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Fh(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Uh(),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(_o,vo,xo),this._renderer.xr.enabled=Mo,e.scissorTest=!1,ts(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Pi||e.mapping===Ms?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),_o=this._renderer.getRenderTarget(),vo=this._renderer.getActiveCubeFace(),xo=this._renderer.getActiveMipmapLevel(),Mo=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:Ft,minFilter:Ft,generateMipmaps:!1,type:Vn,format:dn,colorSpace:ma,depthBuffer:!1},s=Nh(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Nh(e,t,n);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=R1(r)),this._blurMaterial=P1(r,e,t),this._ggxMaterial=C1(r,e,t)}return s}_compileMaterial(e){const t=new ht(new yt,e);this._renderer.compile(t,zs)}_sceneToCubeUV(e,t,n,s,r){const c=new Zt(90,1,t,n),l=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],d=this._renderer,u=d.autoClear,p=d.toneMapping;d.getClearColor(Ih),d.toneMapping=Pn,d.autoClear=!1,d.state.buffers.depth.getReversed()&&(d.setRenderTarget(s),d.clearDepth(),d.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new ht(new rn,new Ss({name:"PMREM.Background",side:Dt,depthWrite:!1,depthTest:!1})));const M=this._backgroundBox,m=M.material;let f=!1;const T=e.background;T?T.isColor&&(m.color.copy(T),e.background=null,f=!0):(m.color.copy(Ih),f=!0);for(let w=0;w<6;w++){const x=w%3;x===0?(c.up.set(0,l[w],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x+h[w],r.y,r.z)):x===1?(c.up.set(0,0,l[w]),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y+h[w],r.z)):(c.up.set(0,l[w],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y,r.z+h[w]));const y=this._cubeSize;ts(s,x*y,w>2?y:0,y,y),d.setRenderTarget(s),f&&d.render(M,c),d.render(e,c)}d.toneMapping=p,d.autoClear=u,e.background=T}_textureToCubeUV(e,t){const n=this._renderer,s=e.mapping===Pi||e.mapping===Ms;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Fh()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Uh());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const c=this._cubeSize;ts(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(a,zs)}_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 c=a.uniforms,l=n/(this._lodMeshes.length-1),h=t/(this._lodMeshes.length-1),d=Math.sqrt(l*l-h*h),u=0+l*1.25,p=d*u,{_lodMax:g}=this,M=this._sizeLods[n],m=3*M*(n>g-ci?n-g+ci:0),f=4*(this._cubeSize-M);c.envMap.value=e.texture,c.roughness.value=p,c.mipInt.value=g-t,ts(r,m,f,3*M,2*M),s.setRenderTarget(r),s.render(o,zs),c.envMap.value=r.texture,c.roughness.value=0,c.mipInt.value=g-n,ts(e,m,f,3*M,2*M),s.setRenderTarget(e),s.render(o,zs)}_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 c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Xe("blur direction must be either latitudinal or longitudinal!");const h=3,d=this._lodMeshes[s];d.material=l;const u=l.uniforms,p=this._sizeLods[n]-1,g=isFinite(r)?Math.PI/(2*p):2*Math.PI/(2*Ei-1),M=r/g,m=isFinite(r)?1+Math.floor(h*M):Ei;m>Ei&&Oe(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Ei}`);const f=[];let T=0;for(let R=0;R<Ei;++R){const v=R/M,E=Math.exp(-v*v/2);f.push(E),R===0?T+=E:R<m&&(T+=2*E)}for(let R=0;R<f.length;R++)f[R]=f[R]/T;u.envMap.value=e.texture,u.samples.value=m,u.weights.value=f,u.latitudinal.value=a==="latitudinal",o&&(u.poleAxis.value=o);const{_lodMax:w}=this;u.dTheta.value=g,u.mipInt.value=w-n;const x=this._sizeLods[s],y=3*x*(s>w-ci?s-w+ci:0),b=4*(this._cubeSize-x);ts(t,y,b,3*x,2*x),c.setRenderTarget(t),c.render(d,zs)}}function R1(i){const e=[],t=[],n=[];let s=i;const r=i-ci+1+Dh.length;for(let a=0;a<r;a++){const o=Math.pow(2,s);e.push(o);let c=1/o;a>i-ci?c=Dh[a-i+ci-1]:a===0&&(c=0),t.push(c);const l=1/(o-2),h=-l,d=1+l,u=[h,h,d,h,d,d,h,h,d,d,h,d],p=6,g=6,M=3,m=2,f=1,T=new Float32Array(M*g*p),w=new Float32Array(m*g*p),x=new Float32Array(f*g*p);for(let b=0;b<p;b++){const R=b%3*2/3-1,v=b>2?0:-1,E=[R,v,0,R+2/3,v,0,R+2/3,v+1,0,R,v,0,R+2/3,v+1,0,R,v+1,0];T.set(E,M*g*b),w.set(u,m*g*b);const P=[b,b,b,b,b,b];x.set(P,f*g*b)}const y=new yt;y.setAttribute("position",new lt(T,M)),y.setAttribute("uv",new lt(w,m)),y.setAttribute("faceIndex",new lt(x,f)),n.push(new ht(y,null)),s>ci&&s--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function Nh(i,e,t){const n=new pn(i,e,t);return n.texture.mapping=Ca,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function ts(i,e,t,n,s){i.viewport.set(e,t,n,s),i.scissor.set(e,t,n,s)}function C1(i,e,t){return new Bt({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:A1,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:La(),fragmentShader:`
|
|
3972
3979
|
|
|
3973
3980
|
precision highp float;
|
|
3974
3981
|
precision highp int;
|
|
@@ -4072,7 +4079,7 @@ void main() {
|
|
|
4072
4079
|
|
|
4073
4080
|
gl_FragColor = vec4(prefilteredColor, 1.0);
|
|
4074
4081
|
}
|
|
4075
|
-
`,blending:Gn,depthTest:!1,depthWrite:!1})}function
|
|
4082
|
+
`,blending:Gn,depthTest:!1,depthWrite:!1})}function P1(i,e,t){const n=new Float32Array(Ei),s=new U(0,1,0);return new Bt({name:"SphericalGaussianBlur",defines:{n:Ei,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,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:La(),fragmentShader:`
|
|
4076
4083
|
|
|
4077
4084
|
precision mediump float;
|
|
4078
4085
|
precision mediump int;
|
|
@@ -4132,7 +4139,7 @@ void main() {
|
|
|
4132
4139
|
}
|
|
4133
4140
|
|
|
4134
4141
|
}
|
|
4135
|
-
`,blending:Gn,depthTest:!1,depthWrite:!1})}function
|
|
4142
|
+
`,blending:Gn,depthTest:!1,depthWrite:!1})}function Uh(){return new Bt({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:La(),fragmentShader:`
|
|
4136
4143
|
|
|
4137
4144
|
precision mediump float;
|
|
4138
4145
|
precision mediump int;
|
|
@@ -4151,7 +4158,7 @@ void main() {
|
|
|
4151
4158
|
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
|
|
4152
4159
|
|
|
4153
4160
|
}
|
|
4154
|
-
`,blending:Gn,depthTest:!1,depthWrite:!1})}function
|
|
4161
|
+
`,blending:Gn,depthTest:!1,depthWrite:!1})}function Fh(){return new Bt({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:La(),fragmentShader:`
|
|
4155
4162
|
|
|
4156
4163
|
precision mediump float;
|
|
4157
4164
|
precision mediump int;
|
|
@@ -4167,7 +4174,7 @@ void main() {
|
|
|
4167
4174
|
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
|
|
4168
4175
|
|
|
4169
4176
|
}
|
|
4170
|
-
`,blending:Gn,depthTest:!1,depthWrite:!1})}function
|
|
4177
|
+
`,blending:Gn,depthTest:!1,depthWrite:!1})}function La(){return`
|
|
4171
4178
|
|
|
4172
4179
|
precision mediump float;
|
|
4173
4180
|
precision mediump int;
|
|
@@ -4222,7 +4229,7 @@ void main() {
|
|
|
4222
4229
|
gl_Position = vec4( position, 1.0 );
|
|
4223
4230
|
|
|
4224
4231
|
}
|
|
4225
|
-
`}class
|
|
4232
|
+
`}class D0 extends pn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},s=[n,n,n,n,n,n];this.texture=new E0(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
|
|
4226
4233
|
|
|
4227
4234
|
varying vec3 vWorldDirection;
|
|
4228
4235
|
|
|
@@ -4257,7 +4264,7 @@ void main() {
|
|
|
4257
4264
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
4258
4265
|
|
|
4259
4266
|
}
|
|
4260
|
-
`},s=new rn(5,5,5),r=new
|
|
4267
|
+
`},s=new rn(5,5,5),r=new Bt({name:"CubemapFromEquirect",uniforms:Es(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Dt,blending:Gn});r.uniforms.tEquirect.value=t;const a=new ht(s,r),o=t.minFilter;return t.minFilter===Ai&&(t.minFilter=Ft),new Fp(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,s=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,s);e.setRenderTarget(r)}}function D1(i){let e=new WeakMap,t=new WeakMap,n=null;function s(u,p=!1){return u==null?null:p?a(u):r(u)}function r(u){if(u&&u.isTexture){const p=u.mapping;if(p===ka||p===Ga)if(e.has(u)){const g=e.get(u).texture;return o(g,u.mapping)}else{const g=u.image;if(g&&g.height>0){const M=new D0(g.height);return M.fromEquirectangularTexture(i,u),e.set(u,M),u.addEventListener("dispose",l),o(M.texture,u.mapping)}else return null}}return u}function a(u){if(u&&u.isTexture){const p=u.mapping,g=p===ka||p===Ga,M=p===Pi||p===Ms;if(g||M){let m=t.get(u);const f=m!==void 0?m.texture.pmremVersion:0;if(u.isRenderTargetTexture&&u.pmremVersion!==f)return n===null&&(n=new Lh(i)),m=g?n.fromEquirectangular(u,m):n.fromCubemap(u,m),m.texture.pmremVersion=u.pmremVersion,t.set(u,m),m.texture;if(m!==void 0)return m.texture;{const T=u.image;return g&&T&&T.height>0||M&&T&&c(T)?(n===null&&(n=new Lh(i)),m=g?n.fromEquirectangular(u):n.fromCubemap(u),m.texture.pmremVersion=u.pmremVersion,t.set(u,m),u.addEventListener("dispose",h),m.texture):null}}}return u}function o(u,p){return p===ka?u.mapping=Pi:p===Ga&&(u.mapping=Ms),u}function c(u){let p=0;const g=6;for(let M=0;M<g;M++)u[M]!==void 0&&p++;return p===g}function l(u){const p=u.target;p.removeEventListener("dispose",l);const g=e.get(p);g!==void 0&&(e.delete(p),g.dispose())}function h(u){const p=u.target;p.removeEventListener("dispose",h);const g=t.get(p);g!==void 0&&(t.delete(p),g.dispose())}function d(){e=new WeakMap,t=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:s,dispose:d}}function I1(i){const e={};function t(n){if(e[n]!==void 0)return e[n];const s=i.getExtension(n);return e[n]=s,s}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){const s=t(n);return s===null&&ps("WebGLRenderer: "+n+" extension not supported."),s}}}function L1(i,e,t,n){const s={},r=new WeakMap;function a(d){const u=d.target;u.index!==null&&e.remove(u.index);for(const g in u.attributes)e.remove(u.attributes[g]);u.removeEventListener("dispose",a),delete s[u.id];const p=r.get(u);p&&(e.remove(p),r.delete(u)),n.releaseStatesOfGeometry(u),u.isInstancedBufferGeometry===!0&&delete u._maxInstanceCount,t.memory.geometries--}function o(d,u){return s[u.id]===!0||(u.addEventListener("dispose",a),s[u.id]=!0,t.memory.geometries++),u}function c(d){const u=d.attributes;for(const p in u)e.update(u[p],i.ARRAY_BUFFER)}function l(d){const u=[],p=d.index,g=d.attributes.position;let M=0;if(g===void 0)return;if(p!==null){const T=p.array;M=p.version;for(let w=0,x=T.length;w<x;w+=3){const y=T[w+0],b=T[w+1],R=T[w+2];u.push(y,b,b,R,R,y)}}else{const T=g.array;M=g.version;for(let w=0,x=T.length/3-1;w<x;w+=3){const y=w+0,b=w+1,R=w+2;u.push(y,b,b,R,R,y)}}const m=new(g.count>=65535?M0:x0)(u,1);m.version=M;const f=r.get(d);f&&e.remove(f),r.set(d,m)}function h(d){const u=r.get(d);if(u){const p=d.index;p!==null&&u.version<p.version&&l(d)}else l(d);return r.get(d)}return{get:o,update:c,getWireframeAttribute:h}}function N1(i,e,t){let n;function s(d){n=d}let r,a;function o(d){r=d.type,a=d.bytesPerElement}function c(d,u){i.drawElements(n,u,r,d*a),t.update(u,n,1)}function l(d,u,p){p!==0&&(i.drawElementsInstanced(n,u,r,d*a,p),t.update(u,n,p))}function h(d,u,p){if(p===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,u,0,r,d,0,p);let M=0;for(let m=0;m<p;m++)M+=u[m];t.update(M,n,1)}this.setMode=s,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=h}function U1(i){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,a,o){switch(t.calls++,a){case i.TRIANGLES:t.triangles+=o*(r/3);break;case i.LINES:t.lines+=o*(r/2);break;case i.LINE_STRIP:t.lines+=o*(r-1);break;case i.LINE_LOOP:t.lines+=o*r;break;case i.POINTS:t.points+=o*r;break;default:Xe("WebGLInfo: Unknown draw mode:",a);break}}function s(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:s,update:n}}function F1(i,e,t){const n=new WeakMap,s=new ut;function r(a,o,c){const l=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,d=h!==void 0?h.length:0;let u=n.get(o);if(u===void 0||u.count!==d){let E=function(){R.dispose(),n.delete(o),o.removeEventListener("dispose",E)};u!==void 0&&u.texture.dispose();const p=o.morphAttributes.position!==void 0,g=o.morphAttributes.normal!==void 0,M=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],f=o.morphAttributes.normal||[],T=o.morphAttributes.color||[];let w=0;p===!0&&(w=1),g===!0&&(w=2),M===!0&&(w=3);let x=o.attributes.position.count*w,y=1;x>e.maxTextureSize&&(y=Math.ceil(x/e.maxTextureSize),x=e.maxTextureSize);const b=new Float32Array(x*y*4*d),R=new g0(b,x,y,d);R.type=Rn,R.needsUpdate=!0;const v=w*4;for(let P=0;P<d;P++){const C=m[P],L=f[P],X=T[P],q=x*y*4*P;for(let F=0;F<C.count;F++){const W=F*v;p===!0&&(s.fromBufferAttribute(C,F),b[q+W+0]=s.x,b[q+W+1]=s.y,b[q+W+2]=s.z,b[q+W+3]=0),g===!0&&(s.fromBufferAttribute(L,F),b[q+W+4]=s.x,b[q+W+5]=s.y,b[q+W+6]=s.z,b[q+W+7]=0),M===!0&&(s.fromBufferAttribute(X,F),b[q+W+8]=s.x,b[q+W+9]=s.y,b[q+W+10]=s.z,b[q+W+11]=X.itemSize===4?s.w:1)}}u={count:d,texture:R,size:new Fe(x,y)},n.set(o,u),o.addEventListener("dispose",E)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",a.morphTexture,t);else{let p=0;for(let M=0;M<l.length;M++)p+=l[M];const g=o.morphTargetsRelative?1:1-p;c.getUniforms().setValue(i,"morphTargetBaseInfluence",g),c.getUniforms().setValue(i,"morphTargetInfluences",l)}c.getUniforms().setValue(i,"morphTargetsTexture",u.texture,t),c.getUniforms().setValue(i,"morphTargetsTextureSize",u.size)}return{update:r}}function O1(i,e,t,n,s){let r=new WeakMap;function a(l){const h=s.render.frame,d=l.geometry,u=e.get(l,d);if(r.get(u)!==h&&(e.update(u),r.set(u,h)),l.isInstancedMesh&&(l.hasEventListener("dispose",c)===!1&&l.addEventListener("dispose",c),r.get(l)!==h&&(t.update(l.instanceMatrix,i.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,i.ARRAY_BUFFER),r.set(l,h))),l.isSkinnedMesh){const p=l.skeleton;r.get(p)!==h&&(p.update(),r.set(p,h))}return u}function o(){r=new WeakMap}function c(l){const h=l.target;h.removeEventListener("dispose",c),n.releaseStatesOfObject(h),t.remove(h.instanceMatrix),h.instanceColor!==null&&t.remove(h.instanceColor)}return{update:a,dispose:o}}const z1={[e0]:"LINEAR_TONE_MAPPING",[t0]:"REINHARD_TONE_MAPPING",[n0]:"CINEON_TONE_MAPPING",[i0]:"ACES_FILMIC_TONE_MAPPING",[r0]:"AGX_TONE_MAPPING",[a0]:"NEUTRAL_TONE_MAPPING",[s0]:"CUSTOM_TONE_MAPPING"};function B1(i,e,t,n,s,r){const a=new pn(e,t,{type:i,depthBuffer:s,stencilBuffer:r,samples:n?4:0,depthTexture:s?new ys(e,t):void 0}),o=new pn(e,t,{type:Vn,depthBuffer:!1,stencilBuffer:!1}),c=new yt;c.setAttribute("position",new Et([-1,3,0,-1,-1,0,3,-1,0],3)),c.setAttribute("uv",new Et([0,2,0,0,2,0],2));const l=new Rp({uniforms:{tDiffuse:{value:null}},vertexShader:`
|
|
4261
4268
|
precision highp float;
|
|
4262
4269
|
|
|
4263
4270
|
uniform mat4 modelViewMatrix;
|
|
@@ -4303,17 +4310,17 @@ void main() {
|
|
|
4303
4310
|
#ifdef SRGB_TRANSFER
|
|
4304
4311
|
gl_FragColor = sRGBTransferOETF( gl_FragColor );
|
|
4305
4312
|
#endif
|
|
4306
|
-
}`,depthTest:!1,depthWrite:!1}),h=new
|
|
4313
|
+
}`,depthTest:!1,depthWrite:!1}),h=new ht(c,l),d=new Ia(-1,1,1,-1,0,1);let u=null,p=null,g=!1,M,m=null,f=[],T=!1;this.setSize=function(w,x){a.setSize(w,x),o.setSize(w,x);for(let y=0;y<f.length;y++){const b=f[y];b.setSize&&b.setSize(w,x)}},this.setEffects=function(w){f=w,T=f.length>0&&f[0].isRenderPass===!0;const x=a.width,y=a.height;for(let b=0;b<f.length;b++){const R=f[b];R.setSize&&R.setSize(x,y)}},this.begin=function(w,x){if(g||w.toneMapping===Pn&&f.length===0)return!1;if(m=x,x!==null){const y=x.width,b=x.height;(a.width!==y||a.height!==b)&&this.setSize(y,b)}return T===!1&&w.setRenderTarget(a),M=w.toneMapping,w.toneMapping=Pn,!0},this.hasRenderPass=function(){return T},this.end=function(w,x){w.toneMapping=M,g=!0;let y=a,b=o;for(let R=0;R<f.length;R++){const v=f[R];if(v.enabled!==!1&&(v.render(w,b,y,x),v.needsSwap!==!1)){const E=y;y=b,b=E}}if(u!==w.outputColorSpace||p!==w.toneMapping){u=w.outputColorSpace,p=w.toneMapping,l.defines={},qe.getTransfer(u)===Qe&&(l.defines.SRGB_TRANSFER="");const R=z1[p];R&&(l.defines[R]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=y.texture,w.setRenderTarget(m),w.render(h,d),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 I0=new zt,Fc=new ys(1,1),L0=new g0,N0=new rp,U0=new E0,Oh=[],zh=[],Bh=new Float32Array(16),kh=new Float32Array(9),Gh=new Float32Array(4);function ws(i,e,t){const n=i[0];if(n<=0||n>0)return i;const s=e*t;let r=Oh[s];if(r===void 0&&(r=new Float32Array(s),Oh[s]=r),e!==0){n.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,i[a].toArray(r,o)}return r}function bt(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function Tt(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function Na(i,e){let t=zh[e];t===void 0&&(t=new Int32Array(e),zh[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function k1(i,e){const t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function G1(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(bt(t,e))return;i.uniform2fv(this.addr,e),Tt(t,e)}}function H1(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(bt(t,e))return;i.uniform3fv(this.addr,e),Tt(t,e)}}function V1(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(bt(t,e))return;i.uniform4fv(this.addr,e),Tt(t,e)}}function W1(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(bt(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),Tt(t,e)}else{if(bt(t,n))return;Gh.set(n),i.uniformMatrix2fv(this.addr,!1,Gh),Tt(t,n)}}function X1(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(bt(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),Tt(t,e)}else{if(bt(t,n))return;kh.set(n),i.uniformMatrix3fv(this.addr,!1,kh),Tt(t,n)}}function q1(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(bt(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),Tt(t,e)}else{if(bt(t,n))return;Bh.set(n),i.uniformMatrix4fv(this.addr,!1,Bh),Tt(t,n)}}function Y1(i,e){const t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function K1(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(bt(t,e))return;i.uniform2iv(this.addr,e),Tt(t,e)}}function Z1(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(bt(t,e))return;i.uniform3iv(this.addr,e),Tt(t,e)}}function $1(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(bt(t,e))return;i.uniform4iv(this.addr,e),Tt(t,e)}}function J1(i,e){const t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function Q1(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(bt(t,e))return;i.uniform2uiv(this.addr,e),Tt(t,e)}}function j1(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(bt(t,e))return;i.uniform3uiv(this.addr,e),Tt(t,e)}}function e_(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(bt(t,e))return;i.uniform4uiv(this.addr,e),Tt(t,e)}}function t_(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let r;this.type===i.SAMPLER_2D_SHADOW?(Fc.compareFunction=t.isReversedDepthBuffer()?_l:gl,r=Fc):r=I0,t.setTexture2D(e||r,s)}function n_(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture3D(e||N0,s)}function i_(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTextureCube(e||U0,s)}function s_(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture2DArray(e||L0,s)}function r_(i){switch(i){case 5126:return k1;case 35664:return G1;case 35665:return H1;case 35666:return V1;case 35674:return W1;case 35675:return X1;case 35676:return q1;case 5124:case 35670:return Y1;case 35667:case 35671:return K1;case 35668:case 35672:return Z1;case 35669:case 35673:return $1;case 5125:return J1;case 36294:return Q1;case 36295:return j1;case 36296:return e_;case 35678:case 36198:case 36298:case 36306:case 35682:return t_;case 35679:case 36299:case 36307:return n_;case 35680:case 36300:case 36308:case 36293:return i_;case 36289:case 36303:case 36311:case 36292:return s_}}function a_(i,e){i.uniform1fv(this.addr,e)}function o_(i,e){const t=ws(e,this.size,2);i.uniform2fv(this.addr,t)}function c_(i,e){const t=ws(e,this.size,3);i.uniform3fv(this.addr,t)}function l_(i,e){const t=ws(e,this.size,4);i.uniform4fv(this.addr,t)}function h_(i,e){const t=ws(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function u_(i,e){const t=ws(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function d_(i,e){const t=ws(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function f_(i,e){i.uniform1iv(this.addr,e)}function p_(i,e){i.uniform2iv(this.addr,e)}function m_(i,e){i.uniform3iv(this.addr,e)}function g_(i,e){i.uniform4iv(this.addr,e)}function __(i,e){i.uniform1uiv(this.addr,e)}function v_(i,e){i.uniform2uiv(this.addr,e)}function x_(i,e){i.uniform3uiv(this.addr,e)}function M_(i,e){i.uniform4uiv(this.addr,e)}function S_(i,e,t){const n=this.cache,s=e.length,r=Na(t,s);bt(n,r)||(i.uniform1iv(this.addr,r),Tt(n,r));let a;this.type===i.SAMPLER_2D_SHADOW?a=Fc:a=I0;for(let o=0;o!==s;++o)t.setTexture2D(e[o]||a,r[o])}function y_(i,e,t){const n=this.cache,s=e.length,r=Na(t,s);bt(n,r)||(i.uniform1iv(this.addr,r),Tt(n,r));for(let a=0;a!==s;++a)t.setTexture3D(e[a]||N0,r[a])}function E_(i,e,t){const n=this.cache,s=e.length,r=Na(t,s);bt(n,r)||(i.uniform1iv(this.addr,r),Tt(n,r));for(let a=0;a!==s;++a)t.setTextureCube(e[a]||U0,r[a])}function b_(i,e,t){const n=this.cache,s=e.length,r=Na(t,s);bt(n,r)||(i.uniform1iv(this.addr,r),Tt(n,r));for(let a=0;a!==s;++a)t.setTexture2DArray(e[a]||L0,r[a])}function T_(i){switch(i){case 5126:return a_;case 35664:return o_;case 35665:return c_;case 35666:return l_;case 35674:return h_;case 35675:return u_;case 35676:return d_;case 5124:case 35670:return f_;case 35667:case 35671:return p_;case 35668:case 35672:return m_;case 35669:case 35673:return g_;case 5125:return __;case 36294:return v_;case 36295:return x_;case 36296:return M_;case 35678:case 36198:case 36298:case 36306:case 35682:return S_;case 35679:case 36299:case 36307:return y_;case 35680:case 36300:case 36308:case 36293:return E_;case 36289:case 36303:case 36311:case 36292:return b_}}class A_{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=r_(t.type)}}class w_{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=T_(t.type)}}class R_{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const s=this.seq;for(let r=0,a=s.length;r!==a;++r){const o=s[r];o.setValue(e,t[o.id],n)}}}const So=/(\w+)(\])?(\[|\.)?/g;function Hh(i,e){i.seq.push(e),i.map[e.id]=e}function C_(i,e,t){const n=i.name,s=n.length;for(So.lastIndex=0;;){const r=So.exec(n),a=So.lastIndex;let o=r[1];const c=r[2]==="]",l=r[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===s){Hh(t,l===void 0?new A_(o,i,e):new w_(o,i,e));break}else{let d=t.map[o];d===void 0&&(d=new R_(o),Hh(t,d)),t=d}}}class ua{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let a=0;a<n;++a){const o=e.getActiveUniform(t,a),c=e.getUniformLocation(t,o.name);C_(o,c,this)}const s=[],r=[];for(const a of this.seq)a.type===e.SAMPLER_2D_SHADOW||a.type===e.SAMPLER_CUBE_SHADOW||a.type===e.SAMPLER_2D_ARRAY_SHADOW?s.push(a):r.push(a);s.length>0&&(this.seq=s.concat(r))}setValue(e,t,n,s){const r=this.map[t];r!==void 0&&r.setValue(e,n,s)}setOptional(e,t,n){const s=t[n];s!==void 0&&this.setValue(e,n,s)}static upload(e,t,n,s){for(let r=0,a=t.length;r!==a;++r){const o=t[r],c=n[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,s)}}static seqWithValue(e,t){const n=[];for(let s=0,r=e.length;s!==r;++s){const a=e[s];a.id in t&&n.push(a)}return n}}function Vh(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const P_=37297;let D_=0;function I_(i,e){const t=i.split(`
|
|
4307
4314
|
`),n=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=s;a<r;a++){const o=a+1;n.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return n.join(`
|
|
4308
|
-
`)}const
|
|
4315
|
+
`)}const Wh=new ze;function L_(i){qe._getMatrix(Wh,qe.workingColorSpace,i);const e=`mat3( ${Wh.elements.map(t=>t.toFixed(4))} )`;switch(qe.getTransfer(i)){case ga:return[e,"LinearTransferOETF"];case Qe:return[e,"sRGBTransferOETF"];default:return Oe("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function Xh(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),r=(i.getShaderInfoLog(e)||"").trim();if(n&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return t.toUpperCase()+`
|
|
4309
4316
|
|
|
4310
4317
|
`+r+`
|
|
4311
4318
|
|
|
4312
|
-
`+
|
|
4313
|
-
`)}const
|
|
4314
|
-
`)}function
|
|
4315
|
-
`)}function
|
|
4316
|
-
`)}function
|
|
4319
|
+
`+I_(i.getShaderSource(e),o)}else return r}function N_(i,e){const t=L_(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
|
|
4320
|
+
`)}const U_={[e0]:"Linear",[t0]:"Reinhard",[n0]:"Cineon",[i0]:"ACESFilmic",[r0]:"AgX",[a0]:"Neutral",[s0]:"Custom"};function F_(i,e){const t=U_[e];return t===void 0?(Oe("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Wr=new U;function O_(){qe.getLuminanceCoefficients(Wr);const i=Wr.x.toFixed(4),e=Wr.y.toFixed(4),t=Wr.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
|
|
4321
|
+
`)}function z_(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Ys).join(`
|
|
4322
|
+
`)}function B_(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
|
|
4323
|
+
`)}function k_(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){const r=i.getActiveAttrib(e,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),t[a]={type:r.type,location:i.getAttribLocation(e,a),locationSize:o}}return t}function Ys(i){return i!==""}function qh(i,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Yh(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const G_=/^[ \t]*#include +<([\w\d./]+)>/gm;function Oc(i){return i.replace(G_,V_)}const H_=new Map;function V_(i,e){let t=Ge[e];if(t===void 0){const n=H_.get(e);if(n!==void 0)t=Ge[n],Oe('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return Oc(t)}const W_=/#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 Kh(i){return i.replace(W_,X_)}function X_(i,e,t,n){let s="";for(let r=parseInt(e);r<parseInt(t);r++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function Zh(i){let e=`precision ${i.precision} float;
|
|
4317
4324
|
precision ${i.precision} int;
|
|
4318
4325
|
precision ${i.precision} sampler2D;
|
|
4319
4326
|
precision ${i.precision} samplerCube;
|
|
@@ -4333,30 +4340,30 @@ void main() {
|
|
|
4333
4340
|
`;return i.precision==="highp"?e+=`
|
|
4334
4341
|
#define HIGH_PRECISION`:i.precision==="mediump"?e+=`
|
|
4335
4342
|
#define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
|
|
4336
|
-
#define LOW_PRECISION`),e}const
|
|
4337
|
-
`:"";t.isRawShaderMaterial?(m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(
|
|
4343
|
+
#define LOW_PRECISION`),e}const q_={[Qs]:"SHADOWMAP_TYPE_PCF",[Xs]:"SHADOWMAP_TYPE_VSM"};function Y_(i){return q_[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const K_={[Pi]:"ENVMAP_TYPE_CUBE",[Ms]:"ENVMAP_TYPE_CUBE",[Ca]:"ENVMAP_TYPE_CUBE_UV"};function Z_(i){return i.envMap===!1?"ENVMAP_TYPE_CUBE":K_[i.envMapMode]||"ENVMAP_TYPE_CUBE"}const $_={[Ms]:"ENVMAP_MODE_REFRACTION"};function J_(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":$_[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}const Q_={[ll]:"ENVMAP_BLENDING_MULTIPLY",[zf]:"ENVMAP_BLENDING_MIX",[Bf]:"ENVMAP_BLENDING_ADD"};function j_(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":Q_[i.combine]||"ENVMAP_BLENDING_NONE"}function ev(i){const e=i.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:n,maxMip:t}}function tv(i,e,t,n){const s=i.getContext(),r=t.defines;let a=t.vertexShader,o=t.fragmentShader;const c=Y_(t),l=Z_(t),h=J_(t),d=j_(t),u=ev(t),p=z_(t),g=B_(r),M=s.createProgram();let m,f,T=t.glslVersion?"#version "+t.glslVersion+`
|
|
4344
|
+
`:"";t.isRawShaderMaterial?(m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Ys).join(`
|
|
4338
4345
|
`),m.length>0&&(m+=`
|
|
4339
|
-
`),f=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(
|
|
4346
|
+
`),f=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Ys).join(`
|
|
4340
4347
|
`),f.length>0&&(f+=`
|
|
4341
|
-
`)):(m=[
|
|
4342
|
-
`].filter(
|
|
4343
|
-
`),f=[
|
|
4344
|
-
`].filter(
|
|
4345
|
-
`)),a=
|
|
4348
|
+
`)):(m=[Zh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.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",`
|
|
4349
|
+
`].filter(Ys).join(`
|
|
4350
|
+
`),f=[Zh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+h:"",t.envMap?"#define "+d:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Pn?"#define TONE_MAPPING":"",t.toneMapping!==Pn?Ge.tonemapping_pars_fragment:"",t.toneMapping!==Pn?F_("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ge.colorspace_pars_fragment,N_("linearToOutputTexel",t.outputColorSpace),O_(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
|
4351
|
+
`].filter(Ys).join(`
|
|
4352
|
+
`)),a=Oc(a),a=qh(a,t),a=Yh(a,t),o=Oc(o),o=qh(o,t),o=Yh(o,t),a=Kh(a),o=Kh(o),t.isRawShaderMaterial!==!0&&(T=`#version 300 es
|
|
4346
4353
|
`,m=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
4347
4354
|
`)+`
|
|
4348
|
-
`+m,f=["#define varying in",t.glslVersion===
|
|
4355
|
+
`+m,f=["#define varying in",t.glslVersion===ih?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===ih?"":"#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(`
|
|
4349
4356
|
`)+`
|
|
4350
|
-
`+f);const w=
|
|
4357
|
+
`+f);const w=T+m+a,x=T+f+o,y=Vh(s,s.VERTEX_SHADER,w),b=Vh(s,s.FRAGMENT_SHADER,x);s.attachShader(M,y),s.attachShader(M,b),t.index0AttributeName!==void 0?s.bindAttribLocation(M,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(M,0,"position"),s.linkProgram(M);function R(C){if(i.debug.checkShaderErrors){const L=s.getProgramInfoLog(M)||"",X=s.getShaderInfoLog(y)||"",q=s.getShaderInfoLog(b)||"",F=L.trim(),W=X.trim(),V=q.trim();let Q=!0,te=!0;if(s.getProgramParameter(M,s.LINK_STATUS)===!1)if(Q=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,M,y,b);else{const ee=Xh(s,y,"vertex"),se=Xh(s,b,"fragment");Xe("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(M,s.VALIDATE_STATUS)+`
|
|
4351
4358
|
|
|
4352
4359
|
Material Name: `+C.name+`
|
|
4353
4360
|
Material Type: `+C.type+`
|
|
4354
4361
|
|
|
4355
4362
|
Program Info Log: `+F+`
|
|
4356
4363
|
`+ee+`
|
|
4357
|
-
`+se)}else F!==""?Fe("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(y),s.deleteShader(b),v=new pa(s,x),E=Q_(s,x)}let v;this.getUniforms=function(){return v===void 0&&R(this),v};let E;this.getAttributes=function(){return E===void 0&&R(this),E};let P=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return P===!1&&(P=s.getProgramParameter(x,H_)),P},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(x),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=V_++,this.cacheKey=e,this.usedTimes=1,this.program=x,this.vertexShader=y,this.fragmentShader=b,this}let pv=0;class mv{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 gv(e),t.set(e,n)),n}}class gv{constructor(e){this.id=pv++,this.code=e,this.usedTimes=0}}function _v(i){return i===Di||i===ga||i===_a}function vv(i,e,t,n,s,r){const a=new Tl,o=new mv,c=new Set,l=[],h=new Map,d=n.logarithmicDepthBuffer;let u=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(v){return c.add(v),v===0?"uv":`uv${v}`}function x(v,E,P,C,L,X){const q=C.fog,F=L.geometry,W=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?C.environment:null,V=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap,Q=e.get(v.envMap||W,V),te=Q&&Q.mapping===Na?Q.image.height:null,ee=p[v.type];v.precision!==null&&(u=n.getMaxPrecision(v.precision),u!==v.precision&&Fe("WebGLProgram.getParameters:",v.precision,"not supported, using",u,"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 rt,We,Z,re;if(ee){const Se=Sn[ee];rt=Se.vertexShader,We=Se.fragmentShader}else{rt=v.vertexShader,We=v.fragmentShader;const Se=o.getVertexShaderStage(v),pt=o.getFragmentShaderStage(v);o.update(v,Se,pt),Z=Se.id,re=pt.id}const ne=i.getRenderTarget(),k=i.state.buffers.depth.getReversed(),Pe=L.isInstancedMesh===!0,De=L.isBatchedMesh===!0,Re=!!v.map,Me=!!v.matcap,Ue=!!Q,Ie=!!v.aoMap,Le=!!v.lightMap,Ze=!!v.bumpMap&&v.wireframe===!1,$e=!!v.normalMap,dt=!!v.displacementMap,ct=!!v.emissiveMap,ft=!!v.metalnessMap,yt=!!v.roughnessMap,I=v.anisotropy>0,Ht=v.clearcoat>0,Je=v.dispersion>0,T=v.iridescence>0,_=v.sheen>0,O=v.transmission>0,G=I&&!!v.anisotropyMap,Y=Ht&&!!v.clearcoatMap,ie=Ht&&!!v.clearcoatNormalMap,oe=Ht&&!!v.clearcoatRoughnessMap,K=T&&!!v.iridescenceMap,J=T&&!!v.iridescenceThicknessMap,ce=_&&!!v.sheenColorMap,Te=_&&!!v.sheenRoughnessMap,ue=!!v.specularMap,le=!!v.specularColorMap,Ce=!!v.specularIntensityMap,Ne=O&&!!v.transmissionMap,Be=O&&!!v.thicknessMap,D=!!v.gradientMap,ae=!!v.alphaMap,$=v.alphaTest>0,he=!!v.alphaHash,me=!!v.extensions;let j=Cn;v.toneMapped&&(ne===null||ne.isXRRenderTarget===!0)&&(j=i.toneMapping);const be={shaderID:ee,shaderType:v.type,shaderName:v.name,vertexShader:rt,fragmentShader:We,defines:v.defines,customVertexShaderID:Z,customFragmentShaderID:re,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:u,batching:De,batchingColor:De&&L._colorsTexture!==null,instancing:Pe,instancingColor:Pe&&L.instanceColor!==null,instancingMorph:Pe&&L.morphTexture!==null,outputColorSpace:ne===null?i.outputColorSpace:ne.isXRRenderTarget===!0?ne.texture.colorSpace:qe.workingColorSpace,alphaToCoverage:!!v.alphaToCoverage,map:Re,matcap:Me,envMap:Ue,envMapMode:Ue&&Q.mapping,envMapCubeUVHeight:te,aoMap:Ie,lightMap:Le,bumpMap:Ze,normalMap:$e,displacementMap:dt,emissiveMap:ct,normalMapObjectSpace:$e&&v.normalMapType===Qf,normalMapTangentSpace:$e&&v.normalMapType===Oc,packedNormalMap:$e&&v.normalMapType===Oc&&_v(v.normalMap.format),metalnessMap:ft,roughnessMap:yt,anisotropy:I,anisotropyMap:G,clearcoat:Ht,clearcoatMap:Y,clearcoatNormalMap:ie,clearcoatRoughnessMap:oe,dispersion:Je,iridescence:T,iridescenceMap:K,iridescenceThicknessMap:J,sheen:_,sheenColorMap:ce,sheenRoughnessMap:Te,specularMap:ue,specularColorMap:le,specularIntensityMap:Ce,transmission:O,transmissionMap:Ne,thicknessMap:Be,gradientMap:D,opaque:v.transparent===!1&&v.blending===ds&&v.alphaToCoverage===!1,alphaMap:ae,alphaTest:$,alphaHash:he,combine:v.combine,mapUv:Re&&g(v.map.channel),aoMapUv:Ie&&g(v.aoMap.channel),lightMapUv:Le&&g(v.lightMap.channel),bumpMapUv:Ze&&g(v.bumpMap.channel),normalMapUv:$e&&g(v.normalMap.channel),displacementMapUv:dt&&g(v.displacementMap.channel),emissiveMapUv:ct&&g(v.emissiveMap.channel),metalnessMapUv:ft&&g(v.metalnessMap.channel),roughnessMapUv:yt&&g(v.roughnessMap.channel),anisotropyMapUv:G&&g(v.anisotropyMap.channel),clearcoatMapUv:Y&&g(v.clearcoatMap.channel),clearcoatNormalMapUv:ie&&g(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:oe&&g(v.clearcoatRoughnessMap.channel),iridescenceMapUv:K&&g(v.iridescenceMap.channel),iridescenceThicknessMapUv:J&&g(v.iridescenceThicknessMap.channel),sheenColorMapUv:ce&&g(v.sheenColorMap.channel),sheenRoughnessMapUv:Te&&g(v.sheenRoughnessMap.channel),specularMapUv:ue&&g(v.specularMap.channel),specularColorMapUv:le&&g(v.specularColorMap.channel),specularIntensityMapUv:Ce&&g(v.specularIntensityMap.channel),transmissionMapUv:Ne&&g(v.transmissionMap.channel),thicknessMapUv:Be&&g(v.thicknessMap.channel),alphaMapUv:ae&&g(v.alphaMap.channel),vertexTangents:!!F.attributes.tangent&&($e||I),vertexNormals:!!F.attributes.normal,vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!F.attributes.color&&F.attributes.color.itemSize===4,pointsUvs:L.isPoints===!0&&!!F.attributes.uv&&(Re||ae),fog:!!q,useFog:v.fog===!0,fogExp2:!!q&&q.isFogExp2,flatShading:v.wireframe===!1&&(v.flatShading===!0||F.attributes.normal===void 0&&$e===!1&&(v.isMeshLambertMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isMeshPhysicalMaterial)),sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:d,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:v.dithering,shadowMapEnabled:i.shadowMap.enabled&&P.length>0,shadowMapType:i.shadowMap.type,toneMapping:j,decodeVideoTexture:Re&&v.map.isVideoTexture===!0&&qe.getTransfer(v.map.colorSpace)===Qe,decodeVideoTextureEmissive:ct&&v.emissiveMap.isVideoTexture===!0&&qe.getTransfer(v.emissiveMap.colorSpace)===Qe,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===zn,flipSided:v.side===Pt,useDepthPacking:v.depthPacking>=0,depthPacking:v.depthPacking||0,index0AttributeName:v.index0AttributeName,extensionClipCullDistance:me&&v.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(me&&v.extensions.multiDraw===!0||De)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return be.vertexUv1s=c.has(1),be.vertexUv2s=c.has(2),be.vertexUv3s=c.has(3),c.clear(),be}function m(v){const E=[];if(v.shaderID?E.push(v.shaderID):(E.push(v.customVertexShaderID),E.push(v.customFragmentShaderID)),v.defines!==void 0)for(const P in v.defines)E.push(P),E.push(v.defines[P]);return v.isRawShaderMaterial===!1&&(f(E,v),A(E,v),E.push(i.outputColorSpace)),E.push(v.customProgramCacheKey),E.join()}function f(v,E){v.push(E.precision),v.push(E.outputColorSpace),v.push(E.envMapMode),v.push(E.envMapCubeUVHeight),v.push(E.mapUv),v.push(E.alphaMapUv),v.push(E.lightMapUv),v.push(E.aoMapUv),v.push(E.bumpMapUv),v.push(E.normalMapUv),v.push(E.displacementMapUv),v.push(E.emissiveMapUv),v.push(E.metalnessMapUv),v.push(E.roughnessMapUv),v.push(E.anisotropyMapUv),v.push(E.clearcoatMapUv),v.push(E.clearcoatNormalMapUv),v.push(E.clearcoatRoughnessMapUv),v.push(E.iridescenceMapUv),v.push(E.iridescenceThicknessMapUv),v.push(E.sheenColorMapUv),v.push(E.sheenRoughnessMapUv),v.push(E.specularMapUv),v.push(E.specularColorMapUv),v.push(E.specularIntensityMapUv),v.push(E.transmissionMapUv),v.push(E.thicknessMapUv),v.push(E.combine),v.push(E.fogExp2),v.push(E.sizeAttenuation),v.push(E.morphTargetsCount),v.push(E.morphAttributeCount),v.push(E.numDirLights),v.push(E.numPointLights),v.push(E.numSpotLights),v.push(E.numSpotLightMaps),v.push(E.numHemiLights),v.push(E.numRectAreaLights),v.push(E.numDirLightShadows),v.push(E.numPointLightShadows),v.push(E.numSpotLightShadows),v.push(E.numSpotLightShadowsWithMaps),v.push(E.numLightProbes),v.push(E.shadowMapType),v.push(E.toneMapping),v.push(E.numClippingPlanes),v.push(E.numClipIntersection),v.push(E.depthPacking)}function A(v,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),v.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),v.push(a.mask)}function w(v){const E=p[v.type];let P;if(E){const C=Sn[E];P=Op.clone(C.uniforms)}else P=v.uniforms;return P}function M(v,E){let P=h.get(E);return P!==void 0?++P.usedTimes:(P=new fv(i,E,v,s),l.push(P),h.set(E,P)),P}function y(v){if(--v.usedTimes===0){const E=l.indexOf(v);l[E]=l[l.length-1],l.pop(),h.delete(v.cacheKey),v.destroy()}}function b(v){o.remove(v)}function R(){o.dispose()}return{getParameters:x,getProgramCacheKey:m,getUniforms:w,acquireProgram:M,releaseProgram:y,releaseShaderCache:b,programs:l,dispose:R}}function xv(){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,c){i.get(a)[o]=c}function r(){i=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:r}}function Mv(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 ru(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 au(){const i=[];let e=0;const t=[],n=[],s=[];function r(){e=0,t.length=0,n.length=0,s.length=0}function a(u){let p=0;return u.isInstancedMesh&&(p+=2),u.isSkinnedMesh&&(p+=1),p}function o(u,p,g,x,m,f){let A=i[e];return A===void 0?(A={id:u.id,object:u,geometry:p,material:g,materialVariant:a(u),groupOrder:x,renderOrder:u.renderOrder,z:m,group:f},i[e]=A):(A.id=u.id,A.object=u,A.geometry=p,A.material=g,A.materialVariant=a(u),A.groupOrder=x,A.renderOrder=u.renderOrder,A.z=m,A.group=f),e++,A}function c(u,p,g,x,m,f){const A=o(u,p,g,x,m,f);g.transmission>0?n.push(A):g.transparent===!0?s.push(A):t.push(A)}function l(u,p,g,x,m,f){const A=o(u,p,g,x,m,f);g.transmission>0?n.unshift(A):g.transparent===!0?s.unshift(A):t.unshift(A)}function h(u,p,g){t.length>1&&t.sort(u||Mv),n.length>1&&n.sort(p||ru),s.length>1&&s.sort(p||ru),g&&(t.reverse(),n.reverse(),s.reverse())}function d(){for(let u=e,p=i.length;u<p;u++){const g=i[u];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:c,unshift:l,finish:d,sort:h}}function Sv(){let i=new WeakMap;function e(n,s){const r=i.get(n);let a;return r===void 0?(a=new au,i.set(n,[a])):s>=r.length?(a=new au,r.push(a)):a=r[s],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function yv(){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 Ev(){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 Oe};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Oe};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Oe,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let bv=0;function Tv(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function Av(i){const e=new yv,t=Ev(),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 U);const s=new U,r=new st,a=new st;function o(l){let h=0,d=0,u=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,A=0,w=0,M=0,y=0,b=0,R=0;l.sort(Tv);for(let E=0,P=l.length;E<P;E++){const C=l[E],L=C.color,X=C.intensity,q=C.distance;let F=null;if(C.shadow&&C.shadow.map&&(C.shadow.map.texture.format===Di?F=C.shadow.map.texture:F=C.shadow.map.depthTexture||C.shadow.map.texture),C.isAmbientLight)h+=L.r*X,d+=L.g*X,u+=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,A++}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[y]=C.map,y++,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,w++}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]=d,n.ambient[2]=u;const v=n.hash;(v.directionalLength!==p||v.pointLength!==g||v.spotLength!==x||v.rectAreaLength!==m||v.hemiLength!==f||v.numDirectionalShadows!==A||v.numPointShadows!==w||v.numSpotShadows!==M||v.numSpotMaps!==y||v.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=A,n.directionalShadowMap.length=A,n.pointShadow.length=w,n.pointShadowMap.length=w,n.spotShadow.length=M,n.spotShadowMap.length=M,n.directionalShadowMatrix.length=A,n.pointShadowMatrix.length=w,n.spotLightMatrix.length=M+y-b,n.spotLightMap.length=y,n.numSpotLightShadowsWithMaps=b,n.numLightProbes=R,v.directionalLength=p,v.pointLength=g,v.spotLength=x,v.rectAreaLength=m,v.hemiLength=f,v.numDirectionalShadows=A,v.numPointShadows=w,v.numSpotShadows=M,v.numSpotMaps=y,v.numLightProbes=R,n.version=bv++)}function c(l,h){let d=0,u=0,p=0,g=0,x=0;const m=h.matrixWorldInverse;for(let f=0,A=l.length;f<A;f++){const w=l[f];if(w.isDirectionalLight){const M=n.directional[d];M.direction.setFromMatrixPosition(w.matrixWorld),s.setFromMatrixPosition(w.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(m),d++}else if(w.isSpotLight){const M=n.spot[p];M.position.setFromMatrixPosition(w.matrixWorld),M.position.applyMatrix4(m),M.direction.setFromMatrixPosition(w.matrixWorld),s.setFromMatrixPosition(w.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(m),p++}else if(w.isRectAreaLight){const M=n.rectArea[g];M.position.setFromMatrixPosition(w.matrixWorld),M.position.applyMatrix4(m),a.identity(),r.copy(w.matrixWorld),r.premultiply(m),a.extractRotation(r),M.halfWidth.set(w.width*.5,0,0),M.halfHeight.set(0,w.height*.5,0),M.halfWidth.applyMatrix4(a),M.halfHeight.applyMatrix4(a),g++}else if(w.isPointLight){const M=n.point[u];M.position.setFromMatrixPosition(w.matrixWorld),M.position.applyMatrix4(m),u++}else if(w.isHemisphereLight){const M=n.hemi[x];M.direction.setFromMatrixPosition(w.matrixWorld),M.direction.transformDirection(m),x++}}}return{setup:o,setupView:c,state:n}}function ou(i){const e=new Av(i),t=[],n=[],s=[];function r(u){d.camera=u,t.length=0,n.length=0,s.length=0}function a(u){t.push(u)}function o(u){n.push(u)}function c(u){s.push(u)}function l(){e.setup(t)}function h(u){e.setupView(t,u)}const d={lightsArray:t,shadowsArray:n,lightProbeGridArray:s,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:d,setupLights:l,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:c}}function wv(i){let e=new WeakMap;function t(s,r=0){const a=e.get(s);let o;return a===void 0?(o=new ou(i),e.set(s,[o])):r>=a.length?(o=new ou(i),a.push(o)):o=a[r],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const Rv=`void main() {
|
|
4364
|
+
`+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(y),s.deleteShader(b),v=new ua(s,M),E=k_(s,M)}let v;this.getUniforms=function(){return v===void 0&&R(this),v};let E;this.getAttributes=function(){return E===void 0&&R(this),E};let P=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return P===!1&&(P=s.getProgramParameter(M,P_)),P},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(M),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=D_++,this.cacheKey=e,this.usedTimes=1,this.program=M,this.vertexShader=y,this.fragmentShader=b,this}let nv=0;class iv{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 sv(e),t.set(e,n)),n}}class sv{constructor(e){this.id=nv++,this.code=e,this.usedTimes=0}}function rv(i){return i===Di||i===fa||i===pa}function av(i,e,t,n,s,r){const a=new xl,o=new iv,c=new Set,l=[],h=new Map,d=n.logarithmicDepthBuffer;let u=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(v){return c.add(v),v===0?"uv":`uv${v}`}function M(v,E,P,C,L,X){const q=C.fog,F=L.geometry,W=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?C.environment:null,V=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap,Q=e.get(v.envMap||W,V),te=Q&&Q.mapping===Ca?Q.image.height:null,ee=p[v.type];v.precision!==null&&(u=n.getMaxPrecision(v.precision),u!==v.precision&&Oe("WebGLProgram.getParameters:",v.precision,"not supported, using",u,"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 st,We,Z,re;if(ee){const Se=Sn[ee];st=Se.vertexShader,We=Se.fragmentShader}else{st=v.vertexShader,We=v.fragmentShader;const Se=o.getVertexShaderStage(v),pt=o.getFragmentShaderStage(v);o.update(v,Se,pt),Z=Se.id,re=pt.id}const ne=i.getRenderTarget(),k=i.state.buffers.depth.getReversed(),Pe=L.isInstancedMesh===!0,De=L.isBatchedMesh===!0,Re=!!v.map,xe=!!v.matcap,Ue=!!Q,Ie=!!v.aoMap,Le=!!v.lightMap,Ze=!!v.bumpMap&&v.wireframe===!1,$e=!!v.normalMap,dt=!!v.displacementMap,ct=!!v.emissiveMap,ft=!!v.metalnessMap,xt=!!v.roughnessMap,I=v.anisotropy>0,Vt=v.clearcoat>0,Je=v.dispersion>0,A=v.iridescence>0,_=v.sheen>0,O=v.transmission>0,G=I&&!!v.anisotropyMap,Y=Vt&&!!v.clearcoatMap,ie=Vt&&!!v.clearcoatNormalMap,oe=Vt&&!!v.clearcoatRoughnessMap,K=A&&!!v.iridescenceMap,J=A&&!!v.iridescenceThicknessMap,ce=_&&!!v.sheenColorMap,Te=_&&!!v.sheenRoughnessMap,ue=!!v.specularMap,le=!!v.specularColorMap,Ce=!!v.specularIntensityMap,Ne=O&&!!v.transmissionMap,Be=O&&!!v.thicknessMap,D=!!v.gradientMap,ae=!!v.alphaMap,$=v.alphaTest>0,he=!!v.alphaHash,me=!!v.extensions;let j=Pn;v.toneMapped&&(ne===null||ne.isXRRenderTarget===!0)&&(j=i.toneMapping);const be={shaderID:ee,shaderType:v.type,shaderName:v.name,vertexShader:st,fragmentShader:We,defines:v.defines,customVertexShaderID:Z,customFragmentShaderID:re,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:u,batching:De,batchingColor:De&&L._colorsTexture!==null,instancing:Pe,instancingColor:Pe&&L.instanceColor!==null,instancingMorph:Pe&&L.morphTexture!==null,outputColorSpace:ne===null?i.outputColorSpace:ne.isXRRenderTarget===!0?ne.texture.colorSpace:qe.workingColorSpace,alphaToCoverage:!!v.alphaToCoverage,map:Re,matcap:xe,envMap:Ue,envMapMode:Ue&&Q.mapping,envMapCubeUVHeight:te,aoMap:Ie,lightMap:Le,bumpMap:Ze,normalMap:$e,displacementMap:dt,emissiveMap:ct,normalMapObjectSpace:$e&&v.normalMapType===Hf,normalMapTangentSpace:$e&&v.normalMapType===Dc,packedNormalMap:$e&&v.normalMapType===Dc&&rv(v.normalMap.format),metalnessMap:ft,roughnessMap:xt,anisotropy:I,anisotropyMap:G,clearcoat:Vt,clearcoatMap:Y,clearcoatNormalMap:ie,clearcoatRoughnessMap:oe,dispersion:Je,iridescence:A,iridescenceMap:K,iridescenceThicknessMap:J,sheen:_,sheenColorMap:ce,sheenRoughnessMap:Te,specularMap:ue,specularColorMap:le,specularIntensityMap:Ce,transmission:O,transmissionMap:Ne,thicknessMap:Be,gradientMap:D,opaque:v.transparent===!1&&v.blending===fs&&v.alphaToCoverage===!1,alphaMap:ae,alphaTest:$,alphaHash:he,combine:v.combine,mapUv:Re&&g(v.map.channel),aoMapUv:Ie&&g(v.aoMap.channel),lightMapUv:Le&&g(v.lightMap.channel),bumpMapUv:Ze&&g(v.bumpMap.channel),normalMapUv:$e&&g(v.normalMap.channel),displacementMapUv:dt&&g(v.displacementMap.channel),emissiveMapUv:ct&&g(v.emissiveMap.channel),metalnessMapUv:ft&&g(v.metalnessMap.channel),roughnessMapUv:xt&&g(v.roughnessMap.channel),anisotropyMapUv:G&&g(v.anisotropyMap.channel),clearcoatMapUv:Y&&g(v.clearcoatMap.channel),clearcoatNormalMapUv:ie&&g(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:oe&&g(v.clearcoatRoughnessMap.channel),iridescenceMapUv:K&&g(v.iridescenceMap.channel),iridescenceThicknessMapUv:J&&g(v.iridescenceThicknessMap.channel),sheenColorMapUv:ce&&g(v.sheenColorMap.channel),sheenRoughnessMapUv:Te&&g(v.sheenRoughnessMap.channel),specularMapUv:ue&&g(v.specularMap.channel),specularColorMapUv:le&&g(v.specularColorMap.channel),specularIntensityMapUv:Ce&&g(v.specularIntensityMap.channel),transmissionMapUv:Ne&&g(v.transmissionMap.channel),thicknessMapUv:Be&&g(v.thicknessMap.channel),alphaMapUv:ae&&g(v.alphaMap.channel),vertexTangents:!!F.attributes.tangent&&($e||I),vertexNormals:!!F.attributes.normal,vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!F.attributes.color&&F.attributes.color.itemSize===4,pointsUvs:L.isPoints===!0&&!!F.attributes.uv&&(Re||ae),fog:!!q,useFog:v.fog===!0,fogExp2:!!q&&q.isFogExp2,flatShading:v.wireframe===!1&&(v.flatShading===!0||F.attributes.normal===void 0&&$e===!1&&(v.isMeshLambertMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isMeshPhysicalMaterial)),sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:d,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:v.dithering,shadowMapEnabled:i.shadowMap.enabled&&P.length>0,shadowMapType:i.shadowMap.type,toneMapping:j,decodeVideoTexture:Re&&v.map.isVideoTexture===!0&&qe.getTransfer(v.map.colorSpace)===Qe,decodeVideoTextureEmissive:ct&&v.emissiveMap.isVideoTexture===!0&&qe.getTransfer(v.emissiveMap.colorSpace)===Qe,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===An,flipSided:v.side===Dt,useDepthPacking:v.depthPacking>=0,depthPacking:v.depthPacking||0,index0AttributeName:v.index0AttributeName,extensionClipCullDistance:me&&v.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(me&&v.extensions.multiDraw===!0||De)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return be.vertexUv1s=c.has(1),be.vertexUv2s=c.has(2),be.vertexUv3s=c.has(3),c.clear(),be}function m(v){const E=[];if(v.shaderID?E.push(v.shaderID):(E.push(v.customVertexShaderID),E.push(v.customFragmentShaderID)),v.defines!==void 0)for(const P in v.defines)E.push(P),E.push(v.defines[P]);return v.isRawShaderMaterial===!1&&(f(E,v),T(E,v),E.push(i.outputColorSpace)),E.push(v.customProgramCacheKey),E.join()}function f(v,E){v.push(E.precision),v.push(E.outputColorSpace),v.push(E.envMapMode),v.push(E.envMapCubeUVHeight),v.push(E.mapUv),v.push(E.alphaMapUv),v.push(E.lightMapUv),v.push(E.aoMapUv),v.push(E.bumpMapUv),v.push(E.normalMapUv),v.push(E.displacementMapUv),v.push(E.emissiveMapUv),v.push(E.metalnessMapUv),v.push(E.roughnessMapUv),v.push(E.anisotropyMapUv),v.push(E.clearcoatMapUv),v.push(E.clearcoatNormalMapUv),v.push(E.clearcoatRoughnessMapUv),v.push(E.iridescenceMapUv),v.push(E.iridescenceThicknessMapUv),v.push(E.sheenColorMapUv),v.push(E.sheenRoughnessMapUv),v.push(E.specularMapUv),v.push(E.specularColorMapUv),v.push(E.specularIntensityMapUv),v.push(E.transmissionMapUv),v.push(E.thicknessMapUv),v.push(E.combine),v.push(E.fogExp2),v.push(E.sizeAttenuation),v.push(E.morphTargetsCount),v.push(E.morphAttributeCount),v.push(E.numDirLights),v.push(E.numPointLights),v.push(E.numSpotLights),v.push(E.numSpotLightMaps),v.push(E.numHemiLights),v.push(E.numRectAreaLights),v.push(E.numDirLightShadows),v.push(E.numPointLightShadows),v.push(E.numSpotLightShadows),v.push(E.numSpotLightShadowsWithMaps),v.push(E.numLightProbes),v.push(E.shadowMapType),v.push(E.toneMapping),v.push(E.numClippingPlanes),v.push(E.numClipIntersection),v.push(E.depthPacking)}function T(v,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),v.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),v.push(a.mask)}function w(v){const E=p[v.type];let P;if(E){const C=Sn[E];P=Tp.clone(C.uniforms)}else P=v.uniforms;return P}function x(v,E){let P=h.get(E);return P!==void 0?++P.usedTimes:(P=new tv(i,E,v,s),l.push(P),h.set(E,P)),P}function y(v){if(--v.usedTimes===0){const E=l.indexOf(v);l[E]=l[l.length-1],l.pop(),h.delete(v.cacheKey),v.destroy()}}function b(v){o.remove(v)}function R(){o.dispose()}return{getParameters:M,getProgramCacheKey:m,getUniforms:w,acquireProgram:x,releaseProgram:y,releaseShaderCache:b,programs:l,dispose:R}}function ov(){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,c){i.get(a)[o]=c}function r(){i=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:r}}function cv(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 $h(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 Jh(){const i=[];let e=0;const t=[],n=[],s=[];function r(){e=0,t.length=0,n.length=0,s.length=0}function a(u){let p=0;return u.isInstancedMesh&&(p+=2),u.isSkinnedMesh&&(p+=1),p}function o(u,p,g,M,m,f){let T=i[e];return T===void 0?(T={id:u.id,object:u,geometry:p,material:g,materialVariant:a(u),groupOrder:M,renderOrder:u.renderOrder,z:m,group:f},i[e]=T):(T.id=u.id,T.object=u,T.geometry=p,T.material=g,T.materialVariant=a(u),T.groupOrder=M,T.renderOrder=u.renderOrder,T.z=m,T.group=f),e++,T}function c(u,p,g,M,m,f){const T=o(u,p,g,M,m,f);g.transmission>0?n.push(T):g.transparent===!0?s.push(T):t.push(T)}function l(u,p,g,M,m,f){const T=o(u,p,g,M,m,f);g.transmission>0?n.unshift(T):g.transparent===!0?s.unshift(T):t.unshift(T)}function h(u,p,g){t.length>1&&t.sort(u||cv),n.length>1&&n.sort(p||$h),s.length>1&&s.sort(p||$h),g&&(t.reverse(),n.reverse(),s.reverse())}function d(){for(let u=e,p=i.length;u<p;u++){const g=i[u];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:c,unshift:l,finish:d,sort:h}}function lv(){let i=new WeakMap;function e(n,s){const r=i.get(n);let a;return r===void 0?(a=new Jh,i.set(n,[a])):s>=r.length?(a=new Jh,r.push(a)):a=r[s],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function hv(){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 Me};break;case"SpotLight":t={position:new U,direction:new U,color:new Me,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new U,color:new Me,distance:0,decay:0};break;case"HemisphereLight":t={direction:new U,skyColor:new Me,groundColor:new Me};break;case"RectAreaLight":t={color:new Me,position:new U,halfWidth:new U,halfHeight:new U};break}return i[e.id]=t,t}}}function uv(){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 dv=0;function fv(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function pv(i){const e=new hv,t=uv(),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 U);const s=new U,r=new ot,a=new ot;function o(l){let h=0,d=0,u=0;for(let E=0;E<9;E++)n.probe[E].set(0,0,0);let p=0,g=0,M=0,m=0,f=0,T=0,w=0,x=0,y=0,b=0,R=0;l.sort(fv);for(let E=0,P=l.length;E<P;E++){const C=l[E],L=C.color,X=C.intensity,q=C.distance;let F=null;if(C.shadow&&C.shadow.map&&(C.shadow.map.texture.format===Di?F=C.shadow.map.texture:F=C.shadow.map.depthTexture||C.shadow.map.texture),C.isAmbientLight)h+=L.r*X,d+=L.g*X,u+=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,T++}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[M]=W;const V=C.shadow;if(C.map&&(n.spotLightMap[y]=C.map,y++,V.updateMatrices(C),C.castShadow&&b++),n.spotLightMatrix[M]=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[M]=Q,n.spotShadowMap[M]=F,x++}M++}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,w++}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]=d,n.ambient[2]=u;const v=n.hash;(v.directionalLength!==p||v.pointLength!==g||v.spotLength!==M||v.rectAreaLength!==m||v.hemiLength!==f||v.numDirectionalShadows!==T||v.numPointShadows!==w||v.numSpotShadows!==x||v.numSpotMaps!==y||v.numLightProbes!==R)&&(n.directional.length=p,n.spot.length=M,n.rectArea.length=m,n.point.length=g,n.hemi.length=f,n.directionalShadow.length=T,n.directionalShadowMap.length=T,n.pointShadow.length=w,n.pointShadowMap.length=w,n.spotShadow.length=x,n.spotShadowMap.length=x,n.directionalShadowMatrix.length=T,n.pointShadowMatrix.length=w,n.spotLightMatrix.length=x+y-b,n.spotLightMap.length=y,n.numSpotLightShadowsWithMaps=b,n.numLightProbes=R,v.directionalLength=p,v.pointLength=g,v.spotLength=M,v.rectAreaLength=m,v.hemiLength=f,v.numDirectionalShadows=T,v.numPointShadows=w,v.numSpotShadows=x,v.numSpotMaps=y,v.numLightProbes=R,n.version=dv++)}function c(l,h){let d=0,u=0,p=0,g=0,M=0;const m=h.matrixWorldInverse;for(let f=0,T=l.length;f<T;f++){const w=l[f];if(w.isDirectionalLight){const x=n.directional[d];x.direction.setFromMatrixPosition(w.matrixWorld),s.setFromMatrixPosition(w.target.matrixWorld),x.direction.sub(s),x.direction.transformDirection(m),d++}else if(w.isSpotLight){const x=n.spot[p];x.position.setFromMatrixPosition(w.matrixWorld),x.position.applyMatrix4(m),x.direction.setFromMatrixPosition(w.matrixWorld),s.setFromMatrixPosition(w.target.matrixWorld),x.direction.sub(s),x.direction.transformDirection(m),p++}else if(w.isRectAreaLight){const x=n.rectArea[g];x.position.setFromMatrixPosition(w.matrixWorld),x.position.applyMatrix4(m),a.identity(),r.copy(w.matrixWorld),r.premultiply(m),a.extractRotation(r),x.halfWidth.set(w.width*.5,0,0),x.halfHeight.set(0,w.height*.5,0),x.halfWidth.applyMatrix4(a),x.halfHeight.applyMatrix4(a),g++}else if(w.isPointLight){const x=n.point[u];x.position.setFromMatrixPosition(w.matrixWorld),x.position.applyMatrix4(m),u++}else if(w.isHemisphereLight){const x=n.hemi[M];x.direction.setFromMatrixPosition(w.matrixWorld),x.direction.transformDirection(m),M++}}}return{setup:o,setupView:c,state:n}}function Qh(i){const e=new pv(i),t=[],n=[],s=[];function r(u){d.camera=u,t.length=0,n.length=0,s.length=0}function a(u){t.push(u)}function o(u){n.push(u)}function c(u){s.push(u)}function l(){e.setup(t)}function h(u){e.setupView(t,u)}const d={lightsArray:t,shadowsArray:n,lightProbeGridArray:s,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:d,setupLights:l,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:c}}function mv(i){let e=new WeakMap;function t(s,r=0){const a=e.get(s);let o;return a===void 0?(o=new Qh(i),e.set(s,[o])):r>=a.length?(o=new Qh(i),a.push(o)):o=a[r],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const gv=`void main() {
|
|
4358
4365
|
gl_Position = vec4( position, 1.0 );
|
|
4359
|
-
}`,
|
|
4366
|
+
}`,_v=`uniform sampler2D shadow_pass;
|
|
4360
4367
|
uniform vec2 resolution;
|
|
4361
4368
|
uniform float radius;
|
|
4362
4369
|
void main() {
|
|
@@ -4381,12 +4388,12 @@ void main() {
|
|
|
4381
4388
|
squared_mean = squared_mean / samples;
|
|
4382
4389
|
float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
|
|
4383
4390
|
gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
|
|
4384
|
-
}`,Pv=[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)],Dv=[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)],cu=new st,zs=new U,Ro=new U;function Iv(i,e,t){let n=new wl;const s=new Oe,r=new Oe,a=new ht,o=new Gp,c=new Hp,l={},h=t.maxTextureSize,d={[di]:Pt,[Pt]:di,[zn]:zn},u=new zt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Oe},radius:{value:4}},vertexShader:Rv,fragmentShader:Cv}),p=u.clone();p.defines.HORIZONTAL_PASS=1;const g=new St;g.setAttribute("position",new lt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const x=new ut(g,u),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Js;let f=this.type;this.render=function(b,R,v){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||b.length===0)return;this.type===Cf&&(Fe("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Js);const E=i.getRenderTarget(),P=i.getActiveCubeFace(),C=i.getActiveMipmapLevel(),L=i.state;L.setBlending(Gn),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){Fe("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===Ws){if(W.isPointLight){Fe("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}V.map=new pn(s.x,s.y,{format:Di,type:Vn,minFilter:Ut,magFilter:Ut,generateMipmaps:!1}),V.map.texture.name=W.name+".shadowMap",V.map.depthTexture=new Ms(s.x,s.y,wn),V.map.depthTexture.name=W.name+".shadowMapDepth",V.map.depthTexture.format=Wn,V.map.depthTexture.compareFunction=null,V.map.depthTexture.minFilter=Ct,V.map.depthTexture.magFilter=Ct}else W.isPointLight?(V.map=new G0(s.x),V.map.depthTexture=new Up(s.x,Pn)):(V.map=new pn(s.x,s.y),V.map.depthTexture=new Ms(s.x,s.y,Pn)),V.map.depthTexture.name=W.name+".shadowMap",V.map.depthTexture.format=Wn,this.type===Js?(V.map.depthTexture.compareFunction=te?El:yl,V.map.depthTexture.minFilter=Ut,V.map.depthTexture.magFilter=Ut):(V.map.depthTexture.compareFunction=null,V.map.depthTexture.minFilter=Ct,V.map.depthTexture.magFilter=Ct);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,rt=W.distance||ge.far;rt!==ge.far&&(ge.far=rt,ge.updateProjectionMatrix()),zs.setFromMatrixPosition(W.matrixWorld),ge.position.copy(zs),Ro.copy(ge.position),Ro.add(Pv[se]),ge.up.copy(Dv[se]),ge.lookAt(Ro),ge.updateMatrixWorld(),Ve.makeTranslation(-zs.x,-zs.y,-zs.z),cu.multiplyMatrices(ge.projectionMatrix,ge.matrixWorldInverse),V._frustum.setFromProjectionMatrix(cu,ge.coordinateSystem,ge.reversedDepth)}else V.updateMatrices(W);n=V.getFrustum(),M(R,v,V.camera,W,this.type)}V.isPointLightShadow!==!0&&this.type===Ws&&A(V,v),V.needsUpdate=!1}f=this.type,m.needsUpdate=!1,i.setRenderTarget(E,P,C)};function A(b,R){const v=e.update(x);u.defines.VSM_SAMPLES!==b.blurSamples&&(u.defines.VSM_SAMPLES=b.blurSamples,p.defines.VSM_SAMPLES=b.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new pn(s.x,s.y,{format:Di,type:Vn})),u.uniforms.shadow_pass.value=b.map.depthTexture,u.uniforms.resolution.value=b.mapSize,u.uniforms.radius.value=b.radius,i.setRenderTarget(b.mapPass),i.clear(),i.renderBufferDirect(R,null,v,u,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,v,p,x,null)}function w(b,R,v,E){let P=null;const C=v.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(C!==void 0)P=C;else if(P=v.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 L=P.uuid,X=R.uuid;let q=l[L];q===void 0&&(q={},l[L]=q);let F=q[X];F===void 0&&(F=P.clone(),q[X]=F,R.addEventListener("dispose",y)),P=F}if(P.visible=R.visible,P.wireframe=R.wireframe,E===Ws?P.side=R.shadowSide!==null?R.shadowSide:R.side:P.side=R.shadowSide!==null?R.shadowSide:d[R.side],P.alphaMap=R.alphaMap,P.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,P.map=R.map,P.clipShadows=R.clipShadows,P.clippingPlanes=R.clippingPlanes,P.clipIntersection=R.clipIntersection,P.displacementMap=R.displacementMap,P.displacementScale=R.displacementScale,P.displacementBias=R.displacementBias,P.wireframeLinewidth=R.wireframeLinewidth,P.linewidth=R.linewidth,v.isPointLight===!0&&P.isMeshDistanceMaterial===!0){const L=i.properties.get(P);L.light=v}return P}function M(b,R,v,E,P){if(b.visible===!1)return;if(b.layers.test(R.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&P===Ws)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(v.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=w(b,te,E,P);b.onBeforeShadow(i,b,R,v,X,ee,Q),i.renderBufferDirect(v,null,X,ee,b,Q),b.onAfterShadow(i,b,R,v,X,ee,Q)}}}else if(q.visible){const F=w(b,q,E,P);b.onBeforeShadow(i,b,R,v,X,F,null),i.renderBufferDirect(v,null,X,F,b,null),b.onAfterShadow(i,b,R,v,X,F,null)}}const L=b.children;for(let X=0,q=L.length;X<q;X++)M(L[X],R,v,E,P)}function y(b){b.target.removeEventListener("dispose",y);for(const v in l){const E=l[v],P=b.target.uuid;P in E&&(E[P].dispose(),delete E[P])}}}function Lv(i,e){function t(){let D=!1;const ae=new ht;let $=null;const he=new ht(0,0,0,0);return{setMask:function(me){$!==me&&!D&&(i.colorMask(me,me,me,me),$=me)},setLocked:function(me){D=me},setClear:function(me,j,be,Se,pt){pt===!0&&(me*=Se,j*=Se,be*=Se),ae.set(me,j,be,Se),he.equals(ae)===!1&&(i.clearColor(me,j,be,Se),he.copy(ae))},reset:function(){D=!1,$=null,he.set(-1,0,0,0)}}}function n(){let D=!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 Se=me;me=null,this.setClear(Se)}},getReversed:function(){return ae},setTest:function(j){j?ne(i.DEPTH_TEST):k(i.DEPTH_TEST)},setMask:function(j){$!==j&&!D&&(i.depthMask(j),$=j)},setFunc:function(j){if(ae&&(j=cp[j]),he!==j){switch(j){case Qo:i.depthFunc(i.NEVER);break;case jo:i.depthFunc(i.ALWAYS);break;case ec:i.depthFunc(i.LESS);break;case vs:i.depthFunc(i.LEQUAL);break;case tc:i.depthFunc(i.EQUAL);break;case nc:i.depthFunc(i.GEQUAL);break;case ic:i.depthFunc(i.GREATER);break;case sc:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}he=j}},setLocked:function(j){D=j},setClear:function(j){me!==j&&(me=j,ae&&(j=1-j),i.clearDepth(j))},reset:function(){D=!1,$=null,he=null,me=null,ae=!1}}}function s(){let D=!1,ae=null,$=null,he=null,me=null,j=null,be=null,Se=null,pt=null;return{setTest:function(at){D||(at?ne(i.STENCIL_TEST):k(i.STENCIL_TEST))},setMask:function(at){ae!==at&&!D&&(i.stencilMask(at),ae=at)},setFunc:function(at,mn,gn){($!==at||he!==mn||me!==gn)&&(i.stencilFunc(at,mn,gn),$=at,he=mn,me=gn)},setOp:function(at,mn,gn){(j!==at||be!==mn||Se!==gn)&&(i.stencilOp(at,mn,gn),j=at,be=mn,Se=gn)},setLocked:function(at){D=at},setClear:function(at){pt!==at&&(i.clearStencil(at),pt=at)},reset:function(){D=!1,ae=null,$=null,he=null,me=null,j=null,be=null,Se=null,pt=null}}}const r=new t,a=new n,o=new s,c=new WeakMap,l=new WeakMap;let h={},d={},u={},p=new WeakMap,g=[],x=null,m=!1,f=null,A=null,w=null,M=null,y=null,b=null,R=null,v=new xe(0,0,0),E=0,P=!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),rt=new ht().fromArray(ge),We=new ht().fromArray(Ve);function Z(D,ae,$,he){const me=new Uint8Array(4),j=i.createTexture();i.bindTexture(D,j),i.texParameteri(D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(D,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let be=0;be<$;be++)D===i.TEXTURE_3D||D===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(vs),Ze(!1),$e(sh),ne(i.CULL_FACE),Ie(Gn);function ne(D){h[D]!==!0&&(i.enable(D),h[D]=!0)}function k(D){h[D]!==!1&&(i.disable(D),h[D]=!1)}function Pe(D,ae){return u[D]!==ae?(i.bindFramebuffer(D,ae),u[D]=ae,D===i.DRAW_FRAMEBUFFER&&(u[i.FRAMEBUFFER]=ae),D===i.FRAMEBUFFER&&(u[i.DRAW_FRAMEBUFFER]=ae),!0):!1}function De(D,ae){let $=g,he=!1;if(D){$=p.get(ae),$===void 0&&($=[],p.set(ae,$));const me=D.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(D){return x!==D?(i.useProgram(D),x=D,!0):!1}const Me={[Ei]:i.FUNC_ADD,[Df]:i.FUNC_SUBTRACT,[If]:i.FUNC_REVERSE_SUBTRACT};Me[Lf]=i.MIN,Me[Nf]=i.MAX;const Ue={[Uf]:i.ZERO,[Ff]:i.ONE,[Of]:i.SRC_COLOR,[$o]:i.SRC_ALPHA,[Vf]:i.SRC_ALPHA_SATURATE,[Gf]:i.DST_COLOR,[Bf]:i.DST_ALPHA,[zf]:i.ONE_MINUS_SRC_COLOR,[Jo]:i.ONE_MINUS_SRC_ALPHA,[Hf]:i.ONE_MINUS_DST_COLOR,[kf]:i.ONE_MINUS_DST_ALPHA,[Wf]:i.CONSTANT_COLOR,[Xf]:i.ONE_MINUS_CONSTANT_COLOR,[qf]:i.CONSTANT_ALPHA,[Yf]:i.ONE_MINUS_CONSTANT_ALPHA};function Ie(D,ae,$,he,me,j,be,Se,pt,at){if(D===Gn){m===!0&&(k(i.BLEND),m=!1);return}if(m===!1&&(ne(i.BLEND),m=!0),D!==Pf){if(D!==f||at!==P){if((A!==Ei||y!==Ei)&&(i.blendEquation(i.FUNC_ADD),A=Ei,y=Ei),at)switch(D){case ds:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case nr:i.blendFunc(i.ONE,i.ONE);break;case rh:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case ah:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:Xe("WebGLState: Invalid blending: ",D);break}else switch(D){case ds:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case nr:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case rh:Xe("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case ah:Xe("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Xe("WebGLState: Invalid blending: ",D);break}w=null,M=null,b=null,R=null,v.set(0,0,0),E=0,f=D,P=at}return}me=me||ae,j=j||$,be=be||he,(ae!==A||me!==y)&&(i.blendEquationSeparate(Me[ae],Me[me]),A=ae,y=me),($!==w||he!==M||j!==b||be!==R)&&(i.blendFuncSeparate(Ue[$],Ue[he],Ue[j],Ue[be]),w=$,M=he,b=j,R=be),(Se.equals(v)===!1||pt!==E)&&(i.blendColor(Se.r,Se.g,Se.b,pt),v.copy(Se),E=pt),f=D,P=!1}function Le(D,ae){D.side===zn?k(i.CULL_FACE):ne(i.CULL_FACE);let $=D.side===Pt;ae&&($=!$),Ze($),D.blending===ds&&D.transparent===!1?Ie(Gn):Ie(D.blending,D.blendEquation,D.blendSrc,D.blendDst,D.blendEquationAlpha,D.blendSrcAlpha,D.blendDstAlpha,D.blendColor,D.blendAlpha,D.premultipliedAlpha),a.setFunc(D.depthFunc),a.setTest(D.depthTest),a.setMask(D.depthWrite),r.setMask(D.colorWrite);const he=D.stencilWrite;o.setTest(he),he&&(o.setMask(D.stencilWriteMask),o.setFunc(D.stencilFunc,D.stencilRef,D.stencilFuncMask),o.setOp(D.stencilFail,D.stencilZFail,D.stencilZPass)),ct(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),D.alphaToCoverage===!0?ne(i.SAMPLE_ALPHA_TO_COVERAGE):k(i.SAMPLE_ALPHA_TO_COVERAGE)}function Ze(D){C!==D&&(D?i.frontFace(i.CW):i.frontFace(i.CCW),C=D)}function $e(D){D!==wf?(ne(i.CULL_FACE),D!==L&&(D===sh?i.cullFace(i.BACK):D===Rf?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):k(i.CULL_FACE),L=D}function dt(D){D!==X&&(V&&i.lineWidth(D),X=D)}function ct(D,ae,$){D?(ne(i.POLYGON_OFFSET_FILL),(q!==ae||F!==$)&&(q=ae,F=$,a.getReversed()&&(ae=-ae),i.polygonOffset(ae,$))):k(i.POLYGON_OFFSET_FILL)}function ft(D){D?ne(i.SCISSOR_TEST):k(i.SCISSOR_TEST)}function yt(D){D===void 0&&(D=i.TEXTURE0+W-1),ee!==D&&(i.activeTexture(D),ee=D)}function I(D,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!==D||he.texture!==ae)&&(ee!==$&&(i.activeTexture($),ee=$),i.bindTexture(D,ae||re[D]),he.type=D,he.texture=ae)}function Ht(){const D=se[ee];D!==void 0&&D.type!==void 0&&(i.bindTexture(D.type,null),D.type=void 0,D.texture=void 0)}function Je(){try{i.compressedTexImage2D(...arguments)}catch(D){Xe("WebGLState:",D)}}function T(){try{i.compressedTexImage3D(...arguments)}catch(D){Xe("WebGLState:",D)}}function _(){try{i.texSubImage2D(...arguments)}catch(D){Xe("WebGLState:",D)}}function O(){try{i.texSubImage3D(...arguments)}catch(D){Xe("WebGLState:",D)}}function G(){try{i.compressedTexSubImage2D(...arguments)}catch(D){Xe("WebGLState:",D)}}function Y(){try{i.compressedTexSubImage3D(...arguments)}catch(D){Xe("WebGLState:",D)}}function ie(){try{i.texStorage2D(...arguments)}catch(D){Xe("WebGLState:",D)}}function oe(){try{i.texStorage3D(...arguments)}catch(D){Xe("WebGLState:",D)}}function K(){try{i.texImage2D(...arguments)}catch(D){Xe("WebGLState:",D)}}function J(){try{i.texImage3D(...arguments)}catch(D){Xe("WebGLState:",D)}}function ce(D){return d[D]!==void 0?d[D]:i.getParameter(D)}function Te(D,ae){d[D]!==ae&&(i.pixelStorei(D,ae),d[D]=ae)}function ue(D){rt.equals(D)===!1&&(i.scissor(D.x,D.y,D.z,D.w),rt.copy(D))}function le(D){We.equals(D)===!1&&(i.viewport(D.x,D.y,D.z,D.w),We.copy(D))}function Ce(D,ae){let $=l.get(ae);$===void 0&&($=new WeakMap,l.set(ae,$));let he=$.get(D);he===void 0&&(he=i.getUniformBlockIndex(ae,D.name),$.set(D,he))}function Ne(D,ae){const he=l.get(ae).get(D);c.get(ae)!==he&&(i.uniformBlockBinding(ae,he,D.__bindingPointIndex),c.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={},d={},ee=null,se={},u={},p=new WeakMap,g=[],x=null,m=!1,f=null,A=null,w=null,M=null,y=null,b=null,R=null,v=new xe(0,0,0),E=0,P=!1,C=null,L=null,X=null,q=null,F=null,rt.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:Pe,drawBuffers:De,useProgram:Re,setBlending:Ie,setMaterial:Le,setFlipSided:Ze,setCullFace:$e,setLineWidth:dt,setPolygonOffset:ct,setScissorTest:ft,activeTexture:yt,bindTexture:I,unbindTexture:Ht,compressedTexImage2D:Je,compressedTexImage3D:T,texImage2D:K,texImage3D:J,pixelStorei:Te,getParameter:ce,updateUBOMapping:Ce,uniformBlockBinding:Ne,texStorage2D:ie,texStorage3D:oe,texSubImage2D:_,texSubImage3D:O,compressedTexSubImage2D:G,compressedTexSubImage3D:Y,scissor:ue,viewport:le,reset:Be}}function Nv(i,e,t,n,s,r,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Oe,h=new WeakMap,d=new Set;let u;const p=new WeakMap;let g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(T,_){return g?new OffscreenCanvas(T,_):Ma("canvas")}function m(T,_,O){let G=1;const Y=Je(T);if((Y.width>O||Y.height>O)&&(G=O/Math.max(Y.width,Y.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 ie=Math.floor(G*Y.width),oe=Math.floor(G*Y.height);u===void 0&&(u=x(ie,oe));const K=_?x(ie,oe):u;return K.width=ie,K.height=oe,K.getContext("2d").drawImage(T,0,0,ie,oe),Fe("WebGLRenderer: Texture has been resized from ("+Y.width+"x"+Y.height+") to ("+ie+"x"+oe+")."),K}else return"data"in T&&Fe("WebGLRenderer: Image in DataTexture is too big ("+Y.width+"x"+Y.height+")."),T;return T}function f(T){return T.generateMipmaps}function A(T){i.generateMipmap(T)}function w(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,_,O,G,Y,ie=!1){if(T!==null){if(i[T]!==void 0)return i[T];Fe("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let oe;G&&(oe=e.get("EXT_texture_norm16"),oe||Fe("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let K=_;if(_===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)),_===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)),_===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)),_===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)),_===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)),_===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)),_===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)),_===i.RGBA){const J=ie?xa:qe.getTransfer(Y);O===i.FLOAT&&(K=i.RGBA32F),O===i.HALF_FLOAT&&(K=i.RGBA16F),O===i.UNSIGNED_BYTE&&(K=J===Qe?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 y(T,_){let O;return T?_===null||_===Pn||_===sr?O=i.DEPTH24_STENCIL8:_===wn?O=i.DEPTH32F_STENCIL8:_===ir&&(O=i.DEPTH24_STENCIL8,Fe("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):_===null||_===Pn||_===sr?O=i.DEPTH_COMPONENT24:_===wn?O=i.DEPTH_COMPONENT32F:_===ir&&(O=i.DEPTH_COMPONENT16),O}function b(T,_){return f(T)===!0||T.isFramebufferTexture&&T.minFilter!==Ct&&T.minFilter!==Ut?Math.log2(Math.max(_.width,_.height))+1:T.mipmaps!==void 0&&T.mipmaps.length>0?T.mipmaps.length:T.isCompressedTexture&&Array.isArray(T.image)?_.mipmaps.length:1}function R(T){const _=T.target;_.removeEventListener("dispose",R),E(_),_.isVideoTexture&&h.delete(_),_.isHTMLTexture&&d.delete(_)}function v(T){const _=T.target;_.removeEventListener("dispose",v),C(_)}function E(T){const _=n.get(T);if(_.__webglInit===void 0)return;const O=T.source,G=p.get(O);if(G){const Y=G[_.__cacheKey];Y.usedTimes--,Y.usedTimes===0&&P(T),Object.keys(G).length===0&&p.delete(O)}n.remove(T)}function P(T){const _=n.get(T);i.deleteTexture(_.__webglTexture);const O=T.source,G=p.get(O);delete G[_.__cacheKey],a.memory.textures--}function C(T){const _=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(_.__webglFramebuffer[G]))for(let Y=0;Y<_.__webglFramebuffer[G].length;Y++)i.deleteFramebuffer(_.__webglFramebuffer[G][Y]);else i.deleteFramebuffer(_.__webglFramebuffer[G]);_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer[G])}else{if(Array.isArray(_.__webglFramebuffer))for(let G=0;G<_.__webglFramebuffer.length;G++)i.deleteFramebuffer(_.__webglFramebuffer[G]);else i.deleteFramebuffer(_.__webglFramebuffer);if(_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer),_.__webglMultisampledFramebuffer&&i.deleteFramebuffer(_.__webglMultisampledFramebuffer),_.__webglColorRenderbuffer)for(let G=0;G<_.__webglColorRenderbuffer.length;G++)_.__webglColorRenderbuffer[G]&&i.deleteRenderbuffer(_.__webglColorRenderbuffer[G]);_.__webglDepthRenderbuffer&&i.deleteRenderbuffer(_.__webglDepthRenderbuffer)}const O=T.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(T)}let L=0;function X(){L=0}function q(){return L}function F(T){L=T}function W(){const T=L;return T>=s.maxTextures&&Fe("WebGLTextures: Trying to use "+T+" texture units while this GPU supports only "+s.maxTextures),L+=1,T}function V(T){const _=[];return _.push(T.wrapS),_.push(T.wrapT),_.push(T.wrapR||0),_.push(T.magFilter),_.push(T.minFilter),_.push(T.anisotropy),_.push(T.internalFormat),_.push(T.format),_.push(T.type),_.push(T.generateMipmaps),_.push(T.premultiplyAlpha),_.push(T.flipY),_.push(T.unpackAlignment),_.push(T.colorSpace),_.join()}function Q(T,_){const O=n.get(T);if(T.isVideoTexture&&I(T),T.isRenderTargetTexture===!1&&T.isExternalTexture!==!0&&T.version>0&&O.__version!==T.version){const G=T.image;if(G===null)Fe("WebGLRenderer: Texture marked for update but no image data found.");else if(G.complete===!1)Fe("WebGLRenderer: Texture marked for update but image is incomplete");else{k(O,T,_);return}}else T.isExternalTexture&&(O.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,O.__webglTexture,i.TEXTURE0+_)}function te(T,_){const O=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&O.__version!==T.version){k(O,T,_);return}else T.isExternalTexture&&(O.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,O.__webglTexture,i.TEXTURE0+_)}function ee(T,_){const O=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&O.__version!==T.version){k(O,T,_);return}t.bindTexture(i.TEXTURE_3D,O.__webglTexture,i.TEXTURE0+_)}function se(T,_){const O=n.get(T);if(T.isCubeDepthTexture!==!0&&T.version>0&&O.__version!==T.version){Pe(O,T,_);return}t.bindTexture(i.TEXTURE_CUBE_MAP,O.__webglTexture,i.TEXTURE0+_)}const ge={[rc]:i.REPEAT,[Bn]:i.CLAMP_TO_EDGE,[ac]:i.MIRRORED_REPEAT},Ve={[Ct]:i.NEAREST,[$f]:i.NEAREST_MIPMAP_NEAREST,[vr]:i.NEAREST_MIPMAP_LINEAR,[Ut]:i.LINEAR,[Ya]:i.LINEAR_MIPMAP_NEAREST,[Ai]:i.LINEAR_MIPMAP_LINEAR},rt={[jf]:i.NEVER,[sp]:i.ALWAYS,[ep]:i.LESS,[yl]:i.LEQUAL,[tp]:i.EQUAL,[El]:i.GEQUAL,[np]:i.GREATER,[ip]:i.NOTEQUAL};function We(T,_){if(_.type===wn&&e.has("OES_texture_float_linear")===!1&&(_.magFilter===Ut||_.magFilter===Ya||_.magFilter===vr||_.magFilter===Ai||_.minFilter===Ut||_.minFilter===Ya||_.minFilter===vr||_.minFilter===Ai)&&Fe("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,ge[_.wrapS]),i.texParameteri(T,i.TEXTURE_WRAP_T,ge[_.wrapT]),(T===i.TEXTURE_3D||T===i.TEXTURE_2D_ARRAY)&&i.texParameteri(T,i.TEXTURE_WRAP_R,ge[_.wrapR]),i.texParameteri(T,i.TEXTURE_MAG_FILTER,Ve[_.magFilter]),i.texParameteri(T,i.TEXTURE_MIN_FILTER,Ve[_.minFilter]),_.compareFunction&&(i.texParameteri(T,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(T,i.TEXTURE_COMPARE_FUNC,rt[_.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(_.magFilter===Ct||_.minFilter!==vr&&_.minFilter!==Ai||_.type===wn&&e.has("OES_texture_float_linear")===!1)return;if(_.anisotropy>1||n.get(_).__currentAnisotropy){const O=e.get("EXT_texture_filter_anisotropic");i.texParameterf(T,O.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(_.anisotropy,s.getMaxAnisotropy())),n.get(_).__currentAnisotropy=_.anisotropy}}}function Z(T,_){let O=!1;T.__webglInit===void 0&&(T.__webglInit=!0,_.addEventListener("dispose",R));const G=_.source;let Y=p.get(G);Y===void 0&&(Y={},p.set(G,Y));const ie=V(_);if(ie!==T.__cacheKey){Y[ie]===void 0&&(Y[ie]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,O=!0),Y[ie].usedTimes++;const oe=Y[T.__cacheKey];oe!==void 0&&(Y[T.__cacheKey].usedTimes--,oe.usedTimes===0&&P(_)),T.__cacheKey=ie,T.__webglTexture=Y[ie].texture}return O}function re(T,_,O){return Math.floor(Math.floor(T/O)/_)}function ne(T,_,O,G){const ie=T.updateRanges;if(ie.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,_.width,_.height,O,G,_.data);else{ie.sort((Te,ue)=>Te.start-ue.start);let oe=0;for(let Te=1;Te<ie.length;Te++){const ue=ie[oe],le=ie[Te],Ce=ue.start+ue.count,Ne=re(le.start,_.width,4),Be=re(ue.start,_.width,4);le.start<=Ce+1&&Ne===Be&&re(le.start+le.count-1,_.width,4)===Ne?ue.count=Math.max(ue.count,le.start+le.count-ue.start):(++oe,ie[oe]=le)}ie.length=oe+1;const K=t.getParameter(i.UNPACK_ROW_LENGTH),J=t.getParameter(i.UNPACK_SKIP_PIXELS),ce=t.getParameter(i.UNPACK_SKIP_ROWS);t.pixelStorei(i.UNPACK_ROW_LENGTH,_.width);for(let Te=0,ue=ie.length;Te<ue;Te++){const le=ie[Te],Ce=Math.floor(le.start/4),Ne=Math.ceil(le.count/4),Be=Ce%_.width,D=Math.floor(Ce/_.width),ae=Ne,$=1;t.pixelStorei(i.UNPACK_SKIP_PIXELS,Be),t.pixelStorei(i.UNPACK_SKIP_ROWS,D),t.texSubImage2D(i.TEXTURE_2D,0,Be,D,ae,$,O,G,_.data)}T.clearUpdateRanges(),t.pixelStorei(i.UNPACK_ROW_LENGTH,K),t.pixelStorei(i.UNPACK_SKIP_PIXELS,J),t.pixelStorei(i.UNPACK_SKIP_ROWS,ce)}}function k(T,_,O){let G=i.TEXTURE_2D;(_.isDataArrayTexture||_.isCompressedArrayTexture)&&(G=i.TEXTURE_2D_ARRAY),_.isData3DTexture&&(G=i.TEXTURE_3D);const Y=Z(T,_),ie=_.source;t.bindTexture(G,T.__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"&&_.image instanceof ImageBitmap)===!1){const $=qe.getPrimaries(qe.workingColorSpace),he=_.colorSpace===oi?null:qe.getPrimaries(_.colorSpace),me=_.colorSpace===oi||$===he?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,_.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,me)}t.pixelStorei(i.UNPACK_ALIGNMENT,_.unpackAlignment);let J=m(_.image,!1,s.maxTextureSize);J=Ht(_,J);const ce=r.convert(_.format,_.colorSpace),Te=r.convert(_.type);let ue=M(_.internalFormat,ce,Te,_.normalized,_.colorSpace,_.isVideoTexture);We(G,_);let le;const Ce=_.mipmaps,Ne=_.isVideoTexture!==!0,Be=oe.__version===void 0||Y===!0,D=ie.dataReady,ae=b(_,J);if(_.isDepthTexture)ue=y(_.format===wi,_.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,ce,Te,null));else if(_.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;$++)le=Ce[$],Ne?D&&t.texSubImage2D(i.TEXTURE_2D,$,0,0,le.width,le.height,ce,Te,le.data):t.texImage2D(i.TEXTURE_2D,$,ue,le.width,le.height,0,ce,Te,le.data);_.generateMipmaps=!1}else Ne?(Be&&t.texStorage2D(i.TEXTURE_2D,ae,ue,J.width,J.height),D&&ne(_,J,ce,Te)):t.texImage2D(i.TEXTURE_2D,0,ue,J.width,J.height,0,ce,Te,J.data);else if(_.isCompressedTexture)if(_.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(le=Ce[$],_.format!==dn)if(ce!==null)if(Ne){if(D)if(_.layerUpdates.size>0){const me=Bh(le.width,le.height,_.format,_.type);for(const j of _.layerUpdates){const be=le.data.subarray(j*me/le.data.BYTES_PER_ELEMENT,(j+1)*me/le.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,$,0,0,j,le.width,le.height,1,ce,be)}_.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,$,0,0,0,le.width,le.height,J.depth,ce,le.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,$,ue,le.width,le.height,J.depth,0,le.data,0,0);else Fe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ne?D&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,$,0,0,0,le.width,le.height,J.depth,ce,Te,le.data):t.texImage3D(i.TEXTURE_2D_ARRAY,$,ue,le.width,le.height,J.depth,0,ce,Te,le.data)}else{Ne&&Be&&t.texStorage2D(i.TEXTURE_2D,ae,ue,Ce[0].width,Ce[0].height);for(let $=0,he=Ce.length;$<he;$++)le=Ce[$],_.format!==dn?ce!==null?Ne?D&&t.compressedTexSubImage2D(i.TEXTURE_2D,$,0,0,le.width,le.height,ce,le.data):t.compressedTexImage2D(i.TEXTURE_2D,$,ue,le.width,le.height,0,le.data):Fe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ne?D&&t.texSubImage2D(i.TEXTURE_2D,$,0,0,le.width,le.height,ce,Te,le.data):t.texImage2D(i.TEXTURE_2D,$,ue,le.width,le.height,0,ce,Te,le.data)}else if(_.isDataArrayTexture)if(Ne){if(Be&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ae,ue,J.width,J.height,J.depth),D)if(_.layerUpdates.size>0){const $=Bh(J.width,J.height,_.format,_.type);for(const he of _.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,ce,Te,me)}_.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,J.width,J.height,J.depth,ce,Te,J.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,ue,J.width,J.height,J.depth,0,ce,Te,J.data);else if(_.isData3DTexture)Ne?(Be&&t.texStorage3D(i.TEXTURE_3D,ae,ue,J.width,J.height,J.depth),D&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,J.width,J.height,J.depth,ce,Te,J.data)):t.texImage3D(i.TEXTURE_3D,0,ue,J.width,J.height,J.depth,0,ce,Te,J.data);else if(_.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,ce,Te,null),$>>=1,he>>=1}}else if(_.isHTMLTexture){if("texElementImage2D"in i){const $=i.canvas;if($.hasAttribute("layoutsubtree")||$.setAttribute("layoutsubtree","true"),J.parentNode!==$){$.appendChild(J),d.add(_),$.onpaint=he=>{const me=he.changedElements;for(const j of d)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 $=Je(Ce[0]);t.texStorage2D(i.TEXTURE_2D,ae,ue,$.width,$.height)}for(let $=0,he=Ce.length;$<he;$++)le=Ce[$],Ne?D&&t.texSubImage2D(i.TEXTURE_2D,$,0,0,ce,Te,le):t.texImage2D(i.TEXTURE_2D,$,ue,ce,Te,le);_.generateMipmaps=!1}else if(Ne){if(Be){const $=Je(J);t.texStorage2D(i.TEXTURE_2D,ae,ue,$.width,$.height)}D&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,ce,Te,J)}else t.texImage2D(i.TEXTURE_2D,0,ue,ce,Te,J);f(_)&&A(G),oe.__version=ie.version,_.onUpdate&&_.onUpdate(_)}T.__version=_.version}function Pe(T,_,O){if(_.image.length!==6)return;const G=Z(T,_),Y=_.source;t.bindTexture(i.TEXTURE_CUBE_MAP,T.__webglTexture,i.TEXTURE0+O);const ie=n.get(Y);if(Y.version!==ie.__version||G===!0){t.activeTexture(i.TEXTURE0+O);const oe=qe.getPrimaries(qe.workingColorSpace),K=_.colorSpace===oi?null:qe.getPrimaries(_.colorSpace),J=_.colorSpace===oi||oe===K?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,_.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),t.pixelStorei(i.UNPACK_ALIGNMENT,_.unpackAlignment),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,J);const ce=_.isCompressedTexture||_.image[0].isCompressedTexture,Te=_.image[0]&&_.image[0].isDataTexture,ue=[];for(let j=0;j<6;j++)!ce&&!Te?ue[j]=m(_.image[j],!0,s.maxCubemapSize):ue[j]=Te?_.image[j].image:_.image[j],ue[j]=Ht(_,ue[j]);const le=ue[0],Ce=r.convert(_.format,_.colorSpace),Ne=r.convert(_.type),Be=M(_.internalFormat,Ce,Ne,_.normalized,_.colorSpace),D=_.isVideoTexture!==!0,ae=ie.__version===void 0||G===!0,$=Y.dataReady;let he=b(_,le);We(i.TEXTURE_CUBE_MAP,_);let me;if(ce){D&&ae&&t.texStorage2D(i.TEXTURE_CUBE_MAP,he,Be,le.width,le.height);for(let j=0;j<6;j++){me=ue[j].mipmaps;for(let be=0;be<me.length;be++){const Se=me[be];_.format!==dn?Ce!==null?D?$&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,be,0,0,Se.width,Se.height,Ce,Se.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,be,Be,Se.width,Se.height,0,Se.data):Fe("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):D?$&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,be,0,0,Se.width,Se.height,Ce,Ne,Se.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,be,Be,Se.width,Se.height,0,Ce,Ne,Se.data)}}}else{if(me=_.mipmaps,D&&ae){me.length>0&&he++;const j=Je(ue[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,he,Be,j.width,j.height)}for(let j=0;j<6;j++)if(Te){D?$&&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 pt=me[be].image[j].image;D?$&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,be+1,0,0,pt.width,pt.height,Ce,Ne,pt.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,be+1,Be,pt.width,pt.height,0,Ce,Ne,pt.data)}}else{D?$&&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 Se=me[be];D?$&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,be+1,0,0,Ce,Ne,Se.image[j]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,be+1,Be,Ce,Ne,Se.image[j])}}}f(_)&&A(i.TEXTURE_CUBE_MAP),ie.__version=Y.version,_.onUpdate&&_.onUpdate(_)}T.__version=_.version}function De(T,_,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),ce=n.get(_),Te=n.get(O);if(Te.__renderTarget=_,!ce.__hasExternalTextures){const ue=Math.max(1,_.width>>ie),le=Math.max(1,_.height>>ie);Y===i.TEXTURE_3D||Y===i.TEXTURE_2D_ARRAY?t.texImage3D(Y,ie,J,ue,le,_.depth,0,oe,K,null):t.texImage2D(Y,ie,J,ue,le,0,oe,K,null)}t.bindFramebuffer(i.FRAMEBUFFER,T),yt(_)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,G,Y,Te.__webglTexture,0,ft(_)):(Y===i.TEXTURE_2D||Y>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&Y<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,G,Y,Te.__webglTexture,ie),t.bindFramebuffer(i.FRAMEBUFFER,null)}function Re(T,_,O){if(i.bindRenderbuffer(i.RENDERBUFFER,T),_.depthBuffer){const G=_.depthTexture,Y=G&&G.isDepthTexture?G.type:null,ie=y(_.stencilBuffer,Y),oe=_.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;yt(_)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ft(_),ie,_.width,_.height):O?i.renderbufferStorageMultisample(i.RENDERBUFFER,ft(_),ie,_.width,_.height):i.renderbufferStorage(i.RENDERBUFFER,ie,_.width,_.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,oe,i.RENDERBUFFER,T)}else{const G=_.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);yt(_)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ft(_),J,_.width,_.height):O?i.renderbufferStorageMultisample(i.RENDERBUFFER,ft(_),J,_.width,_.height):i.renderbufferStorage(i.RENDERBUFFER,J,_.width,_.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Me(T,_,O){const G=_.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(i.FRAMEBUFFER,T),!(_.depthTexture&&_.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const Y=n.get(_.depthTexture);if(Y.__renderTarget=_,(!Y.__webglTexture||_.depthTexture.image.width!==_.width||_.depthTexture.image.height!==_.height)&&(_.depthTexture.image.width=_.width,_.depthTexture.image.height=_.height,_.depthTexture.needsUpdate=!0),G){if(Y.__webglInit===void 0&&(Y.__webglInit=!0,_.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,_.depthTexture);const ce=r.convert(_.depthTexture.format),Te=r.convert(_.depthTexture.type);let ue;_.depthTexture.format===Wn?ue=i.DEPTH_COMPONENT24:_.depthTexture.format===wi&&(ue=i.DEPTH24_STENCIL8);for(let le=0;le<6;le++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,ue,_.width,_.height,0,ce,Te,null)}}else Q(_.depthTexture,0);const ie=Y.__webglTexture,oe=ft(_),K=G?i.TEXTURE_CUBE_MAP_POSITIVE_X+O:i.TEXTURE_2D,J=_.depthTexture.format===wi?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(_.depthTexture.format===Wn)yt(_)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,J,K,ie,0,oe):i.framebufferTexture2D(i.FRAMEBUFFER,J,K,ie,0);else if(_.depthTexture.format===wi)yt(_)?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(T){const _=n.get(T),O=T.isWebGLCubeRenderTarget===!0;if(_.__boundDepthTexture!==T.depthTexture){const G=T.depthTexture;if(_.__depthDisposeCallback&&_.__depthDisposeCallback(),G){const Y=()=>{delete _.__boundDepthTexture,delete _.__depthDisposeCallback,G.removeEventListener("dispose",Y)};G.addEventListener("dispose",Y),_.__depthDisposeCallback=Y}_.__boundDepthTexture=G}if(T.depthTexture&&!_.__autoAllocateDepthBuffer)if(O)for(let G=0;G<6;G++)Me(_.__webglFramebuffer[G],T,G);else{const G=T.texture.mipmaps;G&&G.length>0?Me(_.__webglFramebuffer[0],T,0):Me(_.__webglFramebuffer,T,0)}else if(O){_.__webglDepthbuffer=[];for(let G=0;G<6;G++)if(t.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer[G]),_.__webglDepthbuffer[G]===void 0)_.__webglDepthbuffer[G]=i.createRenderbuffer(),Re(_.__webglDepthbuffer[G],T,!1);else{const Y=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ie=_.__webglDepthbuffer[G];i.bindRenderbuffer(i.RENDERBUFFER,ie),i.framebufferRenderbuffer(i.FRAMEBUFFER,Y,i.RENDERBUFFER,ie)}}else{const G=T.texture.mipmaps;if(G&&G.length>0?t.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer),_.__webglDepthbuffer===void 0)_.__webglDepthbuffer=i.createRenderbuffer(),Re(_.__webglDepthbuffer,T,!1);else{const Y=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ie=_.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,ie),i.framebufferRenderbuffer(i.FRAMEBUFFER,Y,i.RENDERBUFFER,ie)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function Ie(T,_,O){const G=n.get(T);_!==void 0&&De(G.__webglFramebuffer,T,T.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),O!==void 0&&Ue(T)}function Le(T){const _=T.texture,O=n.get(T),G=n.get(_);T.addEventListener("dispose",v);const Y=T.textures,ie=T.isWebGLCubeRenderTarget===!0,oe=Y.length>1;if(oe||(G.__webglTexture===void 0&&(G.__webglTexture=i.createTexture()),G.__version=_.version,a.memory.textures++),ie){O.__webglFramebuffer=[];for(let K=0;K<6;K++)if(_.mipmaps&&_.mipmaps.length>0){O.__webglFramebuffer[K]=[];for(let J=0;J<_.mipmaps.length;J++)O.__webglFramebuffer[K][J]=i.createFramebuffer()}else O.__webglFramebuffer[K]=i.createFramebuffer()}else{if(_.mipmaps&&_.mipmaps.length>0){O.__webglFramebuffer=[];for(let K=0;K<_.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 ce=n.get(Y[K]);ce.__webglTexture===void 0&&(ce.__webglTexture=i.createTexture(),a.memory.textures++)}if(T.samples>0&&yt(T)===!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 ce=r.convert(J.format,J.colorSpace),Te=r.convert(J.type),ue=M(J.internalFormat,ce,Te,J.normalized,J.colorSpace,T.isXRRenderTarget===!0),le=ft(T);i.renderbufferStorageMultisample(i.RENDERBUFFER,le,ue,T.width,T.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+K,i.RENDERBUFFER,O.__webglColorRenderbuffer[K])}i.bindRenderbuffer(i.RENDERBUFFER,null),T.depthBuffer&&(O.__webglDepthRenderbuffer=i.createRenderbuffer(),Re(O.__webglDepthRenderbuffer,T,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(ie){t.bindTexture(i.TEXTURE_CUBE_MAP,G.__webglTexture),We(i.TEXTURE_CUBE_MAP,_);for(let K=0;K<6;K++)if(_.mipmaps&&_.mipmaps.length>0)for(let J=0;J<_.mipmaps.length;J++)De(O.__webglFramebuffer[K][J],T,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+K,J);else De(O.__webglFramebuffer[K],T,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+K,0);f(_)&&A(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(oe){for(let K=0,J=Y.length;K<J;K++){const ce=Y[K],Te=n.get(ce);let ue=i.TEXTURE_2D;(T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(ue=T.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(ue,Te.__webglTexture),We(ue,ce),De(O.__webglFramebuffer,T,ce,i.COLOR_ATTACHMENT0+K,ue,0),f(ce)&&A(ue)}t.unbindTexture()}else{let K=i.TEXTURE_2D;if((T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(K=T.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(K,G.__webglTexture),We(K,_),_.mipmaps&&_.mipmaps.length>0)for(let J=0;J<_.mipmaps.length;J++)De(O.__webglFramebuffer[J],T,_,i.COLOR_ATTACHMENT0,K,J);else De(O.__webglFramebuffer,T,_,i.COLOR_ATTACHMENT0,K,0);f(_)&&A(K),t.unbindTexture()}T.depthBuffer&&Ue(T)}function Ze(T){const _=T.textures;for(let O=0,G=_.length;O<G;O++){const Y=_[O];if(f(Y)){const ie=w(T),oe=n.get(Y).__webglTexture;t.bindTexture(ie,oe),A(ie),t.unbindTexture()}}}const $e=[],dt=[];function ct(T){if(T.samples>0){if(yt(T)===!1){const _=T.textures,O=T.width,G=T.height;let Y=i.COLOR_BUFFER_BIT;const ie=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,oe=n.get(T),K=_.length>1;if(K)for(let ce=0;ce<_.length;ce++)t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ce,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ce,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,oe.__webglMultisampledFramebuffer);const J=T.texture.mipmaps;J&&J.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,oe.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,oe.__webglFramebuffer);for(let ce=0;ce<_.length;ce++){if(T.resolveDepthBuffer&&(T.depthBuffer&&(Y|=i.DEPTH_BUFFER_BIT),T.stencilBuffer&&T.resolveStencilBuffer&&(Y|=i.STENCIL_BUFFER_BIT)),K){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,oe.__webglColorRenderbuffer[ce]);const Te=n.get(_[ce]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,Te,0)}i.blitFramebuffer(0,0,O,G,0,0,O,G,Y,i.NEAREST),c===!0&&($e.length=0,dt.length=0,$e.push(i.COLOR_ATTACHMENT0+ce),T.depthBuffer&&T.resolveDepthBuffer===!1&&($e.push(ie),dt.push(ie),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,dt)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,$e))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),K)for(let ce=0;ce<_.length;ce++){t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ce,i.RENDERBUFFER,oe.__webglColorRenderbuffer[ce]);const Te=n.get(_[ce]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ce,i.TEXTURE_2D,Te,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,oe.__webglMultisampledFramebuffer)}else if(T.depthBuffer&&T.resolveDepthBuffer===!1&&c){const _=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[_])}}}function ft(T){return Math.min(s.maxSamples,T.samples)}function yt(T){const _=n.get(T);return T.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&_.__useRenderToTexture!==!1}function I(T){const _=a.render.frame;h.get(T)!==_&&(h.set(T,_),T.update())}function Ht(T,_){const O=T.colorSpace,G=T.format,Y=T.type;return T.isCompressedTexture===!0||T.isVideoTexture===!0||O!==va&&O!==oi&&(qe.getTransfer(O)===Qe?(G!==dn||Y!==Zt)&&Fe("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Xe("WebGLTextures: Unsupported texture color space:",O)),_}function Je(T){return typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement?(l.width=T.naturalWidth||T.width,l.height=T.naturalHeight||T.height):typeof VideoFrame<"u"&&T instanceof VideoFrame?(l.width=T.displayWidth,l.height=T.displayHeight):(l.width=T.width,l.height=T.height),l}this.allocateTextureUnit=W,this.resetTextureUnits=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=Ze,this.updateMultisampleRenderTarget=ct,this.setupDepthRenderbuffer=Ue,this.setupFrameBufferTexture=De,this.useMultisampledRTT=yt,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Uv(i,e){function t(n,s=oi){let r;const a=qe.getTransfer(s);if(n===Zt)return i.UNSIGNED_BYTE;if(n===_l)return i.UNSIGNED_SHORT_4_4_4_4;if(n===vl)return i.UNSIGNED_SHORT_5_5_5_1;if(n===x0)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===M0)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===_0)return i.BYTE;if(n===v0)return i.SHORT;if(n===ir)return i.UNSIGNED_SHORT;if(n===gl)return i.INT;if(n===Pn)return i.UNSIGNED_INT;if(n===wn)return i.FLOAT;if(n===Vn)return i.HALF_FLOAT;if(n===S0)return i.ALPHA;if(n===y0)return i.RGB;if(n===dn)return i.RGBA;if(n===Wn)return i.DEPTH_COMPONENT;if(n===wi)return i.DEPTH_STENCIL;if(n===E0)return i.RED;if(n===xl)return i.RED_INTEGER;if(n===Di)return i.RG;if(n===Ml)return i.RG_INTEGER;if(n===Sl)return i.RGBA_INTEGER;if(n===la||n===ha||n===ua||n===da)if(a===Qe)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===la)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===ha)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===ua)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=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===la)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===ha)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===ua)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===da)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===oc||n===cc||n===lc||n===hc)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===oc)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===cc)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===lc)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===hc)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===uc||n===dc||n===fc||n===pc||n===mc||n===ga||n===gc)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===uc||n===dc)return a===Qe?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===fc)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===pc)return r.COMPRESSED_R11_EAC;if(n===mc)return r.COMPRESSED_SIGNED_R11_EAC;if(n===ga)return r.COMPRESSED_RG11_EAC;if(n===gc)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===_c||n===vc||n===xc||n===Mc||n===Sc||n===yc||n===Ec||n===bc||n===Tc||n===Ac||n===wc||n===Rc||n===Cc||n===Pc)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===_c)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===vc)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===xc)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Mc)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Sc)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===yc)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Ec)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===bc)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Tc)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Ac)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===wc)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Rc)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Cc)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Pc)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Dc||n===Ic||n===Lc)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===Dc)return a===Qe?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Ic)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Lc)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Nc||n===Uc||n===_a||n===Fc)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===Nc)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Uc)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===_a)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Fc)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:t}}const Fv=`
|
|
4391
|
+
}`,vv=[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)],xv=[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)],jh=new ot,Bs=new U,yo=new U;function Mv(i,e,t){let n=new yl;const s=new Fe,r=new Fe,a=new ut,o=new Cp,c=new Pp,l={},h=t.maxTextureSize,d={[di]:Dt,[Dt]:di,[An]:An},u=new Bt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Fe},radius:{value:4}},vertexShader:gv,fragmentShader:_v}),p=u.clone();p.defines.HORIZONTAL_PASS=1;const g=new yt;g.setAttribute("position",new lt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const M=new ht(g,u),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Qs;let f=this.type;this.render=function(b,R,v){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||b.length===0)return;this.type===xf&&(Oe("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Qs);const E=i.getRenderTarget(),P=i.getActiveCubeFace(),C=i.getActiveMipmapLevel(),L=i.state;L.setBlending(Gn),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===Xs){if(W.isPointLight){Oe("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}V.map=new pn(s.x,s.y,{format:Di,type:Vn,minFilter:Ft,magFilter:Ft,generateMipmaps:!1}),V.map.texture.name=W.name+".shadowMap",V.map.depthTexture=new ys(s.x,s.y,Rn),V.map.depthTexture.name=W.name+".shadowMapDepth",V.map.depthTexture.format=Wn,V.map.depthTexture.compareFunction=null,V.map.depthTexture.minFilter=Pt,V.map.depthTexture.magFilter=Pt}else W.isPointLight?(V.map=new D0(s.x),V.map.depthTexture=new Ep(s.x,Dn)):(V.map=new pn(s.x,s.y),V.map.depthTexture=new ys(s.x,s.y,Dn)),V.map.depthTexture.name=W.name+".shadowMap",V.map.depthTexture.format=Wn,this.type===Qs?(V.map.depthTexture.compareFunction=te?_l:gl,V.map.depthTexture.minFilter=Ft,V.map.depthTexture.magFilter=Ft):(V.map.depthTexture.compareFunction=null,V.map.depthTexture.minFilter=Pt,V.map.depthTexture.magFilter=Pt);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,st=W.distance||ge.far;st!==ge.far&&(ge.far=st,ge.updateProjectionMatrix()),Bs.setFromMatrixPosition(W.matrixWorld),ge.position.copy(Bs),yo.copy(ge.position),yo.add(vv[se]),ge.up.copy(xv[se]),ge.lookAt(yo),ge.updateMatrixWorld(),Ve.makeTranslation(-Bs.x,-Bs.y,-Bs.z),jh.multiplyMatrices(ge.projectionMatrix,ge.matrixWorldInverse),V._frustum.setFromProjectionMatrix(jh,ge.coordinateSystem,ge.reversedDepth)}else V.updateMatrices(W);n=V.getFrustum(),x(R,v,V.camera,W,this.type)}V.isPointLightShadow!==!0&&this.type===Xs&&T(V,v),V.needsUpdate=!1}f=this.type,m.needsUpdate=!1,i.setRenderTarget(E,P,C)};function T(b,R){const v=e.update(M);u.defines.VSM_SAMPLES!==b.blurSamples&&(u.defines.VSM_SAMPLES=b.blurSamples,p.defines.VSM_SAMPLES=b.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new pn(s.x,s.y,{format:Di,type:Vn})),u.uniforms.shadow_pass.value=b.map.depthTexture,u.uniforms.resolution.value=b.mapSize,u.uniforms.radius.value=b.radius,i.setRenderTarget(b.mapPass),i.clear(),i.renderBufferDirect(R,null,v,u,M,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,v,p,M,null)}function w(b,R,v,E){let P=null;const C=v.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(C!==void 0)P=C;else if(P=v.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 L=P.uuid,X=R.uuid;let q=l[L];q===void 0&&(q={},l[L]=q);let F=q[X];F===void 0&&(F=P.clone(),q[X]=F,R.addEventListener("dispose",y)),P=F}if(P.visible=R.visible,P.wireframe=R.wireframe,E===Xs?P.side=R.shadowSide!==null?R.shadowSide:R.side:P.side=R.shadowSide!==null?R.shadowSide:d[R.side],P.alphaMap=R.alphaMap,P.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,P.map=R.map,P.clipShadows=R.clipShadows,P.clippingPlanes=R.clippingPlanes,P.clipIntersection=R.clipIntersection,P.displacementMap=R.displacementMap,P.displacementScale=R.displacementScale,P.displacementBias=R.displacementBias,P.wireframeLinewidth=R.wireframeLinewidth,P.linewidth=R.linewidth,v.isPointLight===!0&&P.isMeshDistanceMaterial===!0){const L=i.properties.get(P);L.light=v}return P}function x(b,R,v,E,P){if(b.visible===!1)return;if(b.layers.test(R.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&P===Xs)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(v.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=w(b,te,E,P);b.onBeforeShadow(i,b,R,v,X,ee,Q),i.renderBufferDirect(v,null,X,ee,b,Q),b.onAfterShadow(i,b,R,v,X,ee,Q)}}}else if(q.visible){const F=w(b,q,E,P);b.onBeforeShadow(i,b,R,v,X,F,null),i.renderBufferDirect(v,null,X,F,b,null),b.onAfterShadow(i,b,R,v,X,F,null)}}const L=b.children;for(let X=0,q=L.length;X<q;X++)x(L[X],R,v,E,P)}function y(b){b.target.removeEventListener("dispose",y);for(const v in l){const E=l[v],P=b.target.uuid;P in E&&(E[P].dispose(),delete E[P])}}}function Sv(i,e){function t(){let D=!1;const ae=new ut;let $=null;const he=new ut(0,0,0,0);return{setMask:function(me){$!==me&&!D&&(i.colorMask(me,me,me,me),$=me)},setLocked:function(me){D=me},setClear:function(me,j,be,Se,pt){pt===!0&&(me*=Se,j*=Se,be*=Se),ae.set(me,j,be,Se),he.equals(ae)===!1&&(i.clearColor(me,j,be,Se),he.copy(ae))},reset:function(){D=!1,$=null,he.set(-1,0,0,0)}}}function n(){let D=!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 Se=me;me=null,this.setClear(Se)}},getReversed:function(){return ae},setTest:function(j){j?ne(i.DEPTH_TEST):k(i.DEPTH_TEST)},setMask:function(j){$!==j&&!D&&(i.depthMask(j),$=j)},setFunc:function(j){if(ae&&(j=Qf[j]),he!==j){switch(j){case qo:i.depthFunc(i.NEVER);break;case Yo:i.depthFunc(i.ALWAYS);break;case Ko:i.depthFunc(i.LESS);break;case xs:i.depthFunc(i.LEQUAL);break;case Zo:i.depthFunc(i.EQUAL);break;case $o:i.depthFunc(i.GEQUAL);break;case Jo:i.depthFunc(i.GREATER);break;case Qo:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}he=j}},setLocked:function(j){D=j},setClear:function(j){me!==j&&(me=j,ae&&(j=1-j),i.clearDepth(j))},reset:function(){D=!1,$=null,he=null,me=null,ae=!1}}}function s(){let D=!1,ae=null,$=null,he=null,me=null,j=null,be=null,Se=null,pt=null;return{setTest:function(rt){D||(rt?ne(i.STENCIL_TEST):k(i.STENCIL_TEST))},setMask:function(rt){ae!==rt&&!D&&(i.stencilMask(rt),ae=rt)},setFunc:function(rt,mn,gn){($!==rt||he!==mn||me!==gn)&&(i.stencilFunc(rt,mn,gn),$=rt,he=mn,me=gn)},setOp:function(rt,mn,gn){(j!==rt||be!==mn||Se!==gn)&&(i.stencilOp(rt,mn,gn),j=rt,be=mn,Se=gn)},setLocked:function(rt){D=rt},setClear:function(rt){pt!==rt&&(i.clearStencil(rt),pt=rt)},reset:function(){D=!1,ae=null,$=null,he=null,me=null,j=null,be=null,Se=null,pt=null}}}const r=new t,a=new n,o=new s,c=new WeakMap,l=new WeakMap;let h={},d={},u={},p=new WeakMap,g=[],M=null,m=!1,f=null,T=null,w=null,x=null,y=null,b=null,R=null,v=new Me(0,0,0),E=0,P=!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),st=new ut().fromArray(ge),We=new ut().fromArray(Ve);function Z(D,ae,$,he){const me=new Uint8Array(4),j=i.createTexture();i.bindTexture(D,j),i.texParameteri(D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(D,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let be=0;be<$;be++)D===i.TEXTURE_3D||D===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(xs),Ze(!1),$e(jl),ne(i.CULL_FACE),Ie(Gn);function ne(D){h[D]!==!0&&(i.enable(D),h[D]=!0)}function k(D){h[D]!==!1&&(i.disable(D),h[D]=!1)}function Pe(D,ae){return u[D]!==ae?(i.bindFramebuffer(D,ae),u[D]=ae,D===i.DRAW_FRAMEBUFFER&&(u[i.FRAMEBUFFER]=ae),D===i.FRAMEBUFFER&&(u[i.DRAW_FRAMEBUFFER]=ae),!0):!1}function De(D,ae){let $=g,he=!1;if(D){$=p.get(ae),$===void 0&&($=[],p.set(ae,$));const me=D.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(D){return M!==D?(i.useProgram(D),M=D,!0):!1}const xe={[yi]:i.FUNC_ADD,[Sf]:i.FUNC_SUBTRACT,[yf]:i.FUNC_REVERSE_SUBTRACT};xe[Ef]=i.MIN,xe[bf]=i.MAX;const Ue={[Tf]:i.ZERO,[Af]:i.ONE,[wf]:i.SRC_COLOR,[Wo]:i.SRC_ALPHA,[Lf]:i.SRC_ALPHA_SATURATE,[Df]:i.DST_COLOR,[Cf]:i.DST_ALPHA,[Rf]:i.ONE_MINUS_SRC_COLOR,[Xo]:i.ONE_MINUS_SRC_ALPHA,[If]:i.ONE_MINUS_DST_COLOR,[Pf]:i.ONE_MINUS_DST_ALPHA,[Nf]:i.CONSTANT_COLOR,[Uf]:i.ONE_MINUS_CONSTANT_COLOR,[Ff]:i.CONSTANT_ALPHA,[Of]:i.ONE_MINUS_CONSTANT_ALPHA};function Ie(D,ae,$,he,me,j,be,Se,pt,rt){if(D===Gn){m===!0&&(k(i.BLEND),m=!1);return}if(m===!1&&(ne(i.BLEND),m=!0),D!==Mf){if(D!==f||rt!==P){if((T!==yi||y!==yi)&&(i.blendEquation(i.FUNC_ADD),T=yi,y=yi),rt)switch(D){case fs:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case ir:i.blendFunc(i.ONE,i.ONE);break;case eh:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case th:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:Xe("WebGLState: Invalid blending: ",D);break}else switch(D){case fs:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case ir:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case eh:Xe("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case th:Xe("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Xe("WebGLState: Invalid blending: ",D);break}w=null,x=null,b=null,R=null,v.set(0,0,0),E=0,f=D,P=rt}return}me=me||ae,j=j||$,be=be||he,(ae!==T||me!==y)&&(i.blendEquationSeparate(xe[ae],xe[me]),T=ae,y=me),($!==w||he!==x||j!==b||be!==R)&&(i.blendFuncSeparate(Ue[$],Ue[he],Ue[j],Ue[be]),w=$,x=he,b=j,R=be),(Se.equals(v)===!1||pt!==E)&&(i.blendColor(Se.r,Se.g,Se.b,pt),v.copy(Se),E=pt),f=D,P=!1}function Le(D,ae){D.side===An?k(i.CULL_FACE):ne(i.CULL_FACE);let $=D.side===Dt;ae&&($=!$),Ze($),D.blending===fs&&D.transparent===!1?Ie(Gn):Ie(D.blending,D.blendEquation,D.blendSrc,D.blendDst,D.blendEquationAlpha,D.blendSrcAlpha,D.blendDstAlpha,D.blendColor,D.blendAlpha,D.premultipliedAlpha),a.setFunc(D.depthFunc),a.setTest(D.depthTest),a.setMask(D.depthWrite),r.setMask(D.colorWrite);const he=D.stencilWrite;o.setTest(he),he&&(o.setMask(D.stencilWriteMask),o.setFunc(D.stencilFunc,D.stencilRef,D.stencilFuncMask),o.setOp(D.stencilFail,D.stencilZFail,D.stencilZPass)),ct(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),D.alphaToCoverage===!0?ne(i.SAMPLE_ALPHA_TO_COVERAGE):k(i.SAMPLE_ALPHA_TO_COVERAGE)}function Ze(D){C!==D&&(D?i.frontFace(i.CW):i.frontFace(i.CCW),C=D)}function $e(D){D!==_f?(ne(i.CULL_FACE),D!==L&&(D===jl?i.cullFace(i.BACK):D===vf?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):k(i.CULL_FACE),L=D}function dt(D){D!==X&&(V&&i.lineWidth(D),X=D)}function ct(D,ae,$){D?(ne(i.POLYGON_OFFSET_FILL),(q!==ae||F!==$)&&(q=ae,F=$,a.getReversed()&&(ae=-ae),i.polygonOffset(ae,$))):k(i.POLYGON_OFFSET_FILL)}function ft(D){D?ne(i.SCISSOR_TEST):k(i.SCISSOR_TEST)}function xt(D){D===void 0&&(D=i.TEXTURE0+W-1),ee!==D&&(i.activeTexture(D),ee=D)}function I(D,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!==D||he.texture!==ae)&&(ee!==$&&(i.activeTexture($),ee=$),i.bindTexture(D,ae||re[D]),he.type=D,he.texture=ae)}function Vt(){const D=se[ee];D!==void 0&&D.type!==void 0&&(i.bindTexture(D.type,null),D.type=void 0,D.texture=void 0)}function Je(){try{i.compressedTexImage2D(...arguments)}catch(D){Xe("WebGLState:",D)}}function A(){try{i.compressedTexImage3D(...arguments)}catch(D){Xe("WebGLState:",D)}}function _(){try{i.texSubImage2D(...arguments)}catch(D){Xe("WebGLState:",D)}}function O(){try{i.texSubImage3D(...arguments)}catch(D){Xe("WebGLState:",D)}}function G(){try{i.compressedTexSubImage2D(...arguments)}catch(D){Xe("WebGLState:",D)}}function Y(){try{i.compressedTexSubImage3D(...arguments)}catch(D){Xe("WebGLState:",D)}}function ie(){try{i.texStorage2D(...arguments)}catch(D){Xe("WebGLState:",D)}}function oe(){try{i.texStorage3D(...arguments)}catch(D){Xe("WebGLState:",D)}}function K(){try{i.texImage2D(...arguments)}catch(D){Xe("WebGLState:",D)}}function J(){try{i.texImage3D(...arguments)}catch(D){Xe("WebGLState:",D)}}function ce(D){return d[D]!==void 0?d[D]:i.getParameter(D)}function Te(D,ae){d[D]!==ae&&(i.pixelStorei(D,ae),d[D]=ae)}function ue(D){st.equals(D)===!1&&(i.scissor(D.x,D.y,D.z,D.w),st.copy(D))}function le(D){We.equals(D)===!1&&(i.viewport(D.x,D.y,D.z,D.w),We.copy(D))}function Ce(D,ae){let $=l.get(ae);$===void 0&&($=new WeakMap,l.set(ae,$));let he=$.get(D);he===void 0&&(he=i.getUniformBlockIndex(ae,D.name),$.set(D,he))}function Ne(D,ae){const he=l.get(ae).get(D);c.get(ae)!==he&&(i.uniformBlockBinding(ae,he,D.__bindingPointIndex),c.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={},d={},ee=null,se={},u={},p=new WeakMap,g=[],M=null,m=!1,f=null,T=null,w=null,x=null,y=null,b=null,R=null,v=new Me(0,0,0),E=0,P=!1,C=null,L=null,X=null,q=null,F=null,st.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:Pe,drawBuffers:De,useProgram:Re,setBlending:Ie,setMaterial:Le,setFlipSided:Ze,setCullFace:$e,setLineWidth:dt,setPolygonOffset:ct,setScissorTest:ft,activeTexture:xt,bindTexture:I,unbindTexture:Vt,compressedTexImage2D:Je,compressedTexImage3D:A,texImage2D:K,texImage3D:J,pixelStorei:Te,getParameter:ce,updateUBOMapping:Ce,uniformBlockBinding:Ne,texStorage2D:ie,texStorage3D:oe,texSubImage2D:_,texSubImage3D:O,compressedTexSubImage2D:G,compressedTexSubImage3D:Y,scissor:ue,viewport:le,reset:Be}}function yv(i,e,t,n,s,r,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Fe,h=new WeakMap,d=new Set;let u;const p=new WeakMap;let g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function M(A,_){return g?new OffscreenCanvas(A,_):_a("canvas")}function m(A,_,O){let G=1;const Y=Je(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);u===void 0&&(u=M(ie,oe));const K=_?M(ie,oe):u;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 T(A){i.generateMipmap(A)}function w(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 x(A,_,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=_;if(_===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)),_===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)),_===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)),_===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)),_===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)),_===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)),_===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)),_===i.RGBA){const J=ie?ga:qe.getTransfer(Y);O===i.FLOAT&&(K=i.RGBA32F),O===i.HALF_FLOAT&&(K=i.RGBA16F),O===i.UNSIGNED_BYTE&&(K=J===Qe?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 y(A,_){let O;return A?_===null||_===Dn||_===rr?O=i.DEPTH24_STENCIL8:_===Rn?O=i.DEPTH32F_STENCIL8:_===sr&&(O=i.DEPTH24_STENCIL8,Oe("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):_===null||_===Dn||_===rr?O=i.DEPTH_COMPONENT24:_===Rn?O=i.DEPTH_COMPONENT32F:_===sr&&(O=i.DEPTH_COMPONENT16),O}function b(A,_){return f(A)===!0||A.isFramebufferTexture&&A.minFilter!==Pt&&A.minFilter!==Ft?Math.log2(Math.max(_.width,_.height))+1:A.mipmaps!==void 0&&A.mipmaps.length>0?A.mipmaps.length:A.isCompressedTexture&&Array.isArray(A.image)?_.mipmaps.length:1}function R(A){const _=A.target;_.removeEventListener("dispose",R),E(_),_.isVideoTexture&&h.delete(_),_.isHTMLTexture&&d.delete(_)}function v(A){const _=A.target;_.removeEventListener("dispose",v),C(_)}function E(A){const _=n.get(A);if(_.__webglInit===void 0)return;const O=A.source,G=p.get(O);if(G){const Y=G[_.__cacheKey];Y.usedTimes--,Y.usedTimes===0&&P(A),Object.keys(G).length===0&&p.delete(O)}n.remove(A)}function P(A){const _=n.get(A);i.deleteTexture(_.__webglTexture);const O=A.source,G=p.get(O);delete G[_.__cacheKey],a.memory.textures--}function C(A){const _=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(_.__webglFramebuffer[G]))for(let Y=0;Y<_.__webglFramebuffer[G].length;Y++)i.deleteFramebuffer(_.__webglFramebuffer[G][Y]);else i.deleteFramebuffer(_.__webglFramebuffer[G]);_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer[G])}else{if(Array.isArray(_.__webglFramebuffer))for(let G=0;G<_.__webglFramebuffer.length;G++)i.deleteFramebuffer(_.__webglFramebuffer[G]);else i.deleteFramebuffer(_.__webglFramebuffer);if(_.__webglDepthbuffer&&i.deleteRenderbuffer(_.__webglDepthbuffer),_.__webglMultisampledFramebuffer&&i.deleteFramebuffer(_.__webglMultisampledFramebuffer),_.__webglColorRenderbuffer)for(let G=0;G<_.__webglColorRenderbuffer.length;G++)_.__webglColorRenderbuffer[G]&&i.deleteRenderbuffer(_.__webglColorRenderbuffer[G]);_.__webglDepthRenderbuffer&&i.deleteRenderbuffer(_.__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 _=[];return _.push(A.wrapS),_.push(A.wrapT),_.push(A.wrapR||0),_.push(A.magFilter),_.push(A.minFilter),_.push(A.anisotropy),_.push(A.internalFormat),_.push(A.format),_.push(A.type),_.push(A.generateMipmaps),_.push(A.premultiplyAlpha),_.push(A.flipY),_.push(A.unpackAlignment),_.push(A.colorSpace),_.join()}function Q(A,_){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,_);return}}else A.isExternalTexture&&(O.__webglTexture=A.sourceTexture?A.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,O.__webglTexture,i.TEXTURE0+_)}function te(A,_){const O=n.get(A);if(A.isRenderTargetTexture===!1&&A.version>0&&O.__version!==A.version){k(O,A,_);return}else A.isExternalTexture&&(O.__webglTexture=A.sourceTexture?A.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,O.__webglTexture,i.TEXTURE0+_)}function ee(A,_){const O=n.get(A);if(A.isRenderTargetTexture===!1&&A.version>0&&O.__version!==A.version){k(O,A,_);return}t.bindTexture(i.TEXTURE_3D,O.__webglTexture,i.TEXTURE0+_)}function se(A,_){const O=n.get(A);if(A.isCubeDepthTexture!==!0&&A.version>0&&O.__version!==A.version){Pe(O,A,_);return}t.bindTexture(i.TEXTURE_CUBE_MAP,O.__webglTexture,i.TEXTURE0+_)}const ge={[jo]:i.REPEAT,[Bn]:i.CLAMP_TO_EDGE,[ec]:i.MIRRORED_REPEAT},Ve={[Pt]:i.NEAREST,[kf]:i.NEAREST_MIPMAP_NEAREST,[_r]:i.NEAREST_MIPMAP_LINEAR,[Ft]:i.LINEAR,[Ha]:i.LINEAR_MIPMAP_NEAREST,[Ai]:i.LINEAR_MIPMAP_LINEAR},st={[Vf]:i.NEVER,[Kf]:i.ALWAYS,[Wf]:i.LESS,[gl]:i.LEQUAL,[Xf]:i.EQUAL,[_l]:i.GEQUAL,[qf]:i.GREATER,[Yf]:i.NOTEQUAL};function We(A,_){if(_.type===Rn&&e.has("OES_texture_float_linear")===!1&&(_.magFilter===Ft||_.magFilter===Ha||_.magFilter===_r||_.magFilter===Ai||_.minFilter===Ft||_.minFilter===Ha||_.minFilter===_r||_.minFilter===Ai)&&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[_.wrapS]),i.texParameteri(A,i.TEXTURE_WRAP_T,ge[_.wrapT]),(A===i.TEXTURE_3D||A===i.TEXTURE_2D_ARRAY)&&i.texParameteri(A,i.TEXTURE_WRAP_R,ge[_.wrapR]),i.texParameteri(A,i.TEXTURE_MAG_FILTER,Ve[_.magFilter]),i.texParameteri(A,i.TEXTURE_MIN_FILTER,Ve[_.minFilter]),_.compareFunction&&(i.texParameteri(A,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(A,i.TEXTURE_COMPARE_FUNC,st[_.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(_.magFilter===Pt||_.minFilter!==_r&&_.minFilter!==Ai||_.type===Rn&&e.has("OES_texture_float_linear")===!1)return;if(_.anisotropy>1||n.get(_).__currentAnisotropy){const O=e.get("EXT_texture_filter_anisotropic");i.texParameterf(A,O.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(_.anisotropy,s.getMaxAnisotropy())),n.get(_).__currentAnisotropy=_.anisotropy}}}function Z(A,_){let O=!1;A.__webglInit===void 0&&(A.__webglInit=!0,_.addEventListener("dispose",R));const G=_.source;let Y=p.get(G);Y===void 0&&(Y={},p.set(G,Y));const ie=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&&P(_)),A.__cacheKey=ie,A.__webglTexture=Y[ie].texture}return O}function re(A,_,O){return Math.floor(Math.floor(A/O)/_)}function ne(A,_,O,G){const ie=A.updateRanges;if(ie.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,_.width,_.height,O,G,_.data);else{ie.sort((Te,ue)=>Te.start-ue.start);let oe=0;for(let Te=1;Te<ie.length;Te++){const ue=ie[oe],le=ie[Te],Ce=ue.start+ue.count,Ne=re(le.start,_.width,4),Be=re(ue.start,_.width,4);le.start<=Ce+1&&Ne===Be&&re(le.start+le.count-1,_.width,4)===Ne?ue.count=Math.max(ue.count,le.start+le.count-ue.start):(++oe,ie[oe]=le)}ie.length=oe+1;const K=t.getParameter(i.UNPACK_ROW_LENGTH),J=t.getParameter(i.UNPACK_SKIP_PIXELS),ce=t.getParameter(i.UNPACK_SKIP_ROWS);t.pixelStorei(i.UNPACK_ROW_LENGTH,_.width);for(let Te=0,ue=ie.length;Te<ue;Te++){const le=ie[Te],Ce=Math.floor(le.start/4),Ne=Math.ceil(le.count/4),Be=Ce%_.width,D=Math.floor(Ce/_.width),ae=Ne,$=1;t.pixelStorei(i.UNPACK_SKIP_PIXELS,Be),t.pixelStorei(i.UNPACK_SKIP_ROWS,D),t.texSubImage2D(i.TEXTURE_2D,0,Be,D,ae,$,O,G,_.data)}A.clearUpdateRanges(),t.pixelStorei(i.UNPACK_ROW_LENGTH,K),t.pixelStorei(i.UNPACK_SKIP_PIXELS,J),t.pixelStorei(i.UNPACK_SKIP_ROWS,ce)}}function k(A,_,O){let G=i.TEXTURE_2D;(_.isDataArrayTexture||_.isCompressedArrayTexture)&&(G=i.TEXTURE_2D_ARRAY),_.isData3DTexture&&(G=i.TEXTURE_3D);const Y=Z(A,_),ie=_.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"&&_.image instanceof ImageBitmap)===!1){const $=qe.getPrimaries(qe.workingColorSpace),he=_.colorSpace===oi?null:qe.getPrimaries(_.colorSpace),me=_.colorSpace===oi||$===he?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,_.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,me)}t.pixelStorei(i.UNPACK_ALIGNMENT,_.unpackAlignment);let J=m(_.image,!1,s.maxTextureSize);J=Vt(_,J);const ce=r.convert(_.format,_.colorSpace),Te=r.convert(_.type);let ue=x(_.internalFormat,ce,Te,_.normalized,_.colorSpace,_.isVideoTexture);We(G,_);let le;const Ce=_.mipmaps,Ne=_.isVideoTexture!==!0,Be=oe.__version===void 0||Y===!0,D=ie.dataReady,ae=b(_,J);if(_.isDepthTexture)ue=y(_.format===wi,_.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,ce,Te,null));else if(_.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;$++)le=Ce[$],Ne?D&&t.texSubImage2D(i.TEXTURE_2D,$,0,0,le.width,le.height,ce,Te,le.data):t.texImage2D(i.TEXTURE_2D,$,ue,le.width,le.height,0,ce,Te,le.data);_.generateMipmaps=!1}else Ne?(Be&&t.texStorage2D(i.TEXTURE_2D,ae,ue,J.width,J.height),D&&ne(_,J,ce,Te)):t.texImage2D(i.TEXTURE_2D,0,ue,J.width,J.height,0,ce,Te,J.data);else if(_.isCompressedTexture)if(_.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(le=Ce[$],_.format!==dn)if(ce!==null)if(Ne){if(D)if(_.layerUpdates.size>0){const me=Ph(le.width,le.height,_.format,_.type);for(const j of _.layerUpdates){const be=le.data.subarray(j*me/le.data.BYTES_PER_ELEMENT,(j+1)*me/le.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,$,0,0,j,le.width,le.height,1,ce,be)}_.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,$,0,0,0,le.width,le.height,J.depth,ce,le.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,$,ue,le.width,le.height,J.depth,0,le.data,0,0);else Oe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ne?D&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,$,0,0,0,le.width,le.height,J.depth,ce,Te,le.data):t.texImage3D(i.TEXTURE_2D_ARRAY,$,ue,le.width,le.height,J.depth,0,ce,Te,le.data)}else{Ne&&Be&&t.texStorage2D(i.TEXTURE_2D,ae,ue,Ce[0].width,Ce[0].height);for(let $=0,he=Ce.length;$<he;$++)le=Ce[$],_.format!==dn?ce!==null?Ne?D&&t.compressedTexSubImage2D(i.TEXTURE_2D,$,0,0,le.width,le.height,ce,le.data):t.compressedTexImage2D(i.TEXTURE_2D,$,ue,le.width,le.height,0,le.data):Oe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ne?D&&t.texSubImage2D(i.TEXTURE_2D,$,0,0,le.width,le.height,ce,Te,le.data):t.texImage2D(i.TEXTURE_2D,$,ue,le.width,le.height,0,ce,Te,le.data)}else if(_.isDataArrayTexture)if(Ne){if(Be&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ae,ue,J.width,J.height,J.depth),D)if(_.layerUpdates.size>0){const $=Ph(J.width,J.height,_.format,_.type);for(const he of _.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,ce,Te,me)}_.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,J.width,J.height,J.depth,ce,Te,J.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,ue,J.width,J.height,J.depth,0,ce,Te,J.data);else if(_.isData3DTexture)Ne?(Be&&t.texStorage3D(i.TEXTURE_3D,ae,ue,J.width,J.height,J.depth),D&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,J.width,J.height,J.depth,ce,Te,J.data)):t.texImage3D(i.TEXTURE_3D,0,ue,J.width,J.height,J.depth,0,ce,Te,J.data);else if(_.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,ce,Te,null),$>>=1,he>>=1}}else if(_.isHTMLTexture){if("texElementImage2D"in i){const $=i.canvas;if($.hasAttribute("layoutsubtree")||$.setAttribute("layoutsubtree","true"),J.parentNode!==$){$.appendChild(J),d.add(_),$.onpaint=he=>{const me=he.changedElements;for(const j of d)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 $=Je(Ce[0]);t.texStorage2D(i.TEXTURE_2D,ae,ue,$.width,$.height)}for(let $=0,he=Ce.length;$<he;$++)le=Ce[$],Ne?D&&t.texSubImage2D(i.TEXTURE_2D,$,0,0,ce,Te,le):t.texImage2D(i.TEXTURE_2D,$,ue,ce,Te,le);_.generateMipmaps=!1}else if(Ne){if(Be){const $=Je(J);t.texStorage2D(i.TEXTURE_2D,ae,ue,$.width,$.height)}D&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,ce,Te,J)}else t.texImage2D(i.TEXTURE_2D,0,ue,ce,Te,J);f(_)&&T(G),oe.__version=ie.version,_.onUpdate&&_.onUpdate(_)}A.__version=_.version}function Pe(A,_,O){if(_.image.length!==6)return;const G=Z(A,_),Y=_.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=qe.getPrimaries(qe.workingColorSpace),K=_.colorSpace===oi?null:qe.getPrimaries(_.colorSpace),J=_.colorSpace===oi||oe===K?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,_.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),t.pixelStorei(i.UNPACK_ALIGNMENT,_.unpackAlignment),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,J);const ce=_.isCompressedTexture||_.image[0].isCompressedTexture,Te=_.image[0]&&_.image[0].isDataTexture,ue=[];for(let j=0;j<6;j++)!ce&&!Te?ue[j]=m(_.image[j],!0,s.maxCubemapSize):ue[j]=Te?_.image[j].image:_.image[j],ue[j]=Vt(_,ue[j]);const le=ue[0],Ce=r.convert(_.format,_.colorSpace),Ne=r.convert(_.type),Be=x(_.internalFormat,Ce,Ne,_.normalized,_.colorSpace),D=_.isVideoTexture!==!0,ae=ie.__version===void 0||G===!0,$=Y.dataReady;let he=b(_,le);We(i.TEXTURE_CUBE_MAP,_);let me;if(ce){D&&ae&&t.texStorage2D(i.TEXTURE_CUBE_MAP,he,Be,le.width,le.height);for(let j=0;j<6;j++){me=ue[j].mipmaps;for(let be=0;be<me.length;be++){const Se=me[be];_.format!==dn?Ce!==null?D?$&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,be,0,0,Se.width,Se.height,Ce,Se.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,be,Be,Se.width,Se.height,0,Se.data):Oe("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):D?$&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,be,0,0,Se.width,Se.height,Ce,Ne,Se.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,be,Be,Se.width,Se.height,0,Ce,Ne,Se.data)}}}else{if(me=_.mipmaps,D&&ae){me.length>0&&he++;const j=Je(ue[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,he,Be,j.width,j.height)}for(let j=0;j<6;j++)if(Te){D?$&&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 pt=me[be].image[j].image;D?$&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,be+1,0,0,pt.width,pt.height,Ce,Ne,pt.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,be+1,Be,pt.width,pt.height,0,Ce,Ne,pt.data)}}else{D?$&&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 Se=me[be];D?$&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,be+1,0,0,Ce,Ne,Se.image[j]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,be+1,Be,Ce,Ne,Se.image[j])}}}f(_)&&T(i.TEXTURE_CUBE_MAP),ie.__version=Y.version,_.onUpdate&&_.onUpdate(_)}A.__version=_.version}function De(A,_,O,G,Y,ie){const oe=r.convert(O.format,O.colorSpace),K=r.convert(O.type),J=x(O.internalFormat,oe,K,O.normalized,O.colorSpace),ce=n.get(_),Te=n.get(O);if(Te.__renderTarget=_,!ce.__hasExternalTextures){const ue=Math.max(1,_.width>>ie),le=Math.max(1,_.height>>ie);Y===i.TEXTURE_3D||Y===i.TEXTURE_2D_ARRAY?t.texImage3D(Y,ie,J,ue,le,_.depth,0,oe,K,null):t.texImage2D(Y,ie,J,ue,le,0,oe,K,null)}t.bindFramebuffer(i.FRAMEBUFFER,A),xt(_)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,G,Y,Te.__webglTexture,0,ft(_)):(Y===i.TEXTURE_2D||Y>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&Y<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,G,Y,Te.__webglTexture,ie),t.bindFramebuffer(i.FRAMEBUFFER,null)}function Re(A,_,O){if(i.bindRenderbuffer(i.RENDERBUFFER,A),_.depthBuffer){const G=_.depthTexture,Y=G&&G.isDepthTexture?G.type:null,ie=y(_.stencilBuffer,Y),oe=_.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;xt(_)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ft(_),ie,_.width,_.height):O?i.renderbufferStorageMultisample(i.RENDERBUFFER,ft(_),ie,_.width,_.height):i.renderbufferStorage(i.RENDERBUFFER,ie,_.width,_.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,oe,i.RENDERBUFFER,A)}else{const G=_.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=x(ie.internalFormat,oe,K,ie.normalized,ie.colorSpace);xt(_)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ft(_),J,_.width,_.height):O?i.renderbufferStorageMultisample(i.RENDERBUFFER,ft(_),J,_.width,_.height):i.renderbufferStorage(i.RENDERBUFFER,J,_.width,_.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function xe(A,_,O){const G=_.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(i.FRAMEBUFFER,A),!(_.depthTexture&&_.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const Y=n.get(_.depthTexture);if(Y.__renderTarget=_,(!Y.__webglTexture||_.depthTexture.image.width!==_.width||_.depthTexture.image.height!==_.height)&&(_.depthTexture.image.width=_.width,_.depthTexture.image.height=_.height,_.depthTexture.needsUpdate=!0),G){if(Y.__webglInit===void 0&&(Y.__webglInit=!0,_.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,_.depthTexture);const ce=r.convert(_.depthTexture.format),Te=r.convert(_.depthTexture.type);let ue;_.depthTexture.format===Wn?ue=i.DEPTH_COMPONENT24:_.depthTexture.format===wi&&(ue=i.DEPTH24_STENCIL8);for(let le=0;le<6;le++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+le,0,ue,_.width,_.height,0,ce,Te,null)}}else Q(_.depthTexture,0);const ie=Y.__webglTexture,oe=ft(_),K=G?i.TEXTURE_CUBE_MAP_POSITIVE_X+O:i.TEXTURE_2D,J=_.depthTexture.format===wi?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(_.depthTexture.format===Wn)xt(_)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,J,K,ie,0,oe):i.framebufferTexture2D(i.FRAMEBUFFER,J,K,ie,0);else if(_.depthTexture.format===wi)xt(_)?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 _=n.get(A),O=A.isWebGLCubeRenderTarget===!0;if(_.__boundDepthTexture!==A.depthTexture){const G=A.depthTexture;if(_.__depthDisposeCallback&&_.__depthDisposeCallback(),G){const Y=()=>{delete _.__boundDepthTexture,delete _.__depthDisposeCallback,G.removeEventListener("dispose",Y)};G.addEventListener("dispose",Y),_.__depthDisposeCallback=Y}_.__boundDepthTexture=G}if(A.depthTexture&&!_.__autoAllocateDepthBuffer)if(O)for(let G=0;G<6;G++)xe(_.__webglFramebuffer[G],A,G);else{const G=A.texture.mipmaps;G&&G.length>0?xe(_.__webglFramebuffer[0],A,0):xe(_.__webglFramebuffer,A,0)}else if(O){_.__webglDepthbuffer=[];for(let G=0;G<6;G++)if(t.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer[G]),_.__webglDepthbuffer[G]===void 0)_.__webglDepthbuffer[G]=i.createRenderbuffer(),Re(_.__webglDepthbuffer[G],A,!1);else{const Y=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ie=_.__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,_.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,_.__webglFramebuffer),_.__webglDepthbuffer===void 0)_.__webglDepthbuffer=i.createRenderbuffer(),Re(_.__webglDepthbuffer,A,!1);else{const Y=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ie=_.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,ie),i.framebufferRenderbuffer(i.FRAMEBUFFER,Y,i.RENDERBUFFER,ie)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function Ie(A,_,O){const G=n.get(A);_!==void 0&&De(G.__webglFramebuffer,A,A.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),O!==void 0&&Ue(A)}function Le(A){const _=A.texture,O=n.get(A),G=n.get(_);A.addEventListener("dispose",v);const Y=A.textures,ie=A.isWebGLCubeRenderTarget===!0,oe=Y.length>1;if(oe||(G.__webglTexture===void 0&&(G.__webglTexture=i.createTexture()),G.__version=_.version,a.memory.textures++),ie){O.__webglFramebuffer=[];for(let K=0;K<6;K++)if(_.mipmaps&&_.mipmaps.length>0){O.__webglFramebuffer[K]=[];for(let J=0;J<_.mipmaps.length;J++)O.__webglFramebuffer[K][J]=i.createFramebuffer()}else O.__webglFramebuffer[K]=i.createFramebuffer()}else{if(_.mipmaps&&_.mipmaps.length>0){O.__webglFramebuffer=[];for(let K=0;K<_.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 ce=n.get(Y[K]);ce.__webglTexture===void 0&&(ce.__webglTexture=i.createTexture(),a.memory.textures++)}if(A.samples>0&&xt(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 ce=r.convert(J.format,J.colorSpace),Te=r.convert(J.type),ue=x(J.internalFormat,ce,Te,J.normalized,J.colorSpace,A.isXRRenderTarget===!0),le=ft(A);i.renderbufferStorageMultisample(i.RENDERBUFFER,le,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,_);for(let K=0;K<6;K++)if(_.mipmaps&&_.mipmaps.length>0)for(let J=0;J<_.mipmaps.length;J++)De(O.__webglFramebuffer[K][J],A,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+K,J);else De(O.__webglFramebuffer[K],A,_,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+K,0);f(_)&&T(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(oe){for(let K=0,J=Y.length;K<J;K++){const ce=Y[K],Te=n.get(ce);let ue=i.TEXTURE_2D;(A.isWebGL3DRenderTarget||A.isWebGLArrayRenderTarget)&&(ue=A.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(ue,Te.__webglTexture),We(ue,ce),De(O.__webglFramebuffer,A,ce,i.COLOR_ATTACHMENT0+K,ue,0),f(ce)&&T(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,_),_.mipmaps&&_.mipmaps.length>0)for(let J=0;J<_.mipmaps.length;J++)De(O.__webglFramebuffer[J],A,_,i.COLOR_ATTACHMENT0,K,J);else De(O.__webglFramebuffer,A,_,i.COLOR_ATTACHMENT0,K,0);f(_)&&T(K),t.unbindTexture()}A.depthBuffer&&Ue(A)}function Ze(A){const _=A.textures;for(let O=0,G=_.length;O<G;O++){const Y=_[O];if(f(Y)){const ie=w(A),oe=n.get(Y).__webglTexture;t.bindTexture(ie,oe),T(ie),t.unbindTexture()}}}const $e=[],dt=[];function ct(A){if(A.samples>0){if(xt(A)===!1){const _=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=_.length>1;if(K)for(let ce=0;ce<_.length;ce++)t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ce,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ce,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 ce=0;ce<_.length;ce++){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[ce]);const Te=n.get(_[ce]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,Te,0)}i.blitFramebuffer(0,0,O,G,0,0,O,G,Y,i.NEAREST),c===!0&&($e.length=0,dt.length=0,$e.push(i.COLOR_ATTACHMENT0+ce),A.depthBuffer&&A.resolveDepthBuffer===!1&&($e.push(ie),dt.push(ie),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,dt)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,$e))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),K)for(let ce=0;ce<_.length;ce++){t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ce,i.RENDERBUFFER,oe.__webglColorRenderbuffer[ce]);const Te=n.get(_[ce]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ce,i.TEXTURE_2D,Te,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,oe.__webglMultisampledFramebuffer)}else if(A.depthBuffer&&A.resolveDepthBuffer===!1&&c){const _=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[_])}}}function ft(A){return Math.min(s.maxSamples,A.samples)}function xt(A){const _=n.get(A);return A.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&_.__useRenderToTexture!==!1}function I(A){const _=a.render.frame;h.get(A)!==_&&(h.set(A,_),A.update())}function Vt(A,_){const O=A.colorSpace,G=A.format,Y=A.type;return A.isCompressedTexture===!0||A.isVideoTexture===!0||O!==ma&&O!==oi&&(qe.getTransfer(O)===Qe?(G!==dn||Y!==$t)&&Oe("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Xe("WebGLTextures: Unsupported texture color space:",O)),_}function Je(A){return typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement?(l.width=A.naturalWidth||A.width,l.height=A.naturalHeight||A.height):typeof VideoFrame<"u"&&A instanceof VideoFrame?(l.width=A.displayWidth,l.height=A.displayHeight):(l.width=A.width,l.height=A.height),l}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=Ze,this.updateMultisampleRenderTarget=ct,this.setupDepthRenderbuffer=Ue,this.setupFrameBufferTexture=De,this.useMultisampledRTT=xt,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Ev(i,e){function t(n,s=oi){let r;const a=qe.getTransfer(s);if(n===$t)return i.UNSIGNED_BYTE;if(n===ul)return i.UNSIGNED_SHORT_4_4_4_4;if(n===dl)return i.UNSIGNED_SHORT_5_5_5_1;if(n===h0)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===u0)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===c0)return i.BYTE;if(n===l0)return i.SHORT;if(n===sr)return i.UNSIGNED_SHORT;if(n===hl)return i.INT;if(n===Dn)return i.UNSIGNED_INT;if(n===Rn)return i.FLOAT;if(n===Vn)return i.HALF_FLOAT;if(n===d0)return i.ALPHA;if(n===f0)return i.RGB;if(n===dn)return i.RGBA;if(n===Wn)return i.DEPTH_COMPONENT;if(n===wi)return i.DEPTH_STENCIL;if(n===p0)return i.RED;if(n===fl)return i.RED_INTEGER;if(n===Di)return i.RG;if(n===pl)return i.RG_INTEGER;if(n===ml)return i.RGBA_INTEGER;if(n===aa||n===oa||n===ca||n===la)if(a===Qe)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===aa)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===oa)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===ca)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===la)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===aa)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===oa)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===ca)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===la)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===tc||n===nc||n===ic||n===sc)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===tc)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===nc)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===ic)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===sc)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===rc||n===ac||n===oc||n===cc||n===lc||n===fa||n===hc)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===rc||n===ac)return a===Qe?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===oc)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===cc)return r.COMPRESSED_R11_EAC;if(n===lc)return r.COMPRESSED_SIGNED_R11_EAC;if(n===fa)return r.COMPRESSED_RG11_EAC;if(n===hc)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===uc||n===dc||n===fc||n===pc||n===mc||n===gc||n===_c||n===vc||n===xc||n===Mc||n===Sc||n===yc||n===Ec||n===bc)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===uc)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===dc)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===fc)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===pc)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===mc)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===gc)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===_c)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===vc)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===xc)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Mc)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Sc)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===yc)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Ec)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===bc)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Tc||n===Ac||n===wc)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===Tc)return a===Qe?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Ac)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===wc)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Rc||n===Cc||n===pa||n===Pc)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===Rc)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Cc)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===pa)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Pc)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===rr?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const bv=`
|
|
4385
4392
|
void main() {
|
|
4386
4393
|
|
|
4387
4394
|
gl_Position = vec4( position, 1.0 );
|
|
4388
4395
|
|
|
4389
|
-
}`,
|
|
4396
|
+
}`,Tv=`
|
|
4390
4397
|
uniform sampler2DArray depthColor;
|
|
4391
4398
|
uniform float depthWidth;
|
|
4392
4399
|
uniform float depthHeight;
|
|
@@ -4405,7 +4412,7 @@ void main() {
|
|
|
4405
4412
|
|
|
4406
4413
|
}
|
|
4407
4414
|
|
|
4408
|
-
}`;class zv{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new N0(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 zt({vertexShader:Fv,fragmentShader:Ov,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new ut(new bs(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Bv extends Ni{constructor(e,t){super();const n=this;let s=null,r=1,a=null,o="local-floor",c=1,l=null,h=null,d=null,u=null,p=null,g=null;const x=typeof XRWebGLBinding<"u",m=new zv,f={},A=t.getContextAttributes();let w=null,M=null;const y=[],b=[],R=new Oe;let v=null;const E=new Kt;E.viewport=new ht;const P=new Kt;P.viewport=new ht;const C=[E,P],L=new Zp;let X=null,q=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let re=y[Z];return re===void 0&&(re=new to,y[Z]=re),re.getTargetRaySpace()},this.getControllerGrip=function(Z){let re=y[Z];return re===void 0&&(re=new to,y[Z]=re),re.getGripSpace()},this.getHand=function(Z){let re=y[Z];return re===void 0&&(re=new to,y[Z]=re),re.getHandSpace()};function F(Z){const re=b.indexOf(Z.inputSource);if(re===-1)return;const ne=y[re];ne!==void 0&&(ne.update(Z.inputSource,Z.frame,l||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<y.length;Z++){const re=b[Z];re!==null&&(b[Z]=null,y[Z].disconnect(re))}X=null,q=null,m.reset();for(const Z in f)delete f[Z];e.setRenderTarget(w),p=null,u=null,d=null,s=null,M=null,We.stop(),n.isPresenting=!1,e.setPixelRatio(v),e.setSize(R.width,R.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Z){r=Z,n.isPresenting===!0&&Fe("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Z){o=Z,n.isPresenting===!0&&Fe("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(Z){l=Z},this.getBaseLayer=function(){return u!==null?u:p},this.getBinding=function(){return d===null&&x&&(d=new XRWebGLBinding(s,t)),d},this.getFrame=function(){return g},this.getSession=function(){return s},this.setSession=async function(Z){if(s=Z,s!==null){if(w=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),A.xrCompatible!==!0&&await t.makeXRCompatible(),v=e.getPixelRatio(),e.getSize(R),x&&"createProjectionLayer"in XRWebGLBinding.prototype){let ne=null,k=null,Pe=null;A.depth&&(Pe=A.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ne=A.stencil?wi:Wn,k=A.stencil?sr:Pn);const De={colorFormat:t.RGBA8,depthFormat:Pe,scaleFactor:r};d=this.getBinding(),u=d.createProjectionLayer(De),s.updateRenderState({layers:[u]}),e.setPixelRatio(1),e.setSize(u.textureWidth,u.textureHeight,!1),M=new pn(u.textureWidth,u.textureHeight,{format:dn,type:Zt,depthTexture:new Ms(u.textureWidth,u.textureHeight,k,void 0,void 0,void 0,void 0,void 0,void 0,ne),stencilBuffer:A.stencil,colorSpace:e.outputColorSpace,samples:A.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}else{const ne={antialias:A.antialias,alpha:!0,depth:A.depth,stencil:A.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 pn(p.framebufferWidth,p.framebufferHeight,{format:dn,type:Zt,colorSpace:e.outputColorSpace,stencilBuffer:A.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}M.isXRRenderTarget=!0,this.setFoveation(c),l=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,y[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 De=0;De<y.length;De++)if(De>=b.length){b.push(ne),k=De;break}else if(b[De]===null){b[De]=ne,k=De;break}if(k===-1)break}const Pe=y[k];Pe&&Pe.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),Pe=re.projectionMatrix.elements,De=ne.projectionMatrix.elements,Re=Pe[14]/(Pe[10]-1),Me=Pe[14]/(Pe[10]+1),Ue=(Pe[9]+1)/Pe[5],Ie=(Pe[9]-1)/Pe[5],Le=(Pe[8]-1)/Pe[0],Ze=(De[8]+1)/De[0],$e=Re*Le,dt=Re*Ze,ct=k/(-Le+Ze),ft=ct*-Le;if(re.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(ft),Z.translateZ(ct),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert(),Pe[10]===-1)Z.projectionMatrix.copy(re.projectionMatrix),Z.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{const yt=Re+ct,I=Me+ct,Ht=$e-ft,Je=dt+(k-ft),T=Ue*Me/I*yt,_=Ie*Me/I*yt;Z.projectionMatrix.makePerspective(Ht,Je,T,_,yt,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=P.near=E.near=re,L.far=P.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,P.layers.mask=L.layers.mask&-3;const k=Z.parent,Pe=L.cameras;se(L,k);for(let De=0;De<Pe.length;De++)se(Pe[De],k);Pe.length===2?ee(L,E,P):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=Bc*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1)}this.getCamera=function(){return L},this.getFoveation=function(){if(!(u===null&&p===null))return c},this.setFoveation=function(Z){c=Z,u!==null&&(u.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 rt(Z,re){if(h=re.getViewerPose(l||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 Ze=d.getViewSubImage(u,Ue);Ie=Ze.viewport,Me===0&&(e.setRenderTargetTextures(M,Ze.colorTexture,Ze.depthStencilTexture),e.setRenderTarget(M))}let Le=C[Me];Le===void 0&&(Le=new Kt,Le.layers.enable(Me),Le.viewport=new ht,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 Pe=s.enabledFeatures;if(Pe&&Pe.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&x){d=n.getBinding();const Me=d.getDepthInformation(ne[0]);Me&&Me.isValid&&Me.texture&&m.init(Me,s.renderState)}if(Pe&&Pe.includes("camera-access")&&x){e.state.unbindTexture(),d=n.getBinding();for(let Me=0;Me<ne.length;Me++){const Ue=ne[Me].camera;if(Ue){let Ie=f[Ue];Ie||(Ie=new N0,f[Ue]=Ie);const Le=d.getCameraImage(Ue);Ie.sourceTexture=Le}}}}for(let ne=0;ne<y.length;ne++){const k=b[ne],Pe=y[ne];k!==null&&Pe!==void 0&&Pe.update(k,re,l||a)}Ve&&Ve(Z,re),re.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:re}),g=null}const We=new B0;We.setAnimationLoop(rt),this.setAnimationLoop=function(Z){Ve=Z},this.dispose=function(){}}}const kv=new st,q0=new ze;q0.set(-1,0,0,0,1,0,0,0,1);function Gv(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,U0(i)),f.isFog?(m.fogNear.value=f.near,m.fogFar.value=f.far):f.isFogExp2&&(m.fogDensity.value=f.density)}function s(m,f,A,w,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),d(m,f)):f.isMeshPhongMaterial?(r(m,f),h(m,f),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)):f.isMeshStandardMaterial?(r(m,f),u(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?c(m,f,A,w):f.isSpriteMaterial?l(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===Pt&&(m.bumpScale.value*=-1)),f.normalMap&&(m.normalMap.value=f.normalMap,t(f.normalMap,m.normalMapTransform),m.normalScale.value.copy(f.normalScale),f.side===Pt&&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 A=e.get(f),w=A.envMap,M=A.envMapRotation;w&&(m.envMap.value=w,m.envMapRotation.value.setFromMatrix4(kv.makeRotationFromEuler(M)).transpose(),w.isCubeTexture&&w.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(q0),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 c(m,f,A,w){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.size.value=f.size*A,m.scale.value=w*.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 l(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 d(m,f){f.gradientMap&&(m.gradientMap.value=f.gradientMap)}function u(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,A){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===Pt&&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=A.texture,m.transmissionSamplerSize.value.set(A.width,A.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 A=e.get(f).light;m.referencePosition.value.setFromMatrixPosition(A.matrixWorld),m.nearDistance.value=A.shadow.camera.near,m.farDistance.value=A.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function Hv(i,e,t,n){let s={},r={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(M,y){const b=y.program;n.uniformBlockBinding(M,b)}function l(M,y){let b=s[M.id];b===void 0&&(m(M),b=h(M),s[M.id]=b,M.addEventListener("dispose",A));const R=y.program;n.updateUBOMapping(M,R);const v=e.render.frame;r[M.id]!==v&&(u(M),r[M.id]=v)}function h(M){const y=d();M.__bindingPointIndex=y;const b=i.createBuffer(),R=M.__size,v=M.usage;return i.bindBuffer(i.UNIFORM_BUFFER,b),i.bufferData(i.UNIFORM_BUFFER,R,v),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,y,b),b}function d(){for(let M=0;M<o;M++)if(a.indexOf(M)===-1)return a.push(M),M;return Xe("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(M){const y=s[M.id],b=M.uniforms,R=M.__cache;i.bindBuffer(i.UNIFORM_BUFFER,y);for(let v=0,E=b.length;v<E;v++){const P=b[v];if(Array.isArray(P))for(let C=0,L=P.length;C<L;C++)p(P[C],v,C,R);else p(P,v,0,R)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function p(M,y,b,R){if(x(M,y,b,R)===!0){const v=M.__offset,E=M.value;if(Array.isArray(E)){let P=0;for(let C=0;C<E.length;C++){const L=E[C],X=f(L);g(L,M.__data,P),typeof L!="number"&&typeof L!="boolean"&&!L.isMatrix3&&!ArrayBuffer.isView(L)&&(P+=X.storage/Float32Array.BYTES_PER_ELEMENT)}}else g(E,M.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,v,M.__data)}}function g(M,y,b){typeof M=="number"||typeof M=="boolean"?y[0]=M:M.isMatrix3?(y[0]=M.elements[0],y[1]=M.elements[1],y[2]=M.elements[2],y[3]=0,y[4]=M.elements[3],y[5]=M.elements[4],y[6]=M.elements[5],y[7]=0,y[8]=M.elements[6],y[9]=M.elements[7],y[10]=M.elements[8],y[11]=0):ArrayBuffer.isView(M)?y.set(new M.constructor(M.buffer,M.byteOffset,y.length)):M.toArray(y,b)}function x(M,y,b,R){const v=M.value,E=y+"_"+b;if(R[E]===void 0)return typeof v=="number"||typeof v=="boolean"?R[E]=v:ArrayBuffer.isView(v)?R[E]=v.slice():R[E]=v.clone(),!0;{const P=R[E];if(typeof v=="number"||typeof v=="boolean"){if(P!==v)return R[E]=v,!0}else{if(ArrayBuffer.isView(v))return!0;if(P.equals(v)===!1)return P.copy(v),!0}}return!1}function m(M){const y=M.uniforms;let b=0;const R=16;for(let E=0,P=y.length;E<P;E++){const C=Array.isArray(y[E])?y[E]:[y[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 v=b%R;return v>0&&(b+=R-v),M.__size=b,M.__cache={},this}function f(M){const y={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(y.boundary=4,y.storage=4):M.isVector2?(y.boundary=8,y.storage=8):M.isVector3||M.isColor?(y.boundary=16,y.storage=12):M.isVector4?(y.boundary=16,y.storage=16):M.isMatrix3?(y.boundary=48,y.storage=48):M.isMatrix4?(y.boundary=64,y.storage=64):M.isTexture?Fe("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(y.boundary=16,y.storage=M.byteLength):Fe("WebGLRenderer: Unsupported uniform value type.",M),y}function A(M){const y=M.target;y.removeEventListener("dispose",A);const b=a.indexOf(y.__bindingPointIndex);a.splice(b,1),i.deleteBuffer(s[y.id]),delete s[y.id],delete r[y.id]}function w(){for(const M in s)i.deleteBuffer(s[M]);a=[],s={},r={}}return{bind:c,update:l,dispose:w}}const Vv=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let xn=null;function Wv(){return xn===null&&(xn=new Cp(Vv,16,16,Di,Vn),xn.name="DFG_LUT",xn.minFilter=Ut,xn.magFilter=Ut,xn.wrapS=Bn,xn.wrapT=Bn,xn.generateMipmaps=!1,xn.needsUpdate=!0),xn}class Xv{constructor(e={}){const{canvas:t=ap(),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:d=!1,reversedDepthBuffer:u=!1,outputBufferType:p=Zt}=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([Sl,Ml,xl]),f=new Set([Zt,Pn,ir,sr,_l,vl]),A=new Uint32Array(4),w=new Int32Array(4),M=new U;let y=null,b=null;const R=[],v=[];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=Cn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const P=this;let C=!1,L=null,X=null,q=null,F=null;this._outputColorSpace=nn;let W=0,V=0,Q=null,te=-1,ee=null;const se=new ht,ge=new ht;let Ve=null;const rt=new xe(0);let We=0,Z=t.width,re=t.height,ne=1,k=null,Pe=null;const De=new ht(0,0,Z,re),Re=new ht(0,0,Z,re);let Me=!1;const Ue=new wl;let Ie=!1,Le=!1;const Ze=new st,$e=new U,dt=new ht,ct={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ft=!1;function yt(){return Q===null?ne:1}let I=n;function Ht(S,N){return t.getContext(S,N)}try{const S={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${pl}`),t.addEventListener("webglcontextlost",pt,!1),t.addEventListener("webglcontextrestored",at,!1),t.addEventListener("webglcontextcreationerror",mn,!1),I===null){const N="webgl2";if(I=Ht(N,S),I===null)throw Ht(N)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(S){throw Xe("WebGLRenderer: "+S.message),S}let Je,T,_,O,G,Y,ie,oe,K,J,ce,Te,ue,le,Ce,Ne,Be,D,ae,$,he,me,j;function be(){Je=new W1(I),Je.init(),he=new Uv(I,Je),T=new F1(I,Je,e,he),_=new Lv(I,Je),T.reversedDepthBuffer&&u&&_.buffers.depth.setReversed(!0),X=I.createFramebuffer(),q=I.createFramebuffer(),F=I.createFramebuffer(),O=new Y1(I),G=new xv,Y=new Nv(I,Je,_,G,T,he,O),ie=new V1(P),oe=new Jp(I),me=new N1(I,oe),K=new X1(I,oe,O,me),J=new Z1(I,K,oe,me,O),D=new K1(I,T,Y),Ce=new O1(G),ce=new vv(P,ie,Je,T,me,Ce),Te=new Gv(P,G),ue=new Sv,le=new wv(Je),Be=new L1(P,ie,_,J,g,c),Ne=new Iv(P,J,T),j=new Hv(I,O,T,_),ae=new U1(I,Je,O),$=new q1(I,Je,O),O.programs=ce.programs,P.capabilities=T,P.extensions=Je,P.properties=G,P.renderLists=ue,P.shadowMap=Ne,P.state=_,P.info=O}be(),x!==Zt&&(E=new J1(x,t.width,t.height,o,s,r));const Se=new Bv(P,I);this.xr=Se,this.getContext=function(){return I},this.getContextAttributes=function(){return I.getContextAttributes()},this.forceContextLoss=function(){const S=Je.get("WEBGL_lose_context");S&&S.loseContext()},this.forceContextRestore=function(){const S=Je.get("WEBGL_lose_context");S&&S.restoreContext()},this.getPixelRatio=function(){return ne},this.setPixelRatio=function(S){S!==void 0&&(ne=S,this.setSize(Z,re,!1))},this.getSize=function(S){return S.set(Z,re)},this.setSize=function(S,N,H=!0){if(Se.isPresenting){Fe("WebGLRenderer: Can't change size while VR device is presenting.");return}Z=S,re=N,t.width=Math.floor(S*ne),t.height=Math.floor(N*ne),H===!0&&(t.style.width=S+"px",t.style.height=N+"px"),E!==null&&E.setSize(t.width,t.height),this.setViewport(0,0,S,N)},this.getDrawingBufferSize=function(S){return S.set(Z*ne,re*ne).floor()},this.setDrawingBufferSize=function(S,N,H){Z=S,re=N,ne=H,t.width=Math.floor(S*H),t.height=Math.floor(N*H),this.setViewport(0,0,S,N)},this.setEffects=function(S){if(x===Zt){Xe("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(S){for(let N=0;N<S.length;N++)if(S[N].isOutputPass===!0){Fe("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}E.setEffects(S||[])},this.getCurrentViewport=function(S){return S.copy(se)},this.getViewport=function(S){return S.copy(De)},this.setViewport=function(S,N,H,z){S.isVector4?De.set(S.x,S.y,S.z,S.w):De.set(S,N,H,z),_.viewport(se.copy(De).multiplyScalar(ne).round())},this.getScissor=function(S){return S.copy(Re)},this.setScissor=function(S,N,H,z){S.isVector4?Re.set(S.x,S.y,S.z,S.w):Re.set(S,N,H,z),_.scissor(ge.copy(Re).multiplyScalar(ne).round())},this.getScissorTest=function(){return Me},this.setScissorTest=function(S){_.setScissorTest(Me=S)},this.setOpaqueSort=function(S){k=S},this.setTransparentSort=function(S){Pe=S},this.getClearColor=function(S){return S.copy(Be.getClearColor())},this.setClearColor=function(){Be.setClearColor(...arguments)},this.getClearAlpha=function(){return Be.getClearAlpha()},this.setClearAlpha=function(){Be.setClearAlpha(...arguments)},this.clear=function(S=!0,N=!0,H=!0){let z=0;if(S){let B=!1;if(Q!==null){const pe=Q.texture.format;B=m.has(pe)}if(B){const pe=Q.texture.type,ve=f.has(pe),fe=Be.getClearColor(),ye=Be.getClearAlpha(),Ae=fe.r,ke=fe.g,He=fe.b;ve?(A[0]=Ae,A[1]=ke,A[2]=He,A[3]=ye,I.clearBufferuiv(I.COLOR,0,A)):(w[0]=Ae,w[1]=ke,w[2]=He,w[3]=ye,I.clearBufferiv(I.COLOR,0,w))}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(S){S.setRenderer(this),L=S},this.dispose=function(){t.removeEventListener("webglcontextlost",pt,!1),t.removeEventListener("webglcontextrestored",at,!1),t.removeEventListener("webglcontextcreationerror",mn,!1),Be.dispose(),ue.dispose(),le.dispose(),G.dispose(),ie.dispose(),J.dispose(),me.dispose(),j.dispose(),ce.dispose(),Se.dispose(),Se.removeEventListener("sessionstart",Ul),Se.removeEventListener("sessionend",Fl),gi.stop()};function pt(S){S.preventDefault(),Sa("WebGLRenderer: Context Lost."),C=!0}function at(){Sa("WebGLRenderer: Context Restored."),C=!1;const S=O.autoReset,N=Ne.enabled,H=Ne.autoUpdate,z=Ne.needsUpdate,B=Ne.type;be(),O.autoReset=S,Ne.enabled=N,Ne.autoUpdate=H,Ne.needsUpdate=z,Ne.type=B}function mn(S){Xe("WebGLRenderer: A WebGL context could not be created. Reason: ",S.statusMessage)}function gn(S){const N=S.target;N.removeEventListener("dispose",gn),Pd(N)}function Pd(S){Dd(S),G.remove(S)}function Dd(S){const N=G.get(S).programs;N!==void 0&&(N.forEach(function(H){ce.releaseProgram(H)}),S.isShaderMaterial&&ce.releaseShaderCache(S))}this.renderBufferDirect=function(S,N,H,z,B,pe){N===null&&(N=ct);const ve=B.isMesh&&B.matrixWorld.determinantAffine()<0,fe=Nd(S,N,H,z,B);_.setMaterial(z,ve);let ye=H.index,Ae=1;if(z.wireframe===!0){if(ye=K.getWireframeAttribute(H),ye===void 0)return;Ae=2}const ke=H.drawRange,He=H.attributes.position;let we=ke.start*Ae,je=(ke.start+ke.count)*Ae;pe!==null&&(we=Math.max(we,pe.start*Ae),je=Math.min(je,(pe.start+pe.count)*Ae)),ye!==null?(we=Math.max(we,0),je=Math.min(je,ye.count)):He!=null&&(we=Math.max(we,0),je=Math.min(je,He.count));const gt=je-we;if(gt<0||gt===1/0)return;me.setup(B,z,fe,H,ye);let mt,tt=ae;if(ye!==null&&(mt=oe.get(ye),tt=$,tt.setIndex(mt)),B.isMesh)z.wireframe===!0?(_.setLineWidth(z.wireframeLinewidth*yt()),tt.setMode(I.LINES)):tt.setMode(I.TRIANGLES);else if(B.isLine){let Dt=z.linewidth;Dt===void 0&&(Dt=1),_.setLineWidth(Dt*yt()),B.isLineSegments?tt.setMode(I.LINES):B.isLineLoop?tt.setMode(I.LINE_LOOP):tt.setMode(I.LINE_STRIP)}else B.isPoints?tt.setMode(I.POINTS):B.isSprite&&tt.setMode(I.TRIANGLES);if(B.isBatchedMesh)if(Je.get("WEBGL_multi_draw"))tt.renderMultiDraw(B._multiDrawStarts,B._multiDrawCounts,B._multiDrawCount);else{const Dt=B._multiDrawStarts,_e=B._multiDrawCounts,Wt=B._multiDrawCount,Ke=ye?oe.get(ye).bytesPerElement:1,$t=G.get(z).currentProgram.getUniforms();for(let _n=0;_n<Wt;_n++)$t.setValue(I,"_gl_DrawID",_n),tt.render(Dt[_n]/Ke,_e[_n])}else if(B.isInstancedMesh)tt.renderInstances(we,gt,B.count);else if(H.isInstancedBufferGeometry){const Dt=H._maxInstanceCount!==void 0?H._maxInstanceCount:1/0,_e=Math.min(H.instanceCount,Dt);tt.renderInstances(we,gt,_e)}else tt.render(we,gt)};function Nl(S,N,H){S.transparent===!0&&S.side===zn&&S.forceSinglePass===!1?(S.side=Pt,S.needsUpdate=!0,dr(S,N,H),S.side=di,S.needsUpdate=!0,dr(S,N,H),S.side=zn):dr(S,N,H)}this.compile=function(S,N,H=null){H===null&&(H=S),b=le.get(H),b.init(N),v.push(b),H.traverseVisible(function(B){B.isLight&&B.layers.test(N.layers)&&(b.pushLight(B),B.castShadow&&b.pushShadow(B))}),S!==H&&S.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 S.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 ve=0;ve<pe.length;ve++){const fe=pe[ve];Nl(fe,H,B),z.add(fe)}else Nl(pe,H,B),z.add(pe)}),b=v.pop(),z},this.compileAsync=function(S,N,H=null){const z=this.compile(S,N,H);return new Promise(B=>{function pe(){if(z.forEach(function(ve){G.get(ve).currentProgram.isReady()&&z.delete(ve)}),z.size===0){B(S);return}setTimeout(pe,10)}Je.get("KHR_parallel_shader_compile")!==null?pe():setTimeout(pe,10)})};let Ha=null;function Id(S){Ha&&Ha(S)}function Ul(){gi.stop()}function Fl(){gi.start()}const gi=new B0;gi.setAnimationLoop(Id),typeof self<"u"&&gi.setContext(self),this.setAnimationLoop=function(S){Ha=S,Se.setAnimationLoop(S),S===null?gi.stop():gi.start()},Se.addEventListener("sessionstart",Ul),Se.addEventListener("sessionend",Fl),this.render=function(S,N){if(N!==void 0&&N.isCamera!==!0){Xe("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;L!==null&&L.renderStart(S,N);const H=Se.enabled===!0&&Se.isPresenting===!0,z=E!==null&&(Q===null||H)&&E.begin(P,Q);if(S.matrixWorldAutoUpdate===!0&&S.updateMatrixWorld(),N.parent===null&&N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),Se.enabled===!0&&Se.isPresenting===!0&&(E===null||E.isCompositing()===!1)&&(Se.cameraAutoUpdate===!0&&Se.updateCamera(N),N=Se.getCamera()),S.isScene===!0&&S.onBeforeRender(P,S,N,Q),b=le.get(S,v.length),b.init(N),b.state.textureUnits=Y.getTextureUnits(),v.push(b),Ze.multiplyMatrices(N.projectionMatrix,N.matrixWorldInverse),Ue.setFromProjectionMatrix(Ze,Rn,N.reversedDepth),Le=this.localClippingEnabled,Ie=Ce.init(this.clippingPlanes,Le),y=ue.get(S,R.length),y.init(),R.push(y),Se.enabled===!0&&Se.isPresenting===!0){const ve=P.xr.getDepthSensingMesh();ve!==null&&Va(ve,N,-1/0,P.sortObjects)}Va(S,N,0,P.sortObjects),y.finish(),P.sortObjects===!0&&y.sort(k,Pe,N.reversedDepth),ft=Se.enabled===!1||Se.isPresenting===!1||Se.hasDepthSensing()===!1,ft&&Be.addToRenderList(y,S),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Ie===!0&&Ce.beginShadows();const B=b.state.shadowsArray;if(Ne.render(B,S,N),Ie===!0&&Ce.endShadows(),(z&&E.hasRenderPass())===!1){const ve=y.opaque,fe=y.transmissive;if(b.setupLights(),N.isArrayCamera){const ye=N.cameras;if(fe.length>0)for(let Ae=0,ke=ye.length;Ae<ke;Ae++){const He=ye[Ae];zl(ve,fe,S,He)}ft&&Be.render(S);for(let Ae=0,ke=ye.length;Ae<ke;Ae++){const He=ye[Ae];Ol(y,S,He,He.viewport)}}else fe.length>0&&zl(ve,fe,S,N),ft&&Be.render(S),Ol(y,S,N)}Q!==null&&V===0&&(Y.updateMultisampleRenderTarget(Q),Y.updateRenderTargetMipmap(Q)),z&&E.end(P),S.isScene===!0&&S.onAfterRender(P,S,N),me.resetDefaultState(),te=-1,ee=null,v.pop(),v.length>0?(b=v[v.length-1],Y.setTextureUnits(b.state.textureUnits),Ie===!0&&Ce.setGlobalState(P.clippingPlanes,b.state.camera)):b=null,R.pop(),R.length>0?y=R[R.length-1]:y=null,L!==null&&L.renderEnd()};function Va(S,N,H,z){if(S.visible===!1)return;if(S.layers.test(N.layers)){if(S.isGroup)H=S.renderOrder;else if(S.isLOD)S.autoUpdate===!0&&S.update(N);else if(S.isLightProbeGrid)b.pushLightProbeGrid(S);else if(S.isLight)b.pushLight(S),S.castShadow&&b.pushShadow(S);else if(S.isSprite){if(!S.frustumCulled||Ue.intersectsSprite(S)){z&&dt.setFromMatrixPosition(S.matrixWorld).applyMatrix4(Ze);const ve=J.update(S),fe=S.material;fe.visible&&y.push(S,ve,fe,H,dt.z,null)}}else if((S.isMesh||S.isLine||S.isPoints)&&(!S.frustumCulled||Ue.intersectsObject(S))){const ve=J.update(S),fe=S.material;if(z&&(S.boundingSphere!==void 0?(S.boundingSphere===null&&S.computeBoundingSphere(),dt.copy(S.boundingSphere.center)):(ve.boundingSphere===null&&ve.computeBoundingSphere(),dt.copy(ve.boundingSphere.center)),dt.applyMatrix4(S.matrixWorld).applyMatrix4(Ze)),Array.isArray(fe)){const ye=ve.groups;for(let Ae=0,ke=ye.length;Ae<ke;Ae++){const He=ye[Ae],we=fe[He.materialIndex];we&&we.visible&&y.push(S,ve,we,H,dt.z,He)}}else fe.visible&&y.push(S,ve,fe,H,dt.z,null)}}const pe=S.children;for(let ve=0,fe=pe.length;ve<fe;ve++)Va(pe[ve],N,H,z)}function Ol(S,N,H,z){const{opaque:B,transmissive:pe,transparent:ve}=S;b.setupLightsView(H),Ie===!0&&Ce.setGlobalState(P.clippingPlanes,H),z&&_.viewport(se.copy(z)),B.length>0&&ur(B,N,H),pe.length>0&&ur(pe,N,H),ve.length>0&&ur(ve,N,H),_.buffers.depth.setTest(!0),_.buffers.depth.setMask(!0),_.buffers.color.setMask(!0),_.setPolygonOffset(!1)}function zl(S,N,H,z){if((H.isScene===!0?H.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[z.id]===void 0){const we=Je.has("EXT_color_buffer_half_float")||Je.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[z.id]=new pn(1,1,{generateMipmaps:!0,type:we?Vn:Zt,minFilter:Ai,samples:Math.max(4,T.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:qe.workingColorSpace})}const pe=b.state.transmissionRenderTarget[z.id],ve=z.viewport||se;pe.setSize(ve.z*P.transmissionResolutionScale,ve.w*P.transmissionResolutionScale);const fe=P.getRenderTarget(),ye=P.getActiveCubeFace(),Ae=P.getActiveMipmapLevel();P.setRenderTarget(pe),P.getClearColor(rt),We=P.getClearAlpha(),We<1&&P.setClearColor(16777215,.5),P.clear(),ft&&Be.render(H);const ke=P.toneMapping;P.toneMapping=Cn;const He=z.viewport;if(z.viewport!==void 0&&(z.viewport=void 0),b.setupLightsView(z),Ie===!0&&Ce.setGlobalState(P.clippingPlanes,z),ur(S,H,z),Y.updateMultisampleRenderTarget(pe),Y.updateRenderTargetMipmap(pe),Je.has("WEBGL_multisampled_render_to_texture")===!1){let we=!1;for(let je=0,gt=N.length;je<gt;je++){const mt=N[je],{object:tt,geometry:Dt,material:_e,group:Wt}=mt;if(_e.side===zn&&tt.layers.test(z.layers)){const Ke=_e.side;_e.side=Pt,_e.needsUpdate=!0,Bl(tt,H,z,Dt,_e,Wt),_e.side=Ke,_e.needsUpdate=!0,we=!0}}we===!0&&(Y.updateMultisampleRenderTarget(pe),Y.updateRenderTargetMipmap(pe))}P.setRenderTarget(fe,ye,Ae),P.setClearColor(rt,We),He!==void 0&&(z.viewport=He),P.toneMapping=ke}function ur(S,N,H){const z=N.isScene===!0?N.overrideMaterial:null;for(let B=0,pe=S.length;B<pe;B++){const ve=S[B],{object:fe,geometry:ye,group:Ae}=ve;let ke=ve.material;ke.allowOverride===!0&&z!==null&&(ke=z),fe.layers.test(H.layers)&&Bl(fe,N,H,ye,ke,Ae)}}function Bl(S,N,H,z,B,pe){S.onBeforeRender(P,N,H,z,B,pe),S.modelViewMatrix.multiplyMatrices(H.matrixWorldInverse,S.matrixWorld),S.normalMatrix.getNormalMatrix(S.modelViewMatrix),B.onBeforeRender(P,N,H,z,S,pe),B.transparent===!0&&B.side===zn&&B.forceSinglePass===!1?(B.side=Pt,B.needsUpdate=!0,P.renderBufferDirect(H,N,z,B,S,pe),B.side=di,B.needsUpdate=!0,P.renderBufferDirect(H,N,z,B,S,pe),B.side=zn):P.renderBufferDirect(H,N,z,B,S,pe),S.onAfterRender(P,N,H,z,B,pe)}function dr(S,N,H){N.isScene!==!0&&(N=ct);const z=G.get(S),B=b.state.lights,pe=b.state.shadowsArray,ve=B.state.version,fe=ce.getParameters(S,B.state,pe,N,H,b.state.lightProbeGridArray),ye=ce.getProgramCacheKey(fe);let Ae=z.programs;z.environment=S.isMeshStandardMaterial||S.isMeshLambertMaterial||S.isMeshPhongMaterial?N.environment:null,z.fog=N.fog;const ke=S.isMeshStandardMaterial||S.isMeshLambertMaterial&&!S.envMap||S.isMeshPhongMaterial&&!S.envMap;z.envMap=ie.get(S.envMap||z.environment,ke),z.envMapRotation=z.environment!==null&&S.envMap===null?N.environmentRotation:S.envMapRotation,Ae===void 0&&(S.addEventListener("dispose",gn),Ae=new Map,z.programs=Ae);let He=Ae.get(ye);if(He!==void 0){if(z.currentProgram===He&&z.lightsStateVersion===ve)return Gl(S,fe),He}else fe.uniforms=ce.getUniforms(S),L!==null&&S.isNodeMaterial&&L.build(S,H,fe),S.onBeforeCompile(fe,P),He=ce.acquireProgram(fe,ye),Ae.set(ye,He),z.uniforms=fe.uniforms;const we=z.uniforms;return(!S.isShaderMaterial&&!S.isRawShaderMaterial||S.clipping===!0)&&(we.clippingPlanes=Ce.uniform),Gl(S,fe),z.needsLights=Fd(S),z.lightsStateVersion=ve,z.needsLights&&(we.ambientLightColor.value=B.state.ambient,we.lightProbe.value=B.state.probe,we.directionalLights.value=B.state.directional,we.directionalLightShadows.value=B.state.directionalShadow,we.spotLights.value=B.state.spot,we.spotLightShadows.value=B.state.spotShadow,we.rectAreaLights.value=B.state.rectArea,we.ltc_1.value=B.state.rectAreaLTC1,we.ltc_2.value=B.state.rectAreaLTC2,we.pointLights.value=B.state.point,we.pointLightShadows.value=B.state.pointShadow,we.hemisphereLights.value=B.state.hemi,we.directionalShadowMatrix.value=B.state.directionalShadowMatrix,we.spotLightMatrix.value=B.state.spotLightMatrix,we.spotLightMap.value=B.state.spotLightMap,we.pointShadowMatrix.value=B.state.pointShadowMatrix),z.lightProbeGrid=b.state.lightProbeGridArray.length>0,z.currentProgram=He,z.uniformsList=null,He}function kl(S){if(S.uniformsList===null){const N=S.currentProgram.getUniforms();S.uniformsList=pa.seqWithValue(N.seq,S.uniforms)}return S.uniformsList}function Gl(S,N){const H=G.get(S);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 Ld(S,N){if(S.length===0)return null;if(S.length===1)return S[0].texture!==null?S[0]:null;M.setFromMatrixPosition(N.matrixWorld);for(let H=0,z=S.length;H<z;H++){const B=S[H];if(B.texture!==null&&B.boundingBox.containsPoint(M))return B}return null}function Nd(S,N,H,z,B){N.isScene!==!0&&(N=ct),Y.resetTextureUnits();const pe=N.fog,ve=z.isMeshStandardMaterial||z.isMeshLambertMaterial||z.isMeshPhongMaterial?N.environment:null,fe=Q===null?P.outputColorSpace:Q.isXRRenderTarget===!0?Q.texture.colorSpace:qe.workingColorSpace,ye=z.isMeshStandardMaterial||z.isMeshLambertMaterial&&!z.envMap||z.isMeshPhongMaterial&&!z.envMap,Ae=ie.get(z.envMap||ve,ye),ke=z.vertexColors===!0&&!!H.attributes.color&&H.attributes.color.itemSize===4,He=!!H.attributes.tangent&&(!!z.normalMap||z.anisotropy>0),we=!!H.morphAttributes.position,je=!!H.morphAttributes.normal,gt=!!H.morphAttributes.color;let mt=Cn;z.toneMapped&&(Q===null||Q.isXRRenderTarget===!0)&&(mt=P.toneMapping);const tt=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,Dt=tt!==void 0?tt.length:0,_e=G.get(z),Wt=b.state.lights;if(Ie===!0&&(Le===!0||S!==ee)){const ot=S===ee&&z.id===te;Ce.setState(z,S,ot)}let Ke=!1;z.version===_e.__version?(_e.needsLights&&_e.lightsStateVersion!==Wt.state.version||_e.outputColorSpace!==fe||B.isBatchedMesh&&_e.batching===!1||!B.isBatchedMesh&&_e.batching===!0||B.isBatchedMesh&&_e.batchingColor===!0&&B.colorTexture===null||B.isBatchedMesh&&_e.batchingColor===!1&&B.colorTexture!==null||B.isInstancedMesh&&_e.instancing===!1||!B.isInstancedMesh&&_e.instancing===!0||B.isSkinnedMesh&&_e.skinning===!1||!B.isSkinnedMesh&&_e.skinning===!0||B.isInstancedMesh&&_e.instancingColor===!0&&B.instanceColor===null||B.isInstancedMesh&&_e.instancingColor===!1&&B.instanceColor!==null||B.isInstancedMesh&&_e.instancingMorph===!0&&B.morphTexture===null||B.isInstancedMesh&&_e.instancingMorph===!1&&B.morphTexture!==null||_e.envMap!==Ae||z.fog===!0&&_e.fog!==pe||_e.numClippingPlanes!==void 0&&(_e.numClippingPlanes!==Ce.numPlanes||_e.numIntersection!==Ce.numIntersection)||_e.vertexAlphas!==ke||_e.vertexTangents!==He||_e.morphTargets!==we||_e.morphNormals!==je||_e.morphColors!==gt||_e.toneMapping!==mt||_e.morphTargetsCount!==Dt||!!_e.lightProbeGrid!=b.state.lightProbeGridArray.length>0)&&(Ke=!0):(Ke=!0,_e.__version=z.version);let $t=_e.currentProgram;Ke===!0&&($t=dr(z,N,B),L&&z.isNodeMaterial&&L.onUpdateProgram(z,$t,_e));let _n=!1,Yn=!1,Ui=!1;const nt=$t.getUniforms(),_t=_e.uniforms;if(_.useProgram($t.program)&&(_n=!0,Yn=!0,Ui=!0),z.id!==te&&(te=z.id,Yn=!0),_e.needsLights){const ot=Ld(b.state.lightProbeGridArray,B);_e.lightProbeGrid!==ot&&(_e.lightProbeGrid=ot,Yn=!0)}if(_n||ee!==S){_.buffers.depth.getReversed()&&S.reversedDepth!==!0&&(S._reversedDepth=!0,S.updateProjectionMatrix()),nt.setValue(I,"projectionMatrix",S.projectionMatrix),nt.setValue(I,"viewMatrix",S.matrixWorldInverse);const Zn=nt.map.cameraPosition;Zn!==void 0&&Zn.setValue(I,$e.setFromMatrixPosition(S.matrixWorld)),T.logarithmicDepthBuffer&&nt.setValue(I,"logDepthBufFC",2/(Math.log(S.far+1)/Math.LN2)),(z.isMeshPhongMaterial||z.isMeshToonMaterial||z.isMeshLambertMaterial||z.isMeshBasicMaterial||z.isMeshStandardMaterial||z.isShaderMaterial)&&nt.setValue(I,"isOrthographic",S.isOrthographicCamera===!0),ee!==S&&(ee=S,Yn=!0,Ui=!0)}if(_e.needsLights&&(Wt.state.directionalShadowMap.length>0&&nt.setValue(I,"directionalShadowMap",Wt.state.directionalShadowMap,Y),Wt.state.spotShadowMap.length>0&&nt.setValue(I,"spotShadowMap",Wt.state.spotShadowMap,Y),Wt.state.pointShadowMap.length>0&&nt.setValue(I,"pointShadowMap",Wt.state.pointShadowMap,Y)),B.isSkinnedMesh){nt.setOptional(I,B,"bindMatrix"),nt.setOptional(I,B,"bindMatrixInverse");const ot=B.skeleton;ot&&(ot.boneTexture===null&&ot.computeBoneTexture(),nt.setValue(I,"boneTexture",ot.boneTexture,Y))}B.isBatchedMesh&&(nt.setOptional(I,B,"batchingTexture"),nt.setValue(I,"batchingTexture",B._matricesTexture,Y),nt.setOptional(I,B,"batchingIdTexture"),nt.setValue(I,"batchingIdTexture",B._indirectTexture,Y),nt.setOptional(I,B,"batchingColorTexture"),B._colorsTexture!==null&&nt.setValue(I,"batchingColorTexture",B._colorsTexture,Y));const Kn=H.morphAttributes;if((Kn.position!==void 0||Kn.normal!==void 0||Kn.color!==void 0)&&D.update(B,H,$t),(Yn||_e.receiveShadow!==B.receiveShadow)&&(_e.receiveShadow=B.receiveShadow,nt.setValue(I,"receiveShadow",B.receiveShadow)),(z.isMeshStandardMaterial||z.isMeshLambertMaterial||z.isMeshPhongMaterial)&&z.envMap===null&&N.environment!==null&&(_t.envMapIntensity.value=N.environmentIntensity),_t.dfgLUT!==void 0&&(_t.dfgLUT.value=Wv()),Yn){if(nt.setValue(I,"toneMappingExposure",P.toneMappingExposure),_e.needsLights&&Ud(_t,Ui),pe&&z.fog===!0&&Te.refreshFogUniforms(_t,pe),Te.refreshMaterialUniforms(_t,z,ne,re,b.state.transmissionRenderTarget[S.id]),_e.needsLights&&_e.lightProbeGrid){const ot=_e.lightProbeGrid;_t.probesSH.value=ot.texture,_t.probesMin.value.copy(ot.boundingBox.min),_t.probesMax.value.copy(ot.boundingBox.max),_t.probesResolution.value.copy(ot.resolution)}pa.upload(I,kl(_e),_t,Y)}if(z.isShaderMaterial&&z.uniformsNeedUpdate===!0&&(pa.upload(I,kl(_e),_t,Y),z.uniformsNeedUpdate=!1),z.isSpriteMaterial&&nt.setValue(I,"center",B.center),nt.setValue(I,"modelViewMatrix",B.modelViewMatrix),nt.setValue(I,"normalMatrix",B.normalMatrix),nt.setValue(I,"modelMatrix",B.matrixWorld),z.uniformsGroups!==void 0){const ot=z.uniformsGroups;for(let Zn=0,Fi=ot.length;Zn<Fi;Zn++){const Hl=ot[Zn];j.update(Hl,$t),j.bind(Hl,$t)}}return $t}function Ud(S,N){S.ambientLightColor.needsUpdate=N,S.lightProbe.needsUpdate=N,S.directionalLights.needsUpdate=N,S.directionalLightShadows.needsUpdate=N,S.pointLights.needsUpdate=N,S.pointLightShadows.needsUpdate=N,S.spotLights.needsUpdate=N,S.spotLightShadows.needsUpdate=N,S.rectAreaLights.needsUpdate=N,S.hemisphereLights.needsUpdate=N}function Fd(S){return S.isMeshLambertMaterial||S.isMeshToonMaterial||S.isMeshPhongMaterial||S.isMeshStandardMaterial||S.isShadowMaterial||S.isShaderMaterial&&S.lights===!0}this.getActiveCubeFace=function(){return W},this.getActiveMipmapLevel=function(){return V},this.getRenderTarget=function(){return Q},this.setRenderTargetTextures=function(S,N,H){const z=G.get(S);z.__autoAllocateDepthBuffer=S.resolveDepthBuffer===!1,z.__autoAllocateDepthBuffer===!1&&(z.__useRenderToTexture=!1),G.get(S.texture).__webglTexture=N,G.get(S.depthTexture).__webglTexture=z.__autoAllocateDepthBuffer?void 0:H,z.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(S,N){const H=G.get(S);H.__webglFramebuffer=N,H.__useDefaultFramebuffer=N===void 0},this.setRenderTarget=function(S,N=0,H=0){Q=S,W=N,V=H;let z=null,B=!1,pe=!1;if(S){const fe=G.get(S);if(fe.__useDefaultFramebuffer!==void 0){_.bindFramebuffer(I.FRAMEBUFFER,fe.__webglFramebuffer),se.copy(S.viewport),ge.copy(S.scissor),Ve=S.scissorTest,_.viewport(se),_.scissor(ge),_.setScissorTest(Ve),te=-1;return}else if(fe.__webglFramebuffer===void 0)Y.setupRenderTarget(S);else if(fe.__hasExternalTextures)Y.rebindTextures(S,G.get(S.texture).__webglTexture,G.get(S.depthTexture).__webglTexture);else if(S.depthBuffer){const ke=S.depthTexture;if(fe.__boundDepthTexture!==ke){if(ke!==null&&G.has(ke)&&(S.width!==ke.image.width||S.height!==ke.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");Y.setupDepthRenderbuffer(S)}}const ye=S.texture;(ye.isData3DTexture||ye.isDataArrayTexture||ye.isCompressedArrayTexture)&&(pe=!0);const Ae=G.get(S).__webglFramebuffer;S.isWebGLCubeRenderTarget?(Array.isArray(Ae[N])?z=Ae[N][H]:z=Ae[N],B=!0):S.samples>0&&Y.useMultisampledRTT(S)===!1?z=G.get(S).__webglMultisampledFramebuffer:Array.isArray(Ae)?z=Ae[H]:z=Ae,se.copy(S.viewport),ge.copy(S.scissor),Ve=S.scissorTest}else se.copy(De).multiplyScalar(ne).floor(),ge.copy(Re).multiplyScalar(ne).floor(),Ve=Me;if(H!==0&&(z=X),_.bindFramebuffer(I.FRAMEBUFFER,z)&&_.drawBuffers(S,z),_.viewport(se),_.scissor(ge),_.setScissorTest(Ve),B){const fe=G.get(S.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 ye=0;ye<S.textures.length;ye++){const Ae=G.get(S.textures[ye]);I.framebufferTextureLayer(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0+ye,Ae.__webglTexture,H,fe)}}else if(S!==null&&H!==0){const fe=G.get(S.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,fe.__webglTexture,H)}te=-1},this.readRenderTargetPixels=function(S,N,H,z,B,pe,ve,fe=0){if(!(S&&S.isWebGLRenderTarget)){Xe("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ye=G.get(S).__webglFramebuffer;if(S.isWebGLCubeRenderTarget&&ve!==void 0&&(ye=ye[ve]),ye){_.bindFramebuffer(I.FRAMEBUFFER,ye);try{const Ae=S.textures[fe],ke=Ae.format,He=Ae.type;if(S.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+fe),!T.textureFormatReadable(ke)){Xe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!T.textureTypeReadable(He)){Xe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}N>=0&&N<=S.width-z&&H>=0&&H<=S.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;_.bindFramebuffer(I.FRAMEBUFFER,Ae)}}},this.readRenderTargetPixelsAsync=async function(S,N,H,z,B,pe,ve,fe=0){if(!(S&&S.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ye=G.get(S).__webglFramebuffer;if(S.isWebGLCubeRenderTarget&&ve!==void 0&&(ye=ye[ve]),ye)if(N>=0&&N<=S.width-z&&H>=0&&H<=S.height-B){_.bindFramebuffer(I.FRAMEBUFFER,ye);const Ae=S.textures[fe],ke=Ae.format,He=Ae.type;if(S.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+fe),!T.textureFormatReadable(ke))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!T.textureTypeReadable(He))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const we=I.createBuffer();I.bindBuffer(I.PIXEL_PACK_BUFFER,we),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 je=Q!==null?G.get(Q).__webglFramebuffer:null;_.bindFramebuffer(I.FRAMEBUFFER,je);const gt=I.fenceSync(I.SYNC_GPU_COMMANDS_COMPLETE,0);return I.flush(),await op(I,gt,4),I.bindBuffer(I.PIXEL_PACK_BUFFER,we),I.getBufferSubData(I.PIXEL_PACK_BUFFER,0,pe),I.deleteBuffer(we),I.deleteSync(gt),pe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(S,N=null,H=0){const z=Math.pow(2,-H),B=Math.floor(S.image.width*z),pe=Math.floor(S.image.height*z),ve=N!==null?N.x:0,fe=N!==null?N.y:0;Y.setTexture2D(S,0),I.copyTexSubImage2D(I.TEXTURE_2D,H,0,0,ve,fe,B,pe),_.unbindTexture()},this.copyTextureToTexture=function(S,N,H=null,z=null,B=0,pe=0){let ve,fe,ye,Ae,ke,He,we,je,gt;const mt=S.isCompressedTexture?S.mipmaps[pe]:S.image;if(H!==null)ve=H.max.x-H.min.x,fe=H.max.y-H.min.y,ye=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 _t=Math.pow(2,-B);ve=Math.floor(mt.width*_t),fe=Math.floor(mt.height*_t),S.isDataArrayTexture?ye=mt.depth:S.isData3DTexture?ye=Math.floor(mt.depth*_t):ye=1,Ae=0,ke=0,He=0}z!==null?(we=z.x,je=z.y,gt=z.z):(we=0,je=0,gt=0);const tt=he.convert(N.format),Dt=he.convert(N.type);let _e;N.isData3DTexture?(Y.setTexture3D(N,0),_e=I.TEXTURE_3D):N.isDataArrayTexture||N.isCompressedArrayTexture?(Y.setTexture2DArray(N,0),_e=I.TEXTURE_2D_ARRAY):(Y.setTexture2D(N,0),_e=I.TEXTURE_2D),_.activeTexture(I.TEXTURE0),_.pixelStorei(I.UNPACK_FLIP_Y_WEBGL,N.flipY),_.pixelStorei(I.UNPACK_PREMULTIPLY_ALPHA_WEBGL,N.premultiplyAlpha),_.pixelStorei(I.UNPACK_ALIGNMENT,N.unpackAlignment);const Wt=_.getParameter(I.UNPACK_ROW_LENGTH),Ke=_.getParameter(I.UNPACK_IMAGE_HEIGHT),$t=_.getParameter(I.UNPACK_SKIP_PIXELS),_n=_.getParameter(I.UNPACK_SKIP_ROWS),Yn=_.getParameter(I.UNPACK_SKIP_IMAGES);_.pixelStorei(I.UNPACK_ROW_LENGTH,mt.width),_.pixelStorei(I.UNPACK_IMAGE_HEIGHT,mt.height),_.pixelStorei(I.UNPACK_SKIP_PIXELS,Ae),_.pixelStorei(I.UNPACK_SKIP_ROWS,ke),_.pixelStorei(I.UNPACK_SKIP_IMAGES,He);const Ui=S.isDataArrayTexture||S.isData3DTexture,nt=N.isDataArrayTexture||N.isData3DTexture;if(S.isDepthTexture){const _t=G.get(S),Kn=G.get(N),ot=G.get(_t.__renderTarget),Zn=G.get(Kn.__renderTarget);_.bindFramebuffer(I.READ_FRAMEBUFFER,ot.__webglFramebuffer),_.bindFramebuffer(I.DRAW_FRAMEBUFFER,Zn.__webglFramebuffer);for(let Fi=0;Fi<ye;Fi++)Ui&&(I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,G.get(S).__webglTexture,B,He+Fi),I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,G.get(N).__webglTexture,pe,gt+Fi)),I.blitFramebuffer(Ae,ke,ve,fe,we,je,ve,fe,I.DEPTH_BUFFER_BIT,I.NEAREST);_.bindFramebuffer(I.READ_FRAMEBUFFER,null),_.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else if(B!==0||S.isRenderTargetTexture||G.has(S)){const _t=G.get(S),Kn=G.get(N);_.bindFramebuffer(I.READ_FRAMEBUFFER,q),_.bindFramebuffer(I.DRAW_FRAMEBUFFER,F);for(let ot=0;ot<ye;ot++)Ui?I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,_t.__webglTexture,B,He+ot):I.framebufferTexture2D(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,_t.__webglTexture,B),nt?I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,Kn.__webglTexture,pe,gt+ot):I.framebufferTexture2D(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,Kn.__webglTexture,pe),B!==0?I.blitFramebuffer(Ae,ke,ve,fe,we,je,ve,fe,I.COLOR_BUFFER_BIT,I.NEAREST):nt?I.copyTexSubImage3D(_e,pe,we,je,gt+ot,Ae,ke,ve,fe):I.copyTexSubImage2D(_e,pe,we,je,Ae,ke,ve,fe);_.bindFramebuffer(I.READ_FRAMEBUFFER,null),_.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else nt?S.isDataTexture||S.isData3DTexture?I.texSubImage3D(_e,pe,we,je,gt,ve,fe,ye,tt,Dt,mt.data):N.isCompressedArrayTexture?I.compressedTexSubImage3D(_e,pe,we,je,gt,ve,fe,ye,tt,mt.data):I.texSubImage3D(_e,pe,we,je,gt,ve,fe,ye,tt,Dt,mt):S.isDataTexture?I.texSubImage2D(I.TEXTURE_2D,pe,we,je,ve,fe,tt,Dt,mt.data):S.isCompressedTexture?I.compressedTexSubImage2D(I.TEXTURE_2D,pe,we,je,mt.width,mt.height,tt,mt.data):I.texSubImage2D(I.TEXTURE_2D,pe,we,je,ve,fe,tt,Dt,mt);_.pixelStorei(I.UNPACK_ROW_LENGTH,Wt),_.pixelStorei(I.UNPACK_IMAGE_HEIGHT,Ke),_.pixelStorei(I.UNPACK_SKIP_PIXELS,$t),_.pixelStorei(I.UNPACK_SKIP_ROWS,_n),_.pixelStorei(I.UNPACK_SKIP_IMAGES,Yn),pe===0&&N.generateMipmaps&&I.generateMipmap(_e),_.unbindTexture()},this.initRenderTarget=function(S){G.get(S).__webglFramebuffer===void 0&&Y.setupRenderTarget(S)},this.initTexture=function(S){S.isCubeTexture?Y.setTextureCube(S,0):S.isData3DTexture?Y.setTexture3D(S,0):S.isDataArrayTexture||S.isCompressedArrayTexture?Y.setTexture2DArray(S,0):Y.setTexture2D(S,0),_.unbindTexture()},this.resetState=function(){W=0,V=0,Q=null,_.reset(),me.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Rn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=qe._getDrawingBufferColorSpace(e),t.unpackColorSpace=qe._getUnpackColorSpace()}}const Wc=Math.PI/180,lu=180/Math.PI;function hr(i,e,t){return Math.max(e,Math.min(t,i))}const ni=[{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 ma(i,e,t){return i+(e-i)*t}function Ta(i,e,t){return[ma(i[0],e[0],t),ma(i[1],e[1],t),ma(i[2],e[2],t)]}function Y0(i){const e=Math.max(ni[0].altitudeDeg,Math.min(ni[ni.length-1].altitudeDeg,i));for(let n=0;n<ni.length-1;n++){const s=ni[n],r=ni[n+1];if(e>=s.altitudeDeg&&e<=r.altitudeDeg){const a=(e-s.altitudeDeg)/(r.altitudeDeg-s.altitudeDeg);return{zenith:Ta(s.zenith,r.zenith,a),horizon:Ta(s.horizon,r.horizon,a)}}}const t=ni[ni.length-1];return{zenith:t.zenith,horizon:t.horizon}}function qv(i){const e=K0,t=-4;if(i<=-18)return e;if(i>=0)return t;const n=(i+18)/18;return ma(e,t,n)}const Yv=-1.5,K0=6.5,hu=K0,Kv=1.6;function uu(i){const e=(hu-i)/(hu-Yv);return hr(e,0,1)**Kv}function ri(i,e,t){const n=i*Wc,s=e*Wc,r=t*Math.cos(n);return{x:r*Math.sin(s),y:t*Math.sin(n),z:-r*Math.cos(s)}}function Zv(i,e,t){const n=Math.sqrt(i*i+e*e+t*t),s=n===0?0:Math.asin(hr(e/n,-1,1))*lu,r=(Math.atan2(i,-t)*lu+360)%360;return{altitudeDeg:s,azimuthDeg:r}}function $v(i,e){const t=Math.abs(i-e)%360;return t>180?360-t:t}function Jv(i,e,t){const n=Math.max(0,1-$v(i,e)/90),s=Math.max(0,1-Math.abs(t)/18);return n*s}function Qv(i,e,t,n){const{zenith:s,horizon:r}=Y0(n),a=hr((i+90)/180,0,1),o=Ta(r,s,a),c=Jv(e,t,n);return c<=0?o:Ta(o,r,c*(1-a)*.8)}function du(i){return .12+.88*i}const jv=-4;function ex(i){return Math.max(0,jv-i)}const tx=6,nx=60;function ix(i){return Math.min(nx,tx*Math.sqrt(i))}const sx=3,rx=.55;function ax(i){return rx*hr(i/sx,0,1)}function ox(i){const e=Math.max(i,-4),t=Math.sin(e*Wc)+.50572*Math.pow(e+6.07995,-1.6364);return hr(1/t,1,40)}function Bs(i){const e=ox(i)-1;return[1,Math.exp(-.022*e),Math.exp(-.062*e)]}const Z0=[{maxBrightness:.35,size:1.2},{maxBrightness:.7,size:2},{maxBrightness:1/0,size:3.2}];function cx(i){return Z0.findIndex(e=>i<=e.maxBrightness)}const lx=.25,fu=.3,hx=2.2;function ux(i,{phase:e,speedFactor:t},n){const r=1+lx*(fu+(1-fu)*i)*Math.sin(n*hx*t+e);return Math.min(1,Math.max(0,r))}/**
|
|
4415
|
+
}`;class Av{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new b0(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 Bt({vertexShader:bv,fragmentShader:Tv,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new ht(new As(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class wv extends Ni{constructor(e,t){super();const n=this;let s=null,r=1,a=null,o="local-floor",c=1,l=null,h=null,d=null,u=null,p=null,g=null;const M=typeof XRWebGLBinding<"u",m=new Av,f={},T=t.getContextAttributes();let w=null,x=null;const y=[],b=[],R=new Fe;let v=null;const E=new Zt;E.viewport=new ut;const P=new Zt;P.viewport=new ut;const C=[E,P],L=new Op;let X=null,q=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let re=y[Z];return re===void 0&&(re=new $a,y[Z]=re),re.getTargetRaySpace()},this.getControllerGrip=function(Z){let re=y[Z];return re===void 0&&(re=new $a,y[Z]=re),re.getGripSpace()},this.getHand=function(Z){let re=y[Z];return re===void 0&&(re=new $a,y[Z]=re),re.getHandSpace()};function F(Z){const re=b.indexOf(Z.inputSource);if(re===-1)return;const ne=y[re];ne!==void 0&&(ne.update(Z.inputSource,Z.frame,l||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<y.length;Z++){const re=b[Z];re!==null&&(b[Z]=null,y[Z].disconnect(re))}X=null,q=null,m.reset();for(const Z in f)delete f[Z];e.setRenderTarget(w),p=null,u=null,d=null,s=null,x=null,We.stop(),n.isPresenting=!1,e.setPixelRatio(v),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 l||a},this.setReferenceSpace=function(Z){l=Z},this.getBaseLayer=function(){return u!==null?u:p},this.getBinding=function(){return d===null&&M&&(d=new XRWebGLBinding(s,t)),d},this.getFrame=function(){return g},this.getSession=function(){return s},this.setSession=async function(Z){if(s=Z,s!==null){if(w=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),T.xrCompatible!==!0&&await t.makeXRCompatible(),v=e.getPixelRatio(),e.getSize(R),M&&"createProjectionLayer"in XRWebGLBinding.prototype){let ne=null,k=null,Pe=null;T.depth&&(Pe=T.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ne=T.stencil?wi:Wn,k=T.stencil?rr:Dn);const De={colorFormat:t.RGBA8,depthFormat:Pe,scaleFactor:r};d=this.getBinding(),u=d.createProjectionLayer(De),s.updateRenderState({layers:[u]}),e.setPixelRatio(1),e.setSize(u.textureWidth,u.textureHeight,!1),x=new pn(u.textureWidth,u.textureHeight,{format:dn,type:$t,depthTexture:new ys(u.textureWidth,u.textureHeight,k,void 0,void 0,void 0,void 0,void 0,void 0,ne),stencilBuffer:T.stencil,colorSpace:e.outputColorSpace,samples:T.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}else{const ne={antialias:T.antialias,alpha:!0,depth:T.depth,stencil:T.stencil,framebufferScaleFactor:r};p=new XRWebGLLayer(s,t,ne),s.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),x=new pn(p.framebufferWidth,p.framebufferHeight,{format:dn,type:$t,colorSpace:e.outputColorSpace,stencilBuffer:T.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}x.isXRRenderTarget=!0,this.setFoveation(c),l=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,y[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 De=0;De<y.length;De++)if(De>=b.length){b.push(ne),k=De;break}else if(b[De]===null){b[De]=ne,k=De;break}if(k===-1)break}const Pe=y[k];Pe&&Pe.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),Pe=re.projectionMatrix.elements,De=ne.projectionMatrix.elements,Re=Pe[14]/(Pe[10]-1),xe=Pe[14]/(Pe[10]+1),Ue=(Pe[9]+1)/Pe[5],Ie=(Pe[9]-1)/Pe[5],Le=(Pe[8]-1)/Pe[0],Ze=(De[8]+1)/De[0],$e=Re*Le,dt=Re*Ze,ct=k/(-Le+Ze),ft=ct*-Le;if(re.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(ft),Z.translateZ(ct),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert(),Pe[10]===-1)Z.projectionMatrix.copy(re.projectionMatrix),Z.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{const xt=Re+ct,I=xe+ct,Vt=$e-ft,Je=dt+(k-ft),A=Ue*xe/I*xt,_=Ie*xe/I*xt;Z.projectionMatrix.makePerspective(Vt,Je,A,_,xt,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=P.near=E.near=re,L.far=P.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,P.layers.mask=L.layers.mask&-3;const k=Z.parent,Pe=L.cameras;se(L,k);for(let De=0;De<Pe.length;De++)se(Pe[De],k);Pe.length===2?ee(L,E,P):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=Lc*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1)}this.getCamera=function(){return L},this.getFoveation=function(){if(!(u===null&&p===null))return c},this.setFoveation=function(Z){c=Z,u!==null&&(u.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 st(Z,re){if(h=re.getViewerPose(l||a),g=re,h!==null){const ne=h.views;p!==null&&(e.setRenderTargetFramebuffer(x,p.framebuffer),e.setRenderTarget(x));let k=!1;ne.length!==L.cameras.length&&(L.cameras.length=0,k=!0);for(let xe=0;xe<ne.length;xe++){const Ue=ne[xe];let Ie=null;if(p!==null)Ie=p.getViewport(Ue);else{const Ze=d.getViewSubImage(u,Ue);Ie=Ze.viewport,xe===0&&(e.setRenderTargetTextures(x,Ze.colorTexture,Ze.depthStencilTexture),e.setRenderTarget(x))}let Le=C[xe];Le===void 0&&(Le=new Zt,Le.layers.enable(xe),Le.viewport=new ut,C[xe]=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),xe===0&&(L.matrix.copy(Le.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale)),k===!0&&L.cameras.push(Le)}const Pe=s.enabledFeatures;if(Pe&&Pe.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&M){d=n.getBinding();const xe=d.getDepthInformation(ne[0]);xe&&xe.isValid&&xe.texture&&m.init(xe,s.renderState)}if(Pe&&Pe.includes("camera-access")&&M){e.state.unbindTexture(),d=n.getBinding();for(let xe=0;xe<ne.length;xe++){const Ue=ne[xe].camera;if(Ue){let Ie=f[Ue];Ie||(Ie=new b0,f[Ue]=Ie);const Le=d.getCameraImage(Ue);Ie.sourceTexture=Le}}}}for(let ne=0;ne<y.length;ne++){const k=b[ne],Pe=y[ne];k!==null&&Pe!==void 0&&Pe.update(k,re,l||a)}Ve&&Ve(Z,re),re.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:re}),g=null}const We=new C0;We.setAnimationLoop(st),this.setAnimationLoop=function(Z){Ve=Z},this.dispose=function(){}}}const Rv=new ot,F0=new ze;F0.set(-1,0,0,0,1,0,0,0,1);function Cv(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,T0(i)),f.isFog?(m.fogNear.value=f.near,m.fogFar.value=f.far):f.isFogExp2&&(m.fogDensity.value=f.density)}function s(m,f,T,w,x){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),d(m,f)):f.isMeshPhongMaterial?(r(m,f),h(m,f),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)):f.isMeshStandardMaterial?(r(m,f),u(m,f),f.isMeshPhysicalMaterial&&p(m,f,x)):f.isMeshMatcapMaterial?(r(m,f),g(m,f)):f.isMeshDepthMaterial?r(m,f):f.isMeshDistanceMaterial?(r(m,f),M(m,f)):f.isMeshNormalMaterial?r(m,f):f.isLineBasicMaterial?(a(m,f),f.isLineDashedMaterial&&o(m,f)):f.isPointsMaterial?c(m,f,T,w):f.isSpriteMaterial?l(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===Dt&&(m.bumpScale.value*=-1)),f.normalMap&&(m.normalMap.value=f.normalMap,t(f.normalMap,m.normalMapTransform),m.normalScale.value.copy(f.normalScale),f.side===Dt&&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 T=e.get(f),w=T.envMap,x=T.envMapRotation;w&&(m.envMap.value=w,m.envMapRotation.value.setFromMatrix4(Rv.makeRotationFromEuler(x)).transpose(),w.isCubeTexture&&w.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(F0),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 c(m,f,T,w){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.size.value=f.size*T,m.scale.value=w*.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 l(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 d(m,f){f.gradientMap&&(m.gradientMap.value=f.gradientMap)}function u(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,T){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===Dt&&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=T.texture,m.transmissionSamplerSize.value.set(T.width,T.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 M(m,f){const T=e.get(f).light;m.referencePosition.value.setFromMatrixPosition(T.matrixWorld),m.nearDistance.value=T.shadow.camera.near,m.farDistance.value=T.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function Pv(i,e,t,n){let s={},r={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(x,y){const b=y.program;n.uniformBlockBinding(x,b)}function l(x,y){let b=s[x.id];b===void 0&&(m(x),b=h(x),s[x.id]=b,x.addEventListener("dispose",T));const R=y.program;n.updateUBOMapping(x,R);const v=e.render.frame;r[x.id]!==v&&(u(x),r[x.id]=v)}function h(x){const y=d();x.__bindingPointIndex=y;const b=i.createBuffer(),R=x.__size,v=x.usage;return i.bindBuffer(i.UNIFORM_BUFFER,b),i.bufferData(i.UNIFORM_BUFFER,R,v),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,y,b),b}function d(){for(let x=0;x<o;x++)if(a.indexOf(x)===-1)return a.push(x),x;return Xe("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(x){const y=s[x.id],b=x.uniforms,R=x.__cache;i.bindBuffer(i.UNIFORM_BUFFER,y);for(let v=0,E=b.length;v<E;v++){const P=b[v];if(Array.isArray(P))for(let C=0,L=P.length;C<L;C++)p(P[C],v,C,R);else p(P,v,0,R)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function p(x,y,b,R){if(M(x,y,b,R)===!0){const v=x.__offset,E=x.value;if(Array.isArray(E)){let P=0;for(let C=0;C<E.length;C++){const L=E[C],X=f(L);g(L,x.__data,P),typeof L!="number"&&typeof L!="boolean"&&!L.isMatrix3&&!ArrayBuffer.isView(L)&&(P+=X.storage/Float32Array.BYTES_PER_ELEMENT)}}else g(E,x.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,v,x.__data)}}function g(x,y,b){typeof x=="number"||typeof x=="boolean"?y[0]=x:x.isMatrix3?(y[0]=x.elements[0],y[1]=x.elements[1],y[2]=x.elements[2],y[3]=0,y[4]=x.elements[3],y[5]=x.elements[4],y[6]=x.elements[5],y[7]=0,y[8]=x.elements[6],y[9]=x.elements[7],y[10]=x.elements[8],y[11]=0):ArrayBuffer.isView(x)?y.set(new x.constructor(x.buffer,x.byteOffset,y.length)):x.toArray(y,b)}function M(x,y,b,R){const v=x.value,E=y+"_"+b;if(R[E]===void 0)return typeof v=="number"||typeof v=="boolean"?R[E]=v:ArrayBuffer.isView(v)?R[E]=v.slice():R[E]=v.clone(),!0;{const P=R[E];if(typeof v=="number"||typeof v=="boolean"){if(P!==v)return R[E]=v,!0}else{if(ArrayBuffer.isView(v))return!0;if(P.equals(v)===!1)return P.copy(v),!0}}return!1}function m(x){const y=x.uniforms;let b=0;const R=16;for(let E=0,P=y.length;E<P;E++){const C=Array.isArray(y[E])?y[E]:[y[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 v=b%R;return v>0&&(b+=R-v),x.__size=b,x.__cache={},this}function f(x){const y={boundary:0,storage:0};return typeof x=="number"||typeof x=="boolean"?(y.boundary=4,y.storage=4):x.isVector2?(y.boundary=8,y.storage=8):x.isVector3||x.isColor?(y.boundary=16,y.storage=12):x.isVector4?(y.boundary=16,y.storage=16):x.isMatrix3?(y.boundary=48,y.storage=48):x.isMatrix4?(y.boundary=64,y.storage=64):x.isTexture?Oe("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(x)?(y.boundary=16,y.storage=x.byteLength):Oe("WebGLRenderer: Unsupported uniform value type.",x),y}function T(x){const y=x.target;y.removeEventListener("dispose",T);const b=a.indexOf(y.__bindingPointIndex);a.splice(b,1),i.deleteBuffer(s[y.id]),delete s[y.id],delete r[y.id]}function w(){for(const x in s)i.deleteBuffer(s[x]);a=[],s={},r={}}return{bind:c,update:l,dispose:w}}const Dv=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let xn=null;function Iv(){return xn===null&&(xn=new xp(Dv,16,16,Di,Vn),xn.name="DFG_LUT",xn.minFilter=Ft,xn.magFilter=Ft,xn.wrapS=Bn,xn.wrapT=Bn,xn.generateMipmaps=!1,xn.needsUpdate=!0),xn}class Lv{constructor(e={}){const{canvas:t=$f(),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:d=!1,reversedDepthBuffer:u=!1,outputBufferType:p=$t}=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 M=p,m=new Set([ml,pl,fl]),f=new Set([$t,Dn,sr,rr,ul,dl]),T=new Uint32Array(4),w=new Int32Array(4),x=new U;let y=null,b=null;const R=[],v=[];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=Pn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const P=this;let C=!1,L=null,X=null,q=null,F=null;this._outputColorSpace=nn;let W=0,V=0,Q=null,te=-1,ee=null;const se=new ut,ge=new ut;let Ve=null;const st=new Me(0);let We=0,Z=t.width,re=t.height,ne=1,k=null,Pe=null;const De=new ut(0,0,Z,re),Re=new ut(0,0,Z,re);let xe=!1;const Ue=new yl;let Ie=!1,Le=!1;const Ze=new ot,$e=new U,dt=new ut,ct={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ft=!1;function xt(){return Q===null?ne:1}let I=n;function Vt(S,N){return t.getContext(S,N)}try{const S={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${cl}`),t.addEventListener("webglcontextlost",pt,!1),t.addEventListener("webglcontextrestored",rt,!1),t.addEventListener("webglcontextcreationerror",mn,!1),I===null){const N="webgl2";if(I=Vt(N,S),I===null)throw Vt(N)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(S){throw Xe("WebGLRenderer: "+S.message),S}let Je,A,_,O,G,Y,ie,oe,K,J,ce,Te,ue,le,Ce,Ne,Be,D,ae,$,he,me,j;function be(){Je=new I1(I),Je.init(),he=new Ev(I,Je),A=new b1(I,Je,e,he),_=new Sv(I,Je),A.reversedDepthBuffer&&u&&_.buffers.depth.setReversed(!0),X=I.createFramebuffer(),q=I.createFramebuffer(),F=I.createFramebuffer(),O=new U1(I),G=new ov,Y=new yv(I,Je,_,G,A,he,O),ie=new D1(P),oe=new Bp(I),me=new y1(I,oe),K=new L1(I,oe,O,me),J=new O1(I,K,oe,me,O),D=new F1(I,A,Y),Ce=new T1(G),ce=new av(P,ie,Je,A,me,Ce),Te=new Cv(P,G),ue=new lv,le=new mv(Je),Be=new S1(P,ie,_,J,g,c),Ne=new Mv(P,J,A),j=new Pv(I,O,A,_),ae=new E1(I,Je,O),$=new N1(I,Je,O),O.programs=ce.programs,P.capabilities=A,P.extensions=Je,P.properties=G,P.renderLists=ue,P.shadowMap=Ne,P.state=_,P.info=O}be(),M!==$t&&(E=new B1(M,t.width,t.height,o,s,r));const Se=new wv(P,I);this.xr=Se,this.getContext=function(){return I},this.getContextAttributes=function(){return I.getContextAttributes()},this.forceContextLoss=function(){const S=Je.get("WEBGL_lose_context");S&&S.loseContext()},this.forceContextRestore=function(){const S=Je.get("WEBGL_lose_context");S&&S.restoreContext()},this.getPixelRatio=function(){return ne},this.setPixelRatio=function(S){S!==void 0&&(ne=S,this.setSize(Z,re,!1))},this.getSize=function(S){return S.set(Z,re)},this.setSize=function(S,N,H=!0){if(Se.isPresenting){Oe("WebGLRenderer: Can't change size while VR device is presenting.");return}Z=S,re=N,t.width=Math.floor(S*ne),t.height=Math.floor(N*ne),H===!0&&(t.style.width=S+"px",t.style.height=N+"px"),E!==null&&E.setSize(t.width,t.height),this.setViewport(0,0,S,N)},this.getDrawingBufferSize=function(S){return S.set(Z*ne,re*ne).floor()},this.setDrawingBufferSize=function(S,N,H){Z=S,re=N,ne=H,t.width=Math.floor(S*H),t.height=Math.floor(N*H),this.setViewport(0,0,S,N)},this.setEffects=function(S){if(M===$t){Xe("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(S){for(let N=0;N<S.length;N++)if(S[N].isOutputPass===!0){Oe("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}E.setEffects(S||[])},this.getCurrentViewport=function(S){return S.copy(se)},this.getViewport=function(S){return S.copy(De)},this.setViewport=function(S,N,H,z){S.isVector4?De.set(S.x,S.y,S.z,S.w):De.set(S,N,H,z),_.viewport(se.copy(De).multiplyScalar(ne).round())},this.getScissor=function(S){return S.copy(Re)},this.setScissor=function(S,N,H,z){S.isVector4?Re.set(S.x,S.y,S.z,S.w):Re.set(S,N,H,z),_.scissor(ge.copy(Re).multiplyScalar(ne).round())},this.getScissorTest=function(){return xe},this.setScissorTest=function(S){_.setScissorTest(xe=S)},this.setOpaqueSort=function(S){k=S},this.setTransparentSort=function(S){Pe=S},this.getClearColor=function(S){return S.copy(Be.getClearColor())},this.setClearColor=function(){Be.setClearColor(...arguments)},this.getClearAlpha=function(){return Be.getClearAlpha()},this.setClearAlpha=function(){Be.setClearAlpha(...arguments)},this.clear=function(S=!0,N=!0,H=!0){let z=0;if(S){let B=!1;if(Q!==null){const pe=Q.texture.format;B=m.has(pe)}if(B){const pe=Q.texture.type,ve=f.has(pe),fe=Be.getClearColor(),ye=Be.getClearAlpha(),Ae=fe.r,ke=fe.g,He=fe.b;ve?(T[0]=Ae,T[1]=ke,T[2]=He,T[3]=ye,I.clearBufferuiv(I.COLOR,0,T)):(w[0]=Ae,w[1]=ke,w[2]=He,w[3]=ye,I.clearBufferiv(I.COLOR,0,w))}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(S){S.setRenderer(this),L=S},this.dispose=function(){t.removeEventListener("webglcontextlost",pt,!1),t.removeEventListener("webglcontextrestored",rt,!1),t.removeEventListener("webglcontextcreationerror",mn,!1),Be.dispose(),ue.dispose(),le.dispose(),G.dispose(),ie.dispose(),J.dispose(),me.dispose(),j.dispose(),ce.dispose(),Se.dispose(),Se.removeEventListener("sessionstart",Pl),Se.removeEventListener("sessionend",Dl),mi.stop()};function pt(S){S.preventDefault(),va("WebGLRenderer: Context Lost."),C=!0}function rt(){va("WebGLRenderer: Context Restored."),C=!1;const S=O.autoReset,N=Ne.enabled,H=Ne.autoUpdate,z=Ne.needsUpdate,B=Ne.type;be(),O.autoReset=S,Ne.enabled=N,Ne.autoUpdate=H,Ne.needsUpdate=z,Ne.type=B}function mn(S){Xe("WebGLRenderer: A WebGL context could not be created. Reason: ",S.statusMessage)}function gn(S){const N=S.target;N.removeEventListener("dispose",gn),Md(N)}function Md(S){Sd(S),G.remove(S)}function Sd(S){const N=G.get(S).programs;N!==void 0&&(N.forEach(function(H){ce.releaseProgram(H)}),S.isShaderMaterial&&ce.releaseShaderCache(S))}this.renderBufferDirect=function(S,N,H,z,B,pe){N===null&&(N=ct);const ve=B.isMesh&&B.matrixWorld.determinantAffine()<0,fe=bd(S,N,H,z,B);_.setMaterial(z,ve);let ye=H.index,Ae=1;if(z.wireframe===!0){if(ye=K.getWireframeAttribute(H),ye===void 0)return;Ae=2}const ke=H.drawRange,He=H.attributes.position;let we=ke.start*Ae,je=(ke.start+ke.count)*Ae;pe!==null&&(we=Math.max(we,pe.start*Ae),je=Math.min(je,(pe.start+pe.count)*Ae)),ye!==null?(we=Math.max(we,0),je=Math.min(je,ye.count)):He!=null&&(we=Math.max(we,0),je=Math.min(je,He.count));const gt=je-we;if(gt<0||gt===1/0)return;me.setup(B,z,fe,H,ye);let mt,tt=ae;if(ye!==null&&(mt=oe.get(ye),tt=$,tt.setIndex(mt)),B.isMesh)z.wireframe===!0?(_.setLineWidth(z.wireframeLinewidth*xt()),tt.setMode(I.LINES)):tt.setMode(I.TRIANGLES);else if(B.isLine){let It=z.linewidth;It===void 0&&(It=1),_.setLineWidth(It*xt()),B.isLineSegments?tt.setMode(I.LINES):B.isLineLoop?tt.setMode(I.LINE_LOOP):tt.setMode(I.LINE_STRIP)}else B.isPoints?tt.setMode(I.POINTS):B.isSprite&&tt.setMode(I.TRIANGLES);if(B.isBatchedMesh)if(Je.get("WEBGL_multi_draw"))tt.renderMultiDraw(B._multiDrawStarts,B._multiDrawCounts,B._multiDrawCount);else{const It=B._multiDrawStarts,_e=B._multiDrawCounts,Xt=B._multiDrawCount,Ke=ye?oe.get(ye).bytesPerElement:1,Jt=G.get(z).currentProgram.getUniforms();for(let _n=0;_n<Xt;_n++)Jt.setValue(I,"_gl_DrawID",_n),tt.render(It[_n]/Ke,_e[_n])}else if(B.isInstancedMesh)tt.renderInstances(we,gt,B.count);else if(H.isInstancedBufferGeometry){const It=H._maxInstanceCount!==void 0?H._maxInstanceCount:1/0,_e=Math.min(H.instanceCount,It);tt.renderInstances(we,gt,_e)}else tt.render(we,gt)};function Cl(S,N,H){S.transparent===!0&&S.side===An&&S.forceSinglePass===!1?(S.side=Dt,S.needsUpdate=!0,ur(S,N,H),S.side=di,S.needsUpdate=!0,ur(S,N,H),S.side=An):ur(S,N,H)}this.compile=function(S,N,H=null){H===null&&(H=S),b=le.get(H),b.init(N),v.push(b),H.traverseVisible(function(B){B.isLight&&B.layers.test(N.layers)&&(b.pushLight(B),B.castShadow&&b.pushShadow(B))}),S!==H&&S.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 S.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 ve=0;ve<pe.length;ve++){const fe=pe[ve];Cl(fe,H,B),z.add(fe)}else Cl(pe,H,B),z.add(pe)}),b=v.pop(),z},this.compileAsync=function(S,N,H=null){const z=this.compile(S,N,H);return new Promise(B=>{function pe(){if(z.forEach(function(ve){G.get(ve).currentProgram.isReady()&&z.delete(ve)}),z.size===0){B(S);return}setTimeout(pe,10)}Je.get("KHR_parallel_shader_compile")!==null?pe():setTimeout(pe,10)})};let Oa=null;function yd(S){Oa&&Oa(S)}function Pl(){mi.stop()}function Dl(){mi.start()}const mi=new C0;mi.setAnimationLoop(yd),typeof self<"u"&&mi.setContext(self),this.setAnimationLoop=function(S){Oa=S,Se.setAnimationLoop(S),S===null?mi.stop():mi.start()},Se.addEventListener("sessionstart",Pl),Se.addEventListener("sessionend",Dl),this.render=function(S,N){if(N!==void 0&&N.isCamera!==!0){Xe("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;L!==null&&L.renderStart(S,N);const H=Se.enabled===!0&&Se.isPresenting===!0,z=E!==null&&(Q===null||H)&&E.begin(P,Q);if(S.matrixWorldAutoUpdate===!0&&S.updateMatrixWorld(),N.parent===null&&N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),Se.enabled===!0&&Se.isPresenting===!0&&(E===null||E.isCompositing()===!1)&&(Se.cameraAutoUpdate===!0&&Se.updateCamera(N),N=Se.getCamera()),S.isScene===!0&&S.onBeforeRender(P,S,N,Q),b=le.get(S,v.length),b.init(N),b.state.textureUnits=Y.getTextureUnits(),v.push(b),Ze.multiplyMatrices(N.projectionMatrix,N.matrixWorldInverse),Ue.setFromProjectionMatrix(Ze,Cn,N.reversedDepth),Le=this.localClippingEnabled,Ie=Ce.init(this.clippingPlanes,Le),y=ue.get(S,R.length),y.init(),R.push(y),Se.enabled===!0&&Se.isPresenting===!0){const ve=P.xr.getDepthSensingMesh();ve!==null&&za(ve,N,-1/0,P.sortObjects)}za(S,N,0,P.sortObjects),y.finish(),P.sortObjects===!0&&y.sort(k,Pe,N.reversedDepth),ft=Se.enabled===!1||Se.isPresenting===!1||Se.hasDepthSensing()===!1,ft&&Be.addToRenderList(y,S),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Ie===!0&&Ce.beginShadows();const B=b.state.shadowsArray;if(Ne.render(B,S,N),Ie===!0&&Ce.endShadows(),(z&&E.hasRenderPass())===!1){const ve=y.opaque,fe=y.transmissive;if(b.setupLights(),N.isArrayCamera){const ye=N.cameras;if(fe.length>0)for(let Ae=0,ke=ye.length;Ae<ke;Ae++){const He=ye[Ae];Ll(ve,fe,S,He)}ft&&Be.render(S);for(let Ae=0,ke=ye.length;Ae<ke;Ae++){const He=ye[Ae];Il(y,S,He,He.viewport)}}else fe.length>0&&Ll(ve,fe,S,N),ft&&Be.render(S),Il(y,S,N)}Q!==null&&V===0&&(Y.updateMultisampleRenderTarget(Q),Y.updateRenderTargetMipmap(Q)),z&&E.end(P),S.isScene===!0&&S.onAfterRender(P,S,N),me.resetDefaultState(),te=-1,ee=null,v.pop(),v.length>0?(b=v[v.length-1],Y.setTextureUnits(b.state.textureUnits),Ie===!0&&Ce.setGlobalState(P.clippingPlanes,b.state.camera)):b=null,R.pop(),R.length>0?y=R[R.length-1]:y=null,L!==null&&L.renderEnd()};function za(S,N,H,z){if(S.visible===!1)return;if(S.layers.test(N.layers)){if(S.isGroup)H=S.renderOrder;else if(S.isLOD)S.autoUpdate===!0&&S.update(N);else if(S.isLightProbeGrid)b.pushLightProbeGrid(S);else if(S.isLight)b.pushLight(S),S.castShadow&&b.pushShadow(S);else if(S.isSprite){if(!S.frustumCulled||Ue.intersectsSprite(S)){z&&dt.setFromMatrixPosition(S.matrixWorld).applyMatrix4(Ze);const ve=J.update(S),fe=S.material;fe.visible&&y.push(S,ve,fe,H,dt.z,null)}}else if((S.isMesh||S.isLine||S.isPoints)&&(!S.frustumCulled||Ue.intersectsObject(S))){const ve=J.update(S),fe=S.material;if(z&&(S.boundingSphere!==void 0?(S.boundingSphere===null&&S.computeBoundingSphere(),dt.copy(S.boundingSphere.center)):(ve.boundingSphere===null&&ve.computeBoundingSphere(),dt.copy(ve.boundingSphere.center)),dt.applyMatrix4(S.matrixWorld).applyMatrix4(Ze)),Array.isArray(fe)){const ye=ve.groups;for(let Ae=0,ke=ye.length;Ae<ke;Ae++){const He=ye[Ae],we=fe[He.materialIndex];we&&we.visible&&y.push(S,ve,we,H,dt.z,He)}}else fe.visible&&y.push(S,ve,fe,H,dt.z,null)}}const pe=S.children;for(let ve=0,fe=pe.length;ve<fe;ve++)za(pe[ve],N,H,z)}function Il(S,N,H,z){const{opaque:B,transmissive:pe,transparent:ve}=S;b.setupLightsView(H),Ie===!0&&Ce.setGlobalState(P.clippingPlanes,H),z&&_.viewport(se.copy(z)),B.length>0&&hr(B,N,H),pe.length>0&&hr(pe,N,H),ve.length>0&&hr(ve,N,H),_.buffers.depth.setTest(!0),_.buffers.depth.setMask(!0),_.buffers.color.setMask(!0),_.setPolygonOffset(!1)}function Ll(S,N,H,z){if((H.isScene===!0?H.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[z.id]===void 0){const we=Je.has("EXT_color_buffer_half_float")||Je.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[z.id]=new pn(1,1,{generateMipmaps:!0,type:we?Vn:$t,minFilter:Ai,samples:Math.max(4,A.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:qe.workingColorSpace})}const pe=b.state.transmissionRenderTarget[z.id],ve=z.viewport||se;pe.setSize(ve.z*P.transmissionResolutionScale,ve.w*P.transmissionResolutionScale);const fe=P.getRenderTarget(),ye=P.getActiveCubeFace(),Ae=P.getActiveMipmapLevel();P.setRenderTarget(pe),P.getClearColor(st),We=P.getClearAlpha(),We<1&&P.setClearColor(16777215,.5),P.clear(),ft&&Be.render(H);const ke=P.toneMapping;P.toneMapping=Pn;const He=z.viewport;if(z.viewport!==void 0&&(z.viewport=void 0),b.setupLightsView(z),Ie===!0&&Ce.setGlobalState(P.clippingPlanes,z),hr(S,H,z),Y.updateMultisampleRenderTarget(pe),Y.updateRenderTargetMipmap(pe),Je.has("WEBGL_multisampled_render_to_texture")===!1){let we=!1;for(let je=0,gt=N.length;je<gt;je++){const mt=N[je],{object:tt,geometry:It,material:_e,group:Xt}=mt;if(_e.side===An&&tt.layers.test(z.layers)){const Ke=_e.side;_e.side=Dt,_e.needsUpdate=!0,Nl(tt,H,z,It,_e,Xt),_e.side=Ke,_e.needsUpdate=!0,we=!0}}we===!0&&(Y.updateMultisampleRenderTarget(pe),Y.updateRenderTargetMipmap(pe))}P.setRenderTarget(fe,ye,Ae),P.setClearColor(st,We),He!==void 0&&(z.viewport=He),P.toneMapping=ke}function hr(S,N,H){const z=N.isScene===!0?N.overrideMaterial:null;for(let B=0,pe=S.length;B<pe;B++){const ve=S[B],{object:fe,geometry:ye,group:Ae}=ve;let ke=ve.material;ke.allowOverride===!0&&z!==null&&(ke=z),fe.layers.test(H.layers)&&Nl(fe,N,H,ye,ke,Ae)}}function Nl(S,N,H,z,B,pe){S.onBeforeRender(P,N,H,z,B,pe),S.modelViewMatrix.multiplyMatrices(H.matrixWorldInverse,S.matrixWorld),S.normalMatrix.getNormalMatrix(S.modelViewMatrix),B.onBeforeRender(P,N,H,z,S,pe),B.transparent===!0&&B.side===An&&B.forceSinglePass===!1?(B.side=Dt,B.needsUpdate=!0,P.renderBufferDirect(H,N,z,B,S,pe),B.side=di,B.needsUpdate=!0,P.renderBufferDirect(H,N,z,B,S,pe),B.side=An):P.renderBufferDirect(H,N,z,B,S,pe),S.onAfterRender(P,N,H,z,B,pe)}function ur(S,N,H){N.isScene!==!0&&(N=ct);const z=G.get(S),B=b.state.lights,pe=b.state.shadowsArray,ve=B.state.version,fe=ce.getParameters(S,B.state,pe,N,H,b.state.lightProbeGridArray),ye=ce.getProgramCacheKey(fe);let Ae=z.programs;z.environment=S.isMeshStandardMaterial||S.isMeshLambertMaterial||S.isMeshPhongMaterial?N.environment:null,z.fog=N.fog;const ke=S.isMeshStandardMaterial||S.isMeshLambertMaterial&&!S.envMap||S.isMeshPhongMaterial&&!S.envMap;z.envMap=ie.get(S.envMap||z.environment,ke),z.envMapRotation=z.environment!==null&&S.envMap===null?N.environmentRotation:S.envMapRotation,Ae===void 0&&(S.addEventListener("dispose",gn),Ae=new Map,z.programs=Ae);let He=Ae.get(ye);if(He!==void 0){if(z.currentProgram===He&&z.lightsStateVersion===ve)return Fl(S,fe),He}else fe.uniforms=ce.getUniforms(S),L!==null&&S.isNodeMaterial&&L.build(S,H,fe),S.onBeforeCompile(fe,P),He=ce.acquireProgram(fe,ye),Ae.set(ye,He),z.uniforms=fe.uniforms;const we=z.uniforms;return(!S.isShaderMaterial&&!S.isRawShaderMaterial||S.clipping===!0)&&(we.clippingPlanes=Ce.uniform),Fl(S,fe),z.needsLights=Ad(S),z.lightsStateVersion=ve,z.needsLights&&(we.ambientLightColor.value=B.state.ambient,we.lightProbe.value=B.state.probe,we.directionalLights.value=B.state.directional,we.directionalLightShadows.value=B.state.directionalShadow,we.spotLights.value=B.state.spot,we.spotLightShadows.value=B.state.spotShadow,we.rectAreaLights.value=B.state.rectArea,we.ltc_1.value=B.state.rectAreaLTC1,we.ltc_2.value=B.state.rectAreaLTC2,we.pointLights.value=B.state.point,we.pointLightShadows.value=B.state.pointShadow,we.hemisphereLights.value=B.state.hemi,we.directionalShadowMatrix.value=B.state.directionalShadowMatrix,we.spotLightMatrix.value=B.state.spotLightMatrix,we.spotLightMap.value=B.state.spotLightMap,we.pointShadowMatrix.value=B.state.pointShadowMatrix),z.lightProbeGrid=b.state.lightProbeGridArray.length>0,z.currentProgram=He,z.uniformsList=null,He}function Ul(S){if(S.uniformsList===null){const N=S.currentProgram.getUniforms();S.uniformsList=ua.seqWithValue(N.seq,S.uniforms)}return S.uniformsList}function Fl(S,N){const H=G.get(S);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 Ed(S,N){if(S.length===0)return null;if(S.length===1)return S[0].texture!==null?S[0]:null;x.setFromMatrixPosition(N.matrixWorld);for(let H=0,z=S.length;H<z;H++){const B=S[H];if(B.texture!==null&&B.boundingBox.containsPoint(x))return B}return null}function bd(S,N,H,z,B){N.isScene!==!0&&(N=ct),Y.resetTextureUnits();const pe=N.fog,ve=z.isMeshStandardMaterial||z.isMeshLambertMaterial||z.isMeshPhongMaterial?N.environment:null,fe=Q===null?P.outputColorSpace:Q.isXRRenderTarget===!0?Q.texture.colorSpace:qe.workingColorSpace,ye=z.isMeshStandardMaterial||z.isMeshLambertMaterial&&!z.envMap||z.isMeshPhongMaterial&&!z.envMap,Ae=ie.get(z.envMap||ve,ye),ke=z.vertexColors===!0&&!!H.attributes.color&&H.attributes.color.itemSize===4,He=!!H.attributes.tangent&&(!!z.normalMap||z.anisotropy>0),we=!!H.morphAttributes.position,je=!!H.morphAttributes.normal,gt=!!H.morphAttributes.color;let mt=Pn;z.toneMapped&&(Q===null||Q.isXRRenderTarget===!0)&&(mt=P.toneMapping);const tt=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,It=tt!==void 0?tt.length:0,_e=G.get(z),Xt=b.state.lights;if(Ie===!0&&(Le===!0||S!==ee)){const at=S===ee&&z.id===te;Ce.setState(z,S,at)}let Ke=!1;z.version===_e.__version?(_e.needsLights&&_e.lightsStateVersion!==Xt.state.version||_e.outputColorSpace!==fe||B.isBatchedMesh&&_e.batching===!1||!B.isBatchedMesh&&_e.batching===!0||B.isBatchedMesh&&_e.batchingColor===!0&&B.colorTexture===null||B.isBatchedMesh&&_e.batchingColor===!1&&B.colorTexture!==null||B.isInstancedMesh&&_e.instancing===!1||!B.isInstancedMesh&&_e.instancing===!0||B.isSkinnedMesh&&_e.skinning===!1||!B.isSkinnedMesh&&_e.skinning===!0||B.isInstancedMesh&&_e.instancingColor===!0&&B.instanceColor===null||B.isInstancedMesh&&_e.instancingColor===!1&&B.instanceColor!==null||B.isInstancedMesh&&_e.instancingMorph===!0&&B.morphTexture===null||B.isInstancedMesh&&_e.instancingMorph===!1&&B.morphTexture!==null||_e.envMap!==Ae||z.fog===!0&&_e.fog!==pe||_e.numClippingPlanes!==void 0&&(_e.numClippingPlanes!==Ce.numPlanes||_e.numIntersection!==Ce.numIntersection)||_e.vertexAlphas!==ke||_e.vertexTangents!==He||_e.morphTargets!==we||_e.morphNormals!==je||_e.morphColors!==gt||_e.toneMapping!==mt||_e.morphTargetsCount!==It||!!_e.lightProbeGrid!=b.state.lightProbeGridArray.length>0)&&(Ke=!0):(Ke=!0,_e.__version=z.version);let Jt=_e.currentProgram;Ke===!0&&(Jt=ur(z,N,B),L&&z.isNodeMaterial&&L.onUpdateProgram(z,Jt,_e));let _n=!1,Yn=!1,Fi=!1;const nt=Jt.getUniforms(),_t=_e.uniforms;if(_.useProgram(Jt.program)&&(_n=!0,Yn=!0,Fi=!0),z.id!==te&&(te=z.id,Yn=!0),_e.needsLights){const at=Ed(b.state.lightProbeGridArray,B);_e.lightProbeGrid!==at&&(_e.lightProbeGrid=at,Yn=!0)}if(_n||ee!==S){_.buffers.depth.getReversed()&&S.reversedDepth!==!0&&(S._reversedDepth=!0,S.updateProjectionMatrix()),nt.setValue(I,"projectionMatrix",S.projectionMatrix),nt.setValue(I,"viewMatrix",S.matrixWorldInverse);const Zn=nt.map.cameraPosition;Zn!==void 0&&Zn.setValue(I,$e.setFromMatrixPosition(S.matrixWorld)),A.logarithmicDepthBuffer&&nt.setValue(I,"logDepthBufFC",2/(Math.log(S.far+1)/Math.LN2)),(z.isMeshPhongMaterial||z.isMeshToonMaterial||z.isMeshLambertMaterial||z.isMeshBasicMaterial||z.isMeshStandardMaterial||z.isShaderMaterial)&&nt.setValue(I,"isOrthographic",S.isOrthographicCamera===!0),ee!==S&&(ee=S,Yn=!0,Fi=!0)}if(_e.needsLights&&(Xt.state.directionalShadowMap.length>0&&nt.setValue(I,"directionalShadowMap",Xt.state.directionalShadowMap,Y),Xt.state.spotShadowMap.length>0&&nt.setValue(I,"spotShadowMap",Xt.state.spotShadowMap,Y),Xt.state.pointShadowMap.length>0&&nt.setValue(I,"pointShadowMap",Xt.state.pointShadowMap,Y)),B.isSkinnedMesh){nt.setOptional(I,B,"bindMatrix"),nt.setOptional(I,B,"bindMatrixInverse");const at=B.skeleton;at&&(at.boneTexture===null&&at.computeBoneTexture(),nt.setValue(I,"boneTexture",at.boneTexture,Y))}B.isBatchedMesh&&(nt.setOptional(I,B,"batchingTexture"),nt.setValue(I,"batchingTexture",B._matricesTexture,Y),nt.setOptional(I,B,"batchingIdTexture"),nt.setValue(I,"batchingIdTexture",B._indirectTexture,Y),nt.setOptional(I,B,"batchingColorTexture"),B._colorsTexture!==null&&nt.setValue(I,"batchingColorTexture",B._colorsTexture,Y));const Kn=H.morphAttributes;if((Kn.position!==void 0||Kn.normal!==void 0||Kn.color!==void 0)&&D.update(B,H,Jt),(Yn||_e.receiveShadow!==B.receiveShadow)&&(_e.receiveShadow=B.receiveShadow,nt.setValue(I,"receiveShadow",B.receiveShadow)),(z.isMeshStandardMaterial||z.isMeshLambertMaterial||z.isMeshPhongMaterial)&&z.envMap===null&&N.environment!==null&&(_t.envMapIntensity.value=N.environmentIntensity),_t.dfgLUT!==void 0&&(_t.dfgLUT.value=Iv()),Yn){if(nt.setValue(I,"toneMappingExposure",P.toneMappingExposure),_e.needsLights&&Td(_t,Fi),pe&&z.fog===!0&&Te.refreshFogUniforms(_t,pe),Te.refreshMaterialUniforms(_t,z,ne,re,b.state.transmissionRenderTarget[S.id]),_e.needsLights&&_e.lightProbeGrid){const at=_e.lightProbeGrid;_t.probesSH.value=at.texture,_t.probesMin.value.copy(at.boundingBox.min),_t.probesMax.value.copy(at.boundingBox.max),_t.probesResolution.value.copy(at.resolution)}ua.upload(I,Ul(_e),_t,Y)}if(z.isShaderMaterial&&z.uniformsNeedUpdate===!0&&(ua.upload(I,Ul(_e),_t,Y),z.uniformsNeedUpdate=!1),z.isSpriteMaterial&&nt.setValue(I,"center",B.center),nt.setValue(I,"modelViewMatrix",B.modelViewMatrix),nt.setValue(I,"normalMatrix",B.normalMatrix),nt.setValue(I,"modelMatrix",B.matrixWorld),z.uniformsGroups!==void 0){const at=z.uniformsGroups;for(let Zn=0,Oi=at.length;Zn<Oi;Zn++){const Ol=at[Zn];j.update(Ol,Jt),j.bind(Ol,Jt)}}return Jt}function Td(S,N){S.ambientLightColor.needsUpdate=N,S.lightProbe.needsUpdate=N,S.directionalLights.needsUpdate=N,S.directionalLightShadows.needsUpdate=N,S.pointLights.needsUpdate=N,S.pointLightShadows.needsUpdate=N,S.spotLights.needsUpdate=N,S.spotLightShadows.needsUpdate=N,S.rectAreaLights.needsUpdate=N,S.hemisphereLights.needsUpdate=N}function Ad(S){return S.isMeshLambertMaterial||S.isMeshToonMaterial||S.isMeshPhongMaterial||S.isMeshStandardMaterial||S.isShadowMaterial||S.isShaderMaterial&&S.lights===!0}this.getActiveCubeFace=function(){return W},this.getActiveMipmapLevel=function(){return V},this.getRenderTarget=function(){return Q},this.setRenderTargetTextures=function(S,N,H){const z=G.get(S);z.__autoAllocateDepthBuffer=S.resolveDepthBuffer===!1,z.__autoAllocateDepthBuffer===!1&&(z.__useRenderToTexture=!1),G.get(S.texture).__webglTexture=N,G.get(S.depthTexture).__webglTexture=z.__autoAllocateDepthBuffer?void 0:H,z.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(S,N){const H=G.get(S);H.__webglFramebuffer=N,H.__useDefaultFramebuffer=N===void 0},this.setRenderTarget=function(S,N=0,H=0){Q=S,W=N,V=H;let z=null,B=!1,pe=!1;if(S){const fe=G.get(S);if(fe.__useDefaultFramebuffer!==void 0){_.bindFramebuffer(I.FRAMEBUFFER,fe.__webglFramebuffer),se.copy(S.viewport),ge.copy(S.scissor),Ve=S.scissorTest,_.viewport(se),_.scissor(ge),_.setScissorTest(Ve),te=-1;return}else if(fe.__webglFramebuffer===void 0)Y.setupRenderTarget(S);else if(fe.__hasExternalTextures)Y.rebindTextures(S,G.get(S.texture).__webglTexture,G.get(S.depthTexture).__webglTexture);else if(S.depthBuffer){const ke=S.depthTexture;if(fe.__boundDepthTexture!==ke){if(ke!==null&&G.has(ke)&&(S.width!==ke.image.width||S.height!==ke.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");Y.setupDepthRenderbuffer(S)}}const ye=S.texture;(ye.isData3DTexture||ye.isDataArrayTexture||ye.isCompressedArrayTexture)&&(pe=!0);const Ae=G.get(S).__webglFramebuffer;S.isWebGLCubeRenderTarget?(Array.isArray(Ae[N])?z=Ae[N][H]:z=Ae[N],B=!0):S.samples>0&&Y.useMultisampledRTT(S)===!1?z=G.get(S).__webglMultisampledFramebuffer:Array.isArray(Ae)?z=Ae[H]:z=Ae,se.copy(S.viewport),ge.copy(S.scissor),Ve=S.scissorTest}else se.copy(De).multiplyScalar(ne).floor(),ge.copy(Re).multiplyScalar(ne).floor(),Ve=xe;if(H!==0&&(z=X),_.bindFramebuffer(I.FRAMEBUFFER,z)&&_.drawBuffers(S,z),_.viewport(se),_.scissor(ge),_.setScissorTest(Ve),B){const fe=G.get(S.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 ye=0;ye<S.textures.length;ye++){const Ae=G.get(S.textures[ye]);I.framebufferTextureLayer(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0+ye,Ae.__webglTexture,H,fe)}}else if(S!==null&&H!==0){const fe=G.get(S.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,fe.__webglTexture,H)}te=-1},this.readRenderTargetPixels=function(S,N,H,z,B,pe,ve,fe=0){if(!(S&&S.isWebGLRenderTarget)){Xe("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ye=G.get(S).__webglFramebuffer;if(S.isWebGLCubeRenderTarget&&ve!==void 0&&(ye=ye[ve]),ye){_.bindFramebuffer(I.FRAMEBUFFER,ye);try{const Ae=S.textures[fe],ke=Ae.format,He=Ae.type;if(S.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+fe),!A.textureFormatReadable(ke)){Xe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!A.textureTypeReadable(He)){Xe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}N>=0&&N<=S.width-z&&H>=0&&H<=S.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;_.bindFramebuffer(I.FRAMEBUFFER,Ae)}}},this.readRenderTargetPixelsAsync=async function(S,N,H,z,B,pe,ve,fe=0){if(!(S&&S.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ye=G.get(S).__webglFramebuffer;if(S.isWebGLCubeRenderTarget&&ve!==void 0&&(ye=ye[ve]),ye)if(N>=0&&N<=S.width-z&&H>=0&&H<=S.height-B){_.bindFramebuffer(I.FRAMEBUFFER,ye);const Ae=S.textures[fe],ke=Ae.format,He=Ae.type;if(S.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 we=I.createBuffer();I.bindBuffer(I.PIXEL_PACK_BUFFER,we),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 je=Q!==null?G.get(Q).__webglFramebuffer:null;_.bindFramebuffer(I.FRAMEBUFFER,je);const gt=I.fenceSync(I.SYNC_GPU_COMMANDS_COMPLETE,0);return I.flush(),await Jf(I,gt,4),I.bindBuffer(I.PIXEL_PACK_BUFFER,we),I.getBufferSubData(I.PIXEL_PACK_BUFFER,0,pe),I.deleteBuffer(we),I.deleteSync(gt),pe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(S,N=null,H=0){const z=Math.pow(2,-H),B=Math.floor(S.image.width*z),pe=Math.floor(S.image.height*z),ve=N!==null?N.x:0,fe=N!==null?N.y:0;Y.setTexture2D(S,0),I.copyTexSubImage2D(I.TEXTURE_2D,H,0,0,ve,fe,B,pe),_.unbindTexture()},this.copyTextureToTexture=function(S,N,H=null,z=null,B=0,pe=0){let ve,fe,ye,Ae,ke,He,we,je,gt;const mt=S.isCompressedTexture?S.mipmaps[pe]:S.image;if(H!==null)ve=H.max.x-H.min.x,fe=H.max.y-H.min.y,ye=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 _t=Math.pow(2,-B);ve=Math.floor(mt.width*_t),fe=Math.floor(mt.height*_t),S.isDataArrayTexture?ye=mt.depth:S.isData3DTexture?ye=Math.floor(mt.depth*_t):ye=1,Ae=0,ke=0,He=0}z!==null?(we=z.x,je=z.y,gt=z.z):(we=0,je=0,gt=0);const tt=he.convert(N.format),It=he.convert(N.type);let _e;N.isData3DTexture?(Y.setTexture3D(N,0),_e=I.TEXTURE_3D):N.isDataArrayTexture||N.isCompressedArrayTexture?(Y.setTexture2DArray(N,0),_e=I.TEXTURE_2D_ARRAY):(Y.setTexture2D(N,0),_e=I.TEXTURE_2D),_.activeTexture(I.TEXTURE0),_.pixelStorei(I.UNPACK_FLIP_Y_WEBGL,N.flipY),_.pixelStorei(I.UNPACK_PREMULTIPLY_ALPHA_WEBGL,N.premultiplyAlpha),_.pixelStorei(I.UNPACK_ALIGNMENT,N.unpackAlignment);const Xt=_.getParameter(I.UNPACK_ROW_LENGTH),Ke=_.getParameter(I.UNPACK_IMAGE_HEIGHT),Jt=_.getParameter(I.UNPACK_SKIP_PIXELS),_n=_.getParameter(I.UNPACK_SKIP_ROWS),Yn=_.getParameter(I.UNPACK_SKIP_IMAGES);_.pixelStorei(I.UNPACK_ROW_LENGTH,mt.width),_.pixelStorei(I.UNPACK_IMAGE_HEIGHT,mt.height),_.pixelStorei(I.UNPACK_SKIP_PIXELS,Ae),_.pixelStorei(I.UNPACK_SKIP_ROWS,ke),_.pixelStorei(I.UNPACK_SKIP_IMAGES,He);const Fi=S.isDataArrayTexture||S.isData3DTexture,nt=N.isDataArrayTexture||N.isData3DTexture;if(S.isDepthTexture){const _t=G.get(S),Kn=G.get(N),at=G.get(_t.__renderTarget),Zn=G.get(Kn.__renderTarget);_.bindFramebuffer(I.READ_FRAMEBUFFER,at.__webglFramebuffer),_.bindFramebuffer(I.DRAW_FRAMEBUFFER,Zn.__webglFramebuffer);for(let Oi=0;Oi<ye;Oi++)Fi&&(I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,G.get(S).__webglTexture,B,He+Oi),I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,G.get(N).__webglTexture,pe,gt+Oi)),I.blitFramebuffer(Ae,ke,ve,fe,we,je,ve,fe,I.DEPTH_BUFFER_BIT,I.NEAREST);_.bindFramebuffer(I.READ_FRAMEBUFFER,null),_.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else if(B!==0||S.isRenderTargetTexture||G.has(S)){const _t=G.get(S),Kn=G.get(N);_.bindFramebuffer(I.READ_FRAMEBUFFER,q),_.bindFramebuffer(I.DRAW_FRAMEBUFFER,F);for(let at=0;at<ye;at++)Fi?I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,_t.__webglTexture,B,He+at):I.framebufferTexture2D(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,_t.__webglTexture,B),nt?I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,Kn.__webglTexture,pe,gt+at):I.framebufferTexture2D(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,Kn.__webglTexture,pe),B!==0?I.blitFramebuffer(Ae,ke,ve,fe,we,je,ve,fe,I.COLOR_BUFFER_BIT,I.NEAREST):nt?I.copyTexSubImage3D(_e,pe,we,je,gt+at,Ae,ke,ve,fe):I.copyTexSubImage2D(_e,pe,we,je,Ae,ke,ve,fe);_.bindFramebuffer(I.READ_FRAMEBUFFER,null),_.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else nt?S.isDataTexture||S.isData3DTexture?I.texSubImage3D(_e,pe,we,je,gt,ve,fe,ye,tt,It,mt.data):N.isCompressedArrayTexture?I.compressedTexSubImage3D(_e,pe,we,je,gt,ve,fe,ye,tt,mt.data):I.texSubImage3D(_e,pe,we,je,gt,ve,fe,ye,tt,It,mt):S.isDataTexture?I.texSubImage2D(I.TEXTURE_2D,pe,we,je,ve,fe,tt,It,mt.data):S.isCompressedTexture?I.compressedTexSubImage2D(I.TEXTURE_2D,pe,we,je,mt.width,mt.height,tt,mt.data):I.texSubImage2D(I.TEXTURE_2D,pe,we,je,ve,fe,tt,It,mt);_.pixelStorei(I.UNPACK_ROW_LENGTH,Xt),_.pixelStorei(I.UNPACK_IMAGE_HEIGHT,Ke),_.pixelStorei(I.UNPACK_SKIP_PIXELS,Jt),_.pixelStorei(I.UNPACK_SKIP_ROWS,_n),_.pixelStorei(I.UNPACK_SKIP_IMAGES,Yn),pe===0&&N.generateMipmaps&&I.generateMipmap(_e),_.unbindTexture()},this.initRenderTarget=function(S){G.get(S).__webglFramebuffer===void 0&&Y.setupRenderTarget(S)},this.initTexture=function(S){S.isCubeTexture?Y.setTextureCube(S,0):S.isData3DTexture?Y.setTexture3D(S,0):S.isDataArrayTexture||S.isCompressedArrayTexture?Y.setTexture2DArray(S,0):Y.setTexture2D(S,0),_.unbindTexture()},this.resetState=function(){W=0,V=0,Q=null,_.reset(),me.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Cn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=qe._getDrawingBufferColorSpace(e),t.unpackColorSpace=qe._getUnpackColorSpace()}}const zc=Math.PI/180,eu=180/Math.PI;function lr(i,e,t){return Math.max(e,Math.min(t,i))}const ni=[{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 da(i,e,t){return i+(e-i)*t}function Ma(i,e,t){return[da(i[0],e[0],t),da(i[1],e[1],t),da(i[2],e[2],t)]}function O0(i){const e=Math.max(ni[0].altitudeDeg,Math.min(ni[ni.length-1].altitudeDeg,i));for(let n=0;n<ni.length-1;n++){const s=ni[n],r=ni[n+1];if(e>=s.altitudeDeg&&e<=r.altitudeDeg){const a=(e-s.altitudeDeg)/(r.altitudeDeg-s.altitudeDeg);return{zenith:Ma(s.zenith,r.zenith,a),horizon:Ma(s.horizon,r.horizon,a)}}}const t=ni[ni.length-1];return{zenith:t.zenith,horizon:t.horizon}}function Nv(i){const e=z0,t=-4;if(i<=-18)return e;if(i>=0)return t;const n=(i+18)/18;return da(e,t,n)}const Uv=-1.5,z0=6.5,tu=z0,Fv=1.6;function nu(i){const e=(tu-i)/(tu-Uv);return lr(e,0,1)**Fv}function ri(i,e,t){const n=i*zc,s=e*zc,r=t*Math.cos(n);return{x:r*Math.sin(s),y:t*Math.sin(n),z:-r*Math.cos(s)}}function Ov(i,e,t){const n=Math.sqrt(i*i+e*e+t*t),s=n===0?0:Math.asin(lr(e/n,-1,1))*eu,r=(Math.atan2(i,-t)*eu+360)%360;return{altitudeDeg:s,azimuthDeg:r}}function zv(i,e){const t=Math.abs(i-e)%360;return t>180?360-t:t}function Bv(i,e,t){const n=Math.max(0,1-zv(i,e)/90),s=Math.max(0,1-Math.abs(t)/18);return n*s}function kv(i,e,t,n){const{zenith:s,horizon:r}=O0(n),a=lr((i+90)/180,0,1),o=Ma(r,s,a),c=Bv(e,t,n);return c<=0?o:Ma(o,r,c*(1-a)*.8)}function iu(i){return .12+.88*i}const Gv=-4;function Hv(i){return Math.max(0,Gv-i)}const Vv=6,Wv=60;function Xv(i){return Math.min(Wv,Vv*Math.sqrt(i))}const qv=3,Yv=.55;function Kv(i){return Yv*lr(i/qv,0,1)}function Zv(i){const e=Math.max(i,-4),t=Math.sin(e*zc)+.50572*Math.pow(e+6.07995,-1.6364);return lr(1/t,1,40)}function ks(i){const e=Zv(i)-1;return[1,Math.exp(-.022*e),Math.exp(-.062*e)]}const B0=[{maxBrightness:.35,size:1.2},{maxBrightness:.7,size:2},{maxBrightness:1/0,size:3.2}];function $v(i){return B0.findIndex(e=>i<=e.maxBrightness)}const Jv=.25,su=.3,Qv=2.2;function jv(i,{phase:e,speedFactor:t},n){const r=1+Jv*(su+(1-su)*i)*Math.sin(n*Qv*t+e);return Math.min(1,Math.max(0,r))}/**
|
|
4409
4416
|
@preserve
|
|
4410
4417
|
|
|
4411
4418
|
Astronomy library for JavaScript (browser and Node.js).
|
|
@@ -4436,7 +4443,11 @@ void main() {
|
|
|
4436
4443
|
* @fileoverview Astronomy calculation library for browser scripting and Node.js.
|
|
4437
4444
|
* @author Don Cross <cosinekitty@gmail.com>
|
|
4438
4445
|
* @license MIT
|
|
4439
|
-
*/const $0=173.1446326846693,Ti=14959787069098932e-8,it=.017453292519943295,pu=.26179938779914946,ui=57.29577951308232,J0=3.819718634205488,dx=365.24217,mu=new Date("2000-01-01T12:00:00Z"),Fn=2*Math.PI,ii=3600*(180/Math.PI),cs=484813681109536e-20,Q0=10800*60,fx=2*Q0,gu=7292115e-11,px=Q0/Math.PI,mx=-.17-5*Math.log10(px),Xc=.996647180302104,gx=Xc*Xc,qc=6378.1366,_x=qc/Ti,j0=81.30056,Pl=.0002959122082855911,Yc=2825345909524226e-22,Kc=8459715185680659e-23,Zc=1292024916781969e-23,$c=1524358900784276e-23;function Aa(i){if(i!==!0&&i!==!1)throw console.trace(),`Value is not boolean: ${i}`;return i}function Rt(i){if(!Number.isFinite(i))throw console.trace(),`Value is not a finite number: ${i}`;return i}function ts(i){return i-Math.floor(i)}function vx(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:ui*Math.acos(s)}var Ee;(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"})(Ee||(Ee={}));const xx=[Ee.Star1,Ee.Star2,Ee.Star3,Ee.Star4,Ee.Star5,Ee.Star6,Ee.Star7,Ee.Star8],Mx=[{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 Sx(i){const e=xx.indexOf(i);return e>=0?Mx[e]:null}function Dl(i){const e=Sx(i);return e&&e.dist>0?e:null}var an;(function(i){i[i.From2000=0]="From2000",i[i.Into2000=1]="Into2000"})(an||(an={}));const kn={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 yx(i){var e,t,n,s,r,a,o;const c=2e3+(i-14)/dx;return c<-500?(e=(c-1820)/100,-20+32*e*e):c<500?(e=c/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):c<1600?(e=(c-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):c<1700?(e=c-1600,t=e*e,n=e*t,120-.9808*e-.01532*t+n/7129):c<1800?(e=c-1700,t=e*e,n=e*t,s=t*t,8.83+.1603*e-.0059285*t+13336e-8*n-s/1174e3):c<1860?(e=c-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):c<1900?(e=c-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):c<1920?(e=c-1900,t=e*e,n=e*t,s=t*t,-2.79+1.494119*e-.0598939*t+.0061966*n-197e-6*s):c<1941?(e=c-1920,t=e*e,n=e*t,21.2+.84493*e-.0761*t+.0020936*n):c<1961?(e=c-1950,t=e*e,n=e*t,29.07+.407*e-t/233+n/2547):c<1986?(e=c-1975,t=e*e,n=e*t,45.45+1.067*e-t/260-n/718):c<2005?(e=c-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):c<2050?(e=c-2e3,62.92+.32217*e+.005589*e*e):c<2150?(e=(c-1820)/100,-20+32*e*e-.5628*(2150-c)):(e=(c-1820)/100,-20+32*e*e)}let Ex=yx;function _u(i){return i+Ex(i)/86400}class ms{constructor(e){if(e instanceof ms){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()-mu.getTime())/t,this.tt=_u(this.ut);return}if(Number.isFinite(e)){this.date=new Date(mu.getTime()+e*t),this.ut=e,this.tt=_u(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 ms(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 ms(this.ut+e)}}function on(i){return i instanceof ms?i:new ms(i)}function bx(i){function e(u){return u%fx*cs}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),c=Math.cos(a),l=(-172064161-174666*t)*o+33386*c,h=(92052331+9086*t)*c+15377*o,d=2*(s-r+a);return o=Math.sin(d),c=Math.cos(d),l+=(-13170906-1675*t)*o-13696*c,h+=(5730336-3015*t)*c-4587*o,d=2*(s+a),o=Math.sin(d),c=Math.cos(d),l+=(-2276413-234*t)*o+2796*c,h+=(978459-485*t)*c+1374*o,d=2*a,o=Math.sin(d),c=Math.cos(d),l+=(2074554+207*t)*o-698*c,h+=(-897492+470*t)*c-291*o,o=Math.sin(n),c=Math.cos(n),l+=(1475877-3633*t)*o+11817*c,h+=(73871-184*t)*c-1924*o,{dpsi:-135e-6+l*1e-7,deps:388e-6+h*1e-7}}function ed(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 Kr;function Il(i){if(!Kr||Math.abs(Kr.tt-i.tt)>1e-6){const e=bx(i),t=ed(i),n=t+e.deps/3600;Kr={tt:i.tt,dpsi:e.dpsi,deps:e.deps,ee:e.dpsi*Math.cos(t*it)/15,mobl:t,tobl:n}}return Kr}function Tx(i,e){const t=i*it,n=Math.cos(t),s=Math.sin(t);return[e[0],e[1]*n-e[2]*s,e[1]*s+e[2]*n]}function Ax(i,e){return Tx(ed(i),e)}function wx(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 Ze=0;Ze<=Me-Re;++Ze)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,c,l,h,d,u,p,g,x,m,f,A,w,M,y,b,R,v,E,P,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(Fn*Re)}u=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),rt=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*rt+.28*We+.24*Z,v=2.94*se+.31*ge+14.27*Ve+9.34*rt+1.12*We+.83*Z,E=-6.4*se-1.89*Z,P=.21*se+.31*ge+14.27*Ve-88.7*rt-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),A=Fn*ts(.60643382+1336.85522467*e-313e-8*u)+R/ii,w=Fn*ts(.37489701+1325.55240982*e+2565e-8*u)+v/ii,M=Fn*ts(.99312619+99.99735956*e-44e-8*u)+E/ii,y=Fn*ts(.25909118+1342.2278298*e-892e-8*u)+P/ii,b=Fn*ts(.82736186+1236.85308708*e-397e-8*u)+C/ii,h=1;h<=4;++h){switch(h){case 1:c=w,o=4,l=1.000002208;break;case 2:c=M,o=3,l=.997504612-.002495388*e;break;case 3:c=y,o=4,l=1.000002708+139.978*p;break;case 4:c=b,o=6,l=1;break;default:throw`Internal error: I = ${h}`}for(V(0,h,1),V(1,h,Math.cos(c)*l),Q(0,h,0),Q(1,h,Math.sin(c)*l),d=2;d<=o;++d)te(F(d-1,h),W(d-1,h),F(1,h),W(1,h),(Re,Me)=>(V(d,h,Re),Q(d,h,Me)));for(d=1;d<=o;++d)V(-d,h,F(d,h)),Q(-d,h,-W(d,h))}function ne(Re,Me,Ue,Ie){for(var Le={x:1,y:0},Ze=[0,Re,Me,Ue,Ie],$e=1;$e<=4;++$e)Ze[$e]!==0&&te(Le.x,Le.y,F(Ze[$e],$e),W(Ze[$e],$e),(dt,ct)=>(Le.x=dt,Le.y=ct));return Le}function k(Re,Me,Ue,Ie,Le,Ze,$e,dt){var ct=ne(Le,Ze,$e,dt);g+=Re*ct.y,L+=Me*ct.y,m+=Ue*ct.x,f+=Ie*ct.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 Pe(Re,Me,Ue,Ie,Le){return Re*ne(Me,Ue,Ie,Le).y}x=0,x+=Pe(-526.069,0,0,1,-2),x+=Pe(-3.352,0,0,1,-4),x+=Pe(44.297,1,0,1,-2),x+=Pe(-6,1,0,1,-4),x+=Pe(20.599,-1,0,1,0),x+=Pe(-30.598,-1,0,1,-2),x+=Pe(-24.649,-2,0,1,0),x+=Pe(-2,-2,0,1,-2),x+=Pe(-22.571,0,1,1,-2),x+=Pe(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=y+L/ii;let De=(1.000002708+139.978*p)*(18518.511+1.189+m)*Math.sin(a)-6.24*Math.sin(3*a)+x;return{geo_eclip_lon:Fn*ts((A+g/ii)/Fn),geo_eclip_lat:Math.PI/(180*3600)*De,distance_au:ii*_x/(.999953253*f)}}function td(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 wa(i,e,t){const n=Rx(e,t);return td(n,i)}function Rx(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*=cs,s*=cs,r*=cs,a*=cs;const o=Math.sin(n),c=Math.cos(n),l=Math.sin(-s),h=Math.cos(-s),d=Math.sin(-r),u=Math.cos(-r),p=Math.sin(a),g=Math.cos(a),x=g*h-l*p*u,m=g*l*c+p*u*h*c-o*p*d,f=g*l*o+p*u*h*o+c*p*d,A=-p*h-l*g*u,w=-p*l*c+g*u*h*c-o*g*d,M=-p*l*o+g*u*h*o+c*g*d,y=l*d,b=-d*h*c-o*u,R=-d*h*o+u*c;if(e===an.Into2000)return new Ra([[x,m,f],[A,w,M],[y,b,R]]);if(e===an.From2000)return new Ra([[x,A,y],[m,w,b],[f,M,R]]);throw"Invalid precess direction"}function Cx(i){const e=.779057273264+.00273781191135448*i.ut,t=i.ut%1;let n=360*((e+t)%1);return n<0&&(n+=360),n}let Zr;function nd(i){if(!Zr||Zr.tt!==i.tt){const e=i.tt/36525;let t=15*Il(i).ee;const n=Cx(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),Zr={tt:i.tt,st:r}}return Zr.st}function Px(i,e){const t=i.latitude*it,n=Math.sin(t),s=Math.cos(t),r=1/Math.hypot(s,Xc*n),a=gx*r,o=i.height/1e3,c=qc*r+o,l=qc*a+o,h=(15*e+i.longitude)*it,d=Math.sin(h),u=Math.cos(h);return{pos:[c*s*u/Ti,c*s*d/Ti,l*n/Ti],vel:[-gu*c*s*d*86400/Ti,gu*c*s*u*86400/Ti,0]}}function Jc(i,e,t){const n=Dx(e,t);return td(n,i)}function Dx(i,e){const t=Il(i),n=t.mobl*it,s=t.tobl*it,r=t.dpsi*cs,a=Math.cos(n),o=Math.sin(n),c=Math.cos(s),l=Math.sin(s),h=Math.cos(r),d=Math.sin(r),u=h,p=-d*a,g=-d*o,x=d*c,m=h*a*c+o*l,f=h*o*c-a*l,A=d*l,w=h*a*l-o*c,M=h*o*l+a*c;if(e===an.From2000)return new Ra([[u,x,A],[p,m,w],[g,f,M]]);if(e===an.Into2000)return new Ra([[u,p,g],[x,m,f],[A,w,M]]);throw"Invalid precess direction"}function id(i,e,t){return t===an.Into2000?wa(Jc(i,e,t),e,t):Jc(wa(i,e,t),e,t)}function Ix(i,e){const t=nd(i),n=Px(e,t).pos;return id(n,i,an.Into2000)}class vt{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 li{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 Lx{constructor(e,t,n){this.lat=Rt(e),this.lon=Rt(t),this.dist=Rt(n)}}class vu{constructor(e,t,n,s){this.ra=Rt(e),this.dec=Rt(t),this.dist=Rt(n),this.vec=s}}class Ra{constructor(e){this.rot=e}}class Nx{constructor(e,t,n,s){this.azimuth=Rt(e),this.altitude=Rt(t),this.ra=Rt(n),this.dec=Rt(s)}}class Ux{constructor(e,t,n){this.vec=e,this.elat=Rt(t),this.elon=Rt(n)}}function Fx(i,e){return new vt(i[0],i[1],i[2],e)}function Ox(i,e){const t=Fx(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 vu(0,t.z<0?-90:90,s,t)}let r=J0*Math.atan2(t.y,t.x);r<0&&(r+=24);const a=ui*Math.atan2(i[2],Math.sqrt(n));return new vu(r,a,s,t)}function Co(i,e){const t=i*it,n=Math.cos(t),s=Math.sin(t);return[n*e[0]+s*e[1],n*e[1]-s*e[0],e[2]]}function sd(i,e,t,n,s){let r=on(i);Ll(e),Rt(t),Rt(n);const a=Math.sin(e.latitude*it),o=Math.cos(e.latitude*it),c=Math.sin(e.longitude*it),l=Math.cos(e.longitude*it),h=Math.sin(n*it),d=Math.cos(n*it),u=Math.sin(t*pu),p=Math.cos(t*pu);let g=[o*l,o*c,a],x=[-a*l,-a*c,o],m=[c,-l,0];const f=-15*nd(r);let A=Co(f,g),w=Co(f,x),M=Co(f,m),y=[d*p,d*u,h];const b=y[0]*A[0]+y[1]*A[1]+y[2]*A[2],R=y[0]*w[0]+y[1]*w[1]+y[2]*w[2],v=y[0]*M[0]+y[1]*M[1]+y[2]*M[2];let E=Math.hypot(R,v),P;E>0?(P=-ui*Math.atan2(v,R),P<0&&(P+=360)):P=0;let C=ui*Math.atan2(E,b),L=t,X=n;{let q=C,F=r2(s,90-C);if(C-=F,F>0&&C>3e-4){const W=Math.sin(C*it),V=Math.cos(C*it),Q=Math.sin(q*it),te=Math.cos(q*it),ee=[];for(let se=0;se<3;++se)ee.push((y[se]-te*A[se])/Q*W+A[se]*V);E=Math.hypot(ee[0],ee[1]),E>0?(L=J0*Math.atan2(ee[1],ee[0]),L<0&&(L+=24)):L=0,X=ui*Math.atan2(ee[2],E)}}return new Nx(P,90-C,L,X)}function Ll(i){if(!(i instanceof rd))throw`Not an instance of the Observer class: ${i}`;if(Rt(i.latitude),Rt(i.longitude),Rt(i.height),i.latitude<-90||i.latitude>90)throw`Latitude ${i.latitude} is out of range. Must be -90..+90.`;return i}class rd{constructor(e,t,n){this.latitude=e,this.longitude=t,this.height=n,Ll(this)}}function zx(i,e,t,n,s){Ll(t),Aa(n),Aa(s);const r=on(e),a=Ix(r,t),o=ol(i,r,s),c=[o.x-a[0],o.y-a[1],o.z-a[2]],l=id(c,r,an.From2000);return Ox(l,r)}function Bx(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=ui*Math.atan2(s,n),o<0&&(o+=360));let c=ui*Math.atan2(r,a),l=new vt(n,s,r,i.t);return new Ux(l,c,o)}function Qc(i){const e=Il(i.t),t=[i.x,i.y,i.z],n=wa(t,i.t,an.From2000),[s,r,a]=Jc(n,i.t,an.From2000),o=new vt(s,r,a,i.t),c=e.tobl*it;return Bx(o,Math.cos(c),Math.sin(c))}function ys(i){const e=on(i),t=wx(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=Ax(e,s),a=wa(r,e,an.Into2000);return new vt(a[0],a[1],a[2],e)}function ad(i){const e=on(i),t=1e-5,n=e.AddDays(-t),s=e.AddDays(+t),r=ys(n),a=ys(s);return new li((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 kx(i){const e=on(i),t=ad(e),n=1+j0;return new li(t.x/n,t.y/n,t.z/n,t.vx/n,t.vy/n,t.vz/n,e)}function gs(i,e,t){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+e*h);let o=n*a;t&&(o%=Fn),s+=o,n*=e}return s}function Po(i,e){let t=1,n=0,s=0,r=0;for(let a of i){let o=0,c=0;for(let[l,h,d]of a){let u=h+e*d;o+=l*d*Math.sin(u),r>0&&(c+=l*Math.cos(u))}s+=r*n*c-t*o,n=t,t*=e,++r}return s}const Ys=365250,jc=0,el=1,tl=2;function nl(i){return new Nt(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 od(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 Qs(i,e){const t=e.tt/Ys,n=gs(i[jc],t,!0),s=gs(i[el],t,!1),r=gs(i[tl],t,!1),a=od(n,s,r);return nl(a).ToAstroVector(e)}function il(i,e){const t=e/Ys,n=gs(i[jc],t,!0),s=gs(i[el],t,!1),r=gs(i[tl],t,!1),a=Po(i[jc],t),o=Po(i[el],t),c=Po(i[tl],t),l=Math.cos(n),h=Math.sin(n),d=Math.cos(s),u=Math.sin(s),p=+(c*d*l)-r*u*l*o-r*d*h*a,g=+(c*d*h)-r*u*h*o+r*d*l*a,x=+(c*u)+r*d*o,m=od(n,s,r),f=[p/Ys,g/Ys,x/Ys],A=nl(m),w=nl(f);return new Ii(e,A,w)}function $r(i,e,t,n){const s=n/(n+Pl),r=Qs(kn[t],e);i.x+=s*r.x,i.y+=s*r.y,i.z+=s*r.z}function Gx(i){const e=new vt(0,0,0,i);return $r(e,i,Ee.Jupiter,Yc),$r(e,i,Ee.Saturn,Kc),$r(e,i,Ee.Uranus,Zc),$r(e,i,Ee.Neptune,$c),e}const sl=51,Hx=29200,ls=146,On=201,Ri=[[-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 Nt{constructor(e,t,n){this.x=e,this.y=t,this.z=n}clone(){return new Nt(this.x,this.y,this.z)}ToAstroVector(e){return new vt(this.x,this.y,this.z,e)}static zero(){return new Nt(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(e){return new Nt(this.x+e.x,this.y+e.y,this.z+e.z)}sub(e){return new Nt(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 Nt(e*this.x,e*this.y,e*this.z)}div(e){return new Nt(this.x/e,this.y/e,this.z/e)}mean(e){return new Nt((this.x+e.x)/2,(this.y+e.y)/2,(this.z+e.z)/2)}neg(){return new Nt(-this.x,-this.y,-this.z)}}class Ii{constructor(e,t,n){this.tt=e,this.r=t,this.v=n}clone(){return new Ii(this.tt,this.r,this.v)}sub(e){return new Ii(this.tt,this.r.sub(e.r),this.v.sub(e.v))}}function Vx(i){let[e,[t,n,s],[r,a,o]]=i;return new Ii(e,new Nt(t,n,s),new Nt(r,a,o))}function Jr(i,e,t,n){const s=n/(n+Pl),r=il(kn[t],e);return i.r.incr(r.r.mul(s)),i.v.incr(r.v.mul(s)),r}function ks(i,e,t){const n=t.sub(i),s=n.quadrature();return n.mul(e/(s*Math.sqrt(s)))}class ka{constructor(e){let t=new Ii(e,new Nt(0,0,0),new Nt(0,0,0));this.Jupiter=Jr(t,e,Ee.Jupiter,Yc),this.Saturn=Jr(t,e,Ee.Saturn,Kc),this.Uranus=Jr(t,e,Ee.Uranus,Zc),this.Neptune=Jr(t,e,Ee.Neptune,$c),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 Ii(e,t.r.mul(-1),t.v.mul(-1))}Acceleration(e){let t=ks(e,Pl,this.Sun.r);return t.incr(ks(e,Yc,this.Jupiter.r)),t.incr(ks(e,Kc,this.Saturn.r)),t.incr(ks(e,Zc,this.Uranus.r)),t.incr(ks(e,$c,this.Neptune.r)),t}}class Ga{constructor(e,t,n,s){this.tt=e,this.r=t,this.v=n,this.a=s}clone(){return new Ga(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class cd{constructor(e,t){this.bary=e,this.grav=t}}function Ca(i,e,t,n){return new Nt(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 xu(i,e,t){return new Nt(e.x+i*t.x,e.y+i*t.y,e.z+i*t.z)}function rl(i,e){const t=i-e.tt,n=new ka(i),s=Ca(t,e.r,e.v,e.a),r=n.Acceleration(s).mean(e.a),a=Ca(t,e.r,e.v,r),o=e.v.add(r.mul(t)),c=n.Acceleration(a),l=new Ga(i,a,o,c);return new cd(n,l)}const Wx=[];function ld(i,e){const t=Math.floor(i);return t<0?0:t>=e?e-1:t}function al(i){const e=Vx(i),t=new ka(e.tt),n=e.r.add(t.Sun.r),s=e.v.add(t.Sun.v),r=t.Acceleration(n),a=new Ga(e.tt,n,s,r);return new cd(t,a)}function Xx(i,e){const t=Ri[0][0];if(e<t||e>Ri[sl-1][0])return null;const n=ld((e-t)/Hx,sl-1);if(!i[n]){const r=i[n]=[];r[0]=al(Ri[n]).grav,r[On-1]=al(Ri[n+1]).grav;let a,o=r[0].tt;for(a=1;a<On-1;++a)r[a]=rl(o+=ls,r[a-1]).grav;o=r[On-1].tt;var s=[];for(s[On-1]=r[On-1],a=On-2;a>0;--a)s[a]=rl(o-=ls,s[a+1]).grav;for(a=On-2;a>0;--a){const c=a/(On-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 Mu(i,e,t){let n=al(i);const s=Math.ceil((e-n.grav.tt)/t);for(let r=0;r<s;++r)n=rl(r+1===s?e:n.grav.tt+t,n.grav);return n}function hd(i,e){let t,n,s;const r=Xx(Wx,i.tt);if(r){const a=ld((i.tt-r[0].tt)/ls,On-1),o=r[a],c=r[a+1],l=o.a.mean(c.a),h=Ca(i.tt-o.tt,o.r,o.v,l),d=xu(i.tt-o.tt,o.v,l),u=Ca(i.tt-c.tt,c.r,c.v,l),p=xu(i.tt-c.tt,c.v,l),g=(i.tt-o.tt)/ls;t=h.mul(1-g).add(u.mul(g)),n=d.mul(1-g).add(p.mul(g))}else{let a;i.tt<Ri[0][0]?a=Mu(Ri[0],i.tt,-ls):a=Mu(Ri[sl-1],i.tt,+ls),t=a.grav.r,n=a.grav.v,s=a.bary}return s||(s=new ka(i.tt)),t=t.sub(s.Sun.r),n=n.sub(s.Sun.v),new li(t.x,t.y,t.z,n.x,n.y,n.z,i)}function Ci(i,e){var t=on(e);if(i in kn)return Qs(kn[i],t);if(i===Ee.Pluto){const a=hd(t);return new vt(a.x,a.y,a.z,t)}if(i===Ee.Sun)return new vt(0,0,0,t);if(i===Ee.Moon){var n=Qs(kn.Earth,t),s=ys(t);return new vt(n.x+s.x,n.y+s.y,n.z+s.z,t)}if(i===Ee.EMB){const a=Qs(kn.Earth,t),o=ys(t),c=1+j0;return new vt(a.x+o.x/c,a.y+o.y/c,a.z+o.z/c,t)}if(i===Ee.SSB)return Gx(t);const r=Dl(i);if(r){const a=new Lx(r.dec,15*r.ra,r.dist);return s2(a,t)}throw`HelioVector: Unknown body "${i}"`}function qx(i,e){let t=e,n=0;for(let s=0;s<10;++s){const r=i(t),a=r.Length()/$0;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 Yx{constructor(e,t,n,s){this.observerBody=e,this.targetBody=t,this.aberration=n,this.observerPos=s}Position(e){this.aberration&&(this.observerPos=Ci(this.observerBody,e));const t=Ci(this.targetBody,e);return new vt(t.x-this.observerPos.x,t.y-this.observerPos.y,t.z-this.observerPos.z,e)}}function Kx(i,e,t,n){Aa(n);const s=on(i);if(Dl(t)){const o=Ci(t,s);if(n){const l=$x(e,s),h=new vt(o.x-l.x,o.y-l.y,o.z-l.z,s),d=$0/h.Length();return new vt(h.x+l.vx/d,h.y+l.vy/d,h.z+l.vz/d,s)}const c=Ci(e,s);return new vt(o.x-c.x,o.y-c.y,o.z-c.z,s)}let r;n?r=new vt(0,0,0,s):r=Ci(e,s);const a=new Yx(e,t,n,r);return qx(o=>a.Position(o),s)}function ol(i,e,t){Aa(t);const n=on(e);switch(i){case Ee.Earth:return new vt(0,0,0,n);case Ee.Moon:return ys(n);default:const s=Kx(n,Ee.Earth,i,t);return s.t=n,s}}function Zx(i,e){return new li(i.r.x,i.r.y,i.r.z,i.v.x,i.v.y,i.v.z,e)}function $x(i,e){const t=on(e);switch(i){case Ee.Sun:return new li(0,0,0,0,0,0,t);case Ee.SSB:const n=new ka(t.tt);return new li(-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 Ee.Mercury:case Ee.Venus:case Ee.Earth:case Ee.Mars:case Ee.Jupiter:case Ee.Saturn:case Ee.Uranus:case Ee.Neptune:const s=il(kn[i],t.tt);return Zx(s,t);case Ee.Pluto:return hd(t);case Ee.Moon:case Ee.EMB:const r=il(kn.Earth,t.tt),a=i==Ee.Moon?ad(t):kx(t);return new li(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(Dl(i)){const o=Ci(i,t);return new li(o.x,o.y,o.z,0,0,0,t)}throw`HelioState: Unsupported body "${i}"`}}function Jx(i){for(;i<0;)i+=360;for(;i>=360;)i-=360;return i}function Qx(i,e,t){if(i===Ee.Earth||e===Ee.Earth)throw"The Earth does not have a longitude as seen from itself.";const n=on(t),s=ol(i,n,!1),r=Qc(s),a=ol(e,n,!1),o=Qc(a);return Jx(r.elon-o.elon)}function jx(i,e,t,n){let s,r=0,a=0,o=0;switch(i){case Ee.Mercury:s=-.6,r=4.98,a=-4.88,o=3.02;break;case Ee.Venus:e<163.6?(s=-4.47,r=1.03,a=.57,o=.13):(s=.98,r=-1.02);break;case Ee.Mars:s=-1.52,r=1.6;break;case Ee.Jupiter:s=-9.4,r=.5;break;case Ee.Uranus:s=-7.19,r=.25;break;case Ee.Neptune:s=-6.87;break;case Ee.Pluto:s=-1,r=4;break;default:throw`VisualMagnitude: unsupported body ${i}`}const c=e/100;let l=s+c*(r+c*(a+c*o));return l+=5*Math.log10(t*n),l}function e2(i,e,t,n,s){const r=Qc(n),a=it*28.06,o=it*(169.51+382e-7*s.tt),c=it*r.elat,l=it*r.elon,h=Math.asin(Math.sin(c)*Math.cos(a)-Math.cos(c)*Math.sin(a)*Math.sin(l-o)),d=Math.sin(Math.abs(h));let u=-9+.044*i;return u+=d*(-2.6+1.2*d),u+=5*Math.log10(e*t),{mag:u,ring_tilt:ui*h}}function t2(i,e,t){let n=i*it,s=n*n,r=s*s,a=-12.717+1.49*Math.abs(n)+.0431*r;const o=385000.6/Ti;let c=t/o;return a+=5*Math.log10(e*c),a}class n2{constructor(e,t,n,s,r,a,o,c){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=c,this.phase_fraction=(1+Math.cos(it*n))/2}}function ud(i,e){if(i===Ee.Earth)throw"The illumination of the Earth is not defined.";const t=on(e),n=Qs(kn.Earth,t);let s,r,a,o;i===Ee.Sun?(a=new vt(-n.x,-n.y,-n.z,t),r=new vt(0,0,0,t),s=0):(i===Ee.Moon?(a=ys(t),r=new vt(n.x+a.x,n.y+a.y,n.z+a.z,t)):(r=Ci(i,e),a=new vt(r.x-n.x,r.y-n.y,r.z-n.z,t)),s=vx(a,r));let c=a.Length(),l=r.Length(),h;if(i===Ee.Sun)o=mx+5*Math.log10(c);else if(i===Ee.Moon)o=t2(s,l,c);else if(i===Ee.Saturn){const d=e2(s,l,c,a,t);o=d.mag,h=d.ring_tilt}else o=jx(i,s,l,c);return new n2(t,o,s,l,c,a,r,h)}function i2(i){return Qx(Ee.Moon,Ee.Sun,i)}var Su;(function(i){i[i.Pericenter=0]="Pericenter",i[i.Apocenter=1]="Apocenter"})(Su||(Su={}));function s2(i,e){e=on(e);const t=i.lat*it,n=i.lon*it,s=i.dist*Math.cos(t);return new vt(s*Math.cos(n),s*Math.sin(n),i.dist*Math.sin(t),e)}function r2(i,e){let t;if(Rt(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))*it)/60,e<-1&&(t*=(e+90)/89)}return t}var yu;(function(i){i.Penumbral="penumbral",i.Partial="partial",i.Annular="annular",i.Total="total"})(yu||(yu={}));var Eu;(function(i){i[i.Invalid=0]="Invalid",i[i.Ascending=1]="Ascending",i[i.Descending=-1]="Descending"})(Eu||(Eu={}));const a2=["Venus","Mars","Jupiter","Saturn"];function dd(i){return new rd(i.lat,i.lng,i.elevationM)}function fd(i,e,t,n){const s=sd(t,dd(n),i,e,"normal");return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}function Do(i,e,t){const n=dd(t),s=zx(Ee[i],e,n,!0,!0),r=sd(e,n,s.ra,s.dec,"normal");return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}function Io(i,e){return ud(Ee[i],e).mag}function o2(i){const e=i2(i),t=ud(Ee.Moon,i);return{phaseFraction:e/360,illuminatedFraction:t.phase_fraction}}const c2=2e3,l2=3,h2=20;function bu(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??c2,r=i.month??(n?1:l2),a=i.day??(n?1:h2),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))}const pd=Math.PI/180,u2=180/Math.PI,d2=256,f2=19;function p2(i,e){return 156543.03392*Math.cos(i*pd)/2**e}function m2(i,e){return p2(i,e)*d2}function md(i,e){let t=0;for(;t<f2&&m2(i,t+1)>=e;)t++;return t}function gd(i,e,t){const n=2**t,s=(i+180)/360*n,r=e*pd,a=(1-Math.log(Math.tan(r)+1/Math.cos(r))/Math.PI)/2*n;return{x:s,y:a}}function g2(i,e,t){const{x:n,y:s}=gd(i,e,t);return{x:Math.floor(n),y:Math.floor(s),z:t}}function _2(i){const e=2**i.z,t=i.x/e*360-180,n=(i.x+1)/e*360-180,s=Tu(i.y,e);return{south:Tu(i.y+1,e),north:s,west:t,east:n}}function Tu(i,e){const t=i/e;return Math.atan(Math.sinh(Math.PI*(1-2*t)))*u2}function _d(i,e,t,n){const s=g2(i,e,t),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:t});const o=a.map(_2),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 vd=Math.PI/180,Pa=111320;function Li(i,e,t,n){const s=Pa*Math.cos(t*vd),r=(i-t)*Pa;return{x:(e-n)*s,z:-r}}function Qr(i,e,t,n){const s=Pa*Math.cos(t*vd),r=-e,a=i;return{lat:t+r/Pa,lng:n+a/s}}const Qt=256,Au=3,v2=32768;class x2{fetchImpl;tileUrlTemplate;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=e.tileUrlTemplate??"https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"}async getElevationGrid(e,t){const n=(e.south+e.north)/2,s=(e.west+e.east)/2,r=Math.abs(Li(n,e.east,n,e.west).x),a=Math.abs(Li(e.north,s,e.south,s).z),o=md(n,Math.max(r,a)),{tiles:c}=_d(s,n,o,Au),l=Au*Qt,h=new Float32Array(l*l),d=c[0];await Promise.all(c.map(p=>this.decodeTileInto(p,d,h,l)));const u=new Float32Array(t.width*t.height);for(let p=0;p<t.height;p++){const g=e.north+(e.south-e.north)*(p/(t.height-1));for(let x=0;x<t.width;x++){const m=e.west+(e.east-e.west)*(x/(t.width-1));u[p*t.width+x]=this.sampleAt(g,m,o,d,h,l)}}return{heights:u,width:t.width,height:t.height,bounds:e}}async decodeTileInto(e,t,n,s){const r=this.tileUrlTemplate.replace("{z}",String(e.z)).replace("{x}",String(e.x)).replace("{y}",String(e.y)),a=await this.fetchImpl(r);if(!a.ok)throw new Error(`Elevation tile fetch failed (${a.status}): ${r}`);const o=await createImageBitmap(await a.blob()),c=document.createElement("canvas");c.width=Qt,c.height=Qt;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,Qt,Qt),d=(e.x-t.x)*Qt,u=(e.y-t.y)*Qt;for(let p=0;p<Qt;p++)for(let g=0;g<Qt;g++){const x=(p*Qt+g)*4,m=h[x]*256+h[x+1]+h[x+2]/256-v2,f=d+g,A=u+p;n[A*s+f]=m}}sampleAt(e,t,n,s,r,a){const{x:o,y:c}=gd(t,e,n),l=(o-s.x)*Qt,h=(c-s.y)*Qt,d=Math.max(0,Math.min(a-1,Math.floor(l))),u=Math.max(0,Math.min(a-1,Math.floor(h))),p=Math.min(a-1,d+1),g=Math.min(a-1,u+1),x=l-d,m=h-u,f=r[u*a+d],A=r[u*a+p],w=r[g*a+d],M=r[g*a+p],y=f+(A-f)*x,b=w+(M-w)*x;return y+(b-y)*m}}const Lo=256,wu=3;async function M2(i,e,t,n){const s=(i.south+i.north)/2,r=(i.west+i.east)/2,a=Math.abs(Li(s,i.east,s,i.west).x),o=Math.abs(Li(i.north,r,i.south,r).z),c=md(s,Math.max(a,o)),{tiles:l}=_d(r,s,c,wu),h=wu*Lo,d=document.createElement("canvas");d.width=h,d.height=h;const u=d.getContext("2d");if(!u)throw new Error("2D canvas context unavailable");const p=l[0];await Promise.all(l.map(async m=>{const f=t(m),A=await n(f);if(!A.ok)throw new Error(`Imagery tile fetch failed (${A.status}): ${f}`);const w=await createImageBitmap(await A.blob());u.drawImage(w,(m.x-p.x)*Lo,(m.y-p.y)*Lo)}));const g=document.createElement("canvas");g.width=e.width,g.height=e.height;const x=g.getContext("2d");if(!x)throw new Error("2D canvas context unavailable");return x.drawImage(d,0,0,h,h,0,0,e.width,e.height),g}class S2{attribution="Imagery © Esri, Maxar, Earthstar Geographics, and the GIS User Community";fetchImpl;tileUrlTemplate;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=e.tileUrlTemplate??"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"}async getImageryTexture(e,t){return{source:await M2(e,t,s=>this.tileUrlTemplate.replace("{z}",String(s.z)).replace("{y}",String(s.y)).replace("{x}",String(s.x)),this.fetchImpl),width:t.width,height:t.height}}}function y2(){return{elevation:new x2,imagery:new S2}}const Ks=64,wt=Ks+1,Ru=512,E2=900,b2=700/900,T2=0,A2=.01;function w2(i,e,t){return{north:Qr(0,-t,i,e).lat,south:Qr(0,t,i,e).lat,east:Qr(t,0,i,e).lng,west:Qr(-t,0,i,e).lng}}async function R2(i,e,t,n=E2){const s=n,r=n*b2,a=w2(i,e,s),o={width:wt,height:wt},[c,l]=await Promise.all([t.elevation.getElevationGrid(a,o),t.imagery.getImageryTexture(a,{width:Ru,height:Ru})]),h=Math.floor(wt/2),d=c.heights[h*wt+h],u=new Float32Array(wt*wt*3),p=new Float32Array(wt*wt*2),g=new Float32Array(wt*wt*4);for(let y=0;y<wt;y++){const b=y/(wt-1),R=a.north+(a.south-a.north)*b;for(let v=0;v<wt;v++){const E=v/(wt-1),P=a.west+(a.east-a.west)*E,{x:C,z:L}=Li(R,P,i,e),X=c.heights[y*wt+v],q=T2+A2+(X-d),F=y*wt+v;u[F*3]=C,u[F*3+1]=q,u[F*3+2]=L,p[F*2]=E,p[F*2+1]=b;const W=Math.max(Math.abs(C),Math.abs(L)),V=1-C2((W-r)/(s-r),0,1);g[F*4]=1,g[F*4+1]=1,g[F*4+2]=1,g[F*4+3]=V}}const x=new Uint16Array(Ks*Ks*6);let m=0;for(let y=0;y<Ks;y++)for(let b=0;b<Ks;b++){const R=y*wt+b,v=R+1,E=R+wt,P=E+1;x[m++]=R,x[m++]=E,x[m++]=v,x[m++]=v,x[m++]=E,x[m++]=P}const f=new St;f.setAttribute("position",new lt(u,3)),f.setAttribute("uv",new lt(p,2)),f.setAttribute("color",new lt(g,4)),f.setIndex(new lt(x,1)),f.computeVertexNormals();const A=new qn(l.source);A.flipY=!1;const w=new lr({map:A,color:new xe(1,1,1),vertexColors:!0,transparent:!0,fog:!0,depthTest:!1}),M=new ut(f,w);return M.receiveShadow=!0,M.castShadow=!0,{mesh:M,attribution:t.imagery.attribution}}function C2(i,e,t){return Math.max(e,Math.min(t,i))}const P2=18,D2=.55,I2=.5,L2=`
|
|
4446
|
+
*/const k0=173.1446326846693,bi=14959787069098932e-8,it=.017453292519943295,ru=.26179938779914946,ui=57.29577951308232,G0=3.819718634205488,e2=365.24217,au=new Date("2000-01-01T12:00:00Z"),On=2*Math.PI,ii=3600*(180/Math.PI),ls=484813681109536e-20,H0=10800*60,t2=2*H0,ou=7292115e-11,n2=H0/Math.PI,i2=-.17-5*Math.log10(n2),Bc=.996647180302104,s2=Bc*Bc,kc=6378.1366,r2=kc/bi,V0=81.30056,Tl=.0002959122082855911,Gc=2825345909524226e-22,Hc=8459715185680659e-23,Vc=1292024916781969e-23,Wc=1524358900784276e-23;function Sa(i){if(i!==!0&&i!==!1)throw console.trace(),`Value is not boolean: ${i}`;return i}function Ct(i){if(!Number.isFinite(i))throw console.trace(),`Value is not a finite number: ${i}`;return i}function ns(i){return i-Math.floor(i)}function a2(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:ui*Math.acos(s)}var Ee;(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"})(Ee||(Ee={}));const o2=[Ee.Star1,Ee.Star2,Ee.Star3,Ee.Star4,Ee.Star5,Ee.Star6,Ee.Star7,Ee.Star8],c2=[{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 l2(i){const e=o2.indexOf(i);return e>=0?c2[e]:null}function Al(i){const e=l2(i);return e&&e.dist>0?e:null}var an;(function(i){i[i.From2000=0]="From2000",i[i.Into2000=1]="Into2000"})(an||(an={}));const kn={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 h2(i){var e,t,n,s,r,a,o;const c=2e3+(i-14)/e2;return c<-500?(e=(c-1820)/100,-20+32*e*e):c<500?(e=c/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):c<1600?(e=(c-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):c<1700?(e=c-1600,t=e*e,n=e*t,120-.9808*e-.01532*t+n/7129):c<1800?(e=c-1700,t=e*e,n=e*t,s=t*t,8.83+.1603*e-.0059285*t+13336e-8*n-s/1174e3):c<1860?(e=c-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):c<1900?(e=c-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):c<1920?(e=c-1900,t=e*e,n=e*t,s=t*t,-2.79+1.494119*e-.0598939*t+.0061966*n-197e-6*s):c<1941?(e=c-1920,t=e*e,n=e*t,21.2+.84493*e-.0761*t+.0020936*n):c<1961?(e=c-1950,t=e*e,n=e*t,29.07+.407*e-t/233+n/2547):c<1986?(e=c-1975,t=e*e,n=e*t,45.45+1.067*e-t/260-n/718):c<2005?(e=c-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):c<2050?(e=c-2e3,62.92+.32217*e+.005589*e*e):c<2150?(e=(c-1820)/100,-20+32*e*e-.5628*(2150-c)):(e=(c-1820)/100,-20+32*e*e)}let u2=h2;function cu(i){return i+u2(i)/86400}class gs{constructor(e){if(e instanceof gs){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()-au.getTime())/t,this.tt=cu(this.ut);return}if(Number.isFinite(e)){this.date=new Date(au.getTime()+e*t),this.ut=e,this.tt=cu(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 gs(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 gs(this.ut+e)}}function on(i){return i instanceof gs?i:new gs(i)}function d2(i){function e(u){return u%t2*ls}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),c=Math.cos(a),l=(-172064161-174666*t)*o+33386*c,h=(92052331+9086*t)*c+15377*o,d=2*(s-r+a);return o=Math.sin(d),c=Math.cos(d),l+=(-13170906-1675*t)*o-13696*c,h+=(5730336-3015*t)*c-4587*o,d=2*(s+a),o=Math.sin(d),c=Math.cos(d),l+=(-2276413-234*t)*o+2796*c,h+=(978459-485*t)*c+1374*o,d=2*a,o=Math.sin(d),c=Math.cos(d),l+=(2074554+207*t)*o-698*c,h+=(-897492+470*t)*c-291*o,o=Math.sin(n),c=Math.cos(n),l+=(1475877-3633*t)*o+11817*c,h+=(73871-184*t)*c-1924*o,{dpsi:-135e-6+l*1e-7,deps:388e-6+h*1e-7}}function W0(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 Xr;function wl(i){if(!Xr||Math.abs(Xr.tt-i.tt)>1e-6){const e=d2(i),t=W0(i),n=t+e.deps/3600;Xr={tt:i.tt,dpsi:e.dpsi,deps:e.deps,ee:e.dpsi*Math.cos(t*it)/15,mobl:t,tobl:n}}return Xr}function f2(i,e){const t=i*it,n=Math.cos(t),s=Math.sin(t);return[e[0],e[1]*n-e[2]*s,e[1]*s+e[2]*n]}function p2(i,e){return f2(W0(i),e)}function m2(i){const e=i.tt/36525;function t(Re,xe){const Ue=[];let Ie;for(Ie=0;Ie<=xe-Re;++Ie)Ue.push(0);return{min:Re,array:Ue}}function n(Re,xe,Ue,Ie){const Le=[];for(let Ze=0;Ze<=xe-Re;++Ze)Le.push(t(Ue,Ie));return{min:Re,array:Le}}function s(Re,xe,Ue){const Ie=Re.array[xe-Re.min];return Ie.array[Ue-Ie.min]}function r(Re,xe,Ue,Ie){const Le=Re.array[xe-Re.min];Le.array[Ue-Le.min]=Ie}let a,o,c,l,h,d,u,p,g,M,m,f,T,w,x,y,b,R,v,E,P,C,L,X=n(-6,6,1,4),q=n(-6,6,1,4);function F(Re,xe){return s(X,Re,xe)}function W(Re,xe){return s(q,Re,xe)}function V(Re,xe,Ue){return r(X,Re,xe,Ue)}function Q(Re,xe,Ue){return r(q,Re,xe,Ue)}function te(Re,xe,Ue,Ie,Le){Le(Re*Ue-xe*Ie,xe*Ue+Re*Ie)}function ee(Re){return Math.sin(On*Re)}u=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),st=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*st+.28*We+.24*Z,v=2.94*se+.31*ge+14.27*Ve+9.34*st+1.12*We+.83*Z,E=-6.4*se-1.89*Z,P=.21*se+.31*ge+14.27*Ve-88.7*st-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),T=On*ns(.60643382+1336.85522467*e-313e-8*u)+R/ii,w=On*ns(.37489701+1325.55240982*e+2565e-8*u)+v/ii,x=On*ns(.99312619+99.99735956*e-44e-8*u)+E/ii,y=On*ns(.25909118+1342.2278298*e-892e-8*u)+P/ii,b=On*ns(.82736186+1236.85308708*e-397e-8*u)+C/ii,h=1;h<=4;++h){switch(h){case 1:c=w,o=4,l=1.000002208;break;case 2:c=x,o=3,l=.997504612-.002495388*e;break;case 3:c=y,o=4,l=1.000002708+139.978*p;break;case 4:c=b,o=6,l=1;break;default:throw`Internal error: I = ${h}`}for(V(0,h,1),V(1,h,Math.cos(c)*l),Q(0,h,0),Q(1,h,Math.sin(c)*l),d=2;d<=o;++d)te(F(d-1,h),W(d-1,h),F(1,h),W(1,h),(Re,xe)=>(V(d,h,Re),Q(d,h,xe)));for(d=1;d<=o;++d)V(-d,h,F(d,h)),Q(-d,h,-W(d,h))}function ne(Re,xe,Ue,Ie){for(var Le={x:1,y:0},Ze=[0,Re,xe,Ue,Ie],$e=1;$e<=4;++$e)Ze[$e]!==0&&te(Le.x,Le.y,F(Ze[$e],$e),W(Ze[$e],$e),(dt,ct)=>(Le.x=dt,Le.y=ct));return Le}function k(Re,xe,Ue,Ie,Le,Ze,$e,dt){var ct=ne(Le,Ze,$e,dt);g+=Re*ct.y,L+=xe*ct.y,m+=Ue*ct.x,f+=Ie*ct.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 Pe(Re,xe,Ue,Ie,Le){return Re*ne(xe,Ue,Ie,Le).y}M=0,M+=Pe(-526.069,0,0,1,-2),M+=Pe(-3.352,0,0,1,-4),M+=Pe(44.297,1,0,1,-2),M+=Pe(-6,1,0,1,-4),M+=Pe(20.599,-1,0,1,0),M+=Pe(-30.598,-1,0,1,-2),M+=Pe(-24.649,-2,0,1,0),M+=Pe(-2,-2,0,1,-2),M+=Pe(-22.571,0,1,1,-2),M+=Pe(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=y+L/ii;let De=(1.000002708+139.978*p)*(18518.511+1.189+m)*Math.sin(a)-6.24*Math.sin(3*a)+M;return{geo_eclip_lon:On*ns((T+g/ii)/On),geo_eclip_lat:Math.PI/(180*3600)*De,distance_au:ii*r2/(.999953253*f)}}function X0(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 ya(i,e,t){const n=g2(e,t);return X0(n,i)}function g2(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*=ls,s*=ls,r*=ls,a*=ls;const o=Math.sin(n),c=Math.cos(n),l=Math.sin(-s),h=Math.cos(-s),d=Math.sin(-r),u=Math.cos(-r),p=Math.sin(a),g=Math.cos(a),M=g*h-l*p*u,m=g*l*c+p*u*h*c-o*p*d,f=g*l*o+p*u*h*o+c*p*d,T=-p*h-l*g*u,w=-p*l*c+g*u*h*c-o*g*d,x=-p*l*o+g*u*h*o+c*g*d,y=l*d,b=-d*h*c-o*u,R=-d*h*o+u*c;if(e===an.Into2000)return new Ea([[M,m,f],[T,w,x],[y,b,R]]);if(e===an.From2000)return new Ea([[M,T,y],[m,w,b],[f,x,R]]);throw"Invalid precess direction"}function _2(i){const e=.779057273264+.00273781191135448*i.ut,t=i.ut%1;let n=360*((e+t)%1);return n<0&&(n+=360),n}let qr;function q0(i){if(!qr||qr.tt!==i.tt){const e=i.tt/36525;let t=15*wl(i).ee;const n=_2(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),qr={tt:i.tt,st:r}}return qr.st}function v2(i,e){const t=i.latitude*it,n=Math.sin(t),s=Math.cos(t),r=1/Math.hypot(s,Bc*n),a=s2*r,o=i.height/1e3,c=kc*r+o,l=kc*a+o,h=(15*e+i.longitude)*it,d=Math.sin(h),u=Math.cos(h);return{pos:[c*s*u/bi,c*s*d/bi,l*n/bi],vel:[-ou*c*s*d*86400/bi,ou*c*s*u*86400/bi,0]}}function Xc(i,e,t){const n=x2(e,t);return X0(n,i)}function x2(i,e){const t=wl(i),n=t.mobl*it,s=t.tobl*it,r=t.dpsi*ls,a=Math.cos(n),o=Math.sin(n),c=Math.cos(s),l=Math.sin(s),h=Math.cos(r),d=Math.sin(r),u=h,p=-d*a,g=-d*o,M=d*c,m=h*a*c+o*l,f=h*o*c-a*l,T=d*l,w=h*a*l-o*c,x=h*o*l+a*c;if(e===an.From2000)return new Ea([[u,M,T],[p,m,w],[g,f,x]]);if(e===an.Into2000)return new Ea([[u,p,g],[M,m,f],[T,w,x]]);throw"Invalid precess direction"}function Y0(i,e,t){return t===an.Into2000?ya(Xc(i,e,t),e,t):Xc(ya(i,e,t),e,t)}function M2(i,e){const t=q0(i),n=v2(e,t).pos;return Y0(n,i,an.Into2000)}class vt{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 li{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 S2{constructor(e,t,n){this.lat=Ct(e),this.lon=Ct(t),this.dist=Ct(n)}}class lu{constructor(e,t,n,s){this.ra=Ct(e),this.dec=Ct(t),this.dist=Ct(n),this.vec=s}}class Ea{constructor(e){this.rot=e}}class y2{constructor(e,t,n,s){this.azimuth=Ct(e),this.altitude=Ct(t),this.ra=Ct(n),this.dec=Ct(s)}}class E2{constructor(e,t,n){this.vec=e,this.elat=Ct(t),this.elon=Ct(n)}}function b2(i,e){return new vt(i[0],i[1],i[2],e)}function T2(i,e){const t=b2(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 lu(0,t.z<0?-90:90,s,t)}let r=G0*Math.atan2(t.y,t.x);r<0&&(r+=24);const a=ui*Math.atan2(i[2],Math.sqrt(n));return new lu(r,a,s,t)}function Eo(i,e){const t=i*it,n=Math.cos(t),s=Math.sin(t);return[n*e[0]+s*e[1],n*e[1]-s*e[0],e[2]]}function K0(i,e,t,n,s){let r=on(i);Rl(e),Ct(t),Ct(n);const a=Math.sin(e.latitude*it),o=Math.cos(e.latitude*it),c=Math.sin(e.longitude*it),l=Math.cos(e.longitude*it),h=Math.sin(n*it),d=Math.cos(n*it),u=Math.sin(t*ru),p=Math.cos(t*ru);let g=[o*l,o*c,a],M=[-a*l,-a*c,o],m=[c,-l,0];const f=-15*q0(r);let T=Eo(f,g),w=Eo(f,M),x=Eo(f,m),y=[d*p,d*u,h];const b=y[0]*T[0]+y[1]*T[1]+y[2]*T[2],R=y[0]*w[0]+y[1]*w[1]+y[2]*w[2],v=y[0]*x[0]+y[1]*x[1]+y[2]*x[2];let E=Math.hypot(R,v),P;E>0?(P=-ui*Math.atan2(v,R),P<0&&(P+=360)):P=0;let C=ui*Math.atan2(E,b),L=t,X=n;{let q=C,F=Y2(s,90-C);if(C-=F,F>0&&C>3e-4){const W=Math.sin(C*it),V=Math.cos(C*it),Q=Math.sin(q*it),te=Math.cos(q*it),ee=[];for(let se=0;se<3;++se)ee.push((y[se]-te*T[se])/Q*W+T[se]*V);E=Math.hypot(ee[0],ee[1]),E>0?(L=G0*Math.atan2(ee[1],ee[0]),L<0&&(L+=24)):L=0,X=ui*Math.atan2(ee[2],E)}}return new y2(P,90-C,L,X)}function Rl(i){if(!(i instanceof Z0))throw`Not an instance of the Observer class: ${i}`;if(Ct(i.latitude),Ct(i.longitude),Ct(i.height),i.latitude<-90||i.latitude>90)throw`Latitude ${i.latitude} is out of range. Must be -90..+90.`;return i}class Z0{constructor(e,t,n){this.latitude=e,this.longitude=t,this.height=n,Rl(this)}}function A2(i,e,t,n,s){Rl(t),Sa(n),Sa(s);const r=on(e),a=M2(r,t),o=tl(i,r,s),c=[o.x-a[0],o.y-a[1],o.z-a[2]],l=Y0(c,r,an.From2000);return T2(l,r)}function w2(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=ui*Math.atan2(s,n),o<0&&(o+=360));let c=ui*Math.atan2(r,a),l=new vt(n,s,r,i.t);return new E2(l,c,o)}function qc(i){const e=wl(i.t),t=[i.x,i.y,i.z],n=ya(t,i.t,an.From2000),[s,r,a]=Xc(n,i.t,an.From2000),o=new vt(s,r,a,i.t),c=e.tobl*it;return w2(o,Math.cos(c),Math.sin(c))}function bs(i){const e=on(i),t=m2(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=p2(e,s),a=ya(r,e,an.Into2000);return new vt(a[0],a[1],a[2],e)}function $0(i){const e=on(i),t=1e-5,n=e.AddDays(-t),s=e.AddDays(+t),r=bs(n),a=bs(s);return new li((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 R2(i){const e=on(i),t=$0(e),n=1+V0;return new li(t.x/n,t.y/n,t.z/n,t.vx/n,t.vy/n,t.vz/n,e)}function _s(i,e,t){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+e*h);let o=n*a;t&&(o%=On),s+=o,n*=e}return s}function bo(i,e){let t=1,n=0,s=0,r=0;for(let a of i){let o=0,c=0;for(let[l,h,d]of a){let u=h+e*d;o+=l*d*Math.sin(u),r>0&&(c+=l*Math.cos(u))}s+=r*n*c-t*o,n=t,t*=e,++r}return s}const Ks=365250,Yc=0,Kc=1,Zc=2;function $c(i){return new Ut(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 J0(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 js(i,e){const t=e.tt/Ks,n=_s(i[Yc],t,!0),s=_s(i[Kc],t,!1),r=_s(i[Zc],t,!1),a=J0(n,s,r);return $c(a).ToAstroVector(e)}function Jc(i,e){const t=e/Ks,n=_s(i[Yc],t,!0),s=_s(i[Kc],t,!1),r=_s(i[Zc],t,!1),a=bo(i[Yc],t),o=bo(i[Kc],t),c=bo(i[Zc],t),l=Math.cos(n),h=Math.sin(n),d=Math.cos(s),u=Math.sin(s),p=+(c*d*l)-r*u*l*o-r*d*h*a,g=+(c*d*h)-r*u*h*o+r*d*l*a,M=+(c*u)+r*d*o,m=J0(n,s,r),f=[p/Ks,g/Ks,M/Ks],T=$c(m),w=$c(f);return new Ii(e,T,w)}function Yr(i,e,t,n){const s=n/(n+Tl),r=js(kn[t],e);i.x+=s*r.x,i.y+=s*r.y,i.z+=s*r.z}function C2(i){const e=new vt(0,0,0,i);return Yr(e,i,Ee.Jupiter,Gc),Yr(e,i,Ee.Saturn,Hc),Yr(e,i,Ee.Uranus,Vc),Yr(e,i,Ee.Neptune,Wc),e}const Qc=51,P2=29200,hs=146,zn=201,Ri=[[-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 Ut{constructor(e,t,n){this.x=e,this.y=t,this.z=n}clone(){return new Ut(this.x,this.y,this.z)}ToAstroVector(e){return new vt(this.x,this.y,this.z,e)}static zero(){return new Ut(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(e){return new Ut(this.x+e.x,this.y+e.y,this.z+e.z)}sub(e){return new Ut(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 Ut(e*this.x,e*this.y,e*this.z)}div(e){return new Ut(this.x/e,this.y/e,this.z/e)}mean(e){return new Ut((this.x+e.x)/2,(this.y+e.y)/2,(this.z+e.z)/2)}neg(){return new Ut(-this.x,-this.y,-this.z)}}class Ii{constructor(e,t,n){this.tt=e,this.r=t,this.v=n}clone(){return new Ii(this.tt,this.r,this.v)}sub(e){return new Ii(this.tt,this.r.sub(e.r),this.v.sub(e.v))}}function D2(i){let[e,[t,n,s],[r,a,o]]=i;return new Ii(e,new Ut(t,n,s),new Ut(r,a,o))}function Kr(i,e,t,n){const s=n/(n+Tl),r=Jc(kn[t],e);return i.r.incr(r.r.mul(s)),i.v.incr(r.v.mul(s)),r}function Gs(i,e,t){const n=t.sub(i),s=n.quadrature();return n.mul(e/(s*Math.sqrt(s)))}class Ua{constructor(e){let t=new Ii(e,new Ut(0,0,0),new Ut(0,0,0));this.Jupiter=Kr(t,e,Ee.Jupiter,Gc),this.Saturn=Kr(t,e,Ee.Saturn,Hc),this.Uranus=Kr(t,e,Ee.Uranus,Vc),this.Neptune=Kr(t,e,Ee.Neptune,Wc),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 Ii(e,t.r.mul(-1),t.v.mul(-1))}Acceleration(e){let t=Gs(e,Tl,this.Sun.r);return t.incr(Gs(e,Gc,this.Jupiter.r)),t.incr(Gs(e,Hc,this.Saturn.r)),t.incr(Gs(e,Vc,this.Uranus.r)),t.incr(Gs(e,Wc,this.Neptune.r)),t}}class Fa{constructor(e,t,n,s){this.tt=e,this.r=t,this.v=n,this.a=s}clone(){return new Fa(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class Q0{constructor(e,t){this.bary=e,this.grav=t}}function ba(i,e,t,n){return new Ut(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 hu(i,e,t){return new Ut(e.x+i*t.x,e.y+i*t.y,e.z+i*t.z)}function jc(i,e){const t=i-e.tt,n=new Ua(i),s=ba(t,e.r,e.v,e.a),r=n.Acceleration(s).mean(e.a),a=ba(t,e.r,e.v,r),o=e.v.add(r.mul(t)),c=n.Acceleration(a),l=new Fa(i,a,o,c);return new Q0(n,l)}const I2=[];function j0(i,e){const t=Math.floor(i);return t<0?0:t>=e?e-1:t}function el(i){const e=D2(i),t=new Ua(e.tt),n=e.r.add(t.Sun.r),s=e.v.add(t.Sun.v),r=t.Acceleration(n),a=new Fa(e.tt,n,s,r);return new Q0(t,a)}function L2(i,e){const t=Ri[0][0];if(e<t||e>Ri[Qc-1][0])return null;const n=j0((e-t)/P2,Qc-1);if(!i[n]){const r=i[n]=[];r[0]=el(Ri[n]).grav,r[zn-1]=el(Ri[n+1]).grav;let a,o=r[0].tt;for(a=1;a<zn-1;++a)r[a]=jc(o+=hs,r[a-1]).grav;o=r[zn-1].tt;var s=[];for(s[zn-1]=r[zn-1],a=zn-2;a>0;--a)s[a]=jc(o-=hs,s[a+1]).grav;for(a=zn-2;a>0;--a){const c=a/(zn-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 uu(i,e,t){let n=el(i);const s=Math.ceil((e-n.grav.tt)/t);for(let r=0;r<s;++r)n=jc(r+1===s?e:n.grav.tt+t,n.grav);return n}function ed(i,e){let t,n,s;const r=L2(I2,i.tt);if(r){const a=j0((i.tt-r[0].tt)/hs,zn-1),o=r[a],c=r[a+1],l=o.a.mean(c.a),h=ba(i.tt-o.tt,o.r,o.v,l),d=hu(i.tt-o.tt,o.v,l),u=ba(i.tt-c.tt,c.r,c.v,l),p=hu(i.tt-c.tt,c.v,l),g=(i.tt-o.tt)/hs;t=h.mul(1-g).add(u.mul(g)),n=d.mul(1-g).add(p.mul(g))}else{let a;i.tt<Ri[0][0]?a=uu(Ri[0],i.tt,-hs):a=uu(Ri[Qc-1],i.tt,+hs),t=a.grav.r,n=a.grav.v,s=a.bary}return s||(s=new Ua(i.tt)),t=t.sub(s.Sun.r),n=n.sub(s.Sun.v),new li(t.x,t.y,t.z,n.x,n.y,n.z,i)}function Ci(i,e){var t=on(e);if(i in kn)return js(kn[i],t);if(i===Ee.Pluto){const a=ed(t);return new vt(a.x,a.y,a.z,t)}if(i===Ee.Sun)return new vt(0,0,0,t);if(i===Ee.Moon){var n=js(kn.Earth,t),s=bs(t);return new vt(n.x+s.x,n.y+s.y,n.z+s.z,t)}if(i===Ee.EMB){const a=js(kn.Earth,t),o=bs(t),c=1+V0;return new vt(a.x+o.x/c,a.y+o.y/c,a.z+o.z/c,t)}if(i===Ee.SSB)return C2(t);const r=Al(i);if(r){const a=new S2(r.dec,15*r.ra,r.dist);return q2(a,t)}throw`HelioVector: Unknown body "${i}"`}function N2(i,e){let t=e,n=0;for(let s=0;s<10;++s){const r=i(t),a=r.Length()/k0;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 U2{constructor(e,t,n,s){this.observerBody=e,this.targetBody=t,this.aberration=n,this.observerPos=s}Position(e){this.aberration&&(this.observerPos=Ci(this.observerBody,e));const t=Ci(this.targetBody,e);return new vt(t.x-this.observerPos.x,t.y-this.observerPos.y,t.z-this.observerPos.z,e)}}function F2(i,e,t,n){Sa(n);const s=on(i);if(Al(t)){const o=Ci(t,s);if(n){const l=z2(e,s),h=new vt(o.x-l.x,o.y-l.y,o.z-l.z,s),d=k0/h.Length();return new vt(h.x+l.vx/d,h.y+l.vy/d,h.z+l.vz/d,s)}const c=Ci(e,s);return new vt(o.x-c.x,o.y-c.y,o.z-c.z,s)}let r;n?r=new vt(0,0,0,s):r=Ci(e,s);const a=new U2(e,t,n,r);return N2(o=>a.Position(o),s)}function tl(i,e,t){Sa(t);const n=on(e);switch(i){case Ee.Earth:return new vt(0,0,0,n);case Ee.Moon:return bs(n);default:const s=F2(n,Ee.Earth,i,t);return s.t=n,s}}function O2(i,e){return new li(i.r.x,i.r.y,i.r.z,i.v.x,i.v.y,i.v.z,e)}function z2(i,e){const t=on(e);switch(i){case Ee.Sun:return new li(0,0,0,0,0,0,t);case Ee.SSB:const n=new Ua(t.tt);return new li(-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 Ee.Mercury:case Ee.Venus:case Ee.Earth:case Ee.Mars:case Ee.Jupiter:case Ee.Saturn:case Ee.Uranus:case Ee.Neptune:const s=Jc(kn[i],t.tt);return O2(s,t);case Ee.Pluto:return ed(t);case Ee.Moon:case Ee.EMB:const r=Jc(kn.Earth,t.tt),a=i==Ee.Moon?$0(t):R2(t);return new li(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(Al(i)){const o=Ci(i,t);return new li(o.x,o.y,o.z,0,0,0,t)}throw`HelioState: Unsupported body "${i}"`}}function B2(i){for(;i<0;)i+=360;for(;i>=360;)i-=360;return i}function k2(i,e,t){if(i===Ee.Earth||e===Ee.Earth)throw"The Earth does not have a longitude as seen from itself.";const n=on(t),s=tl(i,n,!1),r=qc(s),a=tl(e,n,!1),o=qc(a);return B2(r.elon-o.elon)}function G2(i,e,t,n){let s,r=0,a=0,o=0;switch(i){case Ee.Mercury:s=-.6,r=4.98,a=-4.88,o=3.02;break;case Ee.Venus:e<163.6?(s=-4.47,r=1.03,a=.57,o=.13):(s=.98,r=-1.02);break;case Ee.Mars:s=-1.52,r=1.6;break;case Ee.Jupiter:s=-9.4,r=.5;break;case Ee.Uranus:s=-7.19,r=.25;break;case Ee.Neptune:s=-6.87;break;case Ee.Pluto:s=-1,r=4;break;default:throw`VisualMagnitude: unsupported body ${i}`}const c=e/100;let l=s+c*(r+c*(a+c*o));return l+=5*Math.log10(t*n),l}function H2(i,e,t,n,s){const r=qc(n),a=it*28.06,o=it*(169.51+382e-7*s.tt),c=it*r.elat,l=it*r.elon,h=Math.asin(Math.sin(c)*Math.cos(a)-Math.cos(c)*Math.sin(a)*Math.sin(l-o)),d=Math.sin(Math.abs(h));let u=-9+.044*i;return u+=d*(-2.6+1.2*d),u+=5*Math.log10(e*t),{mag:u,ring_tilt:ui*h}}function V2(i,e,t){let n=i*it,s=n*n,r=s*s,a=-12.717+1.49*Math.abs(n)+.0431*r;const o=385000.6/bi;let c=t/o;return a+=5*Math.log10(e*c),a}class W2{constructor(e,t,n,s,r,a,o,c){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=c,this.phase_fraction=(1+Math.cos(it*n))/2}}function td(i,e){if(i===Ee.Earth)throw"The illumination of the Earth is not defined.";const t=on(e),n=js(kn.Earth,t);let s,r,a,o;i===Ee.Sun?(a=new vt(-n.x,-n.y,-n.z,t),r=new vt(0,0,0,t),s=0):(i===Ee.Moon?(a=bs(t),r=new vt(n.x+a.x,n.y+a.y,n.z+a.z,t)):(r=Ci(i,e),a=new vt(r.x-n.x,r.y-n.y,r.z-n.z,t)),s=a2(a,r));let c=a.Length(),l=r.Length(),h;if(i===Ee.Sun)o=i2+5*Math.log10(c);else if(i===Ee.Moon)o=V2(s,l,c);else if(i===Ee.Saturn){const d=H2(s,l,c,a,t);o=d.mag,h=d.ring_tilt}else o=G2(i,s,l,c);return new W2(t,o,s,l,c,a,r,h)}function X2(i){return k2(Ee.Moon,Ee.Sun,i)}var du;(function(i){i[i.Pericenter=0]="Pericenter",i[i.Apocenter=1]="Apocenter"})(du||(du={}));function q2(i,e){e=on(e);const t=i.lat*it,n=i.lon*it,s=i.dist*Math.cos(t);return new vt(s*Math.cos(n),s*Math.sin(n),i.dist*Math.sin(t),e)}function Y2(i,e){let t;if(Ct(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))*it)/60,e<-1&&(t*=(e+90)/89)}return t}var fu;(function(i){i.Penumbral="penumbral",i.Partial="partial",i.Annular="annular",i.Total="total"})(fu||(fu={}));var pu;(function(i){i[i.Invalid=0]="Invalid",i[i.Ascending=1]="Ascending",i[i.Descending=-1]="Descending"})(pu||(pu={}));const K2=["Venus","Mars","Jupiter","Saturn"];function nd(i){return new Z0(i.lat,i.lng,i.elevationM)}function id(i,e,t,n){const s=K0(t,nd(n),i,e,"normal");return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}function To(i,e,t){const n=nd(t),s=A2(Ee[i],e,n,!0,!0),r=K0(e,n,s.ra,s.dec,"normal");return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}function Ao(i,e){return td(Ee[i],e).mag}function Z2(i){const e=X2(i),t=td(Ee.Moon,i);return{phaseFraction:e/360,illuminatedFraction:t.phase_fraction}}const $2=2e3,J2=3,Q2=20;function mu(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??$2,r=i.month??(n?1:J2),a=i.day??(n?1:Q2),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 Ti{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=Ti.patch(t.fragmentShader)}}static patch(e){return e.replace(Ti.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
|
|
4447
|
+
// Outside the inscribed circle there is no star at all — this is what kills the corners.
|
|
4448
|
+
if ( distanceFromCentre > ${Ti.RIM.toFixed(2)} ) discard;
|
|
4449
|
+
float glare = 1.0 - smoothstep( ${Ti.CORE.toFixed(2)}, ${Ti.RIM.toFixed(2)}, distanceFromCentre );
|
|
4450
|
+
vec4 diffuseColor = vec4( diffuse, opacity * glare );`)}}const sd=Math.PI/180,j2=180/Math.PI,ex=256,tx=19;function nx(i,e){return 156543.03392*Math.cos(i*sd)/2**e}function ix(i,e){return nx(i,e)*ex}function rd(i,e){let t=0;for(;t<tx&&ix(i,t+1)>=e;)t++;return t}function ad(i,e,t){const n=2**t,s=(i+180)/360*n,r=e*sd,a=(1-Math.log(Math.tan(r)+1/Math.cos(r))/Math.PI)/2*n;return{x:s,y:a}}function sx(i,e,t){const{x:n,y:s}=ad(i,e,t);return{x:Math.floor(n),y:Math.floor(s),z:t}}function rx(i){const e=2**i.z,t=i.x/e*360-180,n=(i.x+1)/e*360-180,s=gu(i.y,e);return{south:gu(i.y+1,e),north:s,west:t,east:n}}function gu(i,e){const t=i/e;return Math.atan(Math.sinh(Math.PI*(1-2*t)))*j2}function od(i,e,t,n){const s=sx(i,e,t),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:t});const o=a.map(rx),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 cd=Math.PI/180,Ta=111320;function Li(i,e,t,n){const s=Ta*Math.cos(t*cd),r=(i-t)*Ta;return{x:(e-n)*s,z:-r}}function Zr(i,e,t,n){const s=Ta*Math.cos(t*cd),r=-e,a=i;return{lat:t+r/Ta,lng:n+a/s}}const jt=256,_u=3,ax=32768;class ox{fetchImpl;tileUrlTemplate;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=e.tileUrlTemplate??"https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"}async getElevationGrid(e,t){const n=(e.south+e.north)/2,s=(e.west+e.east)/2,r=Math.abs(Li(n,e.east,n,e.west).x),a=Math.abs(Li(e.north,s,e.south,s).z),o=rd(n,Math.max(r,a)),{tiles:c}=od(s,n,o,_u),l=_u*jt,h=new Float32Array(l*l),d=c[0];await Promise.all(c.map(p=>this.decodeTileInto(p,d,h,l)));const u=new Float32Array(t.width*t.height);for(let p=0;p<t.height;p++){const g=e.north+(e.south-e.north)*(p/(t.height-1));for(let M=0;M<t.width;M++){const m=e.west+(e.east-e.west)*(M/(t.width-1));u[p*t.width+M]=this.sampleAt(g,m,o,d,h,l)}}return{heights:u,width:t.width,height:t.height,bounds:e}}async decodeTileInto(e,t,n,s){const r=this.tileUrlTemplate.replace("{z}",String(e.z)).replace("{x}",String(e.x)).replace("{y}",String(e.y)),a=await this.fetchImpl(r);if(!a.ok)throw new Error(`Elevation tile fetch failed (${a.status}): ${r}`);const o=await createImageBitmap(await a.blob()),c=document.createElement("canvas");c.width=jt,c.height=jt;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,jt,jt),d=(e.x-t.x)*jt,u=(e.y-t.y)*jt;for(let p=0;p<jt;p++)for(let g=0;g<jt;g++){const M=(p*jt+g)*4,m=h[M]*256+h[M+1]+h[M+2]/256-ax,f=d+g,T=u+p;n[T*s+f]=m}}sampleAt(e,t,n,s,r,a){const{x:o,y:c}=ad(t,e,n),l=(o-s.x)*jt,h=(c-s.y)*jt,d=Math.max(0,Math.min(a-1,Math.floor(l))),u=Math.max(0,Math.min(a-1,Math.floor(h))),p=Math.min(a-1,d+1),g=Math.min(a-1,u+1),M=l-d,m=h-u,f=r[u*a+d],T=r[u*a+p],w=r[g*a+d],x=r[g*a+p],y=f+(T-f)*M,b=w+(x-w)*M;return y+(b-y)*m}}const wo=256,vu=3;async function cx(i,e,t,n){const s=(i.south+i.north)/2,r=(i.west+i.east)/2,a=Math.abs(Li(s,i.east,s,i.west).x),o=Math.abs(Li(i.north,r,i.south,r).z),c=rd(s,Math.max(a,o)),{tiles:l}=od(r,s,c,vu),h=vu*wo,d=document.createElement("canvas");d.width=h,d.height=h;const u=d.getContext("2d");if(!u)throw new Error("2D canvas context unavailable");const p=l[0];await Promise.all(l.map(async m=>{const f=t(m),T=await n(f);if(!T.ok)throw new Error(`Imagery tile fetch failed (${T.status}): ${f}`);const w=await createImageBitmap(await T.blob());u.drawImage(w,(m.x-p.x)*wo,(m.y-p.y)*wo)}));const g=document.createElement("canvas");g.width=e.width,g.height=e.height;const M=g.getContext("2d");if(!M)throw new Error("2D canvas context unavailable");return M.drawImage(d,0,0,h,h,0,0,e.width,e.height),g}class lx{attribution="Imagery © Esri, Maxar, Earthstar Geographics, and the GIS User Community";fetchImpl;tileUrlTemplate;constructor(e={}){this.fetchImpl=e.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=e.tileUrlTemplate??"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"}async getImageryTexture(e,t){return{source:await cx(e,t,s=>this.tileUrlTemplate.replace("{z}",String(s.z)).replace("{y}",String(s.y)).replace("{x}",String(s.x)),this.fetchImpl),width:t.width,height:t.height}}}function hx(){return{elevation:new ox,imagery:new lx}}const Zs=64,wt=Zs+1,xu=512,ux=900,dx=700/900,fx=0,px=.01;function mx(i,e,t){return{north:Zr(0,-t,i,e).lat,south:Zr(0,t,i,e).lat,east:Zr(t,0,i,e).lng,west:Zr(-t,0,i,e).lng}}async function gx(i,e,t,n=ux){const s=n,r=n*dx,a=mx(i,e,s),o={width:wt,height:wt},[c,l]=await Promise.all([t.elevation.getElevationGrid(a,o),t.imagery.getImageryTexture(a,{width:xu,height:xu})]),h=Math.floor(wt/2),d=c.heights[h*wt+h],u=new Float32Array(wt*wt*3),p=new Float32Array(wt*wt*2),g=new Float32Array(wt*wt*4);for(let y=0;y<wt;y++){const b=y/(wt-1),R=a.north+(a.south-a.north)*b;for(let v=0;v<wt;v++){const E=v/(wt-1),P=a.west+(a.east-a.west)*E,{x:C,z:L}=Li(R,P,i,e),X=c.heights[y*wt+v],q=fx+px+(X-d),F=y*wt+v;u[F*3]=C,u[F*3+1]=q,u[F*3+2]=L,p[F*2]=E,p[F*2+1]=b;const W=Math.max(Math.abs(C),Math.abs(L)),V=1-_x((W-r)/(s-r),0,1);g[F*4]=1,g[F*4+1]=1,g[F*4+2]=1,g[F*4+3]=V}}const M=new Uint16Array(Zs*Zs*6);let m=0;for(let y=0;y<Zs;y++)for(let b=0;b<Zs;b++){const R=y*wt+b,v=R+1,E=R+wt,P=E+1;M[m++]=R,M[m++]=E,M[m++]=v,M[m++]=v,M[m++]=E,M[m++]=P}const f=new yt;f.setAttribute("position",new lt(u,3)),f.setAttribute("uv",new lt(p,2)),f.setAttribute("color",new lt(g,4)),f.setIndex(new lt(M,1)),f.computeVertexNormals();const T=new qn(l.source);T.flipY=!1;const w=new cr({map:T,color:new Me(1,1,1),vertexColors:!0,transparent:!0,fog:!0,depthTest:!1}),x=new ht(f,w);return x.receiveShadow=!0,x.castShadow=!0,{mesh:x,attribution:t.imagery.attribution}}function _x(i,e,t){return Math.max(e,Math.min(t,i))}const vx=18,xx=.55,Mx=.5,Sx=`
|
|
4440
4451
|
attribute float aSpeed;
|
|
4441
4452
|
uniform float uTime;
|
|
4442
4453
|
uniform float uOverallSpeed;
|
|
@@ -4473,9 +4484,9 @@ void main() {
|
|
|
4473
4484
|
// a real, caught bug (a user directly noticed "darker/farther streaks equal-or-bigger than
|
|
4474
4485
|
// lighter/closer ones"), not just a stylistic overcorrection.
|
|
4475
4486
|
vHaze = clamp(dist / uHazeDistance, 0.0, 1.0);
|
|
4476
|
-
gl_PointSize = uPixelSize / dist + vNearBlur * ${
|
|
4487
|
+
gl_PointSize = uPixelSize / dist + vNearBlur * ${vx.toFixed(1)};
|
|
4477
4488
|
}
|
|
4478
|
-
`,
|
|
4489
|
+
`,yx=`
|
|
4479
4490
|
precision mediump float;
|
|
4480
4491
|
uniform sampler2D uTexture;
|
|
4481
4492
|
uniform vec3 uColor;
|
|
@@ -4503,18 +4514,18 @@ void main() {
|
|
|
4503
4514
|
// defocus doesn't change color, only spreads+dims (see vertex shader's own gl_PointSize term) —
|
|
4504
4515
|
// both dim the alpha so a maximally blurred/hazy drop doesn't stay as visually "solid" as a sharp
|
|
4505
4516
|
// one right in the middle distance.
|
|
4506
|
-
vec3 color = mix(uColor, uHazeColor, vHaze * ${
|
|
4517
|
+
vec3 color = mix(uColor, uHazeColor, vHaze * ${xx.toFixed(2)});
|
|
4507
4518
|
float blur = max(vNearBlur, vHaze);
|
|
4508
|
-
gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * ${
|
|
4519
|
+
gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * ${Mx.toFixed(2)}));
|
|
4509
4520
|
}
|
|
4510
|
-
`;function
|
|
4521
|
+
`;function Ex(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}}let $r;function bx(){if($r)return $r;const i=128,e=document.createElement("canvas");e.width=i,e.height=i;const t=e.getContext("2d"),n=t.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)"),t.fillStyle=n,t.fillRect(0,0,i,i);const s=t.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)"),t.globalCompositeOperation="destination-out",t.fillStyle=s,t.fillRect(0,0,i,i),t.globalCompositeOperation="source-over",$r=new qn(e),$r}function Tx(i){const e=Ex(i.seed),t=new Float32Array(i.count*3),n=new Float32Array(i.count),s=i.radiusM;for(let l=0;l<i.count;l++){const h=e()*Math.PI*2,d=Math.sqrt(e())*i.radiusM;t[l*3]=Math.cos(h)*d,t[l*3+1]=e()*i.heightM,t[l*3+2]=Math.sin(h)*d,n[l]=.85+e()*.3}const r=new yt;r.setAttribute("position",new lt(t,3)),r.setAttribute("aSpeed",new lt(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 Fe(0,0)},uHeight:{value:i.heightM},uBottomY:{value:i.bottomYM},uHalfWidth:{value:s},uTexture:{value:bx()},uNearFocusDistance:{value:i.nearFocusDistanceM},uHazeDistance:{value:i.hazeDistanceM},uHazeColor:{value:i.hazeColor}},o=new Bt({uniforms:a,vertexShader:Sx,fragmentShader:yx,transparent:!0,depthWrite:!1,depthTest:!0}),c=new ha(r,o);return c.frustumCulled=!1,{points:c,uniforms:a}}const Ax=`
|
|
4511
4522
|
varying vec3 vDir;
|
|
4512
4523
|
|
|
4513
4524
|
void main() {
|
|
4514
4525
|
vDir = normalize(position);
|
|
4515
4526
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
4516
4527
|
}
|
|
4517
|
-
`,
|
|
4528
|
+
`,wx=`
|
|
4518
4529
|
precision highp float;
|
|
4519
4530
|
uniform vec3 sunDir;
|
|
4520
4531
|
uniform vec3 sunColor;
|
|
@@ -4641,13 +4652,13 @@ void main() {
|
|
|
4641
4652
|
|
|
4642
4653
|
gl_FragColor = vec4(color, alpha);
|
|
4643
4654
|
}
|
|
4644
|
-
`;function
|
|
4655
|
+
`;function Rx(i,e,t){const n={sunDir:{value:new U(0,1,0)},sunColor:{value:new Me(1,1,1)},ambientColor:{value:new Me(.5,.5,.5)},baseColor:{value:i},coverage:{value:e},layerHeight:{value:t}};return{material:new Bt({uniforms:n,vertexShader:Ax,fragmentShader:wx,transparent:!0,depthWrite:!1,depthTest:!1,side:Dt}),uniforms:n}}const Cx=1.5;function Px(i){const e=Math.PI/2-Cx*Math.PI/180;return new Xn(i,48,24,0,Math.PI*2,0,e)}const Dx=`
|
|
4645
4656
|
varying vec2 vUv;
|
|
4646
4657
|
void main() {
|
|
4647
4658
|
vUv = uv;
|
|
4648
4659
|
gl_Position = vec4(position, 1.0);
|
|
4649
4660
|
}
|
|
4650
|
-
`,
|
|
4661
|
+
`,Ix=`
|
|
4651
4662
|
// Based on https://www.shadertoy.com/view/4sX3Rs
|
|
4652
4663
|
uniform float uTime;
|
|
4653
4664
|
uniform vec2 uLensPosition;
|
|
@@ -5034,7 +5045,7 @@ void main()
|
|
|
5034
5045
|
|
|
5035
5046
|
gl_FragColor = vec4(finalColor, max(dazzleAlpha, artifactsAlpha));
|
|
5036
5047
|
}
|
|
5037
|
-
`;let
|
|
5048
|
+
`;let Jr;function Lx(){if(Jr)return Jr;const i=256,e=document.createElement("canvas");e.width=i,e.height=i;const t=e.getContext("2d");t.fillStyle="rgba(60,60,60,1)",t.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=t.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)"),t.fillStyle=c,t.fillRect(0,0,i,i)}return Jr=new qn(e),Jr}function Nx(){const i={uTime:{value:0},uResolution:{value:new Fe(1,1)},uLensPosition:{value:new Fe(0,0)},uColorGain:{value:new Me(55,55,51)},uOpacity:{value:.5},uFlareIntensity:{value:0},uStarPoints:{value:6},uGlareSize:{value:.55},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:Lx()}},e=new Bt({uniforms:i,vertexShader:Dx,fragmentShader:Ix,transparent:!0,depthWrite:!1,depthTest:!1,blending:ir,fog:!1,name:"LensFlareShader"}),t=new ht(new As(2,2),e);return t.frustumCulled=!1,t.renderOrder=20,{mesh:t,uniforms:i}}class Aa{static MAX_HALF_ANGLE_DEG=80;target;quadScene=new v0;quadCamera=new Ia(-1,1,1,-1,0,1);material;width;height;constructor(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.target=new pn(this.width,this.height),this.material=new Bt({uniforms:{uSource:{value:this.target.texture},uHalfFovRad:{value:.5236},uAspect:{value:this.width/this.height},uSrcTanHalfFovY:{value:1},uResolution:{value:new Fe(this.width,this.height)}},vertexShader:`
|
|
5038
5049
|
varying vec2 vNdc;
|
|
5039
5050
|
void main() {
|
|
5040
5051
|
vNdc = position.xy;
|
|
@@ -5068,7 +5079,7 @@ void main()
|
|
|
5068
5079
|
if (any(greaterThan(abs(src), vec2(1.0)))) { gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); return; }
|
|
5069
5080
|
gl_FragColor = texture2D(uSource, src * 0.5 + 0.5);
|
|
5070
5081
|
}
|
|
5071
|
-
`,depthTest:!1,depthWrite:!1}),this.quadScene.add(new ut(new bs(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,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(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 c=e.getRenderTarget();e.setRenderTarget(this.target),e.render(t,n),e.setRenderTarget(c),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=Da.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 Y2{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 _s{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 Y2(r),c=Math.floor(a),l=c+(o.next()<a-c?1:0),h=[];for(let d=0;d<l;d++){const u=Math.min(1,Math.max(0,(s-20)/52)),p=_s.MAX_DURATION_MS-u*(_s.MAX_DURATION_MS-_s.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+u),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 jt{static MAX_CONCURRENT=24;static POINTS=8;static SEGMENTS=jt.POINTS-1;static RADIUS=840;object;positions;colors;meteors=[];radiantAltitudeDeg=0;radiantAzimuthDeg=0;constructor(){const e=jt.MAX_CONCURRENT*jt.SEGMENTS*2;this.positions=new Float32Array(e*3),this.colors=new Float32Array(e*3);const t=new St;t.setAttribute("position",new lt(this.positions,3)),t.setAttribute("color",new lt(this.colors,3)),t.setDrawRange(0,0),this.object=new Np(t,new D0({vertexColors:!0,transparent:!0,blending:nr,depthWrite:!1,fog:!1})),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||this.radiantAltitudeDeg<=0){t.setDrawRange(0,0);return}const n=ri(this.radiantAltitudeDeg,this.radiantAzimuthDeg,1),[s,r]=this.basisAround(n),a=_s.aliveAt(this.meteors,e).slice(0,jt.MAX_CONCURRENT);let o=0;for(const{meteor:c,progress:l}of a){const h=c.fromRadiantDeg+l*c.lengthDeg,d=Math.max(c.fromRadiantDeg,h-c.lengthDeg*.6),u=Math.min(1,(1-l)*2.5),p=c.bearingDeg*Math.PI/180,g={x:s.x*Math.cos(p)+r.x*Math.sin(p),y:s.y*Math.cos(p)+r.y*Math.sin(p),z:s.z*Math.cos(p)+r.z*Math.sin(p)},x=(.15+.85*c.brightness)*u,m=A=>x*A**1.6,f=A=>this.onSphere(n,g,d+(h-d)*A);for(let A=1;A<jt.POINTS;A++){const w=(A-1)/jt.SEGMENTS,M=A/jt.SEGMENTS;o=this.push(o,f(w),m(w)),o=this.push(o,f(M),m(M))}}t.setDrawRange(0,o),t.getAttribute("position").needsUpdate=!0,t.getAttribute("color").needsUpdate=!0}midpointOf(e){if(this.radiantAltitudeDeg<=0)return;const t=ri(this.radiantAltitudeDeg,this.radiantAzimuthDeg,1),[n,s]=this.basisAround(t),r=e.bearingDeg*Math.PI/180,a={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)},o=this.onSphere(t,a,e.fromRadiantDeg+e.lengthDeg/2),c=Math.hypot(o.x,o.y,o.z)||1;return{altitudeDeg:Math.asin(o.y/c)*180/Math.PI,azimuthDeg:(Math.atan2(o.x,-o.z)*180/Math.PI+360)%360}}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}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)*jt.RADIUS,y:(e.y*r+t.y*a)*jt.RADIUS,z:(e.z*r+t.z*a)*jt.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))]}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 K2=2;function Z2(i){return i==="building"||i==="vehicle"}function $2(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 J2(i,e){return i.pattern.kind==="steady"?!0:Q2(i,e,e+1)>.5}function Q2(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,c=e/o+r,l=t/o+r;if(l<=c)return Math.min(Math.max(c-Math.floor(c),0),a)<a?1:0;const h=d=>Math.floor(d)*a+Math.min(d-Math.floor(d),a);return(h(l)-h(c))/(l-c)}function j2(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 Cu(t[0],i);const s=t[t.length-1];if(e>=s.t)return Cu(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 c=o.t-a.t,l=c===0?0:(e-a.t)/c;return{eastM:a.eastM+(o.eastM-a.eastM)*l,northM:a.northM+(o.northM-a.northM)*l,altitudeM:(a.altitudeM??0)+((o.altitudeM??0)-(a.altitudeM??0))*l,headingDeg:a.headingDeg??i.headingDeg}}return n}function Cu(i,e){return{eastM:i.eastM,northM:i.northM,altitudeM:i.altitudeM??0,headingDeg:i.headingDeg??e.headingDeg}}const Pu=Math.PI/180;function Ft(i,e,t,n,s=!1){const r=s?new ar({color:new xe(...t)}):new lr({color:new xe(...t)}),a=new ut(e,r);return a.position.y=n,a.userData={emissive:s},a.castShadow=!s,a.receiveShadow=!s,i.add(a),a}const Du=.25,e3=.002;function t3(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 xd=[.32,.32,.3],Md=[1,.85,.5],Sd=[.25,.25,.25],yd=[1,.97,.85],n3=[.55,.68,.72],yn=.03,En=.05,Ed={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 Gt(i,e){return i?.[e]}function bn(i,e,t,n,s,r,a,o){if(o===void 0)return;const c=new lr({color:new xe(...n3),transparent:!0,opacity:o/100}),l=new ut(new rn(e,t,n),c);l.position.set(s,r,a),i.add(l)}const en=.05,No=[.6,.58,.53],Iu=[.5,.5,.48];function hs(i,e,t,n,s,r,a,o){const c=new lr({color:new xe(...o),side:Pt}),l=new ut(new rn(e,t,n),c);l.position.set(s,r,a),i.add(l)}function i3(i,e,t,n,s,r,a,o,c){const l=(n-r)/2,h=(g,x,m,f)=>{g<=0||(e?hs(i,g,x,en,m,o+f,a,c):hs(i,en,x,g,a,o+f,m,c))};h(t,l,0,n/2-l/2),h(t,l,0,-(n/2-l/2));const d=[...s].sort((g,x)=>g.center-x.center);let u=-t/2;for(const g of d){const m=g.center-g.main/2-u;h(m,r,u+m/2,0),u=g.center+g.main/2}const p=t/2-u;h(p,r,u+p/2,0)}function bd(i,e,t,n,s,r,a,o,c,l){const h=(n+s)/2,d=s-n,u=(p,g,x,m)=>{p.length===0?g?hs(i,x,d,en,0,h,m,No):hs(i,en,d,x,m,h,0,No):i3(i,g,x,d,p,r,m,h,No)};u(a,!0,e*2,-t+en),u(o,!0,e*2,t-en),u(c,!1,t*2,-e+en),u(l,!1,t*2,e-en),hs(i,e*2,en,t*2,0,n+en,0,Iu),hs(i,e*2,en,t*2,0,s-en,0,Iu)}function cl(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:-Tn};case"front-right":return{x:e-n,z:-Tn};case"behind-left":return{x:-(e-n),z:Tn};case"behind-right":return{x:e-n,z:Tn}}}function Td(i,e,t,n,s,r,a){const o=Rd();o.scale.setScalar(n),o.rotation.y=Ed[e];const{x:c,z:l}=cl(e,s,r,a);o.position.set(c,t,l),i.add(o)}const ll=6,hl=6,ai=3,Gs=1.4,Hs=ai*.5,Ad=1.2,wd=.35,s3=.75,r3=1.6;function a3(i,e,t,n){const s=new fn,r=Math.max(1,i+1),a=r*ai;Ft(s,new rn(ll,a,hl),[.55,.54,.5],a/2);const o=ll/2,c=hl/2;for(let l=0;l<r;l++){const h=l*ai+ai/2;bn(s,Gs,Hs,En,0,h,-c-yn,Gt(e,"front")),bn(s,Gs,Hs,En,0,h,c+yn,Gt(e,"behind")),bn(s,En,Hs,Gs,-o-yn,h,0,Gt(e,"left")),bn(s,En,Hs,Gs,o+yn,h,0,Gt(e,"right"))}if(t){const l=Math.min(Math.max(n??0,0),r-1);Td(s,t,l*ai,.72,o,c,Ad);const h=d=>Gt(e,d)!==void 0?[{main:Gs,center:0}]:[];bd(s,o,c,l*ai,(l+1)*ai,Hs,h("front"),h("behind"),h("left"),h("right"))}return s}function o3(){const i=new fn;return Ft(i,new mi(.15,.22,2,8),[.32,.22,.14],1),Ft(i,new Fa(1.4,3,8),[.16,.32,.14],3.5),i}function c3(i){const e=new fn;return Ft(e,new mi(.05,.08,5,8),[.28,.28,.3],2.5),Ft(e,new Xn(.25,12,8),i?Md:xd,5.1,!0),e}const l3=[.08,.08,.08],si=.8,as=1,Mn=1.7,Uo=.6,Si=.4,ta=1.2,ns=.7,Tn=.5,h3=Mn;function u3(i,e,t){const n=new fn;Ft(n,new rn(1.8,1.4,4.2),[.45,.14,.14],.7),Ft(n,new rn(si*2,Uo,as*2),[.4,.12,.12],Mn);for(const r of[-1.4,1.4])for(const a of[-.95,.95]){const o=Ft(n,new mi(.4,.4,.3,12),l3,.4);o.rotation.z=Math.PI/2,o.position.x=a,o.position.z=r}const s=i?yd:Sd;for(const r of[-.7,.7])Ft(n,new Xn(.15,8,6),s,.7,!0).position.set(r,.7,-2.1);if(bn(n,ta,Si,En,0,Mn,-as-yn,Gt(e,"front")),bn(n,ta,Si,En,0,Mn,as+yn,Gt(e,"behind")),bn(n,En,Si,ns,-si-yn,Mn,-Tn,Gt(e,"front-left")),bn(n,En,Si,ns,-si-yn,Mn,Tn,Gt(e,"behind-left")),bn(n,En,Si,ns,si+yn,Mn,-Tn,Gt(e,"front-right")),bn(n,En,Si,ns,si+yn,Mn,Tn,Gt(e,"behind-right")),t){Td(n,t,s3,.5,si,as,wd);const r=(c,l)=>{const h=[];return Gt(e,c)!==void 0&&h.push({main:ns,center:-Tn}),Gt(e,l)!==void 0&&h.push({main:ns,center:Tn}),h},a=Gt(e,"front")!==void 0?[{main:ta,center:0}]:[],o=Gt(e,"behind")!==void 0?[{main:ta,center:0}]:[];bd(n,si,as,Mn-Uo/2,Mn+Uo/2,Si,a,o,r("front-left","behind-left"),r("front-right","behind-right"))}return n}const d3=[.95,.9,.82];function Rd(){const i=new fn;Ft(i,new mi(.25,.3,1.5,10),[.3,.3,.35],.75),Ft(i,new Xn(.22,10,8),[.62,.52,.46],1.72);const e=Ft(i,new Fa(.07,.16,8),d3,1.72);return e.rotation.x=-Math.PI/2,e.position.z=-.2,i}const f3=17,Lu=18.5,Fo=[.16,.16,.18];function p3(){const i=new fn,e=Ft(i,new mi(1.8,1.8,Lu*2,10),Fo,0);e.rotation.x=Math.PI/2,Ft(i,new rn(f3*2,.5,4.5),Fo,0);const t=Ft(i,new rn(.4,5.5,4),Fo,3);return t.position.z=-Lu+2,i}class is{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"?cl(t,si,as,wd):cl(t,ll/2,hl/2,Ad),r=e.kind==="vehicle"?h3:(e.occupiedFloor??0)*ai+r3,a=(e.headingDeg??0)-Ed[t]/Pu;return{x:n,z:s,eyeY:r,headingDeg:a}}static build(e,t){const n=e.kind==="building"?a3(e.floors??K2,e.windows,e.witnessSide,e.occupiedFloor):e.kind==="tree"?o3():e.kind==="streetlight"?c3(t):e.kind==="vehicle"?u3(t,e.windows,e.witnessSide):e.kind==="aircraft"?p3():Rd();return e.headingDeg!==void 0&&(n.rotation.y=-e.headingDeg*Pu),this.addLights(n,e.lights),e.kind==="aircraft"&&this.exemptFromFog(n),n}static exemptFromFog(e){for(const t of e.children){if(!(t instanceof ut))continue;const n=t.material;n.fog=!1,n.needsUpdate=!0}}static addLights(e,t){for(const n of t??[]){const s=Ft(e,new Xn(Du,8,6),t3(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*e3/Du);for(const o of e.children){if(!(o instanceof ut))continue;const c=o.userData.lightId;if(!c)continue;const l=r.get(c);l&&(o.visible=J2(l,n),o.scale.setScalar(a*(l.intensity??1)**.5))}}static setLit(e,t,n){const s=t==="streetlight"?n?Md:xd:n?yd:Sd;for(const r of e.children){const a=r.userData;!(r instanceof ut)||!a.emissive||a.lightId||r.material.color.setRGB(...s)}}static dispose(e){for(const t of e.children)t instanceof ut&&(t.geometry.dispose(),t.material.dispose())}}function m3(i,e){return i.cloudCover===e.cloudCover&&i.cloudDarkness===e.cloudDarkness&&i.cloudBaseM===e.cloudBaseM&&i.precipitationType===e.precipitationType&&i.precipitationIntensity===e.precipitationIntensity&&i.windDirectionDeg===e.windDirectionDeg&&i.windSpeed===e.windSpeed&&i.storm===e.storm}const na=900,Nu=.5,Zs=900,g3=6371e3,_3=3e4;function Uu(i){const e=Math.sqrt(2*g3*Math.max(i,0));return Math.max(Zs,Math.min(e,_3))}const Oo=.5,v3=850,zo=850,Bo=4,x3=1.5,M3=-1,S3=6,ul=-4,Fu=ul,y3=3,E3=.15,b3=.6,T3=40,A3=30,w3=[0,45,90,135,180,225,270,315],R3={en:["N","NE","E","SE","S","SW","W","NW"],fr:["N","NE","E","SE","S","SO","O","NO"]},C3=["en","fr"],P3=880,Ou=40,D3=10,I3=1,L3=150,ko=55,zu=.5,N3=700,U3=250/s0,F3=12,O3=5,Go=6,ss=[.92,.92,.95],Ho=[.15,.15,.19],Bu={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}},os=0,z3=0,ku=3e3,Vs=20,B3=15,Gu=os,k3=40,Hu=1,G3=9;function H3(i){return Hu+(G3-Hu)*i}const V3=new xe(.75,.82,.92),W3=10,X3=.5;function q3(i){return Cd(i/W3,X3,1)}const rs=200,Vu=.18,Wu=.32,Y3=.35,K3=new xe(.85,.9,.98),Xu=5,qu=.85,Yu=.01;function Vo(i,e){return Math.round(i*(Yu+(1-Yu)*e))}const Ku=230,Zu=.7,$u=.05,Z3=.6,$3=.7,J3=.15,Ju=.35,Q3=3,j3=1/12,eM=.5,Qu=8,ju=25,e0=.12,tM={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 nM{renderer;scene=new w0;camera;celestialGroup=new fn;skyMesh;groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;decorObjects=[];decorGroups=new Map;celestialLight=new Yp(16777215,0);celestialLightTarget=new xt;skyLight=new Vp(16777215,0,0);streetlightLights=new Map;compassSprites=[];showCompass=!1;compassHovered=!1;compassForced=!1;animationFrameId=null;raycaster=new yo;weather=r0;observerElevationM=0;groundRadius=Zs;terrainRadius=Zs;cloudMesh;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;lensFlareArtifactIntensity=0;sunWorldPosition=new U;sunVisible=!1;lensFlareScratch=new U;sunOcclusionRaycaster=new yo;sunOcclusionDirectionScratch=new U;ufoOcclusionRaycaster=new yo;projectionKind="rectilinear";equidistantPass;meteorSystem;onLightningFlash;constructor(e,t=y2(),n){this.renderer=new Xv({canvas:e,antialias:!0}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=Js,this.camera=new Kt(60,e.width/Math.max(e.height,1),.1,na*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*un,-e.headingDeg*un,0,"YXZ"):this.camera.rotation.set(e.pitchDeg*un,this.camera.rotation.y,0,"YXZ"),e.elevationM!==this.observerElevationM&&(this.observerElevationM=e.elevationM,this.syncCloudLayer(),Math.abs(Uu(e.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/Zs),this.camera.far=Math.max(na*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}=Li(e,t,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(a*a+o*o)<L3*(s/Zs))return}this.terrainOrigin={lat:e,lng:t},this.terrainRadius=s;const r=++this.terrainBuildToken;R2(e,t,this.terrainProviders,s).then(({mesh:a,attribution:o})=>{r===this.terrainBuildToken&&(this.disposeMesh(this.terrainMesh),a.renderOrder=I3,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=zu*e,this.lastSunPosition&&this.applyLensFlareTint(Bs(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){this.lensFlare&&this.lensFlare.uniforms.uColorGain.value.setRGB(ko*this.dazzleIntensity*e[0],ko*this.dazzleIntensity*e[1],ko*this.dazzleIntensity*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){m3(this.weather,e)||(this.weather=e,this.buildClouds(),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(),is.dispose(t);this.decorGroups.clear(),this.streetlightLights.clear();for(const t of e){const n=is.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?Li(e.lat,e.lng,t.lat,t.lng):{x:0,z:0},r=this.decorObjects.find(l=>l.witnessSide!==void 0&&Z2(l.kind)),a={x:0,z:0};let o=0;if(r){const l=is.occupantView(r),h=-(r.headingDeg??0)*un,d=l.x*Math.cos(h)+l.z*Math.sin(h),u=-l.x*Math.sin(h)+l.z*Math.cos(h),p=r.eastM+s.x,g=-r.northM+s.z;a.x=-(p+d),a.z=-(g+u),this.camera.position.y=l.eyeY,this.camera.rotation.set(this.indoorLookPitchDeg*un,-(l.headingDeg+this.indoorLookYawDeg)*un,0,"YXZ")}for(const l of this.decorObjects){const h=this.decorGroups.get(l.id);if(!h)continue;const d=j2(l,n);h.position.set(d.eastM+s.x+a.x,z3+d.altitudeM,-d.northM+s.z+a.z),d.headingDeg!==void 0&&(h.rotation.y=-d.headingDeg*un),o=Math.max(o,h.position.distanceTo(this.camera.position))}const c=Math.max(na*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(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&&is.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=$2(t,e);is.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 Xp(16764006,T3,A3);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=Y0(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),this.setBodyMesh("sun",e.sun,Bo,new xe(1,.96,.88),e.sun.magnitude),this.setMoonMesh(e.moon),this.buildPlanets(e.planets),this.scene.fog=new Al(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=b3;const s=e.sun.altitudeDeg>=Fu,r=!s&&e.moon.altitudeDeg>=Fu;if(!s&&!r){this.celestialLight.intensity=0;return}const a=s?e.sun:e.moon,{x:o,y:c,z:l}=ri(a.altitudeDeg,a.azimuthDeg,zo);this.celestialLight.position.set(o,c,l);const h=Bs(a.altitudeDeg);this.celestialLight.color.setRGB(h[0],h[1],h[2]);const d=Math.max(0,Math.sin(Math.max(a.altitudeDeg,0)*un));this.celestialLight.intensity=(s?y3:E3)*d,this.celestialLight.castShadow=this.decorGroups.size>0}setMeteorShower(e,t,n){this.meteorSystem||(this.meteorSystem=new jt,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 Oe);if(Da.supports(this.camera.fov,e.x/Math.max(e.y,1)))return this.equidistantPass?this.equidistantPass.resize(e.x,e.y):this.equidistantPass=new Da(e.x,e.y),this.equidistantPass}aimAtScreenPoint(e,t,n){const s=this.projectionKind==="equidistant"?this.equidistantPass:void 0;if(!s){e.setFromCamera(new Oe(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.weather.cloudCover>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=Nu,this.ufoOcclusionRaycaster.intersectObjects(r,!0).length>0)}decorDistancesAt(e,t,n){this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t),this.ufoOcclusionRaycaster.near=Nu;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(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.disposePrecipitationPoints(),this.disposeRain(),this.disposeStarTiers();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())is.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,j3);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 Xn(na,32,16),n=t.attributes.position,s=[];for(let a=0;a<n.count;a++){const{altitudeDeg:o,azimuthDeg:c}=Zv(n.getX(a),n.getY(a),n.getZ(a)),l=Qv(o,c,e.azimuthDeg,e.altitudeDeg);s.push(l[0],l[1],l[2])}t.setAttribute("color",new Mt(s,3));const r=new ar({vertexColors:!0,side:Pt,fog:!1,depthWrite:!1});this.skyMesh=new ut(t,r),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){this.disposeMesh(this.groundMesh),this.groundRadius=Uu(this.observerElevationM);const e=new Rl(this.groundRadius,48),t=new lr({color:new xe(Oo,Oo,Oo),fog:!0});this.groundMesh=new ut(e,t),this.groundMesh.rotation.x=-Math.PI/2,this.groundMesh.position.y=0,this.groundMesh.receiveShadow=!0,this.scene.add(this.groundMesh)}setBodyMesh(e,t,n,s,r){if(this.disposeMesh(this.bodyMeshes.get(e)),this.disposeHitArea(e),this.disposeGlare(e),t.altitudeDeg<ul){this.bodyMeshes.delete(e),e==="sun"&&(this.sunVisible=!1);return}const{x:a,y:o,z:c}=ri(t.altitudeDeg,t.azimuthDeg,zo),l=Bs(t.altitudeDeg),h=new xe(s.r*l[0],s.g*l[1],s.b*l[2]),d=new Xn(n,16,16),u=new ar({color:h,fog:!1}),p=new ut(d,u);if(p.position.set(a,o,c),this.celestialGroup.add(p),this.bodyMeshes.set(e,p),this.setHitArea(e,a,o,c,n),e!=="sun"&&this.setGlare(e,a,o,c,r,h),e==="sun"){this.sunVisible=!0;const g=this.celestialGroup.scale.x;this.sunWorldPosition.set(a*g,o*g+this.celestialGroup.position.y,c*g),this.lensFlare||(this.lensFlare=q2(),this.lensFlare.uniforms.uOpacity.value=zu*this.dazzleIntensity,this.lensFlare.uniforms.uFlareIntensity.value=this.lensFlareArtifactIntensity,this.scene.add(this.lensFlare.mesh)),this.applyLensFlareTint(l)}}setMoonMesh(e){const t="moon";if(this.disposeMesh(this.bodyMeshes.get(t)),this.disposeHitArea(t),this.disposeGlare(t),e.altitudeDeg<ul){this.bodyMeshes.delete(t);return}const{x:n,y:s,z:r}=ri(e.altitudeDeg,e.azimuthDeg,zo),a=Bs(e.altitudeDeg),o=new xe(a[0],a[1],a[2]),c=new Xs({map:dM(e.phase),color:o,fog:!1}),l=new Rr(c);l.position.set(n,s,r);const h=Bo*2;l.scale.set(h,h,1),this.celestialGroup.add(l),this.bodyMeshes.set(t,l),this.setHitArea(t,n,s,r,Bo),this.setGlare(t,n,s,r,e.magnitude,o)}setHitArea(e,t,n,s,r){const a=new Xs({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1}),o=new Rr(a);o.position.set(t,n,s);const c=r*S3;o.scale.set(c,c,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=ex(r);if(o<=0){this.disposeGlare(e);return}const c=ix(o),l=this.glareSprites.get(e),h=l??new Rr(new Xs({map:uM(),transparent:!0,blending:nr,depthWrite:!1,fog:!1}));h.material.color.copy(a),h.material.opacity=ax(o),h.position.set(t,n,s),h.scale.set(c*2,c*2,1),l||(this.celestialGroup.add(h),this.glareSprites.set(e,h))}disposeGlare(e){const t=this.glareSprites.get(e);t&&(t.removeFromParent(),t.material.dispose(),this.glareSprites.delete(e))}buildPlanets(e){const t=new Set(["sun","moon"]);for(const n of e){t.add(n.body);const s=uu(n.magnitude),r=du(s),a=tM[n.body]??new xe(1,1,1),o=new xe(a.r*r,a.g*r,a.b*r),c=x3*(.5+.5*s);this.setBodyMesh(n.body,n.position,c,o,n.magnitude)}for(const n of[...this.bodyMeshes.keys()])t.has(n)||(this.disposeMesh(this.bodyMeshes.get(n)),this.bodyMeshes.delete(n),this.disposeHitArea(n),this.disposeGlare(n))}buildStars(e,t){if(this.disposeStarTiers(),!e||e.catalog.count===0){this.syncAnimationLoop();return}const{catalog:n,date:s,observer:r}=e,a=qv(t),o=Wo(1337),c=[];for(let l=0;l<n.count;l++){const h=n.mag[l];if(h>a)continue;const{altitudeDeg:d,azimuthDeg:u}=fd(n.ra[l],n.dec[l],s,r);if(d<M3)continue;const{x:p,y:g,z:x}=ri(d,u,v3);c.push({x:p,y:g,z:x,brightness:uu(h),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}this.starTiers=Z0.map((l,h)=>{const d=c.filter(M=>cx(M.brightness)===h),u=new Float32Array(d.length*3),p=new Float32Array(d.length),g=new Float32Array(d.length),x=new Float32Array(d.length);d.forEach((M,y)=>{u[y*3]=M.x,u[y*3+1]=M.y,u[y*3+2]=M.z,p[y]=M.brightness,g[y]=M.phase,x[y]=M.speedFactor});const m=new St;m.setAttribute("position",new lt(u,3));const f=new lt(new Float32Array(d.length*3),3);m.setAttribute("color",f);const A=new I0({vertexColors:!0,size:l.size,sizeAttenuation:!1,fog:!1}),w=new fa(m,A);return this.celestialGroup.add(w),{points:w,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=ux(t.brightness[s],{phase:t.phase[s],speedFactor:t.speedFactor[s]},e),a=du(t.brightness[s])*r;n[s*3]=a,n[s*3+1]=a,n[s*3+2]=a}t.colorAttribute.needsUpdate=!0}}buildClouds(){if(this.disposeCloudSystem(),this.weather.cloudCover<=0)return;const e=this.weather.cloudDarkness,t=new xe(ss[0]+(Ho[0]-ss[0])*e,ss[1]+(Ho[1]-ss[1])*e,ss[2]+(Ho[2]-ss[2])*e),{material:n,uniforms:s}=k2(t,this.weather.cloudCover,Math.abs(this.cloudLayerOffset()));this.cloudMaterial=n,this.cloudUniforms=s,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const r=H2(N3);this.cloudMesh=new ut(r,n),this.cloudLayerOffset()<0&&(this.cloudMesh.scale.y=-1),this.cloudMesh.renderOrder=O3,this.celestialGroup.add(this.cloudMesh)}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??s0)-this.observerElevationM)*U3;return Math.sign(t||1)*Math.max(Math.abs(t),F3)}updateCloudLighting(e,t){if(!this.cloudUniforms)return;const{x:n,y:s,z:r}=ri(e.altitudeDeg,e.azimuthDeg,1),a=Bs(e.altitudeDeg),o=Math.max(0,Math.sin(Math.max(e.altitudeDeg,0)*un));this.cloudUniforms.sunDir.value.set(n,s,r),this.cloudUniforms.sunColor.value.setRGB(a[0]*o,.96*a[1]*o,.88*a[2]*o),this.cloudUniforms.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=Bu[e],n=t.poolSize,s=Wo(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),d=new Float32Array(n),u=new Float32Array(n),p=new Float32Array(n),g=new Float32Array(n);for(let w=0;w<n;w++){const M=s()*Math.PI*2,y=s()*t.radiusM;r[w*3]=Math.cos(M)*y,r[w*3+1]=os+s()*(t.topYM-os),r[w*3+2]=Math.sin(M)*y,a[w]=s()*Math.PI*2,o[w]=.7+s()*.6,c[w]=.6+s()*.8,l[w]=.4+s()*1.2}const x=new St;x.setAttribute("position",new lt(r,3)),x.setDrawRange(0,Vo(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:iM(e)},uNearFocusDistance:{value:Xu},uHazeDistance:{value:t.radiusM*qu}},f=new zt({uniforms:m,vertexShader:lM,fragmentShader:hM,transparent:!0,depthWrite:!1});this.precipitationUniforms=m;const A=new fa(x,f);A.renderOrder=Go,this.scene.add(A),this.precipitationPoints=A,this.precipitationPositions=r,this.precipitationPhase=a,this.precipitationSpeedJitter=o,this.precipitationWobbleFreqJitter=c,this.precipitationWobbleAmpJitter=l,this.precipitationBounceRemaining=h,this.precipitationBounceHeight=d,this.precipitationBounceDuration=u,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=Bu[n],r=this.weather.windDirectionDeg*un,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,d=this.precipitationWobbleFreqJitter,u=this.precipitationWobbleAmpJitter,p=this.precipitationBounceRemaining,g=this.precipitationBounceHeight,x=this.precipitationBounceDuration,m=this.precipitationBounceVelX,f=this.precipitationBounceVelZ,A=n==="snow"&&d&&u,w=n==="hail"&&p&&g&&x&&m&&f;for(let M=0,y=0;M<c.length;M+=3,y++){if(w&&p[y]>0){if(p[y]-=t,p[y]<=0){const v=Math.random()*Math.PI*2,E=Math.sqrt(Math.random())*s.radiusM;c[M]=Math.cos(v)*E,c[M+1]=s.topYM,c[M+2]=Math.sin(v)*E,p[y]=0}else{const v=1-p[y]/x[y];c[M+1]=os+Math.sin(Math.PI*v)*g[y],c[M]=sa(c[M]+(a+m[y])*t,s.radiusM),c[M+2]=sa(c[M+2]+(o+f[y])*t,s.radiusM)}continue}let b=0,R=0;if(A){const v=Z3*d[y],E=$3*u[y];b=Math.sin(e*v*Math.PI*2+l[y])*E,R=Math.sin(e*v*Math.PI*2+l[y]+Math.PI/2)*E}if(c[M]+=(a+b)*t,c[M+1]-=s.fallSpeedMPerS*h[y]*t,c[M+2]+=(o+R)*t,c[M]=sa(c[M],s.radiusM),c[M+2]=sa(c[M+2],s.radiusM),c[M+1]<os){if(w){g[y]=Ju*(.2+Math.random()*1.6),x[y]=J3*(.5+Math.random()),p[y]=x[y];const P=Math.random()*Math.PI*2,C=Q3*(g[y]/Ju);m[y]=Math.cos(P)*C,f[y]=Math.sin(P)*C,c[M+1]=os;continue}const v=Math.random()*Math.PI*2,E=Math.sqrt(Math.random())*s.radiusM;c[M]=Math.cos(v)*E,c[M+1]=s.topYM,c[M+2]=Math.sin(v)*E}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const e=H3(this.weather.precipitationIntensity);this.rainSystem=O2({count:ku,radiusM:Vs,heightM:B3,bottomYM:Gu,overallSpeed:k3,color:V3,opacity:.85,visibleCount:Vo(ku,this.weather.precipitationIntensity),speedStreak:q3(e),pixelSize:Ku,seed:9001,nearFocusDistanceM:Xu,hazeDistanceM:Vs*qu,hazeColor:new xe(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.rainSystem.points.renderOrder=Go,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const e=Wo(4242),t=new Float32Array(rs*3),n=new Float32Array(rs),s=new Float32Array(rs),r=new Float32Array(rs);for(let h=0;h<rs;h++){const d=e()*Math.PI*2,u=Math.sqrt(e())*Vs;t[h*3]=Math.cos(d)*u,t[h*3+1]=Gu,t[h*3+2]=Math.sin(d)*u,s[h]=ia(Vu,Wu),n[h]=e()*s[h],r[h]=n[h]/s[h]}const a=new St;a.setAttribute("position",new lt(t,3));const o=new lt(r,1);a.setAttribute("aLife",o),a.setDrawRange(0,Vo(rs,this.weather.precipitationIntensity));const c=new zt({uniforms:{uMaxSize:{value:Y3},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:K3},uTexture:{value:aM()}},vertexShader:oM,fragmentShader:cM,transparent:!0,depthWrite:!1}),l=new fa(a,c);l.renderOrder=Go,this.scene.add(l),this.rainSplashSystem={points:l,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*un,s=Math.sin(n)*this.weather.windSpeed,r=-Math.cos(n)*this.weather.windSpeed,a=Vs,o=l=>(l%(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 c=Math.abs(this.rainCameraDirection.y);if(Math.abs(c-this.rainLastVerticalFacing)>.001){this.rainLastVerticalFacing=c;const l=Zu+(1-Zu)*(1-c),h=$u+(1-$u)*(1-c);t.uniforms.uUvSquash.value=h,t.uniforms.uPixelSize.value=Ku*l*(.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 c=0,l=0;c<n.length;c+=3,l++){if(s[l]+=e,s[l]>=r[l]){const h=Math.random()*Math.PI*2,d=Math.sqrt(Math.random())*Vs;n[c]=Math.cos(h)*d,n[c+2]=Math.sin(h)*d,r[l]=ia(Vu,Wu),s[l]=0}o[l]=s[l]/r[l]}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/e0;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+ia(Qu,ju);return}e>=this.nextLightningAtS&&(this.lightningFlashRemainingS=e0,this.nextLightningAtS=e+ia(Qu,ju),this.onLightningFlash?.())}}buildCompassLabels(){const e=fl(navigator.languages,C3),t=R3[e];this.compassSprites=w3.map((n,s)=>{const r=t[s],a=new Xs({map:fM(r),depthTest:!1,fog:!1}),o=new Rr(a),{x:c,y:l,z:h}=ri(0,n,P3);return o.position.set(c,l,h),o.scale.set(Ou,Ou,1),o.renderOrder=D3,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 un=Math.PI/180;function Cd(i,e,t){return Math.max(e,Math.min(t,i))}function ia(i,e){return i+Math.random()*(e-i)}function sa(i,e){return(i%(e*2)+e*3)%(e*2)-e}let ra,aa;function iM(i){switch(i){case"snow":return sM();case"hail":return rM()}}function sM(){if(ra)return ra;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),ra=new qn(e),ra}function rM(){if(aa)return aa;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),aa=new qn(e),aa}let oa;function aM(){if(oa)return oa;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),oa=new qn(e),oa}const oM=`
|
|
5082
|
+
`,depthTest:!1,depthWrite:!1}),this.quadScene.add(new ht(new As(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,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(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 c=e.getRenderTarget();e.setRenderTarget(this.target),e.render(t,n),e.setRenderTarget(c),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=Aa.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 Ux{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 vs{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 Ux(r),c=Math.floor(a),l=c+(o.next()<a-c?1:0),h=[];for(let d=0;d<l;d++){const u=Math.min(1,Math.max(0,(s-20)/52)),p=vs.MAX_DURATION_MS-u*(vs.MAX_DURATION_MS-vs.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+u),brightness:o.next()**3}),h.sort((M,m)=>M.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 Rt{static MAX_CONCURRENT=24;static POINTS=8;static SEGMENTS=Rt.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(Rt.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=Rt.MAX_CONCURRENT*Rt.SEGMENTS*Rt.VERTICES_PER_SEGMENT;this.positions=new Float32Array(e*3),this.colors=new Float32Array(e*3);const t=new yt;t.setAttribute("position",new lt(this.positions,3)),t.setAttribute("color",new lt(this.colors,3)),t.setDrawRange(0,0),this.object=new ht(t,new Ss({vertexColors:!0,transparent:!0,blending:ir,depthWrite:!1,fog:!1,side:An})),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||this.radiantAltitudeDeg<=0){t.setDrawRange(0,0);return}const n=ri(this.radiantAltitudeDeg,this.radiantAzimuthDeg,1),[s,r]=this.basisAround(n),a=vs.aliveAt(this.meteors,e).slice(0,Rt.MAX_CONCURRENT);let o=0;for(const{meteor:c,progress:l}of a){const h=c.fromRadiantDeg+l*c.lengthDeg,d=Math.max(c.fromRadiantDeg,h-c.lengthDeg*.6),u=Math.min(1,(1-l)*2.5),p=this.turn(s,r,c.bearingDeg),g=(.15+.85*c.brightness)*u,M=T=>g*T**1.6,m=T=>this.onSphere(n,p,d+(h-d)*T),f=T=>Rt.RADIUS*((Rt.MIN_HALF_WIDTH_DEG+Rt.BRIGHT_HALF_WIDTH_DEG*c.brightness*T)*Math.PI/180);for(let T=1;T<Rt.POINTS;T++){const w=(T-1)/Rt.SEGMENTS,x=T/Rt.SEGMENTS;o=this.pushRibbon(o,m(w),m(x),f(w),f(x),M(w),M(x))}}t.setDrawRange(0,o),t.getAttribute("position").needsUpdate=!0,t.getAttribute("color").needsUpdate=!0}midpointOf(e){if(this.radiantAltitudeDeg<=0)return;const t=ri(this.radiantAltitudeDeg,this.radiantAzimuthDeg,1),[n,s]=this.basisAround(t),r=this.turn(n,s,e.bearingDeg),a=this.onSphere(t,r,e.fromRadiantDeg+e.lengthDeg/2),o=Math.hypot(a.x,a.y,a.z)||1;return{altitudeDeg:Math.asin(a.y/o)*180/Math.PI,azimuthDeg:(Math.atan2(a.x,-a.z)*180/Math.PI+360)%360}}pushRibbon(e,t,n,s,r,a,o){const c=this.normalise(this.cross(this.normalise(t),this.normalise(this.subtract(n,t))));for(let l=0;l<Rt.ACROSS-1;l++){const h=l-1,d=l,u=this.across(t,c,s,h),p=this.across(n,c,r,h),g=this.across(t,c,s,d),M=this.across(n,c,r,d),m=(f,T)=>f===0?T:0;e=this.push(e,u,m(h,a)),e=this.push(e,p,m(h,o)),e=this.push(e,g,m(d,a)),e=this.push(e,p,m(h,o)),e=this.push(e,M,m(d,o)),e=this.push(e,g,m(d,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)*Rt.RADIUS,y:(e.y*r+t.y*a)*Rt.RADIUS,z:(e.z*r+t.z*a)*Rt.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 Fx=2;function Ox(i){return i==="building"||i==="vehicle"}function zx(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 Bx(i,e){return i.pattern.kind==="steady"?!0:kx(i,e,e+1)>.5}function kx(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,c=e/o+r,l=t/o+r;if(l<=c)return Math.min(Math.max(c-Math.floor(c),0),a)<a?1:0;const h=d=>Math.floor(d)*a+Math.min(d-Math.floor(d),a);return(h(l)-h(c))/(l-c)}function Gx(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 Mu(t[0],i);const s=t[t.length-1];if(e>=s.t)return Mu(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 c=o.t-a.t,l=c===0?0:(e-a.t)/c;return{eastM:a.eastM+(o.eastM-a.eastM)*l,northM:a.northM+(o.northM-a.northM)*l,altitudeM:(a.altitudeM??0)+((o.altitudeM??0)-(a.altitudeM??0))*l,headingDeg:a.headingDeg??i.headingDeg}}return n}function Mu(i,e){return{eastM:i.eastM,northM:i.northM,altitudeM:i.altitudeM??0,headingDeg:i.headingDeg??e.headingDeg}}const Su=Math.PI/180;function Ot(i,e,t,n,s=!1){const r=s?new Ss({color:new Me(...t)}):new cr({color:new Me(...t)}),a=new ht(e,r);return a.position.y=n,a.userData={emissive:s},a.castShadow=!s,a.receiveShadow=!s,i.add(a),a}const yu=.25,Hx=.002;function Vx(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 ld=[.32,.32,.3],hd=[1,.85,.5],ud=[.25,.25,.25],dd=[1,.97,.85],Wx=[.55,.68,.72],yn=.03,En=.05,fd={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 Ht(i,e){return i?.[e]}function bn(i,e,t,n,s,r,a,o){if(o===void 0)return;const c=new cr({color:new Me(...Wx),transparent:!0,opacity:o/100}),l=new ht(new rn(e,t,n),c);l.position.set(s,r,a),i.add(l)}const en=.05,Ro=[.6,.58,.53],Eu=[.5,.5,.48];function us(i,e,t,n,s,r,a,o){const c=new cr({color:new Me(...o),side:Dt}),l=new ht(new rn(e,t,n),c);l.position.set(s,r,a),i.add(l)}function Xx(i,e,t,n,s,r,a,o,c){const l=(n-r)/2,h=(g,M,m,f)=>{g<=0||(e?us(i,g,M,en,m,o+f,a,c):us(i,en,M,g,a,o+f,m,c))};h(t,l,0,n/2-l/2),h(t,l,0,-(n/2-l/2));const d=[...s].sort((g,M)=>g.center-M.center);let u=-t/2;for(const g of d){const m=g.center-g.main/2-u;h(m,r,u+m/2,0),u=g.center+g.main/2}const p=t/2-u;h(p,r,u+p/2,0)}function pd(i,e,t,n,s,r,a,o,c,l){const h=(n+s)/2,d=s-n,u=(p,g,M,m)=>{p.length===0?g?us(i,M,d,en,0,h,m,Ro):us(i,en,d,M,m,h,0,Ro):Xx(i,g,M,d,p,r,m,h,Ro)};u(a,!0,e*2,-t+en),u(o,!0,e*2,t-en),u(c,!1,t*2,-e+en),u(l,!1,t*2,e-en),us(i,e*2,en,t*2,0,n+en,0,Eu),us(i,e*2,en,t*2,0,s-en,0,Eu)}function nl(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:-Tn};case"front-right":return{x:e-n,z:-Tn};case"behind-left":return{x:-(e-n),z:Tn};case"behind-right":return{x:e-n,z:Tn}}}function md(i,e,t,n,s,r,a){const o=vd();o.scale.setScalar(n),o.rotation.y=fd[e];const{x:c,z:l}=nl(e,s,r,a);o.position.set(c,t,l),i.add(o)}const il=6,sl=6,ai=3,Hs=1.4,Vs=ai*.5,gd=1.2,_d=.35,qx=.75,Yx=1.6;function Kx(i,e,t,n){const s=new fn,r=Math.max(1,i+1),a=r*ai;Ot(s,new rn(il,a,sl),[.55,.54,.5],a/2);const o=il/2,c=sl/2;for(let l=0;l<r;l++){const h=l*ai+ai/2;bn(s,Hs,Vs,En,0,h,-c-yn,Ht(e,"front")),bn(s,Hs,Vs,En,0,h,c+yn,Ht(e,"behind")),bn(s,En,Vs,Hs,-o-yn,h,0,Ht(e,"left")),bn(s,En,Vs,Hs,o+yn,h,0,Ht(e,"right"))}if(t){const l=Math.min(Math.max(n??0,0),r-1);md(s,t,l*ai,.72,o,c,gd);const h=d=>Ht(e,d)!==void 0?[{main:Hs,center:0}]:[];pd(s,o,c,l*ai,(l+1)*ai,Vs,h("front"),h("behind"),h("left"),h("right"))}return s}function Zx(){const i=new fn;return Ot(i,new pi(.15,.22,2,8),[.32,.22,.14],1),Ot(i,new Da(1.4,3,8),[.16,.32,.14],3.5),i}function $x(i){const e=new fn;return Ot(e,new pi(.05,.08,5,8),[.28,.28,.3],2.5),Ot(e,new Xn(.25,12,8),i?hd:ld,5.1,!0),e}const Jx=[.08,.08,.08],si=.8,os=1,Mn=1.7,Co=.6,Mi=.4,Qr=1.2,is=.7,Tn=.5,Qx=Mn;function jx(i,e,t){const n=new fn;Ot(n,new rn(1.8,1.4,4.2),[.45,.14,.14],.7),Ot(n,new rn(si*2,Co,os*2),[.4,.12,.12],Mn);for(const r of[-1.4,1.4])for(const a of[-.95,.95]){const o=Ot(n,new pi(.4,.4,.3,12),Jx,.4);o.rotation.z=Math.PI/2,o.position.x=a,o.position.z=r}const s=i?dd:ud;for(const r of[-.7,.7])Ot(n,new Xn(.15,8,6),s,.7,!0).position.set(r,.7,-2.1);if(bn(n,Qr,Mi,En,0,Mn,-os-yn,Ht(e,"front")),bn(n,Qr,Mi,En,0,Mn,os+yn,Ht(e,"behind")),bn(n,En,Mi,is,-si-yn,Mn,-Tn,Ht(e,"front-left")),bn(n,En,Mi,is,-si-yn,Mn,Tn,Ht(e,"behind-left")),bn(n,En,Mi,is,si+yn,Mn,-Tn,Ht(e,"front-right")),bn(n,En,Mi,is,si+yn,Mn,Tn,Ht(e,"behind-right")),t){md(n,t,qx,.5,si,os,_d);const r=(c,l)=>{const h=[];return Ht(e,c)!==void 0&&h.push({main:is,center:-Tn}),Ht(e,l)!==void 0&&h.push({main:is,center:Tn}),h},a=Ht(e,"front")!==void 0?[{main:Qr,center:0}]:[],o=Ht(e,"behind")!==void 0?[{main:Qr,center:0}]:[];pd(n,si,os,Mn-Co/2,Mn+Co/2,Mi,a,o,r("front-left","behind-left"),r("front-right","behind-right"))}return n}const e3=[.95,.9,.82];function vd(){const i=new fn;Ot(i,new pi(.25,.3,1.5,10),[.3,.3,.35],.75),Ot(i,new Xn(.22,10,8),[.62,.52,.46],1.72);const e=Ot(i,new Da(.07,.16,8),e3,1.72);return e.rotation.x=-Math.PI/2,e.position.z=-.2,i}const t3=17,bu=18.5,Po=[.16,.16,.18];function n3(){const i=new fn,e=Ot(i,new pi(1.8,1.8,bu*2,10),Po,0);e.rotation.x=Math.PI/2,Ot(i,new rn(t3*2,.5,4.5),Po,0);const t=Ot(i,new rn(.4,5.5,4),Po,3);return t.position.z=-bu+2,i}class ss{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"?nl(t,si,os,_d):nl(t,il/2,sl/2,gd),r=e.kind==="vehicle"?Qx:(e.occupiedFloor??0)*ai+Yx,a=(e.headingDeg??0)-fd[t]/Su;return{x:n,z:s,eyeY:r,headingDeg:a}}static build(e,t){const n=e.kind==="building"?Kx(e.floors??Fx,e.windows,e.witnessSide,e.occupiedFloor):e.kind==="tree"?Zx():e.kind==="streetlight"?$x(t):e.kind==="vehicle"?jx(t,e.windows,e.witnessSide):e.kind==="aircraft"?n3():vd();return e.headingDeg!==void 0&&(n.rotation.y=-e.headingDeg*Su),this.addLights(n,e.lights),e.kind==="aircraft"&&this.exemptFromFog(n),n}static exemptFromFog(e){for(const t of e.children){if(!(t instanceof ht))continue;const n=t.material;n.fog=!1,n.needsUpdate=!0}}static addLights(e,t){for(const n of t??[]){const s=Ot(e,new Xn(yu,8,6),Vx(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*Hx/yu);for(const o of e.children){if(!(o instanceof ht))continue;const c=o.userData.lightId;if(!c)continue;const l=r.get(c);l&&(o.visible=Bx(l,n),o.scale.setScalar(a*(l.intensity??1)**.5))}}static setLit(e,t,n){const s=t==="streetlight"?n?hd:ld:n?dd:ud;for(const r of e.children){const a=r.userData;!(r instanceof ht)||!a.emissive||a.lightId||r.material.color.setRGB(...s)}}static dispose(e){for(const t of e.children)t instanceof ht&&(t.geometry.dispose(),t.material.dispose())}}function i3(i,e){return i.cloudCover===e.cloudCover&&i.cloudDarkness===e.cloudDarkness&&i.cloudBaseM===e.cloudBaseM&&i.precipitationType===e.precipitationType&&i.precipitationIntensity===e.precipitationIntensity&&i.windDirectionDeg===e.windDirectionDeg&&i.windSpeed===e.windSpeed&&i.storm===e.storm}const jr=900,Tu=.5,$s=900,s3=6371e3,r3=3e4;function Au(i){const e=Math.sqrt(2*s3*Math.max(i,0));return Math.max($s,Math.min(e,r3))}const Do=.5,a3=850,Io=850,Lo=4,o3=1.5,c3=-1,l3=6,rl=-4,wu=rl,h3=3,u3=.15,d3=.6,f3=40,p3=30,m3=[0,45,90,135,180,225,270,315],g3={en:["N","NE","E","SE","S","SW","W","NW"],fr:["N","NE","E","SE","S","SO","O","NO"]},_3=["en","fr"],v3=880,Ru=40,x3=10,M3=1,S3=150,No=55,Cu=.5,y3=700,E3=250/Zu,b3=12,T3=5,Uo=6,rs=[.92,.92,.95],Fo=[.15,.15,.19],Pu={snow:{fallSpeedMPerS:2,size:.3,color:new Me(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new Me(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},cs=0,A3=0,Du=3e3,Ws=20,w3=15,Iu=cs,R3=40,Lu=1,C3=9;function P3(i){return Lu+(C3-Lu)*i}const D3=new Me(.75,.82,.92),I3=10,L3=.5;function N3(i){return xd(i/I3,L3,1)}const as=200,Nu=.18,Uu=.32,U3=.35,F3=new Me(.85,.9,.98),Fu=5,Ou=.85,zu=.01;function Oo(i,e){return Math.round(i*(zu+(1-zu)*e))}const Bu=230,ku=.7,Gu=.05,O3=.6,z3=.7,B3=.15,Hu=.35,k3=3,G3=1/12,H3=.5,Vu=8,Wu=25,Xu=.12,V3={Venus:new Me(1,.96,.85),Mars:new Me(1,.55,.4),Jupiter:new Me(.95,.87,.72),Saturn:new Me(.92,.86,.68)};class W3{renderer;scene=new v0;camera;celestialGroup=new fn;skyMesh;groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;decorObjects=[];decorGroups=new Map;celestialLight=new Up(16777215,0);celestialLightTarget=new St;skyLight=new Dp(16777215,0,0);streetlightLights=new Map;compassSprites=[];showCompass=!1;compassHovered=!1;compassForced=!1;animationFrameId=null;raycaster=new go;weather=$u;observerElevationM=0;groundRadius=$s;terrainRadius=$s;cloudMesh;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;lensFlareArtifactIntensity=0;sunWorldPosition=new U;sunVisible=!1;lensFlareScratch=new U;sunOcclusionRaycaster=new go;sunOcclusionDirectionScratch=new U;ufoOcclusionRaycaster=new go;projectionKind="rectilinear";equidistantPass;meteorSystem;onLightningFlash;constructor(e,t=hx(),n){this.renderer=new Lv({canvas:e,antialias:!0}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=Qs,this.camera=new Zt(60,e.width/Math.max(e.height,1),.1,jr*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*un,-e.headingDeg*un,0,"YXZ"):this.camera.rotation.set(e.pitchDeg*un,this.camera.rotation.y,0,"YXZ"),e.elevationM!==this.observerElevationM&&(this.observerElevationM=e.elevationM,this.syncCloudLayer(),Math.abs(Au(e.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/$s),this.camera.far=Math.max(jr*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}=Li(e,t,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(a*a+o*o)<S3*(s/$s))return}this.terrainOrigin={lat:e,lng:t},this.terrainRadius=s;const r=++this.terrainBuildToken;gx(e,t,this.terrainProviders,s).then(({mesh:a,attribution:o})=>{r===this.terrainBuildToken&&(this.disposeMesh(this.terrainMesh),a.renderOrder=M3,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=Cu*e,this.lastSunPosition&&this.applyLensFlareTint(ks(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){this.lensFlare&&this.lensFlare.uniforms.uColorGain.value.setRGB(No*this.dazzleIntensity*e[0],No*this.dazzleIntensity*e[1],No*this.dazzleIntensity*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){i3(this.weather,e)||(this.weather=e,this.buildClouds(),this.buildPrecipitation(),this.lightningArmed=e.storm&&e.cloudDarkness>=H3,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(),ss.dispose(t);this.decorGroups.clear(),this.streetlightLights.clear();for(const t of e){const n=ss.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?Li(e.lat,e.lng,t.lat,t.lng):{x:0,z:0},r=this.decorObjects.find(l=>l.witnessSide!==void 0&&Ox(l.kind)),a={x:0,z:0};let o=0;if(r){const l=ss.occupantView(r),h=-(r.headingDeg??0)*un,d=l.x*Math.cos(h)+l.z*Math.sin(h),u=-l.x*Math.sin(h)+l.z*Math.cos(h),p=r.eastM+s.x,g=-r.northM+s.z;a.x=-(p+d),a.z=-(g+u),this.camera.position.y=l.eyeY,this.camera.rotation.set(this.indoorLookPitchDeg*un,-(l.headingDeg+this.indoorLookYawDeg)*un,0,"YXZ")}for(const l of this.decorObjects){const h=this.decorGroups.get(l.id);if(!h)continue;const d=Gx(l,n);h.position.set(d.eastM+s.x+a.x,A3+d.altitudeM,-d.northM+s.z+a.z),d.headingDeg!==void 0&&(h.rotation.y=-d.headingDeg*un),o=Math.max(o,h.position.distanceTo(this.camera.position))}const c=Math.max(jr*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(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&&ss.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=zx(t,e);ss.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 Lp(16764006,f3,p3);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=O0(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),this.setBodyMesh("sun",e.sun,Lo,new Me(1,.96,.88),e.sun.magnitude),this.setMoonMesh(e.moon),this.buildPlanets(e.planets),this.scene.fog=new Ml(new Me(...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=d3;const s=e.sun.altitudeDeg>=wu,r=!s&&e.moon.altitudeDeg>=wu;if(!s&&!r){this.celestialLight.intensity=0;return}const a=s?e.sun:e.moon,{x:o,y:c,z:l}=ri(a.altitudeDeg,a.azimuthDeg,Io);this.celestialLight.position.set(o,c,l);const h=ks(a.altitudeDeg);this.celestialLight.color.setRGB(h[0],h[1],h[2]);const d=Math.max(0,Math.sin(Math.max(a.altitudeDeg,0)*un));this.celestialLight.intensity=(s?h3:u3)*d,this.celestialLight.castShadow=this.decorGroups.size>0}setMeteorShower(e,t,n){this.meteorSystem||(this.meteorSystem=new Rt,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(Aa.supports(this.camera.fov,e.x/Math.max(e.y,1)))return this.equidistantPass?this.equidistantPass.resize(e.x,e.y):this.equidistantPass=new Aa(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.weather.cloudCover>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=Tu,this.ufoOcclusionRaycaster.intersectObjects(r,!0).length>0)}decorDistancesAt(e,t,n){this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t),this.ufoOcclusionRaycaster.near=Tu;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(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.disposePrecipitationPoints(),this.disposeRain(),this.disposeStarTiers();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())ss.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,G3);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 Xn(jr,32,16),n=t.attributes.position,s=[];for(let a=0;a<n.count;a++){const{altitudeDeg:o,azimuthDeg:c}=Ov(n.getX(a),n.getY(a),n.getZ(a)),l=kv(o,c,e.azimuthDeg,e.altitudeDeg);s.push(l[0],l[1],l[2])}t.setAttribute("color",new Et(s,3));const r=new Ss({vertexColors:!0,side:Dt,fog:!1,depthWrite:!1});this.skyMesh=new ht(t,r),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){this.disposeMesh(this.groundMesh),this.groundRadius=Au(this.observerElevationM);const e=new El(this.groundRadius,48),t=new cr({color:new Me(Do,Do,Do),fog:!0});this.groundMesh=new ht(e,t),this.groundMesh.rotation.x=-Math.PI/2,this.groundMesh.position.y=0,this.groundMesh.receiveShadow=!0,this.scene.add(this.groundMesh)}setBodyMesh(e,t,n,s,r){if(this.disposeMesh(this.bodyMeshes.get(e)),this.disposeHitArea(e),this.disposeGlare(e),t.altitudeDeg<rl){this.bodyMeshes.delete(e),e==="sun"&&(this.sunVisible=!1);return}const{x:a,y:o,z:c}=ri(t.altitudeDeg,t.azimuthDeg,Io),l=ks(t.altitudeDeg),h=new Me(s.r*l[0],s.g*l[1],s.b*l[2]),d=new Xn(n,16,16),u=new Ss({color:h,fog:!1}),p=new ht(d,u);if(p.position.set(a,o,c),this.celestialGroup.add(p),this.bodyMeshes.set(e,p),this.setHitArea(e,a,o,c,n),e!=="sun"&&this.setGlare(e,a,o,c,r,h),e==="sun"){this.sunVisible=!0;const g=this.celestialGroup.scale.x;this.sunWorldPosition.set(a*g,o*g+this.celestialGroup.position.y,c*g),this.lensFlare||(this.lensFlare=Nx(),this.lensFlare.uniforms.uOpacity.value=Cu*this.dazzleIntensity,this.lensFlare.uniforms.uFlareIntensity.value=this.lensFlareArtifactIntensity,this.scene.add(this.lensFlare.mesh)),this.applyLensFlareTint(l)}}setMoonMesh(e){const t="moon";if(this.disposeMesh(this.bodyMeshes.get(t)),this.disposeHitArea(t),this.disposeGlare(t),e.altitudeDeg<rl){this.bodyMeshes.delete(t);return}const{x:n,y:s,z:r}=ri(e.altitudeDeg,e.azimuthDeg,Io),a=ks(e.altitudeDeg),o=new Me(a[0],a[1],a[2]),c=new qs({map:eM(e.phase),color:o,fog:!1}),l=new wr(c);l.position.set(n,s,r);const h=Lo*2;l.scale.set(h,h,1),this.celestialGroup.add(l),this.bodyMeshes.set(t,l),this.setHitArea(t,n,s,r,Lo),this.setGlare(t,n,s,r,e.magnitude,o)}setHitArea(e,t,n,s,r){const a=new qs({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1}),o=new wr(a);o.position.set(t,n,s);const c=r*l3;o.scale.set(c,c,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=Hv(r);if(o<=0){this.disposeGlare(e);return}const c=Xv(o),l=this.glareSprites.get(e),h=l??new wr(new qs({map:j3(),transparent:!0,blending:ir,depthWrite:!1,fog:!1}));h.material.color.copy(a),h.material.opacity=Kv(o),h.position.set(t,n,s),h.scale.set(c*2,c*2,1),l||(this.celestialGroup.add(h),this.glareSprites.set(e,h))}disposeGlare(e){const t=this.glareSprites.get(e);t&&(t.removeFromParent(),t.material.dispose(),this.glareSprites.delete(e))}buildPlanets(e){const t=new Set(["sun","moon"]);for(const n of e){t.add(n.body);const s=nu(n.magnitude),r=iu(s),a=V3[n.body]??new Me(1,1,1),o=new Me(a.r*r,a.g*r,a.b*r),c=o3*(.5+.5*s);this.setBodyMesh(n.body,n.position,c,o,n.magnitude)}for(const n of[...this.bodyMeshes.keys()])t.has(n)||(this.disposeMesh(this.bodyMeshes.get(n)),this.bodyMeshes.delete(n),this.disposeHitArea(n),this.disposeGlare(n))}buildStars(e,t){if(this.disposeStarTiers(),!e||e.catalog.count===0){this.syncAnimationLoop();return}const{catalog:n,date:s,observer:r}=e,a=Nv(t),o=zo(1337),c=[];for(let l=0;l<n.count;l++){const h=n.mag[l];if(h>a)continue;const{altitudeDeg:d,azimuthDeg:u}=id(n.ra[l],n.dec[l],s,r);if(d<c3)continue;const{x:p,y:g,z:M}=ri(d,u,a3);c.push({x:p,y:g,z:M,brightness:nu(h),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}this.starTiers=B0.map((l,h)=>{const d=c.filter(x=>$v(x.brightness)===h),u=new Float32Array(d.length*3),p=new Float32Array(d.length),g=new Float32Array(d.length),M=new Float32Array(d.length);d.forEach((x,y)=>{u[y*3]=x.x,u[y*3+1]=x.y,u[y*3+2]=x.z,p[y]=x.brightness,g[y]=x.phase,M[y]=x.speedFactor});const m=new yt;m.setAttribute("position",new lt(u,3));const f=new lt(new Float32Array(d.length*3),3);m.setAttribute("color",f);const T=new y0({vertexColors:!0,size:l.size,sizeAttenuation:!1,fog:!1});Ti.apply(T);const w=new ha(m,T);return this.celestialGroup.add(w),{points:w,colorAttribute:f,brightness:p,phase:g,speedFactor:M}}),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=jv(t.brightness[s],{phase:t.phase[s],speedFactor:t.speedFactor[s]},e),a=iu(t.brightness[s])*r;n[s*3]=a,n[s*3+1]=a,n[s*3+2]=a}t.colorAttribute.needsUpdate=!0}}buildClouds(){if(this.disposeCloudSystem(),this.weather.cloudCover<=0)return;const e=this.weather.cloudDarkness,t=new Me(rs[0]+(Fo[0]-rs[0])*e,rs[1]+(Fo[1]-rs[1])*e,rs[2]+(Fo[2]-rs[2])*e),{material:n,uniforms:s}=Rx(t,this.weather.cloudCover,Math.abs(this.cloudLayerOffset()));this.cloudMaterial=n,this.cloudUniforms=s,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const r=Px(y3);this.cloudMesh=new ht(r,n),this.cloudLayerOffset()<0&&(this.cloudMesh.scale.y=-1),this.cloudMesh.renderOrder=T3,this.celestialGroup.add(this.cloudMesh)}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??Zu)-this.observerElevationM)*E3;return Math.sign(t||1)*Math.max(Math.abs(t),b3)}updateCloudLighting(e,t){if(!this.cloudUniforms)return;const{x:n,y:s,z:r}=ri(e.altitudeDeg,e.azimuthDeg,1),a=ks(e.altitudeDeg),o=Math.max(0,Math.sin(Math.max(e.altitudeDeg,0)*un));this.cloudUniforms.sunDir.value.set(n,s,r),this.cloudUniforms.sunColor.value.setRGB(a[0]*o,.96*a[1]*o,.88*a[2]*o),this.cloudUniforms.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=Pu[e],n=t.poolSize,s=zo(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),d=new Float32Array(n),u=new Float32Array(n),p=new Float32Array(n),g=new Float32Array(n);for(let w=0;w<n;w++){const x=s()*Math.PI*2,y=s()*t.radiusM;r[w*3]=Math.cos(x)*y,r[w*3+1]=cs+s()*(t.topYM-cs),r[w*3+2]=Math.sin(x)*y,a[w]=s()*Math.PI*2,o[w]=.7+s()*.6,c[w]=.6+s()*.8,l[w]=.4+s()*1.2}const M=new yt;M.setAttribute("position",new lt(r,3)),M.setDrawRange(0,Oo(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 Me(...this.baseFogColor)},uTexture:{value:X3(e)},uNearFocusDistance:{value:Fu},uHazeDistance:{value:t.radiusM*Ou}},f=new Bt({uniforms:m,vertexShader:J3,fragmentShader:Q3,transparent:!0,depthWrite:!1});this.precipitationUniforms=m;const T=new ha(M,f);T.renderOrder=Uo,this.scene.add(T),this.precipitationPoints=T,this.precipitationPositions=r,this.precipitationPhase=a,this.precipitationSpeedJitter=o,this.precipitationWobbleFreqJitter=c,this.precipitationWobbleAmpJitter=l,this.precipitationBounceRemaining=h,this.precipitationBounceHeight=d,this.precipitationBounceDuration=u,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=Pu[n],r=this.weather.windDirectionDeg*un,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,d=this.precipitationWobbleFreqJitter,u=this.precipitationWobbleAmpJitter,p=this.precipitationBounceRemaining,g=this.precipitationBounceHeight,M=this.precipitationBounceDuration,m=this.precipitationBounceVelX,f=this.precipitationBounceVelZ,T=n==="snow"&&d&&u,w=n==="hail"&&p&&g&&M&&m&&f;for(let x=0,y=0;x<c.length;x+=3,y++){if(w&&p[y]>0){if(p[y]-=t,p[y]<=0){const v=Math.random()*Math.PI*2,E=Math.sqrt(Math.random())*s.radiusM;c[x]=Math.cos(v)*E,c[x+1]=s.topYM,c[x+2]=Math.sin(v)*E,p[y]=0}else{const v=1-p[y]/M[y];c[x+1]=cs+Math.sin(Math.PI*v)*g[y],c[x]=ta(c[x]+(a+m[y])*t,s.radiusM),c[x+2]=ta(c[x+2]+(o+f[y])*t,s.radiusM)}continue}let b=0,R=0;if(T){const v=O3*d[y],E=z3*u[y];b=Math.sin(e*v*Math.PI*2+l[y])*E,R=Math.sin(e*v*Math.PI*2+l[y]+Math.PI/2)*E}if(c[x]+=(a+b)*t,c[x+1]-=s.fallSpeedMPerS*h[y]*t,c[x+2]+=(o+R)*t,c[x]=ta(c[x],s.radiusM),c[x+2]=ta(c[x+2],s.radiusM),c[x+1]<cs){if(w){g[y]=Hu*(.2+Math.random()*1.6),M[y]=B3*(.5+Math.random()),p[y]=M[y];const P=Math.random()*Math.PI*2,C=k3*(g[y]/Hu);m[y]=Math.cos(P)*C,f[y]=Math.sin(P)*C,c[x+1]=cs;continue}const v=Math.random()*Math.PI*2,E=Math.sqrt(Math.random())*s.radiusM;c[x]=Math.cos(v)*E,c[x+1]=s.topYM,c[x+2]=Math.sin(v)*E}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const e=P3(this.weather.precipitationIntensity);this.rainSystem=Tx({count:Du,radiusM:Ws,heightM:w3,bottomYM:Iu,overallSpeed:R3,color:D3,opacity:.85,visibleCount:Oo(Du,this.weather.precipitationIntensity),speedStreak:N3(e),pixelSize:Bu,seed:9001,nearFocusDistanceM:Fu,hazeDistanceM:Ws*Ou,hazeColor:new Me(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.rainSystem.points.renderOrder=Uo,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const e=zo(4242),t=new Float32Array(as*3),n=new Float32Array(as),s=new Float32Array(as),r=new Float32Array(as);for(let h=0;h<as;h++){const d=e()*Math.PI*2,u=Math.sqrt(e())*Ws;t[h*3]=Math.cos(d)*u,t[h*3+1]=Iu,t[h*3+2]=Math.sin(d)*u,s[h]=ea(Nu,Uu),n[h]=e()*s[h],r[h]=n[h]/s[h]}const a=new yt;a.setAttribute("position",new lt(t,3));const o=new lt(r,1);a.setAttribute("aLife",o),a.setDrawRange(0,Oo(as,this.weather.precipitationIntensity));const c=new Bt({uniforms:{uMaxSize:{value:U3},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:F3},uTexture:{value:K3()}},vertexShader:Z3,fragmentShader:$3,transparent:!0,depthWrite:!1}),l=new ha(a,c);l.renderOrder=Uo,this.scene.add(l),this.rainSplashSystem={points:l,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*un,s=Math.sin(n)*this.weather.windSpeed,r=-Math.cos(n)*this.weather.windSpeed,a=Ws,o=l=>(l%(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 c=Math.abs(this.rainCameraDirection.y);if(Math.abs(c-this.rainLastVerticalFacing)>.001){this.rainLastVerticalFacing=c;const l=ku+(1-ku)*(1-c),h=Gu+(1-Gu)*(1-c);t.uniforms.uUvSquash.value=h,t.uniforms.uPixelSize.value=Bu*l*(.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 c=0,l=0;c<n.length;c+=3,l++){if(s[l]+=e,s[l]>=r[l]){const h=Math.random()*Math.PI*2,d=Math.sqrt(Math.random())*Ws;n[c]=Math.cos(h)*d,n[c+2]=Math.sin(h)*d,r[l]=ea(Nu,Uu),s[l]=0}o[l]=s[l]/r[l]}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/Xu;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+ea(Vu,Wu);return}e>=this.nextLightningAtS&&(this.lightningFlashRemainingS=Xu,this.nextLightningAtS=e+ea(Vu,Wu),this.onLightningFlash?.())}}buildCompassLabels(){const e=ol(navigator.languages,_3),t=g3[e];this.compassSprites=m3.map((n,s)=>{const r=t[s],a=new qs({map:tM(r),depthTest:!1,fog:!1}),o=new wr(a),{x:c,y:l,z:h}=ri(0,n,v3);return o.position.set(c,l,h),o.scale.set(Ru,Ru,1),o.renderOrder=x3,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 un=Math.PI/180;function xd(i,e,t){return Math.max(e,Math.min(t,i))}function ea(i,e){return i+Math.random()*(e-i)}function ta(i,e){return(i%(e*2)+e*3)%(e*2)-e}let na,ia;function X3(i){switch(i){case"snow":return q3();case"hail":return Y3()}}function q3(){if(na)return na;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),na=new qn(e),na}function Y3(){if(ia)return ia;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),ia=new qn(e),ia}let sa;function K3(){if(sa)return sa;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),sa=new qn(e),sa}const Z3=`
|
|
5072
5083
|
uniform float uMaxSize;
|
|
5073
5084
|
uniform float uScale;
|
|
5074
5085
|
attribute float aLife;
|
|
@@ -5081,7 +5092,7 @@ void main() {
|
|
|
5081
5092
|
vOpacity = 1.0 - aLife;
|
|
5082
5093
|
gl_Position = projectionMatrix * mvPosition;
|
|
5083
5094
|
}
|
|
5084
|
-
|
|
5095
|
+
`,$3=`
|
|
5085
5096
|
uniform vec3 uColor;
|
|
5086
5097
|
uniform sampler2D uTexture;
|
|
5087
5098
|
varying float vOpacity;
|
|
@@ -5092,7 +5103,7 @@ void main() {
|
|
|
5092
5103
|
if (alpha < 0.01) discard;
|
|
5093
5104
|
gl_FragColor = vec4(uColor, alpha);
|
|
5094
5105
|
}
|
|
5095
|
-
`,
|
|
5106
|
+
`,J3=`
|
|
5096
5107
|
uniform float uSize;
|
|
5097
5108
|
uniform float uScale;
|
|
5098
5109
|
uniform float uNearFocusDistance;
|
|
@@ -5118,7 +5129,7 @@ void main() {
|
|
|
5118
5129
|
gl_PointSize = max(1.0, uSize * uScale / dist + vNearBlur * 12.0);
|
|
5119
5130
|
gl_Position = projectionMatrix * mvPosition;
|
|
5120
5131
|
}
|
|
5121
|
-
`,
|
|
5132
|
+
`,Q3=`
|
|
5122
5133
|
precision mediump float;
|
|
5123
5134
|
uniform sampler2D uTexture;
|
|
5124
5135
|
uniform vec3 uColor;
|
|
@@ -5133,4 +5144,4 @@ void main() {
|
|
|
5133
5144
|
float blur = max(vNearBlur, vHaze);
|
|
5134
5145
|
gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * 0.5));
|
|
5135
5146
|
}
|
|
5136
|
-
`;let ca;function uM(){if(ca)return ca;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),ca=new qn(e),ca}function dM(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",c="#f4f1e2";n.fillStyle=o,n.beginPath(),n.arc(r,a,s,0,Math.PI*2),n.fill();const l=Cd(i.illuminatedFraction,0,1),h=i.phaseFraction<.5,d=s*Math.abs(1-2*l),u=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,d,s,0,Math.PI/2,-Math.PI/2,u)):(n.arc(r,a,s,Math.PI/2,-Math.PI/2,!1),n.ellipse(r,a,d,s,0,-Math.PI/2,Math.PI/2,u)),n.fill(),n.restore(),new qn(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 qn(e)}function Wo(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 t0=new Map;function pM(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 mM(i){let e=t0.get(i);return e||(e=fetch(i).then(t=>t.arrayBuffer()).then(pM),t0.set(i,e)),e}const gM=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,_M=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,vM=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,xM=20,MM=1;class SM{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(gM,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/xM,1);const r=n>MM;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(_M,this.windVolume).then(o=>this.applyIfCurrent(o,a,()=>this.windToken,c=>{this.windSource=c?.source,this.windGain=c?.gain,c&&(c.gain.gain.value=this.windVolume)}))}else this.windGain&&(this.windGain.gain.value=this.windVolume)}setPaused(e){if(e===this.paused)return;this.paused=e;const{type:t,intensity:n,windSpeed:s}=this.requested;this.setAmbient(t,n,s)}playThunder(){!this.context||this.paused||this.playOneShot(vM,.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()}}const yM=[{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}],n0=6.5;class Xo{static activeAt(e){return yM.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),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(e,t,n,s=n0){if(t<=0)return 0;const r=n0-s;return e*Math.sin(t*Math.PI/180)/Math.pow(n,r)}static radiantPosition(e,t,n){return fd(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 EM{lowerM;upperM;add(e,t){if(!(e<=0)){if(t.behindM!==void 0){const n=Vt.sizeMAt(t.behindM,e);this.lowerM=this.lowerM===void 0?n:Math.max(this.lowerM,n)}if(t.inFrontM!==void 0){const n=Vt.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:Vt.distanceMAt(this.lowerM,e),maxM:this.upperM===void 0?void 0:Vt.distanceMAt(this.upperM,e)}}clear(){this.lowerM=void 0,this.upperM=void 0}}c0();const bM={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"}},TM=["en","fr"],AM={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"}},wM=new URL(""+new URL("stars-mag7.5-DDr9QasD.bin",import.meta.url).href,import.meta.url).href,RM={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},qo={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class CM 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 SM;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),c=fl(navigator.languages,TM),l=this.sceneRenderer.pickBodyAt(a,o);if(l){this.showHoverTooltip(e,bM[l]?.[c]??l);return}const h=this.sceneRenderer.pickDecorAt(a,o),d=h?this.ufoElement.sighting.decor.find(u=>u.id===h):void 0;if(d){this.showHoverTooltip(e,d.title||AM[d.kind][c]);return}this.hoverTooltip.hidden=!0};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(Yl(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>${zd}</style>${Od}`,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 nM(this.sceneCanvas,void 0,this.handleLightningFlash),this.hoverTooltip=this.shadow.getElementById("hover-tooltip"),this.ufoElement=document.createElement(Zo),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")??wM;this.starCatalog=await mM(e),this.updateAstronomy(this.lastTimeMs)}updateAstronomy(e){const t=this.ufoElement.sighting;this.setWeather(Yl(t,e)),this.sceneRenderer.setProjection(t.instrument.projection),this.updateMeteorShower(t,e),this.sceneRenderer.setDecor(t.decor);const n=$s(t,e);this.sceneRenderer.setObserverPose(n??qo),this.sceneRenderer.updateDecorAnchoring($s(t,0),n,e),this.sceneRenderer.updateDecorLitState(e),this.sceneRenderer.setTerrainOrigin(n?.lat,n?.lng);const s=n?.lat??qo.lat,r=n?.lng??qo.lng,a=bu(t.event.time??{},r,t.event.utcOffsetHours);if(!a){this.sceneRenderer.setAstronomy(RM);return}const o=new Date(a.getTime()+e),c={lat:s,lng:r,elevationM:n?.elevationM??0},l={...Do("Sun",o,c),magnitude:Io("Sun",o)},h={...Do("Moon",o,c),phase:o2(o),magnitude:Io("Moon",o)},d=a2.map(u=>({body:u,position:Do(u,o,c),magnitude:Io(u,o)}));this.sceneRenderer.setAstronomy({sun:l,moon:h,planets:d,stars:this.starCatalog?{catalog:this.starCatalog,date:o,observer:c}:void 0})}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 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(e).pxToDeg(o.bounds.width);this.sizeEstimateOf(a).add(h,this.sceneRenderer.decorDistancesAt(c,l,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){e!==this.meteorScheduleFor&&(this.meteorScheduleFor=e,this.scheduleMeteors(e)),this.sceneRenderer.updateMeteors(t)}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?bu(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=Xo.activeAt(s).map(l=>{const h=Xo.radiantPosition(l.shower,s,r);return{entry:l,position:h,rate:Xo.observedRatePerHour(l.zhr,h.altitudeDeg,l.shower.populationIndex)}}).sort((l,h)=>h.rate-l.rate)[0];if(!a||a.rate<=0){this.sceneRenderer.setMeteorShower([],0,0);return}const o=(e.event.durationSeconds??0)*1e3||e.timeline.duration||2e4,c=_s.schedule({ratePerHour:a.rate,durationMs:o,velocityKmS:a.entry.shower.velocityKmS,seed:Math.round(s.getTime()/1e3)+Math.round(t.lat*1e3)});this.sceneRenderer.setMeteorShower(c,a.position.altitudeDeg,a.position.azimuthDeg)}nextMeteor(e){const t=this.sceneRenderer.meteorSchedule;if(t.length===0)return;const n=t.find(r=>r.t>e)??t[0],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=$s(t,e)?.fovDeg??dl.DEFAULT_FOV_DEG;return us.of(t.instrument,Vt.CANVAS_HEIGHT_PX,n)}sizeEstimateOf(e){let t=this.sizeEstimates.get(e);return t||(t=new EM,this.sizeEstimates.set(e,t)),t}}const i0="rr0-scene";function PM(){c0(),customElements.get(i0)||customElements.define(i0,CM)}PM();
|
|
5147
|
+
`;let ra;function j3(){if(ra)return ra;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),ra=new qn(e),ra}function eM(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",c="#f4f1e2";n.fillStyle=o,n.beginPath(),n.arc(r,a,s,0,Math.PI*2),n.fill();const l=xd(i.illuminatedFraction,0,1),h=i.phaseFraction<.5,d=s*Math.abs(1-2*l),u=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,d,s,0,Math.PI/2,-Math.PI/2,u)):(n.arc(r,a,s,Math.PI/2,-Math.PI/2,!1),n.ellipse(r,a,d,s,0,-Math.PI/2,Math.PI/2,u)),n.fill(),n.restore(),new qn(t)}function tM(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 qn(e)}function zo(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 qu=new Map;function nM(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 iM(i){let e=qu.get(i);return e||(e=fetch(i).then(t=>t.arrayBuffer()).then(nM),qu.set(i,e)),e}const sM=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,rM=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,aM=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,oM=20,cM=1;class lM{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(sM,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/oM,1);const r=n>cM;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(rM,this.windVolume).then(o=>this.applyIfCurrent(o,a,()=>this.windToken,c=>{this.windSource=c?.source,this.windGain=c?.gain,c&&(c.gain.gain.value=this.windVolume)}))}else this.windGain&&(this.windGain.gain.value=this.windVolume)}setPaused(e){if(e===this.paused)return;this.paused=e;const{type:t,intensity:n,windSpeed:s}=this.requested;this.setAmbient(t,n,s)}playThunder(){!this.context||this.paused||this.playOneShot(aM,.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()}}const hM=[{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}],Yu=6.5;class Bo{static activeAt(e){return hM.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),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(e,t,n,s=Yu){if(t<=0)return 0;const r=Yu-s;return e*Math.sin(t*Math.PI/180)/Math.pow(n,r)}static radiantPosition(e,t,n){return id(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 uM{lowerM;upperM;add(e,t){if(!(e<=0)){if(t.behindM!==void 0){const n=Wt.sizeMAt(t.behindM,e);this.lowerM=this.lowerM===void 0?n:Math.max(this.lowerM,n)}if(t.inFrontM!==void 0){const n=Wt.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:Wt.distanceMAt(this.lowerM,e),maxM:this.upperM===void 0?void 0:Wt.distanceMAt(this.upperM,e)}}clear(){this.lowerM=void 0,this.upperM=void 0}}ju();const dM={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"}},fM=["en","fr"],pM={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"}},mM=new URL(""+new URL("stars-mag7.5-DDr9QasD.bin",import.meta.url).href,import.meta.url).href,gM={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},ko={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class _M 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 lM;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),c=ol(navigator.languages,fM),l=this.sceneRenderer.pickBodyAt(a,o);if(l){this.showHoverTooltip(e,dM[l]?.[c]??l);return}const h=this.sceneRenderer.pickDecorAt(a,o),d=h?this.ufoElement.sighting.decor.find(u=>u.id===h):void 0;if(d){this.showHoverTooltip(e,d.title||pM[d.kind][c]);return}this.hoverTooltip.hidden=!0};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(Hl(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>${Rd}</style>${wd}`,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 W3(this.sceneCanvas,void 0,this.handleLightningFlash),this.hoverTooltip=this.shadow.getElementById("hover-tooltip"),this.ufoElement=document.createElement(Vo),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")??mM;this.starCatalog=await iM(e),this.updateAstronomy(this.lastTimeMs)}updateAstronomy(e){const t=this.ufoElement.sighting;this.setWeather(Hl(t,e)),this.sceneRenderer.setProjection(t.instrument.projection),this.updateMeteorShower(t,e),this.sceneRenderer.setDecor(t.decor);const n=Js(t,e);this.sceneRenderer.setObserverPose(n??ko),this.sceneRenderer.updateDecorAnchoring(Js(t,0),n,e),this.sceneRenderer.updateDecorLitState(e),this.sceneRenderer.setTerrainOrigin(n?.lat,n?.lng);const s=n?.lat??ko.lat,r=n?.lng??ko.lng,a=mu(t.event.time??{},r,t.event.utcOffsetHours);if(!a){this.sceneRenderer.setAstronomy(gM);return}const o=new Date(a.getTime()+e),c={lat:s,lng:r,elevationM:n?.elevationM??0},l={...To("Sun",o,c),magnitude:Ao("Sun",o)},h={...To("Moon",o,c),phase:Z2(o),magnitude:Ao("Moon",o)},d=K2.map(u=>({body:u,position:To(u,o,c),magnitude:Ao(u,o)}));this.sceneRenderer.setAstronomy({sun:l,moon:h,planets:d,stars:this.starCatalog?{catalog:this.starCatalog,date:o,observer:c}:void 0})}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 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(e).pxToDeg(o.bounds.width);this.sizeEstimateOf(a).add(h,this.sceneRenderer.decorDistancesAt(c,l,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?mu(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=Bo.activeAt(s).map(l=>{const h=Bo.radiantPosition(l.shower,s,r);return{entry:l,position:h,rate:Bo.observedRatePerHour(l.zhr,h.altitudeDeg,l.shower.populationIndex)}}).sort((l,h)=>h.rate-l.rate)[0];if(!a||a.rate<=0){this.sceneRenderer.setMeteorShower([],0,0);return}const o=(e.event.durationSeconds??0)*1e3||e.timeline.duration||2e4,c=vs.schedule({ratePerHour:a.rate,durationMs:o,velocityKmS:a.entry.shower.velocityKmS,seed:Math.round(s.getTime()/1e3)+Math.round(t.lat*1e3)});this.sceneRenderer.setMeteorShower(c,a.position.altitudeDeg,a.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=Js(t,e)?.fovDeg??al.DEFAULT_FOV_DEG;return ds.of(t.instrument,Wt.CANVAS_HEIGHT_PX,n)}sizeEstimateOf(e){let t=this.sizeEstimates.get(e);return t||(t=new uM,this.sizeEstimates.set(e,t)),t}}const Ku="rr0-scene";function vM(){ju(),customElements.get(Ku)||customElements.define(Ku,_M)}vM();
|