@rr0/ufoathome 0.4.0 → 0.5.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/rr0-ufo-recorder.mjs +325 -193
- package/dist-embed-scene/rr0-scene.mjs +325 -193
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const od=`
|
|
2
2
|
<div class="appearance">
|
|
3
3
|
<div class="presets" role="group" aria-label="UFO shape">
|
|
4
4
|
<button class="preset" id="preset-oval" type="button" data-preset="oval">Oval</button>
|
|
@@ -47,7 +47,7 @@ const cd=`
|
|
|
47
47
|
<label><span id="label-lightning">Lightning</span> <input id="lightning" type="checkbox"/></label>
|
|
48
48
|
</div>
|
|
49
49
|
<div id="ufo-slot"></div>
|
|
50
|
-
`,
|
|
50
|
+
`,ld=`
|
|
51
51
|
:host {
|
|
52
52
|
display: block;
|
|
53
53
|
font-family: sans-serif;
|
|
@@ -92,7 +92,7 @@ button.preset[aria-pressed="true"] {
|
|
|
92
92
|
line-height: 1;
|
|
93
93
|
color: #e33;
|
|
94
94
|
}
|
|
95
|
-
`,
|
|
95
|
+
`,cd=`
|
|
96
96
|
<div class="stage" id="stage">
|
|
97
97
|
<div class="frame" id="frame">
|
|
98
98
|
<canvas id="canvas" width="640" height="360"></canvas>
|
|
@@ -106,7 +106,7 @@ button.preset[aria-pressed="true"] {
|
|
|
106
106
|
<button id="loop" type="button" title="Auto-replay" aria-label="Auto-replay" aria-pressed="true">↻</button>
|
|
107
107
|
</div>
|
|
108
108
|
</div>
|
|
109
|
-
`,
|
|
109
|
+
`,hd=`
|
|
110
110
|
:host {
|
|
111
111
|
display: block;
|
|
112
112
|
font-family: sans-serif;
|
|
@@ -224,7 +224,7 @@ input[type=range] {
|
|
|
224
224
|
min-width: 3em;
|
|
225
225
|
text-align: center;
|
|
226
226
|
}
|
|
227
|
-
`;function fd(i,t="#39ff14"){return{kind:"oval",bounds:i,color:t,angle:0,transparency:0,haloScale:0,selected:!1}}function kh(i,t,e="#39ff14"){return{kind:"polygon",bounds:i,points:t,color:e,angle:0,transparency:0,haloScale:0,selected:!1}}function pd(i,t="#39ff14"){const{width:e,height:n}=i,s=[{x:.5*e,y:0},{x:.8*e,y:.25*n},{x:e,y:.5*n},{x:.8*e,y:.75*n},{x:.5*e,y:n},{x:.2*e,y:.75*n},{x:0,y:.5*n},{x:.2*e,y:.25*n}];return kh(i,s,t)}function md(i,t="#39ff14"){const{width:e,height:n}=i,s=[{x:0,y:0},{x:e,y:n/2},{x:0,y:n}];return kh(i,s,t)}const gd={oval:fd,saucer:pd,triangle:md};function Vl(i,t){return{...gd[t.presetId](i,t.color),transparency:t.transparency,haloScale:t.haloScale}}function _d(i,t,e){const{bounds:n}=i;return t>=n.x&&t<=n.x+n.width&&e>=n.y&&e<=n.y+n.height}function Hh(i,t,e){const n=i.bounds.width,s=i.bounds.height;return{...i,bounds:{x:t-n/2,y:e-s/2,width:n,height:s}}}function Ye(i,t,e){return i+(t-i)*e}function Wl(i){const t=/^#([0-9a-f]{6})$/i.exec(i);if(!t)return;const e=parseInt(t[1],16);return[e>>16&255,e>>8&255,e&255]}function vd(i){return`#${i.map(t=>Math.round(t).toString(16).padStart(2,"0")).join("")}`}function xd(i,t,e){const n=Wl(i),s=Wl(t);return!n||!s?e<1?i:t:vd([Ye(n[0],s[0],e),Ye(n[1],s[1],e),Ye(n[2],s[2],e)])}function Sd(i,t,e){const n={x:Ye(i.bounds.x,t.bounds.x,e),y:Ye(i.bounds.y,t.bounds.y,e),width:Ye(i.bounds.width,t.bounds.width,e),height:Ye(i.bounds.height,t.bounds.height,e)},s=Ye(i.angle,t.angle,e),r=Ye(i.transparency,t.transparency,e),a=Ye(i.haloScale,t.haloScale,e),o=xd(i.color,t.color,e);return i.kind==="polygon"&&t.kind==="polygon"&&i.points.length===t.points.length?{...i,bounds:n,angle:s,transparency:r,haloScale:a,color:o,points:i.points.map((l,c)=>({x:Ye(l.x,t.points[c].x,e),y:Ye(l.y,t.points[c].y,e)}))}:{...e<1?i:t,bounds:n,angle:s,transparency:r,haloScale:a,color:o}}class Zr{keyframes=[];addKeyframe(t,e){const n=this.findInsertIndex(t);if(this.keyframes[n]?.t===t){const s=new Set(e.map(r=>r.sourceId));this.keyframes[n]={t,shapes:[...this.keyframes[n].shapes.filter(r=>!s.has(r.sourceId)),...e]}}else this.keyframes.splice(n,0,{t,shapes:[...e]})}findInsertIndex(t){let e=0,n=this.keyframes.length;for(;e<n;){const s=e+n>>>1;this.keyframes[s].t<t?e=s+1:n=s}return e}getKeyframeAt(t){const e=this.findInsertIndex(t),n=this.keyframes[e];return n?.t===t?n:void 0}getShapeAt(t,e){return this.getKeyframeAt(t)?.shapes.find(n=>n.sourceId===e)?.shape}getLatestShapeAt(t,e){let n=this.findInsertIndex(t);for(this.keyframes[n]?.t!==t&&(n-=1);n>=0;n--){const s=this.keyframes[n].shapes.find(r=>r.sourceId===e);if(s)return s.shape}}getInterpolatedShapeAt(t,e){const n=this.findShapeAtOrBefore(t,e);if(n?.t===t)return n.shape;const s=this.findShapeAtOrAfter(t,e);return n?s?Sd(n.shape,s.shape,(t-n.t)/(s.t-n.t)):n.shape:s?.shape}findShapeAtOrBefore(t,e){let n=this.findInsertIndex(t);for(this.keyframes[n]?.t!==t&&(n-=1);n>=0;n--){const s=this.keyframes[n].shapes.find(r=>r.sourceId===e);if(s)return{t:this.keyframes[n].t,shape:s.shape}}}findShapeAtOrAfter(t,e){for(let n=this.findInsertIndex(t);n<this.keyframes.length;n++){const s=this.keyframes[n].shapes.find(r=>r.sourceId===e);if(s)return{t:this.keyframes[n].t,shape:s.shape}}}hitTest(t,e,n){const s=this.sourceIds;for(let r=s.length-1;r>=0;r--){const a=this.getInterpolatedShapeAt(t,s[r]);if(a&&_d(a,e,n))return{sourceId:s[r],shape:a}}}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get sourceIds(){const t=new Set;for(const e of this.keyframes)for(const n of e.shapes)t.add(n.sourceId);return[...t]}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new Zr;for(const n of t.keyframes)e.addKeyframe(n.t,n.shapes);return e}}function Md(i,t,e){return Math.max(t,Math.min(e,i))}function yd(i,t,e){const n=((t-i)%360+540)%360-180;return((i+n*e)%360+360)%360}function ss(i,t,e){return i+(t-i)*e}function Ed(i,t,e){return{lat:i.lat===void 0||t.lat===void 0?void 0:ss(i.lat,t.lat,e),lng:i.lng===void 0||t.lng===void 0?void 0:ss(i.lng,t.lng,e),elevationM:ss(i.elevationM,t.elevationM,e),headingDeg:i.headingDeg===void 0||t.headingDeg===void 0?void 0:yd(i.headingDeg,t.headingDeg,e),pitchDeg:ss(i.pitchDeg,t.pitchDeg,e),fovDeg:ss(i.fovDeg,t.fovDeg,e)}}class Ts{keyframes=[];addKeyframe(t,e){const n=this.findInsertIndex(t);this.keyframes[n]?.t===t?this.keyframes[n]={t,pose:e}:this.keyframes.splice(n,0,{t,pose:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}findInsertIndex(t){let e=0,n=this.keyframes.length;for(;e<n;){const s=e+n>>>1;this.keyframes[s].t<t?e=s+1:n=s}return e}getLatestPoseAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].pose:void 0}getInterpolatedPoseAt(t){const e=this.findInsertIndex(t),n=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(n?.t===t)return n.pose;const s=this.keyframes[e]?.t===t?void 0:this.keyframes[e];return n?s?Ed(n.pose,s.pose,Md((t-n.t)/(s.t-n.t),0,1)):n.pose:s?.pose}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new Ts;for(const n of t.keyframes)e.addKeyframe(n.t,n.pose);return e}}function Ka(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 bd(i){if(i.durationSeconds!==void 0)return i.durationSeconds*1e3;const t=i.time?Ka(i.time):void 0,e=i.endTime?Ka(i.endTime):void 0;return t!==void 0&&e!==void 0?e-t:void 0}class Kr{constructor(t,e,n,s,r,a,o){this.event=t,this.timeline=e,this.observerTrack=n,this.witnessId=s,this.witnessName=r,this.caseId=a,this.weather=o}static create(t,e,n){return new Kr({eventType:"sighting",time:t,place:e},new Zr,new Ts,n)}}const Td=0,Ad=0,wd=60;function Rd(i,t){const e=i.observerTrack.getInterpolatedPoseAt(t);if(e)return e;const n=i.event.place?.[0];if(n)return{lat:n.lat,lng:n.lng,elevationM:Td,headingDeg:void 0,pitchDeg:Ad,fovDeg:wd}}class Cd{constructor(t,e){this.timeline=t,this.onFrame=e}rafId=null;state="stopped";currentT=0;lastWallTime=0;playbackRate=1;loop=!1;durationOverrideMs=0;get seekableDuration(){return Math.max(this.timeline.duration,this.durationOverrideMs)}play(){if(this.state==="playing")return;this.currentT>=this.seekableDuration&&(this.currentT=0,this.resolveFrame(0)),this.state="playing",this.lastWallTime=performance.now();const t=()=>{if(this.state!=="playing")return;const e=performance.now();if(this.currentT+=(e-this.lastWallTime)*this.playbackRate,this.lastWallTime=e,this.currentT>=this.seekableDuration){if(this.loop&&this.seekableDuration>0){this.currentT%=this.seekableDuration,this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(t);return}this.currentT=this.seekableDuration,this.stop(),this.resolveFrame(this.currentT);return}this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(t)};this.rafId=requestAnimationFrame(t)}pause(){this.state==="playing"&&(this.state="paused",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null))}stop(){this.state="stopped",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}seek(t){this.currentT=Math.max(0,Math.min(t,this.seekableDuration)),this.resolveFrame(this.currentT)}get playbackState(){return this.state}get time(){return this.currentT}resolveFrame(t){const e=new Map;for(const n of this.timeline.sourceIds){const s=this.timeline.getInterpolatedShapeAt(t,n);s&&e.set(n,s)}this.onFrame(t,e)}}const Gh=["nw","n","ne","e","se","s","sw","w"],Pd=24,ki=8;function Vh(i,t,e){const n=i.x-t.x,s=i.y-t.y,r=Math.cos(e),a=Math.sin(e);return{x:t.x+n*r-s*a,y:t.y+n*a+s*r}}function dl(i){return{x:i.x+i.width/2,y:i.y+i.height/2}}function Wh(i){const{x:t,y:e,width:n,height:s}=i.bounds,r={nw:{x:t,y:e},n:{x:t+n/2,y:e},ne:{x:t+n,y:e},e:{x:t+n,y:e+s/2},se:{x:t+n,y:e+s},s:{x:t+n/2,y:e+s},sw:{x:t,y:e+s},w:{x:t,y:e+s/2},rotate:{x:t+n/2,y:e-Pd}},a=dl(i.bounds),o={};for(const l of Object.keys(r))o[l]=Vh(r[l],a,i.angle);return o}function Id(i,t,e=8){const n=Wh(i);for(const s of[...Gh,"rotate"])if(Math.hypot(t.x-n[s].x,t.y-n[s].y)<=e)return s}const Dd={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}};function Ld(i,t,e){if(t==="rotate")throw new Error("resizeShape does not accept the rotate handle");const n=dl(i.bounds),s=Vh(e,n,-i.angle),{x:r,y:a,width:o,height:l}=i.bounds,c=Dd[t];let h=r,d=a,u=r+o,p=a+l;c.left&&(h=Math.min(s.x,u-ki)),c.right&&(u=Math.max(s.x,h+ki)),c.top&&(d=Math.min(s.y,p-ki)),c.bottom&&(p=Math.max(s.y,d+ki));const _={x:h,y:d,width:u-h,height:p-d};if(i.kind==="oval")return{...i,bounds:_};const M=o===0?1:_.width/o,m=l===0?1:_.height/l;return{...i,bounds:_,points:i.points.map(f=>({x:f.x*M,y:f.y*m}))}}function Ud(i,t){const e=dl(i.bounds),n=Math.atan2(t.y-e.y,t.x-e.x)+Math.PI/2;return{...i,angle:n}}const $a=6,Ls=$a/2,Nd=20;class Fd{constructor(t){this.ctx=t}clear(t,e){this.ctx.clearRect(0,0,t,e)}paintShape(t){this.ctx.save(),this.ctx.globalAlpha=1-t.transparency,t.haloScale>0&&this.paintHalo(t),this.paintBase(t),this.ctx.restore(),t.selected&&this.paintSelectionHandles(t)}paintBase(t){if(this.ctx.fillStyle=t.color,this.ctx.beginPath(),t.kind==="oval"){const{x:e,y:n,width:s,height:r}=t.bounds,a=s/2,o=r/2;this.ctx.ellipse(e+a,n+o,a,o,t.angle,0,2*Math.PI)}else{const{x:e,y:n,width:s,height:r}=t.bounds;this.ctx.save(),this.ctx.translate(e+s/2,n+r/2),this.ctx.rotate(t.angle),this.ctx.translate(-s/2,-r/2),t.points.forEach((a,o)=>{o===0?this.ctx.moveTo(a.x,a.y):this.ctx.lineTo(a.x,a.y)}),this.ctx.closePath(),this.ctx.restore()}this.ctx.fill()}paintHalo(t){this.ctx.save(),this.ctx.shadowColor=t.color,this.ctx.shadowBlur=Nd*t.haloScale,this.paintBase(t),this.ctx.restore()}paintSelectionHandles(t){const e=Wh(t);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(),this.ctx.fillStyle="lightgray";for(const n of Gh){const s=e[n];this.ctx.fillRect(s.x-Ls,s.y-Ls,$a,$a)}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,Ls+1,Ls+1,0,0,2*Math.PI),this.ctx.fill()}}function Od(i){return{version:1,time:i.event.time,endTime:i.event.endTime,durationSeconds:i.event.durationSeconds,place:i.event.place,witnessId:i.witnessId,witnessName:i.witnessName,caseId:i.caseId,timeline:i.timeline.toJSON(),observerTrack:i.observerTrack.toJSON(),weather:i.weather}}function Bd(i){return new Kr({eventType:"sighting",time:i.time,endTime:i.endTime,durationSeconds:i.durationSeconds,place:i.place},Zr.fromJSON(i.timeline),i.observerTrack?Ts.fromJSON(i.observerTrack):new Ts,i.witnessId,i.witnessName,i.caseId,i.weather)}function fl(i,t){for(const e of i){const n=e.toLowerCase().split("-")[0];if(t.includes(n))return n}return"en"}const zd="modulepreload",kd=function(i,t){return new URL(i,t).href},Xl={},Dr=function(t,e,n){let s=Promise.resolve();if(e&&e.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"),l=document.querySelector("meta[property=csp-nonce]"),c=l?.nonce||l?.getAttribute("nonce");s=a(e.map(h=>{if(h=kd(h,n),h in Xl)return;Xl[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 _=document.createElement("link");if(_.rel=d?"stylesheet":zd,d||(_.as="script"),_.crossOrigin="",_.href=h,c&&_.setAttribute("nonce",c),document.head.appendChild(_),d)return new Promise((M,m)=>{_.addEventListener("load",M),_.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${h}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return s.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return t().catch(r)})},Xh=["en","fr"],Hd={en:()=>Dr(()=>Promise.resolve().then(()=>Xd),void 0,import.meta.url).then(i=>i.ufoMessages_en),fr:()=>Dr(()=>import("./UfoMessages_fr-COCxf8Q_.js"),[],import.meta.url).then(i=>i.ufoMessages_fr)};function Gd(i){return Hd[i]()}const Vd={en:()=>Dr(()=>Promise.resolve().then(()=>r2),void 0,import.meta.url).then(i=>i.ufoRecorderMessages_en),fr:()=>Dr(()=>import("./UfoRecorderMessages_fr-DDDvsOhq.js"),[],import.meta.url).then(i=>i.ufoRecorderMessages_fr)};function Wd(i){return Vd[i]()}const qh={play:"Play",pause:"Pause",autoReplay:"Auto-replay",currentPosition:"Current position",duration:"Duration",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen"},Xd=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:qh},Symbol.toStringTag,{value:"Module"}));class qd extends HTMLElement{static get observedAttributes(){return["src"]}shadow;stageElement;canvas;canvasRenderer;toolbar;playPauseButton;loopButton;fullscreenButton;seekInput;timeStartLabel;timeEndLabel;currentSighting=Kr.create();player;loopEnabled=!0;highlightedSourceId;enableClickToPlay=!0;fullscreenTarget;messages=qh;realDurationMs;realStartMs;handleFullscreenChange=()=>this.updateFullscreenButton();constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${dd}</style>${ud}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new Fd(this.canvas.getContext("2d")),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()}),document.addEventListener("fullscreenchange",this.handleFullscreenChange),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.refresh(),this.loadLocaleMessages()}connectedCallback(){const t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){document.removeEventListener("fullscreenchange",this.handleFullscreenChange)}attributeChangedCallback(t,e,n){t==="src"&&n&&n!==e&&this.isConnected&&this.loadFromSrc(n)}async loadFromSrc(t){const e=await fetch(t);this.sightingData=await e.json()}get sightingData(){return Od(this.currentSighting)}set sightingData(t){this.currentSighting=Bd(t),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.refresh()}get sighting(){return this.currentSighting}get canvasElement(){return this.canvas}get renderer(){return this.canvasRenderer}get currentTime(){return this.player.time}get playbackState(){return this.player.playbackState}get selectedSourceId(){return this.highlightedSourceId}get durationSeconds(){return this.currentSighting.event.durationSeconds}set durationSeconds(t){this.currentSighting.event.durationSeconds=t,this.updateTimeLabels(),this.refresh()}set selectedSourceId(t){t!==this.highlightedSourceId&&(this.highlightedSourceId=t,this.refresh())}refresh(){this.seekInput.max=String(this.player.seekableDuration),this.player.seek(this.player.time)}onFrame(t,e){this.canvasRenderer.clear(this.canvas.width,this.canvas.height);const n=this.playbackState!=="playing";for(const[s,r]of e){const a=n&&s===this.highlightedSourceId;this.canvasRenderer.paintShape(a?{...r,selected:!0}:r)}this.seekInput.value=String(t),this.timeStartLabel.textContent=this.formatPosition(t),this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:t}}))}createPlayer(){const t=new Cd(this.currentSighting.timeline,(e,n)=>this.onFrame(e,n));return t.loop=this.loopEnabled,t}togglePlayPause(){this.player.playbackState==="playing"?(this.player.pause(),this.refresh()):this.player.play(),this.updatePlayPauseButton()}updatePlayPauseButton(){const t=this.player.playbackState==="playing";this.playPauseButton.textContent=t?"⏸":"▶",this.playPauseButton.title=t?this.messages.pause:this.messages.play,this.playPauseButton.setAttribute("aria-label",t?this.messages.pause:this.messages.play),this.toolbar.classList.toggle("auto-hide",t),this.fullscreenButton.classList.toggle("auto-hide",t)}toggleLoop(){this.loopEnabled=!this.loopEnabled,this.loopButton.setAttribute("aria-pressed",String(this.loopEnabled)),this.player.loop=this.loopEnabled}toggleFullscreen(){document.fullscreenElement?document.exitFullscreen():this.fullscreenTarget.requestFullscreen().catch(t=>{console.error("<rr0-ufo>: requestFullscreen() failed —",t)})}updateFullscreenButton(){const t=document.fullscreenElement===this.fullscreenTarget;this.fullscreenButton.title=t?this.messages.exitFullscreen:this.messages.fullscreen,this.fullscreenButton.setAttribute("aria-label",this.fullscreenButton.title)}async loadLocaleMessages(){const t=fl(navigator.languages,Xh);t!=="en"&&this.applyMessages(await Gd(t))}applyMessages(t){this.messages=t,this.timeStartLabel.title=t.currentPosition,this.timeEndLabel.title=t.duration,this.loopButton.title=t.autoReplay,this.loopButton.setAttribute("aria-label",t.autoReplay),this.updatePlayPauseButton(),this.updateFullscreenButton()}updateTimeLabels(){const t=this.currentSighting.event,e=bd(t);this.realDurationMs=e!==void 0&&e>0?e:void 0,this.realStartMs=t.time?Ka(t.time):void 0;const n=this.currentSighting.timeline.duration;this.player.playbackRate=this.realDurationMs!==void 0&&n>0?n/this.realDurationMs:1,this.player.durationOverrideMs=this.realDurationMs??0,this.timeEndLabel.textContent=this.formatEndOfTimeline(),this.timeStartLabel.textContent=this.formatPosition(this.player.time)}formatPosition(t){if(this.realDurationMs===void 0)return Us(t);const e=this.currentSighting.timeline.duration,n=e>0&&t<=e?t/e*this.realDurationMs:t;return this.realStartMs!==void 0?Yl(ql(this.realStartMs+n)):Us(n)}formatEndOfTimeline(){return this.realDurationMs===void 0?Us(this.currentSighting.timeline.duration):this.realStartMs!==void 0?Yl(ql(this.realStartMs+this.realDurationMs)):Us(this.realDurationMs)}}function ql(i){const t=new Date(i);return{hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}function Yl(i){if(i.hour===void 0)return"0:00";const t=e=>String(e).padStart(2,"0");return i.second?`${t(i.hour)}:${t(i.minute??0)}:${t(i.second)}`:`${t(i.hour)}:${t(i.minute??0)}`}function Us(i){const t=Math.round(i/1e3),e=Math.floor(t/60),n=t%60;return`${e}:${String(n).padStart(2,"0")}`}const Ja="rr0-ufo";function $r(){customElements.get(Ja)||customElements.define(Ja,qd)}const Yd=`
|
|
227
|
+
`;function ud(i,e="#39ff14"){return{kind:"oval",bounds:i,color:e,angle:0,transparency:0,haloScale:0,selected:!1}}function Oh(i,e,t="#39ff14"){return{kind:"polygon",bounds:i,points:e,color:t,angle:0,transparency:0,haloScale:0,selected:!1}}function dd(i,e="#39ff14"){const{width:t,height:n}=i,s=[{x:.5*t,y:0},{x:.8*t,y:.25*n},{x:t,y:.5*n},{x:.8*t,y:.75*n},{x:.5*t,y:n},{x:.2*t,y:.75*n},{x:0,y:.5*n},{x:.2*t,y:.25*n}];return Oh(i,s,e)}function fd(i,e="#39ff14"){const{width:t,height:n}=i,s=[{x:0,y:0},{x:t,y:n/2},{x:0,y:n}];return Oh(i,s,e)}const pd={oval:ud,saucer:dd,triangle:fd};function Hl(i,e){return{...pd[e.presetId](i,e.color),transparency:e.transparency,haloScale:e.haloScale}}function md(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 Bh(i,e,t){const n=i.bounds.width,s=i.bounds.height;return{...i,bounds:{x:e-n/2,y:t-s/2,width:n,height:s}}}function Yt(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 gd(i){return`#${i.map(e=>Math.round(e).toString(16).padStart(2,"0")).join("")}`}function _d(i,e,t){const n=Vl(i),s=Vl(e);return!n||!s?t<1?i:e:gd([Yt(n[0],s[0],t),Yt(n[1],s[1],t),Yt(n[2],s[2],t)])}function vd(i,e,t){const n={x:Yt(i.bounds.x,e.bounds.x,t),y:Yt(i.bounds.y,e.bounds.y,t),width:Yt(i.bounds.width,e.bounds.width,t),height:Yt(i.bounds.height,e.bounds.height,t)},s=Yt(i.angle,e.angle,t),r=Yt(i.transparency,e.transparency,t),a=Yt(i.haloScale,e.haloScale,t),o=_d(i.color,e.color,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,points:i.points.map((l,c)=>({x:Yt(l.x,e.points[c].x,t),y:Yt(l.y,e.points[c].y,t)}))}:{...t<1?i:e,bounds:n,angle:s,transparency:r,haloScale:a,color:o}}class qr{keyframes=[];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]})}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?vd(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){const s=this.sourceIds;for(let r=s.length-1;r>=0;r--){const a=this.getInterpolatedShapeAt(e,s[r]);if(a&&md(a,t,n))return{sourceId:s[r],shape:a}}}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get sourceIds(){const e=new Set;for(const t of this.keyframes)for(const n of t.shapes)e.add(n.sourceId);return[...e]}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(e){const t=new qr;for(const n of e.keyframes)t.addKeyframe(n.t,n.shapes);return t}}function xd(i,e,t){return Math.max(e,Math.min(t,i))}function Sd(i,e,t){const n=((e-i)%360+540)%360-180;return((i+n*t)%360+360)%360}function is(i,e,t){return i+(e-i)*t}function Md(i,e,t){return{lat:i.lat===void 0||e.lat===void 0?void 0:is(i.lat,e.lat,t),lng:i.lng===void 0||e.lng===void 0?void 0:is(i.lng,e.lng,t),elevationM:is(i.elevationM,e.elevationM,t),headingDeg:i.headingDeg===void 0||e.headingDeg===void 0?void 0:Sd(i.headingDeg,e.headingDeg,t),pitchDeg:is(i.pitchDeg,e.pitchDeg,t),fovDeg:is(i.fovDeg,e.fovDeg,t)}}class Es{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?Md(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 Es;for(const n of e.keyframes)t.addKeyframe(n.t,n.pose);return t}}function Ka(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 yd(i){if(i.durationSeconds!==void 0)return i.durationSeconds*1e3;const e=i.time?Ka(i.time):void 0,t=i.endTime?Ka(i.endTime):void 0;return e!==void 0&&t!==void 0?t-e:void 0}class Yr{constructor(e,t,n,s,r,a,o){this.event=e,this.timeline=t,this.observerTrack=n,this.witnessId=s,this.witnessName=r,this.caseId=a,this.weather=o}static create(e,t,n){return new Yr({eventType:"sighting",time:e,place:t},new qr,new Es,n)}}const Ed=0,bd=0,Td=60;function Ad(i,e){const t=i.observerTrack.getInterpolatedPoseAt(e);if(t)return t;const n=i.event.place?.[0];if(n)return{lat:n.lat,lng:n.lng,elevationM:Ed,headingDeg:void 0,pitchDeg:bd,fovDeg:Td}}class wd{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 zh=["nw","n","ne","e","se","s","sw","w"],Rd=24,zi=8;function kh(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 dl(i){return{x:i.x+i.width/2,y:i.y+i.height/2}}function Gh(i){const{x:e,y:t,width:n,height:s}=i.bounds,r={nw:{x:e,y:t},n:{x:e+n/2,y:t},ne:{x:e+n,y:t},e:{x:e+n,y:t+s/2},se:{x:e+n,y:t+s},s:{x:e+n/2,y:t+s},sw:{x:e,y:t+s},w:{x:e,y:t+s/2},rotate:{x:e+n/2,y:t-Rd}},a=dl(i.bounds),o={};for(const l of Object.keys(r))o[l]=kh(r[l],a,i.angle);return o}function Cd(i,e,t=8){const n=Gh(i);for(const s of[...zh,"rotate"])if(Math.hypot(e.x-n[s].x,e.y-n[s].y)<=t)return s}const Pd={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}};function Id(i,e,t){if(e==="rotate")throw new Error("resizeShape does not accept the rotate handle");const n=dl(i.bounds),s=kh(t,n,-i.angle),{x:r,y:a,width:o,height:l}=i.bounds,c=Pd[e];let h=r,d=a,u=r+o,p=a+l;c.left&&(h=Math.min(s.x,u-zi)),c.right&&(u=Math.max(s.x,h+zi)),c.top&&(d=Math.min(s.y,p-zi)),c.bottom&&(p=Math.max(s.y,d+zi));const _={x:h,y:d,width:u-h,height:p-d};if(i.kind==="oval")return{...i,bounds:_};const M=o===0?1:_.width/o,m=l===0?1:_.height/l;return{...i,bounds:_,points:i.points.map(f=>({x:f.x*M,y:f.y*m}))}}function Dd(i,e){const t=dl(i.bounds),n=Math.atan2(e.y-t.y,e.x-t.x)+Math.PI/2;return{...i,angle:n}}const $a=6,Ds=$a/2,Ld=20;class Ud{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=Ld*e.haloScale,this.paintBase(e),this.ctx.restore()}paintSelectionHandles(e){const t=Gh(e);this.ctx.strokeStyle="lightgray",this.ctx.beginPath(),this.ctx.moveTo(t.nw.x,t.nw.y),this.ctx.lineTo(t.ne.x,t.ne.y),this.ctx.lineTo(t.se.x,t.se.y),this.ctx.lineTo(t.sw.x,t.sw.y),this.ctx.closePath(),this.ctx.stroke(),this.ctx.fillStyle="lightgray";for(const n of zh){const s=t[n];this.ctx.fillRect(s.x-Ds,s.y-Ds,$a,$a)}this.ctx.beginPath(),this.ctx.moveTo(t.n.x,t.n.y),this.ctx.lineTo(t.rotate.x,t.rotate.y),this.ctx.stroke(),this.ctx.beginPath(),this.ctx.ellipse(t.rotate.x,t.rotate.y,Ds+1,Ds+1,0,0,2*Math.PI),this.ctx.fill()}}function Nd(i){return{version:1,time:i.event.time,endTime:i.event.endTime,durationSeconds:i.event.durationSeconds,place:i.event.place,witnessId:i.witnessId,witnessName:i.witnessName,caseId:i.caseId,timeline:i.timeline.toJSON(),observerTrack:i.observerTrack.toJSON(),weather:i.weather}}function Fd(i){return new Yr({eventType:"sighting",time:i.time,endTime:i.endTime,durationSeconds:i.durationSeconds,place:i.place},qr.fromJSON(i.timeline),i.observerTrack?Es.fromJSON(i.observerTrack):new Es,i.witnessId,i.witnessName,i.caseId,i.weather)}function fl(i,e){for(const t of i){const n=t.toLowerCase().split("-")[0];if(e.includes(n))return n}return"en"}const Od="modulepreload",Bd=function(i,e){return new URL(i,e).href},Wl={},Ir=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"),l=document.querySelector("meta[property=csp-nonce]"),c=l?.nonce||l?.getAttribute("nonce");s=a(t.map(h=>{if(h=Bd(h,n),h in Wl)return;Wl[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 _=document.createElement("link");if(_.rel=d?"stylesheet":Od,d||(_.as="script"),_.crossOrigin="",_.href=h,c&&_.setAttribute("nonce",c),document.head.appendChild(_),d)return new Promise((M,m)=>{_.addEventListener("load",M),_.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)})},Hh=["en","fr"],zd={en:()=>Ir(()=>Promise.resolve().then(()=>Vd),void 0,import.meta.url).then(i=>i.ufoMessages_en),fr:()=>Ir(()=>import("./UfoMessages_fr-COCxf8Q_.js"),[],import.meta.url).then(i=>i.ufoMessages_fr)};function kd(i){return zd[i]()}const Gd={en:()=>Ir(()=>Promise.resolve().then(()=>a2),void 0,import.meta.url).then(i=>i.ufoRecorderMessages_en),fr:()=>Ir(()=>import("./UfoRecorderMessages_fr-DDDvsOhq.js"),[],import.meta.url).then(i=>i.ufoRecorderMessages_fr)};function Hd(i){return Gd[i]()}const Vh={play:"Play",pause:"Pause",autoReplay:"Auto-replay",currentPosition:"Current position",duration:"Duration",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen"},Vd=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:Vh},Symbol.toStringTag,{value:"Module"}));class Wd extends HTMLElement{static get observedAttributes(){return["src"]}shadow;stageElement;canvas;canvasRenderer;toolbar;playPauseButton;loopButton;fullscreenButton;seekInput;timeStartLabel;timeEndLabel;currentSighting=Yr.create();player;loopEnabled=!0;highlightedSourceId;enableClickToPlay=!0;fullscreenTarget;messages=Vh;realDurationMs;realStartMs;handleFullscreenChange=()=>this.updateFullscreenButton();constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${hd}</style>${cd}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new Ud(this.canvas.getContext("2d")),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()}),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)}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 Nd(this.currentSighting)}set sightingData(e){this.currentSighting=Fd(e),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.refresh()}get sighting(){return this.currentSighting}get canvasElement(){return this.canvas}get renderer(){return this.canvasRenderer}get currentTime(){return this.player.time}get playbackState(){return this.player.playbackState}get selectedSourceId(){return this.highlightedSourceId}get durationSeconds(){return this.currentSighting.event.durationSeconds}set durationSeconds(e){this.currentSighting.event.durationSeconds=e,this.updateTimeLabels(),this.refresh()}set selectedSourceId(e){e!==this.highlightedSourceId&&(this.highlightedSourceId=e,this.refresh())}refresh(){this.seekInput.max=String(this.player.seekableDuration),this.player.seek(this.player.time)}onFrame(e,t){this.canvasRenderer.clear(this.canvas.width,this.canvas.height);const n=this.playbackState!=="playing";for(const[s,r]of t){const a=n&&s===this.highlightedSourceId;this.canvasRenderer.paintShape(a?{...r,selected:!0}:r)}this.seekInput.value=String(e),this.timeStartLabel.textContent=this.formatPosition(e),this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:e}}))}createPlayer(){const e=new wd(this.currentSighting.timeline,(t,n)=>this.onFrame(t,n));return e.loop=this.loopEnabled,e}togglePlayPause(){this.player.playbackState==="playing"?(this.player.pause(),this.refresh()):this.player.play(),this.updatePlayPauseButton()}updatePlayPauseButton(){const e=this.player.playbackState==="playing";this.playPauseButton.textContent=e?"⏸":"▶",this.playPauseButton.title=e?this.messages.pause:this.messages.play,this.playPauseButton.setAttribute("aria-label",e?this.messages.pause:this.messages.play),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,Hh);e!=="en"&&this.applyMessages(await kd(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=yd(e);this.realDurationMs=t!==void 0&&t>0?t:void 0,this.realStartMs=e.time?Ka(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=this.realDurationMs??0,this.timeEndLabel.textContent=this.formatEndOfTimeline(),this.timeStartLabel.textContent=this.formatPosition(this.player.time)}formatPosition(e){if(this.realDurationMs===void 0)return Ls(e);const t=this.currentSighting.timeline.duration,n=t>0&&e<=t?e/t*this.realDurationMs:e;return this.realStartMs!==void 0?ql(Xl(this.realStartMs+n)):Ls(n)}formatEndOfTimeline(){return this.realDurationMs===void 0?Ls(this.currentSighting.timeline.duration):this.realStartMs!==void 0?ql(Xl(this.realStartMs+this.realDurationMs)):Ls(this.realDurationMs)}}function Xl(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 Ls(i){const e=Math.round(i/1e3),t=Math.floor(e/60),n=e%60;return`${t}:${String(n).padStart(2,"0")}`}const Ja="rr0-ufo";function Zr(){customElements.get(Ja)||customElements.define(Ja,Wd)}const Xd=`
|
|
228
228
|
<div class="stage" id="stage">
|
|
229
229
|
<div class="frame" id="frame">
|
|
230
230
|
<canvas id="scene-canvas"></canvas>
|
|
@@ -233,7 +233,7 @@ input[type=range] {
|
|
|
233
233
|
<div id="body-tooltip" class="body-tooltip" hidden></div>
|
|
234
234
|
<div id="terrain-attribution" class="terrain-attribution" hidden></div>
|
|
235
235
|
</div>
|
|
236
|
-
`,
|
|
236
|
+
`,qd=`
|
|
237
237
|
:host {
|
|
238
238
|
display: block;
|
|
239
239
|
}
|
|
@@ -319,17 +319,17 @@ input[type=range] {
|
|
|
319
319
|
* @license
|
|
320
320
|
* Copyright 2010-2026 Three.js Authors
|
|
321
321
|
* SPDX-License-Identifier: MIT
|
|
322
|
-
*/const pl="185",Kd=0,Zl=1,$d=2,br=1,Jd=2,xs=3,Kn=0,Fe=1,bn=2,wn=0,Vi=1,Qa=2,Kl=3,$l=4,Qd=5,ni=100,jd=101,t0=102,e0=103,n0=104,i0=200,s0=201,r0=202,a0=203,ja=204,to=205,o0=206,l0=207,c0=208,h0=209,u0=210,d0=211,f0=212,p0=213,m0=214,eo=0,no=1,io=2,Ki=3,so=4,ro=5,ao=6,oo=7,Yh=0,g0=1,_0=2,pn=0,Zh=1,Kh=2,$h=3,Jh=4,Qh=5,jh=6,tu=7,eu=300,ci=301,$i=302,aa=303,oa=304,Jr=306,lo=1e3,Tn=1001,co=1002,Ae=1003,v0=1004,Ns=1005,Ie=1006,la=1007,ri=1008,$e=1009,nu=1010,iu=1011,As=1012,ml=1013,gn=1014,dn=1015,Cn=1016,gl=1017,_l=1018,ws=1020,su=35902,ru=35899,au=1021,ou=1022,sn=1023,Pn=1026,ai=1027,lu=1028,vl=1029,hi=1030,xl=1031,Sl=1033,Tr=33776,Ar=33777,wr=33778,Rr=33779,ho=35840,uo=35841,fo=35842,po=35843,mo=36196,go=37492,_o=37496,vo=37488,xo=37489,Lr=37490,So=37491,Mo=37808,yo=37809,Eo=37810,bo=37811,To=37812,Ao=37813,wo=37814,Ro=37815,Co=37816,Po=37817,Io=37818,Do=37819,Lo=37820,Uo=37821,No=36492,Fo=36494,Oo=36495,Bo=36283,zo=36284,Ur=36285,ko=36286,x0=3200,Jl=0,S0=1,Wn="",Ze="srgb",Nr="srgb-linear",Fr="linear",Qt="srgb",gi=7680,Ql=519,M0=512,y0=513,E0=514,Ml=515,b0=516,T0=517,yl=518,A0=519,Ho=35044,jl="300 es",fn=2e3,Or=2001;function w0(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function Br(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function R0(){const i=Br("canvas");return i.style.display="block",i}const tc={};function zr(...i){const t="THREE."+i.shift();console.log(t,...i)}function cu(i){const t=i[0];if(typeof t=="string"&&t.startsWith("TSL:")){const e=i[1];e&&e.isStackTrace?i[0]+=" "+e.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function Ft(...i){i=cu(i);const t="THREE."+i.shift();{const e=i[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...i)}}function Xt(...i){i=cu(i);const t="THREE."+i.shift();{const e=i[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...i)}}function Wi(...i){const t=i.join(" ");t in tc||(tc[t]=!0,Ft(...i))}function C0(i,t,e){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(t,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,e);break;default:n()}}setTimeout(r,e)})}const P0={[eo]:no,[io]:ao,[so]:oo,[Ki]:ro,[no]:eo,[ao]:io,[oo]:so,[ro]:Ki};class fi{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){const n=this._listeners;return n===void 0?!1:n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){const n=this._listeners;if(n===void 0)return;const s=n[t];if(s!==void 0){const r=s.indexOf(e);r!==-1&&s.splice(r,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const n=e[t.type];if(n!==void 0){t.target=this;const s=n.slice(0);for(let r=0,a=s.length;r<a;r++)s[r].call(this,t);t.target=null}}}const Re=["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"],ca=Math.PI/180,Go=180/Math.PI;function Yn(){const i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Re[i&255]+Re[i>>8&255]+Re[i>>16&255]+Re[i>>24&255]+"-"+Re[t&255]+Re[t>>8&255]+"-"+Re[t>>16&15|64]+Re[t>>24&255]+"-"+Re[e&63|128]+Re[e>>8&255]+"-"+Re[e>>16&255]+Re[e>>24&255]+Re[n&255]+Re[n>>8&255]+Re[n>>16&255]+Re[n>>24&255]).toLowerCase()}function Yt(i,t,e){return Math.max(t,Math.min(e,i))}function I0(i,t){return(i%t+t)%t}function ha(i,t,e){return(1-e)*i+e*t}function un(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function te(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}class kt{static{kt.prototype.isVector2=!0}constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("THREE.Vector2: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6],this.y=s[1]*e+s[4]*n+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Yt(this.x,t.x,e.x),this.y=Yt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Yt(this.x,t,e),this.y=Yt(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Yt(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Yt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),s=Math.sin(e),r=this.x-t.x,a=this.y-t.y;return this.x=r*n-a*s+t.x,this.y=r*s+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class es{constructor(t=0,e=0,n=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=s}static slerpFlat(t,e,n,s,r,a,o){let l=n[s+0],c=n[s+1],h=n[s+2],d=n[s+3],u=r[a+0],p=r[a+1],_=r[a+2],M=r[a+3];if(d!==M||l!==u||c!==p||h!==_){let m=l*u+c*p+h*_+d*M;m<0&&(u=-u,p=-p,_=-_,M=-M,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,l=l*f+u*o,c=c*f+p*o,h=h*f+_*o,d=d*f+M*o}else{l=l*f+u*o,c=c*f+p*o,h=h*f+_*o,d=d*f+M*o;const A=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=A,c*=A,h*=A,d*=A}}t[e]=l,t[e+1]=c,t[e+2]=h,t[e+3]=d}static multiplyQuaternionsFlat(t,e,n,s,r,a){const o=n[s],l=n[s+1],c=n[s+2],h=n[s+3],d=r[a],u=r[a+1],p=r[a+2],_=r[a+3];return t[e]=o*_+h*d+l*p-c*u,t[e+1]=l*_+h*u+c*d-o*p,t[e+2]=c*_+h*p+o*u-l*d,t[e+3]=h*_-o*d-l*u-c*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,s){return this._x=t,this._y=e,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,s=t._y,r=t._z,a=t._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(s/2),d=o(r/2),u=l(n/2),p=l(s/2),_=l(r/2);switch(a){case"XYZ":this._x=u*h*d+c*p*_,this._y=c*p*d-u*h*_,this._z=c*h*_+u*p*d,this._w=c*h*d-u*p*_;break;case"YXZ":this._x=u*h*d+c*p*_,this._y=c*p*d-u*h*_,this._z=c*h*_-u*p*d,this._w=c*h*d+u*p*_;break;case"ZXY":this._x=u*h*d-c*p*_,this._y=c*p*d+u*h*_,this._z=c*h*_+u*p*d,this._w=c*h*d-u*p*_;break;case"ZYX":this._x=u*h*d-c*p*_,this._y=c*p*d+u*h*_,this._z=c*h*_-u*p*d,this._w=c*h*d+u*p*_;break;case"YZX":this._x=u*h*d+c*p*_,this._y=c*p*d+u*h*_,this._z=c*h*_-u*p*d,this._w=c*h*d-u*p*_;break;case"XZY":this._x=u*h*d-c*p*_,this._y=c*p*d-u*h*_,this._z=c*h*_+u*p*d,this._w=c*h*d+u*p*_;break;default:Ft("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,s=Math.sin(n);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],s=e[4],r=e[8],a=e[1],o=e[5],l=e[9],c=e[2],h=e[6],d=e[10],u=n+o+d;if(u>0){const p=.5/Math.sqrt(u+1);this._w=.25/p,this._x=(h-l)*p,this._y=(r-c)*p,this._z=(a-s)*p}else if(n>o&&n>d){const p=2*Math.sqrt(1+n-o-d);this._w=(h-l)/p,this._x=.25*p,this._y=(s+a)/p,this._z=(r+c)/p}else if(o>d){const p=2*Math.sqrt(1+o-n-d);this._w=(r-c)/p,this._x=(s+a)/p,this._y=.25*p,this._z=(l+h)/p}else{const p=2*Math.sqrt(1+d-n-o);this._w=(a-s)/p,this._x=(r+c)/p,this._y=(l+h)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Yt(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const s=Math.min(1,e/n);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,s=t._y,r=t._z,a=t._w,o=e._x,l=e._y,c=e._z,h=e._w;return this._x=n*h+a*o+s*c-r*l,this._y=s*h+a*l+r*o-n*c,this._z=r*h+a*c+n*l-s*o,this._w=a*h-n*o-s*l-r*c,this._onChangeCallback(),this}slerp(t,e){let n=t._x,s=t._y,r=t._z,a=t._w,o=this.dot(t);o<0&&(n=-n,s=-s,r=-r,a=-a,o=-o);let l=1-e;if(o<.9995){const c=Math.acos(o),h=Math.sin(c);l=Math.sin(l*c)/h,e=Math.sin(e*c)/h,this._x=this._x*l+n*e,this._y=this._y*l+s*e,this._z=this._z*l+r*e,this._w=this._w*l+a*e,this._onChangeCallback()}else this._x=this._x*l+n*e,this._y=this._y*l+s*e,this._z=this._z*l+r*e,this._w=this._w*l+a*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(t),s*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class F{static{F.prototype.isVector3=!0}constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("THREE.Vector3: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(ec.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(ec.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*s,this.y=r[1]*e+r[4]*n+r[7]*s,this.z=r[2]*e+r[5]*n+r[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,s=this.z,r=t.elements,a=1/(r[3]*e+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*s+r[12])*a,this.y=(r[1]*e+r[5]*n+r[9]*s+r[13])*a,this.z=(r[2]*e+r[6]*n+r[10]*s+r[14])*a,this}applyQuaternion(t){const e=this.x,n=this.y,s=this.z,r=t.x,a=t.y,o=t.z,l=t.w,c=2*(a*s-o*n),h=2*(o*e-r*s),d=2*(r*n-a*e);return this.x=e+l*c+a*d-o*h,this.y=n+l*h+o*c-r*d,this.z=s+l*d+r*h-a*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*s,this.y=r[1]*e+r[5]*n+r[9]*s,this.z=r[2]*e+r[6]*n+r[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Yt(this.x,t.x,e.x),this.y=Yt(this.y,t.y,e.y),this.z=Yt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Yt(this.x,t,e),this.y=Yt(this.y,t,e),this.z=Yt(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Yt(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,s=t.y,r=t.z,a=e.x,o=e.y,l=e.z;return this.x=s*l-r*o,this.y=r*a-n*l,this.z=n*o-s*a,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return ua.copy(this).projectOnVector(t),this.sub(ua)}reflect(t){return this.sub(ua.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Yt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,s=this.z-t.z;return e*e+n*n+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const s=Math.sin(e)*t;return this.x=s*Math.sin(n),this.y=Math.cos(e)*t,this.z=s*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const ua=new F,ec=new es;class Ot{static{Ot.prototype.isMatrix3=!0}constructor(t,e,n,s,r,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,a,o,l,c)}set(t,e,n,s,r,a,o,l,c){const h=this.elements;return h[0]=t,h[1]=s,h[2]=o,h[3]=e,h[4]=r,h[5]=l,h[6]=n,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,s=e.elements,r=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],h=n[4],d=n[7],u=n[2],p=n[5],_=n[8],M=s[0],m=s[3],f=s[6],A=s[1],w=s[4],S=s[7],y=s[2],b=s[5],R=s[8];return r[0]=a*M+o*A+l*y,r[3]=a*m+o*w+l*b,r[6]=a*f+o*S+l*R,r[1]=c*M+h*A+d*y,r[4]=c*m+h*w+d*b,r[7]=c*f+h*S+d*R,r[2]=u*M+p*A+_*y,r[5]=u*m+p*w+_*b,r[8]=u*f+p*S+_*R,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8];return e*a*h-e*o*c-n*r*h+n*o*l+s*r*c-s*a*l}invert(){const t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8],d=h*a-o*c,u=o*l-h*r,p=c*r-a*l,_=e*d+n*u+s*p;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);const M=1/_;return t[0]=d*M,t[1]=(s*c-h*n)*M,t[2]=(o*n-s*a)*M,t[3]=u*M,t[4]=(h*e-s*l)*M,t[5]=(s*r-o*e)*M,t[6]=p*M,t[7]=(n*l-c*e)*M,t[8]=(a*e-n*r)*M,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,s,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*a+c*o)+a+t,-s*c,s*l,-s*(-c*a+l*o)+o+e,0,0,1),this}scale(t,e){return Wi("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(da.makeScale(t,e)),this}rotate(t){return Wi("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(da.makeRotation(-t)),this}translate(t,e){return Wi("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(da.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let s=0;s<9;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const da=new Ot,nc=new Ot().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ic=new Ot().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function D0(){const i={enabled:!0,workingColorSpace:Nr,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===Qt&&(s.r=Rn(s.r),s.g=Rn(s.g),s.b=Rn(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===Qt&&(s.r=Xi(s.r),s.g=Xi(s.g),s.b=Xi(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===Wn?Fr: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 Wi("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Wi("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(s,r)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Nr]:{primaries:t,whitePoint:n,transfer:Fr,toXYZ:nc,fromXYZ:ic,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Ze},outputColorSpaceConfig:{drawingBufferColorSpace:Ze}},[Ze]:{primaries:t,whitePoint:n,transfer:Qt,toXYZ:nc,fromXYZ:ic,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Ze}}}),i}const qt=D0();function Rn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function Xi(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let _i;class L0{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{_i===void 0&&(_i=Br("canvas")),_i.width=t.width,_i.height=t.height;const s=_i.getContext("2d");t instanceof ImageData?s.putImageData(t,0,0):s.drawImage(t,0,0,t.width,t.height),n=_i}return n.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=Br("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const s=n.getImageData(0,0,t.width,t.height),r=s.data;for(let a=0;a<r.length;a++)r[a]=Rn(r[a]/255)*255;return n.putImageData(s,0,0),e}else if(t.data){const e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(Rn(e[n]/255)*255):e[n]=Rn(e[n]);return{data:e,width:t.width,height:t.height}}else return Ft("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let U0=0;class El{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:U0++}),this.uuid=Yn(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):typeof VideoFrame<"u"&&e instanceof VideoFrame?t.set(e.displayWidth,e.displayHeight,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const n={uuid:this.uuid,url:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let a=0,o=s.length;a<o;a++)s[a].isDataTexture?r.push(fa(s[a].image)):r.push(fa(s[a]))}else r=fa(s);n.url=r}return e||(t.images[this.uuid]=n),n}}function fa(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?L0.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(Ft("Texture: Unable to serialize Texture."),{})}let N0=0;const pa=new F;class De extends fi{constructor(t=De.DEFAULT_IMAGE,e=De.DEFAULT_MAPPING,n=Tn,s=Tn,r=Ie,a=ri,o=sn,l=$e,c=De.DEFAULT_ANISOTROPY,h=Wn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:N0++}),this.uuid=Yn(),this.name="",this.source=new El(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new kt(0,0),this.repeat=new kt(1,1),this.center=new kt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ot,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(pa).x}get height(){return this.source.getSize(pa).y}get depth(){return this.source.getSize(pa).z}get image(){return this.source.data}set image(t){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.normalized=t.normalized,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const n=t[e];if(n===void 0){Ft(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const s=this[e];if(s===void 0){Ft(`Texture.setValues(): property '${e}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==eu)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case lo:t.x=t.x-Math.floor(t.x);break;case Tn:t.x=t.x<0?0:1;break;case co:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case lo:t.y=t.y-Math.floor(t.y);break;case Tn:t.y=t.y<0?0:1;break;case co:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}De.DEFAULT_IMAGE=null;De.DEFAULT_MAPPING=eu;De.DEFAULT_ANISOTROPY=1;class fe{static{fe.prototype.isVector4=!0}constructor(t=0,e=0,n=0,s=1){this.x=t,this.y=e,this.z=n,this.w=s}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,s){return this.x=t,this.y=e,this.z=n,this.w=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("THREE.Vector4: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,s=this.z,r=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*s+a[12]*r,this.y=a[1]*e+a[5]*n+a[9]*s+a[13]*r,this.z=a[2]*e+a[6]*n+a[10]*s+a[14]*r,this.w=a[3]*e+a[7]*n+a[11]*s+a[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,s,r;const l=t.elements,c=l[0],h=l[4],d=l[8],u=l[1],p=l[5],_=l[9],M=l[2],m=l[6],f=l[10];if(Math.abs(h-u)<.01&&Math.abs(d-M)<.01&&Math.abs(_-m)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+M)<.1&&Math.abs(_+m)<.1&&Math.abs(c+p+f-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const w=(c+1)/2,S=(p+1)/2,y=(f+1)/2,b=(h+u)/4,R=(d+M)/4,v=(_+m)/4;return w>S&&w>y?w<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(w),s=b/n,r=R/n):S>y?S<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(S),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,e),this}let A=Math.sqrt((m-_)*(m-_)+(d-M)*(d-M)+(u-h)*(u-h));return Math.abs(A)<.001&&(A=1),this.x=(m-_)/A,this.y=(d-M)/A,this.z=(u-h)/A,this.w=Math.acos((c+p+f-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Yt(this.x,t.x,e.x),this.y=Yt(this.y,t.y,e.y),this.z=Yt(this.z,t.z,e.z),this.w=Yt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Yt(this.x,t,e),this.y=Yt(this.y,t,e),this.z=Yt(this.z,t,e),this.w=Yt(this.w,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Yt(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class F0 extends fi{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ie,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=n.depth,this.scissor=new fe(0,0,t,e),this.scissorTest=!1,this.viewport=new fe(0,0,t,e),this.textures=[];const s={width:t,height:e,depth:n.depth},r=new De(s),a=n.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(t={}){const e={minFilter:Ie,generateMipmaps:!1,flipY:!1,internalFormat:null};t.mapping!==void 0&&(e.mapping=t.mapping),t.wrapS!==void 0&&(e.wrapS=t.wrapS),t.wrapT!==void 0&&(e.wrapT=t.wrapT),t.wrapR!==void 0&&(e.wrapR=t.wrapR),t.magFilter!==void 0&&(e.magFilter=t.magFilter),t.minFilter!==void 0&&(e.minFilter=t.minFilter),t.format!==void 0&&(e.format=t.format),t.type!==void 0&&(e.type=t.type),t.anisotropy!==void 0&&(e.anisotropy=t.anisotropy),t.colorSpace!==void 0&&(e.colorSpace=t.colorSpace),t.flipY!==void 0&&(e.flipY=t.flipY),t.generateMipmaps!==void 0&&(e.generateMipmaps=t.generateMipmaps),t.internalFormat!==void 0&&(e.internalFormat=t.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(e)}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),t!==null&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=t,this.textures[s].image.height=e,this.textures[s].image.depth=n,this.textures[s].isData3DTexture!==!0&&(this.textures[s].isArrayTexture=this.textures[s].image.depth>1);this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,n=t.textures.length;e<n;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;const s=Object.assign({},t.textures[e].image);this.textures[e].source=new El(s)}return this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this.multiview=t.multiview,this.useArrayDepthTexture=t.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class mn extends F0{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class hu extends De{constructor(t=null,e=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=Ae,this.minFilter=Ae,this.wrapR=Tn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class O0 extends De{constructor(t=null,e=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=Ae,this.minFilter=Ae,this.wrapR=Tn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class le{static{le.prototype.isMatrix4=!0}constructor(t,e,n,s,r,a,o,l,c,h,d,u,p,_,M,m){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,a,o,l,c,h,d,u,p,_,M,m)}set(t,e,n,s,r,a,o,l,c,h,d,u,p,_,M,m){const f=this.elements;return f[0]=t,f[4]=e,f[8]=n,f[12]=s,f[1]=r,f[5]=a,f[9]=o,f[13]=l,f[2]=c,f[6]=h,f[10]=d,f[14]=u,f[3]=p,f[7]=_,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 le().fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return this.determinantAffine()===0?(t.set(1,0,0),e.set(0,1,0),n.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){if(t.determinantAffine()===0)return this.identity();const e=this.elements,n=t.elements,s=1/vi.setFromMatrixColumn(t,0).length(),r=1/vi.setFromMatrixColumn(t,1).length(),a=1/vi.setFromMatrixColumn(t,2).length();return e[0]=n[0]*s,e[1]=n[1]*s,e[2]=n[2]*s,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,s=t.y,r=t.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(s),c=Math.sin(s),h=Math.cos(r),d=Math.sin(r);if(t.order==="XYZ"){const u=a*h,p=a*d,_=o*h,M=o*d;e[0]=l*h,e[4]=-l*d,e[8]=c,e[1]=p+_*c,e[5]=u-M*c,e[9]=-o*l,e[2]=M-u*c,e[6]=_+p*c,e[10]=a*l}else if(t.order==="YXZ"){const u=l*h,p=l*d,_=c*h,M=c*d;e[0]=u+M*o,e[4]=_*o-p,e[8]=a*c,e[1]=a*d,e[5]=a*h,e[9]=-o,e[2]=p*o-_,e[6]=M+u*o,e[10]=a*l}else if(t.order==="ZXY"){const u=l*h,p=l*d,_=c*h,M=c*d;e[0]=u-M*o,e[4]=-a*d,e[8]=_+p*o,e[1]=p+_*o,e[5]=a*h,e[9]=M-u*o,e[2]=-a*c,e[6]=o,e[10]=a*l}else if(t.order==="ZYX"){const u=a*h,p=a*d,_=o*h,M=o*d;e[0]=l*h,e[4]=_*c-p,e[8]=u*c+M,e[1]=l*d,e[5]=M*c+u,e[9]=p*c-_,e[2]=-c,e[6]=o*l,e[10]=a*l}else if(t.order==="YZX"){const u=a*l,p=a*c,_=o*l,M=o*c;e[0]=l*h,e[4]=M-u*d,e[8]=_*d+p,e[1]=d,e[5]=a*h,e[9]=-o*h,e[2]=-c*h,e[6]=p*d+_,e[10]=u-M*d}else if(t.order==="XZY"){const u=a*l,p=a*c,_=o*l,M=o*c;e[0]=l*h,e[4]=-d,e[8]=c*h,e[1]=u*d+M,e[5]=a*h,e[9]=p*d-_,e[2]=_*d-p,e[6]=o*h,e[10]=M*d+u}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(B0,t,z0)}lookAt(t,e,n){const s=this.elements;return ke.subVectors(t,e),ke.lengthSq()===0&&(ke.z=1),ke.normalize(),Nn.crossVectors(n,ke),Nn.lengthSq()===0&&(Math.abs(n.z)===1?ke.x+=1e-4:ke.z+=1e-4,ke.normalize(),Nn.crossVectors(n,ke)),Nn.normalize(),Fs.crossVectors(ke,Nn),s[0]=Nn.x,s[4]=Fs.x,s[8]=ke.x,s[1]=Nn.y,s[5]=Fs.y,s[9]=ke.y,s[2]=Nn.z,s[6]=Fs.z,s[10]=ke.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,s=e.elements,r=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],h=n[1],d=n[5],u=n[9],p=n[13],_=n[2],M=n[6],m=n[10],f=n[14],A=n[3],w=n[7],S=n[11],y=n[15],b=s[0],R=s[4],v=s[8],T=s[12],I=s[1],C=s[5],U=s[9],Y=s[13],Z=s[2],O=s[6],W=s[10],V=s[14],Q=s[3],et=s[7],tt=s[11],st=s[15];return r[0]=a*b+o*I+l*Z+c*Q,r[4]=a*R+o*C+l*O+c*et,r[8]=a*v+o*U+l*W+c*tt,r[12]=a*T+o*Y+l*V+c*st,r[1]=h*b+d*I+u*Z+p*Q,r[5]=h*R+d*C+u*O+p*et,r[9]=h*v+d*U+u*W+p*tt,r[13]=h*T+d*Y+u*V+p*st,r[2]=_*b+M*I+m*Z+f*Q,r[6]=_*R+M*C+m*O+f*et,r[10]=_*v+M*U+m*W+f*tt,r[14]=_*T+M*Y+m*V+f*st,r[3]=A*b+w*I+S*Z+y*Q,r[7]=A*R+w*C+S*O+y*et,r[11]=A*v+w*U+S*W+y*tt,r[15]=A*T+w*Y+S*V+y*st,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],s=t[8],r=t[12],a=t[1],o=t[5],l=t[9],c=t[13],h=t[2],d=t[6],u=t[10],p=t[14],_=t[3],M=t[7],m=t[11],f=t[15],A=l*p-c*u,w=o*p-c*d,S=o*u-l*d,y=a*p-c*h,b=a*u-l*h,R=a*d-o*h;return e*(M*A-m*w+f*S)-n*(_*A-m*y+f*b)+s*(_*w-M*y+f*R)-r*(_*S-M*b+m*R)}determinantAffine(){const t=this.elements,e=t[0],n=t[4],s=t[8],r=t[1],a=t[5],o=t[9],l=t[2],c=t[6],h=t[10];return e*(a*h-o*c)-n*(r*h-o*l)+s*(r*c-a*l)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8],d=t[9],u=t[10],p=t[11],_=t[12],M=t[13],m=t[14],f=t[15],A=e*o-n*a,w=e*l-s*a,S=e*c-r*a,y=n*l-s*o,b=n*c-r*o,R=s*c-r*l,v=h*M-d*_,T=h*m-u*_,I=h*f-p*_,C=d*m-u*M,U=d*f-p*M,Y=u*f-p*m,Z=A*Y-w*U+S*C+y*I-b*T+R*v;if(Z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const O=1/Z;return t[0]=(o*Y-l*U+c*C)*O,t[1]=(s*U-n*Y-r*C)*O,t[2]=(M*R-m*b+f*y)*O,t[3]=(u*b-d*R-p*y)*O,t[4]=(l*I-a*Y-c*T)*O,t[5]=(e*Y-s*I+r*T)*O,t[6]=(m*S-_*R-f*w)*O,t[7]=(h*R-u*S+p*w)*O,t[8]=(a*U-o*I+c*v)*O,t[9]=(n*I-e*U-r*v)*O,t[10]=(_*b-M*S+f*A)*O,t[11]=(d*S-h*b-p*A)*O,t[12]=(o*T-a*C-l*v)*O,t[13]=(e*C-n*T+s*v)*O,t[14]=(M*w-_*y-m*A)*O,t[15]=(h*y-d*w+u*A)*O,this}scale(t){const e=this.elements,n=t.x,s=t.y,r=t.z;return e[0]*=n,e[4]*=s,e[8]*=r,e[1]*=n,e[5]*=s,e[9]*=r,e[2]*=n,e[6]*=s,e[10]*=r,e[3]*=n,e[7]*=s,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,s))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),s=Math.sin(e),r=1-n,a=t.x,o=t.y,l=t.z,c=r*a,h=r*o;return this.set(c*a+n,c*o-s*l,c*l+s*o,0,c*o+s*l,h*o+n,h*l-s*a,0,c*l-s*o,h*l+s*a,r*l*l+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,s,r,a){return this.set(1,n,r,0,t,1,a,0,e,s,1,0,0,0,0,1),this}compose(t,e,n){const s=this.elements,r=e._x,a=e._y,o=e._z,l=e._w,c=r+r,h=a+a,d=o+o,u=r*c,p=r*h,_=r*d,M=a*h,m=a*d,f=o*d,A=l*c,w=l*h,S=l*d,y=n.x,b=n.y,R=n.z;return s[0]=(1-(M+f))*y,s[1]=(p+S)*y,s[2]=(_-w)*y,s[3]=0,s[4]=(p-S)*b,s[5]=(1-(u+f))*b,s[6]=(m+A)*b,s[7]=0,s[8]=(_+w)*R,s[9]=(m-A)*R,s[10]=(1-(u+M))*R,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,n){const s=this.elements;t.x=s[12],t.y=s[13],t.z=s[14];const r=this.determinantAffine();if(r===0)return n.set(1,1,1),e.identity(),this;let a=vi.set(s[0],s[1],s[2]).length();const o=vi.set(s[4],s[5],s[6]).length(),l=vi.set(s[8],s[9],s[10]).length();r<0&&(a=-a),tn.copy(this);const c=1/a,h=1/o,d=1/l;return tn.elements[0]*=c,tn.elements[1]*=c,tn.elements[2]*=c,tn.elements[4]*=h,tn.elements[5]*=h,tn.elements[6]*=h,tn.elements[8]*=d,tn.elements[9]*=d,tn.elements[10]*=d,e.setFromRotationMatrix(tn),n.x=a,n.y=o,n.z=l,this}makePerspective(t,e,n,s,r,a,o=fn,l=!1){const c=this.elements,h=2*r/(e-t),d=2*r/(n-s),u=(e+t)/(e-t),p=(n+s)/(n-s);let _,M;if(l)_=r/(a-r),M=a*r/(a-r);else if(o===fn)_=-(a+r)/(a-r),M=-2*a*r/(a-r);else if(o===Or)_=-a/(a-r),M=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=u,c[12]=0,c[1]=0,c[5]=d,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=_,c[14]=M,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,n,s,r,a,o=fn,l=!1){const c=this.elements,h=2/(e-t),d=2/(n-s),u=-(e+t)/(e-t),p=-(n+s)/(n-s);let _,M;if(l)_=1/(a-r),M=a/(a-r);else if(o===fn)_=-2/(a-r),M=-(a+r)/(a-r);else if(o===Or)_=-1/(a-r),M=-r/(a-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=0,c[12]=u,c[1]=0,c[5]=d,c[9]=0,c[13]=p,c[2]=0,c[6]=0,c[10]=_,c[14]=M,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let s=0;s<16;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const vi=new F,tn=new le,B0=new F(0,0,0),z0=new F(1,1,1),Nn=new F,Fs=new F,ke=new F,sc=new le,rc=new es;class ui{constructor(t=0,e=0,n=0,s=ui.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,s=this._order){return this._x=t,this._y=e,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const s=t.elements,r=s[0],a=s[4],o=s[8],l=s[1],c=s[5],h=s[9],d=s[2],u=s[6],p=s[10];switch(e){case"XYZ":this._y=Math.asin(Yt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(u,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Yt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-d,r),this._z=0);break;case"ZXY":this._x=Math.asin(Yt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-d,p),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-Yt(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(u,p),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(Yt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-d,r)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-Yt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,p),this._y=0);break;default:Ft("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return sc.makeRotationFromQuaternion(t),this.setFromRotationMatrix(sc,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return rc.setFromEuler(this),this.setFromQuaternion(rc,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}ui.DEFAULT_ORDER="XYZ";class bl{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let k0=0;const ac=new F,xi=new es,_n=new le,Os=new F,rs=new F,H0=new F,G0=new es,oc=new F(1,0,0),lc=new F(0,1,0),cc=new F(0,0,1),hc={type:"added"},V0={type:"removed"},Si={type:"childadded",child:null},ma={type:"childremoved",child:null};class Oe extends fi{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:k0++}),this.uuid=Yn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Oe.DEFAULT_UP.clone();const t=new F,e=new ui,n=new es,s=new F(1,1,1);function r(){n.setFromEuler(e,!1)}function a(){e.setFromQuaternion(n,void 0,!1)}e._onChange(r),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new le},normalMatrix:{value:new Ot}}),this.matrix=new le,this.matrixWorld=new le,this.matrixAutoUpdate=Oe.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Oe.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new bl,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return xi.setFromAxisAngle(t,e),this.quaternion.multiply(xi),this}rotateOnWorldAxis(t,e){return xi.setFromAxisAngle(t,e),this.quaternion.premultiply(xi),this}rotateX(t){return this.rotateOnAxis(oc,t)}rotateY(t){return this.rotateOnAxis(lc,t)}rotateZ(t){return this.rotateOnAxis(cc,t)}translateOnAxis(t,e){return ac.copy(t).applyQuaternion(this.quaternion),this.position.add(ac.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(oc,t)}translateY(t){return this.translateOnAxis(lc,t)}translateZ(t){return this.translateOnAxis(cc,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(_n.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?Os.copy(t):Os.set(t,e,n);const s=this.parent;this.updateWorldMatrix(!0,!1),rs.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?_n.lookAt(rs,Os,this.up):_n.lookAt(Os,rs,this.up),this.quaternion.setFromRotationMatrix(_n),s&&(_n.extractRotation(s.matrixWorld),xi.setFromRotationMatrix(_n),this.quaternion.premultiply(xi.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(Xt("Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(hc),Si.child=t,this.dispatchEvent(Si),Si.child=null):Xt("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(V0),ma.child=t,this.dispatchEvent(ma),ma.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),_n.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),_n.multiply(t.parent.matrixWorld)),t.applyMatrix4(_n),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(hc),Si.child=t,this.dispatchEvent(Si),Si.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,s=this.children.length;n<s;n++){const a=this.children[n].getObjectByProperty(t,e);if(a!==void 0)return a}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(rs,t,H0),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(rs,G0,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const t=this.pivot;if(t!==null){const e=t.x,n=t.y,s=t.z,r=this.matrix.elements;r[12]+=e-r[0]*e-r[4]*n-r[8]*s,r[13]+=n-r[1]*e-r[5]*n-r[9]*s,r[14]+=s-r[2]*e-r[6]*n-r[10]*s}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e,n=!1){const s=this.parent;if(t===!0&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),e===!0){const r=this.children;for(let a=0,o=r.length;a<o;a++)r[a].updateWorldMatrix(!1,!0,n)}}toJSON(t){const e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),this.static!==!1&&(s.static=this.static),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.pivot!==null&&(s.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(t),s.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(t.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const d=l[c];r(t.shapes,d)}else r(t.shapes,l)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(t.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(r(t.materials,this.material[l]));s.material=o}else s.material=r(t.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];s.animations.push(r(t.animations,l))}}if(e){const o=a(t.geometries),l=a(t.materials),c=a(t.textures),h=a(t.images),d=a(t.shapes),u=a(t.skeletons),p=a(t.animations),_=a(t.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),d.length>0&&(n.shapes=d),u.length>0&&(n.skeletons=u),p.length>0&&(n.animations=p),_.length>0&&(n.nodes=_)}return n.object=s,n;function a(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.pivot=t.pivot!==null?t.pivot.clone():null,this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){const s=t.children[n];this.add(s.clone())}return this}}Oe.DEFAULT_UP=new F(0,1,0);Oe.DEFAULT_MATRIX_AUTO_UPDATE=!0;Oe.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Bs extends Oe{constructor(){super(),this.isGroup=!0,this.type="Group"}}const W0={type:"move"};class ga{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Bs,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 Bs,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new F,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new F),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Bs,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new F,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new F,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let s=null,r=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(c&&t.hand){a=!0;for(const M of t.hand.values()){const m=e.getJointPose(M,n),f=this._getHandJoint(c,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=c.joints["index-finger-tip"],d=c.joints["thumb-tip"],u=h.position.distanceTo(d.position),p=.02,_=.005;c.inputState.pinching&&u>p+_?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&u<=p-_&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:t,target:this})));o!==null&&(s=e.getPose(t.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(W0)))}return o!==null&&(o.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){const n=new Bs;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}const uu={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},Fn={h:0,s:0,l:0},zs={h:0,s:0,l:0};function _a(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+(t-i)*6*e:e<1/2?t:e<2/3?i+(t-i)*6*(2/3-e):i}class It{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){const s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Ze){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,qt.colorSpaceToWorking(this,e),this}setRGB(t,e,n,s=qt.workingColorSpace){return this.r=t,this.g=e,this.b=n,qt.colorSpaceToWorking(this,s),this}setHSL(t,e,n,s=qt.workingColorSpace){if(t=I0(t,1),e=Yt(e,0,1),n=Yt(n,0,1),e===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+e):n+e-n*e,a=2*n-r;this.r=_a(a,r,t+1/3),this.g=_a(a,r,t),this.b=_a(a,r,t-1/3)}return qt.colorSpaceToWorking(this,s),this}setStyle(t,e=Ze){function n(r){r!==void 0&&parseFloat(r)<1&&Ft("Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:Ft("Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){const r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(r,16),e);Ft("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Ze){const n=uu[t.toLowerCase()];return n!==void 0?this.setHex(n,e):Ft("Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Rn(t.r),this.g=Rn(t.g),this.b=Rn(t.b),this}copyLinearToSRGB(t){return this.r=Xi(t.r),this.g=Xi(t.g),this.b=Xi(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Ze){return qt.workingToColorSpace(Ce.copy(this),t),Math.round(Yt(Ce.r*255,0,255))*65536+Math.round(Yt(Ce.g*255,0,255))*256+Math.round(Yt(Ce.b*255,0,255))}getHexString(t=Ze){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=qt.workingColorSpace){qt.workingToColorSpace(Ce.copy(this),e);const n=Ce.r,s=Ce.g,r=Ce.b,a=Math.max(n,s,r),o=Math.min(n,s,r);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const d=a-o;switch(c=h<=.5?d/(a+o):d/(2-a-o),a){case n:l=(s-r)/d+(s<r?6:0);break;case s:l=(r-n)/d+2;break;case r:l=(n-s)/d+4;break}l/=6}return t.h=l,t.s=c,t.l=h,t}getRGB(t,e=qt.workingColorSpace){return qt.workingToColorSpace(Ce.copy(this),e),t.r=Ce.r,t.g=Ce.g,t.b=Ce.b,t}getStyle(t=Ze){qt.workingToColorSpace(Ce.copy(this),t);const e=Ce.r,n=Ce.g,s=Ce.b;return t!==Ze?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(t,e,n){return this.getHSL(Fn),this.setHSL(Fn.h+t,Fn.s+e,Fn.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(Fn),t.getHSL(zs);const n=ha(Fn.h,zs.h,e),s=ha(Fn.s,zs.s,e),r=ha(Fn.l,zs.l,e);return this.setHSL(n,s,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,s=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*s,this.g=r[1]*e+r[4]*n+r[7]*s,this.b=r[2]*e+r[5]*n+r[8]*s,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Ce=new It;It.NAMES=uu;class Tl{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new It(t),this.near=e,this.far=n}clone(){return new Tl(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class X0 extends Oe{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 ui,this.environmentIntensity=1,this.environmentRotation=new ui,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}const en=new F,vn=new F,va=new F,xn=new F,Mi=new F,yi=new F,uc=new F,xa=new F,Sa=new F,Ma=new F,ya=new fe,Ea=new fe,ba=new fe;class Je{constructor(t=new F,e=new F,n=new F){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,s){s.subVectors(n,e),en.subVectors(t,e),s.cross(en);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(t,e,n,s,r){en.subVectors(s,e),vn.subVectors(n,e),va.subVectors(t,e);const a=en.dot(en),o=en.dot(vn),l=en.dot(va),c=vn.dot(vn),h=vn.dot(va),d=a*c-o*o;if(d===0)return r.set(0,0,0),null;const u=1/d,p=(c*l-o*h)*u,_=(a*h-o*l)*u;return r.set(1-p-_,_,p)}static containsPoint(t,e,n,s){return this.getBarycoord(t,e,n,s,xn)===null?!1:xn.x>=0&&xn.y>=0&&xn.x+xn.y<=1}static getInterpolation(t,e,n,s,r,a,o,l){return this.getBarycoord(t,e,n,s,xn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,xn.x),l.addScaledVector(a,xn.y),l.addScaledVector(o,xn.z),l)}static getInterpolatedAttribute(t,e,n,s,r,a){return ya.setScalar(0),Ea.setScalar(0),ba.setScalar(0),ya.fromBufferAttribute(t,e),Ea.fromBufferAttribute(t,n),ba.fromBufferAttribute(t,s),a.setScalar(0),a.addScaledVector(ya,r.x),a.addScaledVector(Ea,r.y),a.addScaledVector(ba,r.z),a}static isFrontFacing(t,e,n,s){return en.subVectors(n,e),vn.subVectors(t,e),en.cross(vn).dot(s)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,s){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,n,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,s),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return en.subVectors(this.c,this.b),vn.subVectors(this.a,this.b),en.cross(vn).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Je.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Je.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,s,r){return Je.getInterpolation(t,this.a,this.b,this.c,e,n,s,r)}containsPoint(t){return Je.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Je.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,s=this.b,r=this.c;let a,o;Mi.subVectors(s,n),yi.subVectors(r,n),xa.subVectors(t,n);const l=Mi.dot(xa),c=yi.dot(xa);if(l<=0&&c<=0)return e.copy(n);Sa.subVectors(t,s);const h=Mi.dot(Sa),d=yi.dot(Sa);if(h>=0&&d<=h)return e.copy(s);const u=l*d-h*c;if(u<=0&&l>=0&&h<=0)return a=l/(l-h),e.copy(n).addScaledVector(Mi,a);Ma.subVectors(t,r);const p=Mi.dot(Ma),_=yi.dot(Ma);if(_>=0&&p<=_)return e.copy(r);const M=p*c-l*_;if(M<=0&&c>=0&&_<=0)return o=c/(c-_),e.copy(n).addScaledVector(yi,o);const m=h*_-p*d;if(m<=0&&d-h>=0&&p-_>=0)return uc.subVectors(r,s),o=(d-h)/(d-h+(p-_)),e.copy(s).addScaledVector(uc,o);const f=1/(m+M+u);return a=M*f,o=u*f,e.copy(n).addScaledVector(Mi,a).addScaledVector(yi,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}class Rs{constructor(t=new F(1/0,1/0,1/0),e=new F(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(nn.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(nn.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=nn.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(n!==void 0){const r=n.getAttribute("position");if(e===!0&&r!==void 0&&t.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)t.isMesh===!0?t.getVertexPosition(a,nn):nn.fromBufferAttribute(r,a),nn.applyMatrix4(t.matrixWorld),this.expandByPoint(nn);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),ks.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),ks.copy(n.boundingBox)),ks.applyMatrix4(t.matrixWorld),this.union(ks)}const s=t.children;for(let r=0,a=s.length;r<a;r++)this.expandByObject(s[r],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,nn),nn.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(as),Hs.subVectors(this.max,as),Ei.subVectors(t.a,as),bi.subVectors(t.b,as),Ti.subVectors(t.c,as),On.subVectors(bi,Ei),Bn.subVectors(Ti,bi),Jn.subVectors(Ei,Ti);let e=[0,-On.z,On.y,0,-Bn.z,Bn.y,0,-Jn.z,Jn.y,On.z,0,-On.x,Bn.z,0,-Bn.x,Jn.z,0,-Jn.x,-On.y,On.x,0,-Bn.y,Bn.x,0,-Jn.y,Jn.x,0];return!Ta(e,Ei,bi,Ti,Hs)||(e=[1,0,0,0,1,0,0,0,1],!Ta(e,Ei,bi,Ti,Hs))?!1:(Gs.crossVectors(On,Bn),e=[Gs.x,Gs.y,Gs.z],Ta(e,Ei,bi,Ti,Hs))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,nn).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(nn).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Sn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Sn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Sn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Sn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Sn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Sn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Sn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Sn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Sn),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}const Sn=[new F,new F,new F,new F,new F,new F,new F,new F],nn=new F,ks=new Rs,Ei=new F,bi=new F,Ti=new F,On=new F,Bn=new F,Jn=new F,as=new F,Hs=new F,Gs=new F,Qn=new F;function Ta(i,t,e,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){Qn.fromArray(i,r);const o=s.x*Math.abs(Qn.x)+s.y*Math.abs(Qn.y)+s.z*Math.abs(Qn.z),l=t.dot(Qn),c=e.dot(Qn),h=n.dot(Qn);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const xe=new F,Vs=new kt;let q0=0;class pe extends fi{constructor(t,e,n=!1){if(super(),Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:q0++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=Ho,this.updateRanges=[],this.gpuType=dn,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[t+s]=e.array[n+s];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)Vs.fromBufferAttribute(this,e),Vs.applyMatrix3(t),this.setXY(e,Vs.x,Vs.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)xe.fromBufferAttribute(this,e),xe.applyMatrix3(t),this.setXYZ(e,xe.x,xe.y,xe.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)xe.fromBufferAttribute(this,e),xe.applyMatrix4(t),this.setXYZ(e,xe.x,xe.y,xe.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)xe.fromBufferAttribute(this,e),xe.applyNormalMatrix(t),this.setXYZ(e,xe.x,xe.y,xe.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)xe.fromBufferAttribute(this,e),xe.transformDirection(t),this.setXYZ(e,xe.x,xe.y,xe.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=un(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=te(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=un(e,this.array)),e}setX(t,e){return this.normalized&&(e=te(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=un(e,this.array)),e}setY(t,e){return this.normalized&&(e=te(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=un(e,this.array)),e}setZ(t,e){return this.normalized&&(e=te(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=un(e,this.array)),e}setW(t,e){return this.normalized&&(e=te(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=te(e,this.array),n=te(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,s){return t*=this.itemSize,this.normalized&&(e=te(e,this.array),n=te(n,this.array),s=te(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=s,this}setXYZW(t,e,n,s,r){return t*=this.itemSize,this.normalized&&(e=te(e,this.array),n=te(n,this.array),s=te(s,this.array),r=te(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=s,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==Ho&&(t.usage=this.usage),t}dispose(){this.dispatchEvent({type:"dispose"})}}class du extends pe{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class fu extends pe{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class Le extends pe{constructor(t,e,n){super(new Float32Array(t),e,n)}}const Y0=new Rs,os=new F,Aa=new F;class Qr{constructor(t=new F,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;e!==void 0?n.copy(e):Y0.setFromPoints(t).getCenter(n);let s=0;for(let r=0,a=t.length;r<a;r++)s=Math.max(s,n.distanceToSquared(t[r]));return this.radius=Math.sqrt(s),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;os.subVectors(t,this.center);const e=os.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),s=(n-this.radius)*.5;this.center.addScaledVector(os,s/n),this.radius+=s}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(Aa.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(os.copy(t.center).add(Aa)),this.expandByPoint(os.copy(t.center).sub(Aa))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}let Z0=0;const Xe=new le,wa=new Oe,Ai=new F,He=new Rs,ls=new Rs,ye=new F;class Te extends fi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Z0++}),this.uuid=Yn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(w0(t)?fu:du)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new Ot().getNormalMatrix(t);n.applyNormalMatrix(r),n.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(t),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(t){return Xe.makeRotationFromQuaternion(t),this.applyMatrix4(Xe),this}rotateX(t){return Xe.makeRotationX(t),this.applyMatrix4(Xe),this}rotateY(t){return Xe.makeRotationY(t),this.applyMatrix4(Xe),this}rotateZ(t){return Xe.makeRotationZ(t),this.applyMatrix4(Xe),this}translate(t,e,n){return Xe.makeTranslation(t,e,n),this.applyMatrix4(Xe),this}scale(t,e,n){return Xe.makeScale(t,e,n),this.applyMatrix4(Xe),this}lookAt(t){return wa.lookAt(t),wa.updateMatrix(),this.applyMatrix4(wa.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ai).negate(),this.translate(Ai.x,Ai.y,Ai.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const n=[];for(let s=0,r=t.length;s<r;s++){const a=t[s];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Le(n,3))}else{const n=Math.min(t.length,e.count);for(let s=0;s<n;s++){const r=t[s];e.setXYZ(s,r.x,r.y,r.z||0)}t.length>e.count&&Ft("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Rs);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Xt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new F(-1/0,-1/0,-1/0),new F(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,s=e.length;n<s;n++){const r=e[n];He.setFromBufferAttribute(r),this.morphTargetsRelative?(ye.addVectors(this.boundingBox.min,He.min),this.boundingBox.expandByPoint(ye),ye.addVectors(this.boundingBox.max,He.max),this.boundingBox.expandByPoint(ye)):(this.boundingBox.expandByPoint(He.min),this.boundingBox.expandByPoint(He.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Xt('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 Qr);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Xt("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new F,1/0);return}if(t){const n=this.boundingSphere.center;if(He.setFromBufferAttribute(t),e)for(let r=0,a=e.length;r<a;r++){const o=e[r];ls.setFromBufferAttribute(o),this.morphTargetsRelative?(ye.addVectors(He.min,ls.min),He.expandByPoint(ye),ye.addVectors(He.max,ls.max),He.expandByPoint(ye)):(He.expandByPoint(ls.min),He.expandByPoint(ls.max))}He.getCenter(n);let s=0;for(let r=0,a=t.count;r<a;r++)ye.fromBufferAttribute(t,r),s=Math.max(s,n.distanceToSquared(ye));if(e)for(let r=0,a=e.length;r<a;r++){const o=e[r],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)ye.fromBufferAttribute(o,c),l&&(Ai.fromBufferAttribute(t,c),ye.add(Ai)),s=Math.max(s,n.distanceToSquared(ye))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&Xt('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){Xt("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.position,s=e.normal,r=e.uv;let a=this.getAttribute("tangent");(a===void 0||a.count!==n.count)&&(a=new pe(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));const o=[],l=[];for(let v=0;v<n.count;v++)o[v]=new F,l[v]=new F;const c=new F,h=new F,d=new F,u=new kt,p=new kt,_=new kt,M=new F,m=new F;function f(v,T,I){c.fromBufferAttribute(n,v),h.fromBufferAttribute(n,T),d.fromBufferAttribute(n,I),u.fromBufferAttribute(r,v),p.fromBufferAttribute(r,T),_.fromBufferAttribute(r,I),h.sub(c),d.sub(c),p.sub(u),_.sub(u);const C=1/(p.x*_.y-_.x*p.y);isFinite(C)&&(M.copy(h).multiplyScalar(_.y).addScaledVector(d,-p.y).multiplyScalar(C),m.copy(d).multiplyScalar(p.x).addScaledVector(h,-_.x).multiplyScalar(C),o[v].add(M),o[T].add(M),o[I].add(M),l[v].add(m),l[T].add(m),l[I].add(m))}let A=this.groups;A.length===0&&(A=[{start:0,count:t.count}]);for(let v=0,T=A.length;v<T;++v){const I=A[v],C=I.start,U=I.count;for(let Y=C,Z=C+U;Y<Z;Y+=3)f(t.getX(Y+0),t.getX(Y+1),t.getX(Y+2))}const w=new F,S=new F,y=new F,b=new F;function R(v){y.fromBufferAttribute(s,v),b.copy(y);const T=o[v];w.copy(T),w.sub(y.multiplyScalar(y.dot(T))).normalize(),S.crossVectors(b,T);const C=S.dot(l[v])<0?-1:1;a.setXYZW(v,w.x,w.y,w.z,C)}for(let v=0,T=A.length;v<T;++v){const I=A[v],C=I.start,U=I.count;for(let Y=C,Z=C+U;Y<Z;Y+=3)R(t.getX(Y+0)),R(t.getX(Y+1)),R(t.getX(Y+2))}this._transformed=!0}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==e.count)n=new pe(new Float32Array(e.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 F,r=new F,a=new F,o=new F,l=new F,c=new F,h=new F,d=new F;if(t)for(let u=0,p=t.count;u<p;u+=3){const _=t.getX(u+0),M=t.getX(u+1),m=t.getX(u+2);s.fromBufferAttribute(e,_),r.fromBufferAttribute(e,M),a.fromBufferAttribute(e,m),h.subVectors(a,r),d.subVectors(s,r),h.cross(d),o.fromBufferAttribute(n,_),l.fromBufferAttribute(n,M),c.fromBufferAttribute(n,m),o.add(h),l.add(h),c.add(h),n.setXYZ(_,o.x,o.y,o.z),n.setXYZ(M,l.x,l.y,l.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let u=0,p=e.count;u<p;u+=3)s.fromBufferAttribute(e,u+0),r.fromBufferAttribute(e,u+1),a.fromBufferAttribute(e,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 t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)ye.fromBufferAttribute(t,e),ye.normalize(),t.setXYZ(e,ye.x,ye.y,ye.z)}toNonIndexed(){function t(o,l){const c=o.array,h=o.itemSize,d=o.normalized,u=new c.constructor(l.length*h);let p=0,_=0;for(let M=0,m=l.length;M<m;M++){o.isInterleavedBufferAttribute?p=l[M]*o.data.stride+o.offset:p=l[M]*h;for(let f=0;f<h;f++)u[_++]=c[p++]}return new pe(u,h,d)}if(this.index===null)return Ft("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Te,n=this.index.array,s=this.attributes;for(const o in s){const l=s[o],c=t(l,n);e.setAttribute(o,c)}const r=this.morphAttributes;for(const o in r){const l=[],c=r[o];for(let h=0,d=c.length;h<d;h++){const u=c[h],p=t(u,n);l.push(p)}e.morphAttributes[o]=l}e.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];e.addGroup(c.start,c.count,c.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(t[c]=l[c]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const l in n){const c=n[l];t.data.attributes[l]=c.toJSON(t.data)}const s={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let d=0,u=c.length;d<u;d++){const p=c[d];h.push(p.toJSON(t.data))}h.length>0&&(s[l]=h,r=!0)}r&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere=o.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;n!==null&&this.setIndex(n.clone());const s=t.attributes;for(const c in s){const h=s[c];this.setAttribute(c,h.clone(e))}const r=t.morphAttributes;for(const c in r){const h=[],d=r[c];for(let u=0,p=d.length;u<p;u++)h.push(d[u].clone(e));this.morphAttributes[c]=h}this.morphTargetsRelative=t.morphTargetsRelative;const a=t.groups;for(let c=0,h=a.length;c<h;c++){const d=a[c];this.addGroup(d.start,d.count,d.materialIndex)}const o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this._transformed=t._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class K0{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=Ho,this.updateRanges=[],this.version=0,this.uuid=Yn()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let s=0,r=this.stride;s<r;s++)this.array[t+s]=e.array[n+s];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Yn()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Yn()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Ue=new F;class kr{constructor(t,e,n,s=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=s}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)Ue.fromBufferAttribute(this,e),Ue.applyMatrix4(t),this.setXYZ(e,Ue.x,Ue.y,Ue.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Ue.fromBufferAttribute(this,e),Ue.applyNormalMatrix(t),this.setXYZ(e,Ue.x,Ue.y,Ue.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Ue.fromBufferAttribute(this,e),Ue.transformDirection(t),this.setXYZ(e,Ue.x,Ue.y,Ue.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(n=un(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=te(n,this.array)),this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){return this.normalized&&(e=te(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=te(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=te(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=te(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=un(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=un(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=un(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=un(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=te(e,this.array),n=te(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=te(e,this.array),n=te(n,this.array),s=te(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=s,this}setXYZW(t,e,n,s,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=te(e,this.array),n=te(n,this.array),s=te(s,this.array),r=te(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=s,this.data.array[t+3]=r,this}clone(t){if(t===void 0){zr("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)e.push(this.data.array[s+r])}return new pe(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new kr(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){zr("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)e.push(this.data.array[s+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let $0=0;class ns extends fi{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:$0++}),this.uuid=Yn(),this.name="",this.type="Material",this.blending=Vi,this.side=Kn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=ja,this.blendDst=to,this.blendEquation=ni,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new It(0,0,0),this.blendAlpha=0,this.depthFunc=Ki,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Ql,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=gi,this.stencilZFail=gi,this.stencilZPass=gi,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const n=t[e];if(n===void 0){Ft(`Material: parameter '${e}' has value of undefined.`);continue}const s=this[e];if(s===void 0){Ft(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector2&&n&&n.isVector2||s&&s.isEuler&&n&&n.isEuler||s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Vi&&(n.blending=this.blending),this.side!==Kn&&(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!==ja&&(n.blendSrc=this.blendSrc),this.blendDst!==to&&(n.blendDst=this.blendDst),this.blendEquation!==ni&&(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!==Ki&&(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!==Ql&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==gi&&(n.stencilFail=this.stencilFail),this.stencilZFail!==gi&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==gi&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(e){const r=s(t.textures),a=s(t.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}fromJSON(t,e){if(t.uuid!==void 0&&(this.uuid=t.uuid),t.name!==void 0&&(this.name=t.name),t.color!==void 0&&this.color!==void 0&&this.color.setHex(t.color),t.roughness!==void 0&&(this.roughness=t.roughness),t.metalness!==void 0&&(this.metalness=t.metalness),t.sheen!==void 0&&(this.sheen=t.sheen),t.sheenColor!==void 0&&(this.sheenColor=new It().setHex(t.sheenColor)),t.sheenRoughness!==void 0&&(this.sheenRoughness=t.sheenRoughness),t.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(t.emissive),t.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(t.specular),t.specularIntensity!==void 0&&(this.specularIntensity=t.specularIntensity),t.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(t.specularColor),t.shininess!==void 0&&(this.shininess=t.shininess),t.clearcoat!==void 0&&(this.clearcoat=t.clearcoat),t.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=t.clearcoatRoughness),t.dispersion!==void 0&&(this.dispersion=t.dispersion),t.iridescence!==void 0&&(this.iridescence=t.iridescence),t.iridescenceIOR!==void 0&&(this.iridescenceIOR=t.iridescenceIOR),t.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=t.iridescenceThicknessRange),t.transmission!==void 0&&(this.transmission=t.transmission),t.thickness!==void 0&&(this.thickness=t.thickness),t.attenuationDistance!==void 0&&(this.attenuationDistance=t.attenuationDistance),t.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(t.attenuationColor),t.anisotropy!==void 0&&(this.anisotropy=t.anisotropy),t.anisotropyRotation!==void 0&&(this.anisotropyRotation=t.anisotropyRotation),t.fog!==void 0&&(this.fog=t.fog),t.flatShading!==void 0&&(this.flatShading=t.flatShading),t.blending!==void 0&&(this.blending=t.blending),t.combine!==void 0&&(this.combine=t.combine),t.side!==void 0&&(this.side=t.side),t.shadowSide!==void 0&&(this.shadowSide=t.shadowSide),t.opacity!==void 0&&(this.opacity=t.opacity),t.transparent!==void 0&&(this.transparent=t.transparent),t.alphaTest!==void 0&&(this.alphaTest=t.alphaTest),t.alphaHash!==void 0&&(this.alphaHash=t.alphaHash),t.depthFunc!==void 0&&(this.depthFunc=t.depthFunc),t.depthTest!==void 0&&(this.depthTest=t.depthTest),t.depthWrite!==void 0&&(this.depthWrite=t.depthWrite),t.colorWrite!==void 0&&(this.colorWrite=t.colorWrite),t.blendSrc!==void 0&&(this.blendSrc=t.blendSrc),t.blendDst!==void 0&&(this.blendDst=t.blendDst),t.blendEquation!==void 0&&(this.blendEquation=t.blendEquation),t.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=t.blendSrcAlpha),t.blendDstAlpha!==void 0&&(this.blendDstAlpha=t.blendDstAlpha),t.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=t.blendEquationAlpha),t.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(t.blendColor),t.blendAlpha!==void 0&&(this.blendAlpha=t.blendAlpha),t.stencilWriteMask!==void 0&&(this.stencilWriteMask=t.stencilWriteMask),t.stencilFunc!==void 0&&(this.stencilFunc=t.stencilFunc),t.stencilRef!==void 0&&(this.stencilRef=t.stencilRef),t.stencilFuncMask!==void 0&&(this.stencilFuncMask=t.stencilFuncMask),t.stencilFail!==void 0&&(this.stencilFail=t.stencilFail),t.stencilZFail!==void 0&&(this.stencilZFail=t.stencilZFail),t.stencilZPass!==void 0&&(this.stencilZPass=t.stencilZPass),t.stencilWrite!==void 0&&(this.stencilWrite=t.stencilWrite),t.wireframe!==void 0&&(this.wireframe=t.wireframe),t.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=t.wireframeLinewidth),t.wireframeLinecap!==void 0&&(this.wireframeLinecap=t.wireframeLinecap),t.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=t.wireframeLinejoin),t.rotation!==void 0&&(this.rotation=t.rotation),t.linewidth!==void 0&&(this.linewidth=t.linewidth),t.dashSize!==void 0&&(this.dashSize=t.dashSize),t.gapSize!==void 0&&(this.gapSize=t.gapSize),t.scale!==void 0&&(this.scale=t.scale),t.polygonOffset!==void 0&&(this.polygonOffset=t.polygonOffset),t.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=t.polygonOffsetFactor),t.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=t.polygonOffsetUnits),t.dithering!==void 0&&(this.dithering=t.dithering),t.alphaToCoverage!==void 0&&(this.alphaToCoverage=t.alphaToCoverage),t.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=t.premultipliedAlpha),t.forceSinglePass!==void 0&&(this.forceSinglePass=t.forceSinglePass),t.allowOverride!==void 0&&(this.allowOverride=t.allowOverride),t.visible!==void 0&&(this.visible=t.visible),t.toneMapped!==void 0&&(this.toneMapped=t.toneMapped),t.userData!==void 0&&(this.userData=t.userData),t.vertexColors!==void 0&&(typeof t.vertexColors=="number"?this.vertexColors=t.vertexColors>0:this.vertexColors=t.vertexColors),t.size!==void 0&&(this.size=t.size),t.sizeAttenuation!==void 0&&(this.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(this.map=e[t.map]||null),t.matcap!==void 0&&(this.matcap=e[t.matcap]||null),t.alphaMap!==void 0&&(this.alphaMap=e[t.alphaMap]||null),t.bumpMap!==void 0&&(this.bumpMap=e[t.bumpMap]||null),t.bumpScale!==void 0&&(this.bumpScale=t.bumpScale),t.normalMap!==void 0&&(this.normalMap=e[t.normalMap]||null),t.normalMapType!==void 0&&(this.normalMapType=t.normalMapType),t.normalScale!==void 0){let n=t.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new kt().fromArray(n)}return t.displacementMap!==void 0&&(this.displacementMap=e[t.displacementMap]||null),t.displacementScale!==void 0&&(this.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(this.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(this.roughnessMap=e[t.roughnessMap]||null),t.metalnessMap!==void 0&&(this.metalnessMap=e[t.metalnessMap]||null),t.emissiveMap!==void 0&&(this.emissiveMap=e[t.emissiveMap]||null),t.emissiveIntensity!==void 0&&(this.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(this.specularMap=e[t.specularMap]||null),t.specularIntensityMap!==void 0&&(this.specularIntensityMap=e[t.specularIntensityMap]||null),t.specularColorMap!==void 0&&(this.specularColorMap=e[t.specularColorMap]||null),t.envMap!==void 0&&(this.envMap=e[t.envMap]||null),t.envMapRotation!==void 0&&this.envMapRotation.fromArray(t.envMapRotation),t.envMapIntensity!==void 0&&(this.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(this.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(this.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(this.lightMap=e[t.lightMap]||null),t.lightMapIntensity!==void 0&&(this.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(this.aoMap=e[t.aoMap]||null),t.aoMapIntensity!==void 0&&(this.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(this.gradientMap=e[t.gradientMap]||null),t.clearcoatMap!==void 0&&(this.clearcoatMap=e[t.clearcoatMap]||null),t.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=e[t.clearcoatRoughnessMap]||null),t.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=e[t.clearcoatNormalMap]||null),t.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new kt().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(this.iridescenceMap=e[t.iridescenceMap]||null),t.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=e[t.iridescenceThicknessMap]||null),t.transmissionMap!==void 0&&(this.transmissionMap=e[t.transmissionMap]||null),t.thicknessMap!==void 0&&(this.thicknessMap=e[t.thicknessMap]||null),t.anisotropyMap!==void 0&&(this.anisotropyMap=e[t.anisotropyMap]||null),t.sheenColorMap!==void 0&&(this.sheenColorMap=e[t.sheenColorMap]||null),t.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=e[t.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(e!==null){const s=e.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}}class Bi extends ns{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new It(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}let wi;const cs=new F,Ri=new F,Ci=new F,Pi=new kt,hs=new kt,pu=new le,Ws=new F,us=new F,Xs=new F,dc=new kt,Ra=new kt,fc=new kt;class ds extends Oe{constructor(t=new Bi){if(super(),this.isSprite=!0,this.type="Sprite",wi===void 0){wi=new Te;const e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new K0(e,5);wi.setIndex([0,1,2,0,2,3]),wi.setAttribute("position",new kr(n,3,0,!1)),wi.setAttribute("uv",new kr(n,2,3,!1))}this.geometry=wi,this.material=t,this.center=new kt(.5,.5),this.count=1}raycast(t,e){t.camera===null&&Xt('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Ri.setFromMatrixScale(this.matrixWorld),pu.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),Ci.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Ri.multiplyScalar(-Ci.z);const n=this.material.rotation;let s,r;n!==0&&(r=Math.cos(n),s=Math.sin(n));const a=this.center;qs(Ws.set(-.5,-.5,0),Ci,a,Ri,s,r),qs(us.set(.5,-.5,0),Ci,a,Ri,s,r),qs(Xs.set(.5,.5,0),Ci,a,Ri,s,r),dc.set(0,0),Ra.set(1,0),fc.set(1,1);let o=t.ray.intersectTriangle(Ws,us,Xs,!1,cs);if(o===null&&(qs(us.set(-.5,.5,0),Ci,a,Ri,s,r),Ra.set(0,1),o=t.ray.intersectTriangle(Ws,Xs,us,!1,cs),o===null))return;const l=t.ray.origin.distanceTo(cs);l<t.near||l>t.far||e.push({distance:l,point:cs.clone(),uv:Je.getInterpolation(cs,Ws,us,Xs,dc,Ra,fc,new kt),face:null,object:this})}copy(t,e){return super.copy(t,e),t.center!==void 0&&this.center.copy(t.center),this.material=t.material,this}}function qs(i,t,e,n,s,r){Pi.subVectors(i,e).addScalar(.5).multiply(n),s!==void 0?(hs.x=r*Pi.x-s*Pi.y,hs.y=s*Pi.x+r*Pi.y):hs.copy(Pi),i.copy(t),i.x+=hs.x,i.y+=hs.y,i.applyMatrix4(pu)}const Mn=new F,Ca=new F,Ys=new F,zn=new F,Pa=new F,Zs=new F,Ia=new F;class Al{constructor(t=new F,e=new F(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Mn)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Mn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Mn.copy(this.origin).addScaledVector(this.direction,e),Mn.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){Ca.copy(t).add(e).multiplyScalar(.5),Ys.copy(e).sub(t).normalize(),zn.copy(this.origin).sub(Ca);const r=t.distanceTo(e)*.5,a=-this.direction.dot(Ys),o=zn.dot(this.direction),l=-zn.dot(Ys),c=zn.lengthSq(),h=Math.abs(1-a*a);let d,u,p,_;if(h>0)if(d=a*l-o,u=a*o-l,_=r*h,d>=0)if(u>=-_)if(u<=_){const M=1/h;d*=M,u*=M,p=d*(d+a*u+2*o)+u*(a*d+u+2*l)+c}else u=r,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*l)+c;else u=-r,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*l)+c;else u<=-_?(d=Math.max(0,-(-a*r+o)),u=d>0?-r:Math.min(Math.max(-r,-l),r),p=-d*d+u*(u+2*l)+c):u<=_?(d=0,u=Math.min(Math.max(-r,-l),r),p=u*(u+2*l)+c):(d=Math.max(0,-(a*r+o)),u=d>0?r:Math.min(Math.max(-r,-l),r),p=-d*d+u*(u+2*l)+c);else u=a>0?-r:r,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(Ca).addScaledVector(Ys,u),p}intersectSphere(t,e){Mn.subVectors(t.center,this.origin);const n=Mn.dot(this.direction),s=Mn.dot(Mn)-n*n,r=t.radius*t.radius;if(s>r)return null;const a=Math.sqrt(r-s),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,e):this.at(o,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,s,r,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,u=this.origin;return c>=0?(n=(t.min.x-u.x)*c,s=(t.max.x-u.x)*c):(n=(t.max.x-u.x)*c,s=(t.min.x-u.x)*c),h>=0?(r=(t.min.y-u.y)*h,a=(t.max.y-u.y)*h):(r=(t.max.y-u.y)*h,a=(t.min.y-u.y)*h),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a<s||isNaN(s))&&(s=a),d>=0?(o=(t.min.z-u.z)*d,l=(t.max.z-u.z)*d):(o=(t.max.z-u.z)*d,l=(t.min.z-u.z)*d),n>l||o>s)||((o>n||n!==n)&&(n=o),(l<s||s!==s)&&(s=l),s<0)?null:this.at(n>=0?n:s,e)}intersectsBox(t){return this.intersectBox(t,Mn)!==null}intersectTriangle(t,e,n,s,r){Pa.subVectors(e,t),Zs.subVectors(n,t),Ia.crossVectors(Pa,Zs);let a=this.direction.dot(Ia),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;zn.subVectors(this.origin,t);const l=o*this.direction.dot(Zs.crossVectors(zn,Zs));if(l<0)return null;const c=o*this.direction.dot(Pa.cross(zn));if(c<0||l+c>a)return null;const h=-o*zn.dot(Ia);return h<0?null:this.at(h/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class qi extends ns{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new It(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 ui,this.combine=Yh,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const pc=new le,jn=new Al,Ks=new Qr,mc=new F,$s=new F,Js=new F,Qs=new F,Da=new F,js=new F,gc=new F,tr=new F;class Ge extends Oe{constructor(t=new Te,e=new qi){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){const o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(t,e){const n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;e.fromBufferAttribute(s,t);const o=this.morphTargetInfluences;if(r&&o){js.set(0,0,0);for(let l=0,c=r.length;l<c;l++){const h=o[l],d=r[l];h!==0&&(Da.fromBufferAttribute(d,t),a?js.addScaledVector(Da,h):js.addScaledVector(Da.sub(e),h))}e.add(js)}return e}raycast(t,e){const n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Ks.copy(n.boundingSphere),Ks.applyMatrix4(r),jn.copy(t.ray).recast(t.near),!(Ks.containsPoint(jn.origin)===!1&&(jn.intersectSphere(Ks,mc)===null||jn.origin.distanceToSquared(mc)>(t.far-t.near)**2))&&(pc.copy(r).invert(),jn.copy(t.ray).applyMatrix4(pc),!(n.boundingBox!==null&&jn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,jn)))}_computeIntersections(t,e,n){let s;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,d=r.attributes.normal,u=r.groups,p=r.drawRange;if(o!==null)if(Array.isArray(a))for(let _=0,M=u.length;_<M;_++){const m=u[_],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 S=A,y=w;S<y;S+=3){const b=o.getX(S),R=o.getX(S+1),v=o.getX(S+2);s=er(this,f,t,n,c,h,d,b,R,v),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=m.materialIndex,e.push(s))}}else{const _=Math.max(0,p.start),M=Math.min(o.count,p.start+p.count);for(let m=_,f=M;m<f;m+=3){const A=o.getX(m),w=o.getX(m+1),S=o.getX(m+2);s=er(this,a,t,n,c,h,d,A,w,S),s&&(s.faceIndex=Math.floor(m/3),e.push(s))}}else if(l!==void 0)if(Array.isArray(a))for(let _=0,M=u.length;_<M;_++){const m=u[_],f=a[m.materialIndex],A=Math.max(m.start,p.start),w=Math.min(l.count,Math.min(m.start+m.count,p.start+p.count));for(let S=A,y=w;S<y;S+=3){const b=S,R=S+1,v=S+2;s=er(this,f,t,n,c,h,d,b,R,v),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=m.materialIndex,e.push(s))}}else{const _=Math.max(0,p.start),M=Math.min(l.count,p.start+p.count);for(let m=_,f=M;m<f;m+=3){const A=m,w=m+1,S=m+2;s=er(this,a,t,n,c,h,d,A,w,S),s&&(s.faceIndex=Math.floor(m/3),e.push(s))}}}}function J0(i,t,e,n,s,r,a,o){let l;if(t.side===Fe?l=n.intersectTriangle(a,r,s,!0,o):l=n.intersectTriangle(s,r,a,t.side===Kn,o),l===null)return null;tr.copy(o),tr.applyMatrix4(i.matrixWorld);const c=e.ray.origin.distanceTo(tr);return c<e.near||c>e.far?null:{distance:c,point:tr.clone(),object:i}}function er(i,t,e,n,s,r,a,o,l,c){i.getVertexPosition(o,$s),i.getVertexPosition(l,Js),i.getVertexPosition(c,Qs);const h=J0(i,t,e,n,$s,Js,Qs,gc);if(h){const d=new F;Je.getBarycoord(gc,$s,Js,Qs,d),s&&(h.uv=Je.getInterpolatedAttribute(s,o,l,c,d,new kt)),r&&(h.uv1=Je.getInterpolatedAttribute(r,o,l,c,d,new kt)),a&&(h.normal=Je.getInterpolatedAttribute(a,o,l,c,d,new F),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const u={a:o,b:l,c,normal:new F,materialIndex:0};Je.getNormal($s,Js,Qs,u.normal),h.face=u,h.barycoord=d}return h}class Q0 extends De{constructor(t=null,e=1,n=1,s,r,a,o,l,c=Ae,h=Ae,d,u){super(null,a,o,l,c,h,s,r,d,u),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const La=new F,j0=new F,tf=new Ot;class ei{constructor(t=new F(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,s){return this.normal.set(t,e,n),this.constant=s,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const s=La.subVectors(n,e).cross(j0.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(s,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e,n=!0){const s=t.delta(La),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const a=-(t.start.dot(this.normal)+this.constant)/r;return n===!0&&(a<0||a>1)?null:e.copy(t.start).addScaledVector(s,a)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||tf.getNormalMatrix(t),s=this.coplanarPoint(La).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const ti=new Qr,ef=new kt(.5,.5),nr=new F;class mu{constructor(t=new ei,e=new ei,n=new ei,s=new ei,r=new ei,a=new ei){this.planes=[t,e,n,s,r,a]}set(t,e,n,s,r,a){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=fn,n=!1){const s=this.planes,r=t.elements,a=r[0],o=r[1],l=r[2],c=r[3],h=r[4],d=r[5],u=r[6],p=r[7],_=r[8],M=r[9],m=r[10],f=r[11],A=r[12],w=r[13],S=r[14],y=r[15];if(s[0].setComponents(c-a,p-h,f-_,y-A).normalize(),s[1].setComponents(c+a,p+h,f+_,y+A).normalize(),s[2].setComponents(c+o,p+d,f+M,y+w).normalize(),s[3].setComponents(c-o,p-d,f-M,y-w).normalize(),n)s[4].setComponents(l,u,m,S).normalize(),s[5].setComponents(c-l,p-u,f-m,y-S).normalize();else if(s[4].setComponents(c-l,p-u,f-m,y-S).normalize(),e===fn)s[5].setComponents(c+l,p+u,f+m,y+S).normalize();else if(e===Or)s[5].setComponents(l,u,m,S).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),ti.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),ti.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(ti)}intersectsSprite(t){ti.center.set(0,0,0);const e=ef.distanceTo(t.center);return ti.radius=.7071067811865476+e,ti.applyMatrix4(t.matrixWorld),this.intersectsSphere(ti)}intersectsSphere(t){const e=this.planes,n=t.center,s=-t.radius;for(let r=0;r<6;r++)if(e[r].distanceToPoint(n)<s)return!1;return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const s=e[n];if(nr.x=s.normal.x>0?t.max.x:t.min.x,nr.y=s.normal.y>0?t.max.y:t.min.y,nr.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(nr)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class gu extends ns{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new It(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const _c=new le,Vo=new Al,ir=new Qr,sr=new F;class Cr extends Oe{constructor(t=new Te,e=new gu){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){const n=this.geometry,s=this.matrixWorld,r=t.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),ir.copy(n.boundingSphere),ir.applyMatrix4(s),ir.radius+=r,t.ray.intersectsSphere(ir)===!1)return;_c.copy(s).invert(),Vo.copy(t.ray).applyMatrix4(_c);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,d=n.attributes.position;if(c!==null){const u=Math.max(0,a.start),p=Math.min(c.count,a.start+a.count);for(let _=u,M=p;_<M;_++){const m=c.getX(_);sr.fromBufferAttribute(d,m),vc(sr,m,l,s,t,e,this)}}else{const u=Math.max(0,a.start),p=Math.min(d.count,a.start+a.count);for(let _=u,M=p;_<M;_++)sr.fromBufferAttribute(d,_),vc(sr,_,l,s,t,e,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){const o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function vc(i,t,e,n,s,r,a){const o=Vo.distanceSqToPoint(i);if(o<e){const l=new F;Vo.closestPointToPoint(i,l),l.applyMatrix4(n);const c=s.ray.origin.distanceTo(l);if(c<s.near||c>s.far)return;r.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:t,face:null,faceIndex:null,barycoord:null,object:a})}}class _u extends De{constructor(t=[],e=ci,n,s,r,a,o,l,c,h){super(t,e,n,s,r,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class In extends De{constructor(t,e,n,s,r,a,o,l,c){super(t,e,n,s,r,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Ji extends De{constructor(t,e,n=gn,s,r,a,o=Ae,l=Ae,c,h=Pn,d=1){if(h!==Pn&&h!==ai)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const u={width:t,height:e,depth:d};super(u,s,r,a,o,l,h,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new El(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}class nf extends Ji{constructor(t,e=gn,n=ci,s,r,a=Ae,o=Ae,l,c=Pn){const h={width:t,height:t,depth:1},d=[h,h,h,h,h,h];super(t,t,e,n,s,r,a,o,l,c),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}}class vu extends De{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}}class Cs extends Te{constructor(t=1,e=1,n=1,s=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:s,heightSegments:r,depthSegments:a};const o=this;s=Math.floor(s),r=Math.floor(r),a=Math.floor(a);const l=[],c=[],h=[],d=[];let u=0,p=0;_("z","y","x",-1,-1,n,e,t,a,r,0),_("z","y","x",1,-1,n,e,-t,a,r,1),_("x","z","y",1,1,t,n,e,s,a,2),_("x","z","y",1,-1,t,n,-e,s,a,3),_("x","y","z",1,-1,t,e,n,s,r,4),_("x","y","z",-1,-1,t,e,-n,s,r,5),this.setIndex(l),this.setAttribute("position",new Le(c,3)),this.setAttribute("normal",new Le(h,3)),this.setAttribute("uv",new Le(d,2));function _(M,m,f,A,w,S,y,b,R,v,T){const I=S/R,C=y/v,U=S/2,Y=y/2,Z=b/2,O=R+1,W=v+1;let V=0,Q=0;const et=new F;for(let tt=0;tt<W;tt++){const st=tt*C-Y;for(let gt=0;gt<O;gt++){const Vt=gt*I-U;et[M]=Vt*A,et[m]=st*w,et[f]=Z,c.push(et.x,et.y,et.z),et[M]=0,et[m]=0,et[f]=b>0?1:-1,h.push(et.x,et.y,et.z),d.push(gt/R),d.push(1-tt/v),V+=1}}for(let tt=0;tt<v;tt++)for(let st=0;st<R;st++){const gt=u+st+O*tt,Vt=u+st+O*(tt+1),se=u+(st+1)+O*(tt+1),Wt=u+(st+1)+O*tt;l.push(gt,Vt,Wt),l.push(Vt,se,Wt),Q+=6}o.addGroup(p,Q,T),p+=Q,u+=V}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Cs(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class wl extends Te{constructor(t=1,e=32,n=0,s=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:s},e=Math.max(3,e);const r=[],a=[],o=[],l=[],c=new F,h=new kt;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let d=0,u=3;d<=e;d++,u+=3){const p=n+d/e*s;c.x=t*Math.cos(p),c.y=t*Math.sin(p),a.push(c.x,c.y,c.z),o.push(0,0,1),h.x=(a[u]/t+1)/2,h.y=(a[u+1]/t+1)/2,l.push(h.x,h.y)}for(let d=1;d<=e;d++)r.push(d,d+1,0);this.setIndex(r),this.setAttribute("position",new Le(a,3)),this.setAttribute("normal",new Le(o,3)),this.setAttribute("uv",new Le(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new wl(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class jr extends Te{constructor(t=1,e=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:s};const r=t/2,a=e/2,o=Math.floor(n),l=Math.floor(s),c=o+1,h=l+1,d=t/o,u=e/l,p=[],_=[],M=[],m=[];for(let f=0;f<h;f++){const A=f*u-a;for(let w=0;w<c;w++){const S=w*d-r;_.push(S,-A,0),M.push(0,0,1),m.push(w/o),m.push(1-f/l)}}for(let f=0;f<l;f++)for(let A=0;A<o;A++){const w=A+c*f,S=A+c*(f+1),y=A+1+c*(f+1),b=A+1+c*f;p.push(w,S,b),p.push(S,y,b)}this.setIndex(p),this.setAttribute("position",new Le(_,3)),this.setAttribute("normal",new Le(M,3)),this.setAttribute("uv",new Le(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new jr(t.width,t.height,t.widthSegments,t.heightSegments)}}class Hr extends Te{constructor(t=1,e=32,n=16,s=0,r=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:s,phiLength:r,thetaStart:a,thetaLength:o},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const l=Math.min(a+o,Math.PI);let c=0;const h=[],d=new F,u=new F,p=[],_=[],M=[],m=[];for(let f=0;f<=n;f++){const A=[],w=f/n,S=a+w*o,y=t*Math.cos(S),b=Math.sqrt(t*t-y*y);let R=0;f===0&&a===0?R=.5/e:f===n&&l===Math.PI&&(R=-.5/e);for(let v=0;v<=e;v++){const T=v/e,I=s+T*r;d.x=-b*Math.cos(I),d.y=y,d.z=b*Math.sin(I),_.push(d.x,d.y,d.z),u.copy(d).normalize(),M.push(u.x,u.y,u.z),m.push(T+R,1-w),A.push(c++)}h.push(A)}for(let f=0;f<n;f++)for(let A=0;A<e;A++){const w=h[f][A+1],S=h[f][A],y=h[f+1][A],b=h[f+1][A+1];(f!==0||a>0)&&p.push(w,S,b),(f!==n-1||l<Math.PI)&&p.push(S,y,b)}this.setIndex(p),this.setAttribute("position",new Le(_,3)),this.setAttribute("normal",new Le(M,3)),this.setAttribute("uv",new Le(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Hr(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}function Qi(i){const t={};for(const e in i){t[e]={};for(const n in i[e]){const s=i[e][n];if(xc(s))s.isRenderTargetTexture?(Ft("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=s.clone();else if(Array.isArray(s))if(xc(s[0])){const r=[];for(let a=0,o=s.length;a<o;a++)r[a]=s[a].clone();t[e][n]=r}else t[e][n]=s.slice();else t[e][n]=s}}return t}function Ne(i){const t={};for(let e=0;e<i.length;e++){const n=Qi(i[e]);for(const s in n)t[s]=n[s]}return t}function xc(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function sf(i){const t=[];for(let e=0;e<i.length;e++)t.push(i[e].clone());return t}function xu(i){const t=i.getRenderTarget();return t===null?i.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:qt.workingColorSpace}const rf={clone:Qi,merge:Ne};var af=`void main() {
|
|
322
|
+
*/const pl="185",Yd=0,Yl=1,Zd=2,Er=1,Kd=2,_s=3,Zn=0,Dt=1,bn=2,wn=0,Hi=1,Qa=2,Zl=3,Kl=4,$d=5,ni=100,Jd=101,Qd=102,jd=103,e0=104,t0=200,n0=201,i0=202,s0=203,ja=204,eo=205,r0=206,a0=207,o0=208,l0=209,c0=210,h0=211,u0=212,d0=213,f0=214,to=0,no=1,io=2,Zi=3,so=4,ro=5,ao=6,oo=7,Wh=0,p0=1,m0=2,pn=0,Xh=1,qh=2,Yh=3,Zh=4,Kh=5,$h=6,Jh=7,Qh=300,ci=301,Ki=302,sa=303,ra=304,Kr=306,lo=1e3,Tn=1001,co=1002,At=1003,g0=1004,Us=1005,It=1006,aa=1007,ri=1008,$t=1009,jh=1010,eu=1011,bs=1012,ml=1013,gn=1014,dn=1015,Cn=1016,gl=1017,_l=1018,Ts=1020,tu=35902,nu=35899,iu=1021,su=1022,sn=1023,Pn=1026,ai=1027,ru=1028,vl=1029,hi=1030,xl=1031,Sl=1033,br=33776,Tr=33777,Ar=33778,wr=33779,ho=35840,uo=35841,fo=35842,po=35843,mo=36196,go=37492,_o=37496,vo=37488,xo=37489,Dr=37490,So=37491,Mo=37808,yo=37809,Eo=37810,bo=37811,To=37812,Ao=37813,wo=37814,Ro=37815,Co=37816,Po=37817,Io=37818,Do=37819,Lo=37820,Uo=37821,No=36492,Fo=36494,Oo=36495,Bo=36283,zo=36284,Lr=36285,ko=36286,_0=3200,$l=0,v0=1,Vn="",Zt="srgb",Ur="srgb-linear",Nr="linear",Qe="srgb",gi=7680,Jl=519,x0=512,S0=513,M0=514,Ml=515,y0=516,E0=517,yl=518,b0=519,Go=35044,Ql="300 es",fn=2e3,Fr=2001;function T0(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function Or(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function A0(){const i=Or("canvas");return i.style.display="block",i}const jl={};function Br(...i){const e="THREE."+i.shift();console.log(e,...i)}function au(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=au(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=au(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function Vi(...i){const e=i.join(" ");e in jl||(jl[e]=!0,Fe(...i))}function w0(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 R0={[to]:no,[io]:ao,[so]:oo,[Zi]:ro,[no]:to,[ao]:io,[oo]:so,[ro]:Zi};class fi{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 Rt=["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"],oa=Math.PI/180,Ho=180/Math.PI;function qn(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Rt[i&255]+Rt[i>>8&255]+Rt[i>>16&255]+Rt[i>>24&255]+"-"+Rt[e&255]+Rt[e>>8&255]+"-"+Rt[e>>16&15|64]+Rt[e>>24&255]+"-"+Rt[t&63|128]+Rt[t>>8&255]+"-"+Rt[t>>16&255]+Rt[t>>24&255]+Rt[n&255]+Rt[n>>8&255]+Rt[n>>16&255]+Rt[n>>24&255]).toLowerCase()}function Ye(i,e,t){return Math.max(e,Math.min(t,i))}function C0(i,e){return(i%e+e)%e}function la(i,e,t){return(1-t)*i+t*e}function un(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 ke{static{ke.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 l=n[s+0],c=n[s+1],h=n[s+2],d=n[s+3],u=r[a+0],p=r[a+1],_=r[a+2],M=r[a+3];if(d!==M||l!==u||c!==p||h!==_){let m=l*u+c*p+h*_+d*M;m<0&&(u=-u,p=-p,_=-_,M=-M,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,l=l*f+u*o,c=c*f+p*o,h=h*f+_*o,d=d*f+M*o}else{l=l*f+u*o,c=c*f+p*o,h=h*f+_*o,d=d*f+M*o;const A=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=A,c*=A,h*=A,d*=A}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,n,s,r,a){const o=n[s],l=n[s+1],c=n[s+2],h=n[s+3],d=r[a],u=r[a+1],p=r[a+2],_=r[a+3];return e[t]=o*_+h*d+l*p-c*u,e[t+1]=l*_+h*u+c*d-o*p,e[t+2]=c*_+h*p+o*u-l*d,e[t+3]=h*_-o*d-l*u-c*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,s){return this._x=e,this._y=t,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,s=e._y,r=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(s/2),d=o(r/2),u=l(n/2),p=l(s/2),_=l(r/2);switch(a){case"XYZ":this._x=u*h*d+c*p*_,this._y=c*p*d-u*h*_,this._z=c*h*_+u*p*d,this._w=c*h*d-u*p*_;break;case"YXZ":this._x=u*h*d+c*p*_,this._y=c*p*d-u*h*_,this._z=c*h*_-u*p*d,this._w=c*h*d+u*p*_;break;case"ZXY":this._x=u*h*d-c*p*_,this._y=c*p*d+u*h*_,this._z=c*h*_+u*p*d,this._w=c*h*d-u*p*_;break;case"ZYX":this._x=u*h*d-c*p*_,this._y=c*p*d+u*h*_,this._z=c*h*_-u*p*d,this._w=c*h*d+u*p*_;break;case"YZX":this._x=u*h*d+c*p*_,this._y=c*p*d+u*h*_,this._z=c*h*_-u*p*d,this._w=c*h*d-u*p*_;break;case"XZY":this._x=u*h*d-c*p*_,this._y=c*p*d-u*h*_,this._z=c*h*_+u*p*d,this._w=c*h*d+u*p*_;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],l=t[9],c=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-l)*p,this._y=(r-c)*p,this._z=(a-s)*p}else if(n>o&&n>d){const p=2*Math.sqrt(1+n-o-d);this._w=(h-l)/p,this._x=.25*p,this._y=(s+a)/p,this._z=(r+c)/p}else if(o>d){const p=2*Math.sqrt(1+o-n-d);this._w=(r-c)/p,this._x=(s+a)/p,this._y=.25*p,this._z=(l+h)/p}else{const p=2*Math.sqrt(1+d-n-o);this._w=(a-s)/p,this._x=(r+c)/p,this._y=(l+h)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(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,l=t._y,c=t._z,h=t._w;return this._x=n*h+a*o+s*c-r*l,this._y=s*h+a*l+r*o-n*c,this._z=r*h+a*c+n*l-s*o,this._w=a*h-n*o-s*l-r*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,s=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,s=-s,r=-r,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),h=Math.sin(c);l=Math.sin(l*c)/h,t=Math.sin(t*c)/h,this._x=this._x*l+n*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+n*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class F{static{F.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(ec.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(ec.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*s,this.y=r[1]*t+r[4]*n+r[7]*s,this.z=r[2]*t+r[5]*n+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,s=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*s+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*s+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*s+r[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,s=this.z,r=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*s-o*n),h=2*(o*t-r*s),d=2*(r*n-a*t);return this.x=t+l*c+a*d-o*h,this.y=n+l*h+o*c-r*d,this.z=s+l*d+r*h-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*s,this.y=r[1]*t+r[5]*n+r[9]*s,this.z=r[2]*t+r[6]*n+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=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,l=t.z;return this.x=s*l-r*o,this.y=r*a-n*l,this.z=n*o-s*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return ca.copy(this).projectOnVector(e),this.sub(ca)}reflect(e){return this.sub(ca.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 ca=new F,ec=new es;class Oe{static{Oe.prototype.isMatrix3=!0}constructor(e,t,n,s,r,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,a,o,l,c)}set(e,t,n,s,r,a,o,l,c){const h=this.elements;return h[0]=e,h[1]=s,h[2]=o,h[3]=t,h[4]=r,h[5]=l,h[6]=n,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,s=t.elements,r=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],h=n[4],d=n[7],u=n[2],p=n[5],_=n[8],M=s[0],m=s[3],f=s[6],A=s[1],w=s[4],S=s[7],y=s[2],b=s[5],R=s[8];return r[0]=a*M+o*A+l*y,r[3]=a*m+o*w+l*b,r[6]=a*f+o*S+l*R,r[1]=c*M+h*A+d*y,r[4]=c*m+h*w+d*b,r[7]=c*f+h*S+d*R,r[2]=u*M+p*A+_*y,r[5]=u*m+p*w+_*b,r[8]=u*f+p*S+_*R,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8];return t*a*h-t*o*c-n*r*h+n*o*l+s*r*c-s*a*l}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=h*a-o*c,u=o*l-h*r,p=c*r-a*l,_=t*d+n*u+s*p;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);const M=1/_;return e[0]=d*M,e[1]=(s*c-h*n)*M,e[2]=(o*n-s*a)*M,e[3]=u*M,e[4]=(h*t-s*l)*M,e[5]=(s*r-o*t)*M,e[6]=p*M,e[7]=(n*l-c*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 l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*a+c*o)+a+e,-s*c,s*l,-s*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return Vi("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(ha.makeScale(e,t)),this}rotate(e){return Vi("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(ha.makeRotation(-e)),this}translate(e,t){return Vi("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(ha.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 ha=new Oe,tc=new Oe().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),nc=new Oe().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function P0(){const i={enabled:!0,workingColorSpace:Ur,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===Qe&&(s.r=Rn(s.r),s.g=Rn(s.g),s.b=Rn(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=Wi(s.r),s.g=Wi(s.g),s.b=Wi(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===Vn?Nr: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 Vi("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Vi("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({[Ur]:{primaries:e,whitePoint:n,transfer:Nr,toXYZ:tc,fromXYZ:nc,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Zt},outputColorSpaceConfig:{drawingBufferColorSpace:Zt}},[Zt]:{primaries:e,whitePoint:n,transfer:Qe,toXYZ:tc,fromXYZ:nc,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Zt}}}),i}const qe=P0();function Rn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function Wi(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let _i;class I0{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{_i===void 0&&(_i=Or("canvas")),_i.width=e.width,_i.height=e.height;const s=_i.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=_i}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Or("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]=Rn(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(Rn(t[n]/255)*255):t[n]=Rn(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 D0=0;class El{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:D0++}),this.uuid=qn(),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(ua(s[a].image)):r.push(ua(s[a]))}else r=ua(s);n.url=r}return t||(e.images[this.uuid]=n),n}}function ua(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?I0.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 L0=0;const da=new F;class Lt extends fi{constructor(e=Lt.DEFAULT_IMAGE,t=Lt.DEFAULT_MAPPING,n=Tn,s=Tn,r=It,a=ri,o=sn,l=$t,c=Lt.DEFAULT_ANISOTROPY,h=Vn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:L0++}),this.uuid=qn(),this.name="",this.source=new El(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new ke(0,0),this.repeat=new ke(1,1),this.center=new ke(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Oe,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(da).x}get height(){return this.source.getSize(da).y}get depth(){return this.source.getSize(da).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!==Qh)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case lo:e.x=e.x-Math.floor(e.x);break;case Tn:e.x=e.x<0?0:1;break;case co: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 lo:e.y=e.y-Math.floor(e.y);break;case Tn:e.y=e.y<0?0:1;break;case co: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++}}Lt.DEFAULT_IMAGE=null;Lt.DEFAULT_MAPPING=Qh;Lt.DEFAULT_ANISOTROPY=1;class ft{static{ft.prototype.isVector4=!0}constructor(e=0,t=0,n=0,s=1){this.x=e,this.y=t,this.z=n,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,s){return this.x=e,this.y=t,this.z=n,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,s=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*s+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*s+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*s+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*s+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,s,r;const l=e.elements,c=l[0],h=l[4],d=l[8],u=l[1],p=l[5],_=l[9],M=l[2],m=l[6],f=l[10];if(Math.abs(h-u)<.01&&Math.abs(d-M)<.01&&Math.abs(_-m)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+M)<.1&&Math.abs(_+m)<.1&&Math.abs(c+p+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const w=(c+1)/2,S=(p+1)/2,y=(f+1)/2,b=(h+u)/4,R=(d+M)/4,v=(_+m)/4;return w>S&&w>y?w<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(w),s=b/n,r=R/n):S>y?S<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(S),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-_)*(m-_)+(d-M)*(d-M)+(u-h)*(u-h));return Math.abs(A)<.001&&(A=1),this.x=(m-_)/A,this.y=(d-M)/A,this.z=(u-h)/A,this.w=Math.acos((c+p+f-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=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 U0 extends fi{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:It,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new ft(0,0,e,t),this.scissorTest=!1,this.viewport=new ft(0,0,e,t),this.textures=[];const s={width:e,height:t,depth:n.depth},r=new Lt(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:It,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 El(s)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class mn extends U0{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class ou extends Lt{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=At,this.minFilter=At,this.wrapR=Tn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class N0 extends Lt{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=At,this.minFilter=At,this.wrapR=Tn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class lt{static{lt.prototype.isMatrix4=!0}constructor(e,t,n,s,r,a,o,l,c,h,d,u,p,_,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,l,c,h,d,u,p,_,M,m)}set(e,t,n,s,r,a,o,l,c,h,d,u,p,_,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]=l,f[2]=c,f[6]=h,f[10]=d,f[14]=u,f[3]=p,f[7]=_,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 lt().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/vi.setFromMatrixColumn(e,0).length(),r=1/vi.setFromMatrixColumn(e,1).length(),a=1/vi.setFromMatrixColumn(e,2).length();return t[0]=n[0]*s,t[1]=n[1]*s,t[2]=n[2]*s,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,s=e.y,r=e.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(s),c=Math.sin(s),h=Math.cos(r),d=Math.sin(r);if(e.order==="XYZ"){const u=a*h,p=a*d,_=o*h,M=o*d;t[0]=l*h,t[4]=-l*d,t[8]=c,t[1]=p+_*c,t[5]=u-M*c,t[9]=-o*l,t[2]=M-u*c,t[6]=_+p*c,t[10]=a*l}else if(e.order==="YXZ"){const u=l*h,p=l*d,_=c*h,M=c*d;t[0]=u+M*o,t[4]=_*o-p,t[8]=a*c,t[1]=a*d,t[5]=a*h,t[9]=-o,t[2]=p*o-_,t[6]=M+u*o,t[10]=a*l}else if(e.order==="ZXY"){const u=l*h,p=l*d,_=c*h,M=c*d;t[0]=u-M*o,t[4]=-a*d,t[8]=_+p*o,t[1]=p+_*o,t[5]=a*h,t[9]=M-u*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const u=a*h,p=a*d,_=o*h,M=o*d;t[0]=l*h,t[4]=_*c-p,t[8]=u*c+M,t[1]=l*d,t[5]=M*c+u,t[9]=p*c-_,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const u=a*l,p=a*c,_=o*l,M=o*c;t[0]=l*h,t[4]=M-u*d,t[8]=_*d+p,t[1]=d,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=p*d+_,t[10]=u-M*d}else if(e.order==="XZY"){const u=a*l,p=a*c,_=o*l,M=o*c;t[0]=l*h,t[4]=-d,t[8]=c*h,t[1]=u*d+M,t[5]=a*h,t[9]=p*d-_,t[2]=_*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(F0,e,O0)}lookAt(e,t,n){const s=this.elements;return Ht.subVectors(e,t),Ht.lengthSq()===0&&(Ht.z=1),Ht.normalize(),Un.crossVectors(n,Ht),Un.lengthSq()===0&&(Math.abs(n.z)===1?Ht.x+=1e-4:Ht.z+=1e-4,Ht.normalize(),Un.crossVectors(n,Ht)),Un.normalize(),Ns.crossVectors(Ht,Un),s[0]=Un.x,s[4]=Ns.x,s[8]=Ht.x,s[1]=Un.y,s[5]=Ns.y,s[9]=Ht.y,s[2]=Un.z,s[6]=Ns.z,s[10]=Ht.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,s=t.elements,r=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],h=n[1],d=n[5],u=n[9],p=n[13],_=n[2],M=n[6],m=n[10],f=n[14],A=n[3],w=n[7],S=n[11],y=n[15],b=s[0],R=s[4],v=s[8],T=s[12],I=s[1],C=s[5],U=s[9],Y=s[13],Z=s[2],O=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*I+l*Z+c*Q,r[4]=a*R+o*C+l*O+c*te,r[8]=a*v+o*U+l*W+c*ee,r[12]=a*T+o*Y+l*V+c*se,r[1]=h*b+d*I+u*Z+p*Q,r[5]=h*R+d*C+u*O+p*te,r[9]=h*v+d*U+u*W+p*ee,r[13]=h*T+d*Y+u*V+p*se,r[2]=_*b+M*I+m*Z+f*Q,r[6]=_*R+M*C+m*O+f*te,r[10]=_*v+M*U+m*W+f*ee,r[14]=_*T+M*Y+m*V+f*se,r[3]=A*b+w*I+S*Z+y*Q,r[7]=A*R+w*C+S*O+y*te,r[11]=A*v+w*U+S*W+y*ee,r[15]=A*T+w*Y+S*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],l=e[9],c=e[13],h=e[2],d=e[6],u=e[10],p=e[14],_=e[3],M=e[7],m=e[11],f=e[15],A=l*p-c*u,w=o*p-c*d,S=o*u-l*d,y=a*p-c*h,b=a*u-l*h,R=a*d-o*h;return t*(M*A-m*w+f*S)-n*(_*A-m*y+f*b)+s*(_*w-M*y+f*R)-r*(_*S-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],l=e[2],c=e[6],h=e[10];return t*(a*h-o*c)-n*(r*h-o*l)+s*(r*c-a*l)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],d=e[9],u=e[10],p=e[11],_=e[12],M=e[13],m=e[14],f=e[15],A=t*o-n*a,w=t*l-s*a,S=t*c-r*a,y=n*l-s*o,b=n*c-r*o,R=s*c-r*l,v=h*M-d*_,T=h*m-u*_,I=h*f-p*_,C=d*m-u*M,U=d*f-p*M,Y=u*f-p*m,Z=A*Y-w*U+S*C+y*I-b*T+R*v;if(Z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const O=1/Z;return e[0]=(o*Y-l*U+c*C)*O,e[1]=(s*U-n*Y-r*C)*O,e[2]=(M*R-m*b+f*y)*O,e[3]=(u*b-d*R-p*y)*O,e[4]=(l*I-a*Y-c*T)*O,e[5]=(t*Y-s*I+r*T)*O,e[6]=(m*S-_*R-f*w)*O,e[7]=(h*R-u*S+p*w)*O,e[8]=(a*U-o*I+c*v)*O,e[9]=(n*I-t*U-r*v)*O,e[10]=(_*b-M*S+f*A)*O,e[11]=(d*S-h*b-p*A)*O,e[12]=(o*T-a*C-l*v)*O,e[13]=(t*C-n*T+s*v)*O,e[14]=(M*w-_*y-m*A)*O,e[15]=(h*y-d*w+u*A)*O,this}scale(e){const t=this.elements,n=e.x,s=e.y,r=e.z;return t[0]*=n,t[4]*=s,t[8]*=r,t[1]*=n,t[5]*=s,t[9]*=r,t[2]*=n,t[6]*=s,t[10]*=r,t[3]*=n,t[7]*=s,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,s))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),s=Math.sin(t),r=1-n,a=e.x,o=e.y,l=e.z,c=r*a,h=r*o;return this.set(c*a+n,c*o-s*l,c*l+s*o,0,c*o+s*l,h*o+n,h*l-s*a,0,c*l-s*o,h*l+s*a,r*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,s,r,a){return this.set(1,n,r,0,e,1,a,0,t,s,1,0,0,0,0,1),this}compose(e,t,n){const s=this.elements,r=t._x,a=t._y,o=t._z,l=t._w,c=r+r,h=a+a,d=o+o,u=r*c,p=r*h,_=r*d,M=a*h,m=a*d,f=o*d,A=l*c,w=l*h,S=l*d,y=n.x,b=n.y,R=n.z;return s[0]=(1-(M+f))*y,s[1]=(p+S)*y,s[2]=(_-w)*y,s[3]=0,s[4]=(p-S)*b,s[5]=(1-(u+f))*b,s[6]=(m+A)*b,s[7]=0,s[8]=(_+w)*R,s[9]=(m-A)*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=vi.set(s[0],s[1],s[2]).length();const o=vi.set(s[4],s[5],s[6]).length(),l=vi.set(s[8],s[9],s[10]).length();r<0&&(a=-a),en.copy(this);const c=1/a,h=1/o,d=1/l;return en.elements[0]*=c,en.elements[1]*=c,en.elements[2]*=c,en.elements[4]*=h,en.elements[5]*=h,en.elements[6]*=h,en.elements[8]*=d,en.elements[9]*=d,en.elements[10]*=d,t.setFromRotationMatrix(en),n.x=a,n.y=o,n.z=l,this}makePerspective(e,t,n,s,r,a,o=fn,l=!1){const c=this.elements,h=2*r/(t-e),d=2*r/(n-s),u=(t+e)/(t-e),p=(n+s)/(n-s);let _,M;if(l)_=r/(a-r),M=a*r/(a-r);else if(o===fn)_=-(a+r)/(a-r),M=-2*a*r/(a-r);else if(o===Fr)_=-a/(a-r),M=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=u,c[12]=0,c[1]=0,c[5]=d,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=_,c[14]=M,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,s,r,a,o=fn,l=!1){const c=this.elements,h=2/(t-e),d=2/(n-s),u=-(t+e)/(t-e),p=-(n+s)/(n-s);let _,M;if(l)_=1/(a-r),M=a/(a-r);else if(o===fn)_=-2/(a-r),M=-(a+r)/(a-r);else if(o===Fr)_=-1/(a-r),M=-r/(a-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=0,c[12]=u,c[1]=0,c[5]=d,c[9]=0,c[13]=p,c[2]=0,c[6]=0,c[10]=_,c[14]=M,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let s=0;s<16;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const vi=new F,en=new lt,F0=new F(0,0,0),O0=new F(1,1,1),Un=new F,Ns=new F,Ht=new F,ic=new lt,sc=new es;class ui{constructor(e=0,t=0,n=0,s=ui.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=s}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,s=this._order){return this._x=e,this._y=t,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const s=e.elements,r=s[0],a=s[4],o=s[8],l=s[1],c=s[5],h=s[9],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,c),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(l,c)):(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,c)):(this._y=0,this._z=Math.atan2(l,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(l,r)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(Ye(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),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,c),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 ic.makeRotationFromQuaternion(e),this.setFromRotationMatrix(ic,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return sc.setFromEuler(this),this.setFromQuaternion(sc,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}}ui.DEFAULT_ORDER="XYZ";class bl{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 B0=0;const rc=new F,xi=new es,_n=new lt,Fs=new F,ss=new F,z0=new F,k0=new es,ac=new F(1,0,0),oc=new F(0,1,0),lc=new F(0,0,1),cc={type:"added"},G0={type:"removed"},Si={type:"childadded",child:null},fa={type:"childremoved",child:null};class Ot extends fi{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:B0++}),this.uuid=qn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ot.DEFAULT_UP.clone();const e=new F,t=new ui,n=new es,s=new F(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 lt},normalMatrix:{value:new Oe}}),this.matrix=new lt,this.matrixWorld=new lt,this.matrixAutoUpdate=Ot.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Ot.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new bl,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 xi.setFromAxisAngle(e,t),this.quaternion.multiply(xi),this}rotateOnWorldAxis(e,t){return xi.setFromAxisAngle(e,t),this.quaternion.premultiply(xi),this}rotateX(e){return this.rotateOnAxis(ac,e)}rotateY(e){return this.rotateOnAxis(oc,e)}rotateZ(e){return this.rotateOnAxis(lc,e)}translateOnAxis(e,t){return rc.copy(e).applyQuaternion(this.quaternion),this.position.add(rc.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(ac,e)}translateY(e){return this.translateOnAxis(oc,e)}translateZ(e){return this.translateOnAxis(lc,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(_n.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Fs.copy(e):Fs.set(e,t,n);const s=this.parent;this.updateWorldMatrix(!0,!1),ss.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?_n.lookAt(ss,Fs,this.up):_n.lookAt(Fs,ss,this.up),this.quaternion.setFromRotationMatrix(_n),s&&(_n.extractRotation(s.matrixWorld),xi.setFromRotationMatrix(_n),this.quaternion.premultiply(xi.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(cc),Si.child=e,this.dispatchEvent(Si),Si.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(G0),fa.child=e,this.dispatchEvent(fa),fa.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),_n.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),_n.multiply(e.parent.matrixWorld)),e.applyMatrix4(_n),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(cc),Si.child=e,this.dispatchEvent(Si),Si.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(ss,e,z0),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ss,k0,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const t=e.x,n=e.y,s=e.z,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*s,r[13]+=n-r[1]*t-r[5]*n-r[9]*s,r[14]+=s-r[2]*t-r[6]*n-r[10]*s}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){const s=this.parent;if(e===!0&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),t===!0){const r=this.children;for(let a=0,o=r.length;a<o;a++)r[a].updateWorldMatrix(!1,!0,n)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),this.static!==!1&&(s.static=this.static),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.pivot!==null&&(s.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const d=l[c];r(e.shapes,d)}else r(e.shapes,l)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(r(e.materials,this.material[l]));s.material=o}else s.material=r(e.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];s.animations.push(r(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),h=a(e.images),d=a(e.shapes),u=a(e.skeletons),p=a(e.animations),_=a(e.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),d.length>0&&(n.shapes=d),u.length>0&&(n.skeletons=u),p.length>0&&(n.animations=p),_.length>0&&(n.nodes=_)}return n.object=s,n;function a(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const s=e.children[n];this.add(s.clone())}return this}}Ot.DEFAULT_UP=new F(0,1,0);Ot.DEFAULT_MATRIX_AUTO_UPDATE=!0;Ot.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Os extends Ot{constructor(){super(),this.isGroup=!0,this.type="Group"}}const H0={type:"move"};class pa{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Os,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 Os,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new F,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new F),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Os,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new F,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new F,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let s=null,r=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const M of e.hand.values()){const m=t.getJointPose(M,n),f=this._getHandJoint(c,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=c.joints["index-finger-tip"],d=c.joints["thumb-tip"],u=h.position.distanceTo(d.position),p=.02,_=.005;c.inputState.pinching&&u>p+_?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&u<=p-_&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(s=t.getPose(e.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(H0)))}return o!==null&&(o.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Os;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const lu={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},Nn={h:0,s:0,l:0},Bs={h:0,s:0,l:0};function ma(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 Ce{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=Zt){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=C0(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=ma(a,r,e+1/3),this.g=ma(a,r,e),this.b=ma(a,r,e-1/3)}return qe.colorSpaceToWorking(this,s),this}setStyle(e,t=Zt){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=Zt){const n=lu[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=Rn(e.r),this.g=Rn(e.g),this.b=Rn(e.b),this}copyLinearToSRGB(e){return this.r=Wi(e.r),this.g=Wi(e.g),this.b=Wi(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Zt){return qe.workingToColorSpace(Ct.copy(this),e),Math.round(Ye(Ct.r*255,0,255))*65536+Math.round(Ye(Ct.g*255,0,255))*256+Math.round(Ye(Ct.b*255,0,255))}getHexString(e=Zt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=qe.workingColorSpace){qe.workingToColorSpace(Ct.copy(this),t);const n=Ct.r,s=Ct.g,r=Ct.b,a=Math.max(n,s,r),o=Math.min(n,s,r);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const d=a-o;switch(c=h<=.5?d/(a+o):d/(2-a-o),a){case n:l=(s-r)/d+(s<r?6:0);break;case s:l=(r-n)/d+2;break;case r:l=(n-s)/d+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=qe.workingColorSpace){return qe.workingToColorSpace(Ct.copy(this),t),e.r=Ct.r,e.g=Ct.g,e.b=Ct.b,e}getStyle(e=Zt){qe.workingToColorSpace(Ct.copy(this),e);const t=Ct.r,n=Ct.g,s=Ct.b;return e!==Zt?`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(Nn),this.setHSL(Nn.h+e,Nn.s+t,Nn.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(Nn),e.getHSL(Bs);const n=la(Nn.h,Bs.h,t),s=la(Nn.s,Bs.s,t),r=la(Nn.l,Bs.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 Ct=new Ce;Ce.NAMES=lu;class Tl{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new Ce(e),this.near=t,this.far=n}clone(){return new Tl(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 Ot{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 ui,this.environmentIntensity=1,this.environmentRotation=new ui,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 tn=new F,vn=new F,ga=new F,xn=new F,Mi=new F,yi=new F,hc=new F,_a=new F,va=new F,xa=new F,Sa=new ft,Ma=new ft,ya=new ft;class Jt{constructor(e=new F,t=new F,n=new F){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,s){s.subVectors(n,t),tn.subVectors(e,t),s.cross(tn);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){tn.subVectors(s,t),vn.subVectors(n,t),ga.subVectors(e,t);const a=tn.dot(tn),o=tn.dot(vn),l=tn.dot(ga),c=vn.dot(vn),h=vn.dot(ga),d=a*c-o*o;if(d===0)return r.set(0,0,0),null;const u=1/d,p=(c*l-o*h)*u,_=(a*h-o*l)*u;return r.set(1-p-_,_,p)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,xn)===null?!1:xn.x>=0&&xn.y>=0&&xn.x+xn.y<=1}static getInterpolation(e,t,n,s,r,a,o,l){return this.getBarycoord(e,t,n,s,xn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,xn.x),l.addScaledVector(a,xn.y),l.addScaledVector(o,xn.z),l)}static getInterpolatedAttribute(e,t,n,s,r,a){return Sa.setScalar(0),Ma.setScalar(0),ya.setScalar(0),Sa.fromBufferAttribute(e,t),Ma.fromBufferAttribute(e,n),ya.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(Sa,r.x),a.addScaledVector(Ma,r.y),a.addScaledVector(ya,r.z),a}static isFrontFacing(e,t,n,s){return tn.subVectors(n,t),vn.subVectors(e,t),tn.cross(vn).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 tn.subVectors(this.c,this.b),vn.subVectors(this.a,this.b),tn.cross(vn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Jt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Jt.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,r){return Jt.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}containsPoint(e){return Jt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Jt.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;Mi.subVectors(s,n),yi.subVectors(r,n),_a.subVectors(e,n);const l=Mi.dot(_a),c=yi.dot(_a);if(l<=0&&c<=0)return t.copy(n);va.subVectors(e,s);const h=Mi.dot(va),d=yi.dot(va);if(h>=0&&d<=h)return t.copy(s);const u=l*d-h*c;if(u<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(n).addScaledVector(Mi,a);xa.subVectors(e,r);const p=Mi.dot(xa),_=yi.dot(xa);if(_>=0&&p<=_)return t.copy(r);const M=p*c-l*_;if(M<=0&&c>=0&&_<=0)return o=c/(c-_),t.copy(n).addScaledVector(yi,o);const m=h*_-p*d;if(m<=0&&d-h>=0&&p-_>=0)return hc.subVectors(r,s),o=(d-h)/(d-h+(p-_)),t.copy(s).addScaledVector(hc,o);const f=1/(m+M+u);return a=M*f,o=u*f,t.copy(n).addScaledVector(Mi,a).addScaledVector(yi,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class ws{constructor(e=new F(1/0,1/0,1/0),t=new F(-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(nn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(nn.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=nn.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,nn):nn.fromBufferAttribute(r,a),nn.applyMatrix4(e.matrixWorld),this.expandByPoint(nn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),zs.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),zs.copy(n.boundingBox)),zs.applyMatrix4(e.matrixWorld),this.union(zs)}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,nn),nn.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(rs),ks.subVectors(this.max,rs),Ei.subVectors(e.a,rs),bi.subVectors(e.b,rs),Ti.subVectors(e.c,rs),Fn.subVectors(bi,Ei),On.subVectors(Ti,bi),Jn.subVectors(Ei,Ti);let t=[0,-Fn.z,Fn.y,0,-On.z,On.y,0,-Jn.z,Jn.y,Fn.z,0,-Fn.x,On.z,0,-On.x,Jn.z,0,-Jn.x,-Fn.y,Fn.x,0,-On.y,On.x,0,-Jn.y,Jn.x,0];return!Ea(t,Ei,bi,Ti,ks)||(t=[1,0,0,0,1,0,0,0,1],!Ea(t,Ei,bi,Ti,ks))?!1:(Gs.crossVectors(Fn,On),t=[Gs.x,Gs.y,Gs.z],Ea(t,Ei,bi,Ti,ks))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,nn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(nn).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:(Sn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Sn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Sn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Sn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Sn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Sn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Sn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Sn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Sn),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 Sn=[new F,new F,new F,new F,new F,new F,new F,new F],nn=new F,zs=new ws,Ei=new F,bi=new F,Ti=new F,Fn=new F,On=new F,Jn=new F,rs=new F,ks=new F,Gs=new F,Qn=new F;function Ea(i,e,t,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){Qn.fromArray(i,r);const o=s.x*Math.abs(Qn.x)+s.y*Math.abs(Qn.y)+s.z*Math.abs(Qn.z),l=e.dot(Qn),c=t.dot(Qn),h=n.dot(Qn);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const xt=new F,Hs=new ke;let W0=0;class pt extends fi{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:W0++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Go,this.updateRanges=[],this.gpuType=dn,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++)Hs.fromBufferAttribute(this,t),Hs.applyMatrix3(e),this.setXY(t,Hs.x,Hs.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)xt.fromBufferAttribute(this,t),xt.applyMatrix3(e),this.setXYZ(t,xt.x,xt.y,xt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)xt.fromBufferAttribute(this,t),xt.applyMatrix4(e),this.setXYZ(t,xt.x,xt.y,xt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)xt.fromBufferAttribute(this,t),xt.applyNormalMatrix(e),this.setXYZ(t,xt.x,xt.y,xt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)xt.fromBufferAttribute(this,t),xt.transformDirection(e),this.setXYZ(t,xt.x,xt.y,xt.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=un(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=un(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=un(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=un(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=un(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!==Go&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class cu extends pt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class hu extends pt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Ut extends pt{constructor(e,t,n){super(new Float32Array(e),t,n)}}const X0=new ws,as=new F,ba=new F;class $r{constructor(e=new F,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):X0.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;as.subVectors(e,this.center);const t=as.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(as,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):(ba.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(as.copy(e.center).add(ba)),this.expandByPoint(as.copy(e.center).sub(ba))),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 q0=0;const Xt=new lt,Ta=new Ot,Ai=new F,Vt=new ws,os=new ws,yt=new F;class Tt extends fi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:q0++}),this.uuid=qn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(T0(e)?hu:cu)(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 Oe().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 Xt.makeRotationFromQuaternion(e),this.applyMatrix4(Xt),this}rotateX(e){return Xt.makeRotationX(e),this.applyMatrix4(Xt),this}rotateY(e){return Xt.makeRotationY(e),this.applyMatrix4(Xt),this}rotateZ(e){return Xt.makeRotationZ(e),this.applyMatrix4(Xt),this}translate(e,t,n){return Xt.makeTranslation(e,t,n),this.applyMatrix4(Xt),this}scale(e,t,n){return Xt.makeScale(e,t,n),this.applyMatrix4(Xt),this}lookAt(e){return Ta.lookAt(e),Ta.updateMatrix(),this.applyMatrix4(Ta.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ai).negate(),this.translate(Ai.x,Ai.y,Ai.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 Ut(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 ws);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 F(-1/0,-1/0,-1/0),new F(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];Vt.setFromBufferAttribute(r),this.morphTargetsRelative?(yt.addVectors(this.boundingBox.min,Vt.min),this.boundingBox.expandByPoint(yt),yt.addVectors(this.boundingBox.max,Vt.max),this.boundingBox.expandByPoint(yt)):(this.boundingBox.expandByPoint(Vt.min),this.boundingBox.expandByPoint(Vt.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 $r);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 F,1/0);return}if(e){const n=this.boundingSphere.center;if(Vt.setFromBufferAttribute(e),t)for(let r=0,a=t.length;r<a;r++){const o=t[r];os.setFromBufferAttribute(o),this.morphTargetsRelative?(yt.addVectors(Vt.min,os.min),Vt.expandByPoint(yt),yt.addVectors(Vt.max,os.max),Vt.expandByPoint(yt)):(Vt.expandByPoint(os.min),Vt.expandByPoint(os.max))}Vt.getCenter(n);let s=0;for(let r=0,a=e.count;r<a;r++)yt.fromBufferAttribute(e,r),s=Math.max(s,n.distanceToSquared(yt));if(t)for(let r=0,a=t.length;r<a;r++){const o=t[r],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)yt.fromBufferAttribute(o,c),l&&(Ai.fromBufferAttribute(e,c),yt.add(Ai)),s=Math.max(s,n.distanceToSquared(yt))}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 pt(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));const o=[],l=[];for(let v=0;v<n.count;v++)o[v]=new F,l[v]=new F;const c=new F,h=new F,d=new F,u=new ke,p=new ke,_=new ke,M=new F,m=new F;function f(v,T,I){c.fromBufferAttribute(n,v),h.fromBufferAttribute(n,T),d.fromBufferAttribute(n,I),u.fromBufferAttribute(r,v),p.fromBufferAttribute(r,T),_.fromBufferAttribute(r,I),h.sub(c),d.sub(c),p.sub(u),_.sub(u);const C=1/(p.x*_.y-_.x*p.y);isFinite(C)&&(M.copy(h).multiplyScalar(_.y).addScaledVector(d,-p.y).multiplyScalar(C),m.copy(d).multiplyScalar(p.x).addScaledVector(h,-_.x).multiplyScalar(C),o[v].add(M),o[T].add(M),o[I].add(M),l[v].add(m),l[T].add(m),l[I].add(m))}let A=this.groups;A.length===0&&(A=[{start:0,count:e.count}]);for(let v=0,T=A.length;v<T;++v){const I=A[v],C=I.start,U=I.count;for(let Y=C,Z=C+U;Y<Z;Y+=3)f(e.getX(Y+0),e.getX(Y+1),e.getX(Y+2))}const w=new F,S=new F,y=new F,b=new F;function R(v){y.fromBufferAttribute(s,v),b.copy(y);const T=o[v];w.copy(T),w.sub(y.multiplyScalar(y.dot(T))).normalize(),S.crossVectors(b,T);const C=S.dot(l[v])<0?-1:1;a.setXYZW(v,w.x,w.y,w.z,C)}for(let v=0,T=A.length;v<T;++v){const I=A[v],C=I.start,U=I.count;for(let Y=C,Z=C+U;Y<Z;Y+=3)R(e.getX(Y+0)),R(e.getX(Y+1)),R(e.getX(Y+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 pt(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 F,r=new F,a=new F,o=new F,l=new F,c=new F,h=new F,d=new F;if(e)for(let u=0,p=e.count;u<p;u+=3){const _=e.getX(u+0),M=e.getX(u+1),m=e.getX(u+2);s.fromBufferAttribute(t,_),r.fromBufferAttribute(t,M),a.fromBufferAttribute(t,m),h.subVectors(a,r),d.subVectors(s,r),h.cross(d),o.fromBufferAttribute(n,_),l.fromBufferAttribute(n,M),c.fromBufferAttribute(n,m),o.add(h),l.add(h),c.add(h),n.setXYZ(_,o.x,o.y,o.z),n.setXYZ(M,l.x,l.y,l.z),n.setXYZ(m,c.x,c.y,c.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++)yt.fromBufferAttribute(e,t),yt.normalize(),e.setXYZ(t,yt.x,yt.y,yt.z)}toNonIndexed(){function e(o,l){const c=o.array,h=o.itemSize,d=o.normalized,u=new c.constructor(l.length*h);let p=0,_=0;for(let M=0,m=l.length;M<m;M++){o.isInterleavedBufferAttribute?p=l[M]*o.data.stride+o.offset:p=l[M]*h;for(let f=0;f<h;f++)u[_++]=c[p++]}return new pt(u,h,d)}if(this.index===null)return Fe("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Tt,n=this.index.array,s=this.attributes;for(const o in s){const l=s[o],c=e(l,n);t.setAttribute(o,c)}const r=this.morphAttributes;for(const o in r){const l=[],c=r[o];for(let h=0,d=c.length;h<d;h++){const u=c[h],p=e(u,n);l.push(p)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const s={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let d=0,u=c.length;d<u;d++){const p=c[d];h.push(p.toJSON(e.data))}h.length>0&&(s[l]=h,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const s=e.attributes;for(const c in s){const h=s[c];this.setAttribute(c,h.clone(t))}const r=e.morphAttributes;for(const c in r){const h=[],d=r[c];for(let u=0,p=d.length;u<p;u++)h.push(d[u].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,h=a.length;c<h;c++){const d=a[c];this.addGroup(d.start,d.count,d.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Y0{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Go,this.updateRanges=[],this.version=0,this.uuid=qn()}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=qn()),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=qn()),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 Nt=new F;class zr{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++)Nt.fromBufferAttribute(this,t),Nt.applyMatrix4(e),this.setXYZ(t,Nt.x,Nt.y,Nt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Nt.fromBufferAttribute(this,t),Nt.applyNormalMatrix(e),this.setXYZ(t,Nt.x,Nt.y,Nt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Nt.fromBufferAttribute(this,t),Nt.transformDirection(e),this.setXYZ(t,Nt.x,Nt.y,Nt.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=un(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=un(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=un(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=un(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=un(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){Br("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 pt(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 zr(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){Br("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 Z0=0;class ts extends fi{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Z0++}),this.uuid=qn(),this.name="",this.type="Material",this.blending=Hi,this.side=Zn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=ja,this.blendDst=eo,this.blendEquation=ni,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ce(0,0,0),this.blendAlpha=0,this.depthFunc=Zi,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Jl,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=gi,this.stencilZFail=gi,this.stencilZPass=gi,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!==Hi&&(n.blending=this.blending),this.side!==Zn&&(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!==ja&&(n.blendSrc=this.blendSrc),this.blendDst!==eo&&(n.blendDst=this.blendDst),this.blendEquation!==ni&&(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!==Zi&&(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!==Jl&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==gi&&(n.stencilFail=this.stencilFail),this.stencilZFail!==gi&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==gi&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(t){const r=s(e.textures),a=s(e.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Ce().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 ke().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 ke().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 vs extends ts{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Ce(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 wi;const ls=new F,Ri=new F,Ci=new F,Pi=new ke,cs=new ke,uu=new lt,Vs=new F,hs=new F,Ws=new F,uc=new ke,Aa=new ke,dc=new ke;class Xs extends Ot{constructor(e=new vs){if(super(),this.isSprite=!0,this.type="Sprite",wi===void 0){wi=new Tt;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 Y0(t,5);wi.setIndex([0,1,2,0,2,3]),wi.setAttribute("position",new zr(n,3,0,!1)),wi.setAttribute("uv",new zr(n,2,3,!1))}this.geometry=wi,this.material=e,this.center=new ke(.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.'),Ri.setFromMatrixScale(this.matrixWorld),uu.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ci.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Ri.multiplyScalar(-Ci.z);const n=this.material.rotation;let s,r;n!==0&&(r=Math.cos(n),s=Math.sin(n));const a=this.center;qs(Vs.set(-.5,-.5,0),Ci,a,Ri,s,r),qs(hs.set(.5,-.5,0),Ci,a,Ri,s,r),qs(Ws.set(.5,.5,0),Ci,a,Ri,s,r),uc.set(0,0),Aa.set(1,0),dc.set(1,1);let o=e.ray.intersectTriangle(Vs,hs,Ws,!1,ls);if(o===null&&(qs(hs.set(-.5,.5,0),Ci,a,Ri,s,r),Aa.set(0,1),o=e.ray.intersectTriangle(Vs,Ws,hs,!1,ls),o===null))return;const l=e.ray.origin.distanceTo(ls);l<e.near||l>e.far||t.push({distance:l,point:ls.clone(),uv:Jt.getInterpolation(ls,Vs,hs,Ws,uc,Aa,dc,new ke),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 qs(i,e,t,n,s,r){Pi.subVectors(i,t).addScalar(.5).multiply(n),s!==void 0?(cs.x=r*Pi.x-s*Pi.y,cs.y=s*Pi.x+r*Pi.y):cs.copy(Pi),i.copy(e),i.x+=cs.x,i.y+=cs.y,i.applyMatrix4(uu)}const Mn=new F,wa=new F,Ys=new F,Bn=new F,Ra=new F,Zs=new F,Ca=new F;class Al{constructor(e=new F,t=new F(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,Mn)),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=Mn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Mn.copy(this.origin).addScaledVector(this.direction,t),Mn.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){wa.copy(e).add(t).multiplyScalar(.5),Ys.copy(t).sub(e).normalize(),Bn.copy(this.origin).sub(wa);const r=e.distanceTo(t)*.5,a=-this.direction.dot(Ys),o=Bn.dot(this.direction),l=-Bn.dot(Ys),c=Bn.lengthSq(),h=Math.abs(1-a*a);let d,u,p,_;if(h>0)if(d=a*l-o,u=a*o-l,_=r*h,d>=0)if(u>=-_)if(u<=_){const M=1/h;d*=M,u*=M,p=d*(d+a*u+2*o)+u*(a*d+u+2*l)+c}else u=r,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*l)+c;else u=-r,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*l)+c;else u<=-_?(d=Math.max(0,-(-a*r+o)),u=d>0?-r:Math.min(Math.max(-r,-l),r),p=-d*d+u*(u+2*l)+c):u<=_?(d=0,u=Math.min(Math.max(-r,-l),r),p=u*(u+2*l)+c):(d=Math.max(0,-(a*r+o)),u=d>0?r:Math.min(Math.max(-r,-l),r),p=-d*d+u*(u+2*l)+c);else u=a>0?-r:r,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(wa).addScaledVector(Ys,u),p}intersectSphere(e,t){Mn.subVectors(e.center,this.origin);const n=Mn.dot(this.direction),s=Mn.dot(Mn)-n*n,r=e.radius*e.radius;if(s>r)return null;const a=Math.sqrt(r-s),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,s,r,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,u=this.origin;return c>=0?(n=(e.min.x-u.x)*c,s=(e.max.x-u.x)*c):(n=(e.max.x-u.x)*c,s=(e.min.x-u.x)*c),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,l=(e.max.z-u.z)*d):(o=(e.max.z-u.z)*d,l=(e.min.z-u.z)*d),n>l||o>s)||((o>n||n!==n)&&(n=o),(l<s||s!==s)&&(s=l),s<0)?null:this.at(n>=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,Mn)!==null}intersectTriangle(e,t,n,s,r){Ra.subVectors(t,e),Zs.subVectors(n,e),Ca.crossVectors(Ra,Zs);let a=this.direction.dot(Ca),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Bn.subVectors(this.origin,e);const l=o*this.direction.dot(Zs.crossVectors(Bn,Zs));if(l<0)return null;const c=o*this.direction.dot(Ra.cross(Bn));if(c<0||l+c>a)return null;const h=-o*Bn.dot(Ca);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 Xi extends ts{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ce(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 ui,this.combine=Wh,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 fc=new lt,jn=new Al,Ks=new $r,pc=new F,$s=new F,Js=new F,Qs=new F,Pa=new F,js=new F,mc=new F,er=new F;class zt extends Ot{constructor(e=new Tt,t=new Xi){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){js.set(0,0,0);for(let l=0,c=r.length;l<c;l++){const h=o[l],d=r[l];h!==0&&(Pa.fromBufferAttribute(d,e),a?js.addScaledVector(Pa,h):js.addScaledVector(Pa.sub(t),h))}t.add(js)}return t}raycast(e,t){const n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Ks.copy(n.boundingSphere),Ks.applyMatrix4(r),jn.copy(e.ray).recast(e.near),!(Ks.containsPoint(jn.origin)===!1&&(jn.intersectSphere(Ks,pc)===null||jn.origin.distanceToSquared(pc)>(e.far-e.near)**2))&&(fc.copy(r).invert(),jn.copy(e.ray).applyMatrix4(fc),!(n.boundingBox!==null&&jn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,jn)))}_computeIntersections(e,t,n){let s;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,d=r.attributes.normal,u=r.groups,p=r.drawRange;if(o!==null)if(Array.isArray(a))for(let _=0,M=u.length;_<M;_++){const m=u[_],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 S=A,y=w;S<y;S+=3){const b=o.getX(S),R=o.getX(S+1),v=o.getX(S+2);s=tr(this,f,e,n,c,h,d,b,R,v),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=m.materialIndex,t.push(s))}}else{const _=Math.max(0,p.start),M=Math.min(o.count,p.start+p.count);for(let m=_,f=M;m<f;m+=3){const A=o.getX(m),w=o.getX(m+1),S=o.getX(m+2);s=tr(this,a,e,n,c,h,d,A,w,S),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}else if(l!==void 0)if(Array.isArray(a))for(let _=0,M=u.length;_<M;_++){const m=u[_],f=a[m.materialIndex],A=Math.max(m.start,p.start),w=Math.min(l.count,Math.min(m.start+m.count,p.start+p.count));for(let S=A,y=w;S<y;S+=3){const b=S,R=S+1,v=S+2;s=tr(this,f,e,n,c,h,d,b,R,v),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=m.materialIndex,t.push(s))}}else{const _=Math.max(0,p.start),M=Math.min(l.count,p.start+p.count);for(let m=_,f=M;m<f;m+=3){const A=m,w=m+1,S=m+2;s=tr(this,a,e,n,c,h,d,A,w,S),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}}}function K0(i,e,t,n,s,r,a,o){let l;if(e.side===Dt?l=n.intersectTriangle(a,r,s,!0,o):l=n.intersectTriangle(s,r,a,e.side===Zn,o),l===null)return null;er.copy(o),er.applyMatrix4(i.matrixWorld);const c=t.ray.origin.distanceTo(er);return c<t.near||c>t.far?null:{distance:c,point:er.clone(),object:i}}function tr(i,e,t,n,s,r,a,o,l,c){i.getVertexPosition(o,$s),i.getVertexPosition(l,Js),i.getVertexPosition(c,Qs);const h=K0(i,e,t,n,$s,Js,Qs,mc);if(h){const d=new F;Jt.getBarycoord(mc,$s,Js,Qs,d),s&&(h.uv=Jt.getInterpolatedAttribute(s,o,l,c,d,new ke)),r&&(h.uv1=Jt.getInterpolatedAttribute(r,o,l,c,d,new ke)),a&&(h.normal=Jt.getInterpolatedAttribute(a,o,l,c,d,new F),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const u={a:o,b:l,c,normal:new F,materialIndex:0};Jt.getNormal($s,Js,Qs,u.normal),h.face=u,h.barycoord=d}return h}class $0 extends Lt{constructor(e=null,t=1,n=1,s,r,a,o,l,c=At,h=At,d,u){super(null,a,o,l,c,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 Ia=new F,J0=new F,Q0=new Oe;class ti{constructor(e=new F(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=Ia.subVectors(n,t).cross(J0.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(Ia),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||Q0.getNormalMatrix(e),s=this.coplanarPoint(Ia).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 ei=new $r,j0=new ke(.5,.5),nr=new F;class du{constructor(e=new ti,t=new ti,n=new ti,s=new ti,r=new ti,a=new ti){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=fn,n=!1){const s=this.planes,r=e.elements,a=r[0],o=r[1],l=r[2],c=r[3],h=r[4],d=r[5],u=r[6],p=r[7],_=r[8],M=r[9],m=r[10],f=r[11],A=r[12],w=r[13],S=r[14],y=r[15];if(s[0].setComponents(c-a,p-h,f-_,y-A).normalize(),s[1].setComponents(c+a,p+h,f+_,y+A).normalize(),s[2].setComponents(c+o,p+d,f+M,y+w).normalize(),s[3].setComponents(c-o,p-d,f-M,y-w).normalize(),n)s[4].setComponents(l,u,m,S).normalize(),s[5].setComponents(c-l,p-u,f-m,y-S).normalize();else if(s[4].setComponents(c-l,p-u,f-m,y-S).normalize(),t===fn)s[5].setComponents(c+l,p+u,f+m,y+S).normalize();else if(t===Fr)s[5].setComponents(l,u,m,S).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(),ei.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),ei.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(ei)}intersectsSprite(e){ei.center.set(0,0,0);const t=j0.distanceTo(e.center);return ei.radius=.7071067811865476+t,ei.applyMatrix4(e.matrixWorld),this.intersectsSphere(ei)}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(nr.x=s.normal.x>0?e.max.x:e.min.x,nr.y=s.normal.y>0?e.max.y:e.min.y,nr.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(nr)<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 fu extends ts{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ce(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 gc=new lt,Vo=new Al,ir=new $r,sr=new F;class Rr extends Ot{constructor(e=new Tt,t=new fu){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(),ir.copy(n.boundingSphere),ir.applyMatrix4(s),ir.radius+=r,e.ray.intersectsSphere(ir)===!1)return;gc.copy(s).invert(),Vo.copy(e.ray).applyMatrix4(gc);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,d=n.attributes.position;if(c!==null){const u=Math.max(0,a.start),p=Math.min(c.count,a.start+a.count);for(let _=u,M=p;_<M;_++){const m=c.getX(_);sr.fromBufferAttribute(d,m),_c(sr,m,l,s,e,t,this)}}else{const u=Math.max(0,a.start),p=Math.min(d.count,a.start+a.count);for(let _=u,M=p;_<M;_++)sr.fromBufferAttribute(d,_),_c(sr,_,l,s,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){const o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function _c(i,e,t,n,s,r,a){const o=Vo.distanceSqToPoint(i);if(o<t){const l=new F;Vo.closestPointToPoint(i,l),l.applyMatrix4(n);const c=s.ray.origin.distanceTo(l);if(c<s.near||c>s.far)return;r.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class pu extends Lt{constructor(e=[],t=ci,n,s,r,a,o,l,c,h){super(e,t,n,s,r,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Kn extends Lt{constructor(e,t,n,s,r,a,o,l,c){super(e,t,n,s,r,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class $i extends Lt{constructor(e,t,n=gn,s,r,a,o=At,l=At,c,h=Pn,d=1){if(h!==Pn&&h!==ai)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,l,h,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new El(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 ef extends $i{constructor(e,t=gn,n=ci,s,r,a=At,o=At,l,c=Pn){const h={width:e,height:e,depth:1},d=[h,h,h,h,h,h];super(e,e,t,n,s,r,a,o,l,c),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class mu extends Lt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Rs extends Tt{constructor(e=1,t=1,n=1,s=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:s,heightSegments:r,depthSegments:a};const o=this;s=Math.floor(s),r=Math.floor(r),a=Math.floor(a);const l=[],c=[],h=[],d=[];let u=0,p=0;_("z","y","x",-1,-1,n,t,e,a,r,0),_("z","y","x",1,-1,n,t,-e,a,r,1),_("x","z","y",1,1,e,n,t,s,a,2),_("x","z","y",1,-1,e,n,-t,s,a,3),_("x","y","z",1,-1,e,t,n,s,r,4),_("x","y","z",-1,-1,e,t,-n,s,r,5),this.setIndex(l),this.setAttribute("position",new Ut(c,3)),this.setAttribute("normal",new Ut(h,3)),this.setAttribute("uv",new Ut(d,2));function _(M,m,f,A,w,S,y,b,R,v,T){const I=S/R,C=y/v,U=S/2,Y=y/2,Z=b/2,O=R+1,W=v+1;let V=0,Q=0;const te=new F;for(let ee=0;ee<W;ee++){const se=ee*C-Y;for(let ge=0;ge<O;ge++){const Ve=ge*I-U;te[M]=Ve*A,te[m]=se*w,te[f]=Z,c.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+O*ee,Ve=u+se+O*(ee+1),st=u+(se+1)+O*(ee+1),We=u+(se+1)+O*ee;l.push(ge,Ve,We),l.push(Ve,st,We),Q+=6}o.addGroup(p,Q,T),p+=Q,u+=V}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Rs(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class wl extends Tt{constructor(e=1,t=32,n=0,s=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:s},t=Math.max(3,t);const r=[],a=[],o=[],l=[],c=new F,h=new ke;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let d=0,u=3;d<=t;d++,u+=3){const p=n+d/t*s;c.x=e*Math.cos(p),c.y=e*Math.sin(p),a.push(c.x,c.y,c.z),o.push(0,0,1),h.x=(a[u]/e+1)/2,h.y=(a[u+1]/e+1)/2,l.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 Ut(a,3)),this.setAttribute("normal",new Ut(o,3)),this.setAttribute("uv",new Ut(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new wl(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Jr extends Tt{constructor(e=1,t=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:s};const r=e/2,a=t/2,o=Math.floor(n),l=Math.floor(s),c=o+1,h=l+1,d=e/o,u=t/l,p=[],_=[],M=[],m=[];for(let f=0;f<h;f++){const A=f*u-a;for(let w=0;w<c;w++){const S=w*d-r;_.push(S,-A,0),M.push(0,0,1),m.push(w/o),m.push(1-f/l)}}for(let f=0;f<l;f++)for(let A=0;A<o;A++){const w=A+c*f,S=A+c*(f+1),y=A+1+c*(f+1),b=A+1+c*f;p.push(w,S,b),p.push(S,y,b)}this.setIndex(p),this.setAttribute("position",new Ut(_,3)),this.setAttribute("normal",new Ut(M,3)),this.setAttribute("uv",new Ut(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Jr(e.width,e.height,e.widthSegments,e.heightSegments)}}class As extends Tt{constructor(e=1,t=32,n=16,s=0,r=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:s,phiLength:r,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const l=Math.min(a+o,Math.PI);let c=0;const h=[],d=new F,u=new F,p=[],_=[],M=[],m=[];for(let f=0;f<=n;f++){const A=[],w=f/n,S=a+w*o,y=e*Math.cos(S),b=Math.sqrt(e*e-y*y);let R=0;f===0&&a===0?R=.5/t:f===n&&l===Math.PI&&(R=-.5/t);for(let v=0;v<=t;v++){const T=v/t,I=s+T*r;d.x=-b*Math.cos(I),d.y=y,d.z=b*Math.sin(I),_.push(d.x,d.y,d.z),u.copy(d).normalize(),M.push(u.x,u.y,u.z),m.push(T+R,1-w),A.push(c++)}h.push(A)}for(let f=0;f<n;f++)for(let A=0;A<t;A++){const w=h[f][A+1],S=h[f][A],y=h[f+1][A],b=h[f+1][A+1];(f!==0||a>0)&&p.push(w,S,b),(f!==n-1||l<Math.PI)&&p.push(S,y,b)}this.setIndex(p),this.setAttribute("position",new Ut(_,3)),this.setAttribute("normal",new Ut(M,3)),this.setAttribute("uv",new Ut(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new As(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}function Ji(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const s=i[t][n];if(vc(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(vc(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 Ft(i){const e={};for(let t=0;t<i.length;t++){const n=Ji(i[t]);for(const s in n)e[s]=n[s]}return e}function vc(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function tf(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function gu(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:qe.workingColorSpace}const nf={clone:Ji,merge:Ft};var sf=`void main() {
|
|
323
323
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
324
|
-
}`,
|
|
324
|
+
}`,rf=`void main() {
|
|
325
325
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
326
|
-
}`;class Ve extends ns{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=af,this.fragmentShader=of,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Qi(t.uniforms),this.uniformsGroups=sf(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this.defaultAttributeValues=Object.assign({},t.defaultAttributeValues),this.index0AttributeName=t.index0AttributeName,this.uniformsNeedUpdate=t.uniformsNeedUpdate,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const s in this.uniforms){const a=this.uniforms[s].value;a&&a.isTexture?e.uniforms[s]={type:"t",value:a.toJSON(t).uuid}:a&&a.isColor?e.uniforms[s]={type:"c",value:a.getHex()}:a&&a.isVector2?e.uniforms[s]={type:"v2",value:a.toArray()}:a&&a.isVector3?e.uniforms[s]={type:"v3",value:a.toArray()}:a&&a.isVector4?e.uniforms[s]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?e.uniforms[s]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?e.uniforms[s]={type:"m4",value:a.toArray()}:e.uniforms[s]={value:a}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}fromJSON(t,e){if(super.fromJSON(t,e),t.uniforms!==void 0)for(const n in t.uniforms){const s=t.uniforms[n];switch(this.uniforms[n]={},s.type){case"t":this.uniforms[n].value=e[s.value]||null;break;case"c":this.uniforms[n].value=new It().setHex(s.value);break;case"v2":this.uniforms[n].value=new kt().fromArray(s.value);break;case"v3":this.uniforms[n].value=new F().fromArray(s.value);break;case"v4":this.uniforms[n].value=new fe().fromArray(s.value);break;case"m3":this.uniforms[n].value=new Ot().fromArray(s.value);break;case"m4":this.uniforms[n].value=new le().fromArray(s.value);break;default:this.uniforms[n].value=s.value}}if(t.defines!==void 0&&(this.defines=t.defines),t.vertexShader!==void 0&&(this.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(this.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(this.glslVersion=t.glslVersion),t.extensions!==void 0)for(const n in t.extensions)this.extensions[n]=t.extensions[n];return t.lights!==void 0&&(this.lights=t.lights),t.clipping!==void 0&&(this.clipping=t.clipping),this}}class lf extends Ve{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class cf extends ns{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=x0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class hf extends ns{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}const rr=new F,ar=new es,ln=new F;class Su extends Oe{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new le,this.projectionMatrix=new le,this.projectionMatrixInverse=new le,this.coordinateSystem=fn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorld.decompose(rr,ar,ln),ln.x===1&&ln.y===1&&ln.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(rr,ar,ln.set(1,1,1)).invert()}updateWorldMatrix(t,e,n=!1){super.updateWorldMatrix(t,e,n),this.matrixWorld.decompose(rr,ar,ln),ln.x===1&&ln.y===1&&ln.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(rr,ar,ln.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const kn=new F,Sc=new kt,Mc=new kt;class Ke extends Su{constructor(t=50,e=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=Go*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(ca*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return Go*2*Math.atan(Math.tan(ca*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){kn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(kn.x,kn.y).multiplyScalar(-t/kn.z),kn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(kn.x,kn.y).multiplyScalar(-t/kn.z)}getViewSize(t,e){return this.getViewBounds(t,Sc,Mc),e.subVectors(Mc,Sc)}setViewOffset(t,e,n,s,r,a){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(ca*.5*this.fov)/this.zoom,n=2*e,s=this.aspect*n,r=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*s/l,e-=a.offsetY*n/c,s*=a.width/l,n*=a.height/c}const o=this.filmOffset;o!==0&&(r+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,e,e-n,t,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}class Mu extends Su{constructor(t=-1,e=1,n=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,s,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let r=n-t,a=n+t,o=s+e,l=s-e;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}const Ii=-90,Di=1;class uf extends Oe{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new Ke(Ii,Di,t,e);s.layers=this.layers,this.add(s);const r=new Ke(Ii,Di,t,e);r.layers=this.layers,this.add(r);const a=new Ke(Ii,Di,t,e);a.layers=this.layers,this.add(a);const o=new Ke(Ii,Di,t,e);o.layers=this.layers,this.add(o);const l=new Ke(Ii,Di,t,e);l.layers=this.layers,this.add(l);const c=new Ke(Ii,Di,t,e);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,s,r,a,o,l]=e;for(const c of e)this.remove(c);if(t===fn)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(t===Or)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(const c of e)this.add(c),c.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,l,c,h]=this.children,d=t.getRenderTarget(),u=t.getActiveCubeFace(),p=t.getActiveMipmapLevel(),_=t.xr.enabled;t.xr.enabled=!1;const M=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let m=!1;t.isWebGLRenderer===!0?m=t.state.buffers.depth.getReversed():m=t.reversedDepthBuffer,t.setRenderTarget(n,0,s),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,r),t.setRenderTarget(n,1,s),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,a),t.setRenderTarget(n,2,s),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,o),t.setRenderTarget(n,3,s),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,l),t.setRenderTarget(n,4,s),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,c),n.texture.generateMipmaps=M,t.setRenderTarget(n,5,s),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,h),t.setRenderTarget(d,u,p),t.xr.enabled=_,n.texture.needsPMREMUpdate=!0}}class df extends Ke{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}const yc=new le;class ff{constructor(t,e,n=0,s=1/0){this.ray=new Al(t,e),this.near=n,this.far=s,this.camera=null,this.layers=new bl,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,e.projectionMatrix.elements[14]).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):Xt("Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return yc.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(yc),this}intersectObject(t,e=!0,n=[]){return Wo(t,this,n,e),n.sort(Ec),n}intersectObjects(t,e=!0,n=[]){for(let s=0,r=t.length;s<r;s++)Wo(t[s],this,n,e);return n.sort(Ec),n}}function Ec(i,t){return i.distance-t.distance}function Wo(i,t,e,n){let s=!0;if(i.layers.test(t.layers)&&i.raycast(t,e)===!1&&(s=!1),s===!0&&n===!0){const r=i.children;for(let a=0,o=r.length;a<o;a++)Wo(r[a],t,e,!0)}}class yu{static{yu.prototype.isMatrix2=!0}constructor(t,e,n,s){this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,n,s)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,s){const r=this.elements;return r[0]=t,r[2]=e,r[1]=n,r[3]=s,this}}function bc(i,t,e,n){const s=pf(n);switch(e){case au:return i*t;case lu:return i*t/s.components*s.byteLength;case vl:return i*t/s.components*s.byteLength;case hi:return i*t*2/s.components*s.byteLength;case xl:return i*t*2/s.components*s.byteLength;case ou:return i*t*3/s.components*s.byteLength;case sn:return i*t*4/s.components*s.byteLength;case Sl:return i*t*4/s.components*s.byteLength;case Tr:case Ar:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case wr:case Rr:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case uo:case po:return Math.max(i,16)*Math.max(t,8)/4;case ho:case fo:return Math.max(i,8)*Math.max(t,8)/2;case mo:case go:case vo:case xo:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case _o:case Lr:case So:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case Mo:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case yo:return Math.floor((i+4)/5)*Math.floor((t+3)/4)*16;case Eo:return Math.floor((i+4)/5)*Math.floor((t+4)/5)*16;case bo:return Math.floor((i+5)/6)*Math.floor((t+4)/5)*16;case To:return Math.floor((i+5)/6)*Math.floor((t+5)/6)*16;case Ao:return Math.floor((i+7)/8)*Math.floor((t+4)/5)*16;case wo:return Math.floor((i+7)/8)*Math.floor((t+5)/6)*16;case Ro:return Math.floor((i+7)/8)*Math.floor((t+7)/8)*16;case Co:return Math.floor((i+9)/10)*Math.floor((t+4)/5)*16;case Po:return Math.floor((i+9)/10)*Math.floor((t+5)/6)*16;case Io:return Math.floor((i+9)/10)*Math.floor((t+7)/8)*16;case Do:return Math.floor((i+9)/10)*Math.floor((t+9)/10)*16;case Lo:return Math.floor((i+11)/12)*Math.floor((t+9)/10)*16;case Uo:return Math.floor((i+11)/12)*Math.floor((t+11)/12)*16;case No:case Fo:case Oo:return Math.ceil(i/4)*Math.ceil(t/4)*16;case Bo:case zo:return Math.ceil(i/4)*Math.ceil(t/4)*8;case Ur:case ko:return Math.ceil(i/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function pf(i){switch(i){case $e:case nu:return{byteLength:1,components:1};case As:case iu:case Cn:return{byteLength:2,components:1};case gl:case _l:return{byteLength:2,components:4};case gn:case ml:case dn:return{byteLength:4,components:1};case su:case ru: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__?Ft("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=pl);/**
|
|
326
|
+
}`;class kt extends ts{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=sf,this.fragmentShader=rf,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=Ji(e.uniforms),this.uniformsGroups=tf(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 Ce().setHex(s.value);break;case"v2":this.uniforms[n].value=new ke().fromArray(s.value);break;case"v3":this.uniforms[n].value=new F().fromArray(s.value);break;case"v4":this.uniforms[n].value=new ft().fromArray(s.value);break;case"m3":this.uniforms[n].value=new Oe().fromArray(s.value);break;case"m4":this.uniforms[n].value=new lt().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 af extends kt{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class of extends ts{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=_0,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 lf extends ts{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}}const rr=new F,ar=new es,ln=new F;class _u extends Ot{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new lt,this.projectionMatrix=new lt,this.projectionMatrixInverse=new lt,this.coordinateSystem=fn,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(rr,ar,ln),ln.x===1&&ln.y===1&&ln.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(rr,ar,ln.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(rr,ar,ln),ln.x===1&&ln.y===1&&ln.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(rr,ar,ln.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const zn=new F,xc=new ke,Sc=new ke;class Kt extends _u{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=Ho*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(oa*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Ho*2*Math.atan(Math.tan(oa*.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){zn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(zn.x,zn.y).multiplyScalar(-e/zn.z),zn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(zn.x,zn.y).multiplyScalar(-e/zn.z)}getViewSize(e,t){return this.getViewBounds(e,xc,Sc),t.subVectors(Sc,xc)}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(oa*.5*this.fov)/this.zoom,n=2*t,s=this.aspect*n,r=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*s/l,t-=a.offsetY*n/c,s*=a.width/l,n*=a.height/c}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class vu extends _u{constructor(e=-1,t=1,n=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,s,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let r=n-e,a=n+e,o=s+t,l=s-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const Ii=-90,Di=1;class cf extends Ot{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new Kt(Ii,Di,e,t);s.layers=this.layers,this.add(s);const r=new Kt(Ii,Di,e,t);r.layers=this.layers,this.add(r);const a=new Kt(Ii,Di,e,t);a.layers=this.layers,this.add(a);const o=new Kt(Ii,Di,e,t);o.layers=this.layers,this.add(o);const l=new Kt(Ii,Di,e,t);l.layers=this.layers,this.add(l);const c=new Kt(Ii,Di,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,s,r,a,o,l]=t;for(const c of t)this.remove(c);if(e===fn)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Fr)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,l,c,h]=this.children,d=e.getRenderTarget(),u=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),_=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,l),e.setRenderTarget(n,4,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),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=_,n.texture.needsPMREMUpdate=!0}}class hf extends Kt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const Mc=new lt;class uf{constructor(e,t,n=0,s=1/0){this.ray=new Al(e,t),this.near=n,this.far=s,this.camera=null,this.layers=new bl,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 Mc.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Mc),this}intersectObject(e,t=!0,n=[]){return Wo(e,this,n,t),n.sort(yc),n}intersectObjects(e,t=!0,n=[]){for(let s=0,r=e.length;s<r;s++)Wo(e[s],this,n,t);return n.sort(yc),n}}function yc(i,e){return i.distance-e.distance}function Wo(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++)Wo(r[a],e,t,!0)}}class xu{static{xu.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 Ec(i,e,t,n){const s=df(n);switch(t){case iu:return i*e;case ru:return i*e/s.components*s.byteLength;case vl:return i*e/s.components*s.byteLength;case hi:return i*e*2/s.components*s.byteLength;case xl:return i*e*2/s.components*s.byteLength;case su:return i*e*3/s.components*s.byteLength;case sn:return i*e*4/s.components*s.byteLength;case Sl:return i*e*4/s.components*s.byteLength;case br:case Tr:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Ar:case wr:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case uo:case po:return Math.max(i,16)*Math.max(e,8)/4;case ho:case fo:return Math.max(i,8)*Math.max(e,8)/2;case mo:case go:case vo:case xo:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case _o:case Dr:case So:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Mo:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case yo:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case Eo:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case bo:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case To:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case Ao:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case wo:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case Ro:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case Co:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case Po:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case Io:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case Do:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case Lo:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case Uo:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case No:case Fo:case Oo:return Math.ceil(i/4)*Math.ceil(e/4)*16;case Bo:case zo:return Math.ceil(i/4)*Math.ceil(e/4)*8;case Lr:case ko:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function df(i){switch(i){case $t:case jh:return{byteLength:1,components:1};case bs:case eu:case Cn:return{byteLength:2,components:1};case gl:case _l:return{byteLength:2,components:4};case gn:case ml:case dn:return{byteLength:4,components:1};case tu:case nu: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);/**
|
|
327
327
|
* @license
|
|
328
328
|
* Copyright 2010-2026 Three.js Authors
|
|
329
329
|
* SPDX-License-Identifier: MIT
|
|
330
|
-
*/function
|
|
330
|
+
*/function Su(){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 ff(i){const e=new WeakMap;function t(o,l){const c=o.array,h=o.usage,d=c.byteLength,u=i.createBuffer();i.bindBuffer(l,u),i.bufferData(l,c,h),o.onUploadCallback();let p;if(c instanceof Float32Array)p=i.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)p=i.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?p=i.HALF_FLOAT:p=i.UNSIGNED_SHORT;else if(c instanceof Int16Array)p=i.SHORT;else if(c instanceof Uint32Array)p=i.UNSIGNED_INT;else if(c instanceof Int32Array)p=i.INT;else if(c instanceof Int8Array)p=i.BYTE;else if(c instanceof Uint8Array)p=i.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)p=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:u,type:p,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:d}}function n(o,l,c){const h=l.array,d=l.updateRanges;if(i.bindBuffer(c,o),d.length===0)i.bufferSubData(c,0,h);else{d.sort((p,_)=>p.start-_.start);let u=0;for(let p=1;p<d.length;p++){const _=d[u],M=d[p];M.start<=_.start+_.count+1?_.count=Math.max(_.count,M.start+M.count-_.start):(++u,d[u]=M)}d.length=u+1;for(let p=0,_=d.length;p<_;p++){const M=d[p];i.bufferSubData(c,M.start*h.BYTES_PER_ELEMENT,h,M.start,M.count)}l.clearUpdateRanges()}l.onUploadCallback()}function s(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(i.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){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 c=e.get(o);if(c===void 0)e.set(o,t(o,l));else if(c.version<o.version){if(c.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(c.buffer,o,l),c.version=o.version}}return{get:s,remove:r,update:a}}var pf=`#ifdef USE_ALPHAHASH
|
|
331
331
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
332
|
-
#endif`,
|
|
332
|
+
#endif`,mf=`#ifdef USE_ALPHAHASH
|
|
333
333
|
const float ALPHA_HASH_SCALE = 0.05;
|
|
334
334
|
float hash2D( vec2 value ) {
|
|
335
335
|
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
|
|
@@ -364,20 +364,20 @@ input[type=range] {
|
|
|
364
364
|
: cases.z;
|
|
365
365
|
return clamp( threshold , 1.0e-6, 1.0 );
|
|
366
366
|
}
|
|
367
|
-
#endif`,
|
|
367
|
+
#endif`,gf=`#ifdef USE_ALPHAMAP
|
|
368
368
|
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
|
369
|
-
#endif`,
|
|
369
|
+
#endif`,_f=`#ifdef USE_ALPHAMAP
|
|
370
370
|
uniform sampler2D alphaMap;
|
|
371
|
-
#endif`,
|
|
371
|
+
#endif`,vf=`#ifdef USE_ALPHATEST
|
|
372
372
|
#ifdef ALPHA_TO_COVERAGE
|
|
373
373
|
diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
|
|
374
374
|
if ( diffuseColor.a == 0.0 ) discard;
|
|
375
375
|
#else
|
|
376
376
|
if ( diffuseColor.a < alphaTest ) discard;
|
|
377
377
|
#endif
|
|
378
|
-
#endif`,
|
|
378
|
+
#endif`,xf=`#ifdef USE_ALPHATEST
|
|
379
379
|
uniform float alphaTest;
|
|
380
|
-
#endif`,
|
|
380
|
+
#endif`,Sf=`#ifdef USE_AOMAP
|
|
381
381
|
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
|
|
382
382
|
reflectedLight.indirectDiffuse *= ambientOcclusion;
|
|
383
383
|
#if defined( USE_CLEARCOAT )
|
|
@@ -390,10 +390,10 @@ input[type=range] {
|
|
|
390
390
|
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
|
|
391
391
|
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
|
|
392
392
|
#endif
|
|
393
|
-
#endif`,
|
|
393
|
+
#endif`,Mf=`#ifdef USE_AOMAP
|
|
394
394
|
uniform sampler2D aoMap;
|
|
395
395
|
uniform float aoMapIntensity;
|
|
396
|
-
#endif`,
|
|
396
|
+
#endif`,yf=`#ifdef USE_BATCHING
|
|
397
397
|
#if ! defined( GL_ANGLE_multi_draw )
|
|
398
398
|
#define gl_DrawID _gl_DrawID
|
|
399
399
|
uniform int _gl_DrawID;
|
|
@@ -427,15 +427,15 @@ input[type=range] {
|
|
|
427
427
|
int y = j / size;
|
|
428
428
|
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
|
|
429
429
|
}
|
|
430
|
-
#endif`,
|
|
430
|
+
#endif`,Ef=`#ifdef USE_BATCHING
|
|
431
431
|
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
|
432
|
-
#endif`,
|
|
432
|
+
#endif`,bf=`vec3 transformed = vec3( position );
|
|
433
433
|
#ifdef USE_ALPHAHASH
|
|
434
434
|
vPosition = vec3( position );
|
|
435
|
-
#endif`,
|
|
435
|
+
#endif`,Tf=`vec3 objectNormal = vec3( normal );
|
|
436
436
|
#ifdef USE_TANGENT
|
|
437
437
|
vec3 objectTangent = vec3( tangent.xyz );
|
|
438
|
-
#endif`,
|
|
438
|
+
#endif`,Af=`float G_BlinnPhong_Implicit( ) {
|
|
439
439
|
return 0.25;
|
|
440
440
|
}
|
|
441
441
|
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
|
|
@@ -449,7 +449,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
449
449
|
float G = G_BlinnPhong_Implicit( );
|
|
450
450
|
float D = D_BlinnPhong( shininess, dotNH );
|
|
451
451
|
return F * ( G * D );
|
|
452
|
-
} // validated`,
|
|
452
|
+
} // validated`,wf=`#ifdef USE_IRIDESCENCE
|
|
453
453
|
const mat3 XYZ_TO_REC709 = mat3(
|
|
454
454
|
3.2404542, -0.9692660, 0.0556434,
|
|
455
455
|
-1.5371385, 1.8760108, -0.2040259,
|
|
@@ -512,7 +512,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
512
512
|
}
|
|
513
513
|
return max( I, vec3( 0.0 ) );
|
|
514
514
|
}
|
|
515
|
-
#endif`,
|
|
515
|
+
#endif`,Rf=`#ifdef USE_BUMPMAP
|
|
516
516
|
uniform sampler2D bumpMap;
|
|
517
517
|
uniform float bumpScale;
|
|
518
518
|
vec2 dHdxy_fwd() {
|
|
@@ -533,7 +533,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
533
533
|
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
|
534
534
|
return normalize( abs( fDet ) * surf_norm - vGrad );
|
|
535
535
|
}
|
|
536
|
-
#endif`,
|
|
536
|
+
#endif`,Cf=`#if NUM_CLIPPING_PLANES > 0
|
|
537
537
|
vec4 plane;
|
|
538
538
|
#ifdef ALPHA_TO_COVERAGE
|
|
539
539
|
float distanceToPlane, distanceGradient;
|
|
@@ -579,20 +579,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
579
579
|
if ( clipped ) discard;
|
|
580
580
|
#endif
|
|
581
581
|
#endif
|
|
582
|
-
#endif`,
|
|
582
|
+
#endif`,Pf=`#if NUM_CLIPPING_PLANES > 0
|
|
583
583
|
varying vec3 vClipPosition;
|
|
584
584
|
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
|
585
|
-
#endif`,
|
|
585
|
+
#endif`,If=`#if NUM_CLIPPING_PLANES > 0
|
|
586
586
|
varying vec3 vClipPosition;
|
|
587
|
-
#endif`,
|
|
587
|
+
#endif`,Df=`#if NUM_CLIPPING_PLANES > 0
|
|
588
588
|
vClipPosition = - mvPosition.xyz;
|
|
589
|
-
#endif`,
|
|
589
|
+
#endif`,Lf=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
|
590
590
|
diffuseColor *= vColor;
|
|
591
|
-
#endif`,
|
|
591
|
+
#endif`,Uf=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
|
592
592
|
varying vec4 vColor;
|
|
593
|
-
#endif`,
|
|
593
|
+
#endif`,Nf=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
594
594
|
varying vec4 vColor;
|
|
595
|
-
#endif`,
|
|
595
|
+
#endif`,Ff=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
596
596
|
vColor = vec4( 1.0 );
|
|
597
597
|
#endif
|
|
598
598
|
#ifdef USE_COLOR_ALPHA
|
|
@@ -605,7 +605,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
605
605
|
#endif
|
|
606
606
|
#ifdef USE_BATCHING_COLOR
|
|
607
607
|
vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
|
|
608
|
-
#endif`,
|
|
608
|
+
#endif`,Of=`#define PI 3.141592653589793
|
|
609
609
|
#define PI2 6.283185307179586
|
|
610
610
|
#define PI_HALF 1.5707963267948966
|
|
611
611
|
#define RECIPROCAL_PI 0.3183098861837907
|
|
@@ -676,7 +676,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
|
|
|
676
676
|
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
|
677
677
|
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
|
678
678
|
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
|
679
|
-
} // validated`,
|
|
679
|
+
} // validated`,Bf=`#ifdef ENVMAP_TYPE_CUBE_UV
|
|
680
680
|
#define cubeUV_minMipLevel 4.0
|
|
681
681
|
#define cubeUV_minTileSize 16.0
|
|
682
682
|
float getFace( vec3 direction ) {
|
|
@@ -769,7 +769,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
|
|
769
769
|
return vec4( mix( color0, color1, mipF ), 1.0 );
|
|
770
770
|
}
|
|
771
771
|
}
|
|
772
|
-
#endif`,
|
|
772
|
+
#endif`,zf=`vec3 transformedNormal = objectNormal;
|
|
773
773
|
#ifdef USE_TANGENT
|
|
774
774
|
vec3 transformedTangent = objectTangent;
|
|
775
775
|
#endif
|
|
@@ -795,21 +795,21 @@ transformedNormal = normalMatrix * transformedNormal;
|
|
|
795
795
|
#endif
|
|
796
796
|
#ifdef USE_TANGENT
|
|
797
797
|
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
|
|
798
|
-
#endif`,
|
|
798
|
+
#endif`,kf=`#ifdef USE_DISPLACEMENTMAP
|
|
799
799
|
uniform sampler2D displacementMap;
|
|
800
800
|
uniform float displacementScale;
|
|
801
801
|
uniform float displacementBias;
|
|
802
|
-
#endif`,
|
|
802
|
+
#endif`,Gf=`#ifdef USE_DISPLACEMENTMAP
|
|
803
803
|
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
|
804
|
-
#endif`,
|
|
804
|
+
#endif`,Hf=`#ifdef USE_EMISSIVEMAP
|
|
805
805
|
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
|
806
806
|
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
|
|
807
807
|
emissiveColor = sRGBTransferEOTF( emissiveColor );
|
|
808
808
|
#endif
|
|
809
809
|
totalEmissiveRadiance *= emissiveColor.rgb;
|
|
810
|
-
#endif`,
|
|
810
|
+
#endif`,Vf=`#ifdef USE_EMISSIVEMAP
|
|
811
811
|
uniform sampler2D emissiveMap;
|
|
812
|
-
#endif`,
|
|
812
|
+
#endif`,Wf="gl_FragColor = linearToOutputTexel( gl_FragColor );",Xf=`vec4 LinearTransferOETF( in vec4 value ) {
|
|
813
813
|
return value;
|
|
814
814
|
}
|
|
815
815
|
vec4 sRGBTransferEOTF( in vec4 value ) {
|
|
@@ -817,7 +817,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {
|
|
|
817
817
|
}
|
|
818
818
|
vec4 sRGBTransferOETF( in vec4 value ) {
|
|
819
819
|
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 );
|
|
820
|
-
}`,
|
|
820
|
+
}`,qf=`#ifdef USE_ENVMAP
|
|
821
821
|
#ifdef ENV_WORLDPOS
|
|
822
822
|
vec3 cameraToFrag;
|
|
823
823
|
if ( isOrthographic ) {
|
|
@@ -844,7 +844,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
844
844
|
outgoingLight += envColor.xyz * specularStrength * reflectivity;
|
|
845
845
|
#endif
|
|
846
846
|
#endif
|
|
847
|
-
#endif`,
|
|
847
|
+
#endif`,Yf=`#ifdef USE_ENVMAP
|
|
848
848
|
uniform float envMapIntensity;
|
|
849
849
|
uniform mat3 envMapRotation;
|
|
850
850
|
#ifdef ENVMAP_TYPE_CUBE
|
|
@@ -852,7 +852,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
852
852
|
#else
|
|
853
853
|
uniform sampler2D envMap;
|
|
854
854
|
#endif
|
|
855
|
-
#endif
|
|
855
|
+
#endif`,Zf=`#ifdef USE_ENVMAP
|
|
856
856
|
uniform float reflectivity;
|
|
857
857
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
858
858
|
#define ENV_WORLDPOS
|
|
@@ -863,7 +863,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
863
863
|
#else
|
|
864
864
|
varying vec3 vReflect;
|
|
865
865
|
#endif
|
|
866
|
-
#endif`,
|
|
866
|
+
#endif`,Kf=`#ifdef USE_ENVMAP
|
|
867
867
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
868
868
|
#define ENV_WORLDPOS
|
|
869
869
|
#endif
|
|
@@ -874,7 +874,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
874
874
|
varying vec3 vReflect;
|
|
875
875
|
uniform float refractionRatio;
|
|
876
876
|
#endif
|
|
877
|
-
#endif
|
|
877
|
+
#endif`,$f=`#ifdef USE_ENVMAP
|
|
878
878
|
#ifdef ENV_WORLDPOS
|
|
879
879
|
vWorldPosition = worldPosition.xyz;
|
|
880
880
|
#else
|
|
@@ -891,18 +891,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
891
891
|
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
|
|
892
892
|
#endif
|
|
893
893
|
#endif
|
|
894
|
-
#endif`,
|
|
894
|
+
#endif`,Jf=`#ifdef USE_FOG
|
|
895
895
|
vFogDepth = - mvPosition.z;
|
|
896
|
-
#endif`,
|
|
896
|
+
#endif`,Qf=`#ifdef USE_FOG
|
|
897
897
|
varying float vFogDepth;
|
|
898
|
-
#endif`,
|
|
898
|
+
#endif`,jf=`#ifdef USE_FOG
|
|
899
899
|
#ifdef FOG_EXP2
|
|
900
900
|
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
|
|
901
901
|
#else
|
|
902
902
|
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
|
|
903
903
|
#endif
|
|
904
904
|
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
|
|
905
|
-
#endif`,
|
|
905
|
+
#endif`,ep=`#ifdef USE_FOG
|
|
906
906
|
uniform vec3 fogColor;
|
|
907
907
|
varying float vFogDepth;
|
|
908
908
|
#ifdef FOG_EXP2
|
|
@@ -911,7 +911,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
911
911
|
uniform float fogNear;
|
|
912
912
|
uniform float fogFar;
|
|
913
913
|
#endif
|
|
914
|
-
#endif`,
|
|
914
|
+
#endif`,tp=`#ifdef USE_GRADIENTMAP
|
|
915
915
|
uniform sampler2D gradientMap;
|
|
916
916
|
#endif
|
|
917
917
|
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
@@ -923,12 +923,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
|
923
923
|
vec2 fw = fwidth( coord ) * 0.5;
|
|
924
924
|
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
|
|
925
925
|
#endif
|
|
926
|
-
}`,
|
|
926
|
+
}`,np=`#ifdef USE_LIGHTMAP
|
|
927
927
|
uniform sampler2D lightMap;
|
|
928
928
|
uniform float lightMapIntensity;
|
|
929
|
-
#endif`,
|
|
929
|
+
#endif`,ip=`LambertMaterial material;
|
|
930
930
|
material.diffuseColor = diffuseColor.rgb;
|
|
931
|
-
material.specularStrength = specularStrength;`,
|
|
931
|
+
material.specularStrength = specularStrength;`,sp=`varying vec3 vViewPosition;
|
|
932
932
|
struct LambertMaterial {
|
|
933
933
|
vec3 diffuseColor;
|
|
934
934
|
float specularStrength;
|
|
@@ -942,7 +942,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
|
|
|
942
942
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
943
943
|
}
|
|
944
944
|
#define RE_Direct RE_Direct_Lambert
|
|
945
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,
|
|
945
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,rp=`uniform bool receiveShadow;
|
|
946
946
|
uniform vec3 ambientLightColor;
|
|
947
947
|
#if defined( USE_LIGHT_PROBES )
|
|
948
948
|
uniform vec3 lightProbe[ 9 ];
|
|
@@ -1059,7 +1059,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
1059
1059
|
return irradiance;
|
|
1060
1060
|
}
|
|
1061
1061
|
#endif
|
|
1062
|
-
#include <lightprobes_pars_fragment>`,
|
|
1062
|
+
#include <lightprobes_pars_fragment>`,ap=`#ifdef USE_ENVMAP
|
|
1063
1063
|
vec3 getIBLIrradiance( const in vec3 normal ) {
|
|
1064
1064
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
1065
1065
|
vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
|
|
@@ -1092,8 +1092,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
1092
1092
|
#endif
|
|
1093
1093
|
}
|
|
1094
1094
|
#endif
|
|
1095
|
-
#endif`,
|
|
1096
|
-
material.diffuseColor = diffuseColor.rgb;`,
|
|
1095
|
+
#endif`,op=`ToonMaterial material;
|
|
1096
|
+
material.diffuseColor = diffuseColor.rgb;`,lp=`varying vec3 vViewPosition;
|
|
1097
1097
|
struct ToonMaterial {
|
|
1098
1098
|
vec3 diffuseColor;
|
|
1099
1099
|
};
|
|
@@ -1105,11 +1105,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
|
|
|
1105
1105
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
1106
1106
|
}
|
|
1107
1107
|
#define RE_Direct RE_Direct_Toon
|
|
1108
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,
|
|
1108
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,cp=`BlinnPhongMaterial material;
|
|
1109
1109
|
material.diffuseColor = diffuseColor.rgb;
|
|
1110
1110
|
material.specularColor = specular;
|
|
1111
1111
|
material.specularShininess = shininess;
|
|
1112
|
-
material.specularStrength = specularStrength;`,
|
|
1112
|
+
material.specularStrength = specularStrength;`,hp=`varying vec3 vViewPosition;
|
|
1113
1113
|
struct BlinnPhongMaterial {
|
|
1114
1114
|
vec3 diffuseColor;
|
|
1115
1115
|
vec3 specularColor;
|
|
@@ -1126,7 +1126,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
|
|
|
1126
1126
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
1127
1127
|
}
|
|
1128
1128
|
#define RE_Direct RE_Direct_BlinnPhong
|
|
1129
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,
|
|
1129
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,up=`PhysicalMaterial material;
|
|
1130
1130
|
material.diffuseColor = diffuseColor.rgb;
|
|
1131
1131
|
material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
|
1132
1132
|
material.metalness = metalnessFactor;
|
|
@@ -1216,7 +1216,7 @@ material.roughness = min( material.roughness, 1.0 );
|
|
|
1216
1216
|
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
|
|
1217
1217
|
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
|
|
1218
1218
|
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
|
|
1219
|
-
#endif`,
|
|
1219
|
+
#endif`,dp=`uniform sampler2D dfgLUT;
|
|
1220
1220
|
struct PhysicalMaterial {
|
|
1221
1221
|
vec3 diffuseColor;
|
|
1222
1222
|
vec3 diffuseContribution;
|
|
@@ -1576,7 +1576,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
|
|
|
1576
1576
|
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
|
1577
1577
|
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
|
1578
1578
|
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
|
1579
|
-
}`,
|
|
1579
|
+
}`,fp=`
|
|
1580
1580
|
vec3 geometryPosition = - vViewPosition;
|
|
1581
1581
|
vec3 geometryNormal = normal;
|
|
1582
1582
|
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
@@ -1698,7 +1698,7 @@ IncidentLight directLight;
|
|
|
1698
1698
|
#if defined( RE_IndirectSpecular )
|
|
1699
1699
|
vec3 radiance = vec3( 0.0 );
|
|
1700
1700
|
vec3 clearcoatRadiance = vec3( 0.0 );
|
|
1701
|
-
#endif`,
|
|
1701
|
+
#endif`,pp=`#if defined( RE_IndirectDiffuse )
|
|
1702
1702
|
#ifdef USE_LIGHTMAP
|
|
1703
1703
|
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
1704
1704
|
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
|
@@ -1719,7 +1719,7 @@ IncidentLight directLight;
|
|
|
1719
1719
|
#ifdef USE_CLEARCOAT
|
|
1720
1720
|
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
|
|
1721
1721
|
#endif
|
|
1722
|
-
#endif`,
|
|
1722
|
+
#endif`,mp=`#if defined( RE_IndirectDiffuse )
|
|
1723
1723
|
#if defined( LAMBERT ) || defined( PHONG )
|
|
1724
1724
|
irradiance += iblIrradiance;
|
|
1725
1725
|
#endif
|
|
@@ -1727,7 +1727,7 @@ IncidentLight directLight;
|
|
|
1727
1727
|
#endif
|
|
1728
1728
|
#if defined( RE_IndirectSpecular )
|
|
1729
1729
|
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1730
|
-
#endif`,
|
|
1730
|
+
#endif`,gp=`#ifdef USE_LIGHT_PROBES_GRID
|
|
1731
1731
|
uniform highp sampler3D probesSH;
|
|
1732
1732
|
uniform vec3 probesMin;
|
|
1733
1733
|
uniform vec3 probesMax;
|
|
@@ -1772,27 +1772,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1772
1772
|
result += c8 * 0.429043 * ( x * x - y * y );
|
|
1773
1773
|
return max( result, vec3( 0.0 ) );
|
|
1774
1774
|
}
|
|
1775
|
-
#endif`,
|
|
1775
|
+
#endif`,_p=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
1776
1776
|
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
|
1777
|
-
#endif`,
|
|
1777
|
+
#endif`,vp=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
1778
1778
|
uniform float logDepthBufFC;
|
|
1779
1779
|
varying float vFragDepth;
|
|
1780
1780
|
varying float vIsPerspective;
|
|
1781
|
-
#endif`,
|
|
1781
|
+
#endif`,xp=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
1782
1782
|
varying float vFragDepth;
|
|
1783
1783
|
varying float vIsPerspective;
|
|
1784
|
-
#endif`,
|
|
1784
|
+
#endif`,Sp=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
1785
1785
|
vFragDepth = 1.0 + gl_Position.w;
|
|
1786
1786
|
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
1787
|
-
#endif`,
|
|
1787
|
+
#endif`,Mp=`#ifdef USE_MAP
|
|
1788
1788
|
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
|
1789
1789
|
#ifdef DECODE_VIDEO_TEXTURE
|
|
1790
1790
|
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
|
|
1791
1791
|
#endif
|
|
1792
1792
|
diffuseColor *= sampledDiffuseColor;
|
|
1793
|
-
#endif`,
|
|
1793
|
+
#endif`,yp=`#ifdef USE_MAP
|
|
1794
1794
|
uniform sampler2D map;
|
|
1795
|
-
#endif`,
|
|
1795
|
+
#endif`,Ep=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
1796
1796
|
#if defined( USE_POINTS_UV )
|
|
1797
1797
|
vec2 uv = vUv;
|
|
1798
1798
|
#else
|
|
@@ -1804,7 +1804,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1804
1804
|
#endif
|
|
1805
1805
|
#ifdef USE_ALPHAMAP
|
|
1806
1806
|
diffuseColor.a *= texture2D( alphaMap, uv ).g;
|
|
1807
|
-
#endif`,
|
|
1807
|
+
#endif`,bp=`#if defined( USE_POINTS_UV )
|
|
1808
1808
|
varying vec2 vUv;
|
|
1809
1809
|
#else
|
|
1810
1810
|
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
@@ -1816,19 +1816,19 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1816
1816
|
#endif
|
|
1817
1817
|
#ifdef USE_ALPHAMAP
|
|
1818
1818
|
uniform sampler2D alphaMap;
|
|
1819
|
-
#endif`,
|
|
1819
|
+
#endif`,Tp=`float metalnessFactor = metalness;
|
|
1820
1820
|
#ifdef USE_METALNESSMAP
|
|
1821
1821
|
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
|
1822
1822
|
metalnessFactor *= texelMetalness.b;
|
|
1823
|
-
#endif`,
|
|
1823
|
+
#endif`,Ap=`#ifdef USE_METALNESSMAP
|
|
1824
1824
|
uniform sampler2D metalnessMap;
|
|
1825
|
-
#endif`,
|
|
1825
|
+
#endif`,wp=`#ifdef USE_INSTANCING_MORPH
|
|
1826
1826
|
float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
1827
1827
|
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
|
|
1828
1828
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1829
1829
|
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
|
|
1830
1830
|
}
|
|
1831
|
-
#endif`,
|
|
1831
|
+
#endif`,Rp=`#if defined( USE_MORPHCOLORS )
|
|
1832
1832
|
vColor *= morphTargetBaseInfluence;
|
|
1833
1833
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1834
1834
|
#if defined( USE_COLOR_ALPHA )
|
|
@@ -1837,12 +1837,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1837
1837
|
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
|
|
1838
1838
|
#endif
|
|
1839
1839
|
}
|
|
1840
|
-
#endif`,
|
|
1840
|
+
#endif`,Cp=`#ifdef USE_MORPHNORMALS
|
|
1841
1841
|
objectNormal *= morphTargetBaseInfluence;
|
|
1842
1842
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1843
1843
|
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
|
|
1844
1844
|
}
|
|
1845
|
-
#endif`,
|
|
1845
|
+
#endif`,Pp=`#ifdef USE_MORPHTARGETS
|
|
1846
1846
|
#ifndef USE_INSTANCING_MORPH
|
|
1847
1847
|
uniform float morphTargetBaseInfluence;
|
|
1848
1848
|
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
@@ -1856,12 +1856,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1856
1856
|
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
|
|
1857
1857
|
return texelFetch( morphTargetsTexture, morphUV, 0 );
|
|
1858
1858
|
}
|
|
1859
|
-
#endif`,
|
|
1859
|
+
#endif`,Ip=`#ifdef USE_MORPHTARGETS
|
|
1860
1860
|
transformed *= morphTargetBaseInfluence;
|
|
1861
1861
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1862
1862
|
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
|
|
1863
1863
|
}
|
|
1864
|
-
#endif`,
|
|
1864
|
+
#endif`,Dp=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
|
|
1865
1865
|
#ifdef FLAT_SHADED
|
|
1866
1866
|
vec3 fdx = dFdx( vViewPosition );
|
|
1867
1867
|
vec3 fdy = dFdy( vViewPosition );
|
|
@@ -1902,7 +1902,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1902
1902
|
tbn2[1] *= faceDirection;
|
|
1903
1903
|
#endif
|
|
1904
1904
|
#endif
|
|
1905
|
-
vec3 nonPerturbedNormal = normal;`,
|
|
1905
|
+
vec3 nonPerturbedNormal = normal;`,Lp=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
1906
1906
|
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|
1907
1907
|
#ifdef FLIP_SIDED
|
|
1908
1908
|
normal = - normal;
|
|
@@ -1920,19 +1920,19 @@ vec3 nonPerturbedNormal = normal;`,Np=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1920
1920
|
normal = normalize( tbn * mapN );
|
|
1921
1921
|
#elif defined( USE_BUMPMAP )
|
|
1922
1922
|
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
|
|
1923
|
-
#endif`,
|
|
1923
|
+
#endif`,Up=`#ifndef FLAT_SHADED
|
|
1924
1924
|
varying vec3 vNormal;
|
|
1925
1925
|
#ifdef USE_TANGENT
|
|
1926
1926
|
varying vec3 vTangent;
|
|
1927
1927
|
varying vec3 vBitangent;
|
|
1928
1928
|
#endif
|
|
1929
|
-
#endif`,
|
|
1929
|
+
#endif`,Np=`#ifndef FLAT_SHADED
|
|
1930
1930
|
varying vec3 vNormal;
|
|
1931
1931
|
#ifdef USE_TANGENT
|
|
1932
1932
|
varying vec3 vTangent;
|
|
1933
1933
|
varying vec3 vBitangent;
|
|
1934
1934
|
#endif
|
|
1935
|
-
#endif`,
|
|
1935
|
+
#endif`,Fp=`#ifndef FLAT_SHADED
|
|
1936
1936
|
vNormal = normalize( transformedNormal );
|
|
1937
1937
|
#ifdef USE_TANGENT
|
|
1938
1938
|
vTangent = normalize( transformedTangent );
|
|
@@ -1941,7 +1941,7 @@ vec3 nonPerturbedNormal = normal;`,Np=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1941
1941
|
vBitangent = - vBitangent;
|
|
1942
1942
|
#endif
|
|
1943
1943
|
#endif
|
|
1944
|
-
#endif`,
|
|
1944
|
+
#endif`,Op=`#ifdef USE_NORMALMAP
|
|
1945
1945
|
uniform sampler2D normalMap;
|
|
1946
1946
|
uniform vec2 normalScale;
|
|
1947
1947
|
#endif
|
|
@@ -1963,13 +1963,13 @@ vec3 nonPerturbedNormal = normal;`,Np=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1963
1963
|
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
|
|
1964
1964
|
return mat3( T * scale, B * scale, N );
|
|
1965
1965
|
}
|
|
1966
|
-
#endif`,
|
|
1966
|
+
#endif`,Bp=`#ifdef USE_CLEARCOAT
|
|
1967
1967
|
vec3 clearcoatNormal = nonPerturbedNormal;
|
|
1968
|
-
#endif`,
|
|
1968
|
+
#endif`,zp=`#ifdef USE_CLEARCOAT_NORMALMAP
|
|
1969
1969
|
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
|
1970
1970
|
clearcoatMapN.xy *= clearcoatNormalScale;
|
|
1971
1971
|
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
|
1972
|
-
#endif`,
|
|
1972
|
+
#endif`,kp=`#ifdef USE_CLEARCOATMAP
|
|
1973
1973
|
uniform sampler2D clearcoatMap;
|
|
1974
1974
|
#endif
|
|
1975
1975
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
@@ -1978,18 +1978,18 @@ vec3 nonPerturbedNormal = normal;`,Np=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1978
1978
|
#endif
|
|
1979
1979
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
1980
1980
|
uniform sampler2D clearcoatRoughnessMap;
|
|
1981
|
-
#endif`,
|
|
1981
|
+
#endif`,Gp=`#ifdef USE_IRIDESCENCEMAP
|
|
1982
1982
|
uniform sampler2D iridescenceMap;
|
|
1983
1983
|
#endif
|
|
1984
1984
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
1985
1985
|
uniform sampler2D iridescenceThicknessMap;
|
|
1986
|
-
#endif`,
|
|
1986
|
+
#endif`,Hp=`#ifdef OPAQUE
|
|
1987
1987
|
diffuseColor.a = 1.0;
|
|
1988
1988
|
#endif
|
|
1989
1989
|
#ifdef USE_TRANSMISSION
|
|
1990
1990
|
diffuseColor.a *= material.transmissionAlpha;
|
|
1991
1991
|
#endif
|
|
1992
|
-
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,
|
|
1992
|
+
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Vp=`vec3 packNormalToRGB( const in vec3 normal ) {
|
|
1993
1993
|
return normalize( normal ) * 0.5 + 0.5;
|
|
1994
1994
|
}
|
|
1995
1995
|
vec3 unpackRGBToNormal( const in vec3 rgb ) {
|
|
@@ -2068,9 +2068,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
|
|
|
2068
2068
|
#else
|
|
2069
2069
|
return ( near * far ) / ( ( far - near ) * depth - far );
|
|
2070
2070
|
#endif
|
|
2071
|
-
}`,
|
|
2071
|
+
}`,Wp=`#ifdef PREMULTIPLIED_ALPHA
|
|
2072
2072
|
gl_FragColor.rgb *= gl_FragColor.a;
|
|
2073
|
-
#endif`,
|
|
2073
|
+
#endif`,Xp=`vec4 mvPosition = vec4( transformed, 1.0 );
|
|
2074
2074
|
#ifdef USE_BATCHING
|
|
2075
2075
|
mvPosition = batchingMatrix * mvPosition;
|
|
2076
2076
|
#endif
|
|
@@ -2078,22 +2078,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
|
|
|
2078
2078
|
mvPosition = instanceMatrix * mvPosition;
|
|
2079
2079
|
#endif
|
|
2080
2080
|
mvPosition = modelViewMatrix * mvPosition;
|
|
2081
|
-
gl_Position = projectionMatrix * mvPosition;`,
|
|
2081
|
+
gl_Position = projectionMatrix * mvPosition;`,qp=`#ifdef DITHERING
|
|
2082
2082
|
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
|
2083
|
-
#endif`,
|
|
2083
|
+
#endif`,Yp=`#ifdef DITHERING
|
|
2084
2084
|
vec3 dithering( vec3 color ) {
|
|
2085
2085
|
float grid_position = rand( gl_FragCoord.xy );
|
|
2086
2086
|
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
|
|
2087
2087
|
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
|
|
2088
2088
|
return color + dither_shift_RGB;
|
|
2089
2089
|
}
|
|
2090
|
-
#endif
|
|
2090
|
+
#endif`,Zp=`float roughnessFactor = roughness;
|
|
2091
2091
|
#ifdef USE_ROUGHNESSMAP
|
|
2092
2092
|
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
|
2093
2093
|
roughnessFactor *= texelRoughness.g;
|
|
2094
|
-
#endif`,
|
|
2094
|
+
#endif`,Kp=`#ifdef USE_ROUGHNESSMAP
|
|
2095
2095
|
uniform sampler2D roughnessMap;
|
|
2096
|
-
#endif
|
|
2096
|
+
#endif`,$p=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
2097
2097
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
2098
2098
|
#endif
|
|
2099
2099
|
#if NUM_SPOT_LIGHT_MAPS > 0
|
|
@@ -2293,7 +2293,7 @@ gl_Position = projectionMatrix * mvPosition;`,Zp=`#ifdef DITHERING
|
|
|
2293
2293
|
}
|
|
2294
2294
|
#endif
|
|
2295
2295
|
#endif
|
|
2296
|
-
#endif`,
|
|
2296
|
+
#endif`,Jp=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
2297
2297
|
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
|
|
2298
2298
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
2299
2299
|
#endif
|
|
@@ -2334,7 +2334,7 @@ gl_Position = projectionMatrix * mvPosition;`,Zp=`#ifdef DITHERING
|
|
|
2334
2334
|
};
|
|
2335
2335
|
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
2336
2336
|
#endif
|
|
2337
|
-
#endif`,
|
|
2337
|
+
#endif`,Qp=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
|
|
2338
2338
|
#ifdef HAS_NORMAL
|
|
2339
2339
|
vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
|
|
2340
2340
|
#else
|
|
@@ -2370,7 +2370,7 @@ gl_Position = projectionMatrix * mvPosition;`,Zp=`#ifdef DITHERING
|
|
|
2370
2370
|
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
|
|
2371
2371
|
}
|
|
2372
2372
|
#pragma unroll_loop_end
|
|
2373
|
-
#endif`,
|
|
2373
|
+
#endif`,jp=`float getShadowMask() {
|
|
2374
2374
|
float shadow = 1.0;
|
|
2375
2375
|
#ifdef USE_SHADOWMAP
|
|
2376
2376
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
@@ -2402,12 +2402,12 @@ gl_Position = projectionMatrix * mvPosition;`,Zp=`#ifdef DITHERING
|
|
|
2402
2402
|
#endif
|
|
2403
2403
|
#endif
|
|
2404
2404
|
return shadow;
|
|
2405
|
-
}`,
|
|
2405
|
+
}`,em=`#ifdef USE_SKINNING
|
|
2406
2406
|
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
|
2407
2407
|
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
|
2408
2408
|
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
|
2409
2409
|
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
|
2410
|
-
#endif`,
|
|
2410
|
+
#endif`,tm=`#ifdef USE_SKINNING
|
|
2411
2411
|
uniform mat4 bindMatrix;
|
|
2412
2412
|
uniform mat4 bindMatrixInverse;
|
|
2413
2413
|
uniform highp sampler2D boneTexture;
|
|
@@ -2422,7 +2422,7 @@ gl_Position = projectionMatrix * mvPosition;`,Zp=`#ifdef DITHERING
|
|
|
2422
2422
|
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
|
|
2423
2423
|
return mat4( v1, v2, v3, v4 );
|
|
2424
2424
|
}
|
|
2425
|
-
#endif`,
|
|
2425
|
+
#endif`,nm=`#ifdef USE_SKINNING
|
|
2426
2426
|
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
|
|
2427
2427
|
vec4 skinned = vec4( 0.0 );
|
|
2428
2428
|
skinned += boneMatX * skinVertex * skinWeight.x;
|
|
@@ -2430,7 +2430,7 @@ gl_Position = projectionMatrix * mvPosition;`,Zp=`#ifdef DITHERING
|
|
|
2430
2430
|
skinned += boneMatZ * skinVertex * skinWeight.z;
|
|
2431
2431
|
skinned += boneMatW * skinVertex * skinWeight.w;
|
|
2432
2432
|
transformed = ( bindMatrixInverse * skinned ).xyz;
|
|
2433
|
-
#endif`,
|
|
2433
|
+
#endif`,im=`#ifdef USE_SKINNING
|
|
2434
2434
|
mat4 skinMatrix = mat4( 0.0 );
|
|
2435
2435
|
skinMatrix += skinWeight.x * boneMatX;
|
|
2436
2436
|
skinMatrix += skinWeight.y * boneMatY;
|
|
@@ -2441,17 +2441,17 @@ gl_Position = projectionMatrix * mvPosition;`,Zp=`#ifdef DITHERING
|
|
|
2441
2441
|
#ifdef USE_TANGENT
|
|
2442
2442
|
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
|
2443
2443
|
#endif
|
|
2444
|
-
#endif`,
|
|
2444
|
+
#endif`,sm=`float specularStrength;
|
|
2445
2445
|
#ifdef USE_SPECULARMAP
|
|
2446
2446
|
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
|
2447
2447
|
specularStrength = texelSpecular.r;
|
|
2448
2448
|
#else
|
|
2449
2449
|
specularStrength = 1.0;
|
|
2450
|
-
#endif`,
|
|
2450
|
+
#endif`,rm=`#ifdef USE_SPECULARMAP
|
|
2451
2451
|
uniform sampler2D specularMap;
|
|
2452
|
-
#endif`,
|
|
2452
|
+
#endif`,am=`#if defined( TONE_MAPPING )
|
|
2453
2453
|
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
|
2454
|
-
#endif`,
|
|
2454
|
+
#endif`,om=`#ifndef saturate
|
|
2455
2455
|
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|
2456
2456
|
#endif
|
|
2457
2457
|
uniform float toneMappingExposure;
|
|
@@ -2548,7 +2548,7 @@ vec3 NeutralToneMapping( vec3 color ) {
|
|
|
2548
2548
|
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
|
|
2549
2549
|
return mix( color, vec3( newPeak ), g );
|
|
2550
2550
|
}
|
|
2551
|
-
vec3 CustomToneMapping( vec3 color ) { return color; }`,
|
|
2551
|
+
vec3 CustomToneMapping( vec3 color ) { return color; }`,lm=`#ifdef USE_TRANSMISSION
|
|
2552
2552
|
material.transmission = transmission;
|
|
2553
2553
|
material.transmissionAlpha = 1.0;
|
|
2554
2554
|
material.thickness = thickness;
|
|
@@ -2569,7 +2569,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,hm=`#ifdef USE_TRANSMISS
|
|
|
2569
2569
|
material.attenuationColor, material.attenuationDistance );
|
|
2570
2570
|
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
|
|
2571
2571
|
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
|
|
2572
|
-
#endif`,
|
|
2572
|
+
#endif`,cm=`#ifdef USE_TRANSMISSION
|
|
2573
2573
|
uniform float transmission;
|
|
2574
2574
|
uniform float thickness;
|
|
2575
2575
|
uniform float attenuationDistance;
|
|
@@ -2695,7 +2695,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,hm=`#ifdef USE_TRANSMISS
|
|
|
2695
2695
|
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
|
|
2696
2696
|
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
|
|
2697
2697
|
}
|
|
2698
|
-
#endif`,
|
|
2698
|
+
#endif`,hm=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2699
2699
|
varying vec2 vUv;
|
|
2700
2700
|
#endif
|
|
2701
2701
|
#ifdef USE_MAP
|
|
@@ -2765,7 +2765,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,hm=`#ifdef USE_TRANSMISS
|
|
|
2765
2765
|
#ifdef USE_THICKNESSMAP
|
|
2766
2766
|
uniform mat3 thicknessMapTransform;
|
|
2767
2767
|
varying vec2 vThicknessMapUv;
|
|
2768
|
-
#endif`,
|
|
2768
|
+
#endif`,um=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2769
2769
|
varying vec2 vUv;
|
|
2770
2770
|
#endif
|
|
2771
2771
|
#ifdef USE_MAP
|
|
@@ -2859,7 +2859,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,hm=`#ifdef USE_TRANSMISS
|
|
|
2859
2859
|
#ifdef USE_THICKNESSMAP
|
|
2860
2860
|
uniform mat3 thicknessMapTransform;
|
|
2861
2861
|
varying vec2 vThicknessMapUv;
|
|
2862
|
-
#endif`,
|
|
2862
|
+
#endif`,dm=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2863
2863
|
vUv = vec3( uv, 1 ).xy;
|
|
2864
2864
|
#endif
|
|
2865
2865
|
#ifdef USE_MAP
|
|
@@ -2930,7 +2930,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,hm=`#ifdef USE_TRANSMISS
|
|
|
2930
2930
|
#endif
|
|
2931
2931
|
#ifdef USE_THICKNESSMAP
|
|
2932
2932
|
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
|
|
2933
|
-
#endif`,
|
|
2933
|
+
#endif`,fm=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
|
|
2934
2934
|
vec4 worldPosition = vec4( transformed, 1.0 );
|
|
2935
2935
|
#ifdef USE_BATCHING
|
|
2936
2936
|
worldPosition = batchingMatrix * worldPosition;
|
|
@@ -2939,12 +2939,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,hm=`#ifdef USE_TRANSMISS
|
|
|
2939
2939
|
worldPosition = instanceMatrix * worldPosition;
|
|
2940
2940
|
#endif
|
|
2941
2941
|
worldPosition = modelMatrix * worldPosition;
|
|
2942
|
-
#endif`;const
|
|
2942
|
+
#endif`;const pm=`varying vec2 vUv;
|
|
2943
2943
|
uniform mat3 uvTransform;
|
|
2944
2944
|
void main() {
|
|
2945
2945
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
2946
2946
|
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
|
2947
|
-
}`,
|
|
2947
|
+
}`,mm=`uniform sampler2D t2D;
|
|
2948
2948
|
uniform float backgroundIntensity;
|
|
2949
2949
|
varying vec2 vUv;
|
|
2950
2950
|
void main() {
|
|
@@ -2956,14 +2956,14 @@ void main() {
|
|
|
2956
2956
|
gl_FragColor = texColor;
|
|
2957
2957
|
#include <tonemapping_fragment>
|
|
2958
2958
|
#include <colorspace_fragment>
|
|
2959
|
-
}`,
|
|
2959
|
+
}`,gm=`varying vec3 vWorldDirection;
|
|
2960
2960
|
#include <common>
|
|
2961
2961
|
void main() {
|
|
2962
2962
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2963
2963
|
#include <begin_vertex>
|
|
2964
2964
|
#include <project_vertex>
|
|
2965
2965
|
gl_Position.z = gl_Position.w;
|
|
2966
|
-
}`,
|
|
2966
|
+
}`,_m=`#ifdef ENVMAP_TYPE_CUBE
|
|
2967
2967
|
uniform samplerCube envMap;
|
|
2968
2968
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
2969
2969
|
uniform sampler2D envMap;
|
|
@@ -2985,14 +2985,14 @@ void main() {
|
|
|
2985
2985
|
gl_FragColor = texColor;
|
|
2986
2986
|
#include <tonemapping_fragment>
|
|
2987
2987
|
#include <colorspace_fragment>
|
|
2988
|
-
}`,
|
|
2988
|
+
}`,vm=`varying vec3 vWorldDirection;
|
|
2989
2989
|
#include <common>
|
|
2990
2990
|
void main() {
|
|
2991
2991
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2992
2992
|
#include <begin_vertex>
|
|
2993
2993
|
#include <project_vertex>
|
|
2994
2994
|
gl_Position.z = gl_Position.w;
|
|
2995
|
-
}`,
|
|
2995
|
+
}`,xm=`uniform samplerCube tCube;
|
|
2996
2996
|
uniform float tFlip;
|
|
2997
2997
|
uniform float opacity;
|
|
2998
2998
|
varying vec3 vWorldDirection;
|
|
@@ -3002,7 +3002,7 @@ void main() {
|
|
|
3002
3002
|
gl_FragColor.a *= opacity;
|
|
3003
3003
|
#include <tonemapping_fragment>
|
|
3004
3004
|
#include <colorspace_fragment>
|
|
3005
|
-
}`,
|
|
3005
|
+
}`,Sm=`#include <common>
|
|
3006
3006
|
#include <batching_pars_vertex>
|
|
3007
3007
|
#include <uv_pars_vertex>
|
|
3008
3008
|
#include <displacementmap_pars_vertex>
|
|
@@ -3029,7 +3029,7 @@ void main() {
|
|
|
3029
3029
|
#include <logdepthbuf_vertex>
|
|
3030
3030
|
#include <clipping_planes_vertex>
|
|
3031
3031
|
vHighPrecisionZW = gl_Position.zw;
|
|
3032
|
-
}`,
|
|
3032
|
+
}`,Mm=`#if DEPTH_PACKING == 3200
|
|
3033
3033
|
uniform float opacity;
|
|
3034
3034
|
#endif
|
|
3035
3035
|
#include <common>
|
|
@@ -3067,7 +3067,7 @@ void main() {
|
|
|
3067
3067
|
#elif DEPTH_PACKING == 3203
|
|
3068
3068
|
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
|
|
3069
3069
|
#endif
|
|
3070
|
-
}`,
|
|
3070
|
+
}`,ym=`#define DISTANCE
|
|
3071
3071
|
varying vec3 vWorldPosition;
|
|
3072
3072
|
#include <common>
|
|
3073
3073
|
#include <batching_pars_vertex>
|
|
@@ -3094,7 +3094,7 @@ void main() {
|
|
|
3094
3094
|
#include <worldpos_vertex>
|
|
3095
3095
|
#include <clipping_planes_vertex>
|
|
3096
3096
|
vWorldPosition = worldPosition.xyz;
|
|
3097
|
-
}`,
|
|
3097
|
+
}`,Em=`#define DISTANCE
|
|
3098
3098
|
uniform vec3 referencePosition;
|
|
3099
3099
|
uniform float nearDistance;
|
|
3100
3100
|
uniform float farDistance;
|
|
@@ -3117,13 +3117,13 @@ void main() {
|
|
|
3117
3117
|
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
|
3118
3118
|
dist = saturate( dist );
|
|
3119
3119
|
gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
|
|
3120
|
-
}`,
|
|
3120
|
+
}`,bm=`varying vec3 vWorldDirection;
|
|
3121
3121
|
#include <common>
|
|
3122
3122
|
void main() {
|
|
3123
3123
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
3124
3124
|
#include <begin_vertex>
|
|
3125
3125
|
#include <project_vertex>
|
|
3126
|
-
}`,
|
|
3126
|
+
}`,Tm=`uniform sampler2D tEquirect;
|
|
3127
3127
|
varying vec3 vWorldDirection;
|
|
3128
3128
|
#include <common>
|
|
3129
3129
|
void main() {
|
|
@@ -3132,7 +3132,7 @@ void main() {
|
|
|
3132
3132
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
3133
3133
|
#include <tonemapping_fragment>
|
|
3134
3134
|
#include <colorspace_fragment>
|
|
3135
|
-
}`,
|
|
3135
|
+
}`,Am=`uniform float scale;
|
|
3136
3136
|
attribute float lineDistance;
|
|
3137
3137
|
varying float vLineDistance;
|
|
3138
3138
|
#include <common>
|
|
@@ -3154,7 +3154,7 @@ void main() {
|
|
|
3154
3154
|
#include <logdepthbuf_vertex>
|
|
3155
3155
|
#include <clipping_planes_vertex>
|
|
3156
3156
|
#include <fog_vertex>
|
|
3157
|
-
}`,
|
|
3157
|
+
}`,wm=`uniform vec3 diffuse;
|
|
3158
3158
|
uniform float opacity;
|
|
3159
3159
|
uniform float dashSize;
|
|
3160
3160
|
uniform float totalSize;
|
|
@@ -3182,7 +3182,7 @@ void main() {
|
|
|
3182
3182
|
#include <colorspace_fragment>
|
|
3183
3183
|
#include <fog_fragment>
|
|
3184
3184
|
#include <premultiplied_alpha_fragment>
|
|
3185
|
-
}`,
|
|
3185
|
+
}`,Rm=`#include <common>
|
|
3186
3186
|
#include <batching_pars_vertex>
|
|
3187
3187
|
#include <uv_pars_vertex>
|
|
3188
3188
|
#include <envmap_pars_vertex>
|
|
@@ -3214,7 +3214,7 @@ void main() {
|
|
|
3214
3214
|
#include <worldpos_vertex>
|
|
3215
3215
|
#include <envmap_vertex>
|
|
3216
3216
|
#include <fog_vertex>
|
|
3217
|
-
}`,
|
|
3217
|
+
}`,Cm=`uniform vec3 diffuse;
|
|
3218
3218
|
uniform float opacity;
|
|
3219
3219
|
#ifndef FLAT_SHADED
|
|
3220
3220
|
varying vec3 vNormal;
|
|
@@ -3262,7 +3262,7 @@ void main() {
|
|
|
3262
3262
|
#include <fog_fragment>
|
|
3263
3263
|
#include <premultiplied_alpha_fragment>
|
|
3264
3264
|
#include <dithering_fragment>
|
|
3265
|
-
}`,
|
|
3265
|
+
}`,Pm=`#define LAMBERT
|
|
3266
3266
|
varying vec3 vViewPosition;
|
|
3267
3267
|
#include <common>
|
|
3268
3268
|
#include <batching_pars_vertex>
|
|
@@ -3301,7 +3301,7 @@ void main() {
|
|
|
3301
3301
|
#include <envmap_vertex>
|
|
3302
3302
|
#include <shadowmap_vertex>
|
|
3303
3303
|
#include <fog_vertex>
|
|
3304
|
-
}`,
|
|
3304
|
+
}`,Im=`#define LAMBERT
|
|
3305
3305
|
uniform vec3 diffuse;
|
|
3306
3306
|
uniform vec3 emissive;
|
|
3307
3307
|
uniform float opacity;
|
|
@@ -3359,7 +3359,7 @@ void main() {
|
|
|
3359
3359
|
#include <fog_fragment>
|
|
3360
3360
|
#include <premultiplied_alpha_fragment>
|
|
3361
3361
|
#include <dithering_fragment>
|
|
3362
|
-
}`,
|
|
3362
|
+
}`,Dm=`#define MATCAP
|
|
3363
3363
|
varying vec3 vViewPosition;
|
|
3364
3364
|
#include <common>
|
|
3365
3365
|
#include <batching_pars_vertex>
|
|
@@ -3393,7 +3393,7 @@ void main() {
|
|
|
3393
3393
|
#include <clipping_planes_vertex>
|
|
3394
3394
|
#include <fog_vertex>
|
|
3395
3395
|
vViewPosition = - mvPosition.xyz;
|
|
3396
|
-
}`,
|
|
3396
|
+
}`,Lm=`#define MATCAP
|
|
3397
3397
|
uniform vec3 diffuse;
|
|
3398
3398
|
uniform float opacity;
|
|
3399
3399
|
uniform sampler2D matcap;
|
|
@@ -3439,7 +3439,7 @@ void main() {
|
|
|
3439
3439
|
#include <fog_fragment>
|
|
3440
3440
|
#include <premultiplied_alpha_fragment>
|
|
3441
3441
|
#include <dithering_fragment>
|
|
3442
|
-
}`,
|
|
3442
|
+
}`,Um=`#define NORMAL
|
|
3443
3443
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3444
3444
|
varying vec3 vViewPosition;
|
|
3445
3445
|
#endif
|
|
@@ -3472,7 +3472,7 @@ void main() {
|
|
|
3472
3472
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3473
3473
|
vViewPosition = - mvPosition.xyz;
|
|
3474
3474
|
#endif
|
|
3475
|
-
}`,
|
|
3475
|
+
}`,Nm=`#define NORMAL
|
|
3476
3476
|
uniform float opacity;
|
|
3477
3477
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3478
3478
|
varying vec3 vViewPosition;
|
|
@@ -3493,7 +3493,7 @@ void main() {
|
|
|
3493
3493
|
#ifdef OPAQUE
|
|
3494
3494
|
gl_FragColor.a = 1.0;
|
|
3495
3495
|
#endif
|
|
3496
|
-
}`,
|
|
3496
|
+
}`,Fm=`#define PHONG
|
|
3497
3497
|
varying vec3 vViewPosition;
|
|
3498
3498
|
#include <common>
|
|
3499
3499
|
#include <batching_pars_vertex>
|
|
@@ -3532,7 +3532,7 @@ void main() {
|
|
|
3532
3532
|
#include <envmap_vertex>
|
|
3533
3533
|
#include <shadowmap_vertex>
|
|
3534
3534
|
#include <fog_vertex>
|
|
3535
|
-
}`,
|
|
3535
|
+
}`,Om=`#define PHONG
|
|
3536
3536
|
uniform vec3 diffuse;
|
|
3537
3537
|
uniform vec3 emissive;
|
|
3538
3538
|
uniform vec3 specular;
|
|
@@ -3592,7 +3592,7 @@ void main() {
|
|
|
3592
3592
|
#include <fog_fragment>
|
|
3593
3593
|
#include <premultiplied_alpha_fragment>
|
|
3594
3594
|
#include <dithering_fragment>
|
|
3595
|
-
}`,
|
|
3595
|
+
}`,Bm=`#define STANDARD
|
|
3596
3596
|
varying vec3 vViewPosition;
|
|
3597
3597
|
#ifdef USE_TRANSMISSION
|
|
3598
3598
|
varying vec3 vWorldPosition;
|
|
@@ -3635,7 +3635,7 @@ void main() {
|
|
|
3635
3635
|
#ifdef USE_TRANSMISSION
|
|
3636
3636
|
vWorldPosition = worldPosition.xyz;
|
|
3637
3637
|
#endif
|
|
3638
|
-
}`,
|
|
3638
|
+
}`,zm=`#define STANDARD
|
|
3639
3639
|
#ifdef PHYSICAL
|
|
3640
3640
|
#define IOR
|
|
3641
3641
|
#define USE_SPECULAR
|
|
@@ -3760,7 +3760,7 @@ void main() {
|
|
|
3760
3760
|
#include <fog_fragment>
|
|
3761
3761
|
#include <premultiplied_alpha_fragment>
|
|
3762
3762
|
#include <dithering_fragment>
|
|
3763
|
-
}`,
|
|
3763
|
+
}`,km=`#define TOON
|
|
3764
3764
|
varying vec3 vViewPosition;
|
|
3765
3765
|
#include <common>
|
|
3766
3766
|
#include <batching_pars_vertex>
|
|
@@ -3797,7 +3797,7 @@ void main() {
|
|
|
3797
3797
|
#include <worldpos_vertex>
|
|
3798
3798
|
#include <shadowmap_vertex>
|
|
3799
3799
|
#include <fog_vertex>
|
|
3800
|
-
}`,
|
|
3800
|
+
}`,Gm=`#define TOON
|
|
3801
3801
|
uniform vec3 diffuse;
|
|
3802
3802
|
uniform vec3 emissive;
|
|
3803
3803
|
uniform float opacity;
|
|
@@ -3849,7 +3849,7 @@ void main() {
|
|
|
3849
3849
|
#include <fog_fragment>
|
|
3850
3850
|
#include <premultiplied_alpha_fragment>
|
|
3851
3851
|
#include <dithering_fragment>
|
|
3852
|
-
}`,
|
|
3852
|
+
}`,Hm=`uniform float size;
|
|
3853
3853
|
uniform float scale;
|
|
3854
3854
|
#include <common>
|
|
3855
3855
|
#include <color_pars_vertex>
|
|
@@ -3880,7 +3880,7 @@ void main() {
|
|
|
3880
3880
|
#include <clipping_planes_vertex>
|
|
3881
3881
|
#include <worldpos_vertex>
|
|
3882
3882
|
#include <fog_vertex>
|
|
3883
|
-
}`,
|
|
3883
|
+
}`,Vm=`uniform vec3 diffuse;
|
|
3884
3884
|
uniform float opacity;
|
|
3885
3885
|
#include <common>
|
|
3886
3886
|
#include <color_pars_fragment>
|
|
@@ -3905,7 +3905,7 @@ void main() {
|
|
|
3905
3905
|
#include <colorspace_fragment>
|
|
3906
3906
|
#include <fog_fragment>
|
|
3907
3907
|
#include <premultiplied_alpha_fragment>
|
|
3908
|
-
}`,
|
|
3908
|
+
}`,Wm=`#include <common>
|
|
3909
3909
|
#include <batching_pars_vertex>
|
|
3910
3910
|
#include <fog_pars_vertex>
|
|
3911
3911
|
#include <morphtarget_pars_vertex>
|
|
@@ -3928,7 +3928,7 @@ void main() {
|
|
|
3928
3928
|
#include <worldpos_vertex>
|
|
3929
3929
|
#include <shadowmap_vertex>
|
|
3930
3930
|
#include <fog_vertex>
|
|
3931
|
-
}`,
|
|
3931
|
+
}`,Xm=`uniform vec3 color;
|
|
3932
3932
|
uniform float opacity;
|
|
3933
3933
|
#include <common>
|
|
3934
3934
|
#include <fog_pars_fragment>
|
|
@@ -3944,7 +3944,7 @@ void main() {
|
|
|
3944
3944
|
#include <colorspace_fragment>
|
|
3945
3945
|
#include <fog_fragment>
|
|
3946
3946
|
#include <premultiplied_alpha_fragment>
|
|
3947
|
-
}`,
|
|
3947
|
+
}`,qm=`uniform float rotation;
|
|
3948
3948
|
uniform vec2 center;
|
|
3949
3949
|
#include <common>
|
|
3950
3950
|
#include <uv_pars_vertex>
|
|
@@ -3968,7 +3968,7 @@ void main() {
|
|
|
3968
3968
|
#include <logdepthbuf_vertex>
|
|
3969
3969
|
#include <clipping_planes_vertex>
|
|
3970
3970
|
#include <fog_vertex>
|
|
3971
|
-
}`,
|
|
3971
|
+
}`,Ym=`uniform vec3 diffuse;
|
|
3972
3972
|
uniform float opacity;
|
|
3973
3973
|
#include <common>
|
|
3974
3974
|
#include <uv_pars_fragment>
|
|
@@ -3993,7 +3993,7 @@ void main() {
|
|
|
3993
3993
|
#include <tonemapping_fragment>
|
|
3994
3994
|
#include <colorspace_fragment>
|
|
3995
3995
|
#include <fog_fragment>
|
|
3996
|
-
}`,Ht={alphahash_fragment:gf,alphahash_pars_fragment:_f,alphamap_fragment:vf,alphamap_pars_fragment:xf,alphatest_fragment:Sf,alphatest_pars_fragment:Mf,aomap_fragment:yf,aomap_pars_fragment:Ef,batching_pars_vertex:bf,batching_vertex:Tf,begin_vertex:Af,beginnormal_vertex:wf,bsdfs:Rf,iridescence_fragment:Cf,bumpmap_pars_fragment:Pf,clipping_planes_fragment:If,clipping_planes_pars_fragment:Df,clipping_planes_pars_vertex:Lf,clipping_planes_vertex:Uf,color_fragment:Nf,color_pars_fragment:Ff,color_pars_vertex:Of,color_vertex:Bf,common:zf,cube_uv_reflection_fragment:kf,defaultnormal_vertex:Hf,displacementmap_pars_vertex:Gf,displacementmap_vertex:Vf,emissivemap_fragment:Wf,emissivemap_pars_fragment:Xf,colorspace_fragment:qf,colorspace_pars_fragment:Yf,envmap_fragment:Zf,envmap_common_pars_fragment:Kf,envmap_pars_fragment:$f,envmap_pars_vertex:Jf,envmap_physical_pars_fragment:lp,envmap_vertex:Qf,fog_vertex:jf,fog_pars_vertex:tp,fog_fragment:ep,fog_pars_fragment:np,gradientmap_pars_fragment:ip,lightmap_pars_fragment:sp,lights_lambert_fragment:rp,lights_lambert_pars_fragment:ap,lights_pars_begin:op,lights_toon_fragment:cp,lights_toon_pars_fragment:hp,lights_phong_fragment:up,lights_phong_pars_fragment:dp,lights_physical_fragment:fp,lights_physical_pars_fragment:pp,lights_fragment_begin:mp,lights_fragment_maps:gp,lights_fragment_end:_p,lightprobes_pars_fragment:vp,logdepthbuf_fragment:xp,logdepthbuf_pars_fragment:Sp,logdepthbuf_pars_vertex:Mp,logdepthbuf_vertex:yp,map_fragment:Ep,map_pars_fragment:bp,map_particle_fragment:Tp,map_particle_pars_fragment:Ap,metalnessmap_fragment:wp,metalnessmap_pars_fragment:Rp,morphinstance_vertex:Cp,morphcolor_vertex:Pp,morphnormal_vertex:Ip,morphtarget_pars_vertex:Dp,morphtarget_vertex:Lp,normal_fragment_begin:Up,normal_fragment_maps:Np,normal_pars_fragment:Fp,normal_pars_vertex:Op,normal_vertex:Bp,normalmap_pars_fragment:zp,clearcoat_normal_fragment_begin:kp,clearcoat_normal_fragment_maps:Hp,clearcoat_pars_fragment:Gp,iridescence_pars_fragment:Vp,opaque_fragment:Wp,packing:Xp,premultiplied_alpha_fragment:qp,project_vertex:Yp,dithering_fragment:Zp,dithering_pars_fragment:Kp,roughnessmap_fragment:$p,roughnessmap_pars_fragment:Jp,shadowmap_pars_fragment:Qp,shadowmap_pars_vertex:jp,shadowmap_vertex:tm,shadowmask_pars_fragment:em,skinbase_vertex:nm,skinning_pars_vertex:im,skinning_vertex:sm,skinnormal_vertex:rm,specularmap_fragment:am,specularmap_pars_fragment:om,tonemapping_fragment:lm,tonemapping_pars_fragment:cm,transmission_fragment:hm,transmission_pars_fragment:um,uv_pars_fragment:dm,uv_pars_vertex:fm,uv_vertex:pm,worldpos_vertex:mm,background_vert:gm,background_frag:_m,backgroundCube_vert:vm,backgroundCube_frag:xm,cube_vert:Sm,cube_frag:Mm,depth_vert:ym,depth_frag:Em,distance_vert:bm,distance_frag:Tm,equirect_vert:Am,equirect_frag:wm,linedashed_vert:Rm,linedashed_frag:Cm,meshbasic_vert:Pm,meshbasic_frag:Im,meshlambert_vert:Dm,meshlambert_frag:Lm,meshmatcap_vert:Um,meshmatcap_frag:Nm,meshnormal_vert:Fm,meshnormal_frag:Om,meshphong_vert:Bm,meshphong_frag:zm,meshphysical_vert:km,meshphysical_frag:Hm,meshtoon_vert:Gm,meshtoon_frag:Vm,points_vert:Wm,points_frag:Xm,shadow_vert:qm,shadow_frag:Ym,sprite_vert:Zm,sprite_frag:Km},dt={common:{diffuse:{value:new It(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ot},alphaMap:{value:null},alphaMapTransform:{value:new Ot},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ot}},envmap:{envMap:{value:null},envMapRotation:{value:new Ot},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ot}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ot}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ot},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ot},normalScale:{value:new kt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ot},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ot}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ot}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ot}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new It(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new F},probesMax:{value:new F},probesResolution:{value:new F}},points:{diffuse:{value:new It(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ot},alphaTest:{value:0},uvTransform:{value:new Ot}},sprite:{diffuse:{value:new It(16777215)},opacity:{value:1},center:{value:new kt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ot},alphaMap:{value:null},alphaMapTransform:{value:new Ot},alphaTest:{value:0}}},hn={basic:{uniforms:Ne([dt.common,dt.specularmap,dt.envmap,dt.aomap,dt.lightmap,dt.fog]),vertexShader:Ht.meshbasic_vert,fragmentShader:Ht.meshbasic_frag},lambert:{uniforms:Ne([dt.common,dt.specularmap,dt.envmap,dt.aomap,dt.lightmap,dt.emissivemap,dt.bumpmap,dt.normalmap,dt.displacementmap,dt.fog,dt.lights,{emissive:{value:new It(0)},envMapIntensity:{value:1}}]),vertexShader:Ht.meshlambert_vert,fragmentShader:Ht.meshlambert_frag},phong:{uniforms:Ne([dt.common,dt.specularmap,dt.envmap,dt.aomap,dt.lightmap,dt.emissivemap,dt.bumpmap,dt.normalmap,dt.displacementmap,dt.fog,dt.lights,{emissive:{value:new It(0)},specular:{value:new It(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ht.meshphong_vert,fragmentShader:Ht.meshphong_frag},standard:{uniforms:Ne([dt.common,dt.envmap,dt.aomap,dt.lightmap,dt.emissivemap,dt.bumpmap,dt.normalmap,dt.displacementmap,dt.roughnessmap,dt.metalnessmap,dt.fog,dt.lights,{emissive:{value:new It(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ht.meshphysical_vert,fragmentShader:Ht.meshphysical_frag},toon:{uniforms:Ne([dt.common,dt.aomap,dt.lightmap,dt.emissivemap,dt.bumpmap,dt.normalmap,dt.displacementmap,dt.gradientmap,dt.fog,dt.lights,{emissive:{value:new It(0)}}]),vertexShader:Ht.meshtoon_vert,fragmentShader:Ht.meshtoon_frag},matcap:{uniforms:Ne([dt.common,dt.bumpmap,dt.normalmap,dt.displacementmap,dt.fog,{matcap:{value:null}}]),vertexShader:Ht.meshmatcap_vert,fragmentShader:Ht.meshmatcap_frag},points:{uniforms:Ne([dt.points,dt.fog]),vertexShader:Ht.points_vert,fragmentShader:Ht.points_frag},dashed:{uniforms:Ne([dt.common,dt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ht.linedashed_vert,fragmentShader:Ht.linedashed_frag},depth:{uniforms:Ne([dt.common,dt.displacementmap]),vertexShader:Ht.depth_vert,fragmentShader:Ht.depth_frag},normal:{uniforms:Ne([dt.common,dt.bumpmap,dt.normalmap,dt.displacementmap,{opacity:{value:1}}]),vertexShader:Ht.meshnormal_vert,fragmentShader:Ht.meshnormal_frag},sprite:{uniforms:Ne([dt.sprite,dt.fog]),vertexShader:Ht.sprite_vert,fragmentShader:Ht.sprite_frag},background:{uniforms:{uvTransform:{value:new Ot},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ht.background_vert,fragmentShader:Ht.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ot}},vertexShader:Ht.backgroundCube_vert,fragmentShader:Ht.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ht.cube_vert,fragmentShader:Ht.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ht.equirect_vert,fragmentShader:Ht.equirect_frag},distance:{uniforms:Ne([dt.common,dt.displacementmap,{referencePosition:{value:new F},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ht.distance_vert,fragmentShader:Ht.distance_frag},shadow:{uniforms:Ne([dt.lights,dt.fog,{color:{value:new It(0)},opacity:{value:1}}]),vertexShader:Ht.shadow_vert,fragmentShader:Ht.shadow_frag}};hn.physical={uniforms:Ne([hn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ot},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ot},clearcoatNormalScale:{value:new kt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ot},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ot},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ot},sheen:{value:0},sheenColor:{value:new It(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ot},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ot},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ot},transmissionSamplerSize:{value:new kt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ot},attenuationDistance:{value:0},attenuationColor:{value:new It(0)},specularColor:{value:new It(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ot},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ot},anisotropyVector:{value:new kt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ot}}]),vertexShader:Ht.meshphysical_vert,fragmentShader:Ht.meshphysical_frag};const or={r:0,b:0,g:0},$m=new le,bu=new Ot;bu.set(-1,0,0,0,1,0,0,0,1);function Jm(i,t,e,n,s,r){const a=new It(0);let o=s===!0?0:1,l,c,h=null,d=0,u=null;function p(A){let w=A.isScene===!0?A.background:null;if(w&&w.isTexture){const S=A.backgroundBlurriness>0;w=t.get(w,S)}return w}function _(A){let w=!1;const S=p(A);S===null?m(a,o):S&&S.isColor&&(m(S,1),w=!0);const y=i.xr.getEnvironmentBlendMode();y==="additive"?e.buffers.color.setClear(0,0,0,1,r):y==="alpha-blend"&&e.buffers.color.setClear(0,0,0,0,r),(i.autoClear||w)&&(e.buffers.depth.setTest(!0),e.buffers.depth.setMask(!0),e.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function M(A,w){const S=p(w);S&&(S.isCubeTexture||S.mapping===Jr)?(c===void 0&&(c=new Ge(new Cs(1,1,1),new Ve({name:"BackgroundCubeMaterial",uniforms:Qi(hn.backgroundCube.uniforms),vertexShader:hn.backgroundCube.vertexShader,fragmentShader:hn.backgroundCube.fragmentShader,side:Fe,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(y,b,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=S,c.material.uniforms.backgroundBlurriness.value=w.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4($m.makeRotationFromEuler(w.backgroundRotation)).transpose(),S.isCubeTexture&&S.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(bu),c.material.toneMapped=qt.getTransfer(S.colorSpace)!==Qt,(h!==S||d!==S.version||u!==i.toneMapping)&&(c.material.needsUpdate=!0,h=S,d=S.version,u=i.toneMapping),c.layers.enableAll(),A.unshift(c,c.geometry,c.material,0,0,null)):S&&S.isTexture&&(l===void 0&&(l=new Ge(new jr(2,2),new Ve({name:"BackgroundMaterial",uniforms:Qi(hn.background.uniforms),vertexShader:hn.background.vertexShader,fragmentShader:hn.background.fragmentShader,side:Kn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=S,l.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,l.material.toneMapped=qt.getTransfer(S.colorSpace)!==Qt,S.matrixAutoUpdate===!0&&S.updateMatrix(),l.material.uniforms.uvTransform.value.copy(S.matrix),(h!==S||d!==S.version||u!==i.toneMapping)&&(l.material.needsUpdate=!0,h=S,d=S.version,u=i.toneMapping),l.layers.enableAll(),A.unshift(l,l.geometry,l.material,0,0,null))}function m(A,w){A.getRGB(or,xu(i)),e.buffers.color.setClear(or.r,or.g,or.b,w,r)}function f(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return a},setClearColor:function(A,w=1){a.set(A),o=w,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(A){o=A,m(a,o)},render:_,addToRenderList:M,dispose:f}}function Qm(i,t){const e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=u(null);let r=s,a=!1;function o(C,U,Y,Z,O){let W=!1;const V=d(C,Z,Y,U);r!==V&&(r=V,c(r.object)),W=p(C,Z,Y,O),W&&_(C,Z,Y,O),O!==null&&t.update(O,i.ELEMENT_ARRAY_BUFFER),(W||a)&&(a=!1,S(C,U,Y,Z),O!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get(O).buffer))}function l(){return i.createVertexArray()}function c(C){return i.bindVertexArray(C)}function h(C){return i.deleteVertexArray(C)}function d(C,U,Y,Z){const O=Z.wireframe===!0;let W=n[U.id];W===void 0&&(W={},n[U.id]=W);const V=C.isInstancedMesh===!0?C.id:0;let Q=W[V];Q===void 0&&(Q={},W[V]=Q);let et=Q[Y.id];et===void 0&&(et={},Q[Y.id]=et);let tt=et[O];return tt===void 0&&(tt=u(l()),et[O]=tt),tt}function u(C){const U=[],Y=[],Z=[];for(let O=0;O<e;O++)U[O]=0,Y[O]=0,Z[O]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:U,enabledAttributes:Y,attributeDivisors:Z,object:C,attributes:{},index:null}}function p(C,U,Y,Z){const O=r.attributes,W=U.attributes;let V=0;const Q=Y.getAttributes();for(const et in Q)if(Q[et].location>=0){const st=O[et];let gt=W[et];if(gt===void 0&&(et==="instanceMatrix"&&C.instanceMatrix&&(gt=C.instanceMatrix),et==="instanceColor"&&C.instanceColor&&(gt=C.instanceColor)),st===void 0||st.attribute!==gt||gt&&st.data!==gt.data)return!0;V++}return r.attributesNum!==V||r.index!==Z}function _(C,U,Y,Z){const O={},W=U.attributes;let V=0;const Q=Y.getAttributes();for(const et in Q)if(Q[et].location>=0){let st=W[et];st===void 0&&(et==="instanceMatrix"&&C.instanceMatrix&&(st=C.instanceMatrix),et==="instanceColor"&&C.instanceColor&&(st=C.instanceColor));const gt={};gt.attribute=st,st&&st.data&&(gt.data=st.data),O[et]=gt,V++}r.attributes=O,r.attributesNum=V,r.index=Z}function M(){const C=r.newAttributes;for(let U=0,Y=C.length;U<Y;U++)C[U]=0}function m(C){f(C,0)}function f(C,U){const Y=r.newAttributes,Z=r.enabledAttributes,O=r.attributeDivisors;Y[C]=1,Z[C]===0&&(i.enableVertexAttribArray(C),Z[C]=1),O[C]!==U&&(i.vertexAttribDivisor(C,U),O[C]=U)}function A(){const C=r.newAttributes,U=r.enabledAttributes;for(let Y=0,Z=U.length;Y<Z;Y++)U[Y]!==C[Y]&&(i.disableVertexAttribArray(Y),U[Y]=0)}function w(C,U,Y,Z,O,W,V){V===!0?i.vertexAttribIPointer(C,U,Y,O,W):i.vertexAttribPointer(C,U,Y,Z,O,W)}function S(C,U,Y,Z){M();const O=Z.attributes,W=Y.getAttributes(),V=U.defaultAttributeValues;for(const Q in W){const et=W[Q];if(et.location>=0){let tt=O[Q];if(tt===void 0&&(Q==="instanceMatrix"&&C.instanceMatrix&&(tt=C.instanceMatrix),Q==="instanceColor"&&C.instanceColor&&(tt=C.instanceColor)),tt!==void 0){const st=tt.normalized,gt=tt.itemSize,Vt=t.get(tt);if(Vt===void 0)continue;const se=Vt.buffer,Wt=Vt.type,K=Vt.bytesPerElement,rt=Wt===i.INT||Wt===i.UNSIGNED_INT||tt.gpuType===ml;if(tt.isInterleavedBufferAttribute){const nt=tt.data,k=nt.stride,Ct=tt.offset;if(nt.isInstancedInterleavedBuffer){for(let Pt=0;Pt<et.locationSize;Pt++)f(et.location+Pt,nt.meshPerAttribute);C.isInstancedMesh!==!0&&Z._maxInstanceCount===void 0&&(Z._maxInstanceCount=nt.meshPerAttribute*nt.count)}else for(let Pt=0;Pt<et.locationSize;Pt++)m(et.location+Pt);i.bindBuffer(i.ARRAY_BUFFER,se);for(let Pt=0;Pt<et.locationSize;Pt++)w(et.location+Pt,gt/et.locationSize,Wt,st,k*K,(Ct+gt/et.locationSize*Pt)*K,rt)}else{if(tt.isInstancedBufferAttribute){for(let nt=0;nt<et.locationSize;nt++)f(et.location+nt,tt.meshPerAttribute);C.isInstancedMesh!==!0&&Z._maxInstanceCount===void 0&&(Z._maxInstanceCount=tt.meshPerAttribute*tt.count)}else for(let nt=0;nt<et.locationSize;nt++)m(et.location+nt);i.bindBuffer(i.ARRAY_BUFFER,se);for(let nt=0;nt<et.locationSize;nt++)w(et.location+nt,gt/et.locationSize,Wt,st,gt*K,gt/et.locationSize*nt*K,rt)}}else if(V!==void 0){const st=V[Q];if(st!==void 0)switch(st.length){case 2:i.vertexAttrib2fv(et.location,st);break;case 3:i.vertexAttrib3fv(et.location,st);break;case 4:i.vertexAttrib4fv(et.location,st);break;default:i.vertexAttrib1fv(et.location,st)}}}}A()}function y(){T();for(const C in n){const U=n[C];for(const Y in U){const Z=U[Y];for(const O in Z){const W=Z[O];for(const V in W)h(W[V].object),delete W[V];delete Z[O]}}delete n[C]}}function b(C){if(n[C.id]===void 0)return;const U=n[C.id];for(const Y in U){const Z=U[Y];for(const O in Z){const W=Z[O];for(const V in W)h(W[V].object),delete W[V];delete Z[O]}}delete n[C.id]}function R(C){for(const U in n){const Y=n[U];for(const Z in Y){const O=Y[Z];if(O[C.id]===void 0)continue;const W=O[C.id];for(const V in W)h(W[V].object),delete W[V];delete O[C.id]}}}function v(C){for(const U in n){const Y=n[U],Z=C.isInstancedMesh===!0?C.id:0,O=Y[Z];if(O!==void 0){for(const W in O){const V=O[W];for(const Q in V)h(V[Q].object),delete V[Q];delete O[W]}delete Y[Z],Object.keys(Y).length===0&&delete n[U]}}}function T(){I(),a=!0,r!==s&&(r=s,c(r.object))}function I(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:T,resetDefaultState:I,dispose:y,releaseStatesOfGeometry:b,releaseStatesOfObject:v,releaseStatesOfProgram:R,initAttributes:M,enableAttribute:m,disableUnusedAttributes:A}}function jm(i,t,e){let n;function s(l){n=l}function r(l,c){i.drawArrays(n,l,c),e.update(c,n,1)}function a(l,c,h){h!==0&&(i.drawArraysInstanced(n,l,c,h),e.update(c,n,h))}function o(l,c,h){if(h===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,c,0,h);let u=0;for(let p=0;p<h;p++)u+=c[p];e.update(u,n,1)}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function tg(i,t,e,n){let s;function r(){if(s!==void 0)return s;if(t.has("EXT_texture_filter_anisotropic")===!0){const R=t.get("EXT_texture_filter_anisotropic");s=i.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function a(R){return!(R!==sn&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(R){const v=R===Cn&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(R!==$e&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==dn&&!v)}function l(R){if(R==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=e.precision!==void 0?e.precision:"highp";const h=l(c);h!==c&&(Ft("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const d=e.logarithmicDepthBuffer===!0,u=e.reversedDepthBuffer===!0&&t.has("EXT_clip_control");e.reversedDepthBuffer===!0&&u===!1&&Ft("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),_=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),A=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),w=i.getParameter(i.MAX_VARYING_VECTORS),S=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),y=i.getParameter(i.MAX_SAMPLES),b=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:u,maxTextures:p,maxVertexTextures:_,maxTextureSize:M,maxCubemapSize:m,maxAttributes:f,maxVertexUniforms:A,maxVaryings:w,maxFragmentUniforms:S,maxSamples:y,samples:b}}function eg(i){const t=this;let e=null,n=0,s=!1,r=!1;const a=new ei,o=new Ot,l={value:null,needsUpdate:!1};this.uniform=l,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){e=h(d,u,0)},this.setState=function(d,u,p){const _=d.clippingPlanes,M=d.clipIntersection,m=d.clipShadows,f=i.get(d);if(!s||_===null||_.length===0||r&&!m)r?h(null):c();else{const A=r?0:n,w=A*4;let S=f.clippingState||null;l.value=S,S=h(_,u,w,p);for(let y=0;y!==w;++y)S[y]=e[y];f.clippingState=S,this.numIntersection=M?this.numPlanes:0,this.numPlanes+=A}};function c(){l.value!==e&&(l.value=e,l.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(d,u,p,_){const M=d!==null?d.length:0;let m=null;if(M!==0){if(m=l.value,_!==!0||m===null){const f=p+M*4,A=u.matrixWorldInverse;o.getNormalMatrix(A),(m===null||m.length<f)&&(m=new Float32Array(f));for(let w=0,S=p;w!==M;++w,S+=4)a.copy(d[w]).applyMatrix4(A,o),a.normal.toArray(m,S),m[S+3]=a.constant}l.value=m,l.needsUpdate=!0}return t.numPlanes=M,t.numIntersection=0,m}}const Xn=4,Tc=[.125,.215,.35,.446,.526,.582],ii=20,ng=256,fs=new Mu,Ac=new It;let Ua=null,Na=0,Fa=0,Oa=!1;const ig=new F;class wc{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(t,e=0,n=.1,s=100,r={}){const{size:a=256,position:o=ig}=r;Ua=this._renderer.getRenderTarget(),Na=this._renderer.getActiveCubeFace(),Fa=this._renderer.getActiveMipmapLevel(),Oa=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(t,n,s,l,o),e>0&&this._blur(l,0,0,e),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Pc(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Cc(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodMeshes.length;t++)this._lodMeshes[t].geometry.dispose()}_cleanup(t){this._renderer.setRenderTarget(Ua,Na,Fa),this._renderer.xr.enabled=Oa,t.scissorTest=!1,Li(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===ci||t.mapping===$i?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Ua=this._renderer.getRenderTarget(),Na=this._renderer.getActiveCubeFace(),Fa=this._renderer.getActiveMipmapLevel(),Oa=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:Ie,minFilter:Ie,generateMipmaps:!1,type:Cn,format:sn,colorSpace:Nr,depthBuffer:!1},s=Rc(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Rc(t,e,n);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=sg(r)),this._blurMaterial=ag(r,t,e),this._ggxMaterial=rg(r,t,e)}return s}_compileMaterial(t){const e=new Ge(new Te,t);this._renderer.compile(e,fs)}_sceneToCubeUV(t,e,n,s,r){const l=new Ke(90,1,e,n),c=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],d=this._renderer,u=d.autoClear,p=d.toneMapping;d.getClearColor(Ac),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 Ge(new Cs,new qi({name:"PMREM.Background",side:Fe,depthWrite:!1,depthTest:!1})));const M=this._backgroundBox,m=M.material;let f=!1;const A=t.background;A?A.isColor&&(m.color.copy(A),t.background=null,f=!0):(m.color.copy(Ac),f=!0);for(let w=0;w<6;w++){const S=w%3;S===0?(l.up.set(0,c[w],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x+h[w],r.y,r.z)):S===1?(l.up.set(0,0,c[w]),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y+h[w],r.z)):(l.up.set(0,c[w],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y,r.z+h[w]));const y=this._cubeSize;Li(s,S*y,w>2?y:0,y,y),d.setRenderTarget(s),f&&d.render(M,l),d.render(t,l)}d.toneMapping=p,d.autoClear=u,t.background=A}_textureToCubeUV(t,e){const n=this._renderer,s=t.mapping===ci||t.mapping===$i;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Pc()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Cc());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=t;const l=this._cubeSize;Li(e,0,0,3*l,2*l),n.setRenderTarget(e),n.render(a,fs)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const s=this._lodMeshes.length;for(let r=1;r<s;r++)this._applyGGXFilter(t,r-1,r);e.autoClear=n}_applyGGXFilter(t,e,n){const s=this._renderer,r=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;const l=a.uniforms,c=n/(this._lodMeshes.length-1),h=e/(this._lodMeshes.length-1),d=Math.sqrt(c*c-h*h),u=0+c*1.25,p=d*u,{_lodMax:_}=this,M=this._sizeLods[n],m=3*M*(n>_-Xn?n-_+Xn:0),f=4*(this._cubeSize-M);l.envMap.value=t.texture,l.roughness.value=p,l.mipInt.value=_-e,Li(r,m,f,3*M,2*M),s.setRenderTarget(r),s.render(o,fs),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=_-n,Li(t,m,f,3*M,2*M),s.setRenderTarget(t),s.render(o,fs)}_blur(t,e,n,s,r){const a=this._pingPongRenderTarget;this._halfBlur(t,a,e,n,s,"latitudinal",r),this._halfBlur(a,t,n,n,s,"longitudinal",r)}_halfBlur(t,e,n,s,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Xt("blur direction must be either latitudinal or longitudinal!");const h=3,d=this._lodMeshes[s];d.material=c;const u=c.uniforms,p=this._sizeLods[n]-1,_=isFinite(r)?Math.PI/(2*p):2*Math.PI/(2*ii-1),M=r/_,m=isFinite(r)?1+Math.floor(h*M):ii;m>ii&&Ft(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${ii}`);const f=[];let A=0;for(let R=0;R<ii;++R){const v=R/M,T=Math.exp(-v*v/2);f.push(T),R===0?A+=T:R<m&&(A+=2*T)}for(let R=0;R<f.length;R++)f[R]=f[R]/A;u.envMap.value=t.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=_,u.mipInt.value=w-n;const S=this._sizeLods[s],y=3*S*(s>w-Xn?s-w+Xn:0),b=4*(this._cubeSize-S);Li(e,y,b,3*S,2*S),l.setRenderTarget(e),l.render(d,fs)}}function sg(i){const t=[],e=[],n=[];let s=i;const r=i-Xn+1+Tc.length;for(let a=0;a<r;a++){const o=Math.pow(2,s);t.push(o);let l=1/o;a>i-Xn?l=Tc[a-i+Xn-1]:a===0&&(l=0),e.push(l);const c=1/(o-2),h=-c,d=1+c,u=[h,h,d,h,d,d,h,h,d,d,h,d],p=6,_=6,M=3,m=2,f=1,A=new Float32Array(M*_*p),w=new Float32Array(m*_*p),S=new Float32Array(f*_*p);for(let b=0;b<p;b++){const R=b%3*2/3-1,v=b>2?0:-1,T=[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(T,M*_*b),w.set(u,m*_*b);const I=[b,b,b,b,b,b];S.set(I,f*_*b)}const y=new Te;y.setAttribute("position",new pe(A,M)),y.setAttribute("uv",new pe(w,m)),y.setAttribute("faceIndex",new pe(S,f)),n.push(new Ge(y,null)),s>Xn&&s--}return{lodMeshes:n,sizeLods:t,sigmas:e}}function Rc(i,t,e){const n=new mn(i,t,e);return n.texture.mapping=Jr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Li(i,t,e,n,s){i.viewport.set(t,e,n,s),i.scissor.set(t,e,n,s)}function rg(i,t,e){return new Ve({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:ng,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:ta(),fragmentShader:`
|
|
3996
|
+
}`,Ge={alphahash_fragment:pf,alphahash_pars_fragment:mf,alphamap_fragment:gf,alphamap_pars_fragment:_f,alphatest_fragment:vf,alphatest_pars_fragment:xf,aomap_fragment:Sf,aomap_pars_fragment:Mf,batching_pars_vertex:yf,batching_vertex:Ef,begin_vertex:bf,beginnormal_vertex:Tf,bsdfs:Af,iridescence_fragment:wf,bumpmap_pars_fragment:Rf,clipping_planes_fragment:Cf,clipping_planes_pars_fragment:Pf,clipping_planes_pars_vertex:If,clipping_planes_vertex:Df,color_fragment:Lf,color_pars_fragment:Uf,color_pars_vertex:Nf,color_vertex:Ff,common:Of,cube_uv_reflection_fragment:Bf,defaultnormal_vertex:zf,displacementmap_pars_vertex:kf,displacementmap_vertex:Gf,emissivemap_fragment:Hf,emissivemap_pars_fragment:Vf,colorspace_fragment:Wf,colorspace_pars_fragment:Xf,envmap_fragment:qf,envmap_common_pars_fragment:Yf,envmap_pars_fragment:Zf,envmap_pars_vertex:Kf,envmap_physical_pars_fragment:ap,envmap_vertex:$f,fog_vertex:Jf,fog_pars_vertex:Qf,fog_fragment:jf,fog_pars_fragment:ep,gradientmap_pars_fragment:tp,lightmap_pars_fragment:np,lights_lambert_fragment:ip,lights_lambert_pars_fragment:sp,lights_pars_begin:rp,lights_toon_fragment:op,lights_toon_pars_fragment:lp,lights_phong_fragment:cp,lights_phong_pars_fragment:hp,lights_physical_fragment:up,lights_physical_pars_fragment:dp,lights_fragment_begin:fp,lights_fragment_maps:pp,lights_fragment_end:mp,lightprobes_pars_fragment:gp,logdepthbuf_fragment:_p,logdepthbuf_pars_fragment:vp,logdepthbuf_pars_vertex:xp,logdepthbuf_vertex:Sp,map_fragment:Mp,map_pars_fragment:yp,map_particle_fragment:Ep,map_particle_pars_fragment:bp,metalnessmap_fragment:Tp,metalnessmap_pars_fragment:Ap,morphinstance_vertex:wp,morphcolor_vertex:Rp,morphnormal_vertex:Cp,morphtarget_pars_vertex:Pp,morphtarget_vertex:Ip,normal_fragment_begin:Dp,normal_fragment_maps:Lp,normal_pars_fragment:Up,normal_pars_vertex:Np,normal_vertex:Fp,normalmap_pars_fragment:Op,clearcoat_normal_fragment_begin:Bp,clearcoat_normal_fragment_maps:zp,clearcoat_pars_fragment:kp,iridescence_pars_fragment:Gp,opaque_fragment:Hp,packing:Vp,premultiplied_alpha_fragment:Wp,project_vertex:Xp,dithering_fragment:qp,dithering_pars_fragment:Yp,roughnessmap_fragment:Zp,roughnessmap_pars_fragment:Kp,shadowmap_pars_fragment:$p,shadowmap_pars_vertex:Jp,shadowmap_vertex:Qp,shadowmask_pars_fragment:jp,skinbase_vertex:em,skinning_pars_vertex:tm,skinning_vertex:nm,skinnormal_vertex:im,specularmap_fragment:sm,specularmap_pars_fragment:rm,tonemapping_fragment:am,tonemapping_pars_fragment:om,transmission_fragment:lm,transmission_pars_fragment:cm,uv_pars_fragment:hm,uv_pars_vertex:um,uv_vertex:dm,worldpos_vertex:fm,background_vert:pm,background_frag:mm,backgroundCube_vert:gm,backgroundCube_frag:_m,cube_vert:vm,cube_frag:xm,depth_vert:Sm,depth_frag:Mm,distance_vert:ym,distance_frag:Em,equirect_vert:bm,equirect_frag:Tm,linedashed_vert:Am,linedashed_frag:wm,meshbasic_vert:Rm,meshbasic_frag:Cm,meshlambert_vert:Pm,meshlambert_frag:Im,meshmatcap_vert:Dm,meshmatcap_frag:Lm,meshnormal_vert:Um,meshnormal_frag:Nm,meshphong_vert:Fm,meshphong_frag:Om,meshphysical_vert:Bm,meshphysical_frag:zm,meshtoon_vert:km,meshtoon_frag:Gm,points_vert:Hm,points_frag:Vm,shadow_vert:Wm,shadow_frag:Xm,sprite_vert:qm,sprite_frag:Ym},de={common:{diffuse:{value:new Ce(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Oe},alphaMap:{value:null},alphaMapTransform:{value:new Oe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Oe}},envmap:{envMap:{value:null},envMapRotation:{value:new Oe},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Oe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Oe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Oe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Oe},normalScale:{value:new ke(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Oe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Oe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Oe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Oe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ce(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new F},probesMax:{value:new F},probesResolution:{value:new F}},points:{diffuse:{value:new Ce(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Oe},alphaTest:{value:0},uvTransform:{value:new Oe}},sprite:{diffuse:{value:new Ce(16777215)},opacity:{value:1},center:{value:new ke(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Oe},alphaMap:{value:null},alphaMapTransform:{value:new Oe},alphaTest:{value:0}}},hn={basic:{uniforms:Ft([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.fog]),vertexShader:Ge.meshbasic_vert,fragmentShader:Ge.meshbasic_frag},lambert:{uniforms:Ft([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 Ce(0)},envMapIntensity:{value:1}}]),vertexShader:Ge.meshlambert_vert,fragmentShader:Ge.meshlambert_frag},phong:{uniforms:Ft([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 Ce(0)},specular:{value:new Ce(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ge.meshphong_vert,fragmentShader:Ge.meshphong_frag},standard:{uniforms:Ft([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 Ce(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ge.meshphysical_vert,fragmentShader:Ge.meshphysical_frag},toon:{uniforms:Ft([de.common,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.gradientmap,de.fog,de.lights,{emissive:{value:new Ce(0)}}]),vertexShader:Ge.meshtoon_vert,fragmentShader:Ge.meshtoon_frag},matcap:{uniforms:Ft([de.common,de.bumpmap,de.normalmap,de.displacementmap,de.fog,{matcap:{value:null}}]),vertexShader:Ge.meshmatcap_vert,fragmentShader:Ge.meshmatcap_frag},points:{uniforms:Ft([de.points,de.fog]),vertexShader:Ge.points_vert,fragmentShader:Ge.points_frag},dashed:{uniforms:Ft([de.common,de.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ge.linedashed_vert,fragmentShader:Ge.linedashed_frag},depth:{uniforms:Ft([de.common,de.displacementmap]),vertexShader:Ge.depth_vert,fragmentShader:Ge.depth_frag},normal:{uniforms:Ft([de.common,de.bumpmap,de.normalmap,de.displacementmap,{opacity:{value:1}}]),vertexShader:Ge.meshnormal_vert,fragmentShader:Ge.meshnormal_frag},sprite:{uniforms:Ft([de.sprite,de.fog]),vertexShader:Ge.sprite_vert,fragmentShader:Ge.sprite_frag},background:{uniforms:{uvTransform:{value:new Oe},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 Oe}},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:Ft([de.common,de.displacementmap,{referencePosition:{value:new F},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ge.distance_vert,fragmentShader:Ge.distance_frag},shadow:{uniforms:Ft([de.lights,de.fog,{color:{value:new Ce(0)},opacity:{value:1}}]),vertexShader:Ge.shadow_vert,fragmentShader:Ge.shadow_frag}};hn.physical={uniforms:Ft([hn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Oe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Oe},clearcoatNormalScale:{value:new ke(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Oe},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Oe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Oe},sheen:{value:0},sheenColor:{value:new Ce(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Oe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Oe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Oe},transmissionSamplerSize:{value:new ke},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Oe},attenuationDistance:{value:0},attenuationColor:{value:new Ce(0)},specularColor:{value:new Ce(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Oe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Oe},anisotropyVector:{value:new ke},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Oe}}]),vertexShader:Ge.meshphysical_vert,fragmentShader:Ge.meshphysical_frag};const or={r:0,b:0,g:0},Zm=new lt,Mu=new Oe;Mu.set(-1,0,0,0,1,0,0,0,1);function Km(i,e,t,n,s,r){const a=new Ce(0);let o=s===!0?0:1,l,c,h=null,d=0,u=null;function p(A){let w=A.isScene===!0?A.background:null;if(w&&w.isTexture){const S=A.backgroundBlurriness>0;w=e.get(w,S)}return w}function _(A){let w=!1;const S=p(A);S===null?m(a,o):S&&S.isColor&&(m(S,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(A,w){const S=p(w);S&&(S.isCubeTexture||S.mapping===Kr)?(c===void 0&&(c=new zt(new Rs(1,1,1),new kt({name:"BackgroundCubeMaterial",uniforms:Ji(hn.backgroundCube.uniforms),vertexShader:hn.backgroundCube.vertexShader,fragmentShader:hn.backgroundCube.fragmentShader,side:Dt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(y,b,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=S,c.material.uniforms.backgroundBlurriness.value=w.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Zm.makeRotationFromEuler(w.backgroundRotation)).transpose(),S.isCubeTexture&&S.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(Mu),c.material.toneMapped=qe.getTransfer(S.colorSpace)!==Qe,(h!==S||d!==S.version||u!==i.toneMapping)&&(c.material.needsUpdate=!0,h=S,d=S.version,u=i.toneMapping),c.layers.enableAll(),A.unshift(c,c.geometry,c.material,0,0,null)):S&&S.isTexture&&(l===void 0&&(l=new zt(new Jr(2,2),new kt({name:"BackgroundMaterial",uniforms:Ji(hn.background.uniforms),vertexShader:hn.background.vertexShader,fragmentShader:hn.background.fragmentShader,side:Zn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=S,l.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,l.material.toneMapped=qe.getTransfer(S.colorSpace)!==Qe,S.matrixAutoUpdate===!0&&S.updateMatrix(),l.material.uniforms.uvTransform.value.copy(S.matrix),(h!==S||d!==S.version||u!==i.toneMapping)&&(l.material.needsUpdate=!0,h=S,d=S.version,u=i.toneMapping),l.layers.enableAll(),A.unshift(l,l.geometry,l.material,0,0,null))}function m(A,w){A.getRGB(or,gu(i)),t.buffers.color.setClear(or.r,or.g,or.b,w,r)}function f(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return a},setClearColor:function(A,w=1){a.set(A),o=w,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(A){o=A,m(a,o)},render:_,addToRenderList:M,dispose:f}}function $m(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=u(null);let r=s,a=!1;function o(C,U,Y,Z,O){let W=!1;const V=d(C,Z,Y,U);r!==V&&(r=V,c(r.object)),W=p(C,Z,Y,O),W&&_(C,Z,Y,O),O!==null&&e.update(O,i.ELEMENT_ARRAY_BUFFER),(W||a)&&(a=!1,S(C,U,Y,Z),O!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(O).buffer))}function l(){return i.createVertexArray()}function c(C){return i.bindVertexArray(C)}function h(C){return i.deleteVertexArray(C)}function d(C,U,Y,Z){const O=Z.wireframe===!0;let W=n[U.id];W===void 0&&(W={},n[U.id]=W);const V=C.isInstancedMesh===!0?C.id:0;let Q=W[V];Q===void 0&&(Q={},W[V]=Q);let te=Q[Y.id];te===void 0&&(te={},Q[Y.id]=te);let ee=te[O];return ee===void 0&&(ee=u(l()),te[O]=ee),ee}function u(C){const U=[],Y=[],Z=[];for(let O=0;O<t;O++)U[O]=0,Y[O]=0,Z[O]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:U,enabledAttributes:Y,attributeDivisors:Z,object:C,attributes:{},index:null}}function p(C,U,Y,Z){const O=r.attributes,W=U.attributes;let V=0;const Q=Y.getAttributes();for(const te in Q)if(Q[te].location>=0){const se=O[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!==Z}function _(C,U,Y,Z){const O={},W=U.attributes;let V=0;const Q=Y.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),O[te]=ge,V++}r.attributes=O,r.attributesNum=V,r.index=Z}function M(){const C=r.newAttributes;for(let U=0,Y=C.length;U<Y;U++)C[U]=0}function m(C){f(C,0)}function f(C,U){const Y=r.newAttributes,Z=r.enabledAttributes,O=r.attributeDivisors;Y[C]=1,Z[C]===0&&(i.enableVertexAttribArray(C),Z[C]=1),O[C]!==U&&(i.vertexAttribDivisor(C,U),O[C]=U)}function A(){const C=r.newAttributes,U=r.enabledAttributes;for(let Y=0,Z=U.length;Y<Z;Y++)U[Y]!==C[Y]&&(i.disableVertexAttribArray(Y),U[Y]=0)}function w(C,U,Y,Z,O,W,V){V===!0?i.vertexAttribIPointer(C,U,Y,O,W):i.vertexAttribPointer(C,U,Y,Z,O,W)}function S(C,U,Y,Z){M();const O=Z.attributes,W=Y.getAttributes(),V=U.defaultAttributeValues;for(const Q in W){const te=W[Q];if(te.location>=0){let ee=O[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,K=Ve.bytesPerElement,re=We===i.INT||We===i.UNSIGNED_INT||ee.gpuType===ml;if(ee.isInterleavedBufferAttribute){const ne=ee.data,k=ne.stride,Pe=ee.offset;if(ne.isInstancedInterleavedBuffer){for(let Ie=0;Ie<te.locationSize;Ie++)f(te.location+Ie,ne.meshPerAttribute);C.isInstancedMesh!==!0&&Z._maxInstanceCount===void 0&&(Z._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let Ie=0;Ie<te.locationSize;Ie++)m(te.location+Ie);i.bindBuffer(i.ARRAY_BUFFER,st);for(let Ie=0;Ie<te.locationSize;Ie++)w(te.location+Ie,ge/te.locationSize,We,se,k*K,(Pe+ge/te.locationSize*Ie)*K,re)}else{if(ee.isInstancedBufferAttribute){for(let ne=0;ne<te.locationSize;ne++)f(te.location+ne,ee.meshPerAttribute);C.isInstancedMesh!==!0&&Z._maxInstanceCount===void 0&&(Z._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*K,ge/te.locationSize*ne*K,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(){T();for(const C in n){const U=n[C];for(const Y in U){const Z=U[Y];for(const O in Z){const W=Z[O];for(const V in W)h(W[V].object),delete W[V];delete Z[O]}}delete n[C]}}function b(C){if(n[C.id]===void 0)return;const U=n[C.id];for(const Y in U){const Z=U[Y];for(const O in Z){const W=Z[O];for(const V in W)h(W[V].object),delete W[V];delete Z[O]}}delete n[C.id]}function R(C){for(const U in n){const Y=n[U];for(const Z in Y){const O=Y[Z];if(O[C.id]===void 0)continue;const W=O[C.id];for(const V in W)h(W[V].object),delete W[V];delete O[C.id]}}}function v(C){for(const U in n){const Y=n[U],Z=C.isInstancedMesh===!0?C.id:0,O=Y[Z];if(O!==void 0){for(const W in O){const V=O[W];for(const Q in V)h(V[Q].object),delete V[Q];delete O[W]}delete Y[Z],Object.keys(Y).length===0&&delete n[U]}}}function T(){I(),a=!0,r!==s&&(r=s,c(r.object))}function I(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:T,resetDefaultState:I,dispose:y,releaseStatesOfGeometry:b,releaseStatesOfObject:v,releaseStatesOfProgram:R,initAttributes:M,enableAttribute:m,disableUnusedAttributes:A}}function Jm(i,e,t){let n;function s(l){n=l}function r(l,c){i.drawArrays(n,l,c),t.update(c,n,1)}function a(l,c,h){h!==0&&(i.drawArraysInstanced(n,l,c,h),t.update(c,n,h))}function o(l,c,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,c,0,h);let u=0;for(let p=0;p<h;p++)u+=c[p];t.update(u,n,1)}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function Qm(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!==sn&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(R){const v=R===Cn&&(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!==dn&&!v)}function l(R){if(R==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const h=l(c);h!==c&&(Fe("WebGLRenderer:",c,"not supported, using",h,"instead."),c=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),_=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),A=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),w=i.getParameter(i.MAX_VARYING_VECTORS),S=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),y=i.getParameter(i.MAX_SAMPLES),b=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:u,maxTextures:p,maxVertexTextures:_,maxTextureSize:M,maxCubemapSize:m,maxAttributes:f,maxVertexUniforms:A,maxVaryings:w,maxFragmentUniforms:S,maxSamples:y,samples:b}}function jm(i){const e=this;let t=null,n=0,s=!1,r=!1;const a=new ti,o=new Oe,l={value:null,needsUpdate:!1};this.uniform=l,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 _=d.clippingPlanes,M=d.clipIntersection,m=d.clipShadows,f=i.get(d);if(!s||_===null||_.length===0||r&&!m)r?h(null):c();else{const A=r?0:n,w=A*4;let S=f.clippingState||null;l.value=S,S=h(_,u,w,p);for(let y=0;y!==w;++y)S[y]=t[y];f.clippingState=S,this.numIntersection=M?this.numPlanes:0,this.numPlanes+=A}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(d,u,p,_){const M=d!==null?d.length:0;let m=null;if(M!==0){if(m=l.value,_!==!0||m===null){const f=p+M*4,A=u.matrixWorldInverse;o.getNormalMatrix(A),(m===null||m.length<f)&&(m=new Float32Array(f));for(let w=0,S=p;w!==M;++w,S+=4)a.copy(d[w]).applyMatrix4(A,o),a.normal.toArray(m,S),m[S+3]=a.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=M,e.numIntersection=0,m}}const Wn=4,bc=[.125,.215,.35,.446,.526,.582],ii=20,eg=256,us=new vu,Tc=new Ce;let Da=null,La=0,Ua=0,Na=!1;const tg=new F;class Ac{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=tg}=r;Da=this._renderer.getRenderTarget(),La=this._renderer.getActiveCubeFace(),Ua=this._renderer.getActiveMipmapLevel(),Na=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,n,s,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Cc(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Rc(),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(Da,La,Ua),this._renderer.xr.enabled=Na,e.scissorTest=!1,Li(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===ci||e.mapping===Ki?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Da=this._renderer.getRenderTarget(),La=this._renderer.getActiveCubeFace(),Ua=this._renderer.getActiveMipmapLevel(),Na=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:It,minFilter:It,generateMipmaps:!1,type:Cn,format:sn,colorSpace:Ur,depthBuffer:!1},s=wc(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=wc(e,t,n);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=ng(r)),this._blurMaterial=sg(r,e,t),this._ggxMaterial=ig(r,e,t)}return s}_compileMaterial(e){const t=new zt(new Tt,e);this._renderer.compile(t,us)}_sceneToCubeUV(e,t,n,s,r){const l=new Kt(90,1,t,n),c=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],d=this._renderer,u=d.autoClear,p=d.toneMapping;d.getClearColor(Tc),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 zt(new Rs,new Xi({name:"PMREM.Background",side:Dt,depthWrite:!1,depthTest:!1})));const M=this._backgroundBox,m=M.material;let f=!1;const A=e.background;A?A.isColor&&(m.color.copy(A),e.background=null,f=!0):(m.color.copy(Tc),f=!0);for(let w=0;w<6;w++){const S=w%3;S===0?(l.up.set(0,c[w],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x+h[w],r.y,r.z)):S===1?(l.up.set(0,0,c[w]),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y+h[w],r.z)):(l.up.set(0,c[w],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y,r.z+h[w]));const y=this._cubeSize;Li(s,S*y,w>2?y:0,y,y),d.setRenderTarget(s),f&&d.render(M,l),d.render(e,l)}d.toneMapping=p,d.autoClear=u,e.background=A}_textureToCubeUV(e,t){const n=this._renderer,s=e.mapping===ci||e.mapping===Ki;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Cc()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Rc());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const l=this._cubeSize;Li(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,us)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let r=1;r<s;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){const s=this._renderer,r=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;const l=a.uniforms,c=n/(this._lodMeshes.length-1),h=t/(this._lodMeshes.length-1),d=Math.sqrt(c*c-h*h),u=0+c*1.25,p=d*u,{_lodMax:_}=this,M=this._sizeLods[n],m=3*M*(n>_-Wn?n-_+Wn:0),f=4*(this._cubeSize-M);l.envMap.value=e.texture,l.roughness.value=p,l.mipInt.value=_-t,Li(r,m,f,3*M,2*M),s.setRenderTarget(r),s.render(o,us),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=_-n,Li(e,m,f,3*M,2*M),s.setRenderTarget(e),s.render(o,us)}_blur(e,t,n,s,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,s,"latitudinal",r),this._halfBlur(a,e,n,n,s,"longitudinal",r)}_halfBlur(e,t,n,s,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Xe("blur direction must be either latitudinal or longitudinal!");const h=3,d=this._lodMeshes[s];d.material=c;const u=c.uniforms,p=this._sizeLods[n]-1,_=isFinite(r)?Math.PI/(2*p):2*Math.PI/(2*ii-1),M=r/_,m=isFinite(r)?1+Math.floor(h*M):ii;m>ii&&Fe(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${ii}`);const f=[];let A=0;for(let R=0;R<ii;++R){const v=R/M,T=Math.exp(-v*v/2);f.push(T),R===0?A+=T:R<m&&(A+=2*T)}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=_,u.mipInt.value=w-n;const S=this._sizeLods[s],y=3*S*(s>w-Wn?s-w+Wn:0),b=4*(this._cubeSize-S);Li(t,y,b,3*S,2*S),l.setRenderTarget(t),l.render(d,us)}}function ng(i){const e=[],t=[],n=[];let s=i;const r=i-Wn+1+bc.length;for(let a=0;a<r;a++){const o=Math.pow(2,s);e.push(o);let l=1/o;a>i-Wn?l=bc[a-i+Wn-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),h=-c,d=1+c,u=[h,h,d,h,d,d,h,h,d,d,h,d],p=6,_=6,M=3,m=2,f=1,A=new Float32Array(M*_*p),w=new Float32Array(m*_*p),S=new Float32Array(f*_*p);for(let b=0;b<p;b++){const R=b%3*2/3-1,v=b>2?0:-1,T=[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(T,M*_*b),w.set(u,m*_*b);const I=[b,b,b,b,b,b];S.set(I,f*_*b)}const y=new Tt;y.setAttribute("position",new pt(A,M)),y.setAttribute("uv",new pt(w,m)),y.setAttribute("faceIndex",new pt(S,f)),n.push(new zt(y,null)),s>Wn&&s--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function wc(i,e,t){const n=new mn(i,e,t);return n.texture.mapping=Kr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Li(i,e,t,n,s){i.viewport.set(e,t,n,s),i.scissor.set(e,t,n,s)}function ig(i,e,t){return new kt({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:eg,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:Qr(),fragmentShader:`
|
|
3997
3997
|
|
|
3998
3998
|
precision highp float;
|
|
3999
3999
|
precision highp int;
|
|
@@ -4097,7 +4097,7 @@ void main() {
|
|
|
4097
4097
|
|
|
4098
4098
|
gl_FragColor = vec4(prefilteredColor, 1.0);
|
|
4099
4099
|
}
|
|
4100
|
-
`,blending:wn,depthTest:!1,depthWrite:!1})}function
|
|
4100
|
+
`,blending:wn,depthTest:!1,depthWrite:!1})}function sg(i,e,t){const n=new Float32Array(ii),s=new F(0,1,0);return new kt({name:"SphericalGaussianBlur",defines:{n:ii,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:Qr(),fragmentShader:`
|
|
4101
4101
|
|
|
4102
4102
|
precision mediump float;
|
|
4103
4103
|
precision mediump int;
|
|
@@ -4157,7 +4157,7 @@ void main() {
|
|
|
4157
4157
|
}
|
|
4158
4158
|
|
|
4159
4159
|
}
|
|
4160
|
-
`,blending:wn,depthTest:!1,depthWrite:!1})}function
|
|
4160
|
+
`,blending:wn,depthTest:!1,depthWrite:!1})}function Rc(){return new kt({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Qr(),fragmentShader:`
|
|
4161
4161
|
|
|
4162
4162
|
precision mediump float;
|
|
4163
4163
|
precision mediump int;
|
|
@@ -4176,7 +4176,7 @@ void main() {
|
|
|
4176
4176
|
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
|
|
4177
4177
|
|
|
4178
4178
|
}
|
|
4179
|
-
`,blending:wn,depthTest:!1,depthWrite:!1})}function
|
|
4179
|
+
`,blending:wn,depthTest:!1,depthWrite:!1})}function Cc(){return new kt({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Qr(),fragmentShader:`
|
|
4180
4180
|
|
|
4181
4181
|
precision mediump float;
|
|
4182
4182
|
precision mediump int;
|
|
@@ -4192,7 +4192,7 @@ void main() {
|
|
|
4192
4192
|
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
|
|
4193
4193
|
|
|
4194
4194
|
}
|
|
4195
|
-
`,blending:wn,depthTest:!1,depthWrite:!1})}function
|
|
4195
|
+
`,blending:wn,depthTest:!1,depthWrite:!1})}function Qr(){return`
|
|
4196
4196
|
|
|
4197
4197
|
precision mediump float;
|
|
4198
4198
|
precision mediump int;
|
|
@@ -4247,7 +4247,7 @@ void main() {
|
|
|
4247
4247
|
gl_Position = vec4( position, 1.0 );
|
|
4248
4248
|
|
|
4249
4249
|
}
|
|
4250
|
-
`}class
|
|
4250
|
+
`}class yu extends mn{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 pu(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:`
|
|
4251
4251
|
|
|
4252
4252
|
varying vec3 vWorldDirection;
|
|
4253
4253
|
|
|
@@ -4282,7 +4282,7 @@ void main() {
|
|
|
4282
4282
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
4283
4283
|
|
|
4284
4284
|
}
|
|
4285
|
-
`},s=new
|
|
4285
|
+
`},s=new Rs(5,5,5),r=new kt({name:"CubemapFromEquirect",uniforms:Ji(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Dt,blending:wn});r.uniforms.tEquirect.value=t;const a=new zt(s,r),o=t.minFilter;return t.minFilter===ri&&(t.minFilter=It),new cf(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 rg(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===sa||p===ra)if(e.has(u)){const _=e.get(u).texture;return o(_,u.mapping)}else{const _=u.image;if(_&&_.height>0){const M=new yu(_.height);return M.fromEquirectangularTexture(i,u),e.set(u,M),u.addEventListener("dispose",c),o(M.texture,u.mapping)}else return null}}return u}function a(u){if(u&&u.isTexture){const p=u.mapping,_=p===sa||p===ra,M=p===ci||p===Ki;if(_||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 Ac(i)),m=_?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 A=u.image;return _&&A&&A.height>0||M&&A&&l(A)?(n===null&&(n=new Ac(i)),m=_?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===sa?u.mapping=ci:p===ra&&(u.mapping=Ki),u}function l(u){let p=0;const _=6;for(let M=0;M<_;M++)u[M]!==void 0&&p++;return p===_}function c(u){const p=u.target;p.removeEventListener("dispose",c);const _=e.get(p);_!==void 0&&(e.delete(p),_.dispose())}function h(u){const p=u.target;p.removeEventListener("dispose",h);const _=t.get(p);_!==void 0&&(t.delete(p),_.dispose())}function d(){e=new WeakMap,t=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:s,dispose:d}}function ag(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&&Vi("WebGLRenderer: "+n+" extension not supported."),s}}}function og(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 _ in u.attributes)e.remove(u.attributes[_]);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 l(d){const u=d.attributes;for(const p in u)e.update(u[p],i.ARRAY_BUFFER)}function c(d){const u=[],p=d.index,_=d.attributes.position;let M=0;if(_===void 0)return;if(p!==null){const A=p.array;M=p.version;for(let w=0,S=A.length;w<S;w+=3){const y=A[w+0],b=A[w+1],R=A[w+2];u.push(y,b,b,R,R,y)}}else{const A=_.array;M=_.version;for(let w=0,S=A.length/3-1;w<S;w+=3){const y=w+0,b=w+1,R=w+2;u.push(y,b,b,R,R,y)}}const m=new(_.count>=65535?hu:cu)(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&&c(d)}else c(d);return r.get(d)}return{get:o,update:l,getWireframeAttribute:h}}function lg(i,e,t){let n;function s(d){n=d}let r,a;function o(d){r=d.type,a=d.bytesPerElement}function l(d,u){i.drawElements(n,u,r,d*a),t.update(u,n,1)}function c(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=l,this.renderInstances=c,this.renderMultiDraw=h}function cg(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 hg(i,e,t){const n=new WeakMap,s=new ft;function r(a,o,l){const c=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 T=function(){R.dispose(),n.delete(o),o.removeEventListener("dispose",T)};u!==void 0&&u.texture.dispose();const p=o.morphAttributes.position!==void 0,_=o.morphAttributes.normal!==void 0,M=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],f=o.morphAttributes.normal||[],A=o.morphAttributes.color||[];let w=0;p===!0&&(w=1),_===!0&&(w=2),M===!0&&(w=3);let S=o.attributes.position.count*w,y=1;S>e.maxTextureSize&&(y=Math.ceil(S/e.maxTextureSize),S=e.maxTextureSize);const b=new Float32Array(S*y*4*d),R=new ou(b,S,y,d);R.type=dn,R.needsUpdate=!0;const v=w*4;for(let I=0;I<d;I++){const C=m[I],U=f[I],Y=A[I],Z=S*y*4*I;for(let O=0;O<C.count;O++){const W=O*v;p===!0&&(s.fromBufferAttribute(C,O),b[Z+W+0]=s.x,b[Z+W+1]=s.y,b[Z+W+2]=s.z,b[Z+W+3]=0),_===!0&&(s.fromBufferAttribute(U,O),b[Z+W+4]=s.x,b[Z+W+5]=s.y,b[Z+W+6]=s.z,b[Z+W+7]=0),M===!0&&(s.fromBufferAttribute(Y,O),b[Z+W+8]=s.x,b[Z+W+9]=s.y,b[Z+W+10]=s.z,b[Z+W+11]=Y.itemSize===4?s.w:1)}}u={count:d,texture:R,size:new ke(S,y)},n.set(o,u),o.addEventListener("dispose",T)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(i,"morphTexture",a.morphTexture,t);else{let p=0;for(let M=0;M<c.length;M++)p+=c[M];const _=o.morphTargetsRelative?1:1-p;l.getUniforms().setValue(i,"morphTargetBaseInfluence",_),l.getUniforms().setValue(i,"morphTargetInfluences",c)}l.getUniforms().setValue(i,"morphTargetsTexture",u.texture,t),l.getUniforms().setValue(i,"morphTargetsTextureSize",u.size)}return{update:r}}function ug(i,e,t,n,s){let r=new WeakMap;function a(c){const h=s.render.frame,d=c.geometry,u=e.get(c,d);if(r.get(u)!==h&&(e.update(u),r.set(u,h)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),r.get(c)!==h&&(t.update(c.instanceMatrix,i.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,i.ARRAY_BUFFER),r.set(c,h))),c.isSkinnedMesh){const p=c.skeleton;r.get(p)!==h&&(p.update(),r.set(p,h))}return u}function o(){r=new WeakMap}function l(c){const h=c.target;h.removeEventListener("dispose",l),n.releaseStatesOfObject(h),t.remove(h.instanceMatrix),h.instanceColor!==null&&t.remove(h.instanceColor)}return{update:a,dispose:o}}const dg={[Xh]:"LINEAR_TONE_MAPPING",[qh]:"REINHARD_TONE_MAPPING",[Yh]:"CINEON_TONE_MAPPING",[Zh]:"ACES_FILMIC_TONE_MAPPING",[$h]:"AGX_TONE_MAPPING",[Jh]:"NEUTRAL_TONE_MAPPING",[Kh]:"CUSTOM_TONE_MAPPING"};function fg(i,e,t,n,s,r){const a=new mn(e,t,{type:i,depthBuffer:s,stencilBuffer:r,samples:n?4:0,depthTexture:s?new $i(e,t):void 0}),o=new mn(e,t,{type:Cn,depthBuffer:!1,stencilBuffer:!1}),l=new Tt;l.setAttribute("position",new Ut([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new Ut([0,2,0,0,2,0],2));const c=new af({uniforms:{tDiffuse:{value:null}},vertexShader:`
|
|
4286
4286
|
precision highp float;
|
|
4287
4287
|
|
|
4288
4288
|
uniform mat4 modelViewMatrix;
|
|
@@ -4328,17 +4328,17 @@ void main() {
|
|
|
4328
4328
|
#ifdef SRGB_TRANSFER
|
|
4329
4329
|
gl_FragColor = sRGBTransferOETF( gl_FragColor );
|
|
4330
4330
|
#endif
|
|
4331
|
-
}`,depthTest:!1,depthWrite:!1}),h=new
|
|
4332
|
-
`),n=[],s=Math.max(
|
|
4333
|
-
`)}const
|
|
4331
|
+
}`,depthTest:!1,depthWrite:!1}),h=new zt(l,c),d=new vu(-1,1,1,-1,0,1);let u=null,p=null,_=!1,M,m=null,f=[],A=!1;this.setSize=function(w,S){a.setSize(w,S),o.setSize(w,S);for(let y=0;y<f.length;y++){const b=f[y];b.setSize&&b.setSize(w,S)}},this.setEffects=function(w){f=w,A=f.length>0&&f[0].isRenderPass===!0;const S=a.width,y=a.height;for(let b=0;b<f.length;b++){const R=f[b];R.setSize&&R.setSize(S,y)}},this.begin=function(w,S){if(_||w.toneMapping===pn&&f.length===0)return!1;if(m=S,S!==null){const y=S.width,b=S.height;(a.width!==y||a.height!==b)&&this.setSize(y,b)}return A===!1&&w.setRenderTarget(a),M=w.toneMapping,w.toneMapping=pn,!0},this.hasRenderPass=function(){return A},this.end=function(w,S){w.toneMapping=M,_=!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,S),v.needsSwap!==!1)){const T=y;y=b,b=T}}if(u!==w.outputColorSpace||p!==w.toneMapping){u=w.outputColorSpace,p=w.toneMapping,c.defines={},qe.getTransfer(u)===Qe&&(c.defines.SRGB_TRANSFER="");const R=dg[p];R&&(c.defines[R]=""),c.needsUpdate=!0}c.uniforms.tDiffuse.value=y.texture,w.setRenderTarget(m),w.render(h,d),m=null,_=!1},this.isCompositing=function(){return _},this.dispose=function(){a.depthTexture&&a.depthTexture.dispose(),a.dispose(),o.dispose(),l.dispose(),c.dispose()}}const Eu=new Lt,Xo=new $i(1,1),bu=new ou,Tu=new N0,Au=new pu,Pc=[],Ic=[],Dc=new Float32Array(16),Lc=new Float32Array(9),Uc=new Float32Array(4);function ns(i,e,t){const n=i[0];if(n<=0||n>0)return i;const s=e*t;let r=Pc[s];if(r===void 0&&(r=new Float32Array(s),Pc[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 St(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 Mt(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function jr(i,e){let t=Ic[e];t===void 0&&(t=new Int32Array(e),Ic[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function pg(i,e){const t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function mg(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(St(t,e))return;i.uniform2fv(this.addr,e),Mt(t,e)}}function gg(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(St(t,e))return;i.uniform3fv(this.addr,e),Mt(t,e)}}function _g(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(St(t,e))return;i.uniform4fv(this.addr,e),Mt(t,e)}}function vg(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(St(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),Mt(t,e)}else{if(St(t,n))return;Uc.set(n),i.uniformMatrix2fv(this.addr,!1,Uc),Mt(t,n)}}function xg(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(St(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),Mt(t,e)}else{if(St(t,n))return;Lc.set(n),i.uniformMatrix3fv(this.addr,!1,Lc),Mt(t,n)}}function Sg(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(St(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),Mt(t,e)}else{if(St(t,n))return;Dc.set(n),i.uniformMatrix4fv(this.addr,!1,Dc),Mt(t,n)}}function Mg(i,e){const t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function yg(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(St(t,e))return;i.uniform2iv(this.addr,e),Mt(t,e)}}function Eg(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(St(t,e))return;i.uniform3iv(this.addr,e),Mt(t,e)}}function bg(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(St(t,e))return;i.uniform4iv(this.addr,e),Mt(t,e)}}function Tg(i,e){const t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function Ag(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(St(t,e))return;i.uniform2uiv(this.addr,e),Mt(t,e)}}function wg(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(St(t,e))return;i.uniform3uiv(this.addr,e),Mt(t,e)}}function Rg(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(St(t,e))return;i.uniform4uiv(this.addr,e),Mt(t,e)}}function Cg(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?(Xo.compareFunction=t.isReversedDepthBuffer()?yl:Ml,r=Xo):r=Eu,t.setTexture2D(e||r,s)}function Pg(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture3D(e||Tu,s)}function Ig(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTextureCube(e||Au,s)}function Dg(i,e,t){const n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture2DArray(e||bu,s)}function Lg(i){switch(i){case 5126:return pg;case 35664:return mg;case 35665:return gg;case 35666:return _g;case 35674:return vg;case 35675:return xg;case 35676:return Sg;case 5124:case 35670:return Mg;case 35667:case 35671:return yg;case 35668:case 35672:return Eg;case 35669:case 35673:return bg;case 5125:return Tg;case 36294:return Ag;case 36295:return wg;case 36296:return Rg;case 35678:case 36198:case 36298:case 36306:case 35682:return Cg;case 35679:case 36299:case 36307:return Pg;case 35680:case 36300:case 36308:case 36293:return Ig;case 36289:case 36303:case 36311:case 36292:return Dg}}function Ug(i,e){i.uniform1fv(this.addr,e)}function Ng(i,e){const t=ns(e,this.size,2);i.uniform2fv(this.addr,t)}function Fg(i,e){const t=ns(e,this.size,3);i.uniform3fv(this.addr,t)}function Og(i,e){const t=ns(e,this.size,4);i.uniform4fv(this.addr,t)}function Bg(i,e){const t=ns(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function zg(i,e){const t=ns(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function kg(i,e){const t=ns(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function Gg(i,e){i.uniform1iv(this.addr,e)}function Hg(i,e){i.uniform2iv(this.addr,e)}function Vg(i,e){i.uniform3iv(this.addr,e)}function Wg(i,e){i.uniform4iv(this.addr,e)}function Xg(i,e){i.uniform1uiv(this.addr,e)}function qg(i,e){i.uniform2uiv(this.addr,e)}function Yg(i,e){i.uniform3uiv(this.addr,e)}function Zg(i,e){i.uniform4uiv(this.addr,e)}function Kg(i,e,t){const n=this.cache,s=e.length,r=jr(t,s);St(n,r)||(i.uniform1iv(this.addr,r),Mt(n,r));let a;this.type===i.SAMPLER_2D_SHADOW?a=Xo:a=Eu;for(let o=0;o!==s;++o)t.setTexture2D(e[o]||a,r[o])}function $g(i,e,t){const n=this.cache,s=e.length,r=jr(t,s);St(n,r)||(i.uniform1iv(this.addr,r),Mt(n,r));for(let a=0;a!==s;++a)t.setTexture3D(e[a]||Tu,r[a])}function Jg(i,e,t){const n=this.cache,s=e.length,r=jr(t,s);St(n,r)||(i.uniform1iv(this.addr,r),Mt(n,r));for(let a=0;a!==s;++a)t.setTextureCube(e[a]||Au,r[a])}function Qg(i,e,t){const n=this.cache,s=e.length,r=jr(t,s);St(n,r)||(i.uniform1iv(this.addr,r),Mt(n,r));for(let a=0;a!==s;++a)t.setTexture2DArray(e[a]||bu,r[a])}function jg(i){switch(i){case 5126:return Ug;case 35664:return Ng;case 35665:return Fg;case 35666:return Og;case 35674:return Bg;case 35675:return zg;case 35676:return kg;case 5124:case 35670:return Gg;case 35667:case 35671:return Hg;case 35668:case 35672:return Vg;case 35669:case 35673:return Wg;case 5125:return Xg;case 36294:return qg;case 36295:return Yg;case 36296:return Zg;case 35678:case 36198:case 36298:case 36306:case 35682:return Kg;case 35679:case 36299:case 36307:return $g;case 35680:case 36300:case 36308:case 36293:return Jg;case 36289:case 36303:case 36311:case 36292:return Qg}}class e_{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=Lg(t.type)}}class t_{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=jg(t.type)}}class n_{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 Fa=/(\w+)(\])?(\[|\.)?/g;function Nc(i,e){i.seq.push(e),i.map[e.id]=e}function i_(i,e,t){const n=i.name,s=n.length;for(Fa.lastIndex=0;;){const r=Fa.exec(n),a=Fa.lastIndex;let o=r[1];const l=r[2]==="]",c=r[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===s){Nc(t,c===void 0?new e_(o,i,e):new t_(o,i,e));break}else{let d=t.map[o];d===void 0&&(d=new n_(o),Nc(t,d)),t=d}}}class Cr{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),l=e.getUniformLocation(t,o.name);i_(o,l,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],l=n[o.id];l.needsUpdate!==!1&&o.setValue(e,l.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 Fc(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const s_=37297;let r_=0;function a_(i,e){const t=i.split(`
|
|
4332
|
+
`),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(`
|
|
4333
|
+
`)}const Oc=new Oe;function o_(i){qe._getMatrix(Oc,qe.workingColorSpace,i);const e=`mat3( ${Oc.elements.map(t=>t.toFixed(4))} )`;switch(qe.getTransfer(i)){case Nr:return[e,"LinearTransferOETF"];case Qe:return[e,"sRGBTransferOETF"];default:return Fe("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function Bc(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()+`
|
|
4334
4334
|
|
|
4335
4335
|
`+r+`
|
|
4336
4336
|
|
|
4337
|
-
`+
|
|
4338
|
-
`)}const
|
|
4339
|
-
`)}function
|
|
4340
|
-
`)}function
|
|
4341
|
-
`)}function
|
|
4337
|
+
`+a_(i.getShaderSource(e),o)}else return r}function l_(i,e){const t=o_(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
|
|
4338
|
+
`)}const c_={[Xh]:"Linear",[qh]:"Reinhard",[Yh]:"Cineon",[Zh]:"ACESFilmic",[$h]:"AgX",[Jh]:"Neutral",[Kh]:"Custom"};function h_(i,e){const t=c_[e];return t===void 0?(Fe("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const lr=new F;function u_(){qe.getLuminanceCoefficients(lr);const i=lr.x.toFixed(4),e=lr.y.toFixed(4),t=lr.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
|
|
4339
|
+
`)}function d_(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(xs).join(`
|
|
4340
|
+
`)}function f_(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
|
|
4341
|
+
`)}function p_(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 xs(i){return i!==""}function zc(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 kc(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const m_=/^[ \t]*#include +<([\w\d./]+)>/gm;function qo(i){return i.replace(m_,__)}const g_=new Map;function __(i,e){let t=Ge[e];if(t===void 0){const n=g_.get(e);if(n!==void 0)t=Ge[n],Fe('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return qo(t)}const v_=/#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 Gc(i){return i.replace(v_,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 Hc(i){let e=`precision ${i.precision} float;
|
|
4342
4342
|
precision ${i.precision} int;
|
|
4343
4343
|
precision ${i.precision} sampler2D;
|
|
4344
4344
|
precision ${i.precision} samplerCube;
|
|
@@ -4355,33 +4355,33 @@ void main() {
|
|
|
4355
4355
|
precision ${i.precision} usampler3D;
|
|
4356
4356
|
precision ${i.precision} usamplerCube;
|
|
4357
4357
|
precision ${i.precision} usampler2DArray;
|
|
4358
|
-
`;return i.precision==="highp"?
|
|
4359
|
-
#define HIGH_PRECISION`:i.precision==="mediump"?
|
|
4360
|
-
#define MEDIUM_PRECISION`:i.precision==="lowp"&&(
|
|
4361
|
-
#define LOW_PRECISION`),
|
|
4362
|
-
`:"";
|
|
4358
|
+
`;return i.precision==="highp"?e+=`
|
|
4359
|
+
#define HIGH_PRECISION`:i.precision==="mediump"?e+=`
|
|
4360
|
+
#define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
|
|
4361
|
+
#define LOW_PRECISION`),e}const S_={[Er]:"SHADOWMAP_TYPE_PCF",[_s]:"SHADOWMAP_TYPE_VSM"};function M_(i){return S_[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const y_={[ci]:"ENVMAP_TYPE_CUBE",[Ki]:"ENVMAP_TYPE_CUBE",[Kr]:"ENVMAP_TYPE_CUBE_UV"};function E_(i){return i.envMap===!1?"ENVMAP_TYPE_CUBE":y_[i.envMapMode]||"ENVMAP_TYPE_CUBE"}const b_={[Ki]:"ENVMAP_MODE_REFRACTION"};function T_(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":b_[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}const A_={[Wh]:"ENVMAP_BLENDING_MULTIPLY",[p0]:"ENVMAP_BLENDING_MIX",[m0]:"ENVMAP_BLENDING_ADD"};function w_(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":A_[i.combine]||"ENVMAP_BLENDING_NONE"}function R_(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 C_(i,e,t,n){const s=i.getContext(),r=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=M_(t),c=E_(t),h=T_(t),d=w_(t),u=R_(t),p=d_(t),_=f_(r),M=s.createProgram();let m,f,A=t.glslVersion?"#version "+t.glslVersion+`
|
|
4362
|
+
`:"";t.isRawShaderMaterial?(m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_].filter(xs).join(`
|
|
4363
4363
|
`),m.length>0&&(m+=`
|
|
4364
|
-
`),f=["#define SHADER_TYPE "+
|
|
4364
|
+
`),f=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_].filter(xs).join(`
|
|
4365
4365
|
`),f.length>0&&(f+=`
|
|
4366
|
-
`)):(m=[
|
|
4367
|
-
`].filter(
|
|
4368
|
-
`),f=[
|
|
4369
|
-
`].filter(
|
|
4370
|
-
`)),a=qo(a),a=
|
|
4366
|
+
`)):(m=[Hc(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_,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 "+l:"",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",`
|
|
4367
|
+
`].filter(xs).join(`
|
|
4368
|
+
`),f=[Hc(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,_,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 "+c:"",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 "+l:"",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?h_("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ge.colorspace_pars_fragment,l_("linearToOutputTexel",t.outputColorSpace),u_(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
|
4369
|
+
`].filter(xs).join(`
|
|
4370
|
+
`)),a=qo(a),a=zc(a,t),a=kc(a,t),o=qo(o),o=zc(o,t),o=kc(o,t),a=Gc(a),o=Gc(o),t.isRawShaderMaterial!==!0&&(A=`#version 300 es
|
|
4371
4371
|
`,m=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
4372
4372
|
`)+`
|
|
4373
|
-
`+m,f=["#define varying in",
|
|
4373
|
+
`+m,f=["#define varying in",t.glslVersion===Ql?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Ql?"":"#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(`
|
|
4374
4374
|
`)+`
|
|
4375
|
-
`+f);const w=A+m+a,S=A+f+o,y=
|
|
4375
|
+
`+f);const w=A+m+a,S=A+f+o,y=Fc(s,s.VERTEX_SHADER,w),b=Fc(s,s.FRAGMENT_SHADER,S);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 U=s.getProgramInfoLog(M)||"",Y=s.getShaderInfoLog(y)||"",Z=s.getShaderInfoLog(b)||"",O=U.trim(),W=Y.trim(),V=Z.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=Bc(s,y,"vertex"),se=Bc(s,b,"fragment");Xe("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(M,s.VALIDATE_STATUS)+`
|
|
4376
4376
|
|
|
4377
4377
|
Material Name: `+C.name+`
|
|
4378
4378
|
Material Type: `+C.type+`
|
|
4379
4379
|
|
|
4380
4380
|
Program Info Log: `+O+`
|
|
4381
|
-
`+
|
|
4382
|
-
`+st)}else O!==""?Ft("WebGLProgram: Program Info Log:",O):(W===""||V==="")&&(et=!1);et&&(C.diagnostics={runnable:Q,programLog:O,vertexShader:{log:W,prefix:m},fragmentShader:{log:V,prefix:f}})}s.deleteShader(y),s.deleteShader(b),v=new Pr(s,M),T=g_(s,M)}let v;this.getUniforms=function(){return v===void 0&&R(this),v};let T;this.getAttributes=function(){return T===void 0&&R(this),T};let I=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=s.getProgramParameter(M,a_)),I},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(M),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=o_++,this.cacheKey=t,this.usedTimes=1,this.program=M,this.vertexShader=y,this.fragmentShader=b,this}let D_=0;class L_{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t,e,n){const s=this._getShaderCacheForMaterial(t);return s.has(e)===!1&&(s.add(e),e.usedTimes++),s.has(n)===!1&&(s.add(n),n.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderStage(t){return this._getShaderStage(t.vertexShader)}getFragmentShaderStage(t){return this._getShaderStage(t.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return n===void 0&&(n=new U_(t),e.set(t,n)),n}}class U_{constructor(t){this.id=D_++,this.code=t,this.usedTimes=0}}function N_(i){return i===hi||i===Lr||i===Ur}function F_(i,t,e,n,s,r){const a=new bl,o=new L_,l=new Set,c=[],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 _(v){return l.add(v),v===0?"uv":`uv${v}`}function M(v,T,I,C,U,Y){const Z=C.fog,O=U.geometry,W=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?C.environment:null,V=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap,Q=t.get(v.envMap||W,V),et=Q&&Q.mapping===Jr?Q.image.height:null,tt=p[v.type];v.precision!==null&&(u=n.getMaxPrecision(v.precision),u!==v.precision&&Ft("WebGLProgram.getParameters:",v.precision,"not supported, using",u,"instead."));const st=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,gt=st!==void 0?st.length:0;let Vt=0;O.morphAttributes.position!==void 0&&(Vt=1),O.morphAttributes.normal!==void 0&&(Vt=2),O.morphAttributes.color!==void 0&&(Vt=3);let se,Wt,K,rt;if(tt){const St=hn[tt];se=St.vertexShader,Wt=St.fragmentShader}else{se=v.vertexShader,Wt=v.fragmentShader;const St=o.getVertexShaderStage(v),ue=o.getFragmentShaderStage(v);o.update(v,St,ue),K=St.id,rt=ue.id}const nt=i.getRenderTarget(),k=i.state.buffers.depth.getReversed(),Ct=U.isInstancedMesh===!0,Pt=U.isBatchedMesh===!0,wt=!!v.map,xt=!!v.matcap,Nt=!!Q,Dt=!!v.aoMap,Lt=!!v.lightMap,Kt=!!v.bumpMap&&v.wireframe===!1,$t=!!v.normalMap,ce=!!v.displacementMap,oe=!!v.emissiveMap,he=!!v.metalnessMap,ve=!!v.roughnessMap,D=v.anisotropy>0,Be=v.clearcoat>0,Jt=v.dispersion>0,E=v.iridescence>0,g=v.sheen>0,N=v.transmission>0,H=D&&!!v.anisotropyMap,X=Be&&!!v.clearcoatMap,it=Be&&!!v.clearcoatNormalMap,ot=Be&&!!v.clearcoatRoughnessMap,q=E&&!!v.iridescenceMap,J=E&&!!v.iridescenceThicknessMap,lt=g&&!!v.sheenColorMap,bt=g&&!!v.sheenRoughnessMap,ut=!!v.specularMap,ct=!!v.specularColorMap,Rt=!!v.specularIntensityMap,Ut=N&&!!v.transmissionMap,Bt=N&&!!v.thicknessMap,P=!!v.gradientMap,at=!!v.alphaMap,$=v.alphaTest>0,ht=!!v.alphaHash,mt=!!v.extensions;let j=pn;v.toneMapped&&(nt===null||nt.isXRRenderTarget===!0)&&(j=i.toneMapping);const Et={shaderID:tt,shaderType:v.type,shaderName:v.name,vertexShader:se,fragmentShader:Wt,defines:v.defines,customVertexShaderID:K,customFragmentShaderID:rt,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:u,batching:Pt,batchingColor:Pt&&U._colorsTexture!==null,instancing:Ct,instancingColor:Ct&&U.instanceColor!==null,instancingMorph:Ct&&U.morphTexture!==null,outputColorSpace:nt===null?i.outputColorSpace:nt.isXRRenderTarget===!0?nt.texture.colorSpace:qt.workingColorSpace,alphaToCoverage:!!v.alphaToCoverage,map:wt,matcap:xt,envMap:Nt,envMapMode:Nt&&Q.mapping,envMapCubeUVHeight:et,aoMap:Dt,lightMap:Lt,bumpMap:Kt,normalMap:$t,displacementMap:ce,emissiveMap:oe,normalMapObjectSpace:$t&&v.normalMapType===S0,normalMapTangentSpace:$t&&v.normalMapType===Jl,packedNormalMap:$t&&v.normalMapType===Jl&&N_(v.normalMap.format),metalnessMap:he,roughnessMap:ve,anisotropy:D,anisotropyMap:H,clearcoat:Be,clearcoatMap:X,clearcoatNormalMap:it,clearcoatRoughnessMap:ot,dispersion:Jt,iridescence:E,iridescenceMap:q,iridescenceThicknessMap:J,sheen:g,sheenColorMap:lt,sheenRoughnessMap:bt,specularMap:ut,specularColorMap:ct,specularIntensityMap:Rt,transmission:N,transmissionMap:Ut,thicknessMap:Bt,gradientMap:P,opaque:v.transparent===!1&&v.blending===Vi&&v.alphaToCoverage===!1,alphaMap:at,alphaTest:$,alphaHash:ht,combine:v.combine,mapUv:wt&&_(v.map.channel),aoMapUv:Dt&&_(v.aoMap.channel),lightMapUv:Lt&&_(v.lightMap.channel),bumpMapUv:Kt&&_(v.bumpMap.channel),normalMapUv:$t&&_(v.normalMap.channel),displacementMapUv:ce&&_(v.displacementMap.channel),emissiveMapUv:oe&&_(v.emissiveMap.channel),metalnessMapUv:he&&_(v.metalnessMap.channel),roughnessMapUv:ve&&_(v.roughnessMap.channel),anisotropyMapUv:H&&_(v.anisotropyMap.channel),clearcoatMapUv:X&&_(v.clearcoatMap.channel),clearcoatNormalMapUv:it&&_(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ot&&_(v.clearcoatRoughnessMap.channel),iridescenceMapUv:q&&_(v.iridescenceMap.channel),iridescenceThicknessMapUv:J&&_(v.iridescenceThicknessMap.channel),sheenColorMapUv:lt&&_(v.sheenColorMap.channel),sheenRoughnessMapUv:bt&&_(v.sheenRoughnessMap.channel),specularMapUv:ut&&_(v.specularMap.channel),specularColorMapUv:ct&&_(v.specularColorMap.channel),specularIntensityMapUv:Rt&&_(v.specularIntensityMap.channel),transmissionMapUv:Ut&&_(v.transmissionMap.channel),thicknessMapUv:Bt&&_(v.thicknessMap.channel),alphaMapUv:at&&_(v.alphaMap.channel),vertexTangents:!!O.attributes.tangent&&($t||D),vertexNormals:!!O.attributes.normal,vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,pointsUvs:U.isPoints===!0&&!!O.attributes.uv&&(wt||at),fog:!!Z,useFog:v.fog===!0,fogExp2:!!Z&&Z.isFogExp2,flatShading:v.wireframe===!1&&(v.flatShading===!0||O.attributes.normal===void 0&&$t===!1&&(v.isMeshLambertMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isMeshPhysicalMaterial)),sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:k,skinning:U.isSkinnedMesh===!0,hasPositionAttribute:O.attributes.position!==void 0,morphTargets:O.morphAttributes.position!==void 0,morphNormals:O.morphAttributes.normal!==void 0,morphColors:O.morphAttributes.color!==void 0,morphTargetsCount:gt,morphTextureStride:Vt,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numSpotLightShadowsWithMaps:T.numSpotLightShadowsWithMaps,numLightProbes:T.numLightProbes,numLightProbeGrids:Y.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:v.dithering,shadowMapEnabled:i.shadowMap.enabled&&I.length>0,shadowMapType:i.shadowMap.type,toneMapping:j,decodeVideoTexture:wt&&v.map.isVideoTexture===!0&&qt.getTransfer(v.map.colorSpace)===Qt,decodeVideoTextureEmissive:oe&&v.emissiveMap.isVideoTexture===!0&&qt.getTransfer(v.emissiveMap.colorSpace)===Qt,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===bn,flipSided:v.side===Fe,useDepthPacking:v.depthPacking>=0,depthPacking:v.depthPacking||0,index0AttributeName:v.index0AttributeName,extensionClipCullDistance:mt&&v.extensions.clipCullDistance===!0&&e.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(mt&&v.extensions.multiDraw===!0||Pt)&&e.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:e.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return Et.vertexUv1s=l.has(1),Et.vertexUv2s=l.has(2),Et.vertexUv3s=l.has(3),l.clear(),Et}function m(v){const T=[];if(v.shaderID?T.push(v.shaderID):(T.push(v.customVertexShaderID),T.push(v.customFragmentShaderID)),v.defines!==void 0)for(const I in v.defines)T.push(I),T.push(v.defines[I]);return v.isRawShaderMaterial===!1&&(f(T,v),A(T,v),T.push(i.outputColorSpace)),T.push(v.customProgramCacheKey),T.join()}function f(v,T){v.push(T.precision),v.push(T.outputColorSpace),v.push(T.envMapMode),v.push(T.envMapCubeUVHeight),v.push(T.mapUv),v.push(T.alphaMapUv),v.push(T.lightMapUv),v.push(T.aoMapUv),v.push(T.bumpMapUv),v.push(T.normalMapUv),v.push(T.displacementMapUv),v.push(T.emissiveMapUv),v.push(T.metalnessMapUv),v.push(T.roughnessMapUv),v.push(T.anisotropyMapUv),v.push(T.clearcoatMapUv),v.push(T.clearcoatNormalMapUv),v.push(T.clearcoatRoughnessMapUv),v.push(T.iridescenceMapUv),v.push(T.iridescenceThicknessMapUv),v.push(T.sheenColorMapUv),v.push(T.sheenRoughnessMapUv),v.push(T.specularMapUv),v.push(T.specularColorMapUv),v.push(T.specularIntensityMapUv),v.push(T.transmissionMapUv),v.push(T.thicknessMapUv),v.push(T.combine),v.push(T.fogExp2),v.push(T.sizeAttenuation),v.push(T.morphTargetsCount),v.push(T.morphAttributeCount),v.push(T.numDirLights),v.push(T.numPointLights),v.push(T.numSpotLights),v.push(T.numSpotLightMaps),v.push(T.numHemiLights),v.push(T.numRectAreaLights),v.push(T.numDirLightShadows),v.push(T.numPointLightShadows),v.push(T.numSpotLightShadows),v.push(T.numSpotLightShadowsWithMaps),v.push(T.numLightProbes),v.push(T.shadowMapType),v.push(T.toneMapping),v.push(T.numClippingPlanes),v.push(T.numClipIntersection),v.push(T.depthPacking)}function A(v,T){a.disableAll(),T.instancing&&a.enable(0),T.instancingColor&&a.enable(1),T.instancingMorph&&a.enable(2),T.matcap&&a.enable(3),T.envMap&&a.enable(4),T.normalMapObjectSpace&&a.enable(5),T.normalMapTangentSpace&&a.enable(6),T.clearcoat&&a.enable(7),T.iridescence&&a.enable(8),T.alphaTest&&a.enable(9),T.vertexColors&&a.enable(10),T.vertexAlphas&&a.enable(11),T.vertexUv1s&&a.enable(12),T.vertexUv2s&&a.enable(13),T.vertexUv3s&&a.enable(14),T.vertexTangents&&a.enable(15),T.anisotropy&&a.enable(16),T.alphaHash&&a.enable(17),T.batching&&a.enable(18),T.dispersion&&a.enable(19),T.batchingColor&&a.enable(20),T.gradientMap&&a.enable(21),T.packedNormalMap&&a.enable(22),T.vertexNormals&&a.enable(23),v.push(a.mask),a.disableAll(),T.fog&&a.enable(0),T.useFog&&a.enable(1),T.flatShading&&a.enable(2),T.logarithmicDepthBuffer&&a.enable(3),T.reversedDepthBuffer&&a.enable(4),T.skinning&&a.enable(5),T.morphTargets&&a.enable(6),T.morphNormals&&a.enable(7),T.morphColors&&a.enable(8),T.premultipliedAlpha&&a.enable(9),T.shadowMapEnabled&&a.enable(10),T.doubleSided&&a.enable(11),T.flipSided&&a.enable(12),T.useDepthPacking&&a.enable(13),T.dithering&&a.enable(14),T.transmission&&a.enable(15),T.sheen&&a.enable(16),T.opaque&&a.enable(17),T.pointsUvs&&a.enable(18),T.decodeVideoTexture&&a.enable(19),T.decodeVideoTextureEmissive&&a.enable(20),T.alphaToCoverage&&a.enable(21),T.numLightProbeGrids>0&&a.enable(22),T.hasPositionAttribute&&a.enable(23),v.push(a.mask)}function w(v){const T=p[v.type];let I;if(T){const C=hn[T];I=rf.clone(C.uniforms)}else I=v.uniforms;return I}function S(v,T){let I=h.get(T);return I!==void 0?++I.usedTimes:(I=new I_(i,T,v,s),c.push(I),h.set(T,I)),I}function y(v){if(--v.usedTimes===0){const T=c.indexOf(v);c[T]=c[c.length-1],c.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:S,releaseProgram:y,releaseShaderCache:b,programs:c,dispose:R}}function O_(){let i=new WeakMap;function t(a){return i.has(a)}function e(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function s(a,o,l){i.get(a)[o]=l}function r(){i=new WeakMap}return{has:t,get:e,remove:n,update:s,dispose:r}}function B_(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.material.id!==t.material.id?i.material.id-t.material.id:i.materialVariant!==t.materialVariant?i.materialVariant-t.materialVariant:i.z!==t.z?i.z-t.z:i.id-t.id}function Wc(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.z!==t.z?t.z-i.z:i.id-t.id}function Xc(){const i=[];let t=0;const e=[],n=[],s=[];function r(){t=0,e.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,_,M,m,f){let A=i[t];return A===void 0?(A={id:u.id,object:u,geometry:p,material:_,materialVariant:a(u),groupOrder:M,renderOrder:u.renderOrder,z:m,group:f},i[t]=A):(A.id=u.id,A.object=u,A.geometry=p,A.material=_,A.materialVariant=a(u),A.groupOrder=M,A.renderOrder=u.renderOrder,A.z=m,A.group=f),t++,A}function l(u,p,_,M,m,f){const A=o(u,p,_,M,m,f);_.transmission>0?n.push(A):_.transparent===!0?s.push(A):e.push(A)}function c(u,p,_,M,m,f){const A=o(u,p,_,M,m,f);_.transmission>0?n.unshift(A):_.transparent===!0?s.unshift(A):e.unshift(A)}function h(u,p,_){e.length>1&&e.sort(u||B_),n.length>1&&n.sort(p||Wc),s.length>1&&s.sort(p||Wc),_&&(e.reverse(),n.reverse(),s.reverse())}function d(){for(let u=t,p=i.length;u<p;u++){const _=i[u];if(_.id===null)break;_.id=null,_.object=null,_.geometry=null,_.material=null,_.group=null}}return{opaque:e,transmissive:n,transparent:s,init:r,push:l,unshift:c,finish:d,sort:h}}function z_(){let i=new WeakMap;function t(n,s){const r=i.get(n);let a;return r===void 0?(a=new Xc,i.set(n,[a])):s>=r.length?(a=new Xc,r.push(a)):a=r[s],a}function e(){i=new WeakMap}return{get:t,dispose:e}}function k_(){const i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new F,color:new It};break;case"SpotLight":e={position:new F,direction:new F,color:new It,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new F,color:new It,distance:0,decay:0};break;case"HemisphereLight":e={direction:new F,skyColor:new It,groundColor:new It};break;case"RectAreaLight":e={color:new It,position:new F,halfWidth:new F,halfHeight:new F};break}return i[t.id]=e,e}}}function H_(){const i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new kt};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new kt};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new kt,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}let G_=0;function V_(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function W_(i){const t=new k_,e=H_(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new F);const s=new F,r=new le,a=new le;function o(c){let h=0,d=0,u=0;for(let T=0;T<9;T++)n.probe[T].set(0,0,0);let p=0,_=0,M=0,m=0,f=0,A=0,w=0,S=0,y=0,b=0,R=0;c.sort(V_);for(let T=0,I=c.length;T<I;T++){const C=c[T],U=C.color,Y=C.intensity,Z=C.distance;let O=null;if(C.shadow&&C.shadow.map&&(C.shadow.map.texture.format===hi?O=C.shadow.map.texture:O=C.shadow.map.depthTexture||C.shadow.map.texture),C.isAmbientLight)h+=U.r*Y,d+=U.g*Y,u+=U.b*Y;else if(C.isLightProbe){for(let W=0;W<9;W++)n.probe[W].addScaledVector(C.sh.coefficients[W],Y);R++}else if(C.isDirectionalLight){const W=t.get(C);if(W.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){const V=C.shadow,Q=e.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]=O,n.directionalShadowMatrix[p]=C.shadow.matrix,A++}n.directional[p]=W,p++}else if(C.isSpotLight){const W=t.get(C);W.position.setFromMatrixPosition(C.matrixWorld),W.color.copy(U).multiplyScalar(Y),W.distance=Z,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=e.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]=O,S++}M++}else if(C.isRectAreaLight){const W=t.get(C);W.color.copy(U).multiplyScalar(Y),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=t.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=e.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[_]=Q,n.pointShadowMap[_]=O,n.pointShadowMatrix[_]=C.shadow.matrix,w++}n.point[_]=W,_++}else if(C.isHemisphereLight){const W=t.get(C);W.skyColor.copy(C.color).multiplyScalar(Y),W.groundColor.copy(C.groundColor).multiplyScalar(Y),n.hemi[f]=W,f++}}m>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=dt.LTC_FLOAT_1,n.rectAreaLTC2=dt.LTC_FLOAT_2):(n.rectAreaLTC1=dt.LTC_HALF_1,n.rectAreaLTC2=dt.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=d,n.ambient[2]=u;const v=n.hash;(v.directionalLength!==p||v.pointLength!==_||v.spotLength!==M||v.rectAreaLength!==m||v.hemiLength!==f||v.numDirectionalShadows!==A||v.numPointShadows!==w||v.numSpotShadows!==S||v.numSpotMaps!==y||v.numLightProbes!==R)&&(n.directional.length=p,n.spot.length=M,n.rectArea.length=m,n.point.length=_,n.hemi.length=f,n.directionalShadow.length=A,n.directionalShadowMap.length=A,n.pointShadow.length=w,n.pointShadowMap.length=w,n.spotShadow.length=S,n.spotShadowMap.length=S,n.directionalShadowMatrix.length=A,n.pointShadowMatrix.length=w,n.spotLightMatrix.length=S+y-b,n.spotLightMap.length=y,n.numSpotLightShadowsWithMaps=b,n.numLightProbes=R,v.directionalLength=p,v.pointLength=_,v.spotLength=M,v.rectAreaLength=m,v.hemiLength=f,v.numDirectionalShadows=A,v.numPointShadows=w,v.numSpotShadows=S,v.numSpotMaps=y,v.numLightProbes=R,n.version=G_++)}function l(c,h){let d=0,u=0,p=0,_=0,M=0;const m=h.matrixWorldInverse;for(let f=0,A=c.length;f<A;f++){const w=c[f];if(w.isDirectionalLight){const S=n.directional[d];S.direction.setFromMatrixPosition(w.matrixWorld),s.setFromMatrixPosition(w.target.matrixWorld),S.direction.sub(s),S.direction.transformDirection(m),d++}else if(w.isSpotLight){const S=n.spot[p];S.position.setFromMatrixPosition(w.matrixWorld),S.position.applyMatrix4(m),S.direction.setFromMatrixPosition(w.matrixWorld),s.setFromMatrixPosition(w.target.matrixWorld),S.direction.sub(s),S.direction.transformDirection(m),p++}else if(w.isRectAreaLight){const S=n.rectArea[_];S.position.setFromMatrixPosition(w.matrixWorld),S.position.applyMatrix4(m),a.identity(),r.copy(w.matrixWorld),r.premultiply(m),a.extractRotation(r),S.halfWidth.set(w.width*.5,0,0),S.halfHeight.set(0,w.height*.5,0),S.halfWidth.applyMatrix4(a),S.halfHeight.applyMatrix4(a),_++}else if(w.isPointLight){const S=n.point[u];S.position.setFromMatrixPosition(w.matrixWorld),S.position.applyMatrix4(m),u++}else if(w.isHemisphereLight){const S=n.hemi[M];S.direction.setFromMatrixPosition(w.matrixWorld),S.direction.transformDirection(m),M++}}}return{setup:o,setupView:l,state:n}}function qc(i){const t=new W_(i),e=[],n=[],s=[];function r(u){d.camera=u,e.length=0,n.length=0,s.length=0}function a(u){e.push(u)}function o(u){n.push(u)}function l(u){s.push(u)}function c(){t.setup(e)}function h(u){t.setupView(e,u)}const d={lightsArray:e,shadowsArray:n,lightProbeGridArray:s,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:d,setupLights:c,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:l}}function X_(i){let t=new WeakMap;function e(s,r=0){const a=t.get(s);let o;return a===void 0?(o=new qc(i),t.set(s,[o])):r>=a.length?(o=new qc(i),a.push(o)):o=a[r],o}function n(){t=new WeakMap}return{get:e,dispose:n}}const q_=`void main() {
|
|
4381
|
+
`+ee+`
|
|
4382
|
+
`+se)}else O!==""?Fe("WebGLProgram: Program Info Log:",O):(W===""||V==="")&&(te=!1);te&&(C.diagnostics={runnable:Q,programLog:O,vertexShader:{log:W,prefix:m},fragmentShader:{log:V,prefix:f}})}s.deleteShader(y),s.deleteShader(b),v=new Cr(s,M),T=p_(s,M)}let v;this.getUniforms=function(){return v===void 0&&R(this),v};let T;this.getAttributes=function(){return T===void 0&&R(this),T};let I=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=s.getProgramParameter(M,s_)),I},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(M),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=r_++,this.cacheKey=e,this.usedTimes=1,this.program=M,this.vertexShader=y,this.fragmentShader=b,this}let P_=0;class I_{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 D_(e),t.set(e,n)),n}}class D_{constructor(e){this.id=P_++,this.code=e,this.usedTimes=0}}function L_(i){return i===hi||i===Dr||i===Lr}function U_(i,e,t,n,s,r){const a=new bl,o=new I_,l=new Set,c=[],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 _(v){return l.add(v),v===0?"uv":`uv${v}`}function M(v,T,I,C,U,Y){const Z=C.fog,O=U.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===Kr?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=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,ge=se!==void 0?se.length:0;let Ve=0;O.morphAttributes.position!==void 0&&(Ve=1),O.morphAttributes.normal!==void 0&&(Ve=2),O.morphAttributes.color!==void 0&&(Ve=3);let st,We,K,re;if(ee){const Se=hn[ee];st=Se.vertexShader,We=Se.fragmentShader}else{st=v.vertexShader,We=v.fragmentShader;const Se=o.getVertexShaderStage(v),ut=o.getFragmentShaderStage(v);o.update(v,Se,ut),K=Se.id,re=ut.id}const ne=i.getRenderTarget(),k=i.state.buffers.depth.getReversed(),Pe=U.isInstancedMesh===!0,Ie=U.isBatchedMesh===!0,we=!!v.map,xe=!!v.matcap,Ne=!!Q,De=!!v.aoMap,Le=!!v.lightMap,Ke=!!v.bumpMap&&v.wireframe===!1,$e=!!v.normalMap,ct=!!v.displacementMap,ot=!!v.emissiveMap,ht=!!v.metalnessMap,vt=!!v.roughnessMap,D=v.anisotropy>0,Bt=v.clearcoat>0,Je=v.dispersion>0,E=v.iridescence>0,g=v.sheen>0,N=v.transmission>0,G=D&&!!v.anisotropyMap,X=Bt&&!!v.clearcoatMap,ie=Bt&&!!v.clearcoatNormalMap,oe=Bt&&!!v.clearcoatRoughnessMap,q=E&&!!v.iridescenceMap,J=E&&!!v.iridescenceThicknessMap,le=g&&!!v.sheenColorMap,be=g&&!!v.sheenRoughnessMap,ue=!!v.specularMap,ce=!!v.specularColorMap,Re=!!v.specularIntensityMap,Ue=N&&!!v.transmissionMap,Be=N&&!!v.thicknessMap,P=!!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 Ee={shaderID:ee,shaderType:v.type,shaderName:v.name,vertexShader:st,fragmentShader:We,defines:v.defines,customVertexShaderID:K,customFragmentShaderID:re,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:u,batching:Ie,batchingColor:Ie&&U._colorsTexture!==null,instancing:Pe,instancingColor:Pe&&U.instanceColor!==null,instancingMorph:Pe&&U.morphTexture!==null,outputColorSpace:ne===null?i.outputColorSpace:ne.isXRRenderTarget===!0?ne.texture.colorSpace:qe.workingColorSpace,alphaToCoverage:!!v.alphaToCoverage,map:we,matcap:xe,envMap:Ne,envMapMode:Ne&&Q.mapping,envMapCubeUVHeight:te,aoMap:De,lightMap:Le,bumpMap:Ke,normalMap:$e,displacementMap:ct,emissiveMap:ot,normalMapObjectSpace:$e&&v.normalMapType===v0,normalMapTangentSpace:$e&&v.normalMapType===$l,packedNormalMap:$e&&v.normalMapType===$l&&L_(v.normalMap.format),metalnessMap:ht,roughnessMap:vt,anisotropy:D,anisotropyMap:G,clearcoat:Bt,clearcoatMap:X,clearcoatNormalMap:ie,clearcoatRoughnessMap:oe,dispersion:Je,iridescence:E,iridescenceMap:q,iridescenceThicknessMap:J,sheen:g,sheenColorMap:le,sheenRoughnessMap:be,specularMap:ue,specularColorMap:ce,specularIntensityMap:Re,transmission:N,transmissionMap:Ue,thicknessMap:Be,gradientMap:P,opaque:v.transparent===!1&&v.blending===Hi&&v.alphaToCoverage===!1,alphaMap:ae,alphaTest:$,alphaHash:he,combine:v.combine,mapUv:we&&_(v.map.channel),aoMapUv:De&&_(v.aoMap.channel),lightMapUv:Le&&_(v.lightMap.channel),bumpMapUv:Ke&&_(v.bumpMap.channel),normalMapUv:$e&&_(v.normalMap.channel),displacementMapUv:ct&&_(v.displacementMap.channel),emissiveMapUv:ot&&_(v.emissiveMap.channel),metalnessMapUv:ht&&_(v.metalnessMap.channel),roughnessMapUv:vt&&_(v.roughnessMap.channel),anisotropyMapUv:G&&_(v.anisotropyMap.channel),clearcoatMapUv:X&&_(v.clearcoatMap.channel),clearcoatNormalMapUv:ie&&_(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:oe&&_(v.clearcoatRoughnessMap.channel),iridescenceMapUv:q&&_(v.iridescenceMap.channel),iridescenceThicknessMapUv:J&&_(v.iridescenceThicknessMap.channel),sheenColorMapUv:le&&_(v.sheenColorMap.channel),sheenRoughnessMapUv:be&&_(v.sheenRoughnessMap.channel),specularMapUv:ue&&_(v.specularMap.channel),specularColorMapUv:ce&&_(v.specularColorMap.channel),specularIntensityMapUv:Re&&_(v.specularIntensityMap.channel),transmissionMapUv:Ue&&_(v.transmissionMap.channel),thicknessMapUv:Be&&_(v.thicknessMap.channel),alphaMapUv:ae&&_(v.alphaMap.channel),vertexTangents:!!O.attributes.tangent&&($e||D),vertexNormals:!!O.attributes.normal,vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,pointsUvs:U.isPoints===!0&&!!O.attributes.uv&&(we||ae),fog:!!Z,useFog:v.fog===!0,fogExp2:!!Z&&Z.isFogExp2,flatShading:v.wireframe===!1&&(v.flatShading===!0||O.attributes.normal===void 0&&$e===!1&&(v.isMeshLambertMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isMeshPhysicalMaterial)),sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:k,skinning:U.isSkinnedMesh===!0,hasPositionAttribute:O.attributes.position!==void 0,morphTargets:O.morphAttributes.position!==void 0,morphNormals:O.morphAttributes.normal!==void 0,morphColors:O.morphAttributes.color!==void 0,morphTargetsCount:ge,morphTextureStride:Ve,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numSpotLightShadowsWithMaps:T.numSpotLightShadowsWithMaps,numLightProbes:T.numLightProbes,numLightProbeGrids:Y.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:v.dithering,shadowMapEnabled:i.shadowMap.enabled&&I.length>0,shadowMapType:i.shadowMap.type,toneMapping:j,decodeVideoTexture:we&&v.map.isVideoTexture===!0&&qe.getTransfer(v.map.colorSpace)===Qe,decodeVideoTextureEmissive:ot&&v.emissiveMap.isVideoTexture===!0&&qe.getTransfer(v.emissiveMap.colorSpace)===Qe,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===bn,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||Ie)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return Ee.vertexUv1s=l.has(1),Ee.vertexUv2s=l.has(2),Ee.vertexUv3s=l.has(3),l.clear(),Ee}function m(v){const T=[];if(v.shaderID?T.push(v.shaderID):(T.push(v.customVertexShaderID),T.push(v.customFragmentShaderID)),v.defines!==void 0)for(const I in v.defines)T.push(I),T.push(v.defines[I]);return v.isRawShaderMaterial===!1&&(f(T,v),A(T,v),T.push(i.outputColorSpace)),T.push(v.customProgramCacheKey),T.join()}function f(v,T){v.push(T.precision),v.push(T.outputColorSpace),v.push(T.envMapMode),v.push(T.envMapCubeUVHeight),v.push(T.mapUv),v.push(T.alphaMapUv),v.push(T.lightMapUv),v.push(T.aoMapUv),v.push(T.bumpMapUv),v.push(T.normalMapUv),v.push(T.displacementMapUv),v.push(T.emissiveMapUv),v.push(T.metalnessMapUv),v.push(T.roughnessMapUv),v.push(T.anisotropyMapUv),v.push(T.clearcoatMapUv),v.push(T.clearcoatNormalMapUv),v.push(T.clearcoatRoughnessMapUv),v.push(T.iridescenceMapUv),v.push(T.iridescenceThicknessMapUv),v.push(T.sheenColorMapUv),v.push(T.sheenRoughnessMapUv),v.push(T.specularMapUv),v.push(T.specularColorMapUv),v.push(T.specularIntensityMapUv),v.push(T.transmissionMapUv),v.push(T.thicknessMapUv),v.push(T.combine),v.push(T.fogExp2),v.push(T.sizeAttenuation),v.push(T.morphTargetsCount),v.push(T.morphAttributeCount),v.push(T.numDirLights),v.push(T.numPointLights),v.push(T.numSpotLights),v.push(T.numSpotLightMaps),v.push(T.numHemiLights),v.push(T.numRectAreaLights),v.push(T.numDirLightShadows),v.push(T.numPointLightShadows),v.push(T.numSpotLightShadows),v.push(T.numSpotLightShadowsWithMaps),v.push(T.numLightProbes),v.push(T.shadowMapType),v.push(T.toneMapping),v.push(T.numClippingPlanes),v.push(T.numClipIntersection),v.push(T.depthPacking)}function A(v,T){a.disableAll(),T.instancing&&a.enable(0),T.instancingColor&&a.enable(1),T.instancingMorph&&a.enable(2),T.matcap&&a.enable(3),T.envMap&&a.enable(4),T.normalMapObjectSpace&&a.enable(5),T.normalMapTangentSpace&&a.enable(6),T.clearcoat&&a.enable(7),T.iridescence&&a.enable(8),T.alphaTest&&a.enable(9),T.vertexColors&&a.enable(10),T.vertexAlphas&&a.enable(11),T.vertexUv1s&&a.enable(12),T.vertexUv2s&&a.enable(13),T.vertexUv3s&&a.enable(14),T.vertexTangents&&a.enable(15),T.anisotropy&&a.enable(16),T.alphaHash&&a.enable(17),T.batching&&a.enable(18),T.dispersion&&a.enable(19),T.batchingColor&&a.enable(20),T.gradientMap&&a.enable(21),T.packedNormalMap&&a.enable(22),T.vertexNormals&&a.enable(23),v.push(a.mask),a.disableAll(),T.fog&&a.enable(0),T.useFog&&a.enable(1),T.flatShading&&a.enable(2),T.logarithmicDepthBuffer&&a.enable(3),T.reversedDepthBuffer&&a.enable(4),T.skinning&&a.enable(5),T.morphTargets&&a.enable(6),T.morphNormals&&a.enable(7),T.morphColors&&a.enable(8),T.premultipliedAlpha&&a.enable(9),T.shadowMapEnabled&&a.enable(10),T.doubleSided&&a.enable(11),T.flipSided&&a.enable(12),T.useDepthPacking&&a.enable(13),T.dithering&&a.enable(14),T.transmission&&a.enable(15),T.sheen&&a.enable(16),T.opaque&&a.enable(17),T.pointsUvs&&a.enable(18),T.decodeVideoTexture&&a.enable(19),T.decodeVideoTextureEmissive&&a.enable(20),T.alphaToCoverage&&a.enable(21),T.numLightProbeGrids>0&&a.enable(22),T.hasPositionAttribute&&a.enable(23),v.push(a.mask)}function w(v){const T=p[v.type];let I;if(T){const C=hn[T];I=nf.clone(C.uniforms)}else I=v.uniforms;return I}function S(v,T){let I=h.get(T);return I!==void 0?++I.usedTimes:(I=new C_(i,T,v,s),c.push(I),h.set(T,I)),I}function y(v){if(--v.usedTimes===0){const T=c.indexOf(v);c[T]=c[c.length-1],c.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:S,releaseProgram:y,releaseShaderCache:b,programs:c,dispose:R}}function N_(){let i=new WeakMap;function e(a){return i.has(a)}function t(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function s(a,o,l){i.get(a)[o]=l}function r(){i=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:r}}function F_(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 Vc(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 Wc(){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,_,M,m,f){let A=i[e];return A===void 0?(A={id:u.id,object:u,geometry:p,material:_,materialVariant:a(u),groupOrder:M,renderOrder:u.renderOrder,z:m,group:f},i[e]=A):(A.id=u.id,A.object=u,A.geometry=p,A.material=_,A.materialVariant=a(u),A.groupOrder=M,A.renderOrder=u.renderOrder,A.z=m,A.group=f),e++,A}function l(u,p,_,M,m,f){const A=o(u,p,_,M,m,f);_.transmission>0?n.push(A):_.transparent===!0?s.push(A):t.push(A)}function c(u,p,_,M,m,f){const A=o(u,p,_,M,m,f);_.transmission>0?n.unshift(A):_.transparent===!0?s.unshift(A):t.unshift(A)}function h(u,p,_){t.length>1&&t.sort(u||F_),n.length>1&&n.sort(p||Vc),s.length>1&&s.sort(p||Vc),_&&(t.reverse(),n.reverse(),s.reverse())}function d(){for(let u=e,p=i.length;u<p;u++){const _=i[u];if(_.id===null)break;_.id=null,_.object=null,_.geometry=null,_.material=null,_.group=null}}return{opaque:t,transmissive:n,transparent:s,init:r,push:l,unshift:c,finish:d,sort:h}}function O_(){let i=new WeakMap;function e(n,s){const r=i.get(n);let a;return r===void 0?(a=new Wc,i.set(n,[a])):s>=r.length?(a=new Wc,r.push(a)):a=r[s],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function B_(){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 F,color:new Ce};break;case"SpotLight":t={position:new F,direction:new F,color:new Ce,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new F,color:new Ce,distance:0,decay:0};break;case"HemisphereLight":t={direction:new F,skyColor:new Ce,groundColor:new Ce};break;case"RectAreaLight":t={color:new Ce,position:new F,halfWidth:new F,halfHeight:new F};break}return i[e.id]=t,t}}}function z_(){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 ke};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ke};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ke,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let k_=0;function G_(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function H_(i){const e=new B_,t=z_(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new F);const s=new F,r=new lt,a=new lt;function o(c){let h=0,d=0,u=0;for(let T=0;T<9;T++)n.probe[T].set(0,0,0);let p=0,_=0,M=0,m=0,f=0,A=0,w=0,S=0,y=0,b=0,R=0;c.sort(G_);for(let T=0,I=c.length;T<I;T++){const C=c[T],U=C.color,Y=C.intensity,Z=C.distance;let O=null;if(C.shadow&&C.shadow.map&&(C.shadow.map.texture.format===hi?O=C.shadow.map.texture:O=C.shadow.map.depthTexture||C.shadow.map.texture),C.isAmbientLight)h+=U.r*Y,d+=U.g*Y,u+=U.b*Y;else if(C.isLightProbe){for(let W=0;W<9;W++)n.probe[W].addScaledVector(C.sh.coefficients[W],Y);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]=O,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(U).multiplyScalar(Y),W.distance=Z,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]=O,S++}M++}else if(C.isRectAreaLight){const W=e.get(C);W.color.copy(U).multiplyScalar(Y),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[_]=Q,n.pointShadowMap[_]=O,n.pointShadowMatrix[_]=C.shadow.matrix,w++}n.point[_]=W,_++}else if(C.isHemisphereLight){const W=e.get(C);W.skyColor.copy(C.color).multiplyScalar(Y),W.groundColor.copy(C.groundColor).multiplyScalar(Y),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!==_||v.spotLength!==M||v.rectAreaLength!==m||v.hemiLength!==f||v.numDirectionalShadows!==A||v.numPointShadows!==w||v.numSpotShadows!==S||v.numSpotMaps!==y||v.numLightProbes!==R)&&(n.directional.length=p,n.spot.length=M,n.rectArea.length=m,n.point.length=_,n.hemi.length=f,n.directionalShadow.length=A,n.directionalShadowMap.length=A,n.pointShadow.length=w,n.pointShadowMap.length=w,n.spotShadow.length=S,n.spotShadowMap.length=S,n.directionalShadowMatrix.length=A,n.pointShadowMatrix.length=w,n.spotLightMatrix.length=S+y-b,n.spotLightMap.length=y,n.numSpotLightShadowsWithMaps=b,n.numLightProbes=R,v.directionalLength=p,v.pointLength=_,v.spotLength=M,v.rectAreaLength=m,v.hemiLength=f,v.numDirectionalShadows=A,v.numPointShadows=w,v.numSpotShadows=S,v.numSpotMaps=y,v.numLightProbes=R,n.version=k_++)}function l(c,h){let d=0,u=0,p=0,_=0,M=0;const m=h.matrixWorldInverse;for(let f=0,A=c.length;f<A;f++){const w=c[f];if(w.isDirectionalLight){const S=n.directional[d];S.direction.setFromMatrixPosition(w.matrixWorld),s.setFromMatrixPosition(w.target.matrixWorld),S.direction.sub(s),S.direction.transformDirection(m),d++}else if(w.isSpotLight){const S=n.spot[p];S.position.setFromMatrixPosition(w.matrixWorld),S.position.applyMatrix4(m),S.direction.setFromMatrixPosition(w.matrixWorld),s.setFromMatrixPosition(w.target.matrixWorld),S.direction.sub(s),S.direction.transformDirection(m),p++}else if(w.isRectAreaLight){const S=n.rectArea[_];S.position.setFromMatrixPosition(w.matrixWorld),S.position.applyMatrix4(m),a.identity(),r.copy(w.matrixWorld),r.premultiply(m),a.extractRotation(r),S.halfWidth.set(w.width*.5,0,0),S.halfHeight.set(0,w.height*.5,0),S.halfWidth.applyMatrix4(a),S.halfHeight.applyMatrix4(a),_++}else if(w.isPointLight){const S=n.point[u];S.position.setFromMatrixPosition(w.matrixWorld),S.position.applyMatrix4(m),u++}else if(w.isHemisphereLight){const S=n.hemi[M];S.direction.setFromMatrixPosition(w.matrixWorld),S.direction.transformDirection(m),M++}}}return{setup:o,setupView:l,state:n}}function Xc(i){const e=new H_(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 l(u){s.push(u)}function c(){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:c,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:l}}function V_(i){let e=new WeakMap;function t(s,r=0){const a=e.get(s);let o;return a===void 0?(o=new Xc(i),e.set(s,[o])):r>=a.length?(o=new Xc(i),a.push(o)):o=a[r],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const W_=`void main() {
|
|
4383
4383
|
gl_Position = vec4( position, 1.0 );
|
|
4384
|
-
}`,
|
|
4384
|
+
}`,X_=`uniform sampler2D shadow_pass;
|
|
4385
4385
|
uniform vec2 resolution;
|
|
4386
4386
|
uniform float radius;
|
|
4387
4387
|
void main() {
|
|
@@ -4406,12 +4406,12 @@ void main() {
|
|
|
4406
4406
|
squared_mean = squared_mean / samples;
|
|
4407
4407
|
float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
|
|
4408
4408
|
gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
|
|
4409
|
-
}`,Z_=[new F(1,0,0),new F(-1,0,0),new F(0,1,0),new F(0,-1,0),new F(0,0,1),new F(0,0,-1)],K_=[new F(0,-1,0),new F(0,-1,0),new F(0,0,1),new F(0,0,-1),new F(0,-1,0),new F(0,-1,0)],Yc=new le,ps=new F,za=new F;function $_(i,t,e){let n=new mu;const s=new kt,r=new kt,a=new fe,o=new cf,l=new hf,c={},h=e.maxTextureSize,d={[Kn]:Fe,[Fe]:Kn,[bn]:bn},u=new Ve({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new kt},radius:{value:4}},vertexShader:q_,fragmentShader:Y_}),p=u.clone();p.defines.HORIZONTAL_PASS=1;const _=new Te;_.setAttribute("position",new pe(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const M=new Ge(_,u),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=br;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===Jd&&(Ft("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=br);const T=i.getRenderTarget(),I=i.getActiveCubeFace(),C=i.getActiveMipmapLevel(),U=i.state;U.setBlending(wn),U.buffers.depth.getReversed()===!0?U.buffers.color.setClear(0,0,0,0):U.buffers.color.setClear(1,1,1,1),U.buffers.depth.setTest(!0),U.setScissorTest(!1);const Y=f!==this.type;Y&&R.traverse(function(Z){Z.material&&(Array.isArray(Z.material)?Z.material.forEach(O=>O.needsUpdate=!0):Z.material.needsUpdate=!0)});for(let Z=0,O=b.length;Z<O;Z++){const W=b[Z],V=W.shadow;if(V===void 0){Ft("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 et=i.state.buffers.depth.getReversed();if(V.camera._reversedDepth=et,V.map===null||Y===!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){Ft("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}V.map=new mn(s.x,s.y,{format:hi,type:Cn,minFilter:Ie,magFilter:Ie,generateMipmaps:!1}),V.map.texture.name=W.name+".shadowMap",V.map.depthTexture=new Ji(s.x,s.y,dn),V.map.depthTexture.name=W.name+".shadowMapDepth",V.map.depthTexture.format=Pn,V.map.depthTexture.compareFunction=null,V.map.depthTexture.minFilter=Ae,V.map.depthTexture.magFilter=Ae}else W.isPointLight?(V.map=new Tu(s.x),V.map.depthTexture=new nf(s.x,gn)):(V.map=new mn(s.x,s.y),V.map.depthTexture=new Ji(s.x,s.y,gn)),V.map.depthTexture.name=W.name+".shadowMap",V.map.depthTexture.format=Pn,this.type===br?(V.map.depthTexture.compareFunction=et?yl:Ml,V.map.depthTexture.minFilter=Ie,V.map.depthTexture.magFilter=Ie):(V.map.depthTexture.compareFunction=null,V.map.depthTexture.minFilter=Ae,V.map.depthTexture.magFilter=Ae);V.camera.updateProjectionMatrix()}const tt=V.map.isWebGLCubeRenderTarget?6:1;for(let st=0;st<tt;st++){if(V.map.isWebGLCubeRenderTarget)i.setRenderTarget(V.map,st),i.clear();else{st===0&&(i.setRenderTarget(V.map),i.clear());const gt=V.getViewport(st);a.set(r.x*gt.x,r.y*gt.y,r.x*gt.z,r.y*gt.w),U.viewport(a)}if(W.isPointLight){const gt=V.camera,Vt=V.matrix,se=W.distance||gt.far;se!==gt.far&&(gt.far=se,gt.updateProjectionMatrix()),ps.setFromMatrixPosition(W.matrixWorld),gt.position.copy(ps),za.copy(gt.position),za.add(Z_[st]),gt.up.copy(K_[st]),gt.lookAt(za),gt.updateMatrixWorld(),Vt.makeTranslation(-ps.x,-ps.y,-ps.z),Yc.multiplyMatrices(gt.projectionMatrix,gt.matrixWorldInverse),V._frustum.setFromProjectionMatrix(Yc,gt.coordinateSystem,gt.reversedDepth)}else V.updateMatrices(W);n=V.getFrustum(),S(R,v,V.camera,W,this.type)}V.isPointLightShadow!==!0&&this.type===xs&&A(V,v),V.needsUpdate=!1}f=this.type,m.needsUpdate=!1,i.setRenderTarget(T,I,C)};function A(b,R){const v=t.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 mn(s.x,s.y,{format:hi,type:Cn})),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,T){let I=null;const C=v.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(C!==void 0)I=C;else if(I=v.isPointLight===!0?l:o,i.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0||R.alphaToCoverage===!0){const U=I.uuid,Y=R.uuid;let Z=c[U];Z===void 0&&(Z={},c[U]=Z);let O=Z[Y];O===void 0&&(O=I.clone(),Z[Y]=O,R.addEventListener("dispose",y)),I=O}if(I.visible=R.visible,I.wireframe=R.wireframe,T===xs?I.side=R.shadowSide!==null?R.shadowSide:R.side:I.side=R.shadowSide!==null?R.shadowSide:d[R.side],I.alphaMap=R.alphaMap,I.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,I.map=R.map,I.clipShadows=R.clipShadows,I.clippingPlanes=R.clippingPlanes,I.clipIntersection=R.clipIntersection,I.displacementMap=R.displacementMap,I.displacementScale=R.displacementScale,I.displacementBias=R.displacementBias,I.wireframeLinewidth=R.wireframeLinewidth,I.linewidth=R.linewidth,v.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const U=i.properties.get(I);U.light=v}return I}function S(b,R,v,T,I){if(b.visible===!1)return;if(b.layers.test(R.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&I===xs)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(v.matrixWorldInverse,b.matrixWorld);const Y=t.update(b),Z=b.material;if(Array.isArray(Z)){const O=Y.groups;for(let W=0,V=O.length;W<V;W++){const Q=O[W],et=Z[Q.materialIndex];if(et&&et.visible){const tt=w(b,et,T,I);b.onBeforeShadow(i,b,R,v,Y,tt,Q),i.renderBufferDirect(v,null,Y,tt,b,Q),b.onAfterShadow(i,b,R,v,Y,tt,Q)}}}else if(Z.visible){const O=w(b,Z,T,I);b.onBeforeShadow(i,b,R,v,Y,O,null),i.renderBufferDirect(v,null,Y,O,b,null),b.onAfterShadow(i,b,R,v,Y,O,null)}}const U=b.children;for(let Y=0,Z=U.length;Y<Z;Y++)S(U[Y],R,v,T,I)}function y(b){b.target.removeEventListener("dispose",y);for(const v in c){const T=c[v],I=b.target.uuid;I in T&&(T[I].dispose(),delete T[I])}}}function J_(i,t){function e(){let P=!1;const at=new fe;let $=null;const ht=new fe(0,0,0,0);return{setMask:function(mt){$!==mt&&!P&&(i.colorMask(mt,mt,mt,mt),$=mt)},setLocked:function(mt){P=mt},setClear:function(mt,j,Et,St,ue){ue===!0&&(mt*=St,j*=St,Et*=St),at.set(mt,j,Et,St),ht.equals(at)===!1&&(i.clearColor(mt,j,Et,St),ht.copy(at))},reset:function(){P=!1,$=null,ht.set(-1,0,0,0)}}}function n(){let P=!1,at=!1,$=null,ht=null,mt=null;return{setReversed:function(j){if(at!==j){const Et=t.get("EXT_clip_control");j?Et.clipControlEXT(Et.LOWER_LEFT_EXT,Et.ZERO_TO_ONE_EXT):Et.clipControlEXT(Et.LOWER_LEFT_EXT,Et.NEGATIVE_ONE_TO_ONE_EXT),at=j;const St=mt;mt=null,this.setClear(St)}},getReversed:function(){return at},setTest:function(j){j?nt(i.DEPTH_TEST):k(i.DEPTH_TEST)},setMask:function(j){$!==j&&!P&&(i.depthMask(j),$=j)},setFunc:function(j){if(at&&(j=P0[j]),ht!==j){switch(j){case eo:i.depthFunc(i.NEVER);break;case no:i.depthFunc(i.ALWAYS);break;case io:i.depthFunc(i.LESS);break;case Ki:i.depthFunc(i.LEQUAL);break;case so:i.depthFunc(i.EQUAL);break;case ro:i.depthFunc(i.GEQUAL);break;case ao:i.depthFunc(i.GREATER);break;case oo:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}ht=j}},setLocked:function(j){P=j},setClear:function(j){mt!==j&&(mt=j,at&&(j=1-j),i.clearDepth(j))},reset:function(){P=!1,$=null,ht=null,mt=null,at=!1}}}function s(){let P=!1,at=null,$=null,ht=null,mt=null,j=null,Et=null,St=null,ue=null;return{setTest:function(re){P||(re?nt(i.STENCIL_TEST):k(i.STENCIL_TEST))},setMask:function(re){at!==re&&!P&&(i.stencilMask(re),at=re)},setFunc:function(re,rn,an){($!==re||ht!==rn||mt!==an)&&(i.stencilFunc(re,rn,an),$=re,ht=rn,mt=an)},setOp:function(re,rn,an){(j!==re||Et!==rn||St!==an)&&(i.stencilOp(re,rn,an),j=re,Et=rn,St=an)},setLocked:function(re){P=re},setClear:function(re){ue!==re&&(i.clearStencil(re),ue=re)},reset:function(){P=!1,at=null,$=null,ht=null,mt=null,j=null,Et=null,St=null,ue=null}}}const r=new e,a=new n,o=new s,l=new WeakMap,c=new WeakMap;let h={},d={},u={},p=new WeakMap,_=[],M=null,m=!1,f=null,A=null,w=null,S=null,y=null,b=null,R=null,v=new It(0,0,0),T=0,I=!1,C=null,U=null,Y=null,Z=null,O=null;const W=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let V=!1,Q=0;const et=i.getParameter(i.VERSION);et.indexOf("WebGL")!==-1?(Q=parseFloat(/^WebGL (\d)/.exec(et)[1]),V=Q>=1):et.indexOf("OpenGL ES")!==-1&&(Q=parseFloat(/^OpenGL ES (\d)/.exec(et)[1]),V=Q>=2);let tt=null,st={};const gt=i.getParameter(i.SCISSOR_BOX),Vt=i.getParameter(i.VIEWPORT),se=new fe().fromArray(gt),Wt=new fe().fromArray(Vt);function K(P,at,$,ht){const mt=new Uint8Array(4),j=i.createTexture();i.bindTexture(P,j),i.texParameteri(P,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(P,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Et=0;Et<$;Et++)P===i.TEXTURE_3D||P===i.TEXTURE_2D_ARRAY?i.texImage3D(at,0,i.RGBA,1,1,ht,0,i.RGBA,i.UNSIGNED_BYTE,mt):i.texImage2D(at+Et,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,mt);return j}const rt={};rt[i.TEXTURE_2D]=K(i.TEXTURE_2D,i.TEXTURE_2D,1),rt[i.TEXTURE_CUBE_MAP]=K(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),rt[i.TEXTURE_2D_ARRAY]=K(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),rt[i.TEXTURE_3D]=K(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),nt(i.DEPTH_TEST),a.setFunc(Ki),Kt(!1),$t(Zl),nt(i.CULL_FACE),Dt(wn);function nt(P){h[P]!==!0&&(i.enable(P),h[P]=!0)}function k(P){h[P]!==!1&&(i.disable(P),h[P]=!1)}function Ct(P,at){return u[P]!==at?(i.bindFramebuffer(P,at),u[P]=at,P===i.DRAW_FRAMEBUFFER&&(u[i.FRAMEBUFFER]=at),P===i.FRAMEBUFFER&&(u[i.DRAW_FRAMEBUFFER]=at),!0):!1}function Pt(P,at){let $=_,ht=!1;if(P){$=p.get(at),$===void 0&&($=[],p.set(at,$));const mt=P.textures;if($.length!==mt.length||$[0]!==i.COLOR_ATTACHMENT0){for(let j=0,Et=mt.length;j<Et;j++)$[j]=i.COLOR_ATTACHMENT0+j;$.length=mt.length,ht=!0}}else $[0]!==i.BACK&&($[0]=i.BACK,ht=!0);ht&&i.drawBuffers($)}function wt(P){return M!==P?(i.useProgram(P),M=P,!0):!1}const xt={[ni]:i.FUNC_ADD,[jd]:i.FUNC_SUBTRACT,[t0]:i.FUNC_REVERSE_SUBTRACT};xt[e0]=i.MIN,xt[n0]=i.MAX;const Nt={[i0]:i.ZERO,[s0]:i.ONE,[r0]:i.SRC_COLOR,[ja]:i.SRC_ALPHA,[u0]:i.SRC_ALPHA_SATURATE,[c0]:i.DST_COLOR,[o0]:i.DST_ALPHA,[a0]:i.ONE_MINUS_SRC_COLOR,[to]:i.ONE_MINUS_SRC_ALPHA,[h0]:i.ONE_MINUS_DST_COLOR,[l0]:i.ONE_MINUS_DST_ALPHA,[d0]:i.CONSTANT_COLOR,[f0]:i.ONE_MINUS_CONSTANT_COLOR,[p0]:i.CONSTANT_ALPHA,[m0]:i.ONE_MINUS_CONSTANT_ALPHA};function Dt(P,at,$,ht,mt,j,Et,St,ue,re){if(P===wn){m===!0&&(k(i.BLEND),m=!1);return}if(m===!1&&(nt(i.BLEND),m=!0),P!==Qd){if(P!==f||re!==I){if((A!==ni||y!==ni)&&(i.blendEquation(i.FUNC_ADD),A=ni,y=ni),re)switch(P){case Vi:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Qa:i.blendFunc(i.ONE,i.ONE);break;case Kl:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case $l:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:Xt("WebGLState: Invalid blending: ",P);break}else switch(P){case Vi:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Qa:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case Kl:Xt("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case $l:Xt("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Xt("WebGLState: Invalid blending: ",P);break}w=null,S=null,b=null,R=null,v.set(0,0,0),T=0,f=P,I=re}return}mt=mt||at,j=j||$,Et=Et||ht,(at!==A||mt!==y)&&(i.blendEquationSeparate(xt[at],xt[mt]),A=at,y=mt),($!==w||ht!==S||j!==b||Et!==R)&&(i.blendFuncSeparate(Nt[$],Nt[ht],Nt[j],Nt[Et]),w=$,S=ht,b=j,R=Et),(St.equals(v)===!1||ue!==T)&&(i.blendColor(St.r,St.g,St.b,ue),v.copy(St),T=ue),f=P,I=!1}function Lt(P,at){P.side===bn?k(i.CULL_FACE):nt(i.CULL_FACE);let $=P.side===Fe;at&&($=!$),Kt($),P.blending===Vi&&P.transparent===!1?Dt(wn):Dt(P.blending,P.blendEquation,P.blendSrc,P.blendDst,P.blendEquationAlpha,P.blendSrcAlpha,P.blendDstAlpha,P.blendColor,P.blendAlpha,P.premultipliedAlpha),a.setFunc(P.depthFunc),a.setTest(P.depthTest),a.setMask(P.depthWrite),r.setMask(P.colorWrite);const ht=P.stencilWrite;o.setTest(ht),ht&&(o.setMask(P.stencilWriteMask),o.setFunc(P.stencilFunc,P.stencilRef,P.stencilFuncMask),o.setOp(P.stencilFail,P.stencilZFail,P.stencilZPass)),oe(P.polygonOffset,P.polygonOffsetFactor,P.polygonOffsetUnits),P.alphaToCoverage===!0?nt(i.SAMPLE_ALPHA_TO_COVERAGE):k(i.SAMPLE_ALPHA_TO_COVERAGE)}function Kt(P){C!==P&&(P?i.frontFace(i.CW):i.frontFace(i.CCW),C=P)}function $t(P){P!==Kd?(nt(i.CULL_FACE),P!==U&&(P===Zl?i.cullFace(i.BACK):P===$d?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):k(i.CULL_FACE),U=P}function ce(P){P!==Y&&(V&&i.lineWidth(P),Y=P)}function oe(P,at,$){P?(nt(i.POLYGON_OFFSET_FILL),(Z!==at||O!==$)&&(Z=at,O=$,a.getReversed()&&(at=-at),i.polygonOffset(at,$))):k(i.POLYGON_OFFSET_FILL)}function he(P){P?nt(i.SCISSOR_TEST):k(i.SCISSOR_TEST)}function ve(P){P===void 0&&(P=i.TEXTURE0+W-1),tt!==P&&(i.activeTexture(P),tt=P)}function D(P,at,$){$===void 0&&(tt===null?$=i.TEXTURE0+W-1:$=tt);let ht=st[$];ht===void 0&&(ht={type:void 0,texture:void 0},st[$]=ht),(ht.type!==P||ht.texture!==at)&&(tt!==$&&(i.activeTexture($),tt=$),i.bindTexture(P,at||rt[P]),ht.type=P,ht.texture=at)}function Be(){const P=st[tt];P!==void 0&&P.type!==void 0&&(i.bindTexture(P.type,null),P.type=void 0,P.texture=void 0)}function Jt(){try{i.compressedTexImage2D(...arguments)}catch(P){Xt("WebGLState:",P)}}function E(){try{i.compressedTexImage3D(...arguments)}catch(P){Xt("WebGLState:",P)}}function g(){try{i.texSubImage2D(...arguments)}catch(P){Xt("WebGLState:",P)}}function N(){try{i.texSubImage3D(...arguments)}catch(P){Xt("WebGLState:",P)}}function H(){try{i.compressedTexSubImage2D(...arguments)}catch(P){Xt("WebGLState:",P)}}function X(){try{i.compressedTexSubImage3D(...arguments)}catch(P){Xt("WebGLState:",P)}}function it(){try{i.texStorage2D(...arguments)}catch(P){Xt("WebGLState:",P)}}function ot(){try{i.texStorage3D(...arguments)}catch(P){Xt("WebGLState:",P)}}function q(){try{i.texImage2D(...arguments)}catch(P){Xt("WebGLState:",P)}}function J(){try{i.texImage3D(...arguments)}catch(P){Xt("WebGLState:",P)}}function lt(P){return d[P]!==void 0?d[P]:i.getParameter(P)}function bt(P,at){d[P]!==at&&(i.pixelStorei(P,at),d[P]=at)}function ut(P){se.equals(P)===!1&&(i.scissor(P.x,P.y,P.z,P.w),se.copy(P))}function ct(P){Wt.equals(P)===!1&&(i.viewport(P.x,P.y,P.z,P.w),Wt.copy(P))}function Rt(P,at){let $=c.get(at);$===void 0&&($=new WeakMap,c.set(at,$));let ht=$.get(P);ht===void 0&&(ht=i.getUniformBlockIndex(at,P.name),$.set(P,ht))}function Ut(P,at){const ht=c.get(at).get(P);l.get(at)!==ht&&(i.uniformBlockBinding(at,ht,P.__bindingPointIndex),l.set(at,ht))}function Bt(){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={},tt=null,st={},u={},p=new WeakMap,_=[],M=null,m=!1,f=null,A=null,w=null,S=null,y=null,b=null,R=null,v=new It(0,0,0),T=0,I=!1,C=null,U=null,Y=null,Z=null,O=null,se.set(0,0,i.canvas.width,i.canvas.height),Wt.set(0,0,i.canvas.width,i.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:nt,disable:k,bindFramebuffer:Ct,drawBuffers:Pt,useProgram:wt,setBlending:Dt,setMaterial:Lt,setFlipSided:Kt,setCullFace:$t,setLineWidth:ce,setPolygonOffset:oe,setScissorTest:he,activeTexture:ve,bindTexture:D,unbindTexture:Be,compressedTexImage2D:Jt,compressedTexImage3D:E,texImage2D:q,texImage3D:J,pixelStorei:bt,getParameter:lt,updateUBOMapping:Rt,uniformBlockBinding:Ut,texStorage2D:it,texStorage3D:ot,texSubImage2D:g,texSubImage3D:N,compressedTexSubImage2D:H,compressedTexSubImage3D:X,scissor:ut,viewport:ct,reset:Bt}}function Q_(i,t,e,n,s,r,a){const o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new kt,h=new WeakMap,d=new Set;let u;const p=new WeakMap;let _=!1;try{_=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function M(E,g){return _?new OffscreenCanvas(E,g):Br("canvas")}function m(E,g,N){let H=1;const X=Jt(E);if((X.width>N||X.height>N)&&(H=N/Math.max(X.width,X.height)),H<1)if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&E instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&E instanceof ImageBitmap||typeof VideoFrame<"u"&&E instanceof VideoFrame){const it=Math.floor(H*X.width),ot=Math.floor(H*X.height);u===void 0&&(u=M(it,ot));const q=g?M(it,ot):u;return q.width=it,q.height=ot,q.getContext("2d").drawImage(E,0,0,it,ot),Ft("WebGLRenderer: Texture has been resized from ("+X.width+"x"+X.height+") to ("+it+"x"+ot+")."),q}else return"data"in E&&Ft("WebGLRenderer: Image in DataTexture is too big ("+X.width+"x"+X.height+")."),E;return E}function f(E){return E.generateMipmaps}function A(E){i.generateMipmap(E)}function w(E){return E.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:E.isWebGL3DRenderTarget?i.TEXTURE_3D:E.isWebGLArrayRenderTarget||E.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function S(E,g,N,H,X,it=!1){if(E!==null){if(i[E]!==void 0)return i[E];Ft("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+E+"'")}let ot;H&&(ot=t.get("EXT_texture_norm16"),ot||Ft("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let q=g;if(g===i.RED&&(N===i.FLOAT&&(q=i.R32F),N===i.HALF_FLOAT&&(q=i.R16F),N===i.UNSIGNED_BYTE&&(q=i.R8),N===i.UNSIGNED_SHORT&&ot&&(q=ot.R16_EXT),N===i.SHORT&&ot&&(q=ot.R16_SNORM_EXT)),g===i.RED_INTEGER&&(N===i.UNSIGNED_BYTE&&(q=i.R8UI),N===i.UNSIGNED_SHORT&&(q=i.R16UI),N===i.UNSIGNED_INT&&(q=i.R32UI),N===i.BYTE&&(q=i.R8I),N===i.SHORT&&(q=i.R16I),N===i.INT&&(q=i.R32I)),g===i.RG&&(N===i.FLOAT&&(q=i.RG32F),N===i.HALF_FLOAT&&(q=i.RG16F),N===i.UNSIGNED_BYTE&&(q=i.RG8),N===i.UNSIGNED_SHORT&&ot&&(q=ot.RG16_EXT),N===i.SHORT&&ot&&(q=ot.RG16_SNORM_EXT)),g===i.RG_INTEGER&&(N===i.UNSIGNED_BYTE&&(q=i.RG8UI),N===i.UNSIGNED_SHORT&&(q=i.RG16UI),N===i.UNSIGNED_INT&&(q=i.RG32UI),N===i.BYTE&&(q=i.RG8I),N===i.SHORT&&(q=i.RG16I),N===i.INT&&(q=i.RG32I)),g===i.RGB_INTEGER&&(N===i.UNSIGNED_BYTE&&(q=i.RGB8UI),N===i.UNSIGNED_SHORT&&(q=i.RGB16UI),N===i.UNSIGNED_INT&&(q=i.RGB32UI),N===i.BYTE&&(q=i.RGB8I),N===i.SHORT&&(q=i.RGB16I),N===i.INT&&(q=i.RGB32I)),g===i.RGBA_INTEGER&&(N===i.UNSIGNED_BYTE&&(q=i.RGBA8UI),N===i.UNSIGNED_SHORT&&(q=i.RGBA16UI),N===i.UNSIGNED_INT&&(q=i.RGBA32UI),N===i.BYTE&&(q=i.RGBA8I),N===i.SHORT&&(q=i.RGBA16I),N===i.INT&&(q=i.RGBA32I)),g===i.RGB&&(N===i.UNSIGNED_SHORT&&ot&&(q=ot.RGB16_EXT),N===i.SHORT&&ot&&(q=ot.RGB16_SNORM_EXT),N===i.UNSIGNED_INT_5_9_9_9_REV&&(q=i.RGB9_E5),N===i.UNSIGNED_INT_10F_11F_11F_REV&&(q=i.R11F_G11F_B10F)),g===i.RGBA){const J=it?Fr:qt.getTransfer(X);N===i.FLOAT&&(q=i.RGBA32F),N===i.HALF_FLOAT&&(q=i.RGBA16F),N===i.UNSIGNED_BYTE&&(q=J===Qt?i.SRGB8_ALPHA8:i.RGBA8),N===i.UNSIGNED_SHORT&&ot&&(q=ot.RGBA16_EXT),N===i.SHORT&&ot&&(q=ot.RGBA16_SNORM_EXT),N===i.UNSIGNED_SHORT_4_4_4_4&&(q=i.RGBA4),N===i.UNSIGNED_SHORT_5_5_5_1&&(q=i.RGB5_A1)}return(q===i.R16F||q===i.R32F||q===i.RG16F||q===i.RG32F||q===i.RGBA16F||q===i.RGBA32F)&&t.get("EXT_color_buffer_float"),q}function y(E,g){let N;return E?g===null||g===gn||g===ws?N=i.DEPTH24_STENCIL8:g===dn?N=i.DEPTH32F_STENCIL8:g===As&&(N=i.DEPTH24_STENCIL8,Ft("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):g===null||g===gn||g===ws?N=i.DEPTH_COMPONENT24:g===dn?N=i.DEPTH_COMPONENT32F:g===As&&(N=i.DEPTH_COMPONENT16),N}function b(E,g){return f(E)===!0||E.isFramebufferTexture&&E.minFilter!==Ae&&E.minFilter!==Ie?Math.log2(Math.max(g.width,g.height))+1:E.mipmaps!==void 0&&E.mipmaps.length>0?E.mipmaps.length:E.isCompressedTexture&&Array.isArray(E.image)?g.mipmaps.length:1}function R(E){const g=E.target;g.removeEventListener("dispose",R),T(g),g.isVideoTexture&&h.delete(g),g.isHTMLTexture&&d.delete(g)}function v(E){const g=E.target;g.removeEventListener("dispose",v),C(g)}function T(E){const g=n.get(E);if(g.__webglInit===void 0)return;const N=E.source,H=p.get(N);if(H){const X=H[g.__cacheKey];X.usedTimes--,X.usedTimes===0&&I(E),Object.keys(H).length===0&&p.delete(N)}n.remove(E)}function I(E){const g=n.get(E);i.deleteTexture(g.__webglTexture);const N=E.source,H=p.get(N);delete H[g.__cacheKey],a.memory.textures--}function C(E){const g=n.get(E);if(E.depthTexture&&(E.depthTexture.dispose(),n.remove(E.depthTexture)),E.isWebGLCubeRenderTarget)for(let H=0;H<6;H++){if(Array.isArray(g.__webglFramebuffer[H]))for(let X=0;X<g.__webglFramebuffer[H].length;X++)i.deleteFramebuffer(g.__webglFramebuffer[H][X]);else i.deleteFramebuffer(g.__webglFramebuffer[H]);g.__webglDepthbuffer&&i.deleteRenderbuffer(g.__webglDepthbuffer[H])}else{if(Array.isArray(g.__webglFramebuffer))for(let H=0;H<g.__webglFramebuffer.length;H++)i.deleteFramebuffer(g.__webglFramebuffer[H]);else i.deleteFramebuffer(g.__webglFramebuffer);if(g.__webglDepthbuffer&&i.deleteRenderbuffer(g.__webglDepthbuffer),g.__webglMultisampledFramebuffer&&i.deleteFramebuffer(g.__webglMultisampledFramebuffer),g.__webglColorRenderbuffer)for(let H=0;H<g.__webglColorRenderbuffer.length;H++)g.__webglColorRenderbuffer[H]&&i.deleteRenderbuffer(g.__webglColorRenderbuffer[H]);g.__webglDepthRenderbuffer&&i.deleteRenderbuffer(g.__webglDepthRenderbuffer)}const N=E.textures;for(let H=0,X=N.length;H<X;H++){const it=n.get(N[H]);it.__webglTexture&&(i.deleteTexture(it.__webglTexture),a.memory.textures--),n.remove(N[H])}n.remove(E)}let U=0;function Y(){U=0}function Z(){return U}function O(E){U=E}function W(){const E=U;return E>=s.maxTextures&&Ft("WebGLTextures: Trying to use "+E+" texture units while this GPU supports only "+s.maxTextures),U+=1,E}function V(E){const g=[];return g.push(E.wrapS),g.push(E.wrapT),g.push(E.wrapR||0),g.push(E.magFilter),g.push(E.minFilter),g.push(E.anisotropy),g.push(E.internalFormat),g.push(E.format),g.push(E.type),g.push(E.generateMipmaps),g.push(E.premultiplyAlpha),g.push(E.flipY),g.push(E.unpackAlignment),g.push(E.colorSpace),g.join()}function Q(E,g){const N=n.get(E);if(E.isVideoTexture&&D(E),E.isRenderTargetTexture===!1&&E.isExternalTexture!==!0&&E.version>0&&N.__version!==E.version){const H=E.image;if(H===null)Ft("WebGLRenderer: Texture marked for update but no image data found.");else if(H.complete===!1)Ft("WebGLRenderer: Texture marked for update but image is incomplete");else{k(N,E,g);return}}else E.isExternalTexture&&(N.__webglTexture=E.sourceTexture?E.sourceTexture:null);e.bindTexture(i.TEXTURE_2D,N.__webglTexture,i.TEXTURE0+g)}function et(E,g){const N=n.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&N.__version!==E.version){k(N,E,g);return}else E.isExternalTexture&&(N.__webglTexture=E.sourceTexture?E.sourceTexture:null);e.bindTexture(i.TEXTURE_2D_ARRAY,N.__webglTexture,i.TEXTURE0+g)}function tt(E,g){const N=n.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&N.__version!==E.version){k(N,E,g);return}e.bindTexture(i.TEXTURE_3D,N.__webglTexture,i.TEXTURE0+g)}function st(E,g){const N=n.get(E);if(E.isCubeDepthTexture!==!0&&E.version>0&&N.__version!==E.version){Ct(N,E,g);return}e.bindTexture(i.TEXTURE_CUBE_MAP,N.__webglTexture,i.TEXTURE0+g)}const gt={[lo]:i.REPEAT,[Tn]:i.CLAMP_TO_EDGE,[co]:i.MIRRORED_REPEAT},Vt={[Ae]:i.NEAREST,[v0]:i.NEAREST_MIPMAP_NEAREST,[Ns]:i.NEAREST_MIPMAP_LINEAR,[Ie]:i.LINEAR,[la]:i.LINEAR_MIPMAP_NEAREST,[ri]:i.LINEAR_MIPMAP_LINEAR},se={[M0]:i.NEVER,[A0]:i.ALWAYS,[y0]:i.LESS,[Ml]:i.LEQUAL,[E0]:i.EQUAL,[yl]:i.GEQUAL,[b0]:i.GREATER,[T0]:i.NOTEQUAL};function Wt(E,g){if(g.type===dn&&t.has("OES_texture_float_linear")===!1&&(g.magFilter===Ie||g.magFilter===la||g.magFilter===Ns||g.magFilter===ri||g.minFilter===Ie||g.minFilter===la||g.minFilter===Ns||g.minFilter===ri)&&Ft("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(E,i.TEXTURE_WRAP_S,gt[g.wrapS]),i.texParameteri(E,i.TEXTURE_WRAP_T,gt[g.wrapT]),(E===i.TEXTURE_3D||E===i.TEXTURE_2D_ARRAY)&&i.texParameteri(E,i.TEXTURE_WRAP_R,gt[g.wrapR]),i.texParameteri(E,i.TEXTURE_MAG_FILTER,Vt[g.magFilter]),i.texParameteri(E,i.TEXTURE_MIN_FILTER,Vt[g.minFilter]),g.compareFunction&&(i.texParameteri(E,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(E,i.TEXTURE_COMPARE_FUNC,se[g.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(g.magFilter===Ae||g.minFilter!==Ns&&g.minFilter!==ri||g.type===dn&&t.has("OES_texture_float_linear")===!1)return;if(g.anisotropy>1||n.get(g).__currentAnisotropy){const N=t.get("EXT_texture_filter_anisotropic");i.texParameterf(E,N.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(g.anisotropy,s.getMaxAnisotropy())),n.get(g).__currentAnisotropy=g.anisotropy}}}function K(E,g){let N=!1;E.__webglInit===void 0&&(E.__webglInit=!0,g.addEventListener("dispose",R));const H=g.source;let X=p.get(H);X===void 0&&(X={},p.set(H,X));const it=V(g);if(it!==E.__cacheKey){X[it]===void 0&&(X[it]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,N=!0),X[it].usedTimes++;const ot=X[E.__cacheKey];ot!==void 0&&(X[E.__cacheKey].usedTimes--,ot.usedTimes===0&&I(g)),E.__cacheKey=it,E.__webglTexture=X[it].texture}return N}function rt(E,g,N){return Math.floor(Math.floor(E/N)/g)}function nt(E,g,N,H){const it=E.updateRanges;if(it.length===0)e.texSubImage2D(i.TEXTURE_2D,0,0,0,g.width,g.height,N,H,g.data);else{it.sort((bt,ut)=>bt.start-ut.start);let ot=0;for(let bt=1;bt<it.length;bt++){const ut=it[ot],ct=it[bt],Rt=ut.start+ut.count,Ut=rt(ct.start,g.width,4),Bt=rt(ut.start,g.width,4);ct.start<=Rt+1&&Ut===Bt&&rt(ct.start+ct.count-1,g.width,4)===Ut?ut.count=Math.max(ut.count,ct.start+ct.count-ut.start):(++ot,it[ot]=ct)}it.length=ot+1;const q=e.getParameter(i.UNPACK_ROW_LENGTH),J=e.getParameter(i.UNPACK_SKIP_PIXELS),lt=e.getParameter(i.UNPACK_SKIP_ROWS);e.pixelStorei(i.UNPACK_ROW_LENGTH,g.width);for(let bt=0,ut=it.length;bt<ut;bt++){const ct=it[bt],Rt=Math.floor(ct.start/4),Ut=Math.ceil(ct.count/4),Bt=Rt%g.width,P=Math.floor(Rt/g.width),at=Ut,$=1;e.pixelStorei(i.UNPACK_SKIP_PIXELS,Bt),e.pixelStorei(i.UNPACK_SKIP_ROWS,P),e.texSubImage2D(i.TEXTURE_2D,0,Bt,P,at,$,N,H,g.data)}E.clearUpdateRanges(),e.pixelStorei(i.UNPACK_ROW_LENGTH,q),e.pixelStorei(i.UNPACK_SKIP_PIXELS,J),e.pixelStorei(i.UNPACK_SKIP_ROWS,lt)}}function k(E,g,N){let H=i.TEXTURE_2D;(g.isDataArrayTexture||g.isCompressedArrayTexture)&&(H=i.TEXTURE_2D_ARRAY),g.isData3DTexture&&(H=i.TEXTURE_3D);const X=K(E,g),it=g.source;e.bindTexture(H,E.__webglTexture,i.TEXTURE0+N);const ot=n.get(it);if(it.version!==ot.__version||X===!0){if(e.activeTexture(i.TEXTURE0+N),(typeof ImageBitmap<"u"&&g.image instanceof ImageBitmap)===!1){const $=qt.getPrimaries(qt.workingColorSpace),ht=g.colorSpace===Wn?null:qt.getPrimaries(g.colorSpace),mt=g.colorSpace===Wn||$===ht?i.NONE:i.BROWSER_DEFAULT_WEBGL;e.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,g.flipY),e.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,g.premultiplyAlpha),e.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,mt)}e.pixelStorei(i.UNPACK_ALIGNMENT,g.unpackAlignment);let J=m(g.image,!1,s.maxTextureSize);J=Be(g,J);const lt=r.convert(g.format,g.colorSpace),bt=r.convert(g.type);let ut=S(g.internalFormat,lt,bt,g.normalized,g.colorSpace,g.isVideoTexture);Wt(H,g);let ct;const Rt=g.mipmaps,Ut=g.isVideoTexture!==!0,Bt=ot.__version===void 0||X===!0,P=it.dataReady,at=b(g,J);if(g.isDepthTexture)ut=y(g.format===ai,g.type),Bt&&(Ut?e.texStorage2D(i.TEXTURE_2D,1,ut,J.width,J.height):e.texImage2D(i.TEXTURE_2D,0,ut,J.width,J.height,0,lt,bt,null));else if(g.isDataTexture)if(Rt.length>0){Ut&&Bt&&e.texStorage2D(i.TEXTURE_2D,at,ut,Rt[0].width,Rt[0].height);for(let $=0,ht=Rt.length;$<ht;$++)ct=Rt[$],Ut?P&&e.texSubImage2D(i.TEXTURE_2D,$,0,0,ct.width,ct.height,lt,bt,ct.data):e.texImage2D(i.TEXTURE_2D,$,ut,ct.width,ct.height,0,lt,bt,ct.data);g.generateMipmaps=!1}else Ut?(Bt&&e.texStorage2D(i.TEXTURE_2D,at,ut,J.width,J.height),P&&nt(g,J,lt,bt)):e.texImage2D(i.TEXTURE_2D,0,ut,J.width,J.height,0,lt,bt,J.data);else if(g.isCompressedTexture)if(g.isCompressedArrayTexture){Ut&&Bt&&e.texStorage3D(i.TEXTURE_2D_ARRAY,at,ut,Rt[0].width,Rt[0].height,J.depth);for(let $=0,ht=Rt.length;$<ht;$++)if(ct=Rt[$],g.format!==sn)if(lt!==null)if(Ut){if(P)if(g.layerUpdates.size>0){const mt=bc(ct.width,ct.height,g.format,g.type);for(const j of g.layerUpdates){const Et=ct.data.subarray(j*mt/ct.data.BYTES_PER_ELEMENT,(j+1)*mt/ct.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,$,0,0,j,ct.width,ct.height,1,lt,Et)}g.clearLayerUpdates()}else e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,$,0,0,0,ct.width,ct.height,J.depth,lt,ct.data)}else e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,$,ut,ct.width,ct.height,J.depth,0,ct.data,0,0);else Ft("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ut?P&&e.texSubImage3D(i.TEXTURE_2D_ARRAY,$,0,0,0,ct.width,ct.height,J.depth,lt,bt,ct.data):e.texImage3D(i.TEXTURE_2D_ARRAY,$,ut,ct.width,ct.height,J.depth,0,lt,bt,ct.data)}else{Ut&&Bt&&e.texStorage2D(i.TEXTURE_2D,at,ut,Rt[0].width,Rt[0].height);for(let $=0,ht=Rt.length;$<ht;$++)ct=Rt[$],g.format!==sn?lt!==null?Ut?P&&e.compressedTexSubImage2D(i.TEXTURE_2D,$,0,0,ct.width,ct.height,lt,ct.data):e.compressedTexImage2D(i.TEXTURE_2D,$,ut,ct.width,ct.height,0,ct.data):Ft("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ut?P&&e.texSubImage2D(i.TEXTURE_2D,$,0,0,ct.width,ct.height,lt,bt,ct.data):e.texImage2D(i.TEXTURE_2D,$,ut,ct.width,ct.height,0,lt,bt,ct.data)}else if(g.isDataArrayTexture)if(Ut){if(Bt&&e.texStorage3D(i.TEXTURE_2D_ARRAY,at,ut,J.width,J.height,J.depth),P)if(g.layerUpdates.size>0){const $=bc(J.width,J.height,g.format,g.type);for(const ht of g.layerUpdates){const mt=J.data.subarray(ht*$/J.data.BYTES_PER_ELEMENT,(ht+1)*$/J.data.BYTES_PER_ELEMENT);e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,ht,J.width,J.height,1,lt,bt,mt)}g.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,J.width,J.height,J.depth,lt,bt,J.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,ut,J.width,J.height,J.depth,0,lt,bt,J.data);else if(g.isData3DTexture)Ut?(Bt&&e.texStorage3D(i.TEXTURE_3D,at,ut,J.width,J.height,J.depth),P&&e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,J.width,J.height,J.depth,lt,bt,J.data)):e.texImage3D(i.TEXTURE_3D,0,ut,J.width,J.height,J.depth,0,lt,bt,J.data);else if(g.isFramebufferTexture){if(Bt)if(Ut)e.texStorage2D(i.TEXTURE_2D,at,ut,J.width,J.height);else{let $=J.width,ht=J.height;for(let mt=0;mt<at;mt++)e.texImage2D(i.TEXTURE_2D,mt,ut,$,ht,0,lt,bt,null),$>>=1,ht>>=1}}else if(g.isHTMLTexture){if("texElementImage2D"in i){const $=i.canvas;if($.hasAttribute("layoutsubtree")||$.setAttribute("layoutsubtree","true"),J.parentNode!==$){$.appendChild(J),d.add(g),$.onpaint=ht=>{const mt=ht.changedElements;for(const j of d)mt.includes(j.image)&&(j.needsUpdate=!0)},$.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,J);else{const mt=i.RGBA,j=i.RGBA,Et=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,mt,j,Et,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(Rt.length>0){if(Ut&&Bt){const $=Jt(Rt[0]);e.texStorage2D(i.TEXTURE_2D,at,ut,$.width,$.height)}for(let $=0,ht=Rt.length;$<ht;$++)ct=Rt[$],Ut?P&&e.texSubImage2D(i.TEXTURE_2D,$,0,0,lt,bt,ct):e.texImage2D(i.TEXTURE_2D,$,ut,lt,bt,ct);g.generateMipmaps=!1}else if(Ut){if(Bt){const $=Jt(J);e.texStorage2D(i.TEXTURE_2D,at,ut,$.width,$.height)}P&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,lt,bt,J)}else e.texImage2D(i.TEXTURE_2D,0,ut,lt,bt,J);f(g)&&A(H),ot.__version=it.version,g.onUpdate&&g.onUpdate(g)}E.__version=g.version}function Ct(E,g,N){if(g.image.length!==6)return;const H=K(E,g),X=g.source;e.bindTexture(i.TEXTURE_CUBE_MAP,E.__webglTexture,i.TEXTURE0+N);const it=n.get(X);if(X.version!==it.__version||H===!0){e.activeTexture(i.TEXTURE0+N);const ot=qt.getPrimaries(qt.workingColorSpace),q=g.colorSpace===Wn?null:qt.getPrimaries(g.colorSpace),J=g.colorSpace===Wn||ot===q?i.NONE:i.BROWSER_DEFAULT_WEBGL;e.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,g.flipY),e.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,g.premultiplyAlpha),e.pixelStorei(i.UNPACK_ALIGNMENT,g.unpackAlignment),e.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,J);const lt=g.isCompressedTexture||g.image[0].isCompressedTexture,bt=g.image[0]&&g.image[0].isDataTexture,ut=[];for(let j=0;j<6;j++)!lt&&!bt?ut[j]=m(g.image[j],!0,s.maxCubemapSize):ut[j]=bt?g.image[j].image:g.image[j],ut[j]=Be(g,ut[j]);const ct=ut[0],Rt=r.convert(g.format,g.colorSpace),Ut=r.convert(g.type),Bt=S(g.internalFormat,Rt,Ut,g.normalized,g.colorSpace),P=g.isVideoTexture!==!0,at=it.__version===void 0||H===!0,$=X.dataReady;let ht=b(g,ct);Wt(i.TEXTURE_CUBE_MAP,g);let mt;if(lt){P&&at&&e.texStorage2D(i.TEXTURE_CUBE_MAP,ht,Bt,ct.width,ct.height);for(let j=0;j<6;j++){mt=ut[j].mipmaps;for(let Et=0;Et<mt.length;Et++){const St=mt[Et];g.format!==sn?Rt!==null?P?$&&e.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Et,0,0,St.width,St.height,Rt,St.data):e.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Et,Bt,St.width,St.height,0,St.data):Ft("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):P?$&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Et,0,0,St.width,St.height,Rt,Ut,St.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Et,Bt,St.width,St.height,0,Rt,Ut,St.data)}}}else{if(mt=g.mipmaps,P&&at){mt.length>0&&ht++;const j=Jt(ut[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,ht,Bt,j.width,j.height)}for(let j=0;j<6;j++)if(bt){P?$&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,0,0,ut[j].width,ut[j].height,Rt,Ut,ut[j].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,Bt,ut[j].width,ut[j].height,0,Rt,Ut,ut[j].data);for(let Et=0;Et<mt.length;Et++){const ue=mt[Et].image[j].image;P?$&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Et+1,0,0,ue.width,ue.height,Rt,Ut,ue.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Et+1,Bt,ue.width,ue.height,0,Rt,Ut,ue.data)}}else{P?$&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,0,0,Rt,Ut,ut[j]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,Bt,Rt,Ut,ut[j]);for(let Et=0;Et<mt.length;Et++){const St=mt[Et];P?$&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Et+1,0,0,Rt,Ut,St.image[j]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Et+1,Bt,Rt,Ut,St.image[j])}}}f(g)&&A(i.TEXTURE_CUBE_MAP),it.__version=X.version,g.onUpdate&&g.onUpdate(g)}E.__version=g.version}function Pt(E,g,N,H,X,it){const ot=r.convert(N.format,N.colorSpace),q=r.convert(N.type),J=S(N.internalFormat,ot,q,N.normalized,N.colorSpace),lt=n.get(g),bt=n.get(N);if(bt.__renderTarget=g,!lt.__hasExternalTextures){const ut=Math.max(1,g.width>>it),ct=Math.max(1,g.height>>it);X===i.TEXTURE_3D||X===i.TEXTURE_2D_ARRAY?e.texImage3D(X,it,J,ut,ct,g.depth,0,ot,q,null):e.texImage2D(X,it,J,ut,ct,0,ot,q,null)}e.bindFramebuffer(i.FRAMEBUFFER,E),ve(g)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,H,X,bt.__webglTexture,0,he(g)):(X===i.TEXTURE_2D||X>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&X<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,H,X,bt.__webglTexture,it),e.bindFramebuffer(i.FRAMEBUFFER,null)}function wt(E,g,N){if(i.bindRenderbuffer(i.RENDERBUFFER,E),g.depthBuffer){const H=g.depthTexture,X=H&&H.isDepthTexture?H.type:null,it=y(g.stencilBuffer,X),ot=g.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;ve(g)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,he(g),it,g.width,g.height):N?i.renderbufferStorageMultisample(i.RENDERBUFFER,he(g),it,g.width,g.height):i.renderbufferStorage(i.RENDERBUFFER,it,g.width,g.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,ot,i.RENDERBUFFER,E)}else{const H=g.textures;for(let X=0;X<H.length;X++){const it=H[X],ot=r.convert(it.format,it.colorSpace),q=r.convert(it.type),J=S(it.internalFormat,ot,q,it.normalized,it.colorSpace);ve(g)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,he(g),J,g.width,g.height):N?i.renderbufferStorageMultisample(i.RENDERBUFFER,he(g),J,g.width,g.height):i.renderbufferStorage(i.RENDERBUFFER,J,g.width,g.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function xt(E,g,N){const H=g.isWebGLCubeRenderTarget===!0;if(e.bindFramebuffer(i.FRAMEBUFFER,E),!(g.depthTexture&&g.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const X=n.get(g.depthTexture);if(X.__renderTarget=g,(!X.__webglTexture||g.depthTexture.image.width!==g.width||g.depthTexture.image.height!==g.height)&&(g.depthTexture.image.width=g.width,g.depthTexture.image.height=g.height,g.depthTexture.needsUpdate=!0),H){if(X.__webglInit===void 0&&(X.__webglInit=!0,g.depthTexture.addEventListener("dispose",R)),X.__webglTexture===void 0){X.__webglTexture=i.createTexture(),e.bindTexture(i.TEXTURE_CUBE_MAP,X.__webglTexture),Wt(i.TEXTURE_CUBE_MAP,g.depthTexture);const lt=r.convert(g.depthTexture.format),bt=r.convert(g.depthTexture.type);let ut;g.depthTexture.format===Pn?ut=i.DEPTH_COMPONENT24:g.depthTexture.format===ai&&(ut=i.DEPTH24_STENCIL8);for(let ct=0;ct<6;ct++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ct,0,ut,g.width,g.height,0,lt,bt,null)}}else Q(g.depthTexture,0);const it=X.__webglTexture,ot=he(g),q=H?i.TEXTURE_CUBE_MAP_POSITIVE_X+N:i.TEXTURE_2D,J=g.depthTexture.format===ai?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(g.depthTexture.format===Pn)ve(g)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,J,q,it,0,ot):i.framebufferTexture2D(i.FRAMEBUFFER,J,q,it,0);else if(g.depthTexture.format===ai)ve(g)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,J,q,it,0,ot):i.framebufferTexture2D(i.FRAMEBUFFER,J,q,it,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Nt(E){const g=n.get(E),N=E.isWebGLCubeRenderTarget===!0;if(g.__boundDepthTexture!==E.depthTexture){const H=E.depthTexture;if(g.__depthDisposeCallback&&g.__depthDisposeCallback(),H){const X=()=>{delete g.__boundDepthTexture,delete g.__depthDisposeCallback,H.removeEventListener("dispose",X)};H.addEventListener("dispose",X),g.__depthDisposeCallback=X}g.__boundDepthTexture=H}if(E.depthTexture&&!g.__autoAllocateDepthBuffer)if(N)for(let H=0;H<6;H++)xt(g.__webglFramebuffer[H],E,H);else{const H=E.texture.mipmaps;H&&H.length>0?xt(g.__webglFramebuffer[0],E,0):xt(g.__webglFramebuffer,E,0)}else if(N){g.__webglDepthbuffer=[];for(let H=0;H<6;H++)if(e.bindFramebuffer(i.FRAMEBUFFER,g.__webglFramebuffer[H]),g.__webglDepthbuffer[H]===void 0)g.__webglDepthbuffer[H]=i.createRenderbuffer(),wt(g.__webglDepthbuffer[H],E,!1);else{const X=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,it=g.__webglDepthbuffer[H];i.bindRenderbuffer(i.RENDERBUFFER,it),i.framebufferRenderbuffer(i.FRAMEBUFFER,X,i.RENDERBUFFER,it)}}else{const H=E.texture.mipmaps;if(H&&H.length>0?e.bindFramebuffer(i.FRAMEBUFFER,g.__webglFramebuffer[0]):e.bindFramebuffer(i.FRAMEBUFFER,g.__webglFramebuffer),g.__webglDepthbuffer===void 0)g.__webglDepthbuffer=i.createRenderbuffer(),wt(g.__webglDepthbuffer,E,!1);else{const X=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,it=g.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,it),i.framebufferRenderbuffer(i.FRAMEBUFFER,X,i.RENDERBUFFER,it)}}e.bindFramebuffer(i.FRAMEBUFFER,null)}function Dt(E,g,N){const H=n.get(E);g!==void 0&&Pt(H.__webglFramebuffer,E,E.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),N!==void 0&&Nt(E)}function Lt(E){const g=E.texture,N=n.get(E),H=n.get(g);E.addEventListener("dispose",v);const X=E.textures,it=E.isWebGLCubeRenderTarget===!0,ot=X.length>1;if(ot||(H.__webglTexture===void 0&&(H.__webglTexture=i.createTexture()),H.__version=g.version,a.memory.textures++),it){N.__webglFramebuffer=[];for(let q=0;q<6;q++)if(g.mipmaps&&g.mipmaps.length>0){N.__webglFramebuffer[q]=[];for(let J=0;J<g.mipmaps.length;J++)N.__webglFramebuffer[q][J]=i.createFramebuffer()}else N.__webglFramebuffer[q]=i.createFramebuffer()}else{if(g.mipmaps&&g.mipmaps.length>0){N.__webglFramebuffer=[];for(let q=0;q<g.mipmaps.length;q++)N.__webglFramebuffer[q]=i.createFramebuffer()}else N.__webglFramebuffer=i.createFramebuffer();if(ot)for(let q=0,J=X.length;q<J;q++){const lt=n.get(X[q]);lt.__webglTexture===void 0&&(lt.__webglTexture=i.createTexture(),a.memory.textures++)}if(E.samples>0&&ve(E)===!1){N.__webglMultisampledFramebuffer=i.createFramebuffer(),N.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,N.__webglMultisampledFramebuffer);for(let q=0;q<X.length;q++){const J=X[q];N.__webglColorRenderbuffer[q]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,N.__webglColorRenderbuffer[q]);const lt=r.convert(J.format,J.colorSpace),bt=r.convert(J.type),ut=S(J.internalFormat,lt,bt,J.normalized,J.colorSpace,E.isXRRenderTarget===!0),ct=he(E);i.renderbufferStorageMultisample(i.RENDERBUFFER,ct,ut,E.width,E.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+q,i.RENDERBUFFER,N.__webglColorRenderbuffer[q])}i.bindRenderbuffer(i.RENDERBUFFER,null),E.depthBuffer&&(N.__webglDepthRenderbuffer=i.createRenderbuffer(),wt(N.__webglDepthRenderbuffer,E,!0)),e.bindFramebuffer(i.FRAMEBUFFER,null)}}if(it){e.bindTexture(i.TEXTURE_CUBE_MAP,H.__webglTexture),Wt(i.TEXTURE_CUBE_MAP,g);for(let q=0;q<6;q++)if(g.mipmaps&&g.mipmaps.length>0)for(let J=0;J<g.mipmaps.length;J++)Pt(N.__webglFramebuffer[q][J],E,g,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+q,J);else Pt(N.__webglFramebuffer[q],E,g,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+q,0);f(g)&&A(i.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(ot){for(let q=0,J=X.length;q<J;q++){const lt=X[q],bt=n.get(lt);let ut=i.TEXTURE_2D;(E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)&&(ut=E.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(ut,bt.__webglTexture),Wt(ut,lt),Pt(N.__webglFramebuffer,E,lt,i.COLOR_ATTACHMENT0+q,ut,0),f(lt)&&A(ut)}e.unbindTexture()}else{let q=i.TEXTURE_2D;if((E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)&&(q=E.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(q,H.__webglTexture),Wt(q,g),g.mipmaps&&g.mipmaps.length>0)for(let J=0;J<g.mipmaps.length;J++)Pt(N.__webglFramebuffer[J],E,g,i.COLOR_ATTACHMENT0,q,J);else Pt(N.__webglFramebuffer,E,g,i.COLOR_ATTACHMENT0,q,0);f(g)&&A(q),e.unbindTexture()}E.depthBuffer&&Nt(E)}function Kt(E){const g=E.textures;for(let N=0,H=g.length;N<H;N++){const X=g[N];if(f(X)){const it=w(E),ot=n.get(X).__webglTexture;e.bindTexture(it,ot),A(it),e.unbindTexture()}}}const $t=[],ce=[];function oe(E){if(E.samples>0){if(ve(E)===!1){const g=E.textures,N=E.width,H=E.height;let X=i.COLOR_BUFFER_BIT;const it=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ot=n.get(E),q=g.length>1;if(q)for(let lt=0;lt<g.length;lt++)e.bindFramebuffer(i.FRAMEBUFFER,ot.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+lt,i.RENDERBUFFER,null),e.bindFramebuffer(i.FRAMEBUFFER,ot.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+lt,i.TEXTURE_2D,null,0);e.bindFramebuffer(i.READ_FRAMEBUFFER,ot.__webglMultisampledFramebuffer);const J=E.texture.mipmaps;J&&J.length>0?e.bindFramebuffer(i.DRAW_FRAMEBUFFER,ot.__webglFramebuffer[0]):e.bindFramebuffer(i.DRAW_FRAMEBUFFER,ot.__webglFramebuffer);for(let lt=0;lt<g.length;lt++){if(E.resolveDepthBuffer&&(E.depthBuffer&&(X|=i.DEPTH_BUFFER_BIT),E.stencilBuffer&&E.resolveStencilBuffer&&(X|=i.STENCIL_BUFFER_BIT)),q){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,ot.__webglColorRenderbuffer[lt]);const bt=n.get(g[lt]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,bt,0)}i.blitFramebuffer(0,0,N,H,0,0,N,H,X,i.NEAREST),l===!0&&($t.length=0,ce.length=0,$t.push(i.COLOR_ATTACHMENT0+lt),E.depthBuffer&&E.resolveDepthBuffer===!1&&($t.push(it),ce.push(it),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,ce)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,$t))}if(e.bindFramebuffer(i.READ_FRAMEBUFFER,null),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),q)for(let lt=0;lt<g.length;lt++){e.bindFramebuffer(i.FRAMEBUFFER,ot.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+lt,i.RENDERBUFFER,ot.__webglColorRenderbuffer[lt]);const bt=n.get(g[lt]).__webglTexture;e.bindFramebuffer(i.FRAMEBUFFER,ot.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+lt,i.TEXTURE_2D,bt,0)}e.bindFramebuffer(i.DRAW_FRAMEBUFFER,ot.__webglMultisampledFramebuffer)}else if(E.depthBuffer&&E.resolveDepthBuffer===!1&&l){const g=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[g])}}}function he(E){return Math.min(s.maxSamples,E.samples)}function ve(E){const g=n.get(E);return E.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&g.__useRenderToTexture!==!1}function D(E){const g=a.render.frame;h.get(E)!==g&&(h.set(E,g),E.update())}function Be(E,g){const N=E.colorSpace,H=E.format,X=E.type;return E.isCompressedTexture===!0||E.isVideoTexture===!0||N!==Nr&&N!==Wn&&(qt.getTransfer(N)===Qt?(H!==sn||X!==$e)&&Ft("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Xt("WebGLTextures: Unsupported texture color space:",N)),g}function Jt(E){return typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement?(c.width=E.naturalWidth||E.width,c.height=E.naturalHeight||E.height):typeof VideoFrame<"u"&&E instanceof VideoFrame?(c.width=E.displayWidth,c.height=E.displayHeight):(c.width=E.width,c.height=E.height),c}this.allocateTextureUnit=W,this.resetTextureUnits=Y,this.getTextureUnits=Z,this.setTextureUnits=O,this.setTexture2D=Q,this.setTexture2DArray=et,this.setTexture3D=tt,this.setTextureCube=st,this.rebindTextures=Dt,this.setupRenderTarget=Lt,this.updateRenderTargetMipmap=Kt,this.updateMultisampleRenderTarget=oe,this.setupDepthRenderbuffer=Nt,this.setupFrameBufferTexture=Pt,this.useMultisampledRTT=ve,this.isReversedDepthBuffer=function(){return e.buffers.depth.getReversed()}}function j_(i,t){function e(n,s=Wn){let r;const a=qt.getTransfer(s);if(n===$e)return i.UNSIGNED_BYTE;if(n===gl)return i.UNSIGNED_SHORT_4_4_4_4;if(n===_l)return i.UNSIGNED_SHORT_5_5_5_1;if(n===su)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===ru)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===nu)return i.BYTE;if(n===iu)return i.SHORT;if(n===As)return i.UNSIGNED_SHORT;if(n===ml)return i.INT;if(n===gn)return i.UNSIGNED_INT;if(n===dn)return i.FLOAT;if(n===Cn)return i.HALF_FLOAT;if(n===au)return i.ALPHA;if(n===ou)return i.RGB;if(n===sn)return i.RGBA;if(n===Pn)return i.DEPTH_COMPONENT;if(n===ai)return i.DEPTH_STENCIL;if(n===lu)return i.RED;if(n===vl)return i.RED_INTEGER;if(n===hi)return i.RG;if(n===xl)return i.RG_INTEGER;if(n===Sl)return i.RGBA_INTEGER;if(n===Tr||n===Ar||n===wr||n===Rr)if(a===Qt)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Tr)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Ar)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===wr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Rr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Tr)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Ar)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===wr)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Rr)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===ho||n===uo||n===fo||n===po)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===ho)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===uo)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===fo)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===po)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===mo||n===go||n===_o||n===vo||n===xo||n===Lr||n===So)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===mo||n===go)return a===Qt?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===_o)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===vo)return r.COMPRESSED_R11_EAC;if(n===xo)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Lr)return r.COMPRESSED_RG11_EAC;if(n===So)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Mo||n===yo||n===Eo||n===bo||n===To||n===Ao||n===wo||n===Ro||n===Co||n===Po||n===Io||n===Do||n===Lo||n===Uo)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Mo)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===yo)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Eo)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===bo)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===To)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Ao)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===wo)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Ro)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Co)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Po)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Io)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Do)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Lo)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Uo)return a===Qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===No||n===Fo||n===Oo)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===No)return a===Qt?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Fo)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Oo)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Bo||n===zo||n===Ur||n===ko)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===Bo)return r.COMPRESSED_RED_RGTC1_EXT;if(n===zo)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Ur)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===ko)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===ws?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:e}}const t1=`
|
|
4409
|
+
}`,q_=[new F(1,0,0),new F(-1,0,0),new F(0,1,0),new F(0,-1,0),new F(0,0,1),new F(0,0,-1)],Y_=[new F(0,-1,0),new F(0,-1,0),new F(0,0,1),new F(0,0,-1),new F(0,-1,0),new F(0,-1,0)],qc=new lt,ds=new F,Oa=new F;function Z_(i,e,t){let n=new du;const s=new ke,r=new ke,a=new ft,o=new of,l=new lf,c={},h=t.maxTextureSize,d={[Zn]:Dt,[Dt]:Zn,[bn]:bn},u=new kt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ke},radius:{value:4}},vertexShader:W_,fragmentShader:X_}),p=u.clone();p.defines.HORIZONTAL_PASS=1;const _=new Tt;_.setAttribute("position",new pt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const M=new zt(_,u),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Er;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===Kd&&(Fe("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Er);const T=i.getRenderTarget(),I=i.getActiveCubeFace(),C=i.getActiveMipmapLevel(),U=i.state;U.setBlending(wn),U.buffers.depth.getReversed()===!0?U.buffers.color.setClear(0,0,0,0):U.buffers.color.setClear(1,1,1,1),U.buffers.depth.setTest(!0),U.setScissorTest(!1);const Y=f!==this.type;Y&&R.traverse(function(Z){Z.material&&(Array.isArray(Z.material)?Z.material.forEach(O=>O.needsUpdate=!0):Z.material.needsUpdate=!0)});for(let Z=0,O=b.length;Z<O;Z++){const W=b[Z],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||Y===!0){if(V.map!==null&&(V.map.depthTexture!==null&&(V.map.depthTexture.dispose(),V.map.depthTexture=null),V.map.dispose()),this.type===_s){if(W.isPointLight){Fe("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}V.map=new mn(s.x,s.y,{format:hi,type:Cn,minFilter:It,magFilter:It,generateMipmaps:!1}),V.map.texture.name=W.name+".shadowMap",V.map.depthTexture=new $i(s.x,s.y,dn),V.map.depthTexture.name=W.name+".shadowMapDepth",V.map.depthTexture.format=Pn,V.map.depthTexture.compareFunction=null,V.map.depthTexture.minFilter=At,V.map.depthTexture.magFilter=At}else W.isPointLight?(V.map=new yu(s.x),V.map.depthTexture=new ef(s.x,gn)):(V.map=new mn(s.x,s.y),V.map.depthTexture=new $i(s.x,s.y,gn)),V.map.depthTexture.name=W.name+".shadowMap",V.map.depthTexture.format=Pn,this.type===Er?(V.map.depthTexture.compareFunction=te?yl:Ml,V.map.depthTexture.minFilter=It,V.map.depthTexture.magFilter=It):(V.map.depthTexture.compareFunction=null,V.map.depthTexture.minFilter=At,V.map.depthTexture.magFilter=At);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),U.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()),ds.setFromMatrixPosition(W.matrixWorld),ge.position.copy(ds),Oa.copy(ge.position),Oa.add(q_[se]),ge.up.copy(Y_[se]),ge.lookAt(Oa),ge.updateMatrixWorld(),Ve.makeTranslation(-ds.x,-ds.y,-ds.z),qc.multiplyMatrices(ge.projectionMatrix,ge.matrixWorldInverse),V._frustum.setFromProjectionMatrix(qc,ge.coordinateSystem,ge.reversedDepth)}else V.updateMatrices(W);n=V.getFrustum(),S(R,v,V.camera,W,this.type)}V.isPointLightShadow!==!0&&this.type===_s&&A(V,v),V.needsUpdate=!1}f=this.type,m.needsUpdate=!1,i.setRenderTarget(T,I,C)};function A(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 mn(s.x,s.y,{format:hi,type:Cn})),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,T){let I=null;const C=v.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(C!==void 0)I=C;else if(I=v.isPointLight===!0?l:o,i.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0||R.alphaToCoverage===!0){const U=I.uuid,Y=R.uuid;let Z=c[U];Z===void 0&&(Z={},c[U]=Z);let O=Z[Y];O===void 0&&(O=I.clone(),Z[Y]=O,R.addEventListener("dispose",y)),I=O}if(I.visible=R.visible,I.wireframe=R.wireframe,T===_s?I.side=R.shadowSide!==null?R.shadowSide:R.side:I.side=R.shadowSide!==null?R.shadowSide:d[R.side],I.alphaMap=R.alphaMap,I.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,I.map=R.map,I.clipShadows=R.clipShadows,I.clippingPlanes=R.clippingPlanes,I.clipIntersection=R.clipIntersection,I.displacementMap=R.displacementMap,I.displacementScale=R.displacementScale,I.displacementBias=R.displacementBias,I.wireframeLinewidth=R.wireframeLinewidth,I.linewidth=R.linewidth,v.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const U=i.properties.get(I);U.light=v}return I}function S(b,R,v,T,I){if(b.visible===!1)return;if(b.layers.test(R.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&I===_s)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(v.matrixWorldInverse,b.matrixWorld);const Y=e.update(b),Z=b.material;if(Array.isArray(Z)){const O=Y.groups;for(let W=0,V=O.length;W<V;W++){const Q=O[W],te=Z[Q.materialIndex];if(te&&te.visible){const ee=w(b,te,T,I);b.onBeforeShadow(i,b,R,v,Y,ee,Q),i.renderBufferDirect(v,null,Y,ee,b,Q),b.onAfterShadow(i,b,R,v,Y,ee,Q)}}}else if(Z.visible){const O=w(b,Z,T,I);b.onBeforeShadow(i,b,R,v,Y,O,null),i.renderBufferDirect(v,null,Y,O,b,null),b.onAfterShadow(i,b,R,v,Y,O,null)}}const U=b.children;for(let Y=0,Z=U.length;Y<Z;Y++)S(U[Y],R,v,T,I)}function y(b){b.target.removeEventListener("dispose",y);for(const v in c){const T=c[v],I=b.target.uuid;I in T&&(T[I].dispose(),delete T[I])}}}function K_(i,e){function t(){let P=!1;const ae=new ft;let $=null;const he=new ft(0,0,0,0);return{setMask:function(me){$!==me&&!P&&(i.colorMask(me,me,me,me),$=me)},setLocked:function(me){P=me},setClear:function(me,j,Ee,Se,ut){ut===!0&&(me*=Se,j*=Se,Ee*=Se),ae.set(me,j,Ee,Se),he.equals(ae)===!1&&(i.clearColor(me,j,Ee,Se),he.copy(ae))},reset:function(){P=!1,$=null,he.set(-1,0,0,0)}}}function n(){let P=!1,ae=!1,$=null,he=null,me=null;return{setReversed:function(j){if(ae!==j){const Ee=e.get("EXT_clip_control");j?Ee.clipControlEXT(Ee.LOWER_LEFT_EXT,Ee.ZERO_TO_ONE_EXT):Ee.clipControlEXT(Ee.LOWER_LEFT_EXT,Ee.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&&!P&&(i.depthMask(j),$=j)},setFunc:function(j){if(ae&&(j=R0[j]),he!==j){switch(j){case to:i.depthFunc(i.NEVER);break;case no:i.depthFunc(i.ALWAYS);break;case io:i.depthFunc(i.LESS);break;case Zi:i.depthFunc(i.LEQUAL);break;case so:i.depthFunc(i.EQUAL);break;case ro:i.depthFunc(i.GEQUAL);break;case ao:i.depthFunc(i.GREATER);break;case oo:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}he=j}},setLocked:function(j){P=j},setClear:function(j){me!==j&&(me=j,ae&&(j=1-j),i.clearDepth(j))},reset:function(){P=!1,$=null,he=null,me=null,ae=!1}}}function s(){let P=!1,ae=null,$=null,he=null,me=null,j=null,Ee=null,Se=null,ut=null;return{setTest:function(rt){P||(rt?ne(i.STENCIL_TEST):k(i.STENCIL_TEST))},setMask:function(rt){ae!==rt&&!P&&(i.stencilMask(rt),ae=rt)},setFunc:function(rt,rn,an){($!==rt||he!==rn||me!==an)&&(i.stencilFunc(rt,rn,an),$=rt,he=rn,me=an)},setOp:function(rt,rn,an){(j!==rt||Ee!==rn||Se!==an)&&(i.stencilOp(rt,rn,an),j=rt,Ee=rn,Se=an)},setLocked:function(rt){P=rt},setClear:function(rt){ut!==rt&&(i.clearStencil(rt),ut=rt)},reset:function(){P=!1,ae=null,$=null,he=null,me=null,j=null,Ee=null,Se=null,ut=null}}}const r=new t,a=new n,o=new s,l=new WeakMap,c=new WeakMap;let h={},d={},u={},p=new WeakMap,_=[],M=null,m=!1,f=null,A=null,w=null,S=null,y=null,b=null,R=null,v=new Ce(0,0,0),T=0,I=!1,C=null,U=null,Y=null,Z=null,O=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 ft().fromArray(ge),We=new ft().fromArray(Ve);function K(P,ae,$,he){const me=new Uint8Array(4),j=i.createTexture();i.bindTexture(P,j),i.texParameteri(P,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(P,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Ee=0;Ee<$;Ee++)P===i.TEXTURE_3D||P===i.TEXTURE_2D_ARRAY?i.texImage3D(ae,0,i.RGBA,1,1,he,0,i.RGBA,i.UNSIGNED_BYTE,me):i.texImage2D(ae+Ee,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,me);return j}const re={};re[i.TEXTURE_2D]=K(i.TEXTURE_2D,i.TEXTURE_2D,1),re[i.TEXTURE_CUBE_MAP]=K(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),re[i.TEXTURE_2D_ARRAY]=K(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),re[i.TEXTURE_3D]=K(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(Zi),Ke(!1),$e(Yl),ne(i.CULL_FACE),De(wn);function ne(P){h[P]!==!0&&(i.enable(P),h[P]=!0)}function k(P){h[P]!==!1&&(i.disable(P),h[P]=!1)}function Pe(P,ae){return u[P]!==ae?(i.bindFramebuffer(P,ae),u[P]=ae,P===i.DRAW_FRAMEBUFFER&&(u[i.FRAMEBUFFER]=ae),P===i.FRAMEBUFFER&&(u[i.DRAW_FRAMEBUFFER]=ae),!0):!1}function Ie(P,ae){let $=_,he=!1;if(P){$=p.get(ae),$===void 0&&($=[],p.set(ae,$));const me=P.textures;if($.length!==me.length||$[0]!==i.COLOR_ATTACHMENT0){for(let j=0,Ee=me.length;j<Ee;j++)$[j]=i.COLOR_ATTACHMENT0+j;$.length=me.length,he=!0}}else $[0]!==i.BACK&&($[0]=i.BACK,he=!0);he&&i.drawBuffers($)}function we(P){return M!==P?(i.useProgram(P),M=P,!0):!1}const xe={[ni]:i.FUNC_ADD,[Jd]:i.FUNC_SUBTRACT,[Qd]:i.FUNC_REVERSE_SUBTRACT};xe[jd]=i.MIN,xe[e0]=i.MAX;const Ne={[t0]:i.ZERO,[n0]:i.ONE,[i0]:i.SRC_COLOR,[ja]:i.SRC_ALPHA,[c0]:i.SRC_ALPHA_SATURATE,[o0]:i.DST_COLOR,[r0]:i.DST_ALPHA,[s0]:i.ONE_MINUS_SRC_COLOR,[eo]:i.ONE_MINUS_SRC_ALPHA,[l0]:i.ONE_MINUS_DST_COLOR,[a0]:i.ONE_MINUS_DST_ALPHA,[h0]:i.CONSTANT_COLOR,[u0]:i.ONE_MINUS_CONSTANT_COLOR,[d0]:i.CONSTANT_ALPHA,[f0]:i.ONE_MINUS_CONSTANT_ALPHA};function De(P,ae,$,he,me,j,Ee,Se,ut,rt){if(P===wn){m===!0&&(k(i.BLEND),m=!1);return}if(m===!1&&(ne(i.BLEND),m=!0),P!==$d){if(P!==f||rt!==I){if((A!==ni||y!==ni)&&(i.blendEquation(i.FUNC_ADD),A=ni,y=ni),rt)switch(P){case Hi:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Qa:i.blendFunc(i.ONE,i.ONE);break;case Zl:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Kl:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:Xe("WebGLState: Invalid blending: ",P);break}else switch(P){case Hi:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Qa:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case Zl:Xe("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Kl:Xe("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Xe("WebGLState: Invalid blending: ",P);break}w=null,S=null,b=null,R=null,v.set(0,0,0),T=0,f=P,I=rt}return}me=me||ae,j=j||$,Ee=Ee||he,(ae!==A||me!==y)&&(i.blendEquationSeparate(xe[ae],xe[me]),A=ae,y=me),($!==w||he!==S||j!==b||Ee!==R)&&(i.blendFuncSeparate(Ne[$],Ne[he],Ne[j],Ne[Ee]),w=$,S=he,b=j,R=Ee),(Se.equals(v)===!1||ut!==T)&&(i.blendColor(Se.r,Se.g,Se.b,ut),v.copy(Se),T=ut),f=P,I=!1}function Le(P,ae){P.side===bn?k(i.CULL_FACE):ne(i.CULL_FACE);let $=P.side===Dt;ae&&($=!$),Ke($),P.blending===Hi&&P.transparent===!1?De(wn):De(P.blending,P.blendEquation,P.blendSrc,P.blendDst,P.blendEquationAlpha,P.blendSrcAlpha,P.blendDstAlpha,P.blendColor,P.blendAlpha,P.premultipliedAlpha),a.setFunc(P.depthFunc),a.setTest(P.depthTest),a.setMask(P.depthWrite),r.setMask(P.colorWrite);const he=P.stencilWrite;o.setTest(he),he&&(o.setMask(P.stencilWriteMask),o.setFunc(P.stencilFunc,P.stencilRef,P.stencilFuncMask),o.setOp(P.stencilFail,P.stencilZFail,P.stencilZPass)),ot(P.polygonOffset,P.polygonOffsetFactor,P.polygonOffsetUnits),P.alphaToCoverage===!0?ne(i.SAMPLE_ALPHA_TO_COVERAGE):k(i.SAMPLE_ALPHA_TO_COVERAGE)}function Ke(P){C!==P&&(P?i.frontFace(i.CW):i.frontFace(i.CCW),C=P)}function $e(P){P!==Yd?(ne(i.CULL_FACE),P!==U&&(P===Yl?i.cullFace(i.BACK):P===Zd?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):k(i.CULL_FACE),U=P}function ct(P){P!==Y&&(V&&i.lineWidth(P),Y=P)}function ot(P,ae,$){P?(ne(i.POLYGON_OFFSET_FILL),(Z!==ae||O!==$)&&(Z=ae,O=$,a.getReversed()&&(ae=-ae),i.polygonOffset(ae,$))):k(i.POLYGON_OFFSET_FILL)}function ht(P){P?ne(i.SCISSOR_TEST):k(i.SCISSOR_TEST)}function vt(P){P===void 0&&(P=i.TEXTURE0+W-1),ee!==P&&(i.activeTexture(P),ee=P)}function D(P,ae,$){$===void 0&&(ee===null?$=i.TEXTURE0+W-1:$=ee);let he=se[$];he===void 0&&(he={type:void 0,texture:void 0},se[$]=he),(he.type!==P||he.texture!==ae)&&(ee!==$&&(i.activeTexture($),ee=$),i.bindTexture(P,ae||re[P]),he.type=P,he.texture=ae)}function Bt(){const P=se[ee];P!==void 0&&P.type!==void 0&&(i.bindTexture(P.type,null),P.type=void 0,P.texture=void 0)}function Je(){try{i.compressedTexImage2D(...arguments)}catch(P){Xe("WebGLState:",P)}}function E(){try{i.compressedTexImage3D(...arguments)}catch(P){Xe("WebGLState:",P)}}function g(){try{i.texSubImage2D(...arguments)}catch(P){Xe("WebGLState:",P)}}function N(){try{i.texSubImage3D(...arguments)}catch(P){Xe("WebGLState:",P)}}function G(){try{i.compressedTexSubImage2D(...arguments)}catch(P){Xe("WebGLState:",P)}}function X(){try{i.compressedTexSubImage3D(...arguments)}catch(P){Xe("WebGLState:",P)}}function ie(){try{i.texStorage2D(...arguments)}catch(P){Xe("WebGLState:",P)}}function oe(){try{i.texStorage3D(...arguments)}catch(P){Xe("WebGLState:",P)}}function q(){try{i.texImage2D(...arguments)}catch(P){Xe("WebGLState:",P)}}function J(){try{i.texImage3D(...arguments)}catch(P){Xe("WebGLState:",P)}}function le(P){return d[P]!==void 0?d[P]:i.getParameter(P)}function be(P,ae){d[P]!==ae&&(i.pixelStorei(P,ae),d[P]=ae)}function ue(P){st.equals(P)===!1&&(i.scissor(P.x,P.y,P.z,P.w),st.copy(P))}function ce(P){We.equals(P)===!1&&(i.viewport(P.x,P.y,P.z,P.w),We.copy(P))}function Re(P,ae){let $=c.get(ae);$===void 0&&($=new WeakMap,c.set(ae,$));let he=$.get(P);he===void 0&&(he=i.getUniformBlockIndex(ae,P.name),$.set(P,he))}function Ue(P,ae){const he=c.get(ae).get(P);l.get(ae)!==he&&(i.uniformBlockBinding(ae,he,P.__bindingPointIndex),l.set(ae,he))}function Be(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),a.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),i.pixelStorei(i.PACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.BROWSER_DEFAULT_WEBGL),i.pixelStorei(i.PACK_ROW_LENGTH,0),i.pixelStorei(i.PACK_SKIP_PIXELS,0),i.pixelStorei(i.PACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_ROW_LENGTH,0),i.pixelStorei(i.UNPACK_IMAGE_HEIGHT,0),i.pixelStorei(i.UNPACK_SKIP_PIXELS,0),i.pixelStorei(i.UNPACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_SKIP_IMAGES,0),h={},d={},ee=null,se={},u={},p=new WeakMap,_=[],M=null,m=!1,f=null,A=null,w=null,S=null,y=null,b=null,R=null,v=new Ce(0,0,0),T=0,I=!1,C=null,U=null,Y=null,Z=null,O=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:Ie,useProgram:we,setBlending:De,setMaterial:Le,setFlipSided:Ke,setCullFace:$e,setLineWidth:ct,setPolygonOffset:ot,setScissorTest:ht,activeTexture:vt,bindTexture:D,unbindTexture:Bt,compressedTexImage2D:Je,compressedTexImage3D:E,texImage2D:q,texImage3D:J,pixelStorei:be,getParameter:le,updateUBOMapping:Re,uniformBlockBinding:Ue,texStorage2D:ie,texStorage3D:oe,texSubImage2D:g,texSubImage3D:N,compressedTexSubImage2D:G,compressedTexSubImage3D:X,scissor:ue,viewport:ce,reset:Be}}function $_(i,e,t,n,s,r,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new ke,h=new WeakMap,d=new Set;let u;const p=new WeakMap;let _=!1;try{_=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function M(E,g){return _?new OffscreenCanvas(E,g):Or("canvas")}function m(E,g,N){let G=1;const X=Je(E);if((X.width>N||X.height>N)&&(G=N/Math.max(X.width,X.height)),G<1)if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&E instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&E instanceof ImageBitmap||typeof VideoFrame<"u"&&E instanceof VideoFrame){const ie=Math.floor(G*X.width),oe=Math.floor(G*X.height);u===void 0&&(u=M(ie,oe));const q=g?M(ie,oe):u;return q.width=ie,q.height=oe,q.getContext("2d").drawImage(E,0,0,ie,oe),Fe("WebGLRenderer: Texture has been resized from ("+X.width+"x"+X.height+") to ("+ie+"x"+oe+")."),q}else return"data"in E&&Fe("WebGLRenderer: Image in DataTexture is too big ("+X.width+"x"+X.height+")."),E;return E}function f(E){return E.generateMipmaps}function A(E){i.generateMipmap(E)}function w(E){return E.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:E.isWebGL3DRenderTarget?i.TEXTURE_3D:E.isWebGLArrayRenderTarget||E.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function S(E,g,N,G,X,ie=!1){if(E!==null){if(i[E]!==void 0)return i[E];Fe("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+E+"'")}let oe;G&&(oe=e.get("EXT_texture_norm16"),oe||Fe("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let q=g;if(g===i.RED&&(N===i.FLOAT&&(q=i.R32F),N===i.HALF_FLOAT&&(q=i.R16F),N===i.UNSIGNED_BYTE&&(q=i.R8),N===i.UNSIGNED_SHORT&&oe&&(q=oe.R16_EXT),N===i.SHORT&&oe&&(q=oe.R16_SNORM_EXT)),g===i.RED_INTEGER&&(N===i.UNSIGNED_BYTE&&(q=i.R8UI),N===i.UNSIGNED_SHORT&&(q=i.R16UI),N===i.UNSIGNED_INT&&(q=i.R32UI),N===i.BYTE&&(q=i.R8I),N===i.SHORT&&(q=i.R16I),N===i.INT&&(q=i.R32I)),g===i.RG&&(N===i.FLOAT&&(q=i.RG32F),N===i.HALF_FLOAT&&(q=i.RG16F),N===i.UNSIGNED_BYTE&&(q=i.RG8),N===i.UNSIGNED_SHORT&&oe&&(q=oe.RG16_EXT),N===i.SHORT&&oe&&(q=oe.RG16_SNORM_EXT)),g===i.RG_INTEGER&&(N===i.UNSIGNED_BYTE&&(q=i.RG8UI),N===i.UNSIGNED_SHORT&&(q=i.RG16UI),N===i.UNSIGNED_INT&&(q=i.RG32UI),N===i.BYTE&&(q=i.RG8I),N===i.SHORT&&(q=i.RG16I),N===i.INT&&(q=i.RG32I)),g===i.RGB_INTEGER&&(N===i.UNSIGNED_BYTE&&(q=i.RGB8UI),N===i.UNSIGNED_SHORT&&(q=i.RGB16UI),N===i.UNSIGNED_INT&&(q=i.RGB32UI),N===i.BYTE&&(q=i.RGB8I),N===i.SHORT&&(q=i.RGB16I),N===i.INT&&(q=i.RGB32I)),g===i.RGBA_INTEGER&&(N===i.UNSIGNED_BYTE&&(q=i.RGBA8UI),N===i.UNSIGNED_SHORT&&(q=i.RGBA16UI),N===i.UNSIGNED_INT&&(q=i.RGBA32UI),N===i.BYTE&&(q=i.RGBA8I),N===i.SHORT&&(q=i.RGBA16I),N===i.INT&&(q=i.RGBA32I)),g===i.RGB&&(N===i.UNSIGNED_SHORT&&oe&&(q=oe.RGB16_EXT),N===i.SHORT&&oe&&(q=oe.RGB16_SNORM_EXT),N===i.UNSIGNED_INT_5_9_9_9_REV&&(q=i.RGB9_E5),N===i.UNSIGNED_INT_10F_11F_11F_REV&&(q=i.R11F_G11F_B10F)),g===i.RGBA){const J=ie?Nr:qe.getTransfer(X);N===i.FLOAT&&(q=i.RGBA32F),N===i.HALF_FLOAT&&(q=i.RGBA16F),N===i.UNSIGNED_BYTE&&(q=J===Qe?i.SRGB8_ALPHA8:i.RGBA8),N===i.UNSIGNED_SHORT&&oe&&(q=oe.RGBA16_EXT),N===i.SHORT&&oe&&(q=oe.RGBA16_SNORM_EXT),N===i.UNSIGNED_SHORT_4_4_4_4&&(q=i.RGBA4),N===i.UNSIGNED_SHORT_5_5_5_1&&(q=i.RGB5_A1)}return(q===i.R16F||q===i.R32F||q===i.RG16F||q===i.RG32F||q===i.RGBA16F||q===i.RGBA32F)&&e.get("EXT_color_buffer_float"),q}function y(E,g){let N;return E?g===null||g===gn||g===Ts?N=i.DEPTH24_STENCIL8:g===dn?N=i.DEPTH32F_STENCIL8:g===bs&&(N=i.DEPTH24_STENCIL8,Fe("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):g===null||g===gn||g===Ts?N=i.DEPTH_COMPONENT24:g===dn?N=i.DEPTH_COMPONENT32F:g===bs&&(N=i.DEPTH_COMPONENT16),N}function b(E,g){return f(E)===!0||E.isFramebufferTexture&&E.minFilter!==At&&E.minFilter!==It?Math.log2(Math.max(g.width,g.height))+1:E.mipmaps!==void 0&&E.mipmaps.length>0?E.mipmaps.length:E.isCompressedTexture&&Array.isArray(E.image)?g.mipmaps.length:1}function R(E){const g=E.target;g.removeEventListener("dispose",R),T(g),g.isVideoTexture&&h.delete(g),g.isHTMLTexture&&d.delete(g)}function v(E){const g=E.target;g.removeEventListener("dispose",v),C(g)}function T(E){const g=n.get(E);if(g.__webglInit===void 0)return;const N=E.source,G=p.get(N);if(G){const X=G[g.__cacheKey];X.usedTimes--,X.usedTimes===0&&I(E),Object.keys(G).length===0&&p.delete(N)}n.remove(E)}function I(E){const g=n.get(E);i.deleteTexture(g.__webglTexture);const N=E.source,G=p.get(N);delete G[g.__cacheKey],a.memory.textures--}function C(E){const g=n.get(E);if(E.depthTexture&&(E.depthTexture.dispose(),n.remove(E.depthTexture)),E.isWebGLCubeRenderTarget)for(let G=0;G<6;G++){if(Array.isArray(g.__webglFramebuffer[G]))for(let X=0;X<g.__webglFramebuffer[G].length;X++)i.deleteFramebuffer(g.__webglFramebuffer[G][X]);else i.deleteFramebuffer(g.__webglFramebuffer[G]);g.__webglDepthbuffer&&i.deleteRenderbuffer(g.__webglDepthbuffer[G])}else{if(Array.isArray(g.__webglFramebuffer))for(let G=0;G<g.__webglFramebuffer.length;G++)i.deleteFramebuffer(g.__webglFramebuffer[G]);else i.deleteFramebuffer(g.__webglFramebuffer);if(g.__webglDepthbuffer&&i.deleteRenderbuffer(g.__webglDepthbuffer),g.__webglMultisampledFramebuffer&&i.deleteFramebuffer(g.__webglMultisampledFramebuffer),g.__webglColorRenderbuffer)for(let G=0;G<g.__webglColorRenderbuffer.length;G++)g.__webglColorRenderbuffer[G]&&i.deleteRenderbuffer(g.__webglColorRenderbuffer[G]);g.__webglDepthRenderbuffer&&i.deleteRenderbuffer(g.__webglDepthRenderbuffer)}const N=E.textures;for(let G=0,X=N.length;G<X;G++){const ie=n.get(N[G]);ie.__webglTexture&&(i.deleteTexture(ie.__webglTexture),a.memory.textures--),n.remove(N[G])}n.remove(E)}let U=0;function Y(){U=0}function Z(){return U}function O(E){U=E}function W(){const E=U;return E>=s.maxTextures&&Fe("WebGLTextures: Trying to use "+E+" texture units while this GPU supports only "+s.maxTextures),U+=1,E}function V(E){const g=[];return g.push(E.wrapS),g.push(E.wrapT),g.push(E.wrapR||0),g.push(E.magFilter),g.push(E.minFilter),g.push(E.anisotropy),g.push(E.internalFormat),g.push(E.format),g.push(E.type),g.push(E.generateMipmaps),g.push(E.premultiplyAlpha),g.push(E.flipY),g.push(E.unpackAlignment),g.push(E.colorSpace),g.join()}function Q(E,g){const N=n.get(E);if(E.isVideoTexture&&D(E),E.isRenderTargetTexture===!1&&E.isExternalTexture!==!0&&E.version>0&&N.__version!==E.version){const G=E.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(N,E,g);return}}else E.isExternalTexture&&(N.__webglTexture=E.sourceTexture?E.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,N.__webglTexture,i.TEXTURE0+g)}function te(E,g){const N=n.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&N.__version!==E.version){k(N,E,g);return}else E.isExternalTexture&&(N.__webglTexture=E.sourceTexture?E.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,N.__webglTexture,i.TEXTURE0+g)}function ee(E,g){const N=n.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&N.__version!==E.version){k(N,E,g);return}t.bindTexture(i.TEXTURE_3D,N.__webglTexture,i.TEXTURE0+g)}function se(E,g){const N=n.get(E);if(E.isCubeDepthTexture!==!0&&E.version>0&&N.__version!==E.version){Pe(N,E,g);return}t.bindTexture(i.TEXTURE_CUBE_MAP,N.__webglTexture,i.TEXTURE0+g)}const ge={[lo]:i.REPEAT,[Tn]:i.CLAMP_TO_EDGE,[co]:i.MIRRORED_REPEAT},Ve={[At]:i.NEAREST,[g0]:i.NEAREST_MIPMAP_NEAREST,[Us]:i.NEAREST_MIPMAP_LINEAR,[It]:i.LINEAR,[aa]:i.LINEAR_MIPMAP_NEAREST,[ri]:i.LINEAR_MIPMAP_LINEAR},st={[x0]:i.NEVER,[b0]:i.ALWAYS,[S0]:i.LESS,[Ml]:i.LEQUAL,[M0]:i.EQUAL,[yl]:i.GEQUAL,[y0]:i.GREATER,[E0]:i.NOTEQUAL};function We(E,g){if(g.type===dn&&e.has("OES_texture_float_linear")===!1&&(g.magFilter===It||g.magFilter===aa||g.magFilter===Us||g.magFilter===ri||g.minFilter===It||g.minFilter===aa||g.minFilter===Us||g.minFilter===ri)&&Fe("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(E,i.TEXTURE_WRAP_S,ge[g.wrapS]),i.texParameteri(E,i.TEXTURE_WRAP_T,ge[g.wrapT]),(E===i.TEXTURE_3D||E===i.TEXTURE_2D_ARRAY)&&i.texParameteri(E,i.TEXTURE_WRAP_R,ge[g.wrapR]),i.texParameteri(E,i.TEXTURE_MAG_FILTER,Ve[g.magFilter]),i.texParameteri(E,i.TEXTURE_MIN_FILTER,Ve[g.minFilter]),g.compareFunction&&(i.texParameteri(E,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(E,i.TEXTURE_COMPARE_FUNC,st[g.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(g.magFilter===At||g.minFilter!==Us&&g.minFilter!==ri||g.type===dn&&e.has("OES_texture_float_linear")===!1)return;if(g.anisotropy>1||n.get(g).__currentAnisotropy){const N=e.get("EXT_texture_filter_anisotropic");i.texParameterf(E,N.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(g.anisotropy,s.getMaxAnisotropy())),n.get(g).__currentAnisotropy=g.anisotropy}}}function K(E,g){let N=!1;E.__webglInit===void 0&&(E.__webglInit=!0,g.addEventListener("dispose",R));const G=g.source;let X=p.get(G);X===void 0&&(X={},p.set(G,X));const ie=V(g);if(ie!==E.__cacheKey){X[ie]===void 0&&(X[ie]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,N=!0),X[ie].usedTimes++;const oe=X[E.__cacheKey];oe!==void 0&&(X[E.__cacheKey].usedTimes--,oe.usedTimes===0&&I(g)),E.__cacheKey=ie,E.__webglTexture=X[ie].texture}return N}function re(E,g,N){return Math.floor(Math.floor(E/N)/g)}function ne(E,g,N,G){const ie=E.updateRanges;if(ie.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,g.width,g.height,N,G,g.data);else{ie.sort((be,ue)=>be.start-ue.start);let oe=0;for(let be=1;be<ie.length;be++){const ue=ie[oe],ce=ie[be],Re=ue.start+ue.count,Ue=re(ce.start,g.width,4),Be=re(ue.start,g.width,4);ce.start<=Re+1&&Ue===Be&&re(ce.start+ce.count-1,g.width,4)===Ue?ue.count=Math.max(ue.count,ce.start+ce.count-ue.start):(++oe,ie[oe]=ce)}ie.length=oe+1;const q=t.getParameter(i.UNPACK_ROW_LENGTH),J=t.getParameter(i.UNPACK_SKIP_PIXELS),le=t.getParameter(i.UNPACK_SKIP_ROWS);t.pixelStorei(i.UNPACK_ROW_LENGTH,g.width);for(let be=0,ue=ie.length;be<ue;be++){const ce=ie[be],Re=Math.floor(ce.start/4),Ue=Math.ceil(ce.count/4),Be=Re%g.width,P=Math.floor(Re/g.width),ae=Ue,$=1;t.pixelStorei(i.UNPACK_SKIP_PIXELS,Be),t.pixelStorei(i.UNPACK_SKIP_ROWS,P),t.texSubImage2D(i.TEXTURE_2D,0,Be,P,ae,$,N,G,g.data)}E.clearUpdateRanges(),t.pixelStorei(i.UNPACK_ROW_LENGTH,q),t.pixelStorei(i.UNPACK_SKIP_PIXELS,J),t.pixelStorei(i.UNPACK_SKIP_ROWS,le)}}function k(E,g,N){let G=i.TEXTURE_2D;(g.isDataArrayTexture||g.isCompressedArrayTexture)&&(G=i.TEXTURE_2D_ARRAY),g.isData3DTexture&&(G=i.TEXTURE_3D);const X=K(E,g),ie=g.source;t.bindTexture(G,E.__webglTexture,i.TEXTURE0+N);const oe=n.get(ie);if(ie.version!==oe.__version||X===!0){if(t.activeTexture(i.TEXTURE0+N),(typeof ImageBitmap<"u"&&g.image instanceof ImageBitmap)===!1){const $=qe.getPrimaries(qe.workingColorSpace),he=g.colorSpace===Vn?null:qe.getPrimaries(g.colorSpace),me=g.colorSpace===Vn||$===he?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,g.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,g.premultiplyAlpha),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,me)}t.pixelStorei(i.UNPACK_ALIGNMENT,g.unpackAlignment);let J=m(g.image,!1,s.maxTextureSize);J=Bt(g,J);const le=r.convert(g.format,g.colorSpace),be=r.convert(g.type);let ue=S(g.internalFormat,le,be,g.normalized,g.colorSpace,g.isVideoTexture);We(G,g);let ce;const Re=g.mipmaps,Ue=g.isVideoTexture!==!0,Be=oe.__version===void 0||X===!0,P=ie.dataReady,ae=b(g,J);if(g.isDepthTexture)ue=y(g.format===ai,g.type),Be&&(Ue?t.texStorage2D(i.TEXTURE_2D,1,ue,J.width,J.height):t.texImage2D(i.TEXTURE_2D,0,ue,J.width,J.height,0,le,be,null));else if(g.isDataTexture)if(Re.length>0){Ue&&Be&&t.texStorage2D(i.TEXTURE_2D,ae,ue,Re[0].width,Re[0].height);for(let $=0,he=Re.length;$<he;$++)ce=Re[$],Ue?P&&t.texSubImage2D(i.TEXTURE_2D,$,0,0,ce.width,ce.height,le,be,ce.data):t.texImage2D(i.TEXTURE_2D,$,ue,ce.width,ce.height,0,le,be,ce.data);g.generateMipmaps=!1}else Ue?(Be&&t.texStorage2D(i.TEXTURE_2D,ae,ue,J.width,J.height),P&&ne(g,J,le,be)):t.texImage2D(i.TEXTURE_2D,0,ue,J.width,J.height,0,le,be,J.data);else if(g.isCompressedTexture)if(g.isCompressedArrayTexture){Ue&&Be&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ae,ue,Re[0].width,Re[0].height,J.depth);for(let $=0,he=Re.length;$<he;$++)if(ce=Re[$],g.format!==sn)if(le!==null)if(Ue){if(P)if(g.layerUpdates.size>0){const me=Ec(ce.width,ce.height,g.format,g.type);for(const j of g.layerUpdates){const Ee=ce.data.subarray(j*me/ce.data.BYTES_PER_ELEMENT,(j+1)*me/ce.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,$,0,0,j,ce.width,ce.height,1,le,Ee)}g.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,$,0,0,0,ce.width,ce.height,J.depth,le,ce.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,$,ue,ce.width,ce.height,J.depth,0,ce.data,0,0);else Fe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ue?P&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,$,0,0,0,ce.width,ce.height,J.depth,le,be,ce.data):t.texImage3D(i.TEXTURE_2D_ARRAY,$,ue,ce.width,ce.height,J.depth,0,le,be,ce.data)}else{Ue&&Be&&t.texStorage2D(i.TEXTURE_2D,ae,ue,Re[0].width,Re[0].height);for(let $=0,he=Re.length;$<he;$++)ce=Re[$],g.format!==sn?le!==null?Ue?P&&t.compressedTexSubImage2D(i.TEXTURE_2D,$,0,0,ce.width,ce.height,le,ce.data):t.compressedTexImage2D(i.TEXTURE_2D,$,ue,ce.width,ce.height,0,ce.data):Fe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ue?P&&t.texSubImage2D(i.TEXTURE_2D,$,0,0,ce.width,ce.height,le,be,ce.data):t.texImage2D(i.TEXTURE_2D,$,ue,ce.width,ce.height,0,le,be,ce.data)}else if(g.isDataArrayTexture)if(Ue){if(Be&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ae,ue,J.width,J.height,J.depth),P)if(g.layerUpdates.size>0){const $=Ec(J.width,J.height,g.format,g.type);for(const he of g.layerUpdates){const me=J.data.subarray(he*$/J.data.BYTES_PER_ELEMENT,(he+1)*$/J.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,he,J.width,J.height,1,le,be,me)}g.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,J.width,J.height,J.depth,le,be,J.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,ue,J.width,J.height,J.depth,0,le,be,J.data);else if(g.isData3DTexture)Ue?(Be&&t.texStorage3D(i.TEXTURE_3D,ae,ue,J.width,J.height,J.depth),P&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,J.width,J.height,J.depth,le,be,J.data)):t.texImage3D(i.TEXTURE_3D,0,ue,J.width,J.height,J.depth,0,le,be,J.data);else if(g.isFramebufferTexture){if(Be)if(Ue)t.texStorage2D(i.TEXTURE_2D,ae,ue,J.width,J.height);else{let $=J.width,he=J.height;for(let me=0;me<ae;me++)t.texImage2D(i.TEXTURE_2D,me,ue,$,he,0,le,be,null),$>>=1,he>>=1}}else if(g.isHTMLTexture){if("texElementImage2D"in i){const $=i.canvas;if($.hasAttribute("layoutsubtree")||$.setAttribute("layoutsubtree","true"),J.parentNode!==$){$.appendChild(J),d.add(g),$.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,Ee=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,me,j,Ee,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(Re.length>0){if(Ue&&Be){const $=Je(Re[0]);t.texStorage2D(i.TEXTURE_2D,ae,ue,$.width,$.height)}for(let $=0,he=Re.length;$<he;$++)ce=Re[$],Ue?P&&t.texSubImage2D(i.TEXTURE_2D,$,0,0,le,be,ce):t.texImage2D(i.TEXTURE_2D,$,ue,le,be,ce);g.generateMipmaps=!1}else if(Ue){if(Be){const $=Je(J);t.texStorage2D(i.TEXTURE_2D,ae,ue,$.width,$.height)}P&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,le,be,J)}else t.texImage2D(i.TEXTURE_2D,0,ue,le,be,J);f(g)&&A(G),oe.__version=ie.version,g.onUpdate&&g.onUpdate(g)}E.__version=g.version}function Pe(E,g,N){if(g.image.length!==6)return;const G=K(E,g),X=g.source;t.bindTexture(i.TEXTURE_CUBE_MAP,E.__webglTexture,i.TEXTURE0+N);const ie=n.get(X);if(X.version!==ie.__version||G===!0){t.activeTexture(i.TEXTURE0+N);const oe=qe.getPrimaries(qe.workingColorSpace),q=g.colorSpace===Vn?null:qe.getPrimaries(g.colorSpace),J=g.colorSpace===Vn||oe===q?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,g.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,g.premultiplyAlpha),t.pixelStorei(i.UNPACK_ALIGNMENT,g.unpackAlignment),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,J);const le=g.isCompressedTexture||g.image[0].isCompressedTexture,be=g.image[0]&&g.image[0].isDataTexture,ue=[];for(let j=0;j<6;j++)!le&&!be?ue[j]=m(g.image[j],!0,s.maxCubemapSize):ue[j]=be?g.image[j].image:g.image[j],ue[j]=Bt(g,ue[j]);const ce=ue[0],Re=r.convert(g.format,g.colorSpace),Ue=r.convert(g.type),Be=S(g.internalFormat,Re,Ue,g.normalized,g.colorSpace),P=g.isVideoTexture!==!0,ae=ie.__version===void 0||G===!0,$=X.dataReady;let he=b(g,ce);We(i.TEXTURE_CUBE_MAP,g);let me;if(le){P&&ae&&t.texStorage2D(i.TEXTURE_CUBE_MAP,he,Be,ce.width,ce.height);for(let j=0;j<6;j++){me=ue[j].mipmaps;for(let Ee=0;Ee<me.length;Ee++){const Se=me[Ee];g.format!==sn?Re!==null?P?$&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Ee,0,0,Se.width,Se.height,Re,Se.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Ee,Be,Se.width,Se.height,0,Se.data):Fe("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):P?$&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Ee,0,0,Se.width,Se.height,Re,Ue,Se.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Ee,Be,Se.width,Se.height,0,Re,Ue,Se.data)}}}else{if(me=g.mipmaps,P&&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(be){P?$&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,0,0,ue[j].width,ue[j].height,Re,Ue,ue[j].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,Be,ue[j].width,ue[j].height,0,Re,Ue,ue[j].data);for(let Ee=0;Ee<me.length;Ee++){const ut=me[Ee].image[j].image;P?$&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Ee+1,0,0,ut.width,ut.height,Re,Ue,ut.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Ee+1,Be,ut.width,ut.height,0,Re,Ue,ut.data)}}else{P?$&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,0,0,Re,Ue,ue[j]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,Be,Re,Ue,ue[j]);for(let Ee=0;Ee<me.length;Ee++){const Se=me[Ee];P?$&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Ee+1,0,0,Re,Ue,Se.image[j]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Ee+1,Be,Re,Ue,Se.image[j])}}}f(g)&&A(i.TEXTURE_CUBE_MAP),ie.__version=X.version,g.onUpdate&&g.onUpdate(g)}E.__version=g.version}function Ie(E,g,N,G,X,ie){const oe=r.convert(N.format,N.colorSpace),q=r.convert(N.type),J=S(N.internalFormat,oe,q,N.normalized,N.colorSpace),le=n.get(g),be=n.get(N);if(be.__renderTarget=g,!le.__hasExternalTextures){const ue=Math.max(1,g.width>>ie),ce=Math.max(1,g.height>>ie);X===i.TEXTURE_3D||X===i.TEXTURE_2D_ARRAY?t.texImage3D(X,ie,J,ue,ce,g.depth,0,oe,q,null):t.texImage2D(X,ie,J,ue,ce,0,oe,q,null)}t.bindFramebuffer(i.FRAMEBUFFER,E),vt(g)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,G,X,be.__webglTexture,0,ht(g)):(X===i.TEXTURE_2D||X>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&X<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,G,X,be.__webglTexture,ie),t.bindFramebuffer(i.FRAMEBUFFER,null)}function we(E,g,N){if(i.bindRenderbuffer(i.RENDERBUFFER,E),g.depthBuffer){const G=g.depthTexture,X=G&&G.isDepthTexture?G.type:null,ie=y(g.stencilBuffer,X),oe=g.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;vt(g)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ht(g),ie,g.width,g.height):N?i.renderbufferStorageMultisample(i.RENDERBUFFER,ht(g),ie,g.width,g.height):i.renderbufferStorage(i.RENDERBUFFER,ie,g.width,g.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,oe,i.RENDERBUFFER,E)}else{const G=g.textures;for(let X=0;X<G.length;X++){const ie=G[X],oe=r.convert(ie.format,ie.colorSpace),q=r.convert(ie.type),J=S(ie.internalFormat,oe,q,ie.normalized,ie.colorSpace);vt(g)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ht(g),J,g.width,g.height):N?i.renderbufferStorageMultisample(i.RENDERBUFFER,ht(g),J,g.width,g.height):i.renderbufferStorage(i.RENDERBUFFER,J,g.width,g.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function xe(E,g,N){const G=g.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(i.FRAMEBUFFER,E),!(g.depthTexture&&g.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const X=n.get(g.depthTexture);if(X.__renderTarget=g,(!X.__webglTexture||g.depthTexture.image.width!==g.width||g.depthTexture.image.height!==g.height)&&(g.depthTexture.image.width=g.width,g.depthTexture.image.height=g.height,g.depthTexture.needsUpdate=!0),G){if(X.__webglInit===void 0&&(X.__webglInit=!0,g.depthTexture.addEventListener("dispose",R)),X.__webglTexture===void 0){X.__webglTexture=i.createTexture(),t.bindTexture(i.TEXTURE_CUBE_MAP,X.__webglTexture),We(i.TEXTURE_CUBE_MAP,g.depthTexture);const le=r.convert(g.depthTexture.format),be=r.convert(g.depthTexture.type);let ue;g.depthTexture.format===Pn?ue=i.DEPTH_COMPONENT24:g.depthTexture.format===ai&&(ue=i.DEPTH24_STENCIL8);for(let ce=0;ce<6;ce++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,ue,g.width,g.height,0,le,be,null)}}else Q(g.depthTexture,0);const ie=X.__webglTexture,oe=ht(g),q=G?i.TEXTURE_CUBE_MAP_POSITIVE_X+N:i.TEXTURE_2D,J=g.depthTexture.format===ai?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(g.depthTexture.format===Pn)vt(g)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,J,q,ie,0,oe):i.framebufferTexture2D(i.FRAMEBUFFER,J,q,ie,0);else if(g.depthTexture.format===ai)vt(g)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,J,q,ie,0,oe):i.framebufferTexture2D(i.FRAMEBUFFER,J,q,ie,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ne(E){const g=n.get(E),N=E.isWebGLCubeRenderTarget===!0;if(g.__boundDepthTexture!==E.depthTexture){const G=E.depthTexture;if(g.__depthDisposeCallback&&g.__depthDisposeCallback(),G){const X=()=>{delete g.__boundDepthTexture,delete g.__depthDisposeCallback,G.removeEventListener("dispose",X)};G.addEventListener("dispose",X),g.__depthDisposeCallback=X}g.__boundDepthTexture=G}if(E.depthTexture&&!g.__autoAllocateDepthBuffer)if(N)for(let G=0;G<6;G++)xe(g.__webglFramebuffer[G],E,G);else{const G=E.texture.mipmaps;G&&G.length>0?xe(g.__webglFramebuffer[0],E,0):xe(g.__webglFramebuffer,E,0)}else if(N){g.__webglDepthbuffer=[];for(let G=0;G<6;G++)if(t.bindFramebuffer(i.FRAMEBUFFER,g.__webglFramebuffer[G]),g.__webglDepthbuffer[G]===void 0)g.__webglDepthbuffer[G]=i.createRenderbuffer(),we(g.__webglDepthbuffer[G],E,!1);else{const X=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ie=g.__webglDepthbuffer[G];i.bindRenderbuffer(i.RENDERBUFFER,ie),i.framebufferRenderbuffer(i.FRAMEBUFFER,X,i.RENDERBUFFER,ie)}}else{const G=E.texture.mipmaps;if(G&&G.length>0?t.bindFramebuffer(i.FRAMEBUFFER,g.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,g.__webglFramebuffer),g.__webglDepthbuffer===void 0)g.__webglDepthbuffer=i.createRenderbuffer(),we(g.__webglDepthbuffer,E,!1);else{const X=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ie=g.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,ie),i.framebufferRenderbuffer(i.FRAMEBUFFER,X,i.RENDERBUFFER,ie)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function De(E,g,N){const G=n.get(E);g!==void 0&&Ie(G.__webglFramebuffer,E,E.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),N!==void 0&&Ne(E)}function Le(E){const g=E.texture,N=n.get(E),G=n.get(g);E.addEventListener("dispose",v);const X=E.textures,ie=E.isWebGLCubeRenderTarget===!0,oe=X.length>1;if(oe||(G.__webglTexture===void 0&&(G.__webglTexture=i.createTexture()),G.__version=g.version,a.memory.textures++),ie){N.__webglFramebuffer=[];for(let q=0;q<6;q++)if(g.mipmaps&&g.mipmaps.length>0){N.__webglFramebuffer[q]=[];for(let J=0;J<g.mipmaps.length;J++)N.__webglFramebuffer[q][J]=i.createFramebuffer()}else N.__webglFramebuffer[q]=i.createFramebuffer()}else{if(g.mipmaps&&g.mipmaps.length>0){N.__webglFramebuffer=[];for(let q=0;q<g.mipmaps.length;q++)N.__webglFramebuffer[q]=i.createFramebuffer()}else N.__webglFramebuffer=i.createFramebuffer();if(oe)for(let q=0,J=X.length;q<J;q++){const le=n.get(X[q]);le.__webglTexture===void 0&&(le.__webglTexture=i.createTexture(),a.memory.textures++)}if(E.samples>0&&vt(E)===!1){N.__webglMultisampledFramebuffer=i.createFramebuffer(),N.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,N.__webglMultisampledFramebuffer);for(let q=0;q<X.length;q++){const J=X[q];N.__webglColorRenderbuffer[q]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,N.__webglColorRenderbuffer[q]);const le=r.convert(J.format,J.colorSpace),be=r.convert(J.type),ue=S(J.internalFormat,le,be,J.normalized,J.colorSpace,E.isXRRenderTarget===!0),ce=ht(E);i.renderbufferStorageMultisample(i.RENDERBUFFER,ce,ue,E.width,E.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+q,i.RENDERBUFFER,N.__webglColorRenderbuffer[q])}i.bindRenderbuffer(i.RENDERBUFFER,null),E.depthBuffer&&(N.__webglDepthRenderbuffer=i.createRenderbuffer(),we(N.__webglDepthRenderbuffer,E,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(ie){t.bindTexture(i.TEXTURE_CUBE_MAP,G.__webglTexture),We(i.TEXTURE_CUBE_MAP,g);for(let q=0;q<6;q++)if(g.mipmaps&&g.mipmaps.length>0)for(let J=0;J<g.mipmaps.length;J++)Ie(N.__webglFramebuffer[q][J],E,g,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+q,J);else Ie(N.__webglFramebuffer[q],E,g,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+q,0);f(g)&&A(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(oe){for(let q=0,J=X.length;q<J;q++){const le=X[q],be=n.get(le);let ue=i.TEXTURE_2D;(E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)&&(ue=E.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(ue,be.__webglTexture),We(ue,le),Ie(N.__webglFramebuffer,E,le,i.COLOR_ATTACHMENT0+q,ue,0),f(le)&&A(ue)}t.unbindTexture()}else{let q=i.TEXTURE_2D;if((E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)&&(q=E.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(q,G.__webglTexture),We(q,g),g.mipmaps&&g.mipmaps.length>0)for(let J=0;J<g.mipmaps.length;J++)Ie(N.__webglFramebuffer[J],E,g,i.COLOR_ATTACHMENT0,q,J);else Ie(N.__webglFramebuffer,E,g,i.COLOR_ATTACHMENT0,q,0);f(g)&&A(q),t.unbindTexture()}E.depthBuffer&&Ne(E)}function Ke(E){const g=E.textures;for(let N=0,G=g.length;N<G;N++){const X=g[N];if(f(X)){const ie=w(E),oe=n.get(X).__webglTexture;t.bindTexture(ie,oe),A(ie),t.unbindTexture()}}}const $e=[],ct=[];function ot(E){if(E.samples>0){if(vt(E)===!1){const g=E.textures,N=E.width,G=E.height;let X=i.COLOR_BUFFER_BIT;const ie=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,oe=n.get(E),q=g.length>1;if(q)for(let le=0;le<g.length;le++)t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+le,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+le,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,oe.__webglMultisampledFramebuffer);const J=E.texture.mipmaps;J&&J.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,oe.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,oe.__webglFramebuffer);for(let le=0;le<g.length;le++){if(E.resolveDepthBuffer&&(E.depthBuffer&&(X|=i.DEPTH_BUFFER_BIT),E.stencilBuffer&&E.resolveStencilBuffer&&(X|=i.STENCIL_BUFFER_BIT)),q){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,oe.__webglColorRenderbuffer[le]);const be=n.get(g[le]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,be,0)}i.blitFramebuffer(0,0,N,G,0,0,N,G,X,i.NEAREST),l===!0&&($e.length=0,ct.length=0,$e.push(i.COLOR_ATTACHMENT0+le),E.depthBuffer&&E.resolveDepthBuffer===!1&&($e.push(ie),ct.push(ie),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,ct)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,$e))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),q)for(let le=0;le<g.length;le++){t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+le,i.RENDERBUFFER,oe.__webglColorRenderbuffer[le]);const be=n.get(g[le]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+le,i.TEXTURE_2D,be,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,oe.__webglMultisampledFramebuffer)}else if(E.depthBuffer&&E.resolveDepthBuffer===!1&&l){const g=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[g])}}}function ht(E){return Math.min(s.maxSamples,E.samples)}function vt(E){const g=n.get(E);return E.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&g.__useRenderToTexture!==!1}function D(E){const g=a.render.frame;h.get(E)!==g&&(h.set(E,g),E.update())}function Bt(E,g){const N=E.colorSpace,G=E.format,X=E.type;return E.isCompressedTexture===!0||E.isVideoTexture===!0||N!==Ur&&N!==Vn&&(qe.getTransfer(N)===Qe?(G!==sn||X!==$t)&&Fe("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Xe("WebGLTextures: Unsupported texture color space:",N)),g}function Je(E){return typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement?(c.width=E.naturalWidth||E.width,c.height=E.naturalHeight||E.height):typeof VideoFrame<"u"&&E instanceof VideoFrame?(c.width=E.displayWidth,c.height=E.displayHeight):(c.width=E.width,c.height=E.height),c}this.allocateTextureUnit=W,this.resetTextureUnits=Y,this.getTextureUnits=Z,this.setTextureUnits=O,this.setTexture2D=Q,this.setTexture2DArray=te,this.setTexture3D=ee,this.setTextureCube=se,this.rebindTextures=De,this.setupRenderTarget=Le,this.updateRenderTargetMipmap=Ke,this.updateMultisampleRenderTarget=ot,this.setupDepthRenderbuffer=Ne,this.setupFrameBufferTexture=Ie,this.useMultisampledRTT=vt,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function J_(i,e){function t(n,s=Vn){let r;const a=qe.getTransfer(s);if(n===$t)return i.UNSIGNED_BYTE;if(n===gl)return i.UNSIGNED_SHORT_4_4_4_4;if(n===_l)return i.UNSIGNED_SHORT_5_5_5_1;if(n===tu)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===nu)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===jh)return i.BYTE;if(n===eu)return i.SHORT;if(n===bs)return i.UNSIGNED_SHORT;if(n===ml)return i.INT;if(n===gn)return i.UNSIGNED_INT;if(n===dn)return i.FLOAT;if(n===Cn)return i.HALF_FLOAT;if(n===iu)return i.ALPHA;if(n===su)return i.RGB;if(n===sn)return i.RGBA;if(n===Pn)return i.DEPTH_COMPONENT;if(n===ai)return i.DEPTH_STENCIL;if(n===ru)return i.RED;if(n===vl)return i.RED_INTEGER;if(n===hi)return i.RG;if(n===xl)return i.RG_INTEGER;if(n===Sl)return i.RGBA_INTEGER;if(n===br||n===Tr||n===Ar||n===wr)if(a===Qe)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===br)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Tr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Ar)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===wr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===br)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Tr)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Ar)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===wr)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===ho||n===uo||n===fo||n===po)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===ho)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===uo)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===fo)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===po)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===mo||n===go||n===_o||n===vo||n===xo||n===Dr||n===So)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===mo||n===go)return a===Qe?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===_o)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===vo)return r.COMPRESSED_R11_EAC;if(n===xo)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Dr)return r.COMPRESSED_RG11_EAC;if(n===So)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Mo||n===yo||n===Eo||n===bo||n===To||n===Ao||n===wo||n===Ro||n===Co||n===Po||n===Io||n===Do||n===Lo||n===Uo)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Mo)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===yo)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Eo)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===bo)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===To)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Ao)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===wo)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Ro)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Co)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Po)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Io)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Do)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Lo)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Uo)return a===Qe?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===No||n===Fo||n===Oo)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===No)return a===Qe?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Fo)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Oo)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Bo||n===zo||n===Lr||n===ko)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===Bo)return r.COMPRESSED_RED_RGTC1_EXT;if(n===zo)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Lr)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===ko)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ts?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const Q_=`
|
|
4410
4410
|
void main() {
|
|
4411
4411
|
|
|
4412
4412
|
gl_Position = vec4( position, 1.0 );
|
|
4413
4413
|
|
|
4414
|
-
}`,
|
|
4414
|
+
}`,j_=`
|
|
4415
4415
|
uniform sampler2DArray depthColor;
|
|
4416
4416
|
uniform float depthWidth;
|
|
4417
4417
|
uniform float depthHeight;
|
|
@@ -4430,7 +4430,7 @@ void main() {
|
|
|
4430
4430
|
|
|
4431
4431
|
}
|
|
4432
4432
|
|
|
4433
|
-
}`;class n1{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){const n=new vu(t.texture);(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=n}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,n=new Ve({vertexShader:t1,fragmentShader:e1,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new Ge(new jr(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class i1 extends fi{constructor(t,e){super();const n=this;let s=null,r=1,a=null,o="local-floor",l=1,c=null,h=null,d=null,u=null,p=null,_=null;const M=typeof XRWebGLBinding<"u",m=new n1,f={},A=e.getContextAttributes();let w=null,S=null;const y=[],b=[],R=new kt;let v=null;const T=new Ke;T.viewport=new fe;const I=new Ke;I.viewport=new fe;const C=[T,I],U=new df;let Y=null,Z=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(K){let rt=y[K];return rt===void 0&&(rt=new ga,y[K]=rt),rt.getTargetRaySpace()},this.getControllerGrip=function(K){let rt=y[K];return rt===void 0&&(rt=new ga,y[K]=rt),rt.getGripSpace()},this.getHand=function(K){let rt=y[K];return rt===void 0&&(rt=new ga,y[K]=rt),rt.getHandSpace()};function O(K){const rt=b.indexOf(K.inputSource);if(rt===-1)return;const nt=y[rt];nt!==void 0&&(nt.update(K.inputSource,K.frame,c||a),nt.dispatchEvent({type:K.type,data:K.inputSource}))}function W(){s.removeEventListener("select",O),s.removeEventListener("selectstart",O),s.removeEventListener("selectend",O),s.removeEventListener("squeeze",O),s.removeEventListener("squeezestart",O),s.removeEventListener("squeezeend",O),s.removeEventListener("end",W),s.removeEventListener("inputsourceschange",V);for(let K=0;K<y.length;K++){const rt=b[K];rt!==null&&(b[K]=null,y[K].disconnect(rt))}Y=null,Z=null,m.reset();for(const K in f)delete f[K];t.setRenderTarget(w),p=null,u=null,d=null,s=null,S=null,Wt.stop(),n.isPresenting=!1,t.setPixelRatio(v),t.setSize(R.width,R.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(K){r=K,n.isPresenting===!0&&Ft("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(K){o=K,n.isPresenting===!0&&Ft("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(K){c=K},this.getBaseLayer=function(){return u!==null?u:p},this.getBinding=function(){return d===null&&M&&(d=new XRWebGLBinding(s,e)),d},this.getFrame=function(){return _},this.getSession=function(){return s},this.setSession=async function(K){if(s=K,s!==null){if(w=t.getRenderTarget(),s.addEventListener("select",O),s.addEventListener("selectstart",O),s.addEventListener("selectend",O),s.addEventListener("squeeze",O),s.addEventListener("squeezestart",O),s.addEventListener("squeezeend",O),s.addEventListener("end",W),s.addEventListener("inputsourceschange",V),A.xrCompatible!==!0&&await e.makeXRCompatible(),v=t.getPixelRatio(),t.getSize(R),M&&"createProjectionLayer"in XRWebGLBinding.prototype){let nt=null,k=null,Ct=null;A.depth&&(Ct=A.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,nt=A.stencil?ai:Pn,k=A.stencil?ws:gn);const Pt={colorFormat:e.RGBA8,depthFormat:Ct,scaleFactor:r};d=this.getBinding(),u=d.createProjectionLayer(Pt),s.updateRenderState({layers:[u]}),t.setPixelRatio(1),t.setSize(u.textureWidth,u.textureHeight,!1),S=new mn(u.textureWidth,u.textureHeight,{format:sn,type:$e,depthTexture:new Ji(u.textureWidth,u.textureHeight,k,void 0,void 0,void 0,void 0,void 0,void 0,nt),stencilBuffer:A.stencil,colorSpace:t.outputColorSpace,samples:A.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}else{const nt={antialias:A.antialias,alpha:!0,depth:A.depth,stencil:A.stencil,framebufferScaleFactor:r};p=new XRWebGLLayer(s,e,nt),s.updateRenderState({baseLayer:p}),t.setPixelRatio(1),t.setSize(p.framebufferWidth,p.framebufferHeight,!1),S=new mn(p.framebufferWidth,p.framebufferHeight,{format:sn,type:$e,colorSpace:t.outputColorSpace,stencilBuffer:A.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}S.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await s.requestReferenceSpace(o),Wt.setContext(s),Wt.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(K){for(let rt=0;rt<K.removed.length;rt++){const nt=K.removed[rt],k=b.indexOf(nt);k>=0&&(b[k]=null,y[k].disconnect(nt))}for(let rt=0;rt<K.added.length;rt++){const nt=K.added[rt];let k=b.indexOf(nt);if(k===-1){for(let Pt=0;Pt<y.length;Pt++)if(Pt>=b.length){b.push(nt),k=Pt;break}else if(b[Pt]===null){b[Pt]=nt,k=Pt;break}if(k===-1)break}const Ct=y[k];Ct&&Ct.connect(nt)}}const Q=new F,et=new F;function tt(K,rt,nt){Q.setFromMatrixPosition(rt.matrixWorld),et.setFromMatrixPosition(nt.matrixWorld);const k=Q.distanceTo(et),Ct=rt.projectionMatrix.elements,Pt=nt.projectionMatrix.elements,wt=Ct[14]/(Ct[10]-1),xt=Ct[14]/(Ct[10]+1),Nt=(Ct[9]+1)/Ct[5],Dt=(Ct[9]-1)/Ct[5],Lt=(Ct[8]-1)/Ct[0],Kt=(Pt[8]+1)/Pt[0],$t=wt*Lt,ce=wt*Kt,oe=k/(-Lt+Kt),he=oe*-Lt;if(rt.matrixWorld.decompose(K.position,K.quaternion,K.scale),K.translateX(he),K.translateZ(oe),K.matrixWorld.compose(K.position,K.quaternion,K.scale),K.matrixWorldInverse.copy(K.matrixWorld).invert(),Ct[10]===-1)K.projectionMatrix.copy(rt.projectionMatrix),K.projectionMatrixInverse.copy(rt.projectionMatrixInverse);else{const ve=wt+oe,D=xt+oe,Be=$t-he,Jt=ce+(k-he),E=Nt*xt/D*ve,g=Dt*xt/D*ve;K.projectionMatrix.makePerspective(Be,Jt,E,g,ve,D),K.projectionMatrixInverse.copy(K.projectionMatrix).invert()}}function st(K,rt){rt===null?K.matrixWorld.copy(K.matrix):K.matrixWorld.multiplyMatrices(rt.matrixWorld,K.matrix),K.matrixWorldInverse.copy(K.matrixWorld).invert()}this.updateCamera=function(K){if(s===null)return;let rt=K.near,nt=K.far;m.texture!==null&&(m.depthNear>0&&(rt=m.depthNear),m.depthFar>0&&(nt=m.depthFar)),U.near=I.near=T.near=rt,U.far=I.far=T.far=nt,(Y!==U.near||Z!==U.far)&&(s.updateRenderState({depthNear:U.near,depthFar:U.far}),Y=U.near,Z=U.far),U.layers.mask=K.layers.mask|6,T.layers.mask=U.layers.mask&-5,I.layers.mask=U.layers.mask&-3;const k=K.parent,Ct=U.cameras;st(U,k);for(let Pt=0;Pt<Ct.length;Pt++)st(Ct[Pt],k);Ct.length===2?tt(U,T,I):U.projectionMatrix.copy(T.projectionMatrix),gt(K,U,k)};function gt(K,rt,nt){nt===null?K.matrix.copy(rt.matrixWorld):(K.matrix.copy(nt.matrixWorld),K.matrix.invert(),K.matrix.multiply(rt.matrixWorld)),K.matrix.decompose(K.position,K.quaternion,K.scale),K.updateMatrixWorld(!0),K.projectionMatrix.copy(rt.projectionMatrix),K.projectionMatrixInverse.copy(rt.projectionMatrixInverse),K.isPerspectiveCamera&&(K.fov=Go*2*Math.atan(1/K.projectionMatrix.elements[5]),K.zoom=1)}this.getCamera=function(){return U},this.getFoveation=function(){if(!(u===null&&p===null))return l},this.setFoveation=function(K){l=K,u!==null&&(u.fixedFoveation=K),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=K)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(U)},this.getCameraTexture=function(K){return f[K]};let Vt=null;function se(K,rt){if(h=rt.getViewerPose(c||a),_=rt,h!==null){const nt=h.views;p!==null&&(t.setRenderTargetFramebuffer(S,p.framebuffer),t.setRenderTarget(S));let k=!1;nt.length!==U.cameras.length&&(U.cameras.length=0,k=!0);for(let xt=0;xt<nt.length;xt++){const Nt=nt[xt];let Dt=null;if(p!==null)Dt=p.getViewport(Nt);else{const Kt=d.getViewSubImage(u,Nt);Dt=Kt.viewport,xt===0&&(t.setRenderTargetTextures(S,Kt.colorTexture,Kt.depthStencilTexture),t.setRenderTarget(S))}let Lt=C[xt];Lt===void 0&&(Lt=new Ke,Lt.layers.enable(xt),Lt.viewport=new fe,C[xt]=Lt),Lt.matrix.fromArray(Nt.transform.matrix),Lt.matrix.decompose(Lt.position,Lt.quaternion,Lt.scale),Lt.projectionMatrix.fromArray(Nt.projectionMatrix),Lt.projectionMatrixInverse.copy(Lt.projectionMatrix).invert(),Lt.viewport.set(Dt.x,Dt.y,Dt.width,Dt.height),xt===0&&(U.matrix.copy(Lt.matrix),U.matrix.decompose(U.position,U.quaternion,U.scale)),k===!0&&U.cameras.push(Lt)}const Ct=s.enabledFeatures;if(Ct&&Ct.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&M){d=n.getBinding();const xt=d.getDepthInformation(nt[0]);xt&&xt.isValid&&xt.texture&&m.init(xt,s.renderState)}if(Ct&&Ct.includes("camera-access")&&M){t.state.unbindTexture(),d=n.getBinding();for(let xt=0;xt<nt.length;xt++){const Nt=nt[xt].camera;if(Nt){let Dt=f[Nt];Dt||(Dt=new vu,f[Nt]=Dt);const Lt=d.getCameraImage(Nt);Dt.sourceTexture=Lt}}}}for(let nt=0;nt<y.length;nt++){const k=b[nt],Ct=y[nt];k!==null&&Ct!==void 0&&Ct.update(k,rt,c||a)}Vt&&Vt(K,rt),rt.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:rt}),_=null}const Wt=new Eu;Wt.setAnimationLoop(se),this.setAnimationLoop=function(K){Vt=K},this.dispose=function(){}}}const s1=new le,Pu=new Ot;Pu.set(-1,0,0,0,1,0,0,0,1);function r1(i,t){function e(m,f){m.matrixAutoUpdate===!0&&m.updateMatrix(),f.value.copy(m.matrix)}function n(m,f){f.color.getRGB(m.fogColor.value,xu(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,S){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,S)):f.isMeshMatcapMaterial?(r(m,f),_(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?l(m,f,A,w):f.isSpriteMaterial?c(m,f):f.isShadowMaterial?(m.color.value.copy(f.color),m.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function r(m,f){m.opacity.value=f.opacity,f.color&&m.diffuse.value.copy(f.color),f.emissive&&m.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(m.map.value=f.map,e(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,e(f.alphaMap,m.alphaMapTransform)),f.bumpMap&&(m.bumpMap.value=f.bumpMap,e(f.bumpMap,m.bumpMapTransform),m.bumpScale.value=f.bumpScale,f.side===Fe&&(m.bumpScale.value*=-1)),f.normalMap&&(m.normalMap.value=f.normalMap,e(f.normalMap,m.normalMapTransform),m.normalScale.value.copy(f.normalScale),f.side===Fe&&m.normalScale.value.negate()),f.displacementMap&&(m.displacementMap.value=f.displacementMap,e(f.displacementMap,m.displacementMapTransform),m.displacementScale.value=f.displacementScale,m.displacementBias.value=f.displacementBias),f.emissiveMap&&(m.emissiveMap.value=f.emissiveMap,e(f.emissiveMap,m.emissiveMapTransform)),f.specularMap&&(m.specularMap.value=f.specularMap,e(f.specularMap,m.specularMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest);const A=t.get(f),w=A.envMap,S=A.envMapRotation;w&&(m.envMap.value=w,m.envMapRotation.value.setFromMatrix4(s1.makeRotationFromEuler(S)).transpose(),w.isCubeTexture&&w.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(Pu),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,e(f.lightMap,m.lightMapTransform)),f.aoMap&&(m.aoMap.value=f.aoMap,m.aoMapIntensity.value=f.aoMapIntensity,e(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,e(f.map,m.mapTransform))}function o(m,f){m.dashSize.value=f.dashSize,m.totalSize.value=f.dashSize+f.gapSize,m.scale.value=f.scale}function l(m,f,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,e(f.map,m.uvTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,e(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function c(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.rotation.value=f.rotation,f.map&&(m.map.value=f.map,e(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,e(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,e(f.metalnessMap,m.metalnessMapTransform)),m.roughness.value=f.roughness,f.roughnessMap&&(m.roughnessMap.value=f.roughnessMap,e(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,e(f.sheenColorMap,m.sheenColorMapTransform)),f.sheenRoughnessMap&&(m.sheenRoughnessMap.value=f.sheenRoughnessMap,e(f.sheenRoughnessMap,m.sheenRoughnessMapTransform))),f.clearcoat>0&&(m.clearcoat.value=f.clearcoat,m.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(m.clearcoatMap.value=f.clearcoatMap,e(f.clearcoatMap,m.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,e(f.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(m.clearcoatNormalMap.value=f.clearcoatNormalMap,e(f.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===Fe&&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,e(f.iridescenceMap,m.iridescenceMapTransform)),f.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=f.iridescenceThicknessMap,e(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,e(f.transmissionMap,m.transmissionMapTransform)),m.thickness.value=f.thickness,f.thicknessMap&&(m.thicknessMap.value=f.thicknessMap,e(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,e(f.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=f.specularIntensity,m.specularColor.value.copy(f.specularColor),f.specularColorMap&&(m.specularColorMap.value=f.specularColorMap,e(f.specularColorMap,m.specularColorMapTransform)),f.specularIntensityMap&&(m.specularIntensityMap.value=f.specularIntensityMap,e(f.specularIntensityMap,m.specularIntensityMapTransform))}function _(m,f){f.matcap&&(m.matcap.value=f.matcap)}function M(m,f){const A=t.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 a1(i,t,e,n){let s={},r={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(S,y){const b=y.program;n.uniformBlockBinding(S,b)}function c(S,y){let b=s[S.id];b===void 0&&(m(S),b=h(S),s[S.id]=b,S.addEventListener("dispose",A));const R=y.program;n.updateUBOMapping(S,R);const v=t.render.frame;r[S.id]!==v&&(u(S),r[S.id]=v)}function h(S){const y=d();S.__bindingPointIndex=y;const b=i.createBuffer(),R=S.__size,v=S.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 S=0;S<o;S++)if(a.indexOf(S)===-1)return a.push(S),S;return Xt("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(S){const y=s[S.id],b=S.uniforms,R=S.__cache;i.bindBuffer(i.UNIFORM_BUFFER,y);for(let v=0,T=b.length;v<T;v++){const I=b[v];if(Array.isArray(I))for(let C=0,U=I.length;C<U;C++)p(I[C],v,C,R);else p(I,v,0,R)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function p(S,y,b,R){if(M(S,y,b,R)===!0){const v=S.__offset,T=S.value;if(Array.isArray(T)){let I=0;for(let C=0;C<T.length;C++){const U=T[C],Y=f(U);_(U,S.__data,I),typeof U!="number"&&typeof U!="boolean"&&!U.isMatrix3&&!ArrayBuffer.isView(U)&&(I+=Y.storage/Float32Array.BYTES_PER_ELEMENT)}}else _(T,S.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,v,S.__data)}}function _(S,y,b){typeof S=="number"||typeof S=="boolean"?y[0]=S:S.isMatrix3?(y[0]=S.elements[0],y[1]=S.elements[1],y[2]=S.elements[2],y[3]=0,y[4]=S.elements[3],y[5]=S.elements[4],y[6]=S.elements[5],y[7]=0,y[8]=S.elements[6],y[9]=S.elements[7],y[10]=S.elements[8],y[11]=0):ArrayBuffer.isView(S)?y.set(new S.constructor(S.buffer,S.byteOffset,y.length)):S.toArray(y,b)}function M(S,y,b,R){const v=S.value,T=y+"_"+b;if(R[T]===void 0)return typeof v=="number"||typeof v=="boolean"?R[T]=v:ArrayBuffer.isView(v)?R[T]=v.slice():R[T]=v.clone(),!0;{const I=R[T];if(typeof v=="number"||typeof v=="boolean"){if(I!==v)return R[T]=v,!0}else{if(ArrayBuffer.isView(v))return!0;if(I.equals(v)===!1)return I.copy(v),!0}}return!1}function m(S){const y=S.uniforms;let b=0;const R=16;for(let T=0,I=y.length;T<I;T++){const C=Array.isArray(y[T])?y[T]:[y[T]];for(let U=0,Y=C.length;U<Y;U++){const Z=C[U],O=Array.isArray(Z.value)?Z.value:[Z.value];for(let W=0,V=O.length;W<V;W++){const Q=O[W],et=f(Q),tt=b%R,st=tt%et.boundary,gt=tt+st;b+=st,gt!==0&&R-gt<et.storage&&(b+=R-gt),Z.__data=new Float32Array(et.storage/Float32Array.BYTES_PER_ELEMENT),Z.__offset=b,b+=et.storage}}}const v=b%R;return v>0&&(b+=R-v),S.__size=b,S.__cache={},this}function f(S){const y={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(y.boundary=4,y.storage=4):S.isVector2?(y.boundary=8,y.storage=8):S.isVector3||S.isColor?(y.boundary=16,y.storage=12):S.isVector4?(y.boundary=16,y.storage=16):S.isMatrix3?(y.boundary=48,y.storage=48):S.isMatrix4?(y.boundary=64,y.storage=64):S.isTexture?Ft("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(S)?(y.boundary=16,y.storage=S.byteLength):Ft("WebGLRenderer: Unsupported uniform value type.",S),y}function A(S){const y=S.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 S in s)i.deleteBuffer(s[S]);a=[],s={},r={}}return{bind:l,update:c,dispose:w}}const o1=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 cn=null;function l1(){return cn===null&&(cn=new Q0(o1,16,16,hi,Cn),cn.name="DFG_LUT",cn.minFilter=Ie,cn.magFilter=Ie,cn.wrapS=Tn,cn.wrapT=Tn,cn.generateMipmaps=!1,cn.needsUpdate=!0),cn}class c1{constructor(t={}){const{canvas:e=R0(),context:n=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:u=!1,outputBufferType:p=$e}=t;this.isWebGLRenderer=!0;let _;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");_=n.getContextAttributes().alpha}else _=a;const M=p,m=new Set([Sl,xl,vl]),f=new Set([$e,gn,As,ws,gl,_l]),A=new Uint32Array(4),w=new Int32Array(4),S=new F;let y=null,b=null;const R=[],v=[];let T=null;this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=pn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const I=this;let C=!1,U=null,Y=null,Z=null,O=null;this._outputColorSpace=Ze;let W=0,V=0,Q=null,et=-1,tt=null;const st=new fe,gt=new fe;let Vt=null;const se=new It(0);let Wt=0,K=e.width,rt=e.height,nt=1,k=null,Ct=null;const Pt=new fe(0,0,K,rt),wt=new fe(0,0,K,rt);let xt=!1;const Nt=new mu;let Dt=!1,Lt=!1;const Kt=new le,$t=new F,ce=new fe,oe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let he=!1;function ve(){return Q===null?nt:1}let D=n;function Be(x,L){return e.getContext(x,L)}try{const x={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${pl}`),e.addEventListener("webglcontextlost",ue,!1),e.addEventListener("webglcontextrestored",re,!1),e.addEventListener("webglcontextcreationerror",rn,!1),D===null){const L="webgl2";if(D=Be(L,x),D===null)throw Be(L)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(x){throw Xt("WebGLRenderer: "+x.message),x}let Jt,E,g,N,H,X,it,ot,q,J,lt,bt,ut,ct,Rt,Ut,Bt,P,at,$,ht,mt,j;function Et(){Jt=new lg(D),Jt.init(),ht=new j_(D,Jt),E=new tg(D,Jt,t,ht),g=new J_(D,Jt),E.reversedDepthBuffer&&u&&g.buffers.depth.setReversed(!0),Y=D.createFramebuffer(),Z=D.createFramebuffer(),O=D.createFramebuffer(),N=new ug(D),H=new O_,X=new Q_(D,Jt,g,H,E,ht,N),it=new og(I),ot=new mf(D),mt=new Qm(D,ot),q=new cg(D,ot,N,mt),J=new fg(D,q,ot,mt,N),P=new dg(D,E,X),Rt=new eg(H),lt=new F_(I,it,Jt,E,mt,Rt),bt=new r1(I,H),ut=new z_,ct=new X_(Jt),Bt=new Jm(I,it,g,J,_,l),Ut=new $_(I,J,E),j=new a1(D,N,E,g),at=new jm(D,Jt,N),$=new hg(D,Jt,N),N.programs=lt.programs,I.capabilities=E,I.extensions=Jt,I.properties=H,I.renderLists=ut,I.shadowMap=Ut,I.state=g,I.info=N}Et(),M!==$e&&(T=new mg(M,e.width,e.height,o,s,r));const St=new i1(I,D);this.xr=St,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){const x=Jt.get("WEBGL_lose_context");x&&x.loseContext()},this.forceContextRestore=function(){const x=Jt.get("WEBGL_lose_context");x&&x.restoreContext()},this.getPixelRatio=function(){return nt},this.setPixelRatio=function(x){x!==void 0&&(nt=x,this.setSize(K,rt,!1))},this.getSize=function(x){return x.set(K,rt)},this.setSize=function(x,L,G=!0){if(St.isPresenting){Ft("WebGLRenderer: Can't change size while VR device is presenting.");return}K=x,rt=L,e.width=Math.floor(x*nt),e.height=Math.floor(L*nt),G===!0&&(e.style.width=x+"px",e.style.height=L+"px"),T!==null&&T.setSize(e.width,e.height),this.setViewport(0,0,x,L)},this.getDrawingBufferSize=function(x){return x.set(K*nt,rt*nt).floor()},this.setDrawingBufferSize=function(x,L,G){K=x,rt=L,nt=G,e.width=Math.floor(x*G),e.height=Math.floor(L*G),this.setViewport(0,0,x,L)},this.setEffects=function(x){if(M===$e){Xt("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(x){for(let L=0;L<x.length;L++)if(x[L].isOutputPass===!0){Ft("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}T.setEffects(x||[])},this.getCurrentViewport=function(x){return x.copy(st)},this.getViewport=function(x){return x.copy(Pt)},this.setViewport=function(x,L,G,B){x.isVector4?Pt.set(x.x,x.y,x.z,x.w):Pt.set(x,L,G,B),g.viewport(st.copy(Pt).multiplyScalar(nt).round())},this.getScissor=function(x){return x.copy(wt)},this.setScissor=function(x,L,G,B){x.isVector4?wt.set(x.x,x.y,x.z,x.w):wt.set(x,L,G,B),g.scissor(gt.copy(wt).multiplyScalar(nt).round())},this.getScissorTest=function(){return xt},this.setScissorTest=function(x){g.setScissorTest(xt=x)},this.setOpaqueSort=function(x){k=x},this.setTransparentSort=function(x){Ct=x},this.getClearColor=function(x){return x.copy(Bt.getClearColor())},this.setClearColor=function(){Bt.setClearColor(...arguments)},this.getClearAlpha=function(){return Bt.getClearAlpha()},this.setClearAlpha=function(){Bt.setClearAlpha(...arguments)},this.clear=function(x=!0,L=!0,G=!0){let B=0;if(x){let z=!1;if(Q!==null){const pt=Q.texture.format;z=m.has(pt)}if(z){const pt=Q.texture.type,vt=f.has(pt),ft=Bt.getClearColor(),Mt=Bt.getClearAlpha(),Tt=ft.r,zt=ft.g,Gt=ft.b;vt?(A[0]=Tt,A[1]=zt,A[2]=Gt,A[3]=Mt,D.clearBufferuiv(D.COLOR,0,A)):(w[0]=Tt,w[1]=zt,w[2]=Gt,w[3]=Mt,D.clearBufferiv(D.COLOR,0,w))}else B|=D.COLOR_BUFFER_BIT}L&&(B|=D.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),G&&(B|=D.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),B!==0&&D.clear(B)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(x){x.setRenderer(this),U=x},this.dispose=function(){e.removeEventListener("webglcontextlost",ue,!1),e.removeEventListener("webglcontextrestored",re,!1),e.removeEventListener("webglcontextcreationerror",rn,!1),Bt.dispose(),ut.dispose(),ct.dispose(),H.dispose(),it.dispose(),J.dispose(),mt.dispose(),j.dispose(),lt.dispose(),St.dispose(),St.removeEventListener("sessionstart",Nl),St.removeEventListener("sessionend",Fl),$n.stop()};function ue(x){x.preventDefault(),zr("WebGLRenderer: Context Lost."),C=!0}function re(){zr("WebGLRenderer: Context Restored."),C=!1;const x=N.autoReset,L=Ut.enabled,G=Ut.autoUpdate,B=Ut.needsUpdate,z=Ut.type;Et(),N.autoReset=x,Ut.enabled=L,Ut.autoUpdate=G,Ut.needsUpdate=B,Ut.type=z}function rn(x){Xt("WebGLRenderer: A WebGL context could not be created. Reason: ",x.statusMessage)}function an(x){const L=x.target;L.removeEventListener("dispose",an),nd(L)}function nd(x){id(x),H.remove(x)}function id(x){const L=H.get(x).programs;L!==void 0&&(L.forEach(function(G){lt.releaseProgram(G)}),x.isShaderMaterial&<.releaseShaderCache(x))}this.renderBufferDirect=function(x,L,G,B,z,pt){L===null&&(L=oe);const vt=z.isMesh&&z.matrixWorld.determinantAffine()<0,ft=ad(x,L,G,B,z);g.setMaterial(B,vt);let Mt=G.index,Tt=1;if(B.wireframe===!0){if(Mt=q.getWireframeAttribute(G),Mt===void 0)return;Tt=2}const zt=G.drawRange,Gt=G.attributes.position;let At=zt.start*Tt,jt=(zt.start+zt.count)*Tt;pt!==null&&(At=Math.max(At,pt.start*Tt),jt=Math.min(jt,(pt.start+pt.count)*Tt)),Mt!==null?(At=Math.max(At,0),jt=Math.min(jt,Mt.count)):Gt!=null&&(At=Math.max(At,0),jt=Math.min(jt,Gt.count));const me=jt-At;if(me<0||me===1/0)return;mt.setup(z,B,ft,G,Mt);let de,ee=at;if(Mt!==null&&(de=ot.get(Mt),ee=$,ee.setIndex(de)),z.isMesh)B.wireframe===!0?(g.setLineWidth(B.wireframeLinewidth*ve()),ee.setMode(D.LINES)):ee.setMode(D.TRIANGLES);else if(z.isLine){let we=B.linewidth;we===void 0&&(we=1),g.setLineWidth(we*ve()),z.isLineSegments?ee.setMode(D.LINES):z.isLineLoop?ee.setMode(D.LINE_LOOP):ee.setMode(D.LINE_STRIP)}else z.isPoints?ee.setMode(D.POINTS):z.isSprite&&ee.setMode(D.TRIANGLES);if(z.isBatchedMesh)if(Jt.get("WEBGL_multi_draw"))ee.renderMultiDraw(z._multiDrawStarts,z._multiDrawCounts,z._multiDrawCount);else{const we=z._multiDrawStarts,_t=z._multiDrawCounts,ze=z._multiDrawCount,Zt=Mt?ot.get(Mt).bytesPerElement:1,We=H.get(B).currentProgram.getUniforms();for(let on=0;on<ze;on++)We.setValue(D,"_gl_DrawID",on),ee.render(we[on]/Zt,_t[on])}else if(z.isInstancedMesh)ee.renderInstances(At,me,z.count);else if(G.isInstancedBufferGeometry){const we=G._maxInstanceCount!==void 0?G._maxInstanceCount:1/0,_t=Math.min(G.instanceCount,we);ee.renderInstances(At,me,_t)}else ee.render(At,me)};function Ul(x,L,G){x.transparent===!0&&x.side===bn&&x.forceSinglePass===!1?(x.side=Fe,x.needsUpdate=!0,Ds(x,L,G),x.side=Kn,x.needsUpdate=!0,Ds(x,L,G),x.side=bn):Ds(x,L,G)}this.compile=function(x,L,G=null){G===null&&(G=x),b=ct.get(G),b.init(L),v.push(b),G.traverseVisible(function(z){z.isLight&&z.layers.test(L.layers)&&(b.pushLight(z),z.castShadow&&b.pushShadow(z))}),x!==G&&x.traverseVisible(function(z){z.isLight&&z.layers.test(L.layers)&&(b.pushLight(z),z.castShadow&&b.pushShadow(z))}),b.setupLights();const B=new Set;return x.traverse(function(z){if(!(z.isMesh||z.isPoints||z.isLine||z.isSprite))return;const pt=z.material;if(pt)if(Array.isArray(pt))for(let vt=0;vt<pt.length;vt++){const ft=pt[vt];Ul(ft,G,z),B.add(ft)}else Ul(pt,G,z),B.add(pt)}),b=v.pop(),B},this.compileAsync=function(x,L,G=null){const B=this.compile(x,L,G);return new Promise(z=>{function pt(){if(B.forEach(function(vt){H.get(vt).currentProgram.isReady()&&B.delete(vt)}),B.size===0){z(x);return}setTimeout(pt,10)}Jt.get("KHR_parallel_shader_compile")!==null?pt():setTimeout(pt,10)})};let sa=null;function sd(x){sa&&sa(x)}function Nl(){$n.stop()}function Fl(){$n.start()}const $n=new Eu;$n.setAnimationLoop(sd),typeof self<"u"&&$n.setContext(self),this.setAnimationLoop=function(x){sa=x,St.setAnimationLoop(x),x===null?$n.stop():$n.start()},St.addEventListener("sessionstart",Nl),St.addEventListener("sessionend",Fl),this.render=function(x,L){if(L!==void 0&&L.isCamera!==!0){Xt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;U!==null&&U.renderStart(x,L);const G=St.enabled===!0&&St.isPresenting===!0,B=T!==null&&(Q===null||G)&&T.begin(I,Q);if(x.matrixWorldAutoUpdate===!0&&x.updateMatrixWorld(),L.parent===null&&L.matrixWorldAutoUpdate===!0&&L.updateMatrixWorld(),St.enabled===!0&&St.isPresenting===!0&&(T===null||T.isCompositing()===!1)&&(St.cameraAutoUpdate===!0&&St.updateCamera(L),L=St.getCamera()),x.isScene===!0&&x.onBeforeRender(I,x,L,Q),b=ct.get(x,v.length),b.init(L),b.state.textureUnits=X.getTextureUnits(),v.push(b),Kt.multiplyMatrices(L.projectionMatrix,L.matrixWorldInverse),Nt.setFromProjectionMatrix(Kt,fn,L.reversedDepth),Lt=this.localClippingEnabled,Dt=Rt.init(this.clippingPlanes,Lt),y=ut.get(x,R.length),y.init(),R.push(y),St.enabled===!0&&St.isPresenting===!0){const vt=I.xr.getDepthSensingMesh();vt!==null&&ra(vt,L,-1/0,I.sortObjects)}ra(x,L,0,I.sortObjects),y.finish(),I.sortObjects===!0&&y.sort(k,Ct,L.reversedDepth),he=St.enabled===!1||St.isPresenting===!1||St.hasDepthSensing()===!1,he&&Bt.addToRenderList(y,x),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Dt===!0&&Rt.beginShadows();const z=b.state.shadowsArray;if(Ut.render(z,x,L),Dt===!0&&Rt.endShadows(),(B&&T.hasRenderPass())===!1){const vt=y.opaque,ft=y.transmissive;if(b.setupLights(),L.isArrayCamera){const Mt=L.cameras;if(ft.length>0)for(let Tt=0,zt=Mt.length;Tt<zt;Tt++){const Gt=Mt[Tt];Bl(vt,ft,x,Gt)}he&&Bt.render(x);for(let Tt=0,zt=Mt.length;Tt<zt;Tt++){const Gt=Mt[Tt];Ol(y,x,Gt,Gt.viewport)}}else ft.length>0&&Bl(vt,ft,x,L),he&&Bt.render(x),Ol(y,x,L)}Q!==null&&V===0&&(X.updateMultisampleRenderTarget(Q),X.updateRenderTargetMipmap(Q)),B&&T.end(I),x.isScene===!0&&x.onAfterRender(I,x,L),mt.resetDefaultState(),et=-1,tt=null,v.pop(),v.length>0?(b=v[v.length-1],X.setTextureUnits(b.state.textureUnits),Dt===!0&&Rt.setGlobalState(I.clippingPlanes,b.state.camera)):b=null,R.pop(),R.length>0?y=R[R.length-1]:y=null,U!==null&&U.renderEnd()};function ra(x,L,G,B){if(x.visible===!1)return;if(x.layers.test(L.layers)){if(x.isGroup)G=x.renderOrder;else if(x.isLOD)x.autoUpdate===!0&&x.update(L);else if(x.isLightProbeGrid)b.pushLightProbeGrid(x);else if(x.isLight)b.pushLight(x),x.castShadow&&b.pushShadow(x);else if(x.isSprite){if(!x.frustumCulled||Nt.intersectsSprite(x)){B&&ce.setFromMatrixPosition(x.matrixWorld).applyMatrix4(Kt);const vt=J.update(x),ft=x.material;ft.visible&&y.push(x,vt,ft,G,ce.z,null)}}else if((x.isMesh||x.isLine||x.isPoints)&&(!x.frustumCulled||Nt.intersectsObject(x))){const vt=J.update(x),ft=x.material;if(B&&(x.boundingSphere!==void 0?(x.boundingSphere===null&&x.computeBoundingSphere(),ce.copy(x.boundingSphere.center)):(vt.boundingSphere===null&&vt.computeBoundingSphere(),ce.copy(vt.boundingSphere.center)),ce.applyMatrix4(x.matrixWorld).applyMatrix4(Kt)),Array.isArray(ft)){const Mt=vt.groups;for(let Tt=0,zt=Mt.length;Tt<zt;Tt++){const Gt=Mt[Tt],At=ft[Gt.materialIndex];At&&At.visible&&y.push(x,vt,At,G,ce.z,Gt)}}else ft.visible&&y.push(x,vt,ft,G,ce.z,null)}}const pt=x.children;for(let vt=0,ft=pt.length;vt<ft;vt++)ra(pt[vt],L,G,B)}function Ol(x,L,G,B){const{opaque:z,transmissive:pt,transparent:vt}=x;b.setupLightsView(G),Dt===!0&&Rt.setGlobalState(I.clippingPlanes,G),B&&g.viewport(st.copy(B)),z.length>0&&Is(z,L,G),pt.length>0&&Is(pt,L,G),vt.length>0&&Is(vt,L,G),g.buffers.depth.setTest(!0),g.buffers.depth.setMask(!0),g.buffers.color.setMask(!0),g.setPolygonOffset(!1)}function Bl(x,L,G,B){if((G.isScene===!0?G.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[B.id]===void 0){const At=Jt.has("EXT_color_buffer_half_float")||Jt.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[B.id]=new mn(1,1,{generateMipmaps:!0,type:At?Cn:$e,minFilter:ri,samples:Math.max(4,E.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:qt.workingColorSpace})}const pt=b.state.transmissionRenderTarget[B.id],vt=B.viewport||st;pt.setSize(vt.z*I.transmissionResolutionScale,vt.w*I.transmissionResolutionScale);const ft=I.getRenderTarget(),Mt=I.getActiveCubeFace(),Tt=I.getActiveMipmapLevel();I.setRenderTarget(pt),I.getClearColor(se),Wt=I.getClearAlpha(),Wt<1&&I.setClearColor(16777215,.5),I.clear(),he&&Bt.render(G);const zt=I.toneMapping;I.toneMapping=pn;const Gt=B.viewport;if(B.viewport!==void 0&&(B.viewport=void 0),b.setupLightsView(B),Dt===!0&&Rt.setGlobalState(I.clippingPlanes,B),Is(x,G,B),X.updateMultisampleRenderTarget(pt),X.updateRenderTargetMipmap(pt),Jt.has("WEBGL_multisampled_render_to_texture")===!1){let At=!1;for(let jt=0,me=L.length;jt<me;jt++){const de=L[jt],{object:ee,geometry:we,material:_t,group:ze}=de;if(_t.side===bn&&ee.layers.test(B.layers)){const Zt=_t.side;_t.side=Fe,_t.needsUpdate=!0,zl(ee,G,B,we,_t,ze),_t.side=Zt,_t.needsUpdate=!0,At=!0}}At===!0&&(X.updateMultisampleRenderTarget(pt),X.updateRenderTargetMipmap(pt))}I.setRenderTarget(ft,Mt,Tt),I.setClearColor(se,Wt),Gt!==void 0&&(B.viewport=Gt),I.toneMapping=zt}function Is(x,L,G){const B=L.isScene===!0?L.overrideMaterial:null;for(let z=0,pt=x.length;z<pt;z++){const vt=x[z],{object:ft,geometry:Mt,group:Tt}=vt;let zt=vt.material;zt.allowOverride===!0&&B!==null&&(zt=B),ft.layers.test(G.layers)&&zl(ft,L,G,Mt,zt,Tt)}}function zl(x,L,G,B,z,pt){x.onBeforeRender(I,L,G,B,z,pt),x.modelViewMatrix.multiplyMatrices(G.matrixWorldInverse,x.matrixWorld),x.normalMatrix.getNormalMatrix(x.modelViewMatrix),z.onBeforeRender(I,L,G,B,x,pt),z.transparent===!0&&z.side===bn&&z.forceSinglePass===!1?(z.side=Fe,z.needsUpdate=!0,I.renderBufferDirect(G,L,B,z,x,pt),z.side=Kn,z.needsUpdate=!0,I.renderBufferDirect(G,L,B,z,x,pt),z.side=bn):I.renderBufferDirect(G,L,B,z,x,pt),x.onAfterRender(I,L,G,B,z,pt)}function Ds(x,L,G){L.isScene!==!0&&(L=oe);const B=H.get(x),z=b.state.lights,pt=b.state.shadowsArray,vt=z.state.version,ft=lt.getParameters(x,z.state,pt,L,G,b.state.lightProbeGridArray),Mt=lt.getProgramCacheKey(ft);let Tt=B.programs;B.environment=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?L.environment:null,B.fog=L.fog;const zt=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap;B.envMap=it.get(x.envMap||B.environment,zt),B.envMapRotation=B.environment!==null&&x.envMap===null?L.environmentRotation:x.envMapRotation,Tt===void 0&&(x.addEventListener("dispose",an),Tt=new Map,B.programs=Tt);let Gt=Tt.get(Mt);if(Gt!==void 0){if(B.currentProgram===Gt&&B.lightsStateVersion===vt)return Hl(x,ft),Gt}else ft.uniforms=lt.getUniforms(x),U!==null&&x.isNodeMaterial&&U.build(x,G,ft),x.onBeforeCompile(ft,I),Gt=lt.acquireProgram(ft,Mt),Tt.set(Mt,Gt),B.uniforms=ft.uniforms;const At=B.uniforms;return(!x.isShaderMaterial&&!x.isRawShaderMaterial||x.clipping===!0)&&(At.clippingPlanes=Rt.uniform),Hl(x,ft),B.needsLights=ld(x),B.lightsStateVersion=vt,B.needsLights&&(At.ambientLightColor.value=z.state.ambient,At.lightProbe.value=z.state.probe,At.directionalLights.value=z.state.directional,At.directionalLightShadows.value=z.state.directionalShadow,At.spotLights.value=z.state.spot,At.spotLightShadows.value=z.state.spotShadow,At.rectAreaLights.value=z.state.rectArea,At.ltc_1.value=z.state.rectAreaLTC1,At.ltc_2.value=z.state.rectAreaLTC2,At.pointLights.value=z.state.point,At.pointLightShadows.value=z.state.pointShadow,At.hemisphereLights.value=z.state.hemi,At.directionalShadowMatrix.value=z.state.directionalShadowMatrix,At.spotLightMatrix.value=z.state.spotLightMatrix,At.spotLightMap.value=z.state.spotLightMap,At.pointShadowMatrix.value=z.state.pointShadowMatrix),B.lightProbeGrid=b.state.lightProbeGridArray.length>0,B.currentProgram=Gt,B.uniformsList=null,Gt}function kl(x){if(x.uniformsList===null){const L=x.currentProgram.getUniforms();x.uniformsList=Pr.seqWithValue(L.seq,x.uniforms)}return x.uniformsList}function Hl(x,L){const G=H.get(x);G.outputColorSpace=L.outputColorSpace,G.batching=L.batching,G.batchingColor=L.batchingColor,G.instancing=L.instancing,G.instancingColor=L.instancingColor,G.instancingMorph=L.instancingMorph,G.skinning=L.skinning,G.morphTargets=L.morphTargets,G.morphNormals=L.morphNormals,G.morphColors=L.morphColors,G.morphTargetsCount=L.morphTargetsCount,G.numClippingPlanes=L.numClippingPlanes,G.numIntersection=L.numClipIntersection,G.vertexAlphas=L.vertexAlphas,G.vertexTangents=L.vertexTangents,G.toneMapping=L.toneMapping}function rd(x,L){if(x.length===0)return null;if(x.length===1)return x[0].texture!==null?x[0]:null;S.setFromMatrixPosition(L.matrixWorld);for(let G=0,B=x.length;G<B;G++){const z=x[G];if(z.texture!==null&&z.boundingBox.containsPoint(S))return z}return null}function ad(x,L,G,B,z){L.isScene!==!0&&(L=oe),X.resetTextureUnits();const pt=L.fog,vt=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?L.environment:null,ft=Q===null?I.outputColorSpace:Q.isXRRenderTarget===!0?Q.texture.colorSpace:qt.workingColorSpace,Mt=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Tt=it.get(B.envMap||vt,Mt),zt=B.vertexColors===!0&&!!G.attributes.color&&G.attributes.color.itemSize===4,Gt=!!G.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),At=!!G.morphAttributes.position,jt=!!G.morphAttributes.normal,me=!!G.morphAttributes.color;let de=pn;B.toneMapped&&(Q===null||Q.isXRRenderTarget===!0)&&(de=I.toneMapping);const ee=G.morphAttributes.position||G.morphAttributes.normal||G.morphAttributes.color,we=ee!==void 0?ee.length:0,_t=H.get(B),ze=b.state.lights;if(Dt===!0&&(Lt===!0||x!==tt)){const ae=x===tt&&B.id===et;Rt.setState(B,x,ae)}let Zt=!1;B.version===_t.__version?(_t.needsLights&&_t.lightsStateVersion!==ze.state.version||_t.outputColorSpace!==ft||z.isBatchedMesh&&_t.batching===!1||!z.isBatchedMesh&&_t.batching===!0||z.isBatchedMesh&&_t.batchingColor===!0&&z.colorTexture===null||z.isBatchedMesh&&_t.batchingColor===!1&&z.colorTexture!==null||z.isInstancedMesh&&_t.instancing===!1||!z.isInstancedMesh&&_t.instancing===!0||z.isSkinnedMesh&&_t.skinning===!1||!z.isSkinnedMesh&&_t.skinning===!0||z.isInstancedMesh&&_t.instancingColor===!0&&z.instanceColor===null||z.isInstancedMesh&&_t.instancingColor===!1&&z.instanceColor!==null||z.isInstancedMesh&&_t.instancingMorph===!0&&z.morphTexture===null||z.isInstancedMesh&&_t.instancingMorph===!1&&z.morphTexture!==null||_t.envMap!==Tt||B.fog===!0&&_t.fog!==pt||_t.numClippingPlanes!==void 0&&(_t.numClippingPlanes!==Rt.numPlanes||_t.numIntersection!==Rt.numIntersection)||_t.vertexAlphas!==zt||_t.vertexTangents!==Gt||_t.morphTargets!==At||_t.morphNormals!==jt||_t.morphColors!==me||_t.toneMapping!==de||_t.morphTargetsCount!==we||!!_t.lightProbeGrid!=b.state.lightProbeGridArray.length>0)&&(Zt=!0):(Zt=!0,_t.__version=B.version);let We=_t.currentProgram;Zt===!0&&(We=Ds(B,L,z),U&&B.isNodeMaterial&&U.onUpdateProgram(B,We,_t));let on=!1,Dn=!1,pi=!1;const ne=We.getUniforms(),ge=_t.uniforms;if(g.useProgram(We.program)&&(on=!0,Dn=!0,pi=!0),B.id!==et&&(et=B.id,Dn=!0),_t.needsLights){const ae=rd(b.state.lightProbeGridArray,z);_t.lightProbeGrid!==ae&&(_t.lightProbeGrid=ae,Dn=!0)}if(on||tt!==x){g.buffers.depth.getReversed()&&x.reversedDepth!==!0&&(x._reversedDepth=!0,x.updateProjectionMatrix()),ne.setValue(D,"projectionMatrix",x.projectionMatrix),ne.setValue(D,"viewMatrix",x.matrixWorldInverse);const Un=ne.map.cameraPosition;Un!==void 0&&Un.setValue(D,$t.setFromMatrixPosition(x.matrixWorld)),E.logarithmicDepthBuffer&&ne.setValue(D,"logDepthBufFC",2/(Math.log(x.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&ne.setValue(D,"isOrthographic",x.isOrthographicCamera===!0),tt!==x&&(tt=x,Dn=!0,pi=!0)}if(_t.needsLights&&(ze.state.directionalShadowMap.length>0&&ne.setValue(D,"directionalShadowMap",ze.state.directionalShadowMap,X),ze.state.spotShadowMap.length>0&&ne.setValue(D,"spotShadowMap",ze.state.spotShadowMap,X),ze.state.pointShadowMap.length>0&&ne.setValue(D,"pointShadowMap",ze.state.pointShadowMap,X)),z.isSkinnedMesh){ne.setOptional(D,z,"bindMatrix"),ne.setOptional(D,z,"bindMatrixInverse");const ae=z.skeleton;ae&&(ae.boneTexture===null&&ae.computeBoneTexture(),ne.setValue(D,"boneTexture",ae.boneTexture,X))}z.isBatchedMesh&&(ne.setOptional(D,z,"batchingTexture"),ne.setValue(D,"batchingTexture",z._matricesTexture,X),ne.setOptional(D,z,"batchingIdTexture"),ne.setValue(D,"batchingIdTexture",z._indirectTexture,X),ne.setOptional(D,z,"batchingColorTexture"),z._colorsTexture!==null&&ne.setValue(D,"batchingColorTexture",z._colorsTexture,X));const Ln=G.morphAttributes;if((Ln.position!==void 0||Ln.normal!==void 0||Ln.color!==void 0)&&P.update(z,G,We),(Dn||_t.receiveShadow!==z.receiveShadow)&&(_t.receiveShadow=z.receiveShadow,ne.setValue(D,"receiveShadow",z.receiveShadow)),(B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&L.environment!==null&&(ge.envMapIntensity.value=L.environmentIntensity),ge.dfgLUT!==void 0&&(ge.dfgLUT.value=l1()),Dn){if(ne.setValue(D,"toneMappingExposure",I.toneMappingExposure),_t.needsLights&&od(ge,pi),pt&&B.fog===!0&&bt.refreshFogUniforms(ge,pt),bt.refreshMaterialUniforms(ge,B,nt,rt,b.state.transmissionRenderTarget[x.id]),_t.needsLights&&_t.lightProbeGrid){const ae=_t.lightProbeGrid;ge.probesSH.value=ae.texture,ge.probesMin.value.copy(ae.boundingBox.min),ge.probesMax.value.copy(ae.boundingBox.max),ge.probesResolution.value.copy(ae.resolution)}Pr.upload(D,kl(_t),ge,X)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(Pr.upload(D,kl(_t),ge,X),B.uniformsNeedUpdate=!1),B.isSpriteMaterial&&ne.setValue(D,"center",z.center),ne.setValue(D,"modelViewMatrix",z.modelViewMatrix),ne.setValue(D,"normalMatrix",z.normalMatrix),ne.setValue(D,"modelMatrix",z.matrixWorld),B.uniformsGroups!==void 0){const ae=B.uniformsGroups;for(let Un=0,mi=ae.length;Un<mi;Un++){const Gl=ae[Un];j.update(Gl,We),j.bind(Gl,We)}}return We}function od(x,L){x.ambientLightColor.needsUpdate=L,x.lightProbe.needsUpdate=L,x.directionalLights.needsUpdate=L,x.directionalLightShadows.needsUpdate=L,x.pointLights.needsUpdate=L,x.pointLightShadows.needsUpdate=L,x.spotLights.needsUpdate=L,x.spotLightShadows.needsUpdate=L,x.rectAreaLights.needsUpdate=L,x.hemisphereLights.needsUpdate=L}function ld(x){return x.isMeshLambertMaterial||x.isMeshToonMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isShadowMaterial||x.isShaderMaterial&&x.lights===!0}this.getActiveCubeFace=function(){return W},this.getActiveMipmapLevel=function(){return V},this.getRenderTarget=function(){return Q},this.setRenderTargetTextures=function(x,L,G){const B=H.get(x);B.__autoAllocateDepthBuffer=x.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1&&(B.__useRenderToTexture=!1),H.get(x.texture).__webglTexture=L,H.get(x.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:G,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(x,L){const G=H.get(x);G.__webglFramebuffer=L,G.__useDefaultFramebuffer=L===void 0},this.setRenderTarget=function(x,L=0,G=0){Q=x,W=L,V=G;let B=null,z=!1,pt=!1;if(x){const ft=H.get(x);if(ft.__useDefaultFramebuffer!==void 0){g.bindFramebuffer(D.FRAMEBUFFER,ft.__webglFramebuffer),st.copy(x.viewport),gt.copy(x.scissor),Vt=x.scissorTest,g.viewport(st),g.scissor(gt),g.setScissorTest(Vt),et=-1;return}else if(ft.__webglFramebuffer===void 0)X.setupRenderTarget(x);else if(ft.__hasExternalTextures)X.rebindTextures(x,H.get(x.texture).__webglTexture,H.get(x.depthTexture).__webglTexture);else if(x.depthBuffer){const zt=x.depthTexture;if(ft.__boundDepthTexture!==zt){if(zt!==null&&H.has(zt)&&(x.width!==zt.image.width||x.height!==zt.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");X.setupDepthRenderbuffer(x)}}const Mt=x.texture;(Mt.isData3DTexture||Mt.isDataArrayTexture||Mt.isCompressedArrayTexture)&&(pt=!0);const Tt=H.get(x).__webglFramebuffer;x.isWebGLCubeRenderTarget?(Array.isArray(Tt[L])?B=Tt[L][G]:B=Tt[L],z=!0):x.samples>0&&X.useMultisampledRTT(x)===!1?B=H.get(x).__webglMultisampledFramebuffer:Array.isArray(Tt)?B=Tt[G]:B=Tt,st.copy(x.viewport),gt.copy(x.scissor),Vt=x.scissorTest}else st.copy(Pt).multiplyScalar(nt).floor(),gt.copy(wt).multiplyScalar(nt).floor(),Vt=xt;if(G!==0&&(B=Y),g.bindFramebuffer(D.FRAMEBUFFER,B)&&g.drawBuffers(x,B),g.viewport(st),g.scissor(gt),g.setScissorTest(Vt),z){const ft=H.get(x.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+L,ft.__webglTexture,G)}else if(pt){const ft=L;for(let Mt=0;Mt<x.textures.length;Mt++){const Tt=H.get(x.textures[Mt]);D.framebufferTextureLayer(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0+Mt,Tt.__webglTexture,G,ft)}}else if(x!==null&&G!==0){const ft=H.get(x.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,ft.__webglTexture,G)}et=-1},this.readRenderTargetPixels=function(x,L,G,B,z,pt,vt,ft=0){if(!(x&&x.isWebGLRenderTarget)){Xt("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Mt=H.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&vt!==void 0&&(Mt=Mt[vt]),Mt){g.bindFramebuffer(D.FRAMEBUFFER,Mt);try{const Tt=x.textures[ft],zt=Tt.format,Gt=Tt.type;if(x.textures.length>1&&D.readBuffer(D.COLOR_ATTACHMENT0+ft),!E.textureFormatReadable(zt)){Xt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!E.textureTypeReadable(Gt)){Xt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}L>=0&&L<=x.width-B&&G>=0&&G<=x.height-z&&D.readPixels(L,G,B,z,ht.convert(zt),ht.convert(Gt),pt)}finally{const Tt=Q!==null?H.get(Q).__webglFramebuffer:null;g.bindFramebuffer(D.FRAMEBUFFER,Tt)}}},this.readRenderTargetPixelsAsync=async function(x,L,G,B,z,pt,vt,ft=0){if(!(x&&x.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Mt=H.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&vt!==void 0&&(Mt=Mt[vt]),Mt)if(L>=0&&L<=x.width-B&&G>=0&&G<=x.height-z){g.bindFramebuffer(D.FRAMEBUFFER,Mt);const Tt=x.textures[ft],zt=Tt.format,Gt=Tt.type;if(x.textures.length>1&&D.readBuffer(D.COLOR_ATTACHMENT0+ft),!E.textureFormatReadable(zt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!E.textureTypeReadable(Gt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const At=D.createBuffer();D.bindBuffer(D.PIXEL_PACK_BUFFER,At),D.bufferData(D.PIXEL_PACK_BUFFER,pt.byteLength,D.STREAM_READ),D.readPixels(L,G,B,z,ht.convert(zt),ht.convert(Gt),0);const jt=Q!==null?H.get(Q).__webglFramebuffer:null;g.bindFramebuffer(D.FRAMEBUFFER,jt);const me=D.fenceSync(D.SYNC_GPU_COMMANDS_COMPLETE,0);return D.flush(),await C0(D,me,4),D.bindBuffer(D.PIXEL_PACK_BUFFER,At),D.getBufferSubData(D.PIXEL_PACK_BUFFER,0,pt),D.deleteBuffer(At),D.deleteSync(me),pt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(x,L=null,G=0){const B=Math.pow(2,-G),z=Math.floor(x.image.width*B),pt=Math.floor(x.image.height*B),vt=L!==null?L.x:0,ft=L!==null?L.y:0;X.setTexture2D(x,0),D.copyTexSubImage2D(D.TEXTURE_2D,G,0,0,vt,ft,z,pt),g.unbindTexture()},this.copyTextureToTexture=function(x,L,G=null,B=null,z=0,pt=0){let vt,ft,Mt,Tt,zt,Gt,At,jt,me;const de=x.isCompressedTexture?x.mipmaps[pt]:x.image;if(G!==null)vt=G.max.x-G.min.x,ft=G.max.y-G.min.y,Mt=G.isBox3?G.max.z-G.min.z:1,Tt=G.min.x,zt=G.min.y,Gt=G.isBox3?G.min.z:0;else{const ge=Math.pow(2,-z);vt=Math.floor(de.width*ge),ft=Math.floor(de.height*ge),x.isDataArrayTexture?Mt=de.depth:x.isData3DTexture?Mt=Math.floor(de.depth*ge):Mt=1,Tt=0,zt=0,Gt=0}B!==null?(At=B.x,jt=B.y,me=B.z):(At=0,jt=0,me=0);const ee=ht.convert(L.format),we=ht.convert(L.type);let _t;L.isData3DTexture?(X.setTexture3D(L,0),_t=D.TEXTURE_3D):L.isDataArrayTexture||L.isCompressedArrayTexture?(X.setTexture2DArray(L,0),_t=D.TEXTURE_2D_ARRAY):(X.setTexture2D(L,0),_t=D.TEXTURE_2D),g.activeTexture(D.TEXTURE0),g.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,L.flipY),g.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),g.pixelStorei(D.UNPACK_ALIGNMENT,L.unpackAlignment);const ze=g.getParameter(D.UNPACK_ROW_LENGTH),Zt=g.getParameter(D.UNPACK_IMAGE_HEIGHT),We=g.getParameter(D.UNPACK_SKIP_PIXELS),on=g.getParameter(D.UNPACK_SKIP_ROWS),Dn=g.getParameter(D.UNPACK_SKIP_IMAGES);g.pixelStorei(D.UNPACK_ROW_LENGTH,de.width),g.pixelStorei(D.UNPACK_IMAGE_HEIGHT,de.height),g.pixelStorei(D.UNPACK_SKIP_PIXELS,Tt),g.pixelStorei(D.UNPACK_SKIP_ROWS,zt),g.pixelStorei(D.UNPACK_SKIP_IMAGES,Gt);const pi=x.isDataArrayTexture||x.isData3DTexture,ne=L.isDataArrayTexture||L.isData3DTexture;if(x.isDepthTexture){const ge=H.get(x),Ln=H.get(L),ae=H.get(ge.__renderTarget),Un=H.get(Ln.__renderTarget);g.bindFramebuffer(D.READ_FRAMEBUFFER,ae.__webglFramebuffer),g.bindFramebuffer(D.DRAW_FRAMEBUFFER,Un.__webglFramebuffer);for(let mi=0;mi<Mt;mi++)pi&&(D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,H.get(x).__webglTexture,z,Gt+mi),D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,H.get(L).__webglTexture,pt,me+mi)),D.blitFramebuffer(Tt,zt,vt,ft,At,jt,vt,ft,D.DEPTH_BUFFER_BIT,D.NEAREST);g.bindFramebuffer(D.READ_FRAMEBUFFER,null),g.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else if(z!==0||x.isRenderTargetTexture||H.has(x)){const ge=H.get(x),Ln=H.get(L);g.bindFramebuffer(D.READ_FRAMEBUFFER,Z),g.bindFramebuffer(D.DRAW_FRAMEBUFFER,O);for(let ae=0;ae<Mt;ae++)pi?D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,ge.__webglTexture,z,Gt+ae):D.framebufferTexture2D(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,ge.__webglTexture,z),ne?D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,Ln.__webglTexture,pt,me+ae):D.framebufferTexture2D(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,Ln.__webglTexture,pt),z!==0?D.blitFramebuffer(Tt,zt,vt,ft,At,jt,vt,ft,D.COLOR_BUFFER_BIT,D.NEAREST):ne?D.copyTexSubImage3D(_t,pt,At,jt,me+ae,Tt,zt,vt,ft):D.copyTexSubImage2D(_t,pt,At,jt,Tt,zt,vt,ft);g.bindFramebuffer(D.READ_FRAMEBUFFER,null),g.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else ne?x.isDataTexture||x.isData3DTexture?D.texSubImage3D(_t,pt,At,jt,me,vt,ft,Mt,ee,we,de.data):L.isCompressedArrayTexture?D.compressedTexSubImage3D(_t,pt,At,jt,me,vt,ft,Mt,ee,de.data):D.texSubImage3D(_t,pt,At,jt,me,vt,ft,Mt,ee,we,de):x.isDataTexture?D.texSubImage2D(D.TEXTURE_2D,pt,At,jt,vt,ft,ee,we,de.data):x.isCompressedTexture?D.compressedTexSubImage2D(D.TEXTURE_2D,pt,At,jt,de.width,de.height,ee,de.data):D.texSubImage2D(D.TEXTURE_2D,pt,At,jt,vt,ft,ee,we,de);g.pixelStorei(D.UNPACK_ROW_LENGTH,ze),g.pixelStorei(D.UNPACK_IMAGE_HEIGHT,Zt),g.pixelStorei(D.UNPACK_SKIP_PIXELS,We),g.pixelStorei(D.UNPACK_SKIP_ROWS,on),g.pixelStorei(D.UNPACK_SKIP_IMAGES,Dn),pt===0&&L.generateMipmaps&&D.generateMipmap(_t),g.unbindTexture()},this.initRenderTarget=function(x){H.get(x).__webglFramebuffer===void 0&&X.setupRenderTarget(x)},this.initTexture=function(x){x.isCubeTexture?X.setTextureCube(x,0):x.isData3DTexture?X.setTexture3D(x,0):x.isDataArrayTexture||x.isCompressedArrayTexture?X.setTexture2DArray(x,0):X.setTexture2D(x,0),g.unbindTexture()},this.resetState=function(){W=0,V=0,Q=null,g.reset(),mt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return fn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=qt._getDrawingBufferColorSpace(t),e.unpackColorSpace=qt._getUnpackColorSpace()}}const Yo=Math.PI/180,Zc=180/Math.PI;function Ps(i,t,e){return Math.max(t,Math.min(e,i))}const Hn=[{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 Ir(i,t,e){return i+(t-i)*e}function Gr(i,t,e){return[Ir(i[0],t[0],e),Ir(i[1],t[1],e),Ir(i[2],t[2],e)]}function Iu(i){const t=Math.max(Hn[0].altitudeDeg,Math.min(Hn[Hn.length-1].altitudeDeg,i));for(let n=0;n<Hn.length-1;n++){const s=Hn[n],r=Hn[n+1];if(t>=s.altitudeDeg&&t<=r.altitudeDeg){const a=(t-s.altitudeDeg)/(r.altitudeDeg-s.altitudeDeg);return{zenith:Gr(s.zenith,r.zenith,a),horizon:Gr(s.horizon,r.horizon,a)}}}const e=Hn[Hn.length-1];return{zenith:e.zenith,horizon:e.horizon}}function h1(i){if(i<=-18)return 7.5;if(i>=0)return-4;const n=(i+18)/18;return Ir(7.5,-4,n)}const u1=-1.5,d1=7.5;function Kc(i){const t=10**(-.4*i),e=10**(-.4*u1),n=10**(-.4*d1);return Ps((t-n)/(e-n),0,1)}function ms(i,t,e){const n=i*Yo,s=t*Yo,r=e*Math.cos(n);return{x:r*Math.sin(s),y:e*Math.sin(n),z:-r*Math.cos(s)}}function f1(i,t,e){const n=Math.sqrt(i*i+t*t+e*e),s=n===0?0:Math.asin(Ps(t/n,-1,1))*Zc,r=(Math.atan2(i,-e)*Zc+360)%360;return{altitudeDeg:s,azimuthDeg:r}}function p1(i,t){const e=Math.abs(i-t)%360;return e>180?360-e:e}function m1(i,t,e){const n=Math.max(0,1-p1(i,t)/90),s=Math.max(0,1-Math.abs(e)/18);return n*s}function g1(i,t,e,n){const{zenith:s,horizon:r}=Iu(n),a=Ps((i+90)/180,0,1),o=Gr(r,s,a),l=m1(t,e,n);return l<=0?o:Gr(o,r,l*(1-a)*.8)}function $c(i){return .3+.7*i}const _1=-4;function v1(i){return Math.max(0,_1-i)}const x1=6,S1=60;function M1(i){return Math.min(S1,x1*Math.sqrt(i))}const y1=3,E1=.55;function b1(i){return E1*Ps(i/y1,0,1)}function T1(i){const t=Math.max(i,-4),e=Math.sin(t*Yo)+.50572*Math.pow(t+6.07995,-1.6364);return Ps(1/e,1,40)}function Jc(i){const t=T1(i)-1;return[1,Math.exp(-.022*t),Math.exp(-.062*t)]}const Du=[{maxBrightness:.5,size:1.2},{maxBrightness:.85,size:2},{maxBrightness:1/0,size:3.2}];function A1(i){return Du.findIndex(t=>i<=t.maxBrightness)}const w1=.25,Qc=.3,R1=2.2;function C1(i,{phase:t,speedFactor:e},n){const r=1+w1*(Qc+(1-Qc)*i)*Math.sin(n*R1*e+t);return Math.min(1,Math.max(0,r))}/**
|
|
4433
|
+
}`;class e1{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new mu(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 kt({vertexShader:Q_,fragmentShader:j_,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new zt(new Jr(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class t1 extends fi{constructor(e,t){super();const n=this;let s=null,r=1,a=null,o="local-floor",l=1,c=null,h=null,d=null,u=null,p=null,_=null;const M=typeof XRWebGLBinding<"u",m=new e1,f={},A=t.getContextAttributes();let w=null,S=null;const y=[],b=[],R=new ke;let v=null;const T=new Kt;T.viewport=new ft;const I=new Kt;I.viewport=new ft;const C=[T,I],U=new hf;let Y=null,Z=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(K){let re=y[K];return re===void 0&&(re=new pa,y[K]=re),re.getTargetRaySpace()},this.getControllerGrip=function(K){let re=y[K];return re===void 0&&(re=new pa,y[K]=re),re.getGripSpace()},this.getHand=function(K){let re=y[K];return re===void 0&&(re=new pa,y[K]=re),re.getHandSpace()};function O(K){const re=b.indexOf(K.inputSource);if(re===-1)return;const ne=y[re];ne!==void 0&&(ne.update(K.inputSource,K.frame,c||a),ne.dispatchEvent({type:K.type,data:K.inputSource}))}function W(){s.removeEventListener("select",O),s.removeEventListener("selectstart",O),s.removeEventListener("selectend",O),s.removeEventListener("squeeze",O),s.removeEventListener("squeezestart",O),s.removeEventListener("squeezeend",O),s.removeEventListener("end",W),s.removeEventListener("inputsourceschange",V);for(let K=0;K<y.length;K++){const re=b[K];re!==null&&(b[K]=null,y[K].disconnect(re))}Y=null,Z=null,m.reset();for(const K in f)delete f[K];e.setRenderTarget(w),p=null,u=null,d=null,s=null,S=null,We.stop(),n.isPresenting=!1,e.setPixelRatio(v),e.setSize(R.width,R.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(K){r=K,n.isPresenting===!0&&Fe("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(K){o=K,n.isPresenting===!0&&Fe("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(K){c=K},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 _},this.getSession=function(){return s},this.setSession=async function(K){if(s=K,s!==null){if(w=e.getRenderTarget(),s.addEventListener("select",O),s.addEventListener("selectstart",O),s.addEventListener("selectend",O),s.addEventListener("squeeze",O),s.addEventListener("squeezestart",O),s.addEventListener("squeezeend",O),s.addEventListener("end",W),s.addEventListener("inputsourceschange",V),A.xrCompatible!==!0&&await t.makeXRCompatible(),v=e.getPixelRatio(),e.getSize(R),M&&"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?ai:Pn,k=A.stencil?Ts:gn);const Ie={colorFormat:t.RGBA8,depthFormat:Pe,scaleFactor:r};d=this.getBinding(),u=d.createProjectionLayer(Ie),s.updateRenderState({layers:[u]}),e.setPixelRatio(1),e.setSize(u.textureWidth,u.textureHeight,!1),S=new mn(u.textureWidth,u.textureHeight,{format:sn,type:$t,depthTexture:new $i(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),S=new mn(p.framebufferWidth,p.framebufferHeight,{format:sn,type:$t,colorSpace:e.outputColorSpace,stencilBuffer:A.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}S.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await s.requestReferenceSpace(o),We.setContext(s),We.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function V(K){for(let re=0;re<K.removed.length;re++){const ne=K.removed[re],k=b.indexOf(ne);k>=0&&(b[k]=null,y[k].disconnect(ne))}for(let re=0;re<K.added.length;re++){const ne=K.added[re];let k=b.indexOf(ne);if(k===-1){for(let Ie=0;Ie<y.length;Ie++)if(Ie>=b.length){b.push(ne),k=Ie;break}else if(b[Ie]===null){b[Ie]=ne,k=Ie;break}if(k===-1)break}const Pe=y[k];Pe&&Pe.connect(ne)}}const Q=new F,te=new F;function ee(K,re,ne){Q.setFromMatrixPosition(re.matrixWorld),te.setFromMatrixPosition(ne.matrixWorld);const k=Q.distanceTo(te),Pe=re.projectionMatrix.elements,Ie=ne.projectionMatrix.elements,we=Pe[14]/(Pe[10]-1),xe=Pe[14]/(Pe[10]+1),Ne=(Pe[9]+1)/Pe[5],De=(Pe[9]-1)/Pe[5],Le=(Pe[8]-1)/Pe[0],Ke=(Ie[8]+1)/Ie[0],$e=we*Le,ct=we*Ke,ot=k/(-Le+Ke),ht=ot*-Le;if(re.matrixWorld.decompose(K.position,K.quaternion,K.scale),K.translateX(ht),K.translateZ(ot),K.matrixWorld.compose(K.position,K.quaternion,K.scale),K.matrixWorldInverse.copy(K.matrixWorld).invert(),Pe[10]===-1)K.projectionMatrix.copy(re.projectionMatrix),K.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{const vt=we+ot,D=xe+ot,Bt=$e-ht,Je=ct+(k-ht),E=Ne*xe/D*vt,g=De*xe/D*vt;K.projectionMatrix.makePerspective(Bt,Je,E,g,vt,D),K.projectionMatrixInverse.copy(K.projectionMatrix).invert()}}function se(K,re){re===null?K.matrixWorld.copy(K.matrix):K.matrixWorld.multiplyMatrices(re.matrixWorld,K.matrix),K.matrixWorldInverse.copy(K.matrixWorld).invert()}this.updateCamera=function(K){if(s===null)return;let re=K.near,ne=K.far;m.texture!==null&&(m.depthNear>0&&(re=m.depthNear),m.depthFar>0&&(ne=m.depthFar)),U.near=I.near=T.near=re,U.far=I.far=T.far=ne,(Y!==U.near||Z!==U.far)&&(s.updateRenderState({depthNear:U.near,depthFar:U.far}),Y=U.near,Z=U.far),U.layers.mask=K.layers.mask|6,T.layers.mask=U.layers.mask&-5,I.layers.mask=U.layers.mask&-3;const k=K.parent,Pe=U.cameras;se(U,k);for(let Ie=0;Ie<Pe.length;Ie++)se(Pe[Ie],k);Pe.length===2?ee(U,T,I):U.projectionMatrix.copy(T.projectionMatrix),ge(K,U,k)};function ge(K,re,ne){ne===null?K.matrix.copy(re.matrixWorld):(K.matrix.copy(ne.matrixWorld),K.matrix.invert(),K.matrix.multiply(re.matrixWorld)),K.matrix.decompose(K.position,K.quaternion,K.scale),K.updateMatrixWorld(!0),K.projectionMatrix.copy(re.projectionMatrix),K.projectionMatrixInverse.copy(re.projectionMatrixInverse),K.isPerspectiveCamera&&(K.fov=Ho*2*Math.atan(1/K.projectionMatrix.elements[5]),K.zoom=1)}this.getCamera=function(){return U},this.getFoveation=function(){if(!(u===null&&p===null))return l},this.setFoveation=function(K){l=K,u!==null&&(u.fixedFoveation=K),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=K)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(U)},this.getCameraTexture=function(K){return f[K]};let Ve=null;function st(K,re){if(h=re.getViewerPose(c||a),_=re,h!==null){const ne=h.views;p!==null&&(e.setRenderTargetFramebuffer(S,p.framebuffer),e.setRenderTarget(S));let k=!1;ne.length!==U.cameras.length&&(U.cameras.length=0,k=!0);for(let xe=0;xe<ne.length;xe++){const Ne=ne[xe];let De=null;if(p!==null)De=p.getViewport(Ne);else{const Ke=d.getViewSubImage(u,Ne);De=Ke.viewport,xe===0&&(e.setRenderTargetTextures(S,Ke.colorTexture,Ke.depthStencilTexture),e.setRenderTarget(S))}let Le=C[xe];Le===void 0&&(Le=new Kt,Le.layers.enable(xe),Le.viewport=new ft,C[xe]=Le),Le.matrix.fromArray(Ne.transform.matrix),Le.matrix.decompose(Le.position,Le.quaternion,Le.scale),Le.projectionMatrix.fromArray(Ne.projectionMatrix),Le.projectionMatrixInverse.copy(Le.projectionMatrix).invert(),Le.viewport.set(De.x,De.y,De.width,De.height),xe===0&&(U.matrix.copy(Le.matrix),U.matrix.decompose(U.position,U.quaternion,U.scale)),k===!0&&U.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 Ne=ne[xe].camera;if(Ne){let De=f[Ne];De||(De=new mu,f[Ne]=De);const Le=d.getCameraImage(Ne);De.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,c||a)}Ve&&Ve(K,re),re.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:re}),_=null}const We=new Su;We.setAnimationLoop(st),this.setAnimationLoop=function(K){Ve=K},this.dispose=function(){}}}const n1=new lt,wu=new Oe;wu.set(-1,0,0,0,1,0,0,0,1);function i1(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,gu(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,S){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,S)):f.isMeshMatcapMaterial?(r(m,f),_(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?l(m,f,A,w):f.isSpriteMaterial?c(m,f):f.isShadowMaterial?(m.color.value.copy(f.color),m.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function r(m,f){m.opacity.value=f.opacity,f.color&&m.diffuse.value.copy(f.color),f.emissive&&m.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(m.map.value=f.map,t(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.bumpMap&&(m.bumpMap.value=f.bumpMap,t(f.bumpMap,m.bumpMapTransform),m.bumpScale.value=f.bumpScale,f.side===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 A=e.get(f),w=A.envMap,S=A.envMapRotation;w&&(m.envMap.value=w,m.envMapRotation.value.setFromMatrix4(n1.makeRotationFromEuler(S)).transpose(),w.isCubeTexture&&w.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(wu),m.reflectivity.value=f.reflectivity,m.ior.value=f.ior,m.refractionRatio.value=f.refractionRatio),f.lightMap&&(m.lightMap.value=f.lightMap,m.lightMapIntensity.value=f.lightMapIntensity,t(f.lightMap,m.lightMapTransform)),f.aoMap&&(m.aoMap.value=f.aoMap,m.aoMapIntensity.value=f.aoMapIntensity,t(f.aoMap,m.aoMapTransform))}function a(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,f.map&&(m.map.value=f.map,t(f.map,m.mapTransform))}function o(m,f){m.dashSize.value=f.dashSize,m.totalSize.value=f.dashSize+f.gapSize,m.scale.value=f.scale}function l(m,f,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 c(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.rotation.value=f.rotation,f.map&&(m.map.value=f.map,t(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function h(m,f){m.specular.value.copy(f.specular),m.shininess.value=Math.max(f.shininess,1e-4)}function 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===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=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 _(m,f){f.matcap&&(m.matcap.value=f.matcap)}function M(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 s1(i,e,t,n){let s={},r={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(S,y){const b=y.program;n.uniformBlockBinding(S,b)}function c(S,y){let b=s[S.id];b===void 0&&(m(S),b=h(S),s[S.id]=b,S.addEventListener("dispose",A));const R=y.program;n.updateUBOMapping(S,R);const v=e.render.frame;r[S.id]!==v&&(u(S),r[S.id]=v)}function h(S){const y=d();S.__bindingPointIndex=y;const b=i.createBuffer(),R=S.__size,v=S.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 S=0;S<o;S++)if(a.indexOf(S)===-1)return a.push(S),S;return Xe("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(S){const y=s[S.id],b=S.uniforms,R=S.__cache;i.bindBuffer(i.UNIFORM_BUFFER,y);for(let v=0,T=b.length;v<T;v++){const I=b[v];if(Array.isArray(I))for(let C=0,U=I.length;C<U;C++)p(I[C],v,C,R);else p(I,v,0,R)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function p(S,y,b,R){if(M(S,y,b,R)===!0){const v=S.__offset,T=S.value;if(Array.isArray(T)){let I=0;for(let C=0;C<T.length;C++){const U=T[C],Y=f(U);_(U,S.__data,I),typeof U!="number"&&typeof U!="boolean"&&!U.isMatrix3&&!ArrayBuffer.isView(U)&&(I+=Y.storage/Float32Array.BYTES_PER_ELEMENT)}}else _(T,S.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,v,S.__data)}}function _(S,y,b){typeof S=="number"||typeof S=="boolean"?y[0]=S:S.isMatrix3?(y[0]=S.elements[0],y[1]=S.elements[1],y[2]=S.elements[2],y[3]=0,y[4]=S.elements[3],y[5]=S.elements[4],y[6]=S.elements[5],y[7]=0,y[8]=S.elements[6],y[9]=S.elements[7],y[10]=S.elements[8],y[11]=0):ArrayBuffer.isView(S)?y.set(new S.constructor(S.buffer,S.byteOffset,y.length)):S.toArray(y,b)}function M(S,y,b,R){const v=S.value,T=y+"_"+b;if(R[T]===void 0)return typeof v=="number"||typeof v=="boolean"?R[T]=v:ArrayBuffer.isView(v)?R[T]=v.slice():R[T]=v.clone(),!0;{const I=R[T];if(typeof v=="number"||typeof v=="boolean"){if(I!==v)return R[T]=v,!0}else{if(ArrayBuffer.isView(v))return!0;if(I.equals(v)===!1)return I.copy(v),!0}}return!1}function m(S){const y=S.uniforms;let b=0;const R=16;for(let T=0,I=y.length;T<I;T++){const C=Array.isArray(y[T])?y[T]:[y[T]];for(let U=0,Y=C.length;U<Y;U++){const Z=C[U],O=Array.isArray(Z.value)?Z.value:[Z.value];for(let W=0,V=O.length;W<V;W++){const Q=O[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),Z.__data=new Float32Array(te.storage/Float32Array.BYTES_PER_ELEMENT),Z.__offset=b,b+=te.storage}}}const v=b%R;return v>0&&(b+=R-v),S.__size=b,S.__cache={},this}function f(S){const y={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(y.boundary=4,y.storage=4):S.isVector2?(y.boundary=8,y.storage=8):S.isVector3||S.isColor?(y.boundary=16,y.storage=12):S.isVector4?(y.boundary=16,y.storage=16):S.isMatrix3?(y.boundary=48,y.storage=48):S.isMatrix4?(y.boundary=64,y.storage=64):S.isTexture?Fe("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(S)?(y.boundary=16,y.storage=S.byteLength):Fe("WebGLRenderer: Unsupported uniform value type.",S),y}function A(S){const y=S.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 S in s)i.deleteBuffer(s[S]);a=[],s={},r={}}return{bind:l,update:c,dispose:w}}const r1=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 cn=null;function a1(){return cn===null&&(cn=new $0(r1,16,16,hi,Cn),cn.name="DFG_LUT",cn.minFilter=It,cn.magFilter=It,cn.wrapS=Tn,cn.wrapT=Tn,cn.generateMipmaps=!1,cn.needsUpdate=!0),cn}class o1{constructor(e={}){const{canvas:t=A0(),context:n=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:u=!1,outputBufferType:p=$t}=e;this.isWebGLRenderer=!0;let _;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");_=n.getContextAttributes().alpha}else _=a;const M=p,m=new Set([Sl,xl,vl]),f=new Set([$t,gn,bs,Ts,gl,_l]),A=new Uint32Array(4),w=new Int32Array(4),S=new F;let y=null,b=null;const R=[],v=[];let T=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 I=this;let C=!1,U=null,Y=null,Z=null,O=null;this._outputColorSpace=Zt;let W=0,V=0,Q=null,te=-1,ee=null;const se=new ft,ge=new ft;let Ve=null;const st=new Ce(0);let We=0,K=t.width,re=t.height,ne=1,k=null,Pe=null;const Ie=new ft(0,0,K,re),we=new ft(0,0,K,re);let xe=!1;const Ne=new du;let De=!1,Le=!1;const Ke=new lt,$e=new F,ct=new ft,ot={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ht=!1;function vt(){return Q===null?ne:1}let D=n;function Bt(x,L){return t.getContext(x,L)}try{const x={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${pl}`),t.addEventListener("webglcontextlost",ut,!1),t.addEventListener("webglcontextrestored",rt,!1),t.addEventListener("webglcontextcreationerror",rn,!1),D===null){const L="webgl2";if(D=Bt(L,x),D===null)throw Bt(L)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(x){throw Xe("WebGLRenderer: "+x.message),x}let Je,E,g,N,G,X,ie,oe,q,J,le,be,ue,ce,Re,Ue,Be,P,ae,$,he,me,j;function Ee(){Je=new ag(D),Je.init(),he=new J_(D,Je),E=new Qm(D,Je,e,he),g=new K_(D,Je),E.reversedDepthBuffer&&u&&g.buffers.depth.setReversed(!0),Y=D.createFramebuffer(),Z=D.createFramebuffer(),O=D.createFramebuffer(),N=new cg(D),G=new N_,X=new $_(D,Je,g,G,E,he,N),ie=new rg(I),oe=new ff(D),me=new $m(D,oe),q=new og(D,oe,N,me),J=new ug(D,q,oe,me,N),P=new hg(D,E,X),Re=new jm(G),le=new U_(I,ie,Je,E,me,Re),be=new i1(I,G),ue=new O_,ce=new V_(Je),Be=new Km(I,ie,g,J,_,l),Ue=new Z_(I,J,E),j=new s1(D,N,E,g),ae=new Jm(D,Je,N),$=new lg(D,Je,N),N.programs=le.programs,I.capabilities=E,I.extensions=Je,I.properties=G,I.renderLists=ue,I.shadowMap=Ue,I.state=g,I.info=N}Ee(),M!==$t&&(T=new fg(M,t.width,t.height,o,s,r));const Se=new t1(I,D);this.xr=Se,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){const x=Je.get("WEBGL_lose_context");x&&x.loseContext()},this.forceContextRestore=function(){const x=Je.get("WEBGL_lose_context");x&&x.restoreContext()},this.getPixelRatio=function(){return ne},this.setPixelRatio=function(x){x!==void 0&&(ne=x,this.setSize(K,re,!1))},this.getSize=function(x){return x.set(K,re)},this.setSize=function(x,L,H=!0){if(Se.isPresenting){Fe("WebGLRenderer: Can't change size while VR device is presenting.");return}K=x,re=L,t.width=Math.floor(x*ne),t.height=Math.floor(L*ne),H===!0&&(t.style.width=x+"px",t.style.height=L+"px"),T!==null&&T.setSize(t.width,t.height),this.setViewport(0,0,x,L)},this.getDrawingBufferSize=function(x){return x.set(K*ne,re*ne).floor()},this.setDrawingBufferSize=function(x,L,H){K=x,re=L,ne=H,t.width=Math.floor(x*H),t.height=Math.floor(L*H),this.setViewport(0,0,x,L)},this.setEffects=function(x){if(M===$t){Xe("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(x){for(let L=0;L<x.length;L++)if(x[L].isOutputPass===!0){Fe("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}T.setEffects(x||[])},this.getCurrentViewport=function(x){return x.copy(se)},this.getViewport=function(x){return x.copy(Ie)},this.setViewport=function(x,L,H,B){x.isVector4?Ie.set(x.x,x.y,x.z,x.w):Ie.set(x,L,H,B),g.viewport(se.copy(Ie).multiplyScalar(ne).round())},this.getScissor=function(x){return x.copy(we)},this.setScissor=function(x,L,H,B){x.isVector4?we.set(x.x,x.y,x.z,x.w):we.set(x,L,H,B),g.scissor(ge.copy(we).multiplyScalar(ne).round())},this.getScissorTest=function(){return xe},this.setScissorTest=function(x){g.setScissorTest(xe=x)},this.setOpaqueSort=function(x){k=x},this.setTransparentSort=function(x){Pe=x},this.getClearColor=function(x){return x.copy(Be.getClearColor())},this.setClearColor=function(){Be.setClearColor(...arguments)},this.getClearAlpha=function(){return Be.getClearAlpha()},this.setClearAlpha=function(){Be.setClearAlpha(...arguments)},this.clear=function(x=!0,L=!0,H=!0){let B=0;if(x){let z=!1;if(Q!==null){const pe=Q.texture.format;z=m.has(pe)}if(z){const pe=Q.texture.type,ve=f.has(pe),fe=Be.getClearColor(),Me=Be.getClearAlpha(),Te=fe.r,ze=fe.g,He=fe.b;ve?(A[0]=Te,A[1]=ze,A[2]=He,A[3]=Me,D.clearBufferuiv(D.COLOR,0,A)):(w[0]=Te,w[1]=ze,w[2]=He,w[3]=Me,D.clearBufferiv(D.COLOR,0,w))}else B|=D.COLOR_BUFFER_BIT}L&&(B|=D.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),H&&(B|=D.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),B!==0&&D.clear(B)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(x){x.setRenderer(this),U=x},this.dispose=function(){t.removeEventListener("webglcontextlost",ut,!1),t.removeEventListener("webglcontextrestored",rt,!1),t.removeEventListener("webglcontextcreationerror",rn,!1),Be.dispose(),ue.dispose(),ce.dispose(),G.dispose(),ie.dispose(),J.dispose(),me.dispose(),j.dispose(),le.dispose(),Se.dispose(),Se.removeEventListener("sessionstart",Ul),Se.removeEventListener("sessionend",Nl),$n.stop()};function ut(x){x.preventDefault(),Br("WebGLRenderer: Context Lost."),C=!0}function rt(){Br("WebGLRenderer: Context Restored."),C=!1;const x=N.autoReset,L=Ue.enabled,H=Ue.autoUpdate,B=Ue.needsUpdate,z=Ue.type;Ee(),N.autoReset=x,Ue.enabled=L,Ue.autoUpdate=H,Ue.needsUpdate=B,Ue.type=z}function rn(x){Xe("WebGLRenderer: A WebGL context could not be created. Reason: ",x.statusMessage)}function an(x){const L=x.target;L.removeEventListener("dispose",an),ed(L)}function ed(x){td(x),G.remove(x)}function td(x){const L=G.get(x).programs;L!==void 0&&(L.forEach(function(H){le.releaseProgram(H)}),x.isShaderMaterial&&le.releaseShaderCache(x))}this.renderBufferDirect=function(x,L,H,B,z,pe){L===null&&(L=ot);const ve=z.isMesh&&z.matrixWorld.determinantAffine()<0,fe=sd(x,L,H,B,z);g.setMaterial(B,ve);let Me=H.index,Te=1;if(B.wireframe===!0){if(Me=q.getWireframeAttribute(H),Me===void 0)return;Te=2}const ze=H.drawRange,He=H.attributes.position;let Ae=ze.start*Te,je=(ze.start+ze.count)*Te;pe!==null&&(Ae=Math.max(Ae,pe.start*Te),je=Math.min(je,(pe.start+pe.count)*Te)),Me!==null?(Ae=Math.max(Ae,0),je=Math.min(je,Me.count)):He!=null&&(Ae=Math.max(Ae,0),je=Math.min(je,He.count));const mt=je-Ae;if(mt<0||mt===1/0)return;me.setup(z,B,fe,H,Me);let dt,tt=ae;if(Me!==null&&(dt=oe.get(Me),tt=$,tt.setIndex(dt)),z.isMesh)B.wireframe===!0?(g.setLineWidth(B.wireframeLinewidth*vt()),tt.setMode(D.LINES)):tt.setMode(D.TRIANGLES);else if(z.isLine){let wt=B.linewidth;wt===void 0&&(wt=1),g.setLineWidth(wt*vt()),z.isLineSegments?tt.setMode(D.LINES):z.isLineLoop?tt.setMode(D.LINE_LOOP):tt.setMode(D.LINE_STRIP)}else z.isPoints?tt.setMode(D.POINTS):z.isSprite&&tt.setMode(D.TRIANGLES);if(z.isBatchedMesh)if(Je.get("WEBGL_multi_draw"))tt.renderMultiDraw(z._multiDrawStarts,z._multiDrawCounts,z._multiDrawCount);else{const wt=z._multiDrawStarts,_e=z._multiDrawCounts,Gt=z._multiDrawCount,Ze=Me?oe.get(Me).bytesPerElement:1,Wt=G.get(B).currentProgram.getUniforms();for(let on=0;on<Gt;on++)Wt.setValue(D,"_gl_DrawID",on),tt.render(wt[on]/Ze,_e[on])}else if(z.isInstancedMesh)tt.renderInstances(Ae,mt,z.count);else if(H.isInstancedBufferGeometry){const wt=H._maxInstanceCount!==void 0?H._maxInstanceCount:1/0,_e=Math.min(H.instanceCount,wt);tt.renderInstances(Ae,mt,_e)}else tt.render(Ae,mt)};function Ll(x,L,H){x.transparent===!0&&x.side===bn&&x.forceSinglePass===!1?(x.side=Dt,x.needsUpdate=!0,Is(x,L,H),x.side=Zn,x.needsUpdate=!0,Is(x,L,H),x.side=bn):Is(x,L,H)}this.compile=function(x,L,H=null){H===null&&(H=x),b=ce.get(H),b.init(L),v.push(b),H.traverseVisible(function(z){z.isLight&&z.layers.test(L.layers)&&(b.pushLight(z),z.castShadow&&b.pushShadow(z))}),x!==H&&x.traverseVisible(function(z){z.isLight&&z.layers.test(L.layers)&&(b.pushLight(z),z.castShadow&&b.pushShadow(z))}),b.setupLights();const B=new Set;return x.traverse(function(z){if(!(z.isMesh||z.isPoints||z.isLine||z.isSprite))return;const pe=z.material;if(pe)if(Array.isArray(pe))for(let ve=0;ve<pe.length;ve++){const fe=pe[ve];Ll(fe,H,z),B.add(fe)}else Ll(pe,H,z),B.add(pe)}),b=v.pop(),B},this.compileAsync=function(x,L,H=null){const B=this.compile(x,L,H);return new Promise(z=>{function pe(){if(B.forEach(function(ve){G.get(ve).currentProgram.isReady()&&B.delete(ve)}),B.size===0){z(x);return}setTimeout(pe,10)}Je.get("KHR_parallel_shader_compile")!==null?pe():setTimeout(pe,10)})};let na=null;function nd(x){na&&na(x)}function Ul(){$n.stop()}function Nl(){$n.start()}const $n=new Su;$n.setAnimationLoop(nd),typeof self<"u"&&$n.setContext(self),this.setAnimationLoop=function(x){na=x,Se.setAnimationLoop(x),x===null?$n.stop():$n.start()},Se.addEventListener("sessionstart",Ul),Se.addEventListener("sessionend",Nl),this.render=function(x,L){if(L!==void 0&&L.isCamera!==!0){Xe("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;U!==null&&U.renderStart(x,L);const H=Se.enabled===!0&&Se.isPresenting===!0,B=T!==null&&(Q===null||H)&&T.begin(I,Q);if(x.matrixWorldAutoUpdate===!0&&x.updateMatrixWorld(),L.parent===null&&L.matrixWorldAutoUpdate===!0&&L.updateMatrixWorld(),Se.enabled===!0&&Se.isPresenting===!0&&(T===null||T.isCompositing()===!1)&&(Se.cameraAutoUpdate===!0&&Se.updateCamera(L),L=Se.getCamera()),x.isScene===!0&&x.onBeforeRender(I,x,L,Q),b=ce.get(x,v.length),b.init(L),b.state.textureUnits=X.getTextureUnits(),v.push(b),Ke.multiplyMatrices(L.projectionMatrix,L.matrixWorldInverse),Ne.setFromProjectionMatrix(Ke,fn,L.reversedDepth),Le=this.localClippingEnabled,De=Re.init(this.clippingPlanes,Le),y=ue.get(x,R.length),y.init(),R.push(y),Se.enabled===!0&&Se.isPresenting===!0){const ve=I.xr.getDepthSensingMesh();ve!==null&&ia(ve,L,-1/0,I.sortObjects)}ia(x,L,0,I.sortObjects),y.finish(),I.sortObjects===!0&&y.sort(k,Pe,L.reversedDepth),ht=Se.enabled===!1||Se.isPresenting===!1||Se.hasDepthSensing()===!1,ht&&Be.addToRenderList(y,x),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),De===!0&&Re.beginShadows();const z=b.state.shadowsArray;if(Ue.render(z,x,L),De===!0&&Re.endShadows(),(B&&T.hasRenderPass())===!1){const ve=y.opaque,fe=y.transmissive;if(b.setupLights(),L.isArrayCamera){const Me=L.cameras;if(fe.length>0)for(let Te=0,ze=Me.length;Te<ze;Te++){const He=Me[Te];Ol(ve,fe,x,He)}ht&&Be.render(x);for(let Te=0,ze=Me.length;Te<ze;Te++){const He=Me[Te];Fl(y,x,He,He.viewport)}}else fe.length>0&&Ol(ve,fe,x,L),ht&&Be.render(x),Fl(y,x,L)}Q!==null&&V===0&&(X.updateMultisampleRenderTarget(Q),X.updateRenderTargetMipmap(Q)),B&&T.end(I),x.isScene===!0&&x.onAfterRender(I,x,L),me.resetDefaultState(),te=-1,ee=null,v.pop(),v.length>0?(b=v[v.length-1],X.setTextureUnits(b.state.textureUnits),De===!0&&Re.setGlobalState(I.clippingPlanes,b.state.camera)):b=null,R.pop(),R.length>0?y=R[R.length-1]:y=null,U!==null&&U.renderEnd()};function ia(x,L,H,B){if(x.visible===!1)return;if(x.layers.test(L.layers)){if(x.isGroup)H=x.renderOrder;else if(x.isLOD)x.autoUpdate===!0&&x.update(L);else if(x.isLightProbeGrid)b.pushLightProbeGrid(x);else if(x.isLight)b.pushLight(x),x.castShadow&&b.pushShadow(x);else if(x.isSprite){if(!x.frustumCulled||Ne.intersectsSprite(x)){B&&ct.setFromMatrixPosition(x.matrixWorld).applyMatrix4(Ke);const ve=J.update(x),fe=x.material;fe.visible&&y.push(x,ve,fe,H,ct.z,null)}}else if((x.isMesh||x.isLine||x.isPoints)&&(!x.frustumCulled||Ne.intersectsObject(x))){const ve=J.update(x),fe=x.material;if(B&&(x.boundingSphere!==void 0?(x.boundingSphere===null&&x.computeBoundingSphere(),ct.copy(x.boundingSphere.center)):(ve.boundingSphere===null&&ve.computeBoundingSphere(),ct.copy(ve.boundingSphere.center)),ct.applyMatrix4(x.matrixWorld).applyMatrix4(Ke)),Array.isArray(fe)){const Me=ve.groups;for(let Te=0,ze=Me.length;Te<ze;Te++){const He=Me[Te],Ae=fe[He.materialIndex];Ae&&Ae.visible&&y.push(x,ve,Ae,H,ct.z,He)}}else fe.visible&&y.push(x,ve,fe,H,ct.z,null)}}const pe=x.children;for(let ve=0,fe=pe.length;ve<fe;ve++)ia(pe[ve],L,H,B)}function Fl(x,L,H,B){const{opaque:z,transmissive:pe,transparent:ve}=x;b.setupLightsView(H),De===!0&&Re.setGlobalState(I.clippingPlanes,H),B&&g.viewport(se.copy(B)),z.length>0&&Ps(z,L,H),pe.length>0&&Ps(pe,L,H),ve.length>0&&Ps(ve,L,H),g.buffers.depth.setTest(!0),g.buffers.depth.setMask(!0),g.buffers.color.setMask(!0),g.setPolygonOffset(!1)}function Ol(x,L,H,B){if((H.isScene===!0?H.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[B.id]===void 0){const Ae=Je.has("EXT_color_buffer_half_float")||Je.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[B.id]=new mn(1,1,{generateMipmaps:!0,type:Ae?Cn:$t,minFilter:ri,samples:Math.max(4,E.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:qe.workingColorSpace})}const pe=b.state.transmissionRenderTarget[B.id],ve=B.viewport||se;pe.setSize(ve.z*I.transmissionResolutionScale,ve.w*I.transmissionResolutionScale);const fe=I.getRenderTarget(),Me=I.getActiveCubeFace(),Te=I.getActiveMipmapLevel();I.setRenderTarget(pe),I.getClearColor(st),We=I.getClearAlpha(),We<1&&I.setClearColor(16777215,.5),I.clear(),ht&&Be.render(H);const ze=I.toneMapping;I.toneMapping=pn;const He=B.viewport;if(B.viewport!==void 0&&(B.viewport=void 0),b.setupLightsView(B),De===!0&&Re.setGlobalState(I.clippingPlanes,B),Ps(x,H,B),X.updateMultisampleRenderTarget(pe),X.updateRenderTargetMipmap(pe),Je.has("WEBGL_multisampled_render_to_texture")===!1){let Ae=!1;for(let je=0,mt=L.length;je<mt;je++){const dt=L[je],{object:tt,geometry:wt,material:_e,group:Gt}=dt;if(_e.side===bn&&tt.layers.test(B.layers)){const Ze=_e.side;_e.side=Dt,_e.needsUpdate=!0,Bl(tt,H,B,wt,_e,Gt),_e.side=Ze,_e.needsUpdate=!0,Ae=!0}}Ae===!0&&(X.updateMultisampleRenderTarget(pe),X.updateRenderTargetMipmap(pe))}I.setRenderTarget(fe,Me,Te),I.setClearColor(st,We),He!==void 0&&(B.viewport=He),I.toneMapping=ze}function Ps(x,L,H){const B=L.isScene===!0?L.overrideMaterial:null;for(let z=0,pe=x.length;z<pe;z++){const ve=x[z],{object:fe,geometry:Me,group:Te}=ve;let ze=ve.material;ze.allowOverride===!0&&B!==null&&(ze=B),fe.layers.test(H.layers)&&Bl(fe,L,H,Me,ze,Te)}}function Bl(x,L,H,B,z,pe){x.onBeforeRender(I,L,H,B,z,pe),x.modelViewMatrix.multiplyMatrices(H.matrixWorldInverse,x.matrixWorld),x.normalMatrix.getNormalMatrix(x.modelViewMatrix),z.onBeforeRender(I,L,H,B,x,pe),z.transparent===!0&&z.side===bn&&z.forceSinglePass===!1?(z.side=Dt,z.needsUpdate=!0,I.renderBufferDirect(H,L,B,z,x,pe),z.side=Zn,z.needsUpdate=!0,I.renderBufferDirect(H,L,B,z,x,pe),z.side=bn):I.renderBufferDirect(H,L,B,z,x,pe),x.onAfterRender(I,L,H,B,z,pe)}function Is(x,L,H){L.isScene!==!0&&(L=ot);const B=G.get(x),z=b.state.lights,pe=b.state.shadowsArray,ve=z.state.version,fe=le.getParameters(x,z.state,pe,L,H,b.state.lightProbeGridArray),Me=le.getProgramCacheKey(fe);let Te=B.programs;B.environment=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?L.environment:null,B.fog=L.fog;const ze=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap;B.envMap=ie.get(x.envMap||B.environment,ze),B.envMapRotation=B.environment!==null&&x.envMap===null?L.environmentRotation:x.envMapRotation,Te===void 0&&(x.addEventListener("dispose",an),Te=new Map,B.programs=Te);let He=Te.get(Me);if(He!==void 0){if(B.currentProgram===He&&B.lightsStateVersion===ve)return kl(x,fe),He}else fe.uniforms=le.getUniforms(x),U!==null&&x.isNodeMaterial&&U.build(x,H,fe),x.onBeforeCompile(fe,I),He=le.acquireProgram(fe,Me),Te.set(Me,He),B.uniforms=fe.uniforms;const Ae=B.uniforms;return(!x.isShaderMaterial&&!x.isRawShaderMaterial||x.clipping===!0)&&(Ae.clippingPlanes=Re.uniform),kl(x,fe),B.needsLights=ad(x),B.lightsStateVersion=ve,B.needsLights&&(Ae.ambientLightColor.value=z.state.ambient,Ae.lightProbe.value=z.state.probe,Ae.directionalLights.value=z.state.directional,Ae.directionalLightShadows.value=z.state.directionalShadow,Ae.spotLights.value=z.state.spot,Ae.spotLightShadows.value=z.state.spotShadow,Ae.rectAreaLights.value=z.state.rectArea,Ae.ltc_1.value=z.state.rectAreaLTC1,Ae.ltc_2.value=z.state.rectAreaLTC2,Ae.pointLights.value=z.state.point,Ae.pointLightShadows.value=z.state.pointShadow,Ae.hemisphereLights.value=z.state.hemi,Ae.directionalShadowMatrix.value=z.state.directionalShadowMatrix,Ae.spotLightMatrix.value=z.state.spotLightMatrix,Ae.spotLightMap.value=z.state.spotLightMap,Ae.pointShadowMatrix.value=z.state.pointShadowMatrix),B.lightProbeGrid=b.state.lightProbeGridArray.length>0,B.currentProgram=He,B.uniformsList=null,He}function zl(x){if(x.uniformsList===null){const L=x.currentProgram.getUniforms();x.uniformsList=Cr.seqWithValue(L.seq,x.uniforms)}return x.uniformsList}function kl(x,L){const H=G.get(x);H.outputColorSpace=L.outputColorSpace,H.batching=L.batching,H.batchingColor=L.batchingColor,H.instancing=L.instancing,H.instancingColor=L.instancingColor,H.instancingMorph=L.instancingMorph,H.skinning=L.skinning,H.morphTargets=L.morphTargets,H.morphNormals=L.morphNormals,H.morphColors=L.morphColors,H.morphTargetsCount=L.morphTargetsCount,H.numClippingPlanes=L.numClippingPlanes,H.numIntersection=L.numClipIntersection,H.vertexAlphas=L.vertexAlphas,H.vertexTangents=L.vertexTangents,H.toneMapping=L.toneMapping}function id(x,L){if(x.length===0)return null;if(x.length===1)return x[0].texture!==null?x[0]:null;S.setFromMatrixPosition(L.matrixWorld);for(let H=0,B=x.length;H<B;H++){const z=x[H];if(z.texture!==null&&z.boundingBox.containsPoint(S))return z}return null}function sd(x,L,H,B,z){L.isScene!==!0&&(L=ot),X.resetTextureUnits();const pe=L.fog,ve=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?L.environment:null,fe=Q===null?I.outputColorSpace:Q.isXRRenderTarget===!0?Q.texture.colorSpace:qe.workingColorSpace,Me=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Te=ie.get(B.envMap||ve,Me),ze=B.vertexColors===!0&&!!H.attributes.color&&H.attributes.color.itemSize===4,He=!!H.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Ae=!!H.morphAttributes.position,je=!!H.morphAttributes.normal,mt=!!H.morphAttributes.color;let dt=pn;B.toneMapped&&(Q===null||Q.isXRRenderTarget===!0)&&(dt=I.toneMapping);const tt=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,wt=tt!==void 0?tt.length:0,_e=G.get(B),Gt=b.state.lights;if(De===!0&&(Le===!0||x!==ee)){const at=x===ee&&B.id===te;Re.setState(B,x,at)}let Ze=!1;B.version===_e.__version?(_e.needsLights&&_e.lightsStateVersion!==Gt.state.version||_e.outputColorSpace!==fe||z.isBatchedMesh&&_e.batching===!1||!z.isBatchedMesh&&_e.batching===!0||z.isBatchedMesh&&_e.batchingColor===!0&&z.colorTexture===null||z.isBatchedMesh&&_e.batchingColor===!1&&z.colorTexture!==null||z.isInstancedMesh&&_e.instancing===!1||!z.isInstancedMesh&&_e.instancing===!0||z.isSkinnedMesh&&_e.skinning===!1||!z.isSkinnedMesh&&_e.skinning===!0||z.isInstancedMesh&&_e.instancingColor===!0&&z.instanceColor===null||z.isInstancedMesh&&_e.instancingColor===!1&&z.instanceColor!==null||z.isInstancedMesh&&_e.instancingMorph===!0&&z.morphTexture===null||z.isInstancedMesh&&_e.instancingMorph===!1&&z.morphTexture!==null||_e.envMap!==Te||B.fog===!0&&_e.fog!==pe||_e.numClippingPlanes!==void 0&&(_e.numClippingPlanes!==Re.numPlanes||_e.numIntersection!==Re.numIntersection)||_e.vertexAlphas!==ze||_e.vertexTangents!==He||_e.morphTargets!==Ae||_e.morphNormals!==je||_e.morphColors!==mt||_e.toneMapping!==dt||_e.morphTargetsCount!==wt||!!_e.lightProbeGrid!=b.state.lightProbeGridArray.length>0)&&(Ze=!0):(Ze=!0,_e.__version=B.version);let Wt=_e.currentProgram;Ze===!0&&(Wt=Is(B,L,z),U&&B.isNodeMaterial&&U.onUpdateProgram(B,Wt,_e));let on=!1,In=!1,pi=!1;const nt=Wt.getUniforms(),gt=_e.uniforms;if(g.useProgram(Wt.program)&&(on=!0,In=!0,pi=!0),B.id!==te&&(te=B.id,In=!0),_e.needsLights){const at=id(b.state.lightProbeGridArray,z);_e.lightProbeGrid!==at&&(_e.lightProbeGrid=at,In=!0)}if(on||ee!==x){g.buffers.depth.getReversed()&&x.reversedDepth!==!0&&(x._reversedDepth=!0,x.updateProjectionMatrix()),nt.setValue(D,"projectionMatrix",x.projectionMatrix),nt.setValue(D,"viewMatrix",x.matrixWorldInverse);const Ln=nt.map.cameraPosition;Ln!==void 0&&Ln.setValue(D,$e.setFromMatrixPosition(x.matrixWorld)),E.logarithmicDepthBuffer&&nt.setValue(D,"logDepthBufFC",2/(Math.log(x.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&nt.setValue(D,"isOrthographic",x.isOrthographicCamera===!0),ee!==x&&(ee=x,In=!0,pi=!0)}if(_e.needsLights&&(Gt.state.directionalShadowMap.length>0&&nt.setValue(D,"directionalShadowMap",Gt.state.directionalShadowMap,X),Gt.state.spotShadowMap.length>0&&nt.setValue(D,"spotShadowMap",Gt.state.spotShadowMap,X),Gt.state.pointShadowMap.length>0&&nt.setValue(D,"pointShadowMap",Gt.state.pointShadowMap,X)),z.isSkinnedMesh){nt.setOptional(D,z,"bindMatrix"),nt.setOptional(D,z,"bindMatrixInverse");const at=z.skeleton;at&&(at.boneTexture===null&&at.computeBoneTexture(),nt.setValue(D,"boneTexture",at.boneTexture,X))}z.isBatchedMesh&&(nt.setOptional(D,z,"batchingTexture"),nt.setValue(D,"batchingTexture",z._matricesTexture,X),nt.setOptional(D,z,"batchingIdTexture"),nt.setValue(D,"batchingIdTexture",z._indirectTexture,X),nt.setOptional(D,z,"batchingColorTexture"),z._colorsTexture!==null&&nt.setValue(D,"batchingColorTexture",z._colorsTexture,X));const Dn=H.morphAttributes;if((Dn.position!==void 0||Dn.normal!==void 0||Dn.color!==void 0)&&P.update(z,H,Wt),(In||_e.receiveShadow!==z.receiveShadow)&&(_e.receiveShadow=z.receiveShadow,nt.setValue(D,"receiveShadow",z.receiveShadow)),(B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&L.environment!==null&&(gt.envMapIntensity.value=L.environmentIntensity),gt.dfgLUT!==void 0&&(gt.dfgLUT.value=a1()),In){if(nt.setValue(D,"toneMappingExposure",I.toneMappingExposure),_e.needsLights&&rd(gt,pi),pe&&B.fog===!0&&be.refreshFogUniforms(gt,pe),be.refreshMaterialUniforms(gt,B,ne,re,b.state.transmissionRenderTarget[x.id]),_e.needsLights&&_e.lightProbeGrid){const at=_e.lightProbeGrid;gt.probesSH.value=at.texture,gt.probesMin.value.copy(at.boundingBox.min),gt.probesMax.value.copy(at.boundingBox.max),gt.probesResolution.value.copy(at.resolution)}Cr.upload(D,zl(_e),gt,X)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(Cr.upload(D,zl(_e),gt,X),B.uniformsNeedUpdate=!1),B.isSpriteMaterial&&nt.setValue(D,"center",z.center),nt.setValue(D,"modelViewMatrix",z.modelViewMatrix),nt.setValue(D,"normalMatrix",z.normalMatrix),nt.setValue(D,"modelMatrix",z.matrixWorld),B.uniformsGroups!==void 0){const at=B.uniformsGroups;for(let Ln=0,mi=at.length;Ln<mi;Ln++){const Gl=at[Ln];j.update(Gl,Wt),j.bind(Gl,Wt)}}return Wt}function rd(x,L){x.ambientLightColor.needsUpdate=L,x.lightProbe.needsUpdate=L,x.directionalLights.needsUpdate=L,x.directionalLightShadows.needsUpdate=L,x.pointLights.needsUpdate=L,x.pointLightShadows.needsUpdate=L,x.spotLights.needsUpdate=L,x.spotLightShadows.needsUpdate=L,x.rectAreaLights.needsUpdate=L,x.hemisphereLights.needsUpdate=L}function ad(x){return x.isMeshLambertMaterial||x.isMeshToonMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isShadowMaterial||x.isShaderMaterial&&x.lights===!0}this.getActiveCubeFace=function(){return W},this.getActiveMipmapLevel=function(){return V},this.getRenderTarget=function(){return Q},this.setRenderTargetTextures=function(x,L,H){const B=G.get(x);B.__autoAllocateDepthBuffer=x.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1&&(B.__useRenderToTexture=!1),G.get(x.texture).__webglTexture=L,G.get(x.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:H,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(x,L){const H=G.get(x);H.__webglFramebuffer=L,H.__useDefaultFramebuffer=L===void 0},this.setRenderTarget=function(x,L=0,H=0){Q=x,W=L,V=H;let B=null,z=!1,pe=!1;if(x){const fe=G.get(x);if(fe.__useDefaultFramebuffer!==void 0){g.bindFramebuffer(D.FRAMEBUFFER,fe.__webglFramebuffer),se.copy(x.viewport),ge.copy(x.scissor),Ve=x.scissorTest,g.viewport(se),g.scissor(ge),g.setScissorTest(Ve),te=-1;return}else if(fe.__webglFramebuffer===void 0)X.setupRenderTarget(x);else if(fe.__hasExternalTextures)X.rebindTextures(x,G.get(x.texture).__webglTexture,G.get(x.depthTexture).__webglTexture);else if(x.depthBuffer){const ze=x.depthTexture;if(fe.__boundDepthTexture!==ze){if(ze!==null&&G.has(ze)&&(x.width!==ze.image.width||x.height!==ze.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");X.setupDepthRenderbuffer(x)}}const Me=x.texture;(Me.isData3DTexture||Me.isDataArrayTexture||Me.isCompressedArrayTexture)&&(pe=!0);const Te=G.get(x).__webglFramebuffer;x.isWebGLCubeRenderTarget?(Array.isArray(Te[L])?B=Te[L][H]:B=Te[L],z=!0):x.samples>0&&X.useMultisampledRTT(x)===!1?B=G.get(x).__webglMultisampledFramebuffer:Array.isArray(Te)?B=Te[H]:B=Te,se.copy(x.viewport),ge.copy(x.scissor),Ve=x.scissorTest}else se.copy(Ie).multiplyScalar(ne).floor(),ge.copy(we).multiplyScalar(ne).floor(),Ve=xe;if(H!==0&&(B=Y),g.bindFramebuffer(D.FRAMEBUFFER,B)&&g.drawBuffers(x,B),g.viewport(se),g.scissor(ge),g.setScissorTest(Ve),z){const fe=G.get(x.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+L,fe.__webglTexture,H)}else if(pe){const fe=L;for(let Me=0;Me<x.textures.length;Me++){const Te=G.get(x.textures[Me]);D.framebufferTextureLayer(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0+Me,Te.__webglTexture,H,fe)}}else if(x!==null&&H!==0){const fe=G.get(x.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,fe.__webglTexture,H)}te=-1},this.readRenderTargetPixels=function(x,L,H,B,z,pe,ve,fe=0){if(!(x&&x.isWebGLRenderTarget)){Xe("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Me=G.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&ve!==void 0&&(Me=Me[ve]),Me){g.bindFramebuffer(D.FRAMEBUFFER,Me);try{const Te=x.textures[fe],ze=Te.format,He=Te.type;if(x.textures.length>1&&D.readBuffer(D.COLOR_ATTACHMENT0+fe),!E.textureFormatReadable(ze)){Xe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!E.textureTypeReadable(He)){Xe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}L>=0&&L<=x.width-B&&H>=0&&H<=x.height-z&&D.readPixels(L,H,B,z,he.convert(ze),he.convert(He),pe)}finally{const Te=Q!==null?G.get(Q).__webglFramebuffer:null;g.bindFramebuffer(D.FRAMEBUFFER,Te)}}},this.readRenderTargetPixelsAsync=async function(x,L,H,B,z,pe,ve,fe=0){if(!(x&&x.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Me=G.get(x).__webglFramebuffer;if(x.isWebGLCubeRenderTarget&&ve!==void 0&&(Me=Me[ve]),Me)if(L>=0&&L<=x.width-B&&H>=0&&H<=x.height-z){g.bindFramebuffer(D.FRAMEBUFFER,Me);const Te=x.textures[fe],ze=Te.format,He=Te.type;if(x.textures.length>1&&D.readBuffer(D.COLOR_ATTACHMENT0+fe),!E.textureFormatReadable(ze))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!E.textureTypeReadable(He))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ae=D.createBuffer();D.bindBuffer(D.PIXEL_PACK_BUFFER,Ae),D.bufferData(D.PIXEL_PACK_BUFFER,pe.byteLength,D.STREAM_READ),D.readPixels(L,H,B,z,he.convert(ze),he.convert(He),0);const je=Q!==null?G.get(Q).__webglFramebuffer:null;g.bindFramebuffer(D.FRAMEBUFFER,je);const mt=D.fenceSync(D.SYNC_GPU_COMMANDS_COMPLETE,0);return D.flush(),await w0(D,mt,4),D.bindBuffer(D.PIXEL_PACK_BUFFER,Ae),D.getBufferSubData(D.PIXEL_PACK_BUFFER,0,pe),D.deleteBuffer(Ae),D.deleteSync(mt),pe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(x,L=null,H=0){const B=Math.pow(2,-H),z=Math.floor(x.image.width*B),pe=Math.floor(x.image.height*B),ve=L!==null?L.x:0,fe=L!==null?L.y:0;X.setTexture2D(x,0),D.copyTexSubImage2D(D.TEXTURE_2D,H,0,0,ve,fe,z,pe),g.unbindTexture()},this.copyTextureToTexture=function(x,L,H=null,B=null,z=0,pe=0){let ve,fe,Me,Te,ze,He,Ae,je,mt;const dt=x.isCompressedTexture?x.mipmaps[pe]:x.image;if(H!==null)ve=H.max.x-H.min.x,fe=H.max.y-H.min.y,Me=H.isBox3?H.max.z-H.min.z:1,Te=H.min.x,ze=H.min.y,He=H.isBox3?H.min.z:0;else{const gt=Math.pow(2,-z);ve=Math.floor(dt.width*gt),fe=Math.floor(dt.height*gt),x.isDataArrayTexture?Me=dt.depth:x.isData3DTexture?Me=Math.floor(dt.depth*gt):Me=1,Te=0,ze=0,He=0}B!==null?(Ae=B.x,je=B.y,mt=B.z):(Ae=0,je=0,mt=0);const tt=he.convert(L.format),wt=he.convert(L.type);let _e;L.isData3DTexture?(X.setTexture3D(L,0),_e=D.TEXTURE_3D):L.isDataArrayTexture||L.isCompressedArrayTexture?(X.setTexture2DArray(L,0),_e=D.TEXTURE_2D_ARRAY):(X.setTexture2D(L,0),_e=D.TEXTURE_2D),g.activeTexture(D.TEXTURE0),g.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,L.flipY),g.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),g.pixelStorei(D.UNPACK_ALIGNMENT,L.unpackAlignment);const Gt=g.getParameter(D.UNPACK_ROW_LENGTH),Ze=g.getParameter(D.UNPACK_IMAGE_HEIGHT),Wt=g.getParameter(D.UNPACK_SKIP_PIXELS),on=g.getParameter(D.UNPACK_SKIP_ROWS),In=g.getParameter(D.UNPACK_SKIP_IMAGES);g.pixelStorei(D.UNPACK_ROW_LENGTH,dt.width),g.pixelStorei(D.UNPACK_IMAGE_HEIGHT,dt.height),g.pixelStorei(D.UNPACK_SKIP_PIXELS,Te),g.pixelStorei(D.UNPACK_SKIP_ROWS,ze),g.pixelStorei(D.UNPACK_SKIP_IMAGES,He);const pi=x.isDataArrayTexture||x.isData3DTexture,nt=L.isDataArrayTexture||L.isData3DTexture;if(x.isDepthTexture){const gt=G.get(x),Dn=G.get(L),at=G.get(gt.__renderTarget),Ln=G.get(Dn.__renderTarget);g.bindFramebuffer(D.READ_FRAMEBUFFER,at.__webglFramebuffer),g.bindFramebuffer(D.DRAW_FRAMEBUFFER,Ln.__webglFramebuffer);for(let mi=0;mi<Me;mi++)pi&&(D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,G.get(x).__webglTexture,z,He+mi),D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,G.get(L).__webglTexture,pe,mt+mi)),D.blitFramebuffer(Te,ze,ve,fe,Ae,je,ve,fe,D.DEPTH_BUFFER_BIT,D.NEAREST);g.bindFramebuffer(D.READ_FRAMEBUFFER,null),g.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else if(z!==0||x.isRenderTargetTexture||G.has(x)){const gt=G.get(x),Dn=G.get(L);g.bindFramebuffer(D.READ_FRAMEBUFFER,Z),g.bindFramebuffer(D.DRAW_FRAMEBUFFER,O);for(let at=0;at<Me;at++)pi?D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,gt.__webglTexture,z,He+at):D.framebufferTexture2D(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,gt.__webglTexture,z),nt?D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,Dn.__webglTexture,pe,mt+at):D.framebufferTexture2D(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,Dn.__webglTexture,pe),z!==0?D.blitFramebuffer(Te,ze,ve,fe,Ae,je,ve,fe,D.COLOR_BUFFER_BIT,D.NEAREST):nt?D.copyTexSubImage3D(_e,pe,Ae,je,mt+at,Te,ze,ve,fe):D.copyTexSubImage2D(_e,pe,Ae,je,Te,ze,ve,fe);g.bindFramebuffer(D.READ_FRAMEBUFFER,null),g.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else nt?x.isDataTexture||x.isData3DTexture?D.texSubImage3D(_e,pe,Ae,je,mt,ve,fe,Me,tt,wt,dt.data):L.isCompressedArrayTexture?D.compressedTexSubImage3D(_e,pe,Ae,je,mt,ve,fe,Me,tt,dt.data):D.texSubImage3D(_e,pe,Ae,je,mt,ve,fe,Me,tt,wt,dt):x.isDataTexture?D.texSubImage2D(D.TEXTURE_2D,pe,Ae,je,ve,fe,tt,wt,dt.data):x.isCompressedTexture?D.compressedTexSubImage2D(D.TEXTURE_2D,pe,Ae,je,dt.width,dt.height,tt,dt.data):D.texSubImage2D(D.TEXTURE_2D,pe,Ae,je,ve,fe,tt,wt,dt);g.pixelStorei(D.UNPACK_ROW_LENGTH,Gt),g.pixelStorei(D.UNPACK_IMAGE_HEIGHT,Ze),g.pixelStorei(D.UNPACK_SKIP_PIXELS,Wt),g.pixelStorei(D.UNPACK_SKIP_ROWS,on),g.pixelStorei(D.UNPACK_SKIP_IMAGES,In),pe===0&&L.generateMipmaps&&D.generateMipmap(_e),g.unbindTexture()},this.initRenderTarget=function(x){G.get(x).__webglFramebuffer===void 0&&X.setupRenderTarget(x)},this.initTexture=function(x){x.isCubeTexture?X.setTextureCube(x,0):x.isData3DTexture?X.setTexture3D(x,0):x.isDataArrayTexture||x.isCompressedArrayTexture?X.setTexture2DArray(x,0):X.setTexture2D(x,0),g.unbindTexture()},this.resetState=function(){W=0,V=0,Q=null,g.reset(),me.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return fn}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 Yo=Math.PI/180,Yc=180/Math.PI;function Cs(i,e,t){return Math.max(e,Math.min(t,i))}const kn=[{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 Pr(i,e,t){return i+(e-i)*t}function kr(i,e,t){return[Pr(i[0],e[0],t),Pr(i[1],e[1],t),Pr(i[2],e[2],t)]}function Ru(i){const e=Math.max(kn[0].altitudeDeg,Math.min(kn[kn.length-1].altitudeDeg,i));for(let n=0;n<kn.length-1;n++){const s=kn[n],r=kn[n+1];if(e>=s.altitudeDeg&&e<=r.altitudeDeg){const a=(e-s.altitudeDeg)/(r.altitudeDeg-s.altitudeDeg);return{zenith:kr(s.zenith,r.zenith,a),horizon:kr(s.horizon,r.horizon,a)}}}const t=kn[kn.length-1];return{zenith:t.zenith,horizon:t.horizon}}function l1(i){if(i<=-18)return 7.5;if(i>=0)return-4;const n=(i+18)/18;return Pr(7.5,-4,n)}const c1=-1.5,h1=7.5;function Zc(i){const e=10**(-.4*i),t=10**(-.4*c1),n=10**(-.4*h1);return Cs((e-n)/(t-n),0,1)}function fs(i,e,t){const n=i*Yo,s=e*Yo,r=t*Math.cos(n);return{x:r*Math.sin(s),y:t*Math.sin(n),z:-r*Math.cos(s)}}function u1(i,e,t){const n=Math.sqrt(i*i+e*e+t*t),s=n===0?0:Math.asin(Cs(e/n,-1,1))*Yc,r=(Math.atan2(i,-t)*Yc+360)%360;return{altitudeDeg:s,azimuthDeg:r}}function d1(i,e){const t=Math.abs(i-e)%360;return t>180?360-t:t}function f1(i,e,t){const n=Math.max(0,1-d1(i,e)/90),s=Math.max(0,1-Math.abs(t)/18);return n*s}function p1(i,e,t,n){const{zenith:s,horizon:r}=Ru(n),a=Cs((i+90)/180,0,1),o=kr(r,s,a),l=f1(e,t,n);return l<=0?o:kr(o,r,l*(1-a)*.8)}function Kc(i){return .3+.7*i}const m1=-4;function g1(i){return Math.max(0,m1-i)}const _1=6,v1=60;function x1(i){return Math.min(v1,_1*Math.sqrt(i))}const S1=3,M1=.55;function y1(i){return M1*Cs(i/S1,0,1)}function E1(i){const e=Math.max(i,-4),t=Math.sin(e*Yo)+.50572*Math.pow(e+6.07995,-1.6364);return Cs(1/t,1,40)}function Ba(i){const e=E1(i)-1;return[1,Math.exp(-.022*e),Math.exp(-.062*e)]}const Cu=[{maxBrightness:.5,size:1.2},{maxBrightness:.85,size:2},{maxBrightness:1/0,size:3.2}];function b1(i){return Cu.findIndex(e=>i<=e.maxBrightness)}const T1=.25,$c=.3,A1=2.2;function w1(i,{phase:e,speedFactor:t},n){const r=1+T1*($c+(1-$c)*i)*Math.sin(n*A1*t+e);return Math.min(1,Math.max(0,r))}/**
|
|
4434
4434
|
@preserve
|
|
4435
4435
|
|
|
4436
4436
|
Astronomy library for JavaScript (browser and Node.js).
|
|
@@ -4461,7 +4461,7 @@ void main() {
|
|
|
4461
4461
|
* @fileoverview Astronomy calculation library for browser scripting and Node.js.
|
|
4462
4462
|
* @author Don Cross <cosinekitty@gmail.com>
|
|
4463
4463
|
* @license MIT
|
|
4464
|
-
*/const Lu=173.1446326846693,si=14959787069098932e-8,ie=.017453292519943295,jc=.26179938779914946,Zn=57.29577951308232,Uu=3.819718634205488,P1=365.24217,th=new Date("2000-01-01T12:00:00Z"),yn=2*Math.PI,Gn=3600*(180/Math.PI),Hi=484813681109536e-20,Nu=10800*60,I1=2*Nu,eh=7292115e-11,D1=Nu/Math.PI,L1=-.17-5*Math.log10(D1),Zo=.996647180302104,U1=Zo*Zo,Ko=6378.1366,N1=Ko/si,Fu=81.30056,Rl=.0002959122082855911,$o=2825345909524226e-22,Jo=8459715185680659e-23,Qo=1292024916781969e-23,jo=1524358900784276e-23;function Vr(i){if(i!==!0&&i!==!1)throw console.trace(),`Value is not boolean: ${i}`;return i}function be(i){if(!Number.isFinite(i))throw console.trace(),`Value is not a finite number: ${i}`;return i}function Ui(i){return i-Math.floor(i)}function F1(i,t){const e=i.x*i.x+i.y*i.y+i.z*i.z;if(Math.abs(e)<1e-8)throw"AngleBetween: first vector is too short.";const n=t.x*t.x+t.y*t.y+t.z*t.z;if(Math.abs(n)<1e-8)throw"AngleBetween: second vector is too short.";const s=(i.x*t.x+i.y*t.y+i.z*t.z)/Math.sqrt(e*n);return s<=-1?180:s>=1?0:Zn*Math.acos(s)}var yt;(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"})(yt||(yt={}));const O1=[yt.Star1,yt.Star2,yt.Star3,yt.Star4,yt.Star5,yt.Star6,yt.Star7,yt.Star8],B1=[{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 z1(i){const t=O1.indexOf(i);return t>=0?B1[t]:null}function Cl(i){const t=z1(i);return t&&t.dist>0?t:null}var Qe;(function(i){i[i.From2000=0]="From2000",i[i.Into2000=1]="Into2000"})(Qe||(Qe={}));const An={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 k1(i){var t,e,n,s,r,a,o;const l=2e3+(i-14)/P1;return l<-500?(t=(l-1820)/100,-20+32*t*t):l<500?(t=l/100,e=t*t,n=t*e,s=e*e,r=e*n,a=n*n,10583.6-1014.41*t+33.78311*e-5.952053*n-.1798452*s+.022174192*r+.0090316521*a):l<1600?(t=(l-1e3)/100,e=t*t,n=t*e,s=e*e,r=e*n,a=n*n,1574.2-556.01*t+71.23472*e+.319781*n-.8503463*s-.005050998*r+.0083572073*a):l<1700?(t=l-1600,e=t*t,n=t*e,120-.9808*t-.01532*e+n/7129):l<1800?(t=l-1700,e=t*t,n=t*e,s=e*e,8.83+.1603*t-.0059285*e+13336e-8*n-s/1174e3):l<1860?(t=l-1800,e=t*t,n=t*e,s=e*e,r=e*n,a=n*n,o=n*s,13.72-.332447*t+.0068612*e+.0041116*n-37436e-8*s+121272e-10*r-1699e-10*a+875e-12*o):l<1900?(t=l-1860,e=t*t,n=t*e,s=e*e,r=e*n,7.62+.5737*t-.251754*e+.01680668*n-.0004473624*s+r/233174):l<1920?(t=l-1900,e=t*t,n=t*e,s=e*e,-2.79+1.494119*t-.0598939*e+.0061966*n-197e-6*s):l<1941?(t=l-1920,e=t*t,n=t*e,21.2+.84493*t-.0761*e+.0020936*n):l<1961?(t=l-1950,e=t*t,n=t*e,29.07+.407*t-e/233+n/2547):l<1986?(t=l-1975,e=t*t,n=t*e,45.45+1.067*t-e/260-n/718):l<2005?(t=l-2e3,e=t*t,n=t*e,s=e*e,r=e*n,63.86+.3345*t-.060374*e+.0017275*n+651814e-9*s+2373599e-11*r):l<2050?(t=l-2e3,62.92+.32217*t+.005589*t*t):l<2150?(t=(l-1820)/100,-20+32*t*t-.5628*(2150-l)):(t=(l-1820)/100,-20+32*t*t)}let H1=k1;function nh(i){return i+H1(i)/86400}class Yi{constructor(t){if(t instanceof Yi){this.date=t.date,this.ut=t.ut,this.tt=t.tt;return}const e=1e3*3600*24;if(t instanceof Date&&Number.isFinite(t.getTime())){this.date=t,this.ut=(t.getTime()-th.getTime())/e,this.tt=nh(this.ut);return}if(Number.isFinite(t)){this.date=new Date(th.getTime()+t*e),this.ut=t,this.tt=nh(this.ut);return}throw"Argument must be a Date object, an AstroTime object, or a numeric UTC Julian date."}static FromTerrestrialTime(t){let e=new Yi(t);for(;;){const n=t-e.tt;if(Math.abs(n)<1e-12)return e;e=e.AddDays(n)}}toString(){return this.date.toISOString()}AddDays(t){return new Yi(this.ut+t)}}function je(i){return i instanceof Yi?i:new Yi(i)}function G1(i){function t(u){return u%I1*Hi}const e=i.tt/36525,n=t(128710479305e-5+e*1295965810481e-4),s=t(335779.526232+e*17395272628478e-4),r=t(107226070369e-5+e*1602961601209e-3),a=t(450160.398036-e*69628905431e-4);let o=Math.sin(a),l=Math.cos(a),c=(-172064161-174666*e)*o+33386*l,h=(92052331+9086*e)*l+15377*o,d=2*(s-r+a);return o=Math.sin(d),l=Math.cos(d),c+=(-13170906-1675*e)*o-13696*l,h+=(5730336-3015*e)*l-4587*o,d=2*(s+a),o=Math.sin(d),l=Math.cos(d),c+=(-2276413-234*e)*o+2796*l,h+=(978459-485*e)*l+1374*o,d=2*a,o=Math.sin(d),l=Math.cos(d),c+=(2074554+207*e)*o-698*l,h+=(-897492+470*e)*l-291*o,o=Math.sin(n),l=Math.cos(n),c+=(1475877-3633*e)*o+11817*l,h+=(73871-184*e)*l-1924*o,{dpsi:-135e-6+c*1e-7,deps:388e-6+h*1e-7}}function Ou(i){var t=i.tt/36525,e=((((-434e-10*t-576e-9)*t+.0020034)*t-1831e-7)*t-46.836769)*t+84381.406;return e/3600}var cr;function Pl(i){if(!cr||Math.abs(cr.tt-i.tt)>1e-6){const t=G1(i),e=Ou(i),n=e+t.deps/3600;cr={tt:i.tt,dpsi:t.dpsi,deps:t.deps,ee:t.dpsi*Math.cos(e*ie)/15,mobl:e,tobl:n}}return cr}function V1(i,t){const e=i*ie,n=Math.cos(e),s=Math.sin(e);return[t[0],t[1]*n-t[2]*s,t[1]*s+t[2]*n]}function W1(i,t){return V1(Ou(i),t)}function X1(i){const t=i.tt/36525;function e(wt,xt){const Nt=[];let Dt;for(Dt=0;Dt<=xt-wt;++Dt)Nt.push(0);return{min:wt,array:Nt}}function n(wt,xt,Nt,Dt){const Lt=[];for(let Kt=0;Kt<=xt-wt;++Kt)Lt.push(e(Nt,Dt));return{min:wt,array:Lt}}function s(wt,xt,Nt){const Dt=wt.array[xt-wt.min];return Dt.array[Nt-Dt.min]}function r(wt,xt,Nt,Dt){const Lt=wt.array[xt-wt.min];Lt.array[Nt-Lt.min]=Dt}let a,o,l,c,h,d,u,p,_,M,m,f,A,w,S,y,b,R,v,T,I,C,U,Y=n(-6,6,1,4),Z=n(-6,6,1,4);function O(wt,xt){return s(Y,wt,xt)}function W(wt,xt){return s(Z,wt,xt)}function V(wt,xt,Nt){return r(Y,wt,xt,Nt)}function Q(wt,xt,Nt){return r(Z,wt,xt,Nt)}function et(wt,xt,Nt,Dt,Lt){Lt(wt*Nt-xt*Dt,xt*Nt+wt*Dt)}function tt(wt){return Math.sin(yn*wt)}u=t*t,_=0,U=0,m=0,f=3422.7;var st=tt(.19833+.05611*t),gt=tt(.27869+.04508*t),Vt=tt(.16827-.36903*t),se=tt(.34734-5.37261*t),Wt=tt(.10498-5.37899*t),K=tt(.42681-.41855*t),rt=tt(.14943-5.37511*t);for(R=.84*st+.31*gt+14.27*Vt+7.26*se+.28*Wt+.24*K,v=2.94*st+.31*gt+14.27*Vt+9.34*se+1.12*Wt+.83*K,T=-6.4*st-1.89*K,I=.21*st+.31*gt+14.27*Vt-88.7*se-15.3*Wt+.24*K-1.86*rt,C=R-T,p=-3332e-9*tt(.59734-5.37261*t)-539e-9*tt(.35498-5.37899*t)-64e-9*tt(.39943-5.37511*t),A=yn*Ui(.60643382+1336.85522467*t-313e-8*u)+R/Gn,w=yn*Ui(.37489701+1325.55240982*t+2565e-8*u)+v/Gn,S=yn*Ui(.99312619+99.99735956*t-44e-8*u)+T/Gn,y=yn*Ui(.25909118+1342.2278298*t-892e-8*u)+I/Gn,b=yn*Ui(.82736186+1236.85308708*t-397e-8*u)+C/Gn,h=1;h<=4;++h){switch(h){case 1:l=w,o=4,c=1.000002208;break;case 2:l=S,o=3,c=.997504612-.002495388*t;break;case 3:l=y,o=4,c=1.000002708+139.978*p;break;case 4:l=b,o=6,c=1;break;default:throw`Internal error: I = ${h}`}for(V(0,h,1),V(1,h,Math.cos(l)*c),Q(0,h,0),Q(1,h,Math.sin(l)*c),d=2;d<=o;++d)et(O(d-1,h),W(d-1,h),O(1,h),W(1,h),(wt,xt)=>(V(d,h,wt),Q(d,h,xt)));for(d=1;d<=o;++d)V(-d,h,O(d,h)),Q(-d,h,-W(d,h))}function nt(wt,xt,Nt,Dt){for(var Lt={x:1,y:0},Kt=[0,wt,xt,Nt,Dt],$t=1;$t<=4;++$t)Kt[$t]!==0&&et(Lt.x,Lt.y,O(Kt[$t],$t),W(Kt[$t],$t),(ce,oe)=>(Lt.x=ce,Lt.y=oe));return Lt}function k(wt,xt,Nt,Dt,Lt,Kt,$t,ce){var oe=nt(Lt,Kt,$t,ce);_+=wt*oe.y,U+=xt*oe.y,m+=Nt*oe.x,f+=Dt*oe.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 Ct(wt,xt,Nt,Dt,Lt){return wt*nt(xt,Nt,Dt,Lt).y}M=0,M+=Ct(-526.069,0,0,1,-2),M+=Ct(-3.352,0,0,1,-4),M+=Ct(44.297,1,0,1,-2),M+=Ct(-6,1,0,1,-4),M+=Ct(20.599,-1,0,1,0),M+=Ct(-30.598,-1,0,1,-2),M+=Ct(-24.649,-2,0,1,0),M+=Ct(-2,-2,0,1,-2),M+=Ct(-22.571,0,1,1,-2),M+=Ct(10.985,0,-1,1,-2),_+=.82*tt(.7736-62.5512*t)+.31*tt(.0466-125.1025*t)+.35*tt(.5785-25.1042*t)+.66*tt(.4591+1335.8075*t)+.64*tt(.313-91.568*t)+1.14*tt(.148+1331.2898*t)+.21*tt(.5918+1056.5859*t)+.44*tt(.5784+1322.8595*t)+.24*tt(.2275-5.7374*t)+.28*tt(.2965+2.6929*t)+.33*tt(.3132+6.3368*t),a=y+U/Gn;let Pt=(1.000002708+139.978*p)*(18518.511+1.189+m)*Math.sin(a)-6.24*Math.sin(3*a)+M;return{geo_eclip_lon:yn*Ui((A+_/Gn)/yn),geo_eclip_lat:Math.PI/(180*3600)*Pt,distance_au:Gn*N1/(.999953253*f)}}function Bu(i,t){return[i.rot[0][0]*t[0]+i.rot[1][0]*t[1]+i.rot[2][0]*t[2],i.rot[0][1]*t[0]+i.rot[1][1]*t[1]+i.rot[2][1]*t[2],i.rot[0][2]*t[0]+i.rot[1][2]*t[1]+i.rot[2][2]*t[2]]}function Wr(i,t,e){const n=q1(t,e);return Bu(n,i)}function q1(i,t){const e=i.tt/36525;let n=84381.406,s=((((-951e-10*e+132851e-9)*e-.00114045)*e-1.0790069)*e+5038.481507)*e,r=((((3337e-10*e-467e-9)*e-.00772503)*e+.0512623)*e-.025754)*e+n,a=((((-56e-9*e+170663e-9)*e-.00121197)*e-2.3814292)*e+10.556403)*e;n*=Hi,s*=Hi,r*=Hi,a*=Hi;const o=Math.sin(n),l=Math.cos(n),c=Math.sin(-s),h=Math.cos(-s),d=Math.sin(-r),u=Math.cos(-r),p=Math.sin(a),_=Math.cos(a),M=_*h-c*p*u,m=_*c*l+p*u*h*l-o*p*d,f=_*c*o+p*u*h*o+l*p*d,A=-p*h-c*_*u,w=-p*c*l+_*u*h*l-o*_*d,S=-p*c*o+_*u*h*o+l*_*d,y=c*d,b=-d*h*l-o*u,R=-d*h*o+u*l;if(t===Qe.Into2000)return new Xr([[M,m,f],[A,w,S],[y,b,R]]);if(t===Qe.From2000)return new Xr([[M,A,y],[m,w,b],[f,S,R]]);throw"Invalid precess direction"}function Y1(i){const t=.779057273264+.00273781191135448*i.ut,e=i.ut%1;let n=360*((t+e)%1);return n<0&&(n+=360),n}let hr;function zu(i){if(!hr||hr.tt!==i.tt){const t=i.tt/36525;let e=15*Pl(i).ee;const n=Y1(i);let r=((e+.014506+((((-368e-10*t-29956e-9)*t-44e-8)*t+1.3915817)*t+4612.156534)*t)/3600+n)%360/15;r<0&&(r+=24),hr={tt:i.tt,st:r}}return hr.st}function Z1(i,t){const e=i.latitude*ie,n=Math.sin(e),s=Math.cos(e),r=1/Math.hypot(s,Zo*n),a=U1*r,o=i.height/1e3,l=Ko*r+o,c=Ko*a+o,h=(15*t+i.longitude)*ie,d=Math.sin(h),u=Math.cos(h);return{pos:[l*s*u/si,l*s*d/si,c*n/si],vel:[-eh*l*s*d*86400/si,eh*l*s*u*86400/si,0]}}function tl(i,t,e){const n=K1(t,e);return Bu(n,i)}function K1(i,t){const e=Pl(i),n=e.mobl*ie,s=e.tobl*ie,r=e.dpsi*Hi,a=Math.cos(n),o=Math.sin(n),l=Math.cos(s),c=Math.sin(s),h=Math.cos(r),d=Math.sin(r),u=h,p=-d*a,_=-d*o,M=d*l,m=h*a*l+o*c,f=h*o*l-a*c,A=d*c,w=h*a*c-o*l,S=h*o*c+a*l;if(t===Qe.From2000)return new Xr([[u,M,A],[p,m,w],[_,f,S]]);if(t===Qe.Into2000)return new Xr([[u,p,_],[M,m,f],[A,w,S]]);throw"Invalid precess direction"}function ku(i,t,e){return e===Qe.Into2000?Wr(tl(i,t,e),t,e):tl(Wr(i,t,e),t,e)}function $1(i,t){const e=zu(i),n=Z1(t,e).pos;return ku(n,i,Qe.Into2000)}class _e{constructor(t,e,n,s){this.x=t,this.y=e,this.z=n,this.t=s}Length(){return Math.hypot(this.x,this.y,this.z)}}class qn{constructor(t,e,n,s,r,a,o){this.x=t,this.y=e,this.z=n,this.vx=s,this.vy=r,this.vz=a,this.t=o}}class J1{constructor(t,e,n){this.lat=be(t),this.lon=be(e),this.dist=be(n)}}class ih{constructor(t,e,n,s){this.ra=be(t),this.dec=be(e),this.dist=be(n),this.vec=s}}class Xr{constructor(t){this.rot=t}}class Q1{constructor(t,e,n,s){this.azimuth=be(t),this.altitude=be(e),this.ra=be(n),this.dec=be(s)}}class j1{constructor(t,e,n){this.vec=t,this.elat=be(e),this.elon=be(n)}}function tv(i,t){return new _e(i[0],i[1],i[2],t)}function ev(i,t){const e=tv(i,t),n=e.x*e.x+e.y*e.y,s=Math.sqrt(n+e.z*e.z);if(n===0){if(e.z===0)throw"Indeterminate sky coordinates";return new ih(0,e.z<0?-90:90,s,e)}let r=Uu*Math.atan2(e.y,e.x);r<0&&(r+=24);const a=Zn*Math.atan2(i[2],Math.sqrt(n));return new ih(r,a,s,e)}function ka(i,t){const e=i*ie,n=Math.cos(e),s=Math.sin(e);return[n*t[0]+s*t[1],n*t[1]-s*t[0],t[2]]}function Hu(i,t,e,n,s){let r=je(i);Il(t),be(e),be(n);const a=Math.sin(t.latitude*ie),o=Math.cos(t.latitude*ie),l=Math.sin(t.longitude*ie),c=Math.cos(t.longitude*ie),h=Math.sin(n*ie),d=Math.cos(n*ie),u=Math.sin(e*jc),p=Math.cos(e*jc);let _=[o*c,o*l,a],M=[-a*c,-a*l,o],m=[l,-c,0];const f=-15*zu(r);let A=ka(f,_),w=ka(f,M),S=ka(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]*S[0]+y[1]*S[1]+y[2]*S[2];let T=Math.hypot(R,v),I;T>0?(I=-Zn*Math.atan2(v,R),I<0&&(I+=360)):I=0;let C=Zn*Math.atan2(T,b),U=e,Y=n;{let Z=C,O=Ev(s,90-C);if(C-=O,O>0&&C>3e-4){const W=Math.sin(C*ie),V=Math.cos(C*ie),Q=Math.sin(Z*ie),et=Math.cos(Z*ie),tt=[];for(let st=0;st<3;++st)tt.push((y[st]-et*A[st])/Q*W+A[st]*V);T=Math.hypot(tt[0],tt[1]),T>0?(U=Uu*Math.atan2(tt[1],tt[0]),U<0&&(U+=24)):U=0,Y=Zn*Math.atan2(tt[2],T)}}return new Q1(I,90-C,U,Y)}function Il(i){if(!(i instanceof Gu))throw`Not an instance of the Observer class: ${i}`;if(be(i.latitude),be(i.longitude),be(i.height),i.latitude<-90||i.latitude>90)throw`Latitude ${i.latitude} is out of range. Must be -90..+90.`;return i}class Gu{constructor(t,e,n){this.latitude=t,this.longitude=e,this.height=n,Il(this)}}function nv(i,t,e,n,s){Il(e),Vr(n),Vr(s);const r=je(t),a=$1(r,e),o=hl(i,r,s),l=[o.x-a[0],o.y-a[1],o.z-a[2]],c=ku(l,r,Qe.From2000);return ev(c,r)}function iv(i,t,e){const n=i.x,s=i.y*t+i.z*e,r=-i.y*e+i.z*t,a=Math.hypot(n,s);let o=0;a>0&&(o=Zn*Math.atan2(s,n),o<0&&(o+=360));let l=Zn*Math.atan2(r,a),c=new _e(n,s,r,i.t);return new j1(c,l,o)}function el(i){const t=Pl(i.t),e=[i.x,i.y,i.z],n=Wr(e,i.t,Qe.From2000),[s,r,a]=tl(n,i.t,Qe.From2000),o=new _e(s,r,a,i.t),l=t.tobl*ie;return iv(o,Math.cos(l),Math.sin(l))}function ji(i){const t=je(i),e=X1(t),n=e.distance_au*Math.cos(e.geo_eclip_lat),s=[n*Math.cos(e.geo_eclip_lon),n*Math.sin(e.geo_eclip_lon),e.distance_au*Math.sin(e.geo_eclip_lat)],r=W1(t,s),a=Wr(r,t,Qe.Into2000);return new _e(a[0],a[1],a[2],t)}function Vu(i){const t=je(i),e=1e-5,n=t.AddDays(-e),s=t.AddDays(+e),r=ji(n),a=ji(s);return new qn((r.x+a.x)/2,(r.y+a.y)/2,(r.z+a.z)/2,(a.x-r.x)/(2*e),(a.y-r.y)/(2*e),(a.z-r.z)/(2*e),t)}function sv(i){const t=je(i),e=Vu(t),n=1+Fu;return new qn(e.x/n,e.y/n,e.z/n,e.vx/n,e.vy/n,e.vz/n,t)}function Zi(i,t,e){let n=1,s=0;for(let r of i){let a=0;for(let[l,c,h]of r)a+=l*Math.cos(c+t*h);let o=n*a;e&&(o%=yn),s+=o,n*=t}return s}function Ha(i,t){let e=1,n=0,s=0,r=0;for(let a of i){let o=0,l=0;for(let[c,h,d]of a){let u=h+t*d;o+=c*d*Math.sin(u),r>0&&(l+=c*Math.cos(u))}s+=r*n*l-e*o,n=e,e*=t,++r}return s}const Ms=365250,nl=0,il=1,sl=2;function rl(i){return new Pe(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 Wu(i,t,e){const n=e*Math.cos(t),s=Math.cos(i),r=Math.sin(i);return[n*s,n*r,e*Math.sin(t)]}function bs(i,t){const e=t.tt/Ms,n=Zi(i[nl],e,!0),s=Zi(i[il],e,!1),r=Zi(i[sl],e,!1),a=Wu(n,s,r);return rl(a).ToAstroVector(t)}function al(i,t){const e=t/Ms,n=Zi(i[nl],e,!0),s=Zi(i[il],e,!1),r=Zi(i[sl],e,!1),a=Ha(i[nl],e),o=Ha(i[il],e),l=Ha(i[sl],e),c=Math.cos(n),h=Math.sin(n),d=Math.cos(s),u=Math.sin(s),p=+(l*d*c)-r*u*c*o-r*d*h*a,_=+(l*d*h)-r*u*h*o+r*d*c*a,M=+(l*u)+r*d*o,m=Wu(n,s,r),f=[p/Ms,_/Ms,M/Ms],A=rl(m),w=rl(f);return new di(t,A,w)}function ur(i,t,e,n){const s=n/(n+Rl),r=bs(An[e],t);i.x+=s*r.x,i.y+=s*r.y,i.z+=s*r.z}function rv(i){const t=new _e(0,0,0,i);return ur(t,i,yt.Jupiter,$o),ur(t,i,yt.Saturn,Jo),ur(t,i,yt.Uranus,Qo),ur(t,i,yt.Neptune,jo),t}const ol=51,av=29200,Gi=146,En=201,oi=[[-73e4,[-26.118207232108,-14.376168177825,3.384402515299],[.0016339372163656,-.0027861699588508,-.0013585880229445]],[-700800,[41.974905202127,-.448502952929,-12.770351505989],[.00073458569351457,.0022785014891658,.00048619778602049]],[-671600,[14.706930780744,44.269110540027,9.353698474772],[-.00210001479998,.00022295915939915,.00070143443551414]],[-642400,[-29.441003929957,-6.43016153057,6.858481011305],[.00084495803960544,-.0030783914758711,-.0012106305981192]],[-613200,[39.444396946234,-6.557989760571,-13.913760296463],[.0011480029005873,.0022400006880665,.00035168075922288]],[-584e3,[20.2303809507,43.266966657189,7.382966091923],[-.0019754081700585,.00053457141292226,.00075929169129793]],[-554800,[-30.65832536462,2.093818874552,9.880531138071],[61010603013347e-18,-.0031326500935382,-.00099346125151067]],[-525600,[35.737703251673,-12.587706024764,-14.677847247563],[.0015802939375649,.0021347678412429,.00019074436384343]],[-496400,[25.466295188546,41.367478338417,5.216476873382],[-.0018054401046468,.0008328308359951,.00080260156912107]],[-467200,[-29.847174904071,10.636426313081,12.297904180106],[-.00063257063052907,-.0029969577578221,-.00074476074151596]],[-438e3,[30.774692107687,-18.236637015304,-14.945535879896],[.0020113162005465,.0019353827024189,-20937793168297e-19]],[-408800,[30.243153324028,38.656267888503,2.938501750218],[-.0016052508674468,.0011183495337525,.00083333973416824]],[-379600,[-27.288984772533,18.643162147874,14.023633623329],[-.0011856388898191,-.0027170609282181,-.00049015526126399]],[-350400,[24.519605196774,-23.245756064727,-14.626862367368],[.0024322321483154,.0016062008146048,-.00023369181613312]],[-321200,[34.505274805875,35.125338586954,.557361475637],[-.0013824391637782,.0013833397561817,.00084823598806262]],[-292e3,[-23.275363915119,25.818514298769,15.055381588598],[-.0016062295460975,-.0023395961498533,-.00024377362639479]],[-262800,[17.050384798092,-27.180376290126,-13.608963321694],[.0028175521080578,.0011358749093955,-.00049548725258825]],[-233600,[38.093671910285,30.880588383337,-1.843688067413],[-.0011317697153459,.0016128814698472,.00084177586176055]],[-204400,[-18.197852930878,31.932869934309,15.438294826279],[-.0019117272501813,-.0019146495909842,-19657304369835e-18]],[-175200,[8.528924039997,-29.618422200048,-11.805400994258],[.0031034370787005,.0005139363329243,-.00077293066202546]],[-146e3,[40.94685725864,25.904973592021,-4.256336240499],[-.00083652705194051,.0018129497136404,.0008156422827306]],[-116800,[-12.326958895325,36.881883446292,15.217158258711],[-.0021166103705038,-.001481442003599,.00017401209844705]],[-87600,[-.633258375909,-30.018759794709,-9.17193287495],[.0032016994581737,-.00025279858672148,-.0010411088271861]],[-58400,[42.936048423883,20.344685584452,-6.588027007912],[-.00050525450073192,.0019910074335507,.00077440196540269]],[-29200,[-5.975910552974,40.61180995846,14.470131723673],[-.0022184202156107,-.0010562361130164,.00033652250216211]],[0,[-9.875369580774,-27.978926224737,-5.753711824704],[.0030287533248818,-.0011276087003636,-.0012651326732361]],[29200,[43.958831986165,14.214147973292,-8.808306227163],[-.00014717608981871,.0021404187242141,.00071486567806614]],[58400,[.67813676352,43.094461639362,13.243238780721],[-.0022358226110718,-.00063233636090933,.00047664798895648]],[87600,[-18.282602096834,-23.30503958666,-1.766620508028],[.0025567245263557,-.0019902940754171,-.0013943491701082]],[116800,[43.873338744526,7.700705617215,-10.814273666425],[.00023174803055677,.0022402163127924,.00062988756452032]],[146e3,[7.392949027906,44.382678951534,11.629500214854],[-.002193281545383,-.00021751799585364,.00059556516201114]],[175200,[-24.981690229261,-16.204012851426,2.466457544298],[.001819398914958,-.0026765419531201,-.0013848283502247]],[204400,[42.530187039511,.845935508021,-12.554907527683],[.00065059779150669,.0022725657282262,.00051133743202822]],[233600,[13.999526486822,44.462363044894,9.669418486465],[-.0021079296569252,.00017533423831993,.00069128485798076]],[262800,[-29.184024803031,-7.371243995762,6.493275957928],[.00093581363109681,-.0030610357109184,-.0012364201089345]],[292e3,[39.831980671753,-6.078405766765,-13.909815358656],[.0011117769689167,.0022362097830152,.00036230548231153]],[321200,[20.294955108476,43.417190420251,7.450091985932],[-.0019742157451535,.00053102050468554,.00075938408813008]],[350400,[-30.66999230216,2.318743558955,9.973480913858],[45605107450676e-18,-.0031308219926928,-.00099066533301924]],[379600,[35.626122155983,-12.897647509224,-14.777586508444],[.0016015684949743,.0021171931182284,.00018002516202204]],[408800,[26.133186148561,41.232139187599,5.00640132622],[-.0017857704419579,.00086046232702817,.00080614690298954]],[438e3,[-29.57674022923,11.863535943587,12.631323039872],[-.00072292830060955,-.0029587820140709,-.000708242964503]],[467200,[29.910805787391,-19.159019294,-15.013363865194],[.0020871080437997,.0018848372554514,-38528655083926e-18]],[496400,[31.375957451819,38.050372720763,2.433138343754],[-.0015546055556611,.0011699815465629,.00083565439266001]],[525600,[-26.360071336928,20.662505904952,14.414696258958],[-.0013142373118349,-.0026236647854842,-.00042542017598193]],[554800,[22.599441488648,-24.508879898306,-14.484045731468],[.0025454108304806,.0014917058755191,-.00030243665086079]],[584e3,[35.877864013014,33.894226366071,-.224524636277],[-.0012941245730845,.0014560427668319,.00084762160640137]],[613200,[-21.538149762417,28.204068269761,15.321973799534],[-.001731211740901,-.0021939631314577,-.0001631691327518]],[642400,[13.971521374415,-28.339941764789,-13.083792871886],[.0029334630526035,.00091860931752944,-.00059939422488627]],[671600,[39.526942044143,28.93989736011,-2.872799527539],[-.0010068481658095,.001702113288809,.00083578230511981]],[700800,[-15.576200701394,34.399412961275,15.466033737854],[-.0020098814612884,-.0017191109825989,70414782780416e-18]],[73e4,[4.24325283709,-30.118201690825,-10.707441231349],[.0031725847067411,.0001609846120227,-.00090672150593868]]];class Pe{constructor(t,e,n){this.x=t,this.y=e,this.z=n}clone(){return new Pe(this.x,this.y,this.z)}ToAstroVector(t){return new _e(this.x,this.y,this.z,t)}static zero(){return new Pe(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(t){return new Pe(this.x+t.x,this.y+t.y,this.z+t.z)}sub(t){return new Pe(this.x-t.x,this.y-t.y,this.z-t.z)}incr(t){this.x+=t.x,this.y+=t.y,this.z+=t.z}decr(t){this.x-=t.x,this.y-=t.y,this.z-=t.z}mul(t){return new Pe(t*this.x,t*this.y,t*this.z)}div(t){return new Pe(this.x/t,this.y/t,this.z/t)}mean(t){return new Pe((this.x+t.x)/2,(this.y+t.y)/2,(this.z+t.z)/2)}neg(){return new Pe(-this.x,-this.y,-this.z)}}class di{constructor(t,e,n){this.tt=t,this.r=e,this.v=n}clone(){return new di(this.tt,this.r,this.v)}sub(t){return new di(this.tt,this.r.sub(t.r),this.v.sub(t.v))}}function ov(i){let[t,[e,n,s],[r,a,o]]=i;return new di(t,new Pe(e,n,s),new Pe(r,a,o))}function dr(i,t,e,n){const s=n/(n+Rl),r=al(An[e],t);return i.r.incr(r.r.mul(s)),i.v.incr(r.v.mul(s)),r}function gs(i,t,e){const n=e.sub(i),s=n.quadrature();return n.mul(t/(s*Math.sqrt(s)))}class na{constructor(t){let e=new di(t,new Pe(0,0,0),new Pe(0,0,0));this.Jupiter=dr(e,t,yt.Jupiter,$o),this.Saturn=dr(e,t,yt.Saturn,Jo),this.Uranus=dr(e,t,yt.Uranus,Qo),this.Neptune=dr(e,t,yt.Neptune,jo),this.Jupiter.r.decr(e.r),this.Jupiter.v.decr(e.v),this.Saturn.r.decr(e.r),this.Saturn.v.decr(e.v),this.Uranus.r.decr(e.r),this.Uranus.v.decr(e.v),this.Neptune.r.decr(e.r),this.Neptune.v.decr(e.v),this.Sun=new di(t,e.r.mul(-1),e.v.mul(-1))}Acceleration(t){let e=gs(t,Rl,this.Sun.r);return e.incr(gs(t,$o,this.Jupiter.r)),e.incr(gs(t,Jo,this.Saturn.r)),e.incr(gs(t,Qo,this.Uranus.r)),e.incr(gs(t,jo,this.Neptune.r)),e}}class ia{constructor(t,e,n,s){this.tt=t,this.r=e,this.v=n,this.a=s}clone(){return new ia(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class Xu{constructor(t,e){this.bary=t,this.grav=e}}function qr(i,t,e,n){return new Pe(t.x+i*(e.x+i*n.x/2),t.y+i*(e.y+i*n.y/2),t.z+i*(e.z+i*n.z/2))}function sh(i,t,e){return new Pe(t.x+i*e.x,t.y+i*e.y,t.z+i*e.z)}function ll(i,t){const e=i-t.tt,n=new na(i),s=qr(e,t.r,t.v,t.a),r=n.Acceleration(s).mean(t.a),a=qr(e,t.r,t.v,r),o=t.v.add(r.mul(e)),l=n.Acceleration(a),c=new ia(i,a,o,l);return new Xu(n,c)}const lv=[];function qu(i,t){const e=Math.floor(i);return e<0?0:e>=t?t-1:e}function cl(i){const t=ov(i),e=new na(t.tt),n=t.r.add(e.Sun.r),s=t.v.add(e.Sun.v),r=e.Acceleration(n),a=new ia(t.tt,n,s,r);return new Xu(e,a)}function cv(i,t){const e=oi[0][0];if(t<e||t>oi[ol-1][0])return null;const n=qu((t-e)/av,ol-1);if(!i[n]){const r=i[n]=[];r[0]=cl(oi[n]).grav,r[En-1]=cl(oi[n+1]).grav;let a,o=r[0].tt;for(a=1;a<En-1;++a)r[a]=ll(o+=Gi,r[a-1]).grav;o=r[En-1].tt;var s=[];for(s[En-1]=r[En-1],a=En-2;a>0;--a)s[a]=ll(o-=Gi,s[a+1]).grav;for(a=En-2;a>0;--a){const l=a/(En-1);r[a].r=r[a].r.mul(1-l).add(s[a].r.mul(l)),r[a].v=r[a].v.mul(1-l).add(s[a].v.mul(l)),r[a].a=r[a].a.mul(1-l).add(s[a].a.mul(l))}}return i[n]}function rh(i,t,e){let n=cl(i);const s=Math.ceil((t-n.grav.tt)/e);for(let r=0;r<s;++r)n=ll(r+1===s?t:n.grav.tt+e,n.grav);return n}function Yu(i,t){let e,n,s;const r=cv(lv,i.tt);if(r){const a=qu((i.tt-r[0].tt)/Gi,En-1),o=r[a],l=r[a+1],c=o.a.mean(l.a),h=qr(i.tt-o.tt,o.r,o.v,c),d=sh(i.tt-o.tt,o.v,c),u=qr(i.tt-l.tt,l.r,l.v,c),p=sh(i.tt-l.tt,l.v,c),_=(i.tt-o.tt)/Gi;e=h.mul(1-_).add(u.mul(_)),n=d.mul(1-_).add(p.mul(_))}else{let a;i.tt<oi[0][0]?a=rh(oi[0],i.tt,-Gi):a=rh(oi[ol-1],i.tt,+Gi),e=a.grav.r,n=a.grav.v,s=a.bary}return s||(s=new na(i.tt)),e=e.sub(s.Sun.r),n=n.sub(s.Sun.v),new qn(e.x,e.y,e.z,n.x,n.y,n.z,i)}function li(i,t){var e=je(t);if(i in An)return bs(An[i],e);if(i===yt.Pluto){const a=Yu(e);return new _e(a.x,a.y,a.z,e)}if(i===yt.Sun)return new _e(0,0,0,e);if(i===yt.Moon){var n=bs(An.Earth,e),s=ji(e);return new _e(n.x+s.x,n.y+s.y,n.z+s.z,e)}if(i===yt.EMB){const a=bs(An.Earth,e),o=ji(e),l=1+Fu;return new _e(a.x+o.x/l,a.y+o.y/l,a.z+o.z/l,e)}if(i===yt.SSB)return rv(e);const r=Cl(i);if(r){const a=new J1(r.dec,15*r.ra,r.dist);return yv(a,e)}throw`HelioVector: Unknown body "${i}"`}function hv(i,t){let e=t,n=0;for(let s=0;s<10;++s){const r=i(e),a=r.Length()/Lu;if(a>1)throw"Object is too distant for light-travel solver.";const o=t.AddDays(-a);if(n=Math.abs(o.tt-e.tt),n<1e-9)return r;e=o}throw`Light-travel time solver did not converge: dt = ${n}`}class uv{constructor(t,e,n,s){this.observerBody=t,this.targetBody=e,this.aberration=n,this.observerPos=s}Position(t){this.aberration&&(this.observerPos=li(this.observerBody,t));const e=li(this.targetBody,t);return new _e(e.x-this.observerPos.x,e.y-this.observerPos.y,e.z-this.observerPos.z,t)}}function dv(i,t,e,n){Vr(n);const s=je(i);if(Cl(e)){const o=li(e,s);if(n){const c=pv(t,s),h=new _e(o.x-c.x,o.y-c.y,o.z-c.z,s),d=Lu/h.Length();return new _e(h.x+c.vx/d,h.y+c.vy/d,h.z+c.vz/d,s)}const l=li(t,s);return new _e(o.x-l.x,o.y-l.y,o.z-l.z,s)}let r;n?r=new _e(0,0,0,s):r=li(t,s);const a=new uv(t,e,n,r);return hv(o=>a.Position(o),s)}function hl(i,t,e){Vr(e);const n=je(t);switch(i){case yt.Earth:return new _e(0,0,0,n);case yt.Moon:return ji(n);default:const s=dv(n,yt.Earth,i,e);return s.t=n,s}}function fv(i,t){return new qn(i.r.x,i.r.y,i.r.z,i.v.x,i.v.y,i.v.z,t)}function pv(i,t){const e=je(t);switch(i){case yt.Sun:return new qn(0,0,0,0,0,0,e);case yt.SSB:const n=new na(e.tt);return new qn(-n.Sun.r.x,-n.Sun.r.y,-n.Sun.r.z,-n.Sun.v.x,-n.Sun.v.y,-n.Sun.v.z,e);case yt.Mercury:case yt.Venus:case yt.Earth:case yt.Mars:case yt.Jupiter:case yt.Saturn:case yt.Uranus:case yt.Neptune:const s=al(An[i],e.tt);return fv(s,e);case yt.Pluto:return Yu(e);case yt.Moon:case yt.EMB:const r=al(An.Earth,e.tt),a=i==yt.Moon?Vu(e):sv(e);return new qn(a.x+r.r.x,a.y+r.r.y,a.z+r.r.z,a.vx+r.v.x,a.vy+r.v.y,a.vz+r.v.z,e);default:if(Cl(i)){const o=li(i,e);return new qn(o.x,o.y,o.z,0,0,0,e)}throw`HelioState: Unsupported body "${i}"`}}function mv(i){for(;i<0;)i+=360;for(;i>=360;)i-=360;return i}function gv(i,t,e){if(i===yt.Earth||t===yt.Earth)throw"The Earth does not have a longitude as seen from itself.";const n=je(e),s=hl(i,n,!1),r=el(s),a=hl(t,n,!1),o=el(a);return mv(r.elon-o.elon)}function _v(i,t,e,n){let s,r=0,a=0,o=0;switch(i){case yt.Mercury:s=-.6,r=4.98,a=-4.88,o=3.02;break;case yt.Venus:t<163.6?(s=-4.47,r=1.03,a=.57,o=.13):(s=.98,r=-1.02);break;case yt.Mars:s=-1.52,r=1.6;break;case yt.Jupiter:s=-9.4,r=.5;break;case yt.Uranus:s=-7.19,r=.25;break;case yt.Neptune:s=-6.87;break;case yt.Pluto:s=-1,r=4;break;default:throw`VisualMagnitude: unsupported body ${i}`}const l=t/100;let c=s+l*(r+l*(a+l*o));return c+=5*Math.log10(e*n),c}function vv(i,t,e,n,s){const r=el(n),a=ie*28.06,o=ie*(169.51+382e-7*s.tt),l=ie*r.elat,c=ie*r.elon,h=Math.asin(Math.sin(l)*Math.cos(a)-Math.cos(l)*Math.sin(a)*Math.sin(c-o)),d=Math.sin(Math.abs(h));let u=-9+.044*i;return u+=d*(-2.6+1.2*d),u+=5*Math.log10(t*e),{mag:u,ring_tilt:Zn*h}}function xv(i,t,e){let n=i*ie,s=n*n,r=s*s,a=-12.717+1.49*Math.abs(n)+.0431*r;const o=385000.6/si;let l=e/o;return a+=5*Math.log10(t*l),a}class Sv{constructor(t,e,n,s,r,a,o,l){this.time=t,this.mag=e,this.phase_angle=n,this.helio_dist=s,this.geo_dist=r,this.gc=a,this.hc=o,this.ring_tilt=l,this.phase_fraction=(1+Math.cos(ie*n))/2}}function Zu(i,t){if(i===yt.Earth)throw"The illumination of the Earth is not defined.";const e=je(t),n=bs(An.Earth,e);let s,r,a,o;i===yt.Sun?(a=new _e(-n.x,-n.y,-n.z,e),r=new _e(0,0,0,e),s=0):(i===yt.Moon?(a=ji(e),r=new _e(n.x+a.x,n.y+a.y,n.z+a.z,e)):(r=li(i,t),a=new _e(r.x-n.x,r.y-n.y,r.z-n.z,e)),s=F1(a,r));let l=a.Length(),c=r.Length(),h;if(i===yt.Sun)o=L1+5*Math.log10(l);else if(i===yt.Moon)o=xv(s,c,l);else if(i===yt.Saturn){const d=vv(s,c,l,a,e);o=d.mag,h=d.ring_tilt}else o=_v(i,s,c,l);return new Sv(e,o,s,c,l,a,r,h)}function Mv(i){return gv(yt.Moon,yt.Sun,i)}var ah;(function(i){i[i.Pericenter=0]="Pericenter",i[i.Apocenter=1]="Apocenter"})(ah||(ah={}));function yv(i,t){t=je(t);const e=i.lat*ie,n=i.lon*ie,s=i.dist*Math.cos(e);return new _e(s*Math.cos(n),s*Math.sin(n),i.dist*Math.sin(e),t)}function Ev(i,t){let e;if(be(t),t<-90||t>90)return 0;{let n=t;n<-1&&(n=-1),e=1.02/Math.tan((n+10.3/(n+5.11))*ie)/60,t<-1&&(e*=(t+90)/89)}return e}var oh;(function(i){i.Penumbral="penumbral",i.Partial="partial",i.Annular="annular",i.Total="total"})(oh||(oh={}));var lh;(function(i){i[i.Invalid=0]="Invalid",i[i.Ascending=1]="Ascending",i[i.Descending=-1]="Descending"})(lh||(lh={}));const bv=["Venus","Mars","Jupiter","Saturn"];function Ku(i){return new Gu(i.lat,i.lng,i.elevationM)}function Tv(i,t,e,n){const s=Hu(e,Ku(n),i,t,"normal");return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}function Ga(i,t,e){const n=Ku(e),s=nv(yt[i],t,n,!0,!0),r=Hu(t,n,s.ra,s.dec,"normal");return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}function Va(i,t){return Zu(yt[i],t).mag}function Av(i){const t=Mv(i),e=Zu(yt.Moon,i);return{phaseFraction:t/360,illuminatedFraction:e.phase_fraction}}const wv=2e3,Rv=3,Cv=20;function Pv(i,t){if(i.year===void 0&&i.month===void 0&&i.day===void 0&&i.hour===void 0)return;const e=i.year!==void 0,n=i.year??wv,s=i.month??(e?1:Rv),r=i.day??(e?1:Cv),a=Math.round(t/15);return new Date(Date.UTC(n,s-1,r,(i.hour??12)-a,i.minute??0,i.second??0))}const $u=Math.PI/180,Iv=180/Math.PI,Dv=256,Lv=19;function Uv(i,t){return 156543.03392*Math.cos(i*$u)/2**t}function Nv(i,t){return Uv(i,t)*Dv}function Ju(i,t){let e=0;for(;e<Lv&&Nv(i,e+1)>=t;)e++;return e}function Qu(i,t,e){const n=2**e,s=(i+180)/360*n,r=t*$u,a=(1-Math.log(Math.tan(r)+1/Math.cos(r))/Math.PI)/2*n;return{x:s,y:a}}function Fv(i,t,e){const{x:n,y:s}=Qu(i,t,e);return{x:Math.floor(n),y:Math.floor(s),z:e}}function Ov(i){const t=2**i.z,e=i.x/t*360-180,n=(i.x+1)/t*360-180,s=ch(i.y,t);return{south:ch(i.y+1,t),north:s,west:e,east:n}}function ch(i,t){const e=i/t;return Math.atan(Math.sinh(Math.PI*(1-2*e)))*Iv}function ju(i,t,e,n){const s=Fv(i,t,e),r=Math.floor(n/2),a=[];for(let c=-r;c<=r;c++)for(let h=-r;h<=r;h++)a.push({x:s.x+h,y:s.y+c,z:e});const o=a.map(Ov),l={south:Math.min(...o.map(c=>c.south)),north:Math.max(...o.map(c=>c.north)),west:Math.min(...o.map(c=>c.west)),east:Math.max(...o.map(c=>c.east))};return{tiles:a,bounds:l}}const td=Math.PI/180,Yr=111320;function ts(i,t,e,n){const s=Yr*Math.cos(e*td),r=(i-e)*Yr;return{x:(t-n)*s,z:-r}}function fr(i,t,e,n){const s=Yr*Math.cos(e*td),r=-t,a=i;return{lat:e+r/Yr,lng:n+a/s}}const qe=256,hh=3,Bv=32768;class zv{fetchImpl;tileUrlTemplate;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=t.tileUrlTemplate??"https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"}async getElevationGrid(t,e){const n=(t.south+t.north)/2,s=(t.west+t.east)/2,r=Math.abs(ts(n,t.east,n,t.west).x),a=Math.abs(ts(t.north,s,t.south,s).z),o=Ju(n,Math.max(r,a)),{tiles:l}=ju(s,n,o,hh),c=hh*qe,h=new Float32Array(c*c),d=l[0];await Promise.all(l.map(p=>this.decodeTileInto(p,d,h,c)));const u=new Float32Array(e.width*e.height);for(let p=0;p<e.height;p++){const _=t.north+(t.south-t.north)*(p/(e.height-1));for(let M=0;M<e.width;M++){const m=t.west+(t.east-t.west)*(M/(e.width-1));u[p*e.width+M]=this.sampleAt(_,m,o,d,h,c)}}return{heights:u,width:e.width,height:e.height,bounds:t}}async decodeTileInto(t,e,n,s){const r=this.tileUrlTemplate.replace("{z}",String(t.z)).replace("{x}",String(t.x)).replace("{y}",String(t.y)),a=await this.fetchImpl(r);if(!a.ok)throw new Error(`Elevation tile fetch failed (${a.status}): ${r}`);const o=await createImageBitmap(await a.blob()),l=document.createElement("canvas");l.width=qe,l.height=qe;const c=l.getContext("2d");if(!c)throw new Error("2D canvas context unavailable");c.drawImage(o,0,0);const{data:h}=c.getImageData(0,0,qe,qe),d=(t.x-e.x)*qe,u=(t.y-e.y)*qe;for(let p=0;p<qe;p++)for(let _=0;_<qe;_++){const M=(p*qe+_)*4,m=h[M]*256+h[M+1]+h[M+2]/256-Bv,f=d+_,A=u+p;n[A*s+f]=m}}sampleAt(t,e,n,s,r,a){const{x:o,y:l}=Qu(e,t,n),c=(o-s.x)*qe,h=(l-s.y)*qe,d=Math.max(0,Math.min(a-1,Math.floor(c))),u=Math.max(0,Math.min(a-1,Math.floor(h))),p=Math.min(a-1,d+1),_=Math.min(a-1,u+1),M=c-d,m=h-u,f=r[u*a+d],A=r[u*a+p],w=r[_*a+d],S=r[_*a+p],y=f+(A-f)*M,b=w+(S-w)*M;return y+(b-y)*m}}const Wa=256,uh=3;async function kv(i,t,e,n){const s=(i.south+i.north)/2,r=(i.west+i.east)/2,a=Math.abs(ts(s,i.east,s,i.west).x),o=Math.abs(ts(i.north,r,i.south,r).z),l=Ju(s,Math.max(a,o)),{tiles:c}=ju(r,s,l,uh),h=uh*Wa,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=c[0];await Promise.all(c.map(async m=>{const f=e(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)*Wa,(m.y-p.y)*Wa)}));const _=document.createElement("canvas");_.width=t.width,_.height=t.height;const M=_.getContext("2d");if(!M)throw new Error("2D canvas context unavailable");return M.drawImage(d,0,0,h,h,0,0,t.width,t.height),_}class Hv{attribution="Imagery © Esri, Maxar, Earthstar Geographics, and the GIS User Community";fetchImpl;tileUrlTemplate;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=t.tileUrlTemplate??"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"}async getImageryTexture(t,e){return{source:await kv(t,e,s=>this.tileUrlTemplate.replace("{z}",String(s.z)).replace("{y}",String(s.y)).replace("{x}",String(s.x)),this.fetchImpl),width:e.width,height:e.height}}}function Gv(){return{elevation:new zv,imagery:new Hv}}const ys=64,Ee=ys+1,dh=512,fh=700,ph=900,Vv=-.5,Wv=.01;function Xv(i,t,e){return{north:fr(0,-e,i,t).lat,south:fr(0,e,i,t).lat,east:fr(e,0,i,t).lng,west:fr(-e,0,i,t).lng}}async function qv(i,t,e){const n=Xv(i,t,ph),s={width:Ee,height:Ee},[r,a]=await Promise.all([e.elevation.getElevationGrid(n,s),e.imagery.getImageryTexture(n,{width:dh,height:dh})]),o=Math.floor(Ee/2),l=r.heights[o*Ee+o],c=new Float32Array(Ee*Ee*3),h=new Float32Array(Ee*Ee*2),d=new Float32Array(Ee*Ee*4);for(let A=0;A<Ee;A++){const w=A/(Ee-1),S=n.north+(n.south-n.north)*w;for(let y=0;y<Ee;y++){const b=y/(Ee-1),R=n.west+(n.east-n.west)*b,{x:v,z:T}=ts(S,R,i,t),I=r.heights[A*Ee+y],C=Vv+Wv+(I-l),U=A*Ee+y;c[U*3]=v,c[U*3+1]=C,c[U*3+2]=T,h[U*2]=b,h[U*2+1]=w;const Y=Math.max(Math.abs(v),Math.abs(T)),Z=1-Yv((Y-fh)/(ph-fh),0,1);d[U*4]=1,d[U*4+1]=1,d[U*4+2]=1,d[U*4+3]=Z}}const u=new Uint16Array(ys*ys*6);let p=0;for(let A=0;A<ys;A++)for(let w=0;w<ys;w++){const S=A*Ee+w,y=S+1,b=S+Ee,R=b+1;u[p++]=S,u[p++]=b,u[p++]=y,u[p++]=y,u[p++]=b,u[p++]=R}const _=new Te;_.setAttribute("position",new pe(c,3)),_.setAttribute("uv",new pe(h,2)),_.setAttribute("color",new pe(d,4)),_.setIndex(new pe(u,1));const M=new In(a.source);M.flipY=!1;const m=new qi({map:M,color:new It(1,1,1),vertexColors:!0,transparent:!0,fog:!0,depthTest:!1});return{mesh:new Ge(_,m),attribution:e.imagery.attribution}}function Yv(i,t,e){return Math.max(t,Math.min(e,i))}const Dl={cloudCover:0,cloudDarkness:0,precipitationType:"none",precipitationIntensity:0,windDirectionDeg:0,windSpeed:0,lightning:!1},Zv=18,Kv=.55,$v=.5,Jv=`
|
|
4464
|
+
*/const Pu=173.1446326846693,si=14959787069098932e-8,it=.017453292519943295,Jc=.26179938779914946,Yn=57.29577951308232,Iu=3.819718634205488,R1=365.24217,Qc=new Date("2000-01-01T12:00:00Z"),yn=2*Math.PI,Gn=3600*(180/Math.PI),ki=484813681109536e-20,Du=10800*60,C1=2*Du,jc=7292115e-11,P1=Du/Math.PI,I1=-.17-5*Math.log10(P1),Zo=.996647180302104,D1=Zo*Zo,Ko=6378.1366,L1=Ko/si,Lu=81.30056,Rl=.0002959122082855911,$o=2825345909524226e-22,Jo=8459715185680659e-23,Qo=1292024916781969e-23,jo=1524358900784276e-23;function Gr(i){if(i!==!0&&i!==!1)throw console.trace(),`Value is not boolean: ${i}`;return i}function bt(i){if(!Number.isFinite(i))throw console.trace(),`Value is not a finite number: ${i}`;return i}function Ui(i){return i-Math.floor(i)}function U1(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:Yn*Math.acos(s)}var ye;(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"})(ye||(ye={}));const N1=[ye.Star1,ye.Star2,ye.Star3,ye.Star4,ye.Star5,ye.Star6,ye.Star7,ye.Star8],F1=[{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 O1(i){const e=N1.indexOf(i);return e>=0?F1[e]:null}function Cl(i){const e=O1(i);return e&&e.dist>0?e:null}var Qt;(function(i){i[i.From2000=0]="From2000",i[i.Into2000=1]="Into2000"})(Qt||(Qt={}));const An={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 B1(i){var e,t,n,s,r,a,o;const l=2e3+(i-14)/R1;return l<-500?(e=(l-1820)/100,-20+32*e*e):l<500?(e=l/100,t=e*e,n=e*t,s=t*t,r=t*n,a=n*n,10583.6-1014.41*e+33.78311*t-5.952053*n-.1798452*s+.022174192*r+.0090316521*a):l<1600?(e=(l-1e3)/100,t=e*e,n=e*t,s=t*t,r=t*n,a=n*n,1574.2-556.01*e+71.23472*t+.319781*n-.8503463*s-.005050998*r+.0083572073*a):l<1700?(e=l-1600,t=e*e,n=e*t,120-.9808*e-.01532*t+n/7129):l<1800?(e=l-1700,t=e*e,n=e*t,s=t*t,8.83+.1603*e-.0059285*t+13336e-8*n-s/1174e3):l<1860?(e=l-1800,t=e*e,n=e*t,s=t*t,r=t*n,a=n*n,o=n*s,13.72-.332447*e+.0068612*t+.0041116*n-37436e-8*s+121272e-10*r-1699e-10*a+875e-12*o):l<1900?(e=l-1860,t=e*e,n=e*t,s=t*t,r=t*n,7.62+.5737*e-.251754*t+.01680668*n-.0004473624*s+r/233174):l<1920?(e=l-1900,t=e*e,n=e*t,s=t*t,-2.79+1.494119*e-.0598939*t+.0061966*n-197e-6*s):l<1941?(e=l-1920,t=e*e,n=e*t,21.2+.84493*e-.0761*t+.0020936*n):l<1961?(e=l-1950,t=e*e,n=e*t,29.07+.407*e-t/233+n/2547):l<1986?(e=l-1975,t=e*e,n=e*t,45.45+1.067*e-t/260-n/718):l<2005?(e=l-2e3,t=e*e,n=e*t,s=t*t,r=t*n,63.86+.3345*e-.060374*t+.0017275*n+651814e-9*s+2373599e-11*r):l<2050?(e=l-2e3,62.92+.32217*e+.005589*e*e):l<2150?(e=(l-1820)/100,-20+32*e*e-.5628*(2150-l)):(e=(l-1820)/100,-20+32*e*e)}let z1=B1;function eh(i){return i+z1(i)/86400}class qi{constructor(e){if(e instanceof qi){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()-Qc.getTime())/t,this.tt=eh(this.ut);return}if(Number.isFinite(e)){this.date=new Date(Qc.getTime()+e*t),this.ut=e,this.tt=eh(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 qi(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 qi(this.ut+e)}}function jt(i){return i instanceof qi?i:new qi(i)}function k1(i){function e(u){return u%C1*ki}const t=i.tt/36525,n=e(128710479305e-5+t*1295965810481e-4),s=e(335779.526232+t*17395272628478e-4),r=e(107226070369e-5+t*1602961601209e-3),a=e(450160.398036-t*69628905431e-4);let o=Math.sin(a),l=Math.cos(a),c=(-172064161-174666*t)*o+33386*l,h=(92052331+9086*t)*l+15377*o,d=2*(s-r+a);return o=Math.sin(d),l=Math.cos(d),c+=(-13170906-1675*t)*o-13696*l,h+=(5730336-3015*t)*l-4587*o,d=2*(s+a),o=Math.sin(d),l=Math.cos(d),c+=(-2276413-234*t)*o+2796*l,h+=(978459-485*t)*l+1374*o,d=2*a,o=Math.sin(d),l=Math.cos(d),c+=(2074554+207*t)*o-698*l,h+=(-897492+470*t)*l-291*o,o=Math.sin(n),l=Math.cos(n),c+=(1475877-3633*t)*o+11817*l,h+=(73871-184*t)*l-1924*o,{dpsi:-135e-6+c*1e-7,deps:388e-6+h*1e-7}}function Uu(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 cr;function Pl(i){if(!cr||Math.abs(cr.tt-i.tt)>1e-6){const e=k1(i),t=Uu(i),n=t+e.deps/3600;cr={tt:i.tt,dpsi:e.dpsi,deps:e.deps,ee:e.dpsi*Math.cos(t*it)/15,mobl:t,tobl:n}}return cr}function G1(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 H1(i,e){return G1(Uu(i),e)}function V1(i){const e=i.tt/36525;function t(we,xe){const Ne=[];let De;for(De=0;De<=xe-we;++De)Ne.push(0);return{min:we,array:Ne}}function n(we,xe,Ne,De){const Le=[];for(let Ke=0;Ke<=xe-we;++Ke)Le.push(t(Ne,De));return{min:we,array:Le}}function s(we,xe,Ne){const De=we.array[xe-we.min];return De.array[Ne-De.min]}function r(we,xe,Ne,De){const Le=we.array[xe-we.min];Le.array[Ne-Le.min]=De}let a,o,l,c,h,d,u,p,_,M,m,f,A,w,S,y,b,R,v,T,I,C,U,Y=n(-6,6,1,4),Z=n(-6,6,1,4);function O(we,xe){return s(Y,we,xe)}function W(we,xe){return s(Z,we,xe)}function V(we,xe,Ne){return r(Y,we,xe,Ne)}function Q(we,xe,Ne){return r(Z,we,xe,Ne)}function te(we,xe,Ne,De,Le){Le(we*Ne-xe*De,xe*Ne+we*De)}function ee(we){return Math.sin(yn*we)}u=e*e,_=0,U=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),K=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*K,v=2.94*se+.31*ge+14.27*Ve+9.34*st+1.12*We+.83*K,T=-6.4*se-1.89*K,I=.21*se+.31*ge+14.27*Ve-88.7*st-15.3*We+.24*K-1.86*re,C=R-T,p=-3332e-9*ee(.59734-5.37261*e)-539e-9*ee(.35498-5.37899*e)-64e-9*ee(.39943-5.37511*e),A=yn*Ui(.60643382+1336.85522467*e-313e-8*u)+R/Gn,w=yn*Ui(.37489701+1325.55240982*e+2565e-8*u)+v/Gn,S=yn*Ui(.99312619+99.99735956*e-44e-8*u)+T/Gn,y=yn*Ui(.25909118+1342.2278298*e-892e-8*u)+I/Gn,b=yn*Ui(.82736186+1236.85308708*e-397e-8*u)+C/Gn,h=1;h<=4;++h){switch(h){case 1:l=w,o=4,c=1.000002208;break;case 2:l=S,o=3,c=.997504612-.002495388*e;break;case 3:l=y,o=4,c=1.000002708+139.978*p;break;case 4:l=b,o=6,c=1;break;default:throw`Internal error: I = ${h}`}for(V(0,h,1),V(1,h,Math.cos(l)*c),Q(0,h,0),Q(1,h,Math.sin(l)*c),d=2;d<=o;++d)te(O(d-1,h),W(d-1,h),O(1,h),W(1,h),(we,xe)=>(V(d,h,we),Q(d,h,xe)));for(d=1;d<=o;++d)V(-d,h,O(d,h)),Q(-d,h,-W(d,h))}function ne(we,xe,Ne,De){for(var Le={x:1,y:0},Ke=[0,we,xe,Ne,De],$e=1;$e<=4;++$e)Ke[$e]!==0&&te(Le.x,Le.y,O(Ke[$e],$e),W(Ke[$e],$e),(ct,ot)=>(Le.x=ct,Le.y=ot));return Le}function k(we,xe,Ne,De,Le,Ke,$e,ct){var ot=ne(Le,Ke,$e,ct);_+=we*ot.y,U+=xe*ot.y,m+=Ne*ot.x,f+=De*ot.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(we,xe,Ne,De,Le){return we*ne(xe,Ne,De,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),_+=.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+U/Gn;let Ie=(1.000002708+139.978*p)*(18518.511+1.189+m)*Math.sin(a)-6.24*Math.sin(3*a)+M;return{geo_eclip_lon:yn*Ui((A+_/Gn)/yn),geo_eclip_lat:Math.PI/(180*3600)*Ie,distance_au:Gn*L1/(.999953253*f)}}function Nu(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 Hr(i,e,t){const n=W1(e,t);return Nu(n,i)}function W1(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*=ki,s*=ki,r*=ki,a*=ki;const o=Math.sin(n),l=Math.cos(n),c=Math.sin(-s),h=Math.cos(-s),d=Math.sin(-r),u=Math.cos(-r),p=Math.sin(a),_=Math.cos(a),M=_*h-c*p*u,m=_*c*l+p*u*h*l-o*p*d,f=_*c*o+p*u*h*o+l*p*d,A=-p*h-c*_*u,w=-p*c*l+_*u*h*l-o*_*d,S=-p*c*o+_*u*h*o+l*_*d,y=c*d,b=-d*h*l-o*u,R=-d*h*o+u*l;if(e===Qt.Into2000)return new Vr([[M,m,f],[A,w,S],[y,b,R]]);if(e===Qt.From2000)return new Vr([[M,A,y],[m,w,b],[f,S,R]]);throw"Invalid precess direction"}function X1(i){const e=.779057273264+.00273781191135448*i.ut,t=i.ut%1;let n=360*((e+t)%1);return n<0&&(n+=360),n}let hr;function Fu(i){if(!hr||hr.tt!==i.tt){const e=i.tt/36525;let t=15*Pl(i).ee;const n=X1(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),hr={tt:i.tt,st:r}}return hr.st}function q1(i,e){const t=i.latitude*it,n=Math.sin(t),s=Math.cos(t),r=1/Math.hypot(s,Zo*n),a=D1*r,o=i.height/1e3,l=Ko*r+o,c=Ko*a+o,h=(15*e+i.longitude)*it,d=Math.sin(h),u=Math.cos(h);return{pos:[l*s*u/si,l*s*d/si,c*n/si],vel:[-jc*l*s*d*86400/si,jc*l*s*u*86400/si,0]}}function el(i,e,t){const n=Y1(e,t);return Nu(n,i)}function Y1(i,e){const t=Pl(i),n=t.mobl*it,s=t.tobl*it,r=t.dpsi*ki,a=Math.cos(n),o=Math.sin(n),l=Math.cos(s),c=Math.sin(s),h=Math.cos(r),d=Math.sin(r),u=h,p=-d*a,_=-d*o,M=d*l,m=h*a*l+o*c,f=h*o*l-a*c,A=d*c,w=h*a*c-o*l,S=h*o*c+a*l;if(e===Qt.From2000)return new Vr([[u,M,A],[p,m,w],[_,f,S]]);if(e===Qt.Into2000)return new Vr([[u,p,_],[M,m,f],[A,w,S]]);throw"Invalid precess direction"}function Ou(i,e,t){return t===Qt.Into2000?Hr(el(i,e,t),e,t):el(Hr(i,e,t),e,t)}function Z1(i,e){const t=Fu(i),n=q1(e,t).pos;return Ou(n,i,Qt.Into2000)}class _t{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 Xn{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 K1{constructor(e,t,n){this.lat=bt(e),this.lon=bt(t),this.dist=bt(n)}}class th{constructor(e,t,n,s){this.ra=bt(e),this.dec=bt(t),this.dist=bt(n),this.vec=s}}class Vr{constructor(e){this.rot=e}}class $1{constructor(e,t,n,s){this.azimuth=bt(e),this.altitude=bt(t),this.ra=bt(n),this.dec=bt(s)}}class J1{constructor(e,t,n){this.vec=e,this.elat=bt(t),this.elon=bt(n)}}function Q1(i,e){return new _t(i[0],i[1],i[2],e)}function j1(i,e){const t=Q1(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 th(0,t.z<0?-90:90,s,t)}let r=Iu*Math.atan2(t.y,t.x);r<0&&(r+=24);const a=Yn*Math.atan2(i[2],Math.sqrt(n));return new th(r,a,s,t)}function za(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 Bu(i,e,t,n,s){let r=jt(i);Il(e),bt(t),bt(n);const a=Math.sin(e.latitude*it),o=Math.cos(e.latitude*it),l=Math.sin(e.longitude*it),c=Math.cos(e.longitude*it),h=Math.sin(n*it),d=Math.cos(n*it),u=Math.sin(t*Jc),p=Math.cos(t*Jc);let _=[o*c,o*l,a],M=[-a*c,-a*l,o],m=[l,-c,0];const f=-15*Fu(r);let A=za(f,_),w=za(f,M),S=za(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]*S[0]+y[1]*S[1]+y[2]*S[2];let T=Math.hypot(R,v),I;T>0?(I=-Yn*Math.atan2(v,R),I<0&&(I+=360)):I=0;let C=Yn*Math.atan2(T,b),U=t,Y=n;{let Z=C,O=Mv(s,90-C);if(C-=O,O>0&&C>3e-4){const W=Math.sin(C*it),V=Math.cos(C*it),Q=Math.sin(Z*it),te=Math.cos(Z*it),ee=[];for(let se=0;se<3;++se)ee.push((y[se]-te*A[se])/Q*W+A[se]*V);T=Math.hypot(ee[0],ee[1]),T>0?(U=Iu*Math.atan2(ee[1],ee[0]),U<0&&(U+=24)):U=0,Y=Yn*Math.atan2(ee[2],T)}}return new $1(I,90-C,U,Y)}function Il(i){if(!(i instanceof zu))throw`Not an instance of the Observer class: ${i}`;if(bt(i.latitude),bt(i.longitude),bt(i.height),i.latitude<-90||i.latitude>90)throw`Latitude ${i.latitude} is out of range. Must be -90..+90.`;return i}class zu{constructor(e,t,n){this.latitude=e,this.longitude=t,this.height=n,Il(this)}}function ev(i,e,t,n,s){Il(t),Gr(n),Gr(s);const r=jt(e),a=Z1(r,t),o=hl(i,r,s),l=[o.x-a[0],o.y-a[1],o.z-a[2]],c=Ou(l,r,Qt.From2000);return j1(c,r)}function tv(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=Yn*Math.atan2(s,n),o<0&&(o+=360));let l=Yn*Math.atan2(r,a),c=new _t(n,s,r,i.t);return new J1(c,l,o)}function tl(i){const e=Pl(i.t),t=[i.x,i.y,i.z],n=Hr(t,i.t,Qt.From2000),[s,r,a]=el(n,i.t,Qt.From2000),o=new _t(s,r,a,i.t),l=e.tobl*it;return tv(o,Math.cos(l),Math.sin(l))}function Qi(i){const e=jt(i),t=V1(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=H1(e,s),a=Hr(r,e,Qt.Into2000);return new _t(a[0],a[1],a[2],e)}function ku(i){const e=jt(i),t=1e-5,n=e.AddDays(-t),s=e.AddDays(+t),r=Qi(n),a=Qi(s);return new Xn((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 nv(i){const e=jt(i),t=ku(e),n=1+Lu;return new Xn(t.x/n,t.y/n,t.z/n,t.vx/n,t.vy/n,t.vz/n,e)}function Yi(i,e,t){let n=1,s=0;for(let r of i){let a=0;for(let[l,c,h]of r)a+=l*Math.cos(c+e*h);let o=n*a;t&&(o%=yn),s+=o,n*=e}return s}function ka(i,e){let t=1,n=0,s=0,r=0;for(let a of i){let o=0,l=0;for(let[c,h,d]of a){let u=h+e*d;o+=c*d*Math.sin(u),r>0&&(l+=c*Math.cos(u))}s+=r*n*l-t*o,n=t,t*=e,++r}return s}const Ss=365250,nl=0,il=1,sl=2;function rl(i){return new Pt(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 Gu(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 ys(i,e){const t=e.tt/Ss,n=Yi(i[nl],t,!0),s=Yi(i[il],t,!1),r=Yi(i[sl],t,!1),a=Gu(n,s,r);return rl(a).ToAstroVector(e)}function al(i,e){const t=e/Ss,n=Yi(i[nl],t,!0),s=Yi(i[il],t,!1),r=Yi(i[sl],t,!1),a=ka(i[nl],t),o=ka(i[il],t),l=ka(i[sl],t),c=Math.cos(n),h=Math.sin(n),d=Math.cos(s),u=Math.sin(s),p=+(l*d*c)-r*u*c*o-r*d*h*a,_=+(l*d*h)-r*u*h*o+r*d*c*a,M=+(l*u)+r*d*o,m=Gu(n,s,r),f=[p/Ss,_/Ss,M/Ss],A=rl(m),w=rl(f);return new di(e,A,w)}function ur(i,e,t,n){const s=n/(n+Rl),r=ys(An[t],e);i.x+=s*r.x,i.y+=s*r.y,i.z+=s*r.z}function iv(i){const e=new _t(0,0,0,i);return ur(e,i,ye.Jupiter,$o),ur(e,i,ye.Saturn,Jo),ur(e,i,ye.Uranus,Qo),ur(e,i,ye.Neptune,jo),e}const ol=51,sv=29200,Gi=146,En=201,oi=[[-73e4,[-26.118207232108,-14.376168177825,3.384402515299],[.0016339372163656,-.0027861699588508,-.0013585880229445]],[-700800,[41.974905202127,-.448502952929,-12.770351505989],[.00073458569351457,.0022785014891658,.00048619778602049]],[-671600,[14.706930780744,44.269110540027,9.353698474772],[-.00210001479998,.00022295915939915,.00070143443551414]],[-642400,[-29.441003929957,-6.43016153057,6.858481011305],[.00084495803960544,-.0030783914758711,-.0012106305981192]],[-613200,[39.444396946234,-6.557989760571,-13.913760296463],[.0011480029005873,.0022400006880665,.00035168075922288]],[-584e3,[20.2303809507,43.266966657189,7.382966091923],[-.0019754081700585,.00053457141292226,.00075929169129793]],[-554800,[-30.65832536462,2.093818874552,9.880531138071],[61010603013347e-18,-.0031326500935382,-.00099346125151067]],[-525600,[35.737703251673,-12.587706024764,-14.677847247563],[.0015802939375649,.0021347678412429,.00019074436384343]],[-496400,[25.466295188546,41.367478338417,5.216476873382],[-.0018054401046468,.0008328308359951,.00080260156912107]],[-467200,[-29.847174904071,10.636426313081,12.297904180106],[-.00063257063052907,-.0029969577578221,-.00074476074151596]],[-438e3,[30.774692107687,-18.236637015304,-14.945535879896],[.0020113162005465,.0019353827024189,-20937793168297e-19]],[-408800,[30.243153324028,38.656267888503,2.938501750218],[-.0016052508674468,.0011183495337525,.00083333973416824]],[-379600,[-27.288984772533,18.643162147874,14.023633623329],[-.0011856388898191,-.0027170609282181,-.00049015526126399]],[-350400,[24.519605196774,-23.245756064727,-14.626862367368],[.0024322321483154,.0016062008146048,-.00023369181613312]],[-321200,[34.505274805875,35.125338586954,.557361475637],[-.0013824391637782,.0013833397561817,.00084823598806262]],[-292e3,[-23.275363915119,25.818514298769,15.055381588598],[-.0016062295460975,-.0023395961498533,-.00024377362639479]],[-262800,[17.050384798092,-27.180376290126,-13.608963321694],[.0028175521080578,.0011358749093955,-.00049548725258825]],[-233600,[38.093671910285,30.880588383337,-1.843688067413],[-.0011317697153459,.0016128814698472,.00084177586176055]],[-204400,[-18.197852930878,31.932869934309,15.438294826279],[-.0019117272501813,-.0019146495909842,-19657304369835e-18]],[-175200,[8.528924039997,-29.618422200048,-11.805400994258],[.0031034370787005,.0005139363329243,-.00077293066202546]],[-146e3,[40.94685725864,25.904973592021,-4.256336240499],[-.00083652705194051,.0018129497136404,.0008156422827306]],[-116800,[-12.326958895325,36.881883446292,15.217158258711],[-.0021166103705038,-.001481442003599,.00017401209844705]],[-87600,[-.633258375909,-30.018759794709,-9.17193287495],[.0032016994581737,-.00025279858672148,-.0010411088271861]],[-58400,[42.936048423883,20.344685584452,-6.588027007912],[-.00050525450073192,.0019910074335507,.00077440196540269]],[-29200,[-5.975910552974,40.61180995846,14.470131723673],[-.0022184202156107,-.0010562361130164,.00033652250216211]],[0,[-9.875369580774,-27.978926224737,-5.753711824704],[.0030287533248818,-.0011276087003636,-.0012651326732361]],[29200,[43.958831986165,14.214147973292,-8.808306227163],[-.00014717608981871,.0021404187242141,.00071486567806614]],[58400,[.67813676352,43.094461639362,13.243238780721],[-.0022358226110718,-.00063233636090933,.00047664798895648]],[87600,[-18.282602096834,-23.30503958666,-1.766620508028],[.0025567245263557,-.0019902940754171,-.0013943491701082]],[116800,[43.873338744526,7.700705617215,-10.814273666425],[.00023174803055677,.0022402163127924,.00062988756452032]],[146e3,[7.392949027906,44.382678951534,11.629500214854],[-.002193281545383,-.00021751799585364,.00059556516201114]],[175200,[-24.981690229261,-16.204012851426,2.466457544298],[.001819398914958,-.0026765419531201,-.0013848283502247]],[204400,[42.530187039511,.845935508021,-12.554907527683],[.00065059779150669,.0022725657282262,.00051133743202822]],[233600,[13.999526486822,44.462363044894,9.669418486465],[-.0021079296569252,.00017533423831993,.00069128485798076]],[262800,[-29.184024803031,-7.371243995762,6.493275957928],[.00093581363109681,-.0030610357109184,-.0012364201089345]],[292e3,[39.831980671753,-6.078405766765,-13.909815358656],[.0011117769689167,.0022362097830152,.00036230548231153]],[321200,[20.294955108476,43.417190420251,7.450091985932],[-.0019742157451535,.00053102050468554,.00075938408813008]],[350400,[-30.66999230216,2.318743558955,9.973480913858],[45605107450676e-18,-.0031308219926928,-.00099066533301924]],[379600,[35.626122155983,-12.897647509224,-14.777586508444],[.0016015684949743,.0021171931182284,.00018002516202204]],[408800,[26.133186148561,41.232139187599,5.00640132622],[-.0017857704419579,.00086046232702817,.00080614690298954]],[438e3,[-29.57674022923,11.863535943587,12.631323039872],[-.00072292830060955,-.0029587820140709,-.000708242964503]],[467200,[29.910805787391,-19.159019294,-15.013363865194],[.0020871080437997,.0018848372554514,-38528655083926e-18]],[496400,[31.375957451819,38.050372720763,2.433138343754],[-.0015546055556611,.0011699815465629,.00083565439266001]],[525600,[-26.360071336928,20.662505904952,14.414696258958],[-.0013142373118349,-.0026236647854842,-.00042542017598193]],[554800,[22.599441488648,-24.508879898306,-14.484045731468],[.0025454108304806,.0014917058755191,-.00030243665086079]],[584e3,[35.877864013014,33.894226366071,-.224524636277],[-.0012941245730845,.0014560427668319,.00084762160640137]],[613200,[-21.538149762417,28.204068269761,15.321973799534],[-.001731211740901,-.0021939631314577,-.0001631691327518]],[642400,[13.971521374415,-28.339941764789,-13.083792871886],[.0029334630526035,.00091860931752944,-.00059939422488627]],[671600,[39.526942044143,28.93989736011,-2.872799527539],[-.0010068481658095,.001702113288809,.00083578230511981]],[700800,[-15.576200701394,34.399412961275,15.466033737854],[-.0020098814612884,-.0017191109825989,70414782780416e-18]],[73e4,[4.24325283709,-30.118201690825,-10.707441231349],[.0031725847067411,.0001609846120227,-.00090672150593868]]];class Pt{constructor(e,t,n){this.x=e,this.y=t,this.z=n}clone(){return new Pt(this.x,this.y,this.z)}ToAstroVector(e){return new _t(this.x,this.y,this.z,e)}static zero(){return new Pt(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(e){return new Pt(this.x+e.x,this.y+e.y,this.z+e.z)}sub(e){return new Pt(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 Pt(e*this.x,e*this.y,e*this.z)}div(e){return new Pt(this.x/e,this.y/e,this.z/e)}mean(e){return new Pt((this.x+e.x)/2,(this.y+e.y)/2,(this.z+e.z)/2)}neg(){return new Pt(-this.x,-this.y,-this.z)}}class di{constructor(e,t,n){this.tt=e,this.r=t,this.v=n}clone(){return new di(this.tt,this.r,this.v)}sub(e){return new di(this.tt,this.r.sub(e.r),this.v.sub(e.v))}}function rv(i){let[e,[t,n,s],[r,a,o]]=i;return new di(e,new Pt(t,n,s),new Pt(r,a,o))}function dr(i,e,t,n){const s=n/(n+Rl),r=al(An[t],e);return i.r.incr(r.r.mul(s)),i.v.incr(r.v.mul(s)),r}function ps(i,e,t){const n=t.sub(i),s=n.quadrature();return n.mul(e/(s*Math.sqrt(s)))}class ea{constructor(e){let t=new di(e,new Pt(0,0,0),new Pt(0,0,0));this.Jupiter=dr(t,e,ye.Jupiter,$o),this.Saturn=dr(t,e,ye.Saturn,Jo),this.Uranus=dr(t,e,ye.Uranus,Qo),this.Neptune=dr(t,e,ye.Neptune,jo),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 di(e,t.r.mul(-1),t.v.mul(-1))}Acceleration(e){let t=ps(e,Rl,this.Sun.r);return t.incr(ps(e,$o,this.Jupiter.r)),t.incr(ps(e,Jo,this.Saturn.r)),t.incr(ps(e,Qo,this.Uranus.r)),t.incr(ps(e,jo,this.Neptune.r)),t}}class ta{constructor(e,t,n,s){this.tt=e,this.r=t,this.v=n,this.a=s}clone(){return new ta(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class Hu{constructor(e,t){this.bary=e,this.grav=t}}function Wr(i,e,t,n){return new Pt(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 nh(i,e,t){return new Pt(e.x+i*t.x,e.y+i*t.y,e.z+i*t.z)}function ll(i,e){const t=i-e.tt,n=new ea(i),s=Wr(t,e.r,e.v,e.a),r=n.Acceleration(s).mean(e.a),a=Wr(t,e.r,e.v,r),o=e.v.add(r.mul(t)),l=n.Acceleration(a),c=new ta(i,a,o,l);return new Hu(n,c)}const av=[];function Vu(i,e){const t=Math.floor(i);return t<0?0:t>=e?e-1:t}function cl(i){const e=rv(i),t=new ea(e.tt),n=e.r.add(t.Sun.r),s=e.v.add(t.Sun.v),r=t.Acceleration(n),a=new ta(e.tt,n,s,r);return new Hu(t,a)}function ov(i,e){const t=oi[0][0];if(e<t||e>oi[ol-1][0])return null;const n=Vu((e-t)/sv,ol-1);if(!i[n]){const r=i[n]=[];r[0]=cl(oi[n]).grav,r[En-1]=cl(oi[n+1]).grav;let a,o=r[0].tt;for(a=1;a<En-1;++a)r[a]=ll(o+=Gi,r[a-1]).grav;o=r[En-1].tt;var s=[];for(s[En-1]=r[En-1],a=En-2;a>0;--a)s[a]=ll(o-=Gi,s[a+1]).grav;for(a=En-2;a>0;--a){const l=a/(En-1);r[a].r=r[a].r.mul(1-l).add(s[a].r.mul(l)),r[a].v=r[a].v.mul(1-l).add(s[a].v.mul(l)),r[a].a=r[a].a.mul(1-l).add(s[a].a.mul(l))}}return i[n]}function ih(i,e,t){let n=cl(i);const s=Math.ceil((e-n.grav.tt)/t);for(let r=0;r<s;++r)n=ll(r+1===s?e:n.grav.tt+t,n.grav);return n}function Wu(i,e){let t,n,s;const r=ov(av,i.tt);if(r){const a=Vu((i.tt-r[0].tt)/Gi,En-1),o=r[a],l=r[a+1],c=o.a.mean(l.a),h=Wr(i.tt-o.tt,o.r,o.v,c),d=nh(i.tt-o.tt,o.v,c),u=Wr(i.tt-l.tt,l.r,l.v,c),p=nh(i.tt-l.tt,l.v,c),_=(i.tt-o.tt)/Gi;t=h.mul(1-_).add(u.mul(_)),n=d.mul(1-_).add(p.mul(_))}else{let a;i.tt<oi[0][0]?a=ih(oi[0],i.tt,-Gi):a=ih(oi[ol-1],i.tt,+Gi),t=a.grav.r,n=a.grav.v,s=a.bary}return s||(s=new ea(i.tt)),t=t.sub(s.Sun.r),n=n.sub(s.Sun.v),new Xn(t.x,t.y,t.z,n.x,n.y,n.z,i)}function li(i,e){var t=jt(e);if(i in An)return ys(An[i],t);if(i===ye.Pluto){const a=Wu(t);return new _t(a.x,a.y,a.z,t)}if(i===ye.Sun)return new _t(0,0,0,t);if(i===ye.Moon){var n=ys(An.Earth,t),s=Qi(t);return new _t(n.x+s.x,n.y+s.y,n.z+s.z,t)}if(i===ye.EMB){const a=ys(An.Earth,t),o=Qi(t),l=1+Lu;return new _t(a.x+o.x/l,a.y+o.y/l,a.z+o.z/l,t)}if(i===ye.SSB)return iv(t);const r=Cl(i);if(r){const a=new K1(r.dec,15*r.ra,r.dist);return Sv(a,t)}throw`HelioVector: Unknown body "${i}"`}function lv(i,e){let t=e,n=0;for(let s=0;s<10;++s){const r=i(t),a=r.Length()/Pu;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 cv{constructor(e,t,n,s){this.observerBody=e,this.targetBody=t,this.aberration=n,this.observerPos=s}Position(e){this.aberration&&(this.observerPos=li(this.observerBody,e));const t=li(this.targetBody,e);return new _t(t.x-this.observerPos.x,t.y-this.observerPos.y,t.z-this.observerPos.z,e)}}function hv(i,e,t,n){Gr(n);const s=jt(i);if(Cl(t)){const o=li(t,s);if(n){const c=dv(e,s),h=new _t(o.x-c.x,o.y-c.y,o.z-c.z,s),d=Pu/h.Length();return new _t(h.x+c.vx/d,h.y+c.vy/d,h.z+c.vz/d,s)}const l=li(e,s);return new _t(o.x-l.x,o.y-l.y,o.z-l.z,s)}let r;n?r=new _t(0,0,0,s):r=li(e,s);const a=new cv(e,t,n,r);return lv(o=>a.Position(o),s)}function hl(i,e,t){Gr(t);const n=jt(e);switch(i){case ye.Earth:return new _t(0,0,0,n);case ye.Moon:return Qi(n);default:const s=hv(n,ye.Earth,i,t);return s.t=n,s}}function uv(i,e){return new Xn(i.r.x,i.r.y,i.r.z,i.v.x,i.v.y,i.v.z,e)}function dv(i,e){const t=jt(e);switch(i){case ye.Sun:return new Xn(0,0,0,0,0,0,t);case ye.SSB:const n=new ea(t.tt);return new Xn(-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 ye.Mercury:case ye.Venus:case ye.Earth:case ye.Mars:case ye.Jupiter:case ye.Saturn:case ye.Uranus:case ye.Neptune:const s=al(An[i],t.tt);return uv(s,t);case ye.Pluto:return Wu(t);case ye.Moon:case ye.EMB:const r=al(An.Earth,t.tt),a=i==ye.Moon?ku(t):nv(t);return new Xn(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(Cl(i)){const o=li(i,t);return new Xn(o.x,o.y,o.z,0,0,0,t)}throw`HelioState: Unsupported body "${i}"`}}function fv(i){for(;i<0;)i+=360;for(;i>=360;)i-=360;return i}function pv(i,e,t){if(i===ye.Earth||e===ye.Earth)throw"The Earth does not have a longitude as seen from itself.";const n=jt(t),s=hl(i,n,!1),r=tl(s),a=hl(e,n,!1),o=tl(a);return fv(r.elon-o.elon)}function mv(i,e,t,n){let s,r=0,a=0,o=0;switch(i){case ye.Mercury:s=-.6,r=4.98,a=-4.88,o=3.02;break;case ye.Venus:e<163.6?(s=-4.47,r=1.03,a=.57,o=.13):(s=.98,r=-1.02);break;case ye.Mars:s=-1.52,r=1.6;break;case ye.Jupiter:s=-9.4,r=.5;break;case ye.Uranus:s=-7.19,r=.25;break;case ye.Neptune:s=-6.87;break;case ye.Pluto:s=-1,r=4;break;default:throw`VisualMagnitude: unsupported body ${i}`}const l=e/100;let c=s+l*(r+l*(a+l*o));return c+=5*Math.log10(t*n),c}function gv(i,e,t,n,s){const r=tl(n),a=it*28.06,o=it*(169.51+382e-7*s.tt),l=it*r.elat,c=it*r.elon,h=Math.asin(Math.sin(l)*Math.cos(a)-Math.cos(l)*Math.sin(a)*Math.sin(c-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:Yn*h}}function _v(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/si;let l=t/o;return a+=5*Math.log10(e*l),a}class vv{constructor(e,t,n,s,r,a,o,l){this.time=e,this.mag=t,this.phase_angle=n,this.helio_dist=s,this.geo_dist=r,this.gc=a,this.hc=o,this.ring_tilt=l,this.phase_fraction=(1+Math.cos(it*n))/2}}function Xu(i,e){if(i===ye.Earth)throw"The illumination of the Earth is not defined.";const t=jt(e),n=ys(An.Earth,t);let s,r,a,o;i===ye.Sun?(a=new _t(-n.x,-n.y,-n.z,t),r=new _t(0,0,0,t),s=0):(i===ye.Moon?(a=Qi(t),r=new _t(n.x+a.x,n.y+a.y,n.z+a.z,t)):(r=li(i,e),a=new _t(r.x-n.x,r.y-n.y,r.z-n.z,t)),s=U1(a,r));let l=a.Length(),c=r.Length(),h;if(i===ye.Sun)o=I1+5*Math.log10(l);else if(i===ye.Moon)o=_v(s,c,l);else if(i===ye.Saturn){const d=gv(s,c,l,a,t);o=d.mag,h=d.ring_tilt}else o=mv(i,s,c,l);return new vv(t,o,s,c,l,a,r,h)}function xv(i){return pv(ye.Moon,ye.Sun,i)}var sh;(function(i){i[i.Pericenter=0]="Pericenter",i[i.Apocenter=1]="Apocenter"})(sh||(sh={}));function Sv(i,e){e=jt(e);const t=i.lat*it,n=i.lon*it,s=i.dist*Math.cos(t);return new _t(s*Math.cos(n),s*Math.sin(n),i.dist*Math.sin(t),e)}function Mv(i,e){let t;if(bt(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 rh;(function(i){i.Penumbral="penumbral",i.Partial="partial",i.Annular="annular",i.Total="total"})(rh||(rh={}));var ah;(function(i){i[i.Invalid=0]="Invalid",i[i.Ascending=1]="Ascending",i[i.Descending=-1]="Descending"})(ah||(ah={}));const yv=["Venus","Mars","Jupiter","Saturn"];function qu(i){return new zu(i.lat,i.lng,i.elevationM)}function Ev(i,e,t,n){const s=Bu(t,qu(n),i,e,"normal");return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}function Ga(i,e,t){const n=qu(t),s=ev(ye[i],e,n,!0,!0),r=Bu(e,n,s.ra,s.dec,"normal");return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}function Ha(i,e){return Xu(ye[i],e).mag}function bv(i){const e=xv(i),t=Xu(ye.Moon,i);return{phaseFraction:e/360,illuminatedFraction:t.phase_fraction}}const Tv=2e3,Av=3,wv=20;function Rv(i,e){if(i.year===void 0&&i.month===void 0&&i.day===void 0&&i.hour===void 0)return;const t=i.year!==void 0,n=i.year??Tv,s=i.month??(t?1:Av),r=i.day??(t?1:wv),a=Math.round(e/15);return new Date(Date.UTC(n,s-1,r,(i.hour??12)-a,i.minute??0,i.second??0))}const Yu=Math.PI/180,Cv=180/Math.PI,Pv=256,Iv=19;function Dv(i,e){return 156543.03392*Math.cos(i*Yu)/2**e}function Lv(i,e){return Dv(i,e)*Pv}function Zu(i,e){let t=0;for(;t<Iv&&Lv(i,t+1)>=e;)t++;return t}function Ku(i,e,t){const n=2**t,s=(i+180)/360*n,r=e*Yu,a=(1-Math.log(Math.tan(r)+1/Math.cos(r))/Math.PI)/2*n;return{x:s,y:a}}function Uv(i,e,t){const{x:n,y:s}=Ku(i,e,t);return{x:Math.floor(n),y:Math.floor(s),z:t}}function Nv(i){const e=2**i.z,t=i.x/e*360-180,n=(i.x+1)/e*360-180,s=oh(i.y,e);return{south:oh(i.y+1,e),north:s,west:t,east:n}}function oh(i,e){const t=i/e;return Math.atan(Math.sinh(Math.PI*(1-2*t)))*Cv}function $u(i,e,t,n){const s=Uv(i,e,t),r=Math.floor(n/2),a=[];for(let c=-r;c<=r;c++)for(let h=-r;h<=r;h++)a.push({x:s.x+h,y:s.y+c,z:t});const o=a.map(Nv),l={south:Math.min(...o.map(c=>c.south)),north:Math.max(...o.map(c=>c.north)),west:Math.min(...o.map(c=>c.west)),east:Math.max(...o.map(c=>c.east))};return{tiles:a,bounds:l}}const Ju=Math.PI/180,Xr=111320;function ji(i,e,t,n){const s=Xr*Math.cos(t*Ju),r=(i-t)*Xr;return{x:(e-n)*s,z:-r}}function fr(i,e,t,n){const s=Xr*Math.cos(t*Ju),r=-e,a=i;return{lat:t+r/Xr,lng:n+a/s}}const qt=256,lh=3,Fv=32768;class Ov{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(ji(n,e.east,n,e.west).x),a=Math.abs(ji(e.north,s,e.south,s).z),o=Zu(n,Math.max(r,a)),{tiles:l}=$u(s,n,o,lh),c=lh*qt,h=new Float32Array(c*c),d=l[0];await Promise.all(l.map(p=>this.decodeTileInto(p,d,h,c)));const u=new Float32Array(t.width*t.height);for(let p=0;p<t.height;p++){const _=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(_,m,o,d,h,c)}}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()),l=document.createElement("canvas");l.width=qt,l.height=qt;const c=l.getContext("2d");if(!c)throw new Error("2D canvas context unavailable");c.drawImage(o,0,0);const{data:h}=c.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 _=0;_<qt;_++){const M=(p*qt+_)*4,m=h[M]*256+h[M+1]+h[M+2]/256-Fv,f=d+_,A=u+p;n[A*s+f]=m}}sampleAt(e,t,n,s,r,a){const{x:o,y:l}=Ku(t,e,n),c=(o-s.x)*qt,h=(l-s.y)*qt,d=Math.max(0,Math.min(a-1,Math.floor(c))),u=Math.max(0,Math.min(a-1,Math.floor(h))),p=Math.min(a-1,d+1),_=Math.min(a-1,u+1),M=c-d,m=h-u,f=r[u*a+d],A=r[u*a+p],w=r[_*a+d],S=r[_*a+p],y=f+(A-f)*M,b=w+(S-w)*M;return y+(b-y)*m}}const Va=256,ch=3;async function Bv(i,e,t,n){const s=(i.south+i.north)/2,r=(i.west+i.east)/2,a=Math.abs(ji(s,i.east,s,i.west).x),o=Math.abs(ji(i.north,r,i.south,r).z),l=Zu(s,Math.max(a,o)),{tiles:c}=$u(r,s,l,ch),h=ch*Va,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=c[0];await Promise.all(c.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)*Va,(m.y-p.y)*Va)}));const _=document.createElement("canvas");_.width=e.width,_.height=e.height;const M=_.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),_}class zv{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 Bv(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 kv(){return{elevation:new Ov,imagery:new zv}}const Ms=64,Et=Ms+1,hh=512,uh=700,dh=900,Gv=-.5,Hv=.01;function Vv(i,e,t){return{north:fr(0,-t,i,e).lat,south:fr(0,t,i,e).lat,east:fr(t,0,i,e).lng,west:fr(-t,0,i,e).lng}}async function Wv(i,e,t){const n=Vv(i,e,dh),s={width:Et,height:Et},[r,a]=await Promise.all([t.elevation.getElevationGrid(n,s),t.imagery.getImageryTexture(n,{width:hh,height:hh})]),o=Math.floor(Et/2),l=r.heights[o*Et+o],c=new Float32Array(Et*Et*3),h=new Float32Array(Et*Et*2),d=new Float32Array(Et*Et*4);for(let A=0;A<Et;A++){const w=A/(Et-1),S=n.north+(n.south-n.north)*w;for(let y=0;y<Et;y++){const b=y/(Et-1),R=n.west+(n.east-n.west)*b,{x:v,z:T}=ji(S,R,i,e),I=r.heights[A*Et+y],C=Gv+Hv+(I-l),U=A*Et+y;c[U*3]=v,c[U*3+1]=C,c[U*3+2]=T,h[U*2]=b,h[U*2+1]=w;const Y=Math.max(Math.abs(v),Math.abs(T)),Z=1-Xv((Y-uh)/(dh-uh),0,1);d[U*4]=1,d[U*4+1]=1,d[U*4+2]=1,d[U*4+3]=Z}}const u=new Uint16Array(Ms*Ms*6);let p=0;for(let A=0;A<Ms;A++)for(let w=0;w<Ms;w++){const S=A*Et+w,y=S+1,b=S+Et,R=b+1;u[p++]=S,u[p++]=b,u[p++]=y,u[p++]=y,u[p++]=b,u[p++]=R}const _=new Tt;_.setAttribute("position",new pt(c,3)),_.setAttribute("uv",new pt(h,2)),_.setAttribute("color",new pt(d,4)),_.setIndex(new pt(u,1));const M=new Kn(a.source);M.flipY=!1;const m=new Xi({map:M,color:new Ce(1,1,1),vertexColors:!0,transparent:!0,fog:!0,depthTest:!1});return{mesh:new zt(_,m),attribution:t.imagery.attribution}}function Xv(i,e,t){return Math.max(e,Math.min(t,i))}const Dl={cloudCover:0,cloudDarkness:0,precipitationType:"none",precipitationIntensity:0,windDirectionDeg:0,windSpeed:0,lightning:!1},qv=18,Yv=.55,Zv=.5,Kv=`
|
|
4465
4465
|
attribute float aSpeed;
|
|
4466
4466
|
uniform float uTime;
|
|
4467
4467
|
uniform float uOverallSpeed;
|
|
@@ -4498,9 +4498,9 @@ void main() {
|
|
|
4498
4498
|
// a real, caught bug (a user directly noticed "darker/farther streaks equal-or-bigger than
|
|
4499
4499
|
// lighter/closer ones"), not just a stylistic overcorrection.
|
|
4500
4500
|
vHaze = clamp(dist / uHazeDistance, 0.0, 1.0);
|
|
4501
|
-
gl_PointSize = uPixelSize / dist + vNearBlur * ${
|
|
4501
|
+
gl_PointSize = uPixelSize / dist + vNearBlur * ${qv.toFixed(1)};
|
|
4502
4502
|
}
|
|
4503
|
-
|
|
4503
|
+
`,$v=`
|
|
4504
4504
|
precision mediump float;
|
|
4505
4505
|
uniform sampler2D uTexture;
|
|
4506
4506
|
uniform vec3 uColor;
|
|
@@ -4528,11 +4528,143 @@ void main() {
|
|
|
4528
4528
|
// defocus doesn't change color, only spreads+dims (see vertex shader's own gl_PointSize term) —
|
|
4529
4529
|
// both dim the alpha so a maximally blurred/hazy drop doesn't stay as visually "solid" as a sharp
|
|
4530
4530
|
// one right in the middle distance.
|
|
4531
|
-
vec3 color = mix(uColor, uHazeColor, vHaze * ${
|
|
4531
|
+
vec3 color = mix(uColor, uHazeColor, vHaze * ${Yv.toFixed(2)});
|
|
4532
4532
|
float blur = max(vNearBlur, vHaze);
|
|
4533
|
-
gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * ${
|
|
4533
|
+
gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * ${Zv.toFixed(2)}));
|
|
4534
|
+
}
|
|
4535
|
+
`;function Jv(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 pr;function Qv(){if(pr)return pr;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",pr=new Kn(e),pr}function jv(i){const e=Jv(i.seed),t=new Float32Array(i.count*3),n=new Float32Array(i.count),s=i.radiusM;for(let c=0;c<i.count;c++){const h=e()*Math.PI*2,d=Math.sqrt(e())*i.radiusM;t[c*3]=Math.cos(h)*d,t[c*3+1]=e()*i.heightM,t[c*3+2]=Math.sin(h)*d,n[c]=.85+e()*.3}const r=new Tt;r.setAttribute("position",new pt(t,3)),r.setAttribute("aSpeed",new pt(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 ke(0,0)},uHeight:{value:i.heightM},uBottomY:{value:i.bottomYM},uHalfWidth:{value:s},uTexture:{value:Qv()},uNearFocusDistance:{value:i.nearFocusDistanceM},uHazeDistance:{value:i.hazeDistanceM},uHazeColor:{value:i.hazeColor}},o=new kt({uniforms:a,vertexShader:Kv,fragmentShader:$v,transparent:!0,depthWrite:!1,depthTest:!0}),l=new Rr(r,o);return l.frustumCulled=!1,{points:l,uniforms:a}}const ex=`
|
|
4536
|
+
varying vec3 vDir;
|
|
4537
|
+
|
|
4538
|
+
void main() {
|
|
4539
|
+
vDir = normalize(position);
|
|
4540
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
4541
|
+
}
|
|
4542
|
+
`,tx=`
|
|
4543
|
+
precision highp float;
|
|
4544
|
+
uniform vec3 sunDir;
|
|
4545
|
+
uniform vec3 sunColor;
|
|
4546
|
+
uniform vec3 ambientColor;
|
|
4547
|
+
uniform vec3 baseColor;
|
|
4548
|
+
uniform float coverage;
|
|
4549
|
+
varying vec3 vDir;
|
|
4550
|
+
|
|
4551
|
+
// Implied altitude (world units) of the flat plane cloud noise is projected onto — see main()'s own
|
|
4552
|
+
// comment for why. Roughly matches typical real cloud-base altitudes scaled into this scene's own
|
|
4553
|
+
// CLOUD_RADIUS=700 dome: a mid-low value so the horizon compression effect is clearly visible
|
|
4554
|
+
// without being so low it reads as unrealistically close fog.
|
|
4555
|
+
const float CLOUD_LAYER_HEIGHT = 250.0;
|
|
4556
|
+
|
|
4557
|
+
vec3 hash3(vec3 p) {
|
|
4558
|
+
p = vec3(dot(p, vec3(127.1, 311.7, 74.7)), dot(p, vec3(269.5, 183.3, 246.1)), dot(p, vec3(113.5, 271.9, 124.6)));
|
|
4559
|
+
return fract(sin(p) * 43758.5453) * 2.0 - 1.0;
|
|
4560
|
+
}
|
|
4561
|
+
float noise3D(vec3 p) {
|
|
4562
|
+
vec3 i = floor(p);
|
|
4563
|
+
vec3 f = fract(p);
|
|
4564
|
+
vec3 u = f * f * (3.0 - 2.0 * f);
|
|
4565
|
+
return mix(
|
|
4566
|
+
mix(mix(dot(hash3(i + vec3(0.0, 0.0, 0.0)), f - vec3(0.0, 0.0, 0.0)),
|
|
4567
|
+
dot(hash3(i + vec3(1.0, 0.0, 0.0)), f - vec3(1.0, 0.0, 0.0)), u.x),
|
|
4568
|
+
mix(dot(hash3(i + vec3(0.0, 1.0, 0.0)), f - vec3(0.0, 1.0, 0.0)),
|
|
4569
|
+
dot(hash3(i + vec3(1.0, 1.0, 0.0)), f - vec3(1.0, 1.0, 0.0)), u.x), u.y),
|
|
4570
|
+
mix(mix(dot(hash3(i + vec3(0.0, 0.0, 1.0)), f - vec3(0.0, 0.0, 1.0)),
|
|
4571
|
+
dot(hash3(i + vec3(1.0, 0.0, 1.0)), f - vec3(1.0, 0.0, 1.0)), u.x),
|
|
4572
|
+
mix(dot(hash3(i + vec3(0.0, 1.0, 1.0)), f - vec3(0.0, 1.0, 1.0)),
|
|
4573
|
+
dot(hash3(i + vec3(1.0, 1.0, 1.0)), f - vec3(1.0, 1.0, 1.0)), u.x), u.y),
|
|
4574
|
+
u.z);
|
|
4575
|
+
}
|
|
4576
|
+
float fbm(vec3 p) {
|
|
4577
|
+
float sum = 0.0;
|
|
4578
|
+
float amp = 0.55;
|
|
4579
|
+
for (int i = 0; i < 4; i++) {
|
|
4580
|
+
sum += noise3D(p) * amp;
|
|
4581
|
+
p *= 2.03;
|
|
4582
|
+
amp *= 0.55;
|
|
4583
|
+
}
|
|
4584
|
+
return sum;
|
|
4585
|
+
}
|
|
4586
|
+
// Cellular (Worley) noise — distance to the nearest of 27 randomly-jittered cell points. Unlike
|
|
4587
|
+
// fbm's smooth interpolated blobs, this has genuinely sharp valleys between cells, reading as
|
|
4588
|
+
// distinct billowy cloud masses with real gaps/shadows between them rather than one soft gradient.
|
|
4589
|
+
float worley(vec3 p) {
|
|
4590
|
+
vec3 i = floor(p);
|
|
4591
|
+
vec3 f = fract(p);
|
|
4592
|
+
float minDist = 1.0;
|
|
4593
|
+
for (int x = -1; x <= 1; x++) {
|
|
4594
|
+
for (int y = -1; y <= 1; y++) {
|
|
4595
|
+
for (int z = -1; z <= 1; z++) {
|
|
4596
|
+
vec3 neighbor = vec3(float(x), float(y), float(z));
|
|
4597
|
+
vec3 point = hash3(i + neighbor) * 0.5 + 0.5;
|
|
4598
|
+
vec3 diff = neighbor + point - f;
|
|
4599
|
+
minDist = min(minDist, dot(diff, diff));
|
|
4600
|
+
}
|
|
4601
|
+
}
|
|
4602
|
+
}
|
|
4603
|
+
return sqrt(minDist);
|
|
4534
4604
|
}
|
|
4535
|
-
`;function jv(i){let t=i;return function(){t|=0,t=t+1831565813|0;let n=Math.imul(t^t>>>15,1|t);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}let pr;function tx(){if(pr)return pr;const i=128,t=document.createElement("canvas");t.width=i,t.height=i;const e=t.getContext("2d"),n=e.createLinearGradient(0,0,i,0);n.addColorStop(0,"rgba(255,255,255,0)"),n.addColorStop(.42,"rgba(255,255,255,0)"),n.addColorStop(.47,"rgba(255,255,255,0.85)"),n.addColorStop(.5,"rgba(255,255,255,1)"),n.addColorStop(.53,"rgba(255,255,255,0.85)"),n.addColorStop(.58,"rgba(255,255,255,0)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,i,i);const s=e.createLinearGradient(0,0,0,i);return s.addColorStop(0,"rgba(0,0,0,1)"),s.addColorStop(.1,"rgba(0,0,0,0)"),s.addColorStop(.9,"rgba(0,0,0,0)"),s.addColorStop(1,"rgba(0,0,0,1)"),e.globalCompositeOperation="destination-out",e.fillStyle=s,e.fillRect(0,0,i,i),e.globalCompositeOperation="source-over",pr=new In(t),pr}function ex(i){const t=jv(i.seed),e=new Float32Array(i.count*3),n=new Float32Array(i.count),s=i.radiusM;for(let c=0;c<i.count;c++){const h=t()*Math.PI*2,d=Math.sqrt(t())*i.radiusM;e[c*3]=Math.cos(h)*d,e[c*3+1]=t()*i.heightM,e[c*3+2]=Math.sin(h)*d,n[c]=.85+t()*.3}const r=new Te;r.setAttribute("position",new pe(e,3)),r.setAttribute("aSpeed",new pe(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 kt(0,0)},uHeight:{value:i.heightM},uBottomY:{value:i.bottomYM},uHalfWidth:{value:s},uTexture:{value:tx()},uNearFocusDistance:{value:i.nearFocusDistanceM},uHazeDistance:{value:i.hazeDistanceM},uHazeColor:{value:i.hazeColor}},o=new Ve({uniforms:a,vertexShader:Jv,fragmentShader:Qv,transparent:!0,depthWrite:!1,depthTest:!0}),l=new Cr(r,o);return l.frustumCulled=!1,{points:l,uniforms:a}}const mr=900,nx=900,ix=850,mh=850,Xa=4,sx=1.5,rx=-1,ax=6,gh=-4,ox=[{azimuthDeg:0,label:"N"},{azimuthDeg:45,label:"NE"},{azimuthDeg:90,label:"E"},{azimuthDeg:135,label:"SE"},{azimuthDeg:180,label:"S"},{azimuthDeg:225,label:"SO"},{azimuthDeg:270,label:"O"},{azimuthDeg:315,label:"NO"}],lx=880,_h=40,cx=10,hx=1,ux=150,vh=24,dx=700,fx=260,px=5,Ni=[.92,.92,.95],qa=[.15,.15,.19],xh={snow:{fallSpeedMPerS:2,size:.3,color:new It(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new It(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},zi=-.5,gr=6,Sh=3e3,_s=20,mx=15,Mh=zi,gx=40,yh=1,_x=9;function vx(i){return yh+(_x-yh)*i}const xx=new It(.75,.82,.92),Sx=10,Mx=.5;function yx(i){return Ll(i/Sx,Mx,1)}const Fi=200,Eh=.18,bh=.32,Ex=.35,bx=new It(.85,.9,.98),Th=5,Ah=.85,wh=.01;function Ya(i,t){return Math.round(i*(wh+(1-wh)*t))}const Rh=230,Ch=.7,Ph=.05,Tx=.6,Ax=.7,wx=.15,Ih=.35,Rx=3,Cx=1/12,Px=.5,Dh=8,Lh=25,Uh=.12,Ix={Venus:new It(1,.96,.85),Mars:new It(1,.55,.4),Jupiter:new It(.95,.87,.72),Saturn:new It(.92,.86,.68)};class Dx{renderer;scene=new X0;camera;skyMesh;groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;compassSprites=[];showCompass=!1;compassHovered=!1;compassForced=!1;animationFrameId=null;raycaster=new ff;weather=Dl;cloudSprites=[];precipitationPoints;precipitationPositions;precipitationPhase;precipitationSpeedJitter;precipitationWobbleFreqJitter;precipitationWobbleAmpJitter;precipitationBounceRemaining;precipitationBounceHeight;precipitationBounceDuration;precipitationBounceVelX;precipitationBounceVelZ;precipitationUniforms;rainSystem;rainSplashSystem;rainCameraDirection=new F;rainLastVerticalFacing=-1;lightningArmed=!1;nextLightningAtS=null;lightningFlashRemainingS=0;baseFogColor=[0,0,0];onLightningFlash;constructor(t,e=Gv(),n){this.renderer=new c1({canvas:t,antialias:!0}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),this.camera=new Ke(60,t.width/Math.max(t.height,1),.1,mr*1.2),this.camera.position.set(0,1.6,0),this.terrainProviders=e,this.onLightningFlash=n}get currentTerrainAttribution(){return this.terrainAttribution}resize(t,e){this.renderer.setSize(t,e,!1),this.camera.aspect=t/Math.max(e,1),this.camera.updateProjectionMatrix(),this.render()}setObserverPose(t){t.headingDeg!==void 0?this.camera.rotation.set(t.pitchDeg*vs,-t.headingDeg*vs,0,"YXZ"):this.camera.rotation.set(t.pitchDeg*vs,this.camera.rotation.y,0,"YXZ"),this.camera.position.y=1.6+t.elevationM,this.camera.fov!==t.fovDeg&&(this.camera.fov=t.fovDeg,this.camera.updateProjectionMatrix())}setTerrainOrigin(t,e,n){if(t===void 0||e===void 0)return;if(this.terrainOrigin){const{x:r,z:a}=ts(t,e,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(r*r+a*a)<ux)return}this.terrainOrigin={lat:t,lng:e};const s=++this.terrainBuildToken;qv(t,e,this.terrainProviders).then(({mesh:r,attribution:a})=>{s===this.terrainBuildToken&&(this.disposeMesh(this.terrainMesh),r.renderOrder=hx,this.terrainMesh=r,this.terrainAttribution=a,this.scene.add(r),this.render(),n?.())}).catch(r=>{console.warn("Terrain build failed, keeping the flat ground fallback:",r),n?.()})}setShowCompass(t){this.showCompass!==t&&(this.showCompass=t,this.disposeCompassLabels(),t&&this.buildCompassLabels(),this.render())}setCompassHovered(t){this.compassHovered!==t&&(this.compassHovered=t,this.updateCompassVisibility())}setCompassForced(t){this.compassForced!==t&&(this.compassForced=t,this.updateCompassVisibility())}updateCompassVisibility(){const t=this.compassHovered||this.compassForced;for(const e of this.compassSprites)e.visible=t;this.render()}setWeather(t){this.weather!==t&&(this.weather=t,this.buildClouds(),this.buildPrecipitation(),this.lightningArmed=t.lightning&&t.cloudDarkness>=Px,this.lightningArmed||(this.nextLightningAtS=null,this.lightningFlashRemainingS=0,this.scene.fog&&this.scene.fog.color.setRGB(...this.baseFogColor)),this.syncAnimationLoop(),this.render())}setAstronomy(t){const e=Iu(t.sun.altitudeDeg).horizon;this.baseFogColor=e,this.buildSky(t.sun),this.buildGround(e),this.retintClouds(e),this.terrainMesh&&this.terrainMesh.material.color.setRGB(e[0],e[1],e[2]),this.buildStars(t.stars,t.sun.altitudeDeg),this.setBodyMesh("sun",t.sun,Xa,new It(1,.96,.88),t.sun.magnitude),this.setMoonMesh(t.moon),this.buildPlanets(t.planets),this.scene.fog=new Tl(new It(...e),mr*.2,mr),this.render()}render(){this.renderer.render(this.scene,this.camera)}pickBodyAt(t,e){this.raycaster.setFromCamera(new kt(t,e),this.camera);const n=[...this.hitAreas.entries()],s=this.raycaster.intersectObjects(n.map(([,r])=>r))[0];if(s)return n.find(([,r])=>r===s.object)?.[0]}dispose(){this.stopTwinkle(),this.terrainBuildToken++,this.disposeMesh(this.skyMesh),this.disposeMesh(this.groundMesh),this.disposeMesh(this.terrainMesh),this.disposeCloudSprites(),this.disposePrecipitationPoints(),this.disposeRain(),this.disposeStarTiers();for(const t of this.bodyMeshes.values())this.disposeMesh(t);this.bodyMeshes.clear();for(const t of[...this.hitAreas.keys()])this.disposeHitArea(t);for(const t of[...this.glareSprites.keys()])this.disposeGlare(t);this.disposeCompassLabels(),this.renderer.dispose()}startTwinkle(){if(this.animationFrameId!==null||!this.needsAnimationLoop())return;let t;const e=n=>{const s=t===void 0?0:Math.min((n-t)/1e3,Cx);t=n,this.updateTwinkle(n/1e3),this.updatePrecipitation(n/1e3,s),this.updateRain(s),this.updateLightning(n/1e3,s),this.render(),this.animationFrameId=requestAnimationFrame(e)};this.animationFrameId=requestAnimationFrame(e)}stopTwinkle(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}needsAnimationLoop(){return this.starTiers.length>0||this.precipitationPoints!==void 0||this.rainSystem!==void 0||this.lightningArmed}syncAnimationLoop(){this.needsAnimationLoop()?this.startTwinkle():this.stopTwinkle()}buildSky(t){this.disposeMesh(this.skyMesh);const e=new Hr(mr,32,16),n=e.attributes.position,s=[];for(let a=0;a<n.count;a++){const{altitudeDeg:o,azimuthDeg:l}=f1(n.getX(a),n.getY(a),n.getZ(a)),c=g1(o,l,t.azimuthDeg,t.altitudeDeg);s.push(c[0],c[1],c[2])}e.setAttribute("color",new Le(s,3));const r=new qi({vertexColors:!0,side:Fe,fog:!1});this.skyMesh=new Ge(e,r),this.scene.add(this.skyMesh)}buildGround(t){this.disposeMesh(this.groundMesh);const e=new wl(nx,48),n=new It(t[0]*.35,t[1]*.35,t[2]*.35),s=new qi({color:n,fog:!0});this.groundMesh=new Ge(e,s),this.groundMesh.rotation.x=-Math.PI/2,this.groundMesh.position.y=-.5,this.scene.add(this.groundMesh)}setBodyMesh(t,e,n,s,r){if(this.disposeMesh(this.bodyMeshes.get(t)),this.disposeHitArea(t),this.disposeGlare(t),e.altitudeDeg<gh){this.bodyMeshes.delete(t);return}const{x:a,y:o,z:l}=ms(e.altitudeDeg,e.azimuthDeg,mh),c=Jc(e.altitudeDeg),h=new It(s.r*c[0],s.g*c[1],s.b*c[2]),d=new Hr(n,16,16),u=new qi({color:h,fog:!1}),p=new Ge(d,u);p.position.set(a,o,l),this.scene.add(p),this.bodyMeshes.set(t,p),this.setHitArea(t,a,o,l,n),this.setGlare(t,a,o,l,r,h)}setMoonMesh(t){const e="moon";if(this.disposeMesh(this.bodyMeshes.get(e)),this.disposeHitArea(e),this.disposeGlare(e),t.altitudeDeg<gh){this.bodyMeshes.delete(e);return}const{x:n,y:s,z:r}=ms(t.altitudeDeg,t.azimuthDeg,mh),a=Jc(t.altitudeDeg),o=new It(a[0],a[1],a[2]),l=new Bi({map:Vx(t.phase),color:o,fog:!1}),c=new ds(l);c.position.set(n,s,r);const h=Xa*2;c.scale.set(h,h,1),this.scene.add(c),this.bodyMeshes.set(e,c),this.setHitArea(e,n,s,r,Xa),this.setGlare(e,n,s,r,t.magnitude,o)}setHitArea(t,e,n,s,r){const a=new Bi({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1}),o=new ds(a);o.position.set(e,n,s);const l=r*ax;o.scale.set(l,l,1),this.scene.add(o),this.hitAreas.set(t,o)}disposeHitArea(t){const e=this.hitAreas.get(t);e&&(this.scene.remove(e),e.material.dispose(),this.hitAreas.delete(t))}setGlare(t,e,n,s,r,a){this.disposeGlare(t);const o=v1(r);if(o<=0)return;const l=M1(o),c=new Bi({map:Gx(),color:a,transparent:!0,opacity:b1(o),blending:Qa,depthWrite:!1,fog:!1}),h=new ds(c);h.position.set(e,n,s),h.scale.set(l*2,l*2,1),this.scene.add(h),this.glareSprites.set(t,h)}disposeGlare(t){const e=this.glareSprites.get(t);e&&(this.scene.remove(e),e.material.dispose(),this.glareSprites.delete(t))}buildPlanets(t){const e=new Set(["sun","moon"]);for(const n of t){e.add(n.body);const s=Kc(n.magnitude),r=$c(s),a=Ix[n.body]??new It(1,1,1),o=new It(a.r*r,a.g*r,a.b*r),l=sx*(.5+.5*s);this.setBodyMesh(n.body,n.position,l,o,n.magnitude)}for(const n of[...this.bodyMeshes.keys()])e.has(n)||(this.disposeMesh(this.bodyMeshes.get(n)),this.bodyMeshes.delete(n),this.disposeHitArea(n),this.disposeGlare(n))}buildStars(t,e){if(this.disposeStarTiers(),!t||t.catalog.count===0){this.syncAnimationLoop();return}const{catalog:n,date:s,observer:r}=t,a=h1(e),o=Es(1337),l=[];for(let c=0;c<n.count;c++){const h=n.mag[c];if(h>a)continue;const{altitudeDeg:d,azimuthDeg:u}=Tv(n.ra[c],n.dec[c],s,r);if(d<rx)continue;const{x:p,y:_,z:M}=ms(d,u,ix);l.push({x:p,y:_,z:M,brightness:Kc(h),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}this.starTiers=Du.map((c,h)=>{const d=l.filter(S=>A1(S.brightness)===h),u=new Float32Array(d.length*3),p=new Float32Array(d.length),_=new Float32Array(d.length),M=new Float32Array(d.length);d.forEach((S,y)=>{u[y*3]=S.x,u[y*3+1]=S.y,u[y*3+2]=S.z,p[y]=S.brightness,_[y]=S.phase,M[y]=S.speedFactor});const m=new Te;m.setAttribute("position",new pe(u,3));const f=new pe(new Float32Array(d.length*3),3);m.setAttribute("color",f);const A=new gu({vertexColors:!0,size:c.size,sizeAttenuation:!1,fog:!1}),w=new Cr(m,A);return this.scene.add(w),{points:w,colorAttribute:f,brightness:p,phase:_,speedFactor:M}}),this.updateTwinkle(0),this.startTwinkle()}updateTwinkle(t){for(const e of this.starTiers){const n=e.colorAttribute.array;for(let s=0;s<e.brightness.length;s++){const r=C1(e.brightness[s],{phase:e.phase[s],speedFactor:e.speedFactor[s]},t),a=$c(e.brightness[s])*r;n[s*3]=a,n[s*3+1]=a,n[s*3+2]=a}e.colorAttribute.needsUpdate=!0}}buildClouds(){this.disposeCloudSprites();const t=Math.round(this.weather.cloudCover*vh);if(t===0)return;const e=Es(4242),n=Lx();for(let s=0;s<vh;s++){const r=15+e()*55,a=e()*360,o=.4+e()*.45,l=fx*(.7+e()*.6);if(s>=t)continue;const{x:c,y:h,z:d}=ms(r,a,dx),u=new Bi({map:n,color:new It(1,1,1),transparent:!0,opacity:o,fog:!1,depthTest:!1}),p=new ds(u);p.position.set(c,h,d),p.scale.set(l,l*.6,1),p.renderOrder=px,this.scene.add(p),this.cloudSprites.push(p)}}retintClouds(t){if(this.cloudSprites.length===0)return;const e=this.weather.cloudDarkness,n=Ni[0]+(qa[0]-Ni[0])*e,s=Ni[1]+(qa[1]-Ni[1])*e,r=Ni[2]+(qa[2]-Ni[2])*e,a=(t[0]+t[1]+t[2])/3,o=Ll(a*1.8,.15,1);for(const l of this.cloudSprites)l.material.color.setRGB(n*o,s*o,r*o)}disposeCloudSprites(){for(const t of this.cloudSprites)this.scene.remove(t),t.material.dispose();this.cloudSprites=[]}disposePrecipitationPoints(){this.precipitationPoints&&(this.scene.remove(this.precipitationPoints),this.precipitationPoints.geometry.dispose(),this.precipitationPoints.material.dispose()),this.precipitationPoints=void 0,this.precipitationPositions=void 0,this.precipitationPhase=void 0,this.precipitationSpeedJitter=void 0,this.precipitationWobbleFreqJitter=void 0,this.precipitationWobbleAmpJitter=void 0,this.precipitationBounceRemaining=void 0,this.precipitationBounceHeight=void 0,this.precipitationBounceDuration=void 0,this.precipitationBounceVelX=void 0,this.precipitationBounceVelZ=void 0,this.precipitationUniforms=void 0}buildPrecipitation(){this.disposePrecipitationPoints(),this.disposeRain();const t=this.weather.precipitationType;if(t==="none")return;if(t==="rain"){this.buildRain();return}const e=xh[t],n=e.poolSize,s=Es(9001),r=new Float32Array(n*3),a=new Float32Array(n),o=new Float32Array(n),l=new Float32Array(n),c=new Float32Array(n),h=new Float32Array(n),d=new Float32Array(n),u=new Float32Array(n),p=new Float32Array(n),_=new Float32Array(n);for(let w=0;w<n;w++){const S=s()*Math.PI*2,y=s()*e.radiusM;r[w*3]=Math.cos(S)*y,r[w*3+1]=zi+s()*(e.topYM-zi),r[w*3+2]=Math.sin(S)*y,a[w]=s()*Math.PI*2,o[w]=.7+s()*.6,l[w]=.6+s()*.8,c[w]=.4+s()*1.2}const M=new Te;M.setAttribute("position",new pe(r,3)),M.setDrawRange(0,Ya(n,this.weather.precipitationIntensity));const m={uSize:{value:e.size},uScale:{value:.5*this.renderer.domElement.height},uOpacity:{value:e.opacity},uColor:{value:e.color},uHazeColor:{value:new It(...this.baseFogColor)},uTexture:{value:Ux(t)},uNearFocusDistance:{value:Th},uHazeDistance:{value:e.radiusM*Ah}},f=new Ve({uniforms:m,vertexShader:kx,fragmentShader:Hx,transparent:!0,depthWrite:!1});this.precipitationUniforms=m;const A=new Cr(M,f);this.scene.add(A),this.precipitationPoints=A,this.precipitationPositions=r,this.precipitationPhase=a,this.precipitationSpeedJitter=o,this.precipitationWobbleFreqJitter=l,this.precipitationWobbleAmpJitter=c,this.precipitationBounceRemaining=h,this.precipitationBounceHeight=d,this.precipitationBounceDuration=u,this.precipitationBounceVelX=p,this.precipitationBounceVelZ=_}updatePrecipitation(t,e){if(!this.precipitationPoints||!this.precipitationPositions||!this.precipitationPhase||!this.precipitationSpeedJitter||(this.precipitationUniforms?.uHazeColor.value.setRGB(...this.baseFogColor),e<=0))return;const n=this.weather.precipitationType;if(n==="none"||n==="rain")return;const s=xh[n],r=this.weather.windDirectionDeg*vs,a=Math.sin(r)*this.weather.windSpeed*s.driftSensitivity*gr,o=-Math.cos(r)*this.weather.windSpeed*s.driftSensitivity*gr,l=this.precipitationPositions,c=this.precipitationPhase,h=this.precipitationSpeedJitter,d=this.precipitationWobbleFreqJitter,u=this.precipitationWobbleAmpJitter,p=this.precipitationBounceRemaining,_=this.precipitationBounceHeight,M=this.precipitationBounceDuration,m=this.precipitationBounceVelX,f=this.precipitationBounceVelZ,A=n==="snow"&&d&&u,w=n==="hail"&&p&&_&&M&&m&&f;for(let S=0,y=0;S<l.length;S+=3,y++){if(w&&p[y]>0){if(p[y]-=e,p[y]<=0){const v=Math.random()*Math.PI*2,T=Math.sqrt(Math.random())*s.radiusM;l[S]=Math.cos(v)*T,l[S+1]=s.topYM,l[S+2]=Math.sin(v)*T,p[y]=0}else{const v=1-p[y]/M[y];l[S+1]=zi+Math.sin(Math.PI*v)*_[y],l[S]=vr(l[S]+(a+m[y])*e,s.radiusM),l[S+2]=vr(l[S+2]+(o+f[y])*e,s.radiusM)}continue}let b=0,R=0;if(A){const v=Tx*d[y],T=Ax*u[y];b=Math.sin(t*v*Math.PI*2+c[y])*T,R=Math.sin(t*v*Math.PI*2+c[y]+Math.PI/2)*T}if(l[S]+=(a+b)*e,l[S+1]-=s.fallSpeedMPerS*h[y]*e,l[S+2]+=(o+R)*e,l[S]=vr(l[S],s.radiusM),l[S+2]=vr(l[S+2],s.radiusM),l[S+1]<zi){if(w){_[y]=Ih*(.2+Math.random()*1.6),M[y]=wx*(.5+Math.random()),p[y]=M[y];const I=Math.random()*Math.PI*2,C=Rx*(_[y]/Ih);m[y]=Math.cos(I)*C,f[y]=Math.sin(I)*C,l[S+1]=zi;continue}const v=Math.random()*Math.PI*2,T=Math.sqrt(Math.random())*s.radiusM;l[S]=Math.cos(v)*T,l[S+1]=s.topYM,l[S+2]=Math.sin(v)*T}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const t=vx(this.weather.precipitationIntensity);this.rainSystem=ex({count:Sh,radiusM:_s,heightM:mx,bottomYM:Mh,overallSpeed:gx,color:xx,opacity:.85,visibleCount:Ya(Sh,this.weather.precipitationIntensity),speedStreak:yx(t),pixelSize:Rh,seed:9001,nearFocusDistanceM:Th,hazeDistanceM:_s*Ah,hazeColor:new It(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const t=Es(4242),e=new Float32Array(Fi*3),n=new Float32Array(Fi),s=new Float32Array(Fi),r=new Float32Array(Fi);for(let h=0;h<Fi;h++){const d=t()*Math.PI*2,u=Math.sqrt(t())*_s;e[h*3]=Math.cos(d)*u,e[h*3+1]=Mh,e[h*3+2]=Math.sin(d)*u,s[h]=_r(Eh,bh),n[h]=t()*s[h],r[h]=n[h]/s[h]}const a=new Te;a.setAttribute("position",new pe(e,3));const o=new pe(r,1);a.setAttribute("aLife",o),a.setDrawRange(0,Ya(Fi,this.weather.precipitationIntensity));const l=new Ve({uniforms:{uMaxSize:{value:Ex},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:bx},uTexture:{value:Ox()}},vertexShader:Bx,fragmentShader:zx,transparent:!0,depthWrite:!1}),c=new Cr(a,l);this.scene.add(c),this.rainSplashSystem={points:c,positions:e,life:n,duration:s,lifeAttribute:o}}disposeRain(){this.rainSystem&&(this.scene.remove(this.rainSystem.points),this.rainSystem.points.geometry.dispose(),this.rainSystem.points.material.dispose()),this.rainSystem=void 0,this.disposeRainSplashes()}disposeRainSplashes(){this.rainSplashSystem&&(this.scene.remove(this.rainSplashSystem.points),this.rainSplashSystem.points.geometry.dispose(),this.rainSplashSystem.points.material.dispose()),this.rainSplashSystem=void 0}updateRain(t){const e=this.rainSystem;if(!e)return;e.uniforms.uTime.value+=t,e.uniforms.uHazeColor.value.setRGB(...this.baseFogColor);const n=this.weather.windDirectionDeg*vs,s=Math.sin(n)*this.weather.windSpeed*gr,r=-Math.cos(n)*this.weather.windSpeed*gr,a=_s,o=c=>(c%(a*2)+a*3)%(a*2)-a;e.uniforms.uWindOffset.value.set(o(e.uniforms.uWindOffset.value.x+s*t),o(e.uniforms.uWindOffset.value.y+r*t)),this.camera.getWorldDirection(this.rainCameraDirection);const l=Math.abs(this.rainCameraDirection.y);if(Math.abs(l-this.rainLastVerticalFacing)>.001){this.rainLastVerticalFacing=l;const c=Ch+(1-Ch)*(1-l),h=Ph+(1-Ph)*(1-l);e.uniforms.uUvSquash.value=h,e.uniforms.uPixelSize.value=Rh*c*(.5+.5*h)}this.updateRainSplashes(t)}updateRainSplashes(t){const e=this.rainSplashSystem;if(!e||t<=0)return;const{positions:n,life:s,duration:r,lifeAttribute:a}=e,o=a.array;for(let l=0,c=0;l<n.length;l+=3,c++){if(s[c]+=t,s[c]>=r[c]){const h=Math.random()*Math.PI*2,d=Math.sqrt(Math.random())*_s;n[l]=Math.cos(h)*d,n[l+2]=Math.sin(h)*d,r[c]=_r(Eh,bh),s[c]=0}o[c]=s[c]/r[c]}e.points.geometry.attributes.position.needsUpdate=!0,a.needsUpdate=!0}updateLightning(t,e){if(this.lightningArmed){if(this.lightningFlashRemainingS>0){this.lightningFlashRemainingS=Math.max(0,this.lightningFlashRemainingS-e);const n=this.lightningFlashRemainingS/Uh;this.scene.fog&&this.scene.fog.color.setRGB(this.baseFogColor[0]+(1-this.baseFogColor[0])*n,this.baseFogColor[1]+(1-this.baseFogColor[1])*n,this.baseFogColor[2]+(1-this.baseFogColor[2])*n);return}if(this.nextLightningAtS===null){this.nextLightningAtS=t+_r(Dh,Lh);return}t>=this.nextLightningAtS&&(this.lightningFlashRemainingS=Uh,this.nextLightningAtS=t+_r(Dh,Lh),this.onLightningFlash?.())}}buildCompassLabels(){this.compassSprites=ox.map(({azimuthDeg:t,label:e})=>{const n=new Bi({map:Wx(e),depthTest:!1,fog:!1}),s=new ds(n),{x:r,y:a,z:o}=ms(0,t,lx);return s.position.set(r,a,o),s.scale.set(_h,_h,1),s.renderOrder=cx,s.visible=this.compassHovered||this.compassForced,this.scene.add(s),s})}disposeCompassLabels(){for(const t of this.compassSprites)this.scene.remove(t),t.material.map?.dispose(),t.material.dispose();this.compassSprites=[]}disposeStarTiers(){for(const t of this.starTiers)this.disposeMesh(t.points);this.starTiers=[]}disposeMesh(t){if(!t)return;this.scene.remove(t),"geometry"in t&&t.geometry.dispose();const e=t.material;for(const n of Array.isArray(e)?e:[e]){const s=n.map;s&&s.dispose(),n.dispose()}}}const vs=Math.PI/180;function Ll(i,t,e){return Math.max(t,Math.min(e,i))}function _r(i,t){return i+Math.random()*(t-i)}function vr(i,t){return(i%(t*2)+t*3)%(t*2)-t}let xr;function Lx(){if(xr)return xr;const i=256,t=document.createElement("canvas");t.width=i,t.height=i;const e=t.getContext("2d"),n=Es(77);for(let s=0;s<6;s++){const r=i*(.3+n()*.4),a=i*(.35+n()*.3),o=i*(.18+n()*.14),l=e.createRadialGradient(r,a,0,r,a,o);l.addColorStop(0,"rgba(255,255,255,0.9)"),l.addColorStop(.6,"rgba(255,255,255,0.5)"),l.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=l,e.beginPath(),e.arc(r,a,o,0,Math.PI*2),e.fill()}return xr=new In(t),xr}let Sr,Mr;function Ux(i){switch(i){case"snow":return Nx();case"hail":return Fx()}}function Nx(){if(Sr)return Sr;const i=64,t=document.createElement("canvas");t.width=i,t.height=i;const e=t.getContext("2d"),n=e.createRadialGradient(i/2,i/2,0,i/2,i/2,i/2);return n.addColorStop(0,"rgba(255,255,255,0.95)"),n.addColorStop(.5,"rgba(255,255,255,0.55)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,i,i),Sr=new In(t),Sr}function Fx(){if(Mr)return Mr;const i=64,t=document.createElement("canvas");t.width=i,t.height=i;const e=t.getContext("2d"),n=e.createRadialGradient(i/2,i/2,0,i/2,i/2,i/2);return n.addColorStop(0,"rgba(255,255,255,1)"),n.addColorStop(.55,"rgba(255,255,255,0.95)"),n.addColorStop(.8,"rgba(255,255,255,0.4)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,i,i),Mr=new In(t),Mr}let yr;function Ox(){if(yr)return yr;const i=64,t=document.createElement("canvas");t.width=i,t.height=i;const e=t.getContext("2d"),n=e.createRadialGradient(i/2,i/2,0,i/2,i/2,i/2);return n.addColorStop(0,"rgba(255,255,255,0)"),n.addColorStop(.4,"rgba(255,255,255,0)"),n.addColorStop(.6,"rgba(255,255,255,0.9)"),n.addColorStop(.8,"rgba(255,255,255,0.25)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,i,i),yr=new In(t),yr}const Bx=`
|
|
4605
|
+
|
|
4606
|
+
void main() {
|
|
4607
|
+
vec3 dir = normalize(vDir);
|
|
4608
|
+
vec3 L = normalize(sunDir);
|
|
4609
|
+
|
|
4610
|
+
// Sampling noise directly by angular direction put clouds at a CONSTANT apparent size regardless
|
|
4611
|
+
// of where you look — real clouds sit at a real, roughly flat altitude, so ones near the horizon
|
|
4612
|
+
// are seen through a much longer, grazing slant path and compress/stretch dramatically (the same
|
|
4613
|
+
// reason floor tiles or a flat ceiling look compressed toward a vanishing point), while ones
|
|
4614
|
+
// overhead look comparatively large. Projecting the view ray onto a flat plane at a fixed height
|
|
4615
|
+
// and sampling noise in THAT position (not the raw direction) reproduces the effect for free: near
|
|
4616
|
+
// zenith the projected point stays close to the origin (small coordinates, large apparent cloud
|
|
4617
|
+
// features); near the horizon dir.y shrinks toward 0 and the projected point races toward infinity
|
|
4618
|
+
// (huge, fast-varying coordinates between neighboring pixels = visual compression). dir.y is
|
|
4619
|
+
// floored, not left to hit exactly 0, to avoid an infinite/NaN blowup right at the horizon edge.
|
|
4620
|
+
float t = CLOUD_LAYER_HEIGHT / max(dir.y, 0.04);
|
|
4621
|
+
vec3 planePos = dir * t;
|
|
4622
|
+
|
|
4623
|
+
// Domain warp: distorts the position each noise layer below actually samples, using a slower,
|
|
4624
|
+
// broader noise field of its own. Without this, Worley cells (shapeCell) come out as too-regular,
|
|
4625
|
+
// too-round, near-identical-sized ovals — visually indistinguishable from a UFO's own saucer
|
|
4626
|
+
// silhouette in this app, which is exactly the wrong thing for a cloud layer to look like. Warping
|
|
4627
|
+
// the sample position stretches/bends those cell boundaries into irregular, organic shapes instead.
|
|
4628
|
+
vec3 warpPos = planePos * 0.006;
|
|
4629
|
+
vec3 warp = vec3(fbm(warpPos + 12.3), fbm(warpPos + 47.1), fbm(warpPos + 91.7)) * 40.0;
|
|
4630
|
+
vec3 warpedPos = planePos + warp;
|
|
4631
|
+
|
|
4632
|
+
float shapeFbm = fbm(warpedPos * 0.014) * 0.5 + 0.5;
|
|
4633
|
+
float shapeCell = 1.0 - worley(warpedPos * 0.011);
|
|
4634
|
+
float shape = mix(shapeFbm, shapeCell, 0.4);
|
|
4635
|
+
float detail = fbm(warpedPos * 0.031 + 41.0) * 0.5 + 0.5;
|
|
4636
|
+
|
|
4637
|
+
// Leaves a real, unclouded gap near the horizon (see buildCloudGeometry's own thetaLength — the
|
|
4638
|
+
// geometry itself stops short of the true horizon) — a soft fade across that same last few degrees
|
|
4639
|
+
// so the shell's own edge doesn't read as a hard-edged rim floating in the sky. Real terrain relief
|
|
4640
|
+
// near the observer can rise above the flat y=0 horizon plane in screen space, and this shell
|
|
4641
|
+
// (depthTest off, see buildCloudMaterial) would otherwise paint straight over it regardless of
|
|
4642
|
+
// which is really closer — see CLOUD_MIN_ALTITUDE_DEG's own comment.
|
|
4643
|
+
float horizonFade = smoothstep(0.026, 0.052, dir.y); // sin(1.5deg)..sin(3deg), matches buildCloudGeometry's own cutoff
|
|
4644
|
+
|
|
4645
|
+
// Below coverage's own noise threshold: a broken/patchy ceiling with real sky-colored gaps,
|
|
4646
|
+
// exactly like a real transition from scattered to overcast. remap-by-threshold, same technique
|
|
4647
|
+
// as the reference skill's own cloudDensity coverage control.
|
|
4648
|
+
float threshold = 1.0 - coverage;
|
|
4649
|
+
float alpha = smoothstep(threshold - 0.08, threshold + 0.08, shape);
|
|
4650
|
+
// This is what actually guarantees "total overcast, no sky visible" at cloudCover=1: force full
|
|
4651
|
+
// opacity everywhere as coverage approaches its max, overriding the noise field's own local value
|
|
4652
|
+
// rather than merely biasing it (a pure threshold shift would still leave the occasional fragment
|
|
4653
|
+
// below threshold even at coverage=1, since fbm's own range rarely spans a full 0..1).
|
|
4654
|
+
alpha = mix(alpha, 1.0, smoothstep(0.82, 1.0, coverage)) * horizonFade;
|
|
4655
|
+
if (alpha < 0.02) discard;
|
|
4656
|
+
|
|
4657
|
+
float diff = dot(dir, L) * 0.5 + 0.5;
|
|
4658
|
+
float sunGlow = pow(max(dot(dir, L), 0.0), 6.0) * 0.6; // diffuse bright patch toward the sun, like light through an overcast layer
|
|
4659
|
+
vec3 color = baseColor * (sunColor * diff * 0.7 + ambientColor * 0.5) + sunColor * sunGlow;
|
|
4660
|
+
// Strong contrast that survives even where alpha is forced fully opaque (high coverage) — shape's
|
|
4661
|
+
// own cell structure must stay visible as darker valleys / brighter billow tops, or a "fully
|
|
4662
|
+
// overcast" sky degenerates back into one flat painted color with no visible cloud structure.
|
|
4663
|
+
color *= mix(0.45, 1.4, shape) * mix(0.8, 1.15, detail);
|
|
4664
|
+
|
|
4665
|
+
gl_FragColor = vec4(color, alpha);
|
|
4666
|
+
}
|
|
4667
|
+
`;function nx(i,e){const t={sunDir:{value:new F(0,1,0)},sunColor:{value:new Ce(1,1,1)},ambientColor:{value:new Ce(.5,.5,.5)},baseColor:{value:i},coverage:{value:e}};return{material:new kt({uniforms:t,vertexShader:ex,fragmentShader:tx,transparent:!0,depthWrite:!1,depthTest:!1,side:Dt}),uniforms:t}}const ix=1.5;function sx(i){const e=Math.PI/2-ix*Math.PI/180;return new As(i,48,24,0,Math.PI*2,0,e)}const mr=900,rx=900,ax=850,fh=850,Wa=4,ox=1.5,lx=-1,cx=6,ph=-4,hx=[{azimuthDeg:0,label:"N"},{azimuthDeg:45,label:"NE"},{azimuthDeg:90,label:"E"},{azimuthDeg:135,label:"SE"},{azimuthDeg:180,label:"S"},{azimuthDeg:225,label:"SO"},{azimuthDeg:270,label:"O"},{azimuthDeg:315,label:"NO"}],ux=880,mh=40,dx=10,fx=1,px=150,mx=700,gx=5,Ni=[.92,.92,.95],Xa=[.15,.15,.19],gh={snow:{fallSpeedMPerS:2,size:.3,color:new Ce(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new Ce(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},Bi=-.5,gr=6,_h=3e3,ms=20,_x=15,vh=Bi,vx=40,xh=1,xx=9;function Sx(i){return xh+(xx-xh)*i}const Mx=new Ce(.75,.82,.92),yx=10,Ex=.5;function bx(i){return Qu(i/yx,Ex,1)}const Fi=200,Sh=.18,Mh=.32,Tx=.35,Ax=new Ce(.85,.9,.98),yh=5,Eh=.85,bh=.01;function qa(i,e){return Math.round(i*(bh+(1-bh)*e))}const Th=230,Ah=.7,wh=.05,wx=.6,Rx=.7,Cx=.15,Rh=.35,Px=3,Ix=1/12,Dx=.5,Ch=8,Ph=25,Ih=.12,Lx={Venus:new Ce(1,.96,.85),Mars:new Ce(1,.55,.4),Jupiter:new Ce(.95,.87,.72),Saturn:new Ce(.92,.86,.68)};class Ux{renderer;scene=new V0;camera;skyMesh;groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;compassSprites=[];showCompass=!1;compassHovered=!1;compassForced=!1;animationFrameId=null;raycaster=new uf;weather=Dl;cloudMesh;cloudMaterial;cloudUniforms;precipitationPoints;precipitationPositions;precipitationPhase;precipitationSpeedJitter;precipitationWobbleFreqJitter;precipitationWobbleAmpJitter;precipitationBounceRemaining;precipitationBounceHeight;precipitationBounceDuration;precipitationBounceVelX;precipitationBounceVelZ;precipitationUniforms;rainSystem;rainSplashSystem;rainCameraDirection=new F;rainLastVerticalFacing=-1;lightningArmed=!1;nextLightningAtS=null;lightningFlashRemainingS=0;baseFogColor=[0,0,0];lastSunPosition;onLightningFlash;constructor(e,t=kv(),n){this.renderer=new o1({canvas:e,antialias:!0}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),this.camera=new Kt(60,e.width/Math.max(e.height,1),.1,mr*1.2),this.camera.position.set(0,1.6,0),this.terrainProviders=t,this.onLightningFlash=n}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*gs,-e.headingDeg*gs,0,"YXZ"):this.camera.rotation.set(e.pitchDeg*gs,this.camera.rotation.y,0,"YXZ"),this.camera.position.y=1.6+e.elevationM,this.camera.fov!==e.fovDeg&&(this.camera.fov=e.fovDeg,this.camera.updateProjectionMatrix())}setTerrainOrigin(e,t,n){if(e===void 0||t===void 0)return;if(this.terrainOrigin){const{x:r,z:a}=ji(e,t,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(r*r+a*a)<px)return}this.terrainOrigin={lat:e,lng:t};const s=++this.terrainBuildToken;Wv(e,t,this.terrainProviders).then(({mesh:r,attribution:a})=>{s===this.terrainBuildToken&&(this.disposeMesh(this.terrainMesh),r.renderOrder=fx,r.material.color.setRGB(...this.baseFogColor),this.terrainMesh=r,this.terrainAttribution=a,this.scene.add(r),this.render(),n?.())}).catch(r=>{console.warn("Terrain build failed, keeping the flat ground fallback:",r),n?.()})}setShowCompass(e){this.showCompass!==e&&(this.showCompass=e,this.disposeCompassLabels(),e&&this.buildCompassLabels(),this.render())}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){this.weather!==e&&(this.weather=e,this.buildClouds(),this.buildPrecipitation(),this.lightningArmed=e.lightning&&e.cloudDarkness>=Dx,this.lightningArmed||(this.nextLightningAtS=null,this.lightningFlashRemainingS=0,this.scene.fog&&this.scene.fog.color.setRGB(...this.baseFogColor)),this.syncAnimationLoop(),this.render())}setAstronomy(e){const t=Ru(e.sun.altitudeDeg).horizon;this.baseFogColor=t,this.lastSunPosition=e.sun,this.buildSky(e.sun),this.buildGround(t),this.updateCloudLighting(e.sun,t),this.terrainMesh&&this.terrainMesh.material.color.setRGB(t[0],t[1],t[2]),this.buildStars(e.stars,e.sun.altitudeDeg),this.setBodyMesh("sun",e.sun,Wa,new Ce(1,.96,.88),e.sun.magnitude),this.setMoonMesh(e.moon),this.buildPlanets(e.planets),this.scene.fog=new Tl(new Ce(...t),mr*.2,mr),this.render()}render(){this.renderer.render(this.scene,this.camera)}pickBodyAt(e,t){this.raycaster.setFromCamera(new ke(e,t),this.camera);const n=[...this.hitAreas.entries()],s=this.raycaster.intersectObjects(n.map(([,r])=>r))[0];if(s)return n.find(([,r])=>r===s.object)?.[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(),this.renderer.dispose()}startTwinkle(){if(this.animationFrameId!==null||!this.needsAnimationLoop())return;let e;const t=n=>{const s=e===void 0?0:Math.min((n-e)/1e3,Ix);e=n,this.updateTwinkle(n/1e3),this.updatePrecipitation(n/1e3,s),this.updateRain(s),this.updateLightning(n/1e3,s),this.render(),this.animationFrameId=requestAnimationFrame(t)};this.animationFrameId=requestAnimationFrame(t)}stopTwinkle(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}needsAnimationLoop(){return this.starTiers.length>0||this.precipitationPoints!==void 0||this.rainSystem!==void 0||this.lightningArmed}syncAnimationLoop(){this.needsAnimationLoop()?this.startTwinkle():this.stopTwinkle()}buildSky(e){this.disposeMesh(this.skyMesh);const t=new As(mr,32,16),n=t.attributes.position,s=[];for(let a=0;a<n.count;a++){const{altitudeDeg:o,azimuthDeg:l}=u1(n.getX(a),n.getY(a),n.getZ(a)),c=p1(o,l,e.azimuthDeg,e.altitudeDeg);s.push(c[0],c[1],c[2])}t.setAttribute("color",new Ut(s,3));const r=new Xi({vertexColors:!0,side:Dt,fog:!1});this.skyMesh=new zt(t,r),this.scene.add(this.skyMesh)}buildGround(e){this.disposeMesh(this.groundMesh);const t=new wl(rx,48),n=new Ce(e[0]*.35,e[1]*.35,e[2]*.35),s=new Xi({color:n,fog:!0});this.groundMesh=new zt(t,s),this.groundMesh.rotation.x=-Math.PI/2,this.groundMesh.position.y=-.5,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<ph){this.bodyMeshes.delete(e);return}const{x:a,y:o,z:l}=fs(t.altitudeDeg,t.azimuthDeg,fh),c=Ba(t.altitudeDeg),h=new Ce(s.r*c[0],s.g*c[1],s.b*c[2]),d=new As(n,16,16),u=new Xi({color:h,fog:!1}),p=new zt(d,u);p.position.set(a,o,l),this.scene.add(p),this.bodyMeshes.set(e,p),this.setHitArea(e,a,o,l,n),this.setGlare(e,a,o,l,r,h)}setMoonMesh(e){const t="moon";if(this.disposeMesh(this.bodyMeshes.get(t)),this.disposeHitArea(t),this.disposeGlare(t),e.altitudeDeg<ph){this.bodyMeshes.delete(t);return}const{x:n,y:s,z:r}=fs(e.altitudeDeg,e.azimuthDeg,fh),a=Ba(e.altitudeDeg),o=new Ce(a[0],a[1],a[2]),l=new vs({map:Wx(e.phase),color:o,fog:!1}),c=new Xs(l);c.position.set(n,s,r);const h=Wa*2;c.scale.set(h,h,1),this.scene.add(c),this.bodyMeshes.set(t,c),this.setHitArea(t,n,s,r,Wa),this.setGlare(t,n,s,r,e.magnitude,o)}setHitArea(e,t,n,s,r){const a=new vs({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1}),o=new Xs(a);o.position.set(t,n,s);const l=r*cx;o.scale.set(l,l,1),this.scene.add(o),this.hitAreas.set(e,o)}disposeHitArea(e){const t=this.hitAreas.get(e);t&&(this.scene.remove(t),t.material.dispose(),this.hitAreas.delete(e))}setGlare(e,t,n,s,r,a){this.disposeGlare(e);const o=g1(r);if(o<=0)return;const l=x1(o),c=new vs({map:Vx(),color:a,transparent:!0,opacity:y1(o),blending:Qa,depthWrite:!1,fog:!1}),h=new Xs(c);h.position.set(t,n,s),h.scale.set(l*2,l*2,1),this.scene.add(h),this.glareSprites.set(e,h)}disposeGlare(e){const t=this.glareSprites.get(e);t&&(this.scene.remove(t),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=Zc(n.magnitude),r=Kc(s),a=Lx[n.body]??new Ce(1,1,1),o=new Ce(a.r*r,a.g*r,a.b*r),l=ox*(.5+.5*s);this.setBodyMesh(n.body,n.position,l,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=l1(t),o=Ya(1337),l=[];for(let c=0;c<n.count;c++){const h=n.mag[c];if(h>a)continue;const{altitudeDeg:d,azimuthDeg:u}=Ev(n.ra[c],n.dec[c],s,r);if(d<lx)continue;const{x:p,y:_,z:M}=fs(d,u,ax);l.push({x:p,y:_,z:M,brightness:Zc(h),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}this.starTiers=Cu.map((c,h)=>{const d=l.filter(S=>b1(S.brightness)===h),u=new Float32Array(d.length*3),p=new Float32Array(d.length),_=new Float32Array(d.length),M=new Float32Array(d.length);d.forEach((S,y)=>{u[y*3]=S.x,u[y*3+1]=S.y,u[y*3+2]=S.z,p[y]=S.brightness,_[y]=S.phase,M[y]=S.speedFactor});const m=new Tt;m.setAttribute("position",new pt(u,3));const f=new pt(new Float32Array(d.length*3),3);m.setAttribute("color",f);const A=new fu({vertexColors:!0,size:c.size,sizeAttenuation:!1,fog:!1}),w=new Rr(m,A);return this.scene.add(w),{points:w,colorAttribute:f,brightness:p,phase:_,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=w1(t.brightness[s],{phase:t.phase[s],speedFactor:t.speedFactor[s]},e),a=Kc(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 Ce(Ni[0]+(Xa[0]-Ni[0])*e,Ni[1]+(Xa[1]-Ni[1])*e,Ni[2]+(Xa[2]-Ni[2])*e),{material:n,uniforms:s}=nx(t,this.weather.cloudCover);this.cloudMaterial=n,this.cloudUniforms=s,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const r=sx(mx);this.cloudMesh=new zt(r,n),this.cloudMesh.renderOrder=gx,this.scene.add(this.cloudMesh)}updateCloudLighting(e,t){if(!this.cloudUniforms)return;const{x:n,y:s,z:r}=fs(e.altitudeDeg,e.azimuthDeg,1),a=Ba(e.altitudeDeg);this.cloudUniforms.sunDir.value.set(n,s,r),this.cloudUniforms.sunColor.value.setRGB(a[0],.96*a[1],.88*a[2]),this.cloudUniforms.ambientColor.value.setRGB(t[0],t[1],t[2])}disposeCloudSystem(){this.cloudMesh&&(this.scene.remove(this.cloudMesh),this.cloudMesh.geometry.dispose()),this.cloudMaterial?.dispose(),this.cloudMesh=void 0,this.cloudMaterial=void 0,this.cloudUniforms=void 0}disposePrecipitationPoints(){this.precipitationPoints&&(this.scene.remove(this.precipitationPoints),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=gh[e],n=t.poolSize,s=Ya(9001),r=new Float32Array(n*3),a=new Float32Array(n),o=new Float32Array(n),l=new Float32Array(n),c=new Float32Array(n),h=new Float32Array(n),d=new Float32Array(n),u=new Float32Array(n),p=new Float32Array(n),_=new Float32Array(n);for(let w=0;w<n;w++){const S=s()*Math.PI*2,y=s()*t.radiusM;r[w*3]=Math.cos(S)*y,r[w*3+1]=Bi+s()*(t.topYM-Bi),r[w*3+2]=Math.sin(S)*y,a[w]=s()*Math.PI*2,o[w]=.7+s()*.6,l[w]=.6+s()*.8,c[w]=.4+s()*1.2}const M=new Tt;M.setAttribute("position",new pt(r,3)),M.setDrawRange(0,qa(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 Ce(...this.baseFogColor)},uTexture:{value:Nx(e)},uNearFocusDistance:{value:yh},uHazeDistance:{value:t.radiusM*Eh}},f=new kt({uniforms:m,vertexShader:Gx,fragmentShader:Hx,transparent:!0,depthWrite:!1});this.precipitationUniforms=m;const A=new Rr(M,f);this.scene.add(A),this.precipitationPoints=A,this.precipitationPositions=r,this.precipitationPhase=a,this.precipitationSpeedJitter=o,this.precipitationWobbleFreqJitter=l,this.precipitationWobbleAmpJitter=c,this.precipitationBounceRemaining=h,this.precipitationBounceHeight=d,this.precipitationBounceDuration=u,this.precipitationBounceVelX=p,this.precipitationBounceVelZ=_}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=gh[n],r=this.weather.windDirectionDeg*gs,a=Math.sin(r)*this.weather.windSpeed*s.driftSensitivity*gr,o=-Math.cos(r)*this.weather.windSpeed*s.driftSensitivity*gr,l=this.precipitationPositions,c=this.precipitationPhase,h=this.precipitationSpeedJitter,d=this.precipitationWobbleFreqJitter,u=this.precipitationWobbleAmpJitter,p=this.precipitationBounceRemaining,_=this.precipitationBounceHeight,M=this.precipitationBounceDuration,m=this.precipitationBounceVelX,f=this.precipitationBounceVelZ,A=n==="snow"&&d&&u,w=n==="hail"&&p&&_&&M&&m&&f;for(let S=0,y=0;S<l.length;S+=3,y++){if(w&&p[y]>0){if(p[y]-=t,p[y]<=0){const v=Math.random()*Math.PI*2,T=Math.sqrt(Math.random())*s.radiusM;l[S]=Math.cos(v)*T,l[S+1]=s.topYM,l[S+2]=Math.sin(v)*T,p[y]=0}else{const v=1-p[y]/M[y];l[S+1]=Bi+Math.sin(Math.PI*v)*_[y],l[S]=vr(l[S]+(a+m[y])*t,s.radiusM),l[S+2]=vr(l[S+2]+(o+f[y])*t,s.radiusM)}continue}let b=0,R=0;if(A){const v=wx*d[y],T=Rx*u[y];b=Math.sin(e*v*Math.PI*2+c[y])*T,R=Math.sin(e*v*Math.PI*2+c[y]+Math.PI/2)*T}if(l[S]+=(a+b)*t,l[S+1]-=s.fallSpeedMPerS*h[y]*t,l[S+2]+=(o+R)*t,l[S]=vr(l[S],s.radiusM),l[S+2]=vr(l[S+2],s.radiusM),l[S+1]<Bi){if(w){_[y]=Rh*(.2+Math.random()*1.6),M[y]=Cx*(.5+Math.random()),p[y]=M[y];const I=Math.random()*Math.PI*2,C=Px*(_[y]/Rh);m[y]=Math.cos(I)*C,f[y]=Math.sin(I)*C,l[S+1]=Bi;continue}const v=Math.random()*Math.PI*2,T=Math.sqrt(Math.random())*s.radiusM;l[S]=Math.cos(v)*T,l[S+1]=s.topYM,l[S+2]=Math.sin(v)*T}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const e=Sx(this.weather.precipitationIntensity);this.rainSystem=jv({count:_h,radiusM:ms,heightM:_x,bottomYM:vh,overallSpeed:vx,color:Mx,opacity:.85,visibleCount:qa(_h,this.weather.precipitationIntensity),speedStreak:bx(e),pixelSize:Th,seed:9001,nearFocusDistanceM:yh,hazeDistanceM:ms*Eh,hazeColor:new Ce(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const e=Ya(4242),t=new Float32Array(Fi*3),n=new Float32Array(Fi),s=new Float32Array(Fi),r=new Float32Array(Fi);for(let h=0;h<Fi;h++){const d=e()*Math.PI*2,u=Math.sqrt(e())*ms;t[h*3]=Math.cos(d)*u,t[h*3+1]=vh,t[h*3+2]=Math.sin(d)*u,s[h]=_r(Sh,Mh),n[h]=e()*s[h],r[h]=n[h]/s[h]}const a=new Tt;a.setAttribute("position",new pt(t,3));const o=new pt(r,1);a.setAttribute("aLife",o),a.setDrawRange(0,qa(Fi,this.weather.precipitationIntensity));const l=new kt({uniforms:{uMaxSize:{value:Tx},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:Ax},uTexture:{value:Bx()}},vertexShader:zx,fragmentShader:kx,transparent:!0,depthWrite:!1}),c=new Rr(a,l);this.scene.add(c),this.rainSplashSystem={points:c,positions:t,life:n,duration:s,lifeAttribute:o}}disposeRain(){this.rainSystem&&(this.scene.remove(this.rainSystem.points),this.rainSystem.points.geometry.dispose(),this.rainSystem.points.material.dispose()),this.rainSystem=void 0,this.disposeRainSplashes()}disposeRainSplashes(){this.rainSplashSystem&&(this.scene.remove(this.rainSplashSystem.points),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*gs,s=Math.sin(n)*this.weather.windSpeed*gr,r=-Math.cos(n)*this.weather.windSpeed*gr,a=ms,o=c=>(c%(a*2)+a*3)%(a*2)-a;t.uniforms.uWindOffset.value.set(o(t.uniforms.uWindOffset.value.x+s*e),o(t.uniforms.uWindOffset.value.y+r*e)),this.camera.getWorldDirection(this.rainCameraDirection);const l=Math.abs(this.rainCameraDirection.y);if(Math.abs(l-this.rainLastVerticalFacing)>.001){this.rainLastVerticalFacing=l;const c=Ah+(1-Ah)*(1-l),h=wh+(1-wh)*(1-l);t.uniforms.uUvSquash.value=h,t.uniforms.uPixelSize.value=Th*c*(.5+.5*h)}this.updateRainSplashes(e)}updateRainSplashes(e){const t=this.rainSplashSystem;if(!t||e<=0)return;const{positions:n,life:s,duration:r,lifeAttribute:a}=t,o=a.array;for(let l=0,c=0;l<n.length;l+=3,c++){if(s[c]+=e,s[c]>=r[c]){const h=Math.random()*Math.PI*2,d=Math.sqrt(Math.random())*ms;n[l]=Math.cos(h)*d,n[l+2]=Math.sin(h)*d,r[c]=_r(Sh,Mh),s[c]=0}o[c]=s[c]/r[c]}t.points.geometry.attributes.position.needsUpdate=!0,a.needsUpdate=!0}updateLightning(e,t){if(this.lightningArmed){if(this.lightningFlashRemainingS>0){this.lightningFlashRemainingS=Math.max(0,this.lightningFlashRemainingS-t);const n=this.lightningFlashRemainingS/Ih;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+_r(Ch,Ph);return}e>=this.nextLightningAtS&&(this.lightningFlashRemainingS=Ih,this.nextLightningAtS=e+_r(Ch,Ph),this.onLightningFlash?.())}}buildCompassLabels(){this.compassSprites=hx.map(({azimuthDeg:e,label:t})=>{const n=new vs({map:Xx(t),depthTest:!1,fog:!1}),s=new Xs(n),{x:r,y:a,z:o}=fs(0,e,ux);return s.position.set(r,a,o),s.scale.set(mh,mh,1),s.renderOrder=dx,s.visible=this.compassHovered||this.compassForced,this.scene.add(s),s})}disposeCompassLabels(){for(const e of this.compassSprites)this.scene.remove(e),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;this.scene.remove(e),"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 gs=Math.PI/180;function Qu(i,e,t){return Math.max(e,Math.min(t,i))}function _r(i,e){return i+Math.random()*(e-i)}function vr(i,e){return(i%(e*2)+e*3)%(e*2)-e}let xr,Sr;function Nx(i){switch(i){case"snow":return Fx();case"hail":return Ox()}}function Fx(){if(xr)return xr;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),xr=new Kn(e),xr}function Ox(){if(Sr)return Sr;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),Sr=new Kn(e),Sr}let Mr;function Bx(){if(Mr)return Mr;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),Mr=new Kn(e),Mr}const zx=`
|
|
4536
4668
|
uniform float uMaxSize;
|
|
4537
4669
|
uniform float uScale;
|
|
4538
4670
|
attribute float aLife;
|
|
@@ -4545,7 +4677,7 @@ void main() {
|
|
|
4545
4677
|
vOpacity = 1.0 - aLife;
|
|
4546
4678
|
gl_Position = projectionMatrix * mvPosition;
|
|
4547
4679
|
}
|
|
4548
|
-
`,
|
|
4680
|
+
`,kx=`
|
|
4549
4681
|
uniform vec3 uColor;
|
|
4550
4682
|
uniform sampler2D uTexture;
|
|
4551
4683
|
varying float vOpacity;
|
|
@@ -4556,7 +4688,7 @@ void main() {
|
|
|
4556
4688
|
if (alpha < 0.01) discard;
|
|
4557
4689
|
gl_FragColor = vec4(uColor, alpha);
|
|
4558
4690
|
}
|
|
4559
|
-
`,
|
|
4691
|
+
`,Gx=`
|
|
4560
4692
|
uniform float uSize;
|
|
4561
4693
|
uniform float uScale;
|
|
4562
4694
|
uniform float uNearFocusDistance;
|
|
@@ -4597,4 +4729,4 @@ void main() {
|
|
|
4597
4729
|
float blur = max(vNearBlur, vHaze);
|
|
4598
4730
|
gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * 0.5));
|
|
4599
4731
|
}
|
|
4600
|
-
`;let Er;function Gx(){if(Er)return Er;const i=128,t=document.createElement("canvas");t.width=i,t.height=i;const e=t.getContext("2d"),n=e.createRadialGradient(i/2,i/2,0,i/2,i/2,i/2);return n.addColorStop(0,"rgba(255,255,255,1)"),n.addColorStop(.4,"rgba(255,255,255,0.35)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,i,i),Er=new In(t),Er}function Vx(i){const e=document.createElement("canvas");e.width=128,e.height=128;const n=e.getContext("2d"),s=128/2-2,r=128/2,a=128/2,o="#2e2b26",l="#f4f1e2";n.fillStyle=o,n.beginPath(),n.arc(r,a,s,0,Math.PI*2),n.fill();const c=Ll(i.illuminatedFraction,0,1),h=i.phaseFraction<.5,d=s*Math.abs(1-2*c),u=c<.5;return n.save(),n.beginPath(),n.arc(r,a,s,0,Math.PI*2),n.clip(),n.fillStyle=l,n.beginPath(),h?(n.arc(r,a,s,-Math.PI/2,Math.PI/2,!1),n.ellipse(r,a,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 In(e)}function Wx(i){const t=document.createElement("canvas");t.width=128,t.height=128;const e=t.getContext("2d");return e.fillStyle="rgba(0, 0, 0, 0.55)",e.beginPath(),e.arc(64,64,60,0,Math.PI*2),e.fill(),e.fillStyle="#ffffff",e.font="bold 52px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(i,64,68),new In(t)}function Es(i){let t=i;return function(){t|=0,t=t+1831565813|0;let n=Math.imul(t^t>>>15,1|t);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}const Nh=new Map;function Xx(i){const t=i.byteLength/(4*Float32Array.BYTES_PER_ELEMENT),e=t,n=e*Float32Array.BYTES_PER_ELEMENT;return{count:t,ra:new Float32Array(i,0*n,e),dec:new Float32Array(i,1*n,e),mag:new Float32Array(i,2*n,e),ci:new Float32Array(i,3*n,e)}}function qx(i){let t=Nh.get(i);return t||(t=fetch(i).then(e=>e.arrayBuffer()).then(Xx),Nh.set(i,t)),t}const Yx=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,Zx=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,Kx=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href;class $x{context;buffers=new Map;ambientSource;ambientGain;ambientKey="none";ambientToken=0;ambientVolume=0;windSource;windGain;windActive=!1;windToken=0;windVolume=0;resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("WeatherAudio: Web Audio unavailable, weather sounds disabled:",t);return}}this.context.state==="suspended"&&this.context.resume()}setAmbient(t,e,n){if(!this.context)return;const s=t==="rain"||t==="hail"?t:"none";if(this.ambientVolume=s==="hail"?Math.min(1,e*1.3+.2):s==="rain"?e:0,s!==this.ambientKey){this.ambientKey=s;const a=++this.ambientToken;this.stopSource(this.ambientSource,this.ambientGain),this.ambientSource=void 0,this.ambientGain=void 0,s!=="none"&&this.startLoop(Yx,this.ambientVolume).then(o=>this.applyIfCurrent(o,a,()=>this.ambientToken,l=>{this.ambientSource=l?.source,this.ambientGain=l?.gain,l&&(l.gain.gain.value=this.ambientVolume)}))}else this.ambientGain&&(this.ambientGain.gain.value=this.ambientVolume);this.windVolume=n;const r=n>.03;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(Zx,this.windVolume).then(o=>this.applyIfCurrent(o,a,()=>this.windToken,l=>{this.windSource=l?.source,this.windGain=l?.gain,l&&(l.gain.gain.value=this.windVolume)}))}else this.windGain&&(this.windGain.gain.value=this.windVolume)}playThunder(){this.context&&this.playOneShot(Kx,.9)}dispose(){this.ambientToken++,this.windToken++,this.stopSource(this.ambientSource,this.ambientGain),this.stopSource(this.windSource,this.windGain),this.ambientSource=void 0,this.ambientGain=void 0,this.windSource=void 0,this.windGain=void 0,this.context?.close(),this.context=void 0,this.buffers.clear()}applyIfCurrent(t,e,n,s){if(e!==n()){t?.source.stop();return}s(t)}async startLoop(t,e){const n=this.context;if(n)try{const s=await this.getBuffer(t),r=n.createBufferSource();r.buffer=s,r.loop=!0;const a=n.createGain();return a.gain.value=e,r.connect(a).connect(n.destination),r.start(),{source:r,gain:a}}catch(s){console.warn("Weather ambient sound failed to load, staying silent:",s);return}}async playOneShot(t,e){const n=this.context;if(n)try{const s=await this.getBuffer(t),r=n.createBufferSource();r.buffer=s;const a=n.createGain();a.gain.value=e,r.connect(a).connect(n.destination),r.start()}catch(s){console.warn("Thunder sound failed to load:",s)}}async getBuffer(t){const e=this.context;if(!e)throw new Error("WeatherAudio: AudioContext not ready — resume() must be called first");let n=this.buffers.get(t);return n||(n=fetch(t).then(s=>{if(!s.ok)throw new Error(`Audio fetch failed (${s.status}): ${t}`);return s.arrayBuffer()}).then(s=>e.decodeAudioData(s)),this.buffers.set(t,n)),n}stopSource(t,e){try{t?.stop()}catch{}t?.disconnect(),e?.disconnect()}}$r();const Jx={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"}},Qx=["en","fr"],jx=new URL(""+new URL("stars-mag7.5-DDr9QasD.bin",import.meta.url).href,import.meta.url).href,t2={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},Za={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class e2 extends HTMLElement{static get observedAttributes(){return["src","star-catalog-src","show-compass"]}shadow;stageElement;frameElement;sceneCanvas;ufoElement;sceneRenderer;bodyTooltip;terrainAttributionElement;shownTerrainAttribution;resizeObserver;lastTimeMs=0;starCatalog;weatherAudio=new $x;thunderTimeoutId;handleFullscreenChange=()=>this.resizeToStage();handlePointerMove=t=>{this.sceneRenderer.setCompassHovered(!0);const n=this.ufoElement.canvasElement.getBoundingClientRect();if(n.width===0||n.height===0)return;const s=(t.clientX-n.left)/n.width*2-1,r=-((t.clientY-n.top)/n.height*2-1),a=this.sceneRenderer.pickBodyAt(s,r);if(!a){this.bodyTooltip.hidden=!0;return}const o=fl(navigator.languages,Qx);this.bodyTooltip.textContent=Jx[a]?.[o]??a,this.bodyTooltip.hidden=!1;const l=this.stageElement.getBoundingClientRect();this.bodyTooltip.style.left=`${t.clientX-l.left+12}px`,this.bodyTooltip.style.top=`${t.clientY-l.top+12}px`};handlePointerLeave=()=>{this.bodyTooltip.hidden=!0,this.sceneRenderer.setCompassHovered(!1)};handleLightningFlash=()=>{clearTimeout(this.thunderTimeoutId);const t=(.5+Math.random()*3.5)*1e3;this.thunderTimeoutId=window.setTimeout(()=>this.weatherAudio.playThunder(),t)};handleFirstInteraction=()=>{this.weatherAudio.resume(),this.setWeather(this.ufoElement.sighting.weather)};handleTimeUpdate=t=>{this.lastTimeMs=t.detail.time,this.updateAstronomy(this.lastTimeMs)};constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${Zd}</style>${Yd}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.frameElement=this.shadow.getElementById("frame"),this.sceneCanvas=this.shadow.getElementById("scene-canvas"),this.sceneRenderer=new Dx(this.sceneCanvas,void 0,this.handleLightningFlash),this.bodyTooltip=this.shadow.getElementById("body-tooltip"),this.terrainAttributionElement=this.shadow.getElementById("terrain-attribution"),this.ufoElement=document.createElement(Ja),this.ufoElement.classList.add("ufo-overlay"),this.ufoElement.style.setProperty("--ufo-canvas-background","transparent"),this.ufoElement.style.setProperty("--ufo-canvas-border","none"),this.ufoElement.fullscreenTarget=this.stageElement,this.shadow.getElementById("ufo-slot").replaceWith(this.ufoElement),this.ufoElement.addEventListener("timeupdate",this.handleTimeUpdate),this.ufoElement.canvasElement.addEventListener("pointermove",this.handlePointerMove),this.ufoElement.canvasElement.addEventListener("pointerleave",this.handlePointerLeave),this.ufoElement.canvasElement.addEventListener("pointerdown",this.handleFirstInteraction,{once:!0})}connectedCallback(){this.resizeToStage(),this.updateAstronomy(this.lastTimeMs),this.loadStars(),this.resizeObserver=new ResizeObserver(()=>this.resizeToStage()),this.resizeObserver.observe(this.frameElement),document.addEventListener("fullscreenchange",this.handleFullscreenChange);const t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){this.resizeObserver?.disconnect(),document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.sceneRenderer.stopTwinkle(),clearTimeout(this.thunderTimeoutId),this.weatherAudio.dispose()}attributeChangedCallback(t,e,n){t==="src"&&n&&n!==e&&this.isConnected&&this.loadFromSrc(n),t==="star-catalog-src"&&n!==e&&this.isConnected&&this.loadStars(),t==="show-compass"&&n!==e&&this.sceneRenderer.setShowCompass(this.hasAttribute("show-compass"))}setCompassForced(t){this.sceneRenderer.setCompassForced(t)}setWeather(t){const e=t??Dl;this.sceneRenderer.setWeather(e),this.weatherAudio.setAmbient(e.precipitationType,e.precipitationIntensity,e.windSpeed)}resumeWeatherAudio(){this.weatherAudio.resume()}async loadFromSrc(t){const e=await fetch(t);this.sightingData=await e.json()}get sightingData(){return this.ufoElement.sightingData}set sightingData(t){this.ufoElement.sightingData=t,this.lastTimeMs=0,this.updateAstronomy(0),this.setWeather(this.ufoElement.sighting.weather)}resizeToStage(){const t=this.frameElement.getBoundingClientRect(),e=Math.max(1,Math.round(t.width)),n=Math.max(1,Math.round(t.height));this.sceneCanvas.width=e,this.sceneCanvas.height=n,this.sceneRenderer.resize(e,n)}async loadStars(){const t=this.getAttribute("star-catalog-src")??jx;this.starCatalog=await qx(t),this.updateAstronomy(this.lastTimeMs)}updateAstronomy(t){const e=this.ufoElement.sighting,n=Rd(e,t);this.sceneRenderer.setObserverPose(n??Za),this.sceneRenderer.setTerrainOrigin(n?.lat,n?.lng,()=>this.updateTerrainAttribution()),this.updateTerrainAttribution();const s=n?.lat??Za.lat,r=n?.lng??Za.lng,a=Pv(e.event.time??{},r);if(!a){this.sceneRenderer.setAstronomy(t2);return}const o=new Date(a.getTime()+t),l={lat:s,lng:r,elevationM:n?.elevationM??0},c={...Ga("Sun",o,l),magnitude:Va("Sun",o)},h={...Ga("Moon",o,l),phase:Av(o),magnitude:Va("Moon",o)},d=bv.map(u=>({body:u,position:Ga(u,o,l),magnitude:Va(u,o)}));this.sceneRenderer.setAstronomy({sun:c,moon:h,planets:d,stars:this.starCatalog?{catalog:this.starCatalog,date:o,observer:l}:void 0})}updateTerrainAttribution(){const t=this.sceneRenderer.currentTerrainAttribution;t!==this.shownTerrainAttribution&&(this.shownTerrainAttribution=t,this.terrainAttributionElement.textContent=t??"",this.terrainAttributionElement.hidden=!t)}}const ul="rr0-scene";function n2(){$r(),customElements.get(ul)||customElements.define(ul,e2)}class i2{constructor(t,e){this.timeline=t,this.clock=e}currentPointer=null;shapePrototype=null;sourceId="";start(t,e){this.sourceId=t,this.shapePrototype=e,this.currentPointer=null,this.clock.start(n=>this.recordSample(n))}onPointerMove(t,e){this.currentPointer={x:t,y:e}}stop(){this.clock.stop()}recordSample(t){if(!this.currentPointer||!this.shapePrototype)return;const e=Hh(this.shapePrototype,this.currentPointer.x,this.currentPointer.y);this.timeline.addKeyframe(t,[{sourceId:this.sourceId,shape:e}])}}class s2{constructor(t){this.intervalMs=t}rafId=null;startTime=0;lastTick=0;start(t){this.startTime=performance.now(),this.lastTick=0;const e=()=>{const n=performance.now()-this.startTime;n-this.lastTick>=this.intervalMs&&(this.lastTick=n,t(n)),this.rafId=requestAnimationFrame(e)};this.rafId=requestAnimationFrame(e)}stop(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}}const ed={oval:"Oval",saucer:"Saucer",triangle:"Triangle",color:"Color",transparency:"Transparency",halo:"Halo",shape:"Shape",addShape:"Add shape",samplingRate:"Sampling rate (ms)",duration:"Duration (s)",durationPlaceholder:"recording length",export:"Export JSON",record:"Record",stop:"Stop",latitude:"Latitude",longitude:"Longitude",heading:"Heading (°)",headingPlaceholder:"unknown",pitch:"Tilt (°)",observationTime:"Observation start (optional)",yearPlaceholder:"year",monthPlaceholder:"month",dayPlaceholder:"day",hourPlaceholder:"hour",minutePlaceholder:"min",weather:"Weather",cloudCover:"Cloud cover",cloudDarkness:"Cloud darkness",precipitationType:"Precipitation",precipitationNone:"None",precipitationRain:"Rain",precipitationSnow:"Snow",precipitationHail:"Hail",precipitationIntensity:"Intensity",windDirection:"Wind direction (°)",windSpeed:"Wind speed",lightning:"Lightning"},r2=Object.freeze(Object.defineProperty({__proto__:null,ufoRecorderMessages_en:ed},Symbol.toStringTag,{value:"Module"}));$r();n2();const Oi={width:48,height:28},Fh=.2,a2=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"]),Vn=4,Oh="ufo-1",Bh=["oval","saucer","triangle"],o2={presetId:"oval",color:"#39ff14",transparency:0,haloScale:1.5};function l2(i){if(i.kind==="oval")return"oval";if(i.points.length===3)return"triangle";if(i.points.length===8)return"saucer"}class c2 extends HTMLElement{shadow;sceneElement;ufoElement;recordButton;samplingRateInput;presetButtons;colorInput;transparencyInput;haloScaleInput;sourceSelect;addShapeButton;durationInput;exportButton;latInput;lngInput;headingInput;pitchInput;obsYearInput;obsMonthInput;obsDayInput;obsHourInput;obsMinuteInput;cloudCoverInput;cloudDarknessInput;precipitationTypeSelect;precipitationIntensityInput;windDirectionInput;windSpeedInput;lightningInput;labelColor;labelTransparency;labelHalo;labelShape;labelSamplingRate;labelDuration;labelLatitude;labelLongitude;labelHeading;labelPitch;labelObservationTime;labelWeather;labelCloudCover;labelCloudDarkness;labelPrecipitationType;labelPrecipitationIntensity;labelWindDirection;labelWindSpeed;labelLightning;optionPrecipitationNone;optionPrecipitationRain;optionPrecipitationSnow;optionPrecipitationHail;recorder;isRecording=!1;messages=ed;currentAppearance={...o2};currentSourceId=Oh;dragState;cameraDragState;handleKeyDown=t=>{if(t.key==="Escape"&&this.isRecording&&this.toggleRecording(),a2.has(t.key)){const e=t.composedPath()[0];if(e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement)return;this.moveOrResizeSelectedShape(t)}};handleDragPointerMove=t=>this.onDragPointerMove(t);handleDragPointerUp=()=>this.endDrag();constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${hd}</style>${cd}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.sceneElement=document.createElement(ul),this.sceneElement.setAttribute("show-compass",""),this.ufoElement=this.sceneElement.ufoElement,this.ufoElement.enableClickToPlay=!1,this.shadow.getElementById("ufo-slot").replaceWith(this.sceneElement),this.recordButton=this.shadow.getElementById("record"),this.samplingRateInput=this.shadow.getElementById("samplingRate"),this.presetButtons={oval:this.shadow.getElementById("preset-oval"),saucer:this.shadow.getElementById("preset-saucer"),triangle:this.shadow.getElementById("preset-triangle")},this.colorInput=this.shadow.getElementById("color"),this.transparencyInput=this.shadow.getElementById("transparency"),this.haloScaleInput=this.shadow.getElementById("haloScale"),this.sourceSelect=this.shadow.getElementById("source"),this.addShapeButton=this.shadow.getElementById("add-shape"),this.durationInput=this.shadow.getElementById("durationSeconds"),this.exportButton=this.shadow.getElementById("export"),this.latInput=this.shadow.getElementById("lat"),this.lngInput=this.shadow.getElementById("lng"),this.headingInput=this.shadow.getElementById("heading"),this.pitchInput=this.shadow.getElementById("pitch"),this.obsYearInput=this.shadow.getElementById("obs-year"),this.obsMonthInput=this.shadow.getElementById("obs-month"),this.obsDayInput=this.shadow.getElementById("obs-day"),this.obsHourInput=this.shadow.getElementById("obs-hour"),this.obsMinuteInput=this.shadow.getElementById("obs-minute"),this.cloudCoverInput=this.shadow.getElementById("cloudCover"),this.cloudDarknessInput=this.shadow.getElementById("cloudDarkness"),this.precipitationTypeSelect=this.shadow.getElementById("precipitationType"),this.precipitationIntensityInput=this.shadow.getElementById("precipitationIntensity"),this.windDirectionInput=this.shadow.getElementById("windDirection"),this.windSpeedInput=this.shadow.getElementById("windSpeed"),this.lightningInput=this.shadow.getElementById("lightning"),this.labelColor=this.shadow.getElementById("label-color"),this.labelTransparency=this.shadow.getElementById("label-transparency"),this.labelHalo=this.shadow.getElementById("label-halo"),this.labelShape=this.shadow.getElementById("label-shape"),this.labelSamplingRate=this.shadow.getElementById("label-sampling-rate"),this.labelDuration=this.shadow.getElementById("label-duration"),this.labelLatitude=this.shadow.getElementById("label-lat"),this.labelLongitude=this.shadow.getElementById("label-lng"),this.labelHeading=this.shadow.getElementById("label-heading"),this.labelPitch=this.shadow.getElementById("label-pitch"),this.labelObservationTime=this.shadow.getElementById("label-observation-time"),this.labelWeather=this.shadow.getElementById("label-weather"),this.labelCloudCover=this.shadow.getElementById("label-cloud-cover"),this.labelCloudDarkness=this.shadow.getElementById("label-cloud-darkness"),this.labelPrecipitationType=this.shadow.getElementById("label-precipitation-type"),this.labelPrecipitationIntensity=this.shadow.getElementById("label-precipitation-intensity"),this.labelWindDirection=this.shadow.getElementById("label-wind-direction"),this.labelWindSpeed=this.shadow.getElementById("label-wind-speed"),this.labelLightning=this.shadow.getElementById("label-lightning"),this.optionPrecipitationNone=this.shadow.getElementById("option-precipitation-none"),this.optionPrecipitationRain=this.shadow.getElementById("option-precipitation-rain"),this.optionPrecipitationSnow=this.shadow.getElementById("option-precipitation-snow"),this.optionPrecipitationHail=this.shadow.getElementById("option-precipitation-hail"),this.ufoElement.canvasElement.addEventListener("pointerdown",e=>this.onPointerDown(e)),this.ufoElement.canvasElement.addEventListener("pointermove",e=>this.onPointerMove(e)),this.recordButton.addEventListener("click",()=>this.toggleRecording()),this.addShapeButton.addEventListener("click",()=>this.addShape()),this.exportButton.addEventListener("click",()=>this.exportJson()),this.durationInput.addEventListener("input",()=>{this.ufoElement.durationSeconds=this.durationInput.value===""?void 0:Number(this.durationInput.value),this.ufoElement.refresh()}),this.sourceSelect.addEventListener("change",()=>{this.currentSourceId=this.sourceSelect.value,this.onSelectionOrTimeChanged()}),this.ufoElement.addEventListener("timeupdate",()=>{this.onSelectionOrTimeChanged(),this.dispatchEvent(new CustomEvent("sightingchange"))}),document.addEventListener("keydown",this.handleKeyDown);for(const e of Bh)this.presetButtons[e].addEventListener("click",()=>this.setAppearance({presetId:e}));this.colorInput.addEventListener("input",()=>this.setAppearance({color:this.colorInput.value})),this.transparencyInput.addEventListener("input",()=>this.setAppearance({transparency:Number(this.transparencyInput.value)})),this.haloScaleInput.addEventListener("input",()=>this.setAppearance({haloScale:Number(this.haloScaleInput.value)}));for(const e of[this.latInput,this.lngInput,this.headingInput,this.pitchInput])e.addEventListener("input",()=>this.updateObserver());this.headingInput.addEventListener("focus",()=>this.sceneElement.setCompassForced(!0)),this.headingInput.addEventListener("blur",()=>this.sceneElement.setCompassForced(!1));for(const e of[this.obsYearInput,this.obsMonthInput,this.obsDayInput,this.obsHourInput,this.obsMinuteInput])e.addEventListener("input",()=>this.updateObservationTime());for(const e of[this.cloudCoverInput,this.cloudDarknessInput,this.precipitationTypeSelect,this.precipitationIntensityInput,this.windDirectionInput,this.windSpeedInput,this.lightningInput])e.addEventListener("input",()=>this.updateWeather());this.updatePresetButtons(),this.setRecordButtonLabel(!1),this.applyAppearanceAtPlayhead(),this.refreshSourceList(),this.onSelectionOrTimeChanged(),this.loadLocaleMessages()}disconnectedCallback(){document.removeEventListener("keydown",this.handleKeyDown),this.endDrag()}get sightingData(){return this.ufoElement.sightingData}set sightingData(t){this.endDrag(),this.ufoElement.sightingData=t,this.currentSourceId=this.ufoElement.sighting.timeline.sourceIds[0]??Oh,this.refreshSourceList(),this.onSelectionOrTimeChanged(),this.durationInput.value=this.ufoElement.durationSeconds!==void 0?String(this.ufoElement.durationSeconds):"",this.syncObservationTimeFields(),this.syncWeatherFromSighting(),this.sceneElement.setWeather(this.ufoElement.sighting.weather)}exportJson(){const t=this.sightingData,e=`${t.witnessId??"sighting"}-sighting.json`,n=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),s=URL.createObjectURL(n),r=document.createElement("a");r.href=s,r.download=e,r.click(),URL.revokeObjectURL(s)}numberOrUndefined(t){return t===""?void 0:Number(t)}wrapDegrees(t,e){if(t===void 0)return;const n=(t%360+360)%360;return String(n)!==e.value&&(e.value=String(n)),n}updateObserver(){if(this.ufoElement.playbackState==="playing")return;const t=this.numberOrUndefined(this.latInput.value),e=this.numberOrUndefined(this.lngInput.value),n=this.wrapDegrees(this.numberOrUndefined(this.headingInput.value),this.headingInput),s=this.numberOrUndefined(this.pitchInput.value)??0,r=this.ufoElement.sighting.event,a=this.ufoElement.sighting.observerTrack,o=this.ufoElement.currentTime;r.place=t!==void 0&&e!==void 0?[{lat:t,lng:e}]:void 0,t===void 0&&e===void 0&&n===void 0&&s===0?a.removeKeyframeAt(o):a.addKeyframe(o,{lat:t,lng:e,elevationM:0,headingDeg:n,pitchDeg:s,fovDeg:60}),this.ufoElement.refresh()}updateObservationTime(){const t=this.numberOrUndefined(this.obsYearInput.value),e=this.numberOrUndefined(this.obsMonthInput.value),n=this.numberOrUndefined(this.obsDayInput.value),s=this.numberOrUndefined(this.obsHourInput.value),r=this.numberOrUndefined(this.obsMinuteInput.value),a=this.ufoElement.sighting.event;a.time=t===void 0&&e===void 0&&n===void 0&&s===void 0&&r===void 0?void 0:{year:t,month:e,day:n,hour:s,minute:r},this.ufoElement.refresh()}updateWeather(){this.sceneElement.resumeWeatherAudio();const t=this.ufoElement.sighting,e={cloudCover:Number(this.cloudCoverInput.value),cloudDarkness:Number(this.cloudDarknessInput.value),precipitationType:this.precipitationTypeSelect.value,precipitationIntensity:Number(this.precipitationIntensityInput.value),windDirectionDeg:this.wrapDegrees(this.numberOrUndefined(this.windDirectionInput.value),this.windDirectionInput)??0,windSpeed:Number(this.windSpeedInput.value),lightning:this.lightningInput.checked};t.weather=e,this.sceneElement.setWeather(e)}syncObservationTimeFields(){const t=this.ufoElement.sighting.event;this.obsYearInput.value=t.time?.year!==void 0?String(t.time.year):"",this.obsMonthInput.value=t.time?.month!==void 0?String(t.time.month):"",this.obsDayInput.value=t.time?.day!==void 0?String(t.time.day):"",this.obsHourInput.value=t.time?.hour!==void 0?String(t.time.hour):"",this.obsMinuteInput.value=t.time?.minute!==void 0?String(t.time.minute):""}syncWeatherFromSighting(){const t=this.ufoElement.sighting.weather??Dl;this.cloudCoverInput.value=String(t.cloudCover),this.cloudDarknessInput.value=String(t.cloudDarkness),this.precipitationTypeSelect.value=t.precipitationType,this.precipitationIntensityInput.value=String(t.precipitationIntensity),this.windDirectionInput.value=String(t.windDirectionDeg),this.windSpeedInput.value=String(t.windSpeed),this.lightningInput.checked=t.lightning}syncObserverFromTimeline(){if(this.ufoElement.playbackState==="playing")return;const t=this.ufoElement.sighting,e=t.observerTrack.getInterpolatedPoseAt(this.ufoElement.currentTime),n=t.event.place?.[0],s=this.shadow.activeElement;s!==this.latInput&&(this.latInput.value=e?.lat!==void 0?String(e.lat):n?String(n.lat):""),s!==this.lngInput&&(this.lngInput.value=e?.lng!==void 0?String(e.lng):n?String(n.lng):""),s!==this.headingInput&&(this.headingInput.value=e?.headingDeg!==void 0?String(e.headingDeg):""),s!==this.pitchInput&&(this.pitchInput.value=String(e?.pitchDeg??0))}get appearance(){return{...this.currentAppearance}}set appearance(t){this.setAppearance(t)}setAppearance(t){this.currentAppearance={...this.currentAppearance,...t},this.updatePresetButtons(),!(this.isRecording||this.ufoElement.playbackState==="playing")&&this.applyAppearanceAtPlayhead()}applyAppearanceAtPlayhead(t){const e=this.ufoElement.sighting.timeline,n=this.ufoElement.currentTime,s=e.getInterpolatedShapeAt(n,this.currentSourceId),r=this.buildAppearanceShape(t??s?.bounds??this.defaultBounds(),s);e.addKeyframe(n,[{sourceId:this.currentSourceId,shape:r}]),this.ufoElement.refresh()}buildAppearanceShape(t,e){const n=Vl(t,this.currentAppearance);return e?{...n,angle:e.angle,title:e.title,selected:e.selected}:n}onSelectionOrTimeChanged(){this.syncAppearanceFromTimeline(),this.syncObserverFromTimeline(),this.ufoElement.selectedSourceId=this.currentSourceId}syncAppearanceFromTimeline(){if(this.ufoElement.playbackState==="playing")return;const t=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(this.ufoElement.currentTime,this.currentSourceId);t&&(this.currentAppearance={presetId:l2(t)??this.currentAppearance.presetId,color:t.color,transparency:t.transparency,haloScale:t.haloScale},this.updatePresetButtons(),this.colorInput.value=this.currentAppearance.color,this.transparencyInput.value=String(this.currentAppearance.transparency),this.haloScaleInput.value=String(this.currentAppearance.haloScale))}addShape(){if(this.isRecording)return;const t=this.ufoElement.sighting.timeline,e=new Set([...t.sourceIds,this.currentSourceId]);let n=e.size+1;for(;e.has(`ufo-${n}`);)n++;this.currentSourceId=`ufo-${n}`,this.applyAppearanceAtPlayhead(this.offsetDefaultBounds(t.sourceIds.length)),this.refreshSourceList()}offsetDefaultBounds(t){const e=this.defaultBounds(),n=24;return{...e,x:e.x+t*n,y:e.y+t*n}}refreshSourceList(){const t=this.ufoElement.sighting.timeline,e=[...new Set([...t.sourceIds,this.currentSourceId])];this.sourceSelect.innerHTML="";for(const n of e){const s=document.createElement("option");s.value=n,s.textContent=n,this.sourceSelect.appendChild(s)}this.sourceSelect.value=this.currentSourceId}updatePresetButtons(){for(const t of Bh)this.presetButtons[t]?.setAttribute("aria-pressed",String(t===this.currentAppearance.presetId))}get samplingRate(){return Number(this.samplingRateInput.value)}buildPrototype(t=this.defaultBounds()){return Vl(t,this.currentAppearance)}defaultBounds(){const t=this.ufoElement.canvasElement;return{x:t.width/2-Oi.width/2,y:t.height/2-Oi.height/2,width:Oi.width,height:Oi.height}}toggleRecording(){this.endDrag();const t=this.ufoElement.canvasElement;this.isRecording?(this.recorder?.stop(),this.isRecording=!1,this.setRecordButtonLabel(!1),t.style.cursor="",t.style.touchAction="",this.sourceSelect.disabled=!1,this.addShapeButton.disabled=!1,this.ufoElement.refresh(),this.refreshSourceList()):(this.recorder=new i2(this.ufoElement.sighting.timeline,new s2(this.samplingRate)),this.recorder.start(this.currentSourceId,this.buildPrototype()),this.isRecording=!0,this.setRecordButtonLabel(!0),t.style.cursor="crosshair",t.style.touchAction="none",this.sourceSelect.disabled=!0,this.addShapeButton.disabled=!0)}setRecordButtonLabel(t){this.recordButton.textContent=t?"⏹":"⏺";const e=t?this.messages.stop:this.messages.record;this.recordButton.title=e,this.recordButton.setAttribute("aria-label",e)}async loadLocaleMessages(){const t=fl(navigator.languages,Xh);t!=="en"&&this.applyMessages(await Wd(t))}applyMessages(t){this.messages=t,this.presetButtons.oval.textContent=t.oval,this.presetButtons.saucer.textContent=t.saucer,this.presetButtons.triangle.textContent=t.triangle,this.labelColor.textContent=t.color,this.labelTransparency.textContent=t.transparency,this.labelHalo.textContent=t.halo,this.labelShape.textContent=t.shape,this.labelSamplingRate.textContent=t.samplingRate,this.labelDuration.textContent=t.duration,this.durationInput.placeholder=t.durationPlaceholder,this.addShapeButton.textContent=t.addShape,this.exportButton.textContent=t.export,this.labelLatitude.textContent=t.latitude,this.labelLongitude.textContent=t.longitude,this.labelHeading.textContent=t.heading,this.headingInput.placeholder=t.headingPlaceholder,this.labelPitch.textContent=t.pitch,this.labelObservationTime.textContent=t.observationTime,this.obsYearInput.placeholder=t.yearPlaceholder,this.obsMonthInput.placeholder=t.monthPlaceholder,this.obsDayInput.placeholder=t.dayPlaceholder,this.obsHourInput.placeholder=t.hourPlaceholder,this.obsMinuteInput.placeholder=t.minutePlaceholder,this.labelWeather.textContent=t.weather,this.labelCloudCover.textContent=t.cloudCover,this.labelCloudDarkness.textContent=t.cloudDarkness,this.labelPrecipitationType.textContent=t.precipitationType,this.optionPrecipitationNone.textContent=t.precipitationNone,this.optionPrecipitationRain.textContent=t.precipitationRain,this.optionPrecipitationSnow.textContent=t.precipitationSnow,this.optionPrecipitationHail.textContent=t.precipitationHail,this.labelPrecipitationIntensity.textContent=t.precipitationIntensity,this.labelWindDirection.textContent=t.windDirection,this.labelWindSpeed.textContent=t.windSpeed,this.labelLightning.textContent=t.lightning,this.setRecordButtonLabel(this.isRecording)}onPointerDown(t){if(this.isRecording){this.onPointerMove(t);return}const e=this.canvasPointFromEvent(t);if(!e)return;const n=this.ufoElement.sighting.timeline,s=this.ufoElement.currentTime,r=n.getInterpolatedShapeAt(s,this.currentSourceId),a=r&&Id(r,e),o=this.ufoElement.playbackState==="playing";if(r&&a){if(o)return;this.beginDrag(a==="rotate"?"rotate":"resize",this.currentSourceId,r,e,a);return}const l=n.hitTest(s,e.x,e.y);if(!l){o||this.beginCameraDrag(e);return}l.sourceId!==this.currentSourceId&&(this.currentSourceId=l.sourceId,this.refreshSourceList(),this.onSelectionOrTimeChanged()),!o&&this.beginDrag("move",l.sourceId,l.shape,e)}beginDrag(t,e,n,s,r){this.dragState={kind:t,sourceId:e,original:n,handle:r,startPointer:s},this.startDragListening()}beginCameraDrag(t){this.cameraDragState={startPointer:t,startHeadingDeg:this.numberOrUndefined(this.headingInput.value)??0,startPitchDeg:this.numberOrUndefined(this.pitchInput.value)??0},this.sceneElement.setCompassForced(!0),this.startDragListening()}startDragListening(){document.addEventListener("pointermove",this.handleDragPointerMove),document.addEventListener("pointerup",this.handleDragPointerUp)}onDragPointerMove(t){if(this.cameraDragState){this.onCameraDragPointerMove(t);return}if(!this.dragState)return;const e=this.canvasPointFromEvent(t);if(!e)return;const{kind:n,sourceId:s,original:r,handle:a,startPointer:o}=this.dragState,l=n==="move"?{...r,bounds:{...r.bounds,x:r.bounds.x+(e.x-o.x),y:r.bounds.y+(e.y-o.y)}}:n==="resize"?Ld(r,a,e):Ud(r,e);this.ufoElement.sighting.timeline.addKeyframe(this.ufoElement.currentTime,[{sourceId:s,shape:l}]),this.ufoElement.refresh()}onCameraDragPointerMove(t){if(!this.cameraDragState)return;const e=this.canvasPointFromEvent(t);if(!e)return;const{startPointer:n,startHeadingDeg:s,startPitchDeg:r}=this.cameraDragState,a=s+(e.x-n.x)*Fh,o=Math.max(-90,Math.min(90,r-(e.y-n.y)*Fh));this.headingInput.value=String(a),this.pitchInput.value=String(o),this.updateObserver()}endDrag(){!this.dragState&&!this.cameraDragState||(this.cameraDragState&&this.sceneElement.setCompassForced(!1),this.dragState=void 0,this.cameraDragState=void 0,document.removeEventListener("pointermove",this.handleDragPointerMove),document.removeEventListener("pointerup",this.handleDragPointerUp))}moveOrResizeSelectedShape(t){if(this.isRecording||this.ufoElement.playbackState==="playing")return;const e=this.ufoElement.sighting.timeline,n=this.ufoElement.currentTime,s=e.getInterpolatedShapeAt(n,this.currentSourceId);if(!s)return;const r={...s.bounds};if(t.shiftKey){switch(t.key){case"ArrowLeft":r.width=Math.max(ki,r.width-Vn);break;case"ArrowRight":r.width+=Vn;break;case"ArrowUp":r.height=Math.max(ki,r.height-Vn);break;case"ArrowDown":r.height+=Vn;break}r.x-=(r.width-s.bounds.width)/2,r.y-=(r.height-s.bounds.height)/2}else switch(t.key){case"ArrowLeft":r.x-=Vn;break;case"ArrowRight":r.x+=Vn;break;case"ArrowUp":r.y-=Vn;break;case"ArrowDown":r.y+=Vn;break}t.preventDefault(),e.addKeyframe(n,[{sourceId:this.currentSourceId,shape:{...s,bounds:r}}]),this.ufoElement.refresh()}onPointerMove(t){if(!this.isRecording)return;const e=this.ufoElement.canvasElement,n=e.getBoundingClientRect(),s=t.clientX-n.left,r=t.clientY-n.top;this.recorder?.onPointerMove(s,r),this.ufoElement.renderer.clear(e.width,e.height),this.ufoElement.renderer.paintShape(Hh(this.buildPrototype({x:0,y:0,width:Oi.width,height:Oi.height}),s,r))}canvasPointFromEvent(t){const e=this.ufoElement.canvasElement,n=e.getBoundingClientRect();if(!(n.width===0||n.height===0))return{x:(t.clientX-n.left)/n.width*e.width,y:(t.clientY-n.top)/n.height*e.height}}}const zh="rr0-ufo-recorder";function h2(){$r(),customElements.get(zh)||customElements.define(zh,c2)}h2();
|
|
4732
|
+
`;let yr;function Vx(){if(yr)return yr;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),yr=new Kn(e),yr}function Wx(i){const t=document.createElement("canvas");t.width=128,t.height=128;const n=t.getContext("2d"),s=128/2-2,r=128/2,a=128/2,o="#2e2b26",l="#f4f1e2";n.fillStyle=o,n.beginPath(),n.arc(r,a,s,0,Math.PI*2),n.fill();const c=Qu(i.illuminatedFraction,0,1),h=i.phaseFraction<.5,d=s*Math.abs(1-2*c),u=c<.5;return n.save(),n.beginPath(),n.arc(r,a,s,0,Math.PI*2),n.clip(),n.fillStyle=l,n.beginPath(),h?(n.arc(r,a,s,-Math.PI/2,Math.PI/2,!1),n.ellipse(r,a,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 Kn(t)}function Xx(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 Kn(e)}function Ya(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 Dh=new Map;function qx(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 Yx(i){let e=Dh.get(i);return e||(e=fetch(i).then(t=>t.arrayBuffer()).then(qx),Dh.set(i,e)),e}const Zx=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,Kx=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,$x=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href;class Jx{context;buffers=new Map;ambientSource;ambientGain;ambientKey="none";ambientToken=0;ambientVolume=0;windSource;windGain;windActive=!1;windToken=0;windVolume=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.context)return;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(Zx,this.ambientVolume).then(o=>this.applyIfCurrent(o,a,()=>this.ambientToken,l=>{this.ambientSource=l?.source,this.ambientGain=l?.gain,l&&(l.gain.gain.value=this.ambientVolume)}))}else this.ambientGain&&(this.ambientGain.gain.value=this.ambientVolume);this.windVolume=n;const r=n>.03;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(Kx,this.windVolume).then(o=>this.applyIfCurrent(o,a,()=>this.windToken,l=>{this.windSource=l?.source,this.windGain=l?.gain,l&&(l.gain.gain.value=this.windVolume)}))}else this.windGain&&(this.windGain.gain.value=this.windVolume)}playThunder(){this.context&&this.playOneShot($x,.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()}}Zr();const Qx={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"}},jx=["en","fr"],e2=new URL(""+new URL("stars-mag7.5-DDr9QasD.bin",import.meta.url).href,import.meta.url).href,t2={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},Za={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class n2 extends HTMLElement{static get observedAttributes(){return["src","star-catalog-src","show-compass"]}shadow;stageElement;frameElement;sceneCanvas;ufoElement;sceneRenderer;bodyTooltip;terrainAttributionElement;shownTerrainAttribution;resizeObserver;lastTimeMs=0;starCatalog;weatherAudio=new Jx;thunderTimeoutId;handleFullscreenChange=()=>this.resizeToStage();handlePointerMove=e=>{this.sceneRenderer.setCompassHovered(!0);const n=this.ufoElement.canvasElement.getBoundingClientRect();if(n.width===0||n.height===0)return;const s=(e.clientX-n.left)/n.width*2-1,r=-((e.clientY-n.top)/n.height*2-1),a=this.sceneRenderer.pickBodyAt(s,r);if(!a){this.bodyTooltip.hidden=!0;return}const o=fl(navigator.languages,jx);this.bodyTooltip.textContent=Qx[a]?.[o]??a,this.bodyTooltip.hidden=!1;const l=this.stageElement.getBoundingClientRect();this.bodyTooltip.style.left=`${e.clientX-l.left+12}px`,this.bodyTooltip.style.top=`${e.clientY-l.top+12}px`};handlePointerLeave=()=>{this.bodyTooltip.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(this.ufoElement.sighting.weather)};handleTimeUpdate=e=>{this.lastTimeMs=e.detail.time,this.updateAstronomy(this.lastTimeMs)};constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${qd}</style>${Xd}`,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 Ux(this.sceneCanvas,void 0,this.handleLightningFlash),this.bodyTooltip=this.shadow.getElementById("body-tooltip"),this.terrainAttributionElement=this.shadow.getElementById("terrain-attribution"),this.ufoElement=document.createElement(Ja),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){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"))}setCompassForced(e){this.sceneRenderer.setCompassForced(e)}setWeather(e){const t=e??Dl;this.sceneRenderer.setWeather(t),this.weatherAudio.setAmbient(t.precipitationType,t.precipitationIntensity,t.windSpeed)}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),this.setWeather(this.ufoElement.sighting.weather)}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")??e2;this.starCatalog=await Yx(e),this.updateAstronomy(this.lastTimeMs)}updateAstronomy(e){const t=this.ufoElement.sighting,n=Ad(t,e);this.sceneRenderer.setObserverPose(n??Za),this.sceneRenderer.setTerrainOrigin(n?.lat,n?.lng,()=>this.updateTerrainAttribution()),this.updateTerrainAttribution();const s=n?.lat??Za.lat,r=n?.lng??Za.lng,a=Rv(t.event.time??{},r);if(!a){this.sceneRenderer.setAstronomy(t2);return}const o=new Date(a.getTime()+e),l={lat:s,lng:r,elevationM:n?.elevationM??0},c={...Ga("Sun",o,l),magnitude:Ha("Sun",o)},h={...Ga("Moon",o,l),phase:bv(o),magnitude:Ha("Moon",o)},d=yv.map(u=>({body:u,position:Ga(u,o,l),magnitude:Ha(u,o)}));this.sceneRenderer.setAstronomy({sun:c,moon:h,planets:d,stars:this.starCatalog?{catalog:this.starCatalog,date:o,observer:l}:void 0})}updateTerrainAttribution(){const e=this.sceneRenderer.currentTerrainAttribution;e!==this.shownTerrainAttribution&&(this.shownTerrainAttribution=e,this.terrainAttributionElement.textContent=e??"",this.terrainAttributionElement.hidden=!e)}}const ul="rr0-scene";function i2(){Zr(),customElements.get(ul)||customElements.define(ul,n2)}class s2{constructor(e,t){this.timeline=e,this.clock=t}currentPointer=null;shapePrototype=null;sourceId="";start(e,t){this.sourceId=e,this.shapePrototype=t,this.currentPointer=null,this.clock.start(n=>this.recordSample(n))}onPointerMove(e,t){this.currentPointer={x:e,y:t}}stop(){this.clock.stop()}recordSample(e){if(!this.currentPointer||!this.shapePrototype)return;const t=Bh(this.shapePrototype,this.currentPointer.x,this.currentPointer.y);this.timeline.addKeyframe(e,[{sourceId:this.sourceId,shape:t}])}}class r2{constructor(e){this.intervalMs=e}rafId=null;startTime=0;lastTick=0;start(e){this.startTime=performance.now(),this.lastTick=0;const t=()=>{const n=performance.now()-this.startTime;n-this.lastTick>=this.intervalMs&&(this.lastTick=n,e(n)),this.rafId=requestAnimationFrame(t)};this.rafId=requestAnimationFrame(t)}stop(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}}const ju={oval:"Oval",saucer:"Saucer",triangle:"Triangle",color:"Color",transparency:"Transparency",halo:"Halo",shape:"Shape",addShape:"Add shape",samplingRate:"Sampling rate (ms)",duration:"Duration (s)",durationPlaceholder:"recording length",export:"Export JSON",record:"Record",stop:"Stop",latitude:"Latitude",longitude:"Longitude",heading:"Heading (°)",headingPlaceholder:"unknown",pitch:"Tilt (°)",observationTime:"Observation start (optional)",yearPlaceholder:"year",monthPlaceholder:"month",dayPlaceholder:"day",hourPlaceholder:"hour",minutePlaceholder:"min",weather:"Weather",cloudCover:"Cloud cover",cloudDarkness:"Cloud darkness",precipitationType:"Precipitation",precipitationNone:"None",precipitationRain:"Rain",precipitationSnow:"Snow",precipitationHail:"Hail",precipitationIntensity:"Intensity",windDirection:"Wind direction (°)",windSpeed:"Wind speed",lightning:"Lightning"},a2=Object.freeze(Object.defineProperty({__proto__:null,ufoRecorderMessages_en:ju},Symbol.toStringTag,{value:"Module"}));Zr();i2();const Oi={width:48,height:28},Lh=.2,o2=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"]),Hn=4,Uh="ufo-1",Nh=["oval","saucer","triangle"],l2={presetId:"oval",color:"#39ff14",transparency:0,haloScale:1.5};function c2(i){if(i.kind==="oval")return"oval";if(i.points.length===3)return"triangle";if(i.points.length===8)return"saucer"}class h2 extends HTMLElement{shadow;sceneElement;ufoElement;recordButton;samplingRateInput;presetButtons;colorInput;transparencyInput;haloScaleInput;sourceSelect;addShapeButton;durationInput;exportButton;latInput;lngInput;headingInput;pitchInput;obsYearInput;obsMonthInput;obsDayInput;obsHourInput;obsMinuteInput;cloudCoverInput;cloudDarknessInput;precipitationTypeSelect;precipitationIntensityInput;windDirectionInput;windSpeedInput;lightningInput;labelColor;labelTransparency;labelHalo;labelShape;labelSamplingRate;labelDuration;labelLatitude;labelLongitude;labelHeading;labelPitch;labelObservationTime;labelWeather;labelCloudCover;labelCloudDarkness;labelPrecipitationType;labelPrecipitationIntensity;labelWindDirection;labelWindSpeed;labelLightning;optionPrecipitationNone;optionPrecipitationRain;optionPrecipitationSnow;optionPrecipitationHail;recorder;isRecording=!1;messages=ju;currentAppearance={...l2};currentSourceId=Uh;dragState;cameraDragState;handleKeyDown=e=>{if(e.key==="Escape"&&this.isRecording&&this.toggleRecording(),o2.has(e.key)){const t=e.composedPath()[0];if(t instanceof HTMLInputElement||t instanceof HTMLSelectElement||t instanceof HTMLTextAreaElement)return;this.moveOrResizeSelectedShape(e)}};handleDragPointerMove=e=>this.onDragPointerMove(e);handleDragPointerUp=()=>this.endDrag();constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${ld}</style>${od}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.sceneElement=document.createElement(ul),this.sceneElement.setAttribute("show-compass",""),this.ufoElement=this.sceneElement.ufoElement,this.ufoElement.enableClickToPlay=!1,this.shadow.getElementById("ufo-slot").replaceWith(this.sceneElement),this.recordButton=this.shadow.getElementById("record"),this.samplingRateInput=this.shadow.getElementById("samplingRate"),this.presetButtons={oval:this.shadow.getElementById("preset-oval"),saucer:this.shadow.getElementById("preset-saucer"),triangle:this.shadow.getElementById("preset-triangle")},this.colorInput=this.shadow.getElementById("color"),this.transparencyInput=this.shadow.getElementById("transparency"),this.haloScaleInput=this.shadow.getElementById("haloScale"),this.sourceSelect=this.shadow.getElementById("source"),this.addShapeButton=this.shadow.getElementById("add-shape"),this.durationInput=this.shadow.getElementById("durationSeconds"),this.exportButton=this.shadow.getElementById("export"),this.latInput=this.shadow.getElementById("lat"),this.lngInput=this.shadow.getElementById("lng"),this.headingInput=this.shadow.getElementById("heading"),this.pitchInput=this.shadow.getElementById("pitch"),this.obsYearInput=this.shadow.getElementById("obs-year"),this.obsMonthInput=this.shadow.getElementById("obs-month"),this.obsDayInput=this.shadow.getElementById("obs-day"),this.obsHourInput=this.shadow.getElementById("obs-hour"),this.obsMinuteInput=this.shadow.getElementById("obs-minute"),this.cloudCoverInput=this.shadow.getElementById("cloudCover"),this.cloudDarknessInput=this.shadow.getElementById("cloudDarkness"),this.precipitationTypeSelect=this.shadow.getElementById("precipitationType"),this.precipitationIntensityInput=this.shadow.getElementById("precipitationIntensity"),this.windDirectionInput=this.shadow.getElementById("windDirection"),this.windSpeedInput=this.shadow.getElementById("windSpeed"),this.lightningInput=this.shadow.getElementById("lightning"),this.labelColor=this.shadow.getElementById("label-color"),this.labelTransparency=this.shadow.getElementById("label-transparency"),this.labelHalo=this.shadow.getElementById("label-halo"),this.labelShape=this.shadow.getElementById("label-shape"),this.labelSamplingRate=this.shadow.getElementById("label-sampling-rate"),this.labelDuration=this.shadow.getElementById("label-duration"),this.labelLatitude=this.shadow.getElementById("label-lat"),this.labelLongitude=this.shadow.getElementById("label-lng"),this.labelHeading=this.shadow.getElementById("label-heading"),this.labelPitch=this.shadow.getElementById("label-pitch"),this.labelObservationTime=this.shadow.getElementById("label-observation-time"),this.labelWeather=this.shadow.getElementById("label-weather"),this.labelCloudCover=this.shadow.getElementById("label-cloud-cover"),this.labelCloudDarkness=this.shadow.getElementById("label-cloud-darkness"),this.labelPrecipitationType=this.shadow.getElementById("label-precipitation-type"),this.labelPrecipitationIntensity=this.shadow.getElementById("label-precipitation-intensity"),this.labelWindDirection=this.shadow.getElementById("label-wind-direction"),this.labelWindSpeed=this.shadow.getElementById("label-wind-speed"),this.labelLightning=this.shadow.getElementById("label-lightning"),this.optionPrecipitationNone=this.shadow.getElementById("option-precipitation-none"),this.optionPrecipitationRain=this.shadow.getElementById("option-precipitation-rain"),this.optionPrecipitationSnow=this.shadow.getElementById("option-precipitation-snow"),this.optionPrecipitationHail=this.shadow.getElementById("option-precipitation-hail"),this.ufoElement.canvasElement.addEventListener("pointerdown",t=>this.onPointerDown(t)),this.ufoElement.canvasElement.addEventListener("pointermove",t=>this.onPointerMove(t)),this.recordButton.addEventListener("click",()=>this.toggleRecording()),this.addShapeButton.addEventListener("click",()=>this.addShape()),this.exportButton.addEventListener("click",()=>this.exportJson()),this.durationInput.addEventListener("input",()=>{this.ufoElement.durationSeconds=this.durationInput.value===""?void 0:Number(this.durationInput.value),this.ufoElement.refresh()}),this.sourceSelect.addEventListener("change",()=>{this.currentSourceId=this.sourceSelect.value,this.onSelectionOrTimeChanged()}),this.ufoElement.addEventListener("timeupdate",()=>{this.onSelectionOrTimeChanged(),this.dispatchEvent(new CustomEvent("sightingchange"))}),document.addEventListener("keydown",this.handleKeyDown);for(const t of Nh)this.presetButtons[t].addEventListener("click",()=>this.setAppearance({presetId:t}));this.colorInput.addEventListener("input",()=>this.setAppearance({color:this.colorInput.value})),this.transparencyInput.addEventListener("input",()=>this.setAppearance({transparency:Number(this.transparencyInput.value)})),this.haloScaleInput.addEventListener("input",()=>this.setAppearance({haloScale:Number(this.haloScaleInput.value)}));for(const t of[this.latInput,this.lngInput,this.headingInput,this.pitchInput])t.addEventListener("input",()=>this.updateObserver());this.headingInput.addEventListener("focus",()=>this.sceneElement.setCompassForced(!0)),this.headingInput.addEventListener("blur",()=>this.sceneElement.setCompassForced(!1));for(const t of[this.obsYearInput,this.obsMonthInput,this.obsDayInput,this.obsHourInput,this.obsMinuteInput])t.addEventListener("input",()=>this.updateObservationTime());for(const t of[this.cloudCoverInput,this.cloudDarknessInput,this.precipitationTypeSelect,this.precipitationIntensityInput,this.windDirectionInput,this.windSpeedInput,this.lightningInput])t.addEventListener("input",()=>this.updateWeather());this.updatePresetButtons(),this.setRecordButtonLabel(!1),this.applyAppearanceAtPlayhead(),this.refreshSourceList(),this.onSelectionOrTimeChanged(),this.loadLocaleMessages()}disconnectedCallback(){document.removeEventListener("keydown",this.handleKeyDown),this.endDrag()}get sightingData(){return this.ufoElement.sightingData}set sightingData(e){this.endDrag(),this.ufoElement.sightingData=e,this.currentSourceId=this.ufoElement.sighting.timeline.sourceIds[0]??Uh,this.refreshSourceList(),this.onSelectionOrTimeChanged(),this.durationInput.value=this.ufoElement.durationSeconds!==void 0?String(this.ufoElement.durationSeconds):"",this.syncObservationTimeFields(),this.syncWeatherFromSighting(),this.sceneElement.setWeather(this.ufoElement.sighting.weather)}exportJson(){const e=this.sightingData,t=`${e.witnessId??"sighting"}-sighting.json`,n=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),s=URL.createObjectURL(n),r=document.createElement("a");r.href=s,r.download=t,r.click(),URL.revokeObjectURL(s)}numberOrUndefined(e){return e===""?void 0:Number(e)}wrapDegrees(e,t){if(e===void 0)return;const n=(e%360+360)%360;return String(n)!==t.value&&(t.value=String(n)),n}updateObserver(){if(this.ufoElement.playbackState==="playing")return;const e=this.numberOrUndefined(this.latInput.value),t=this.numberOrUndefined(this.lngInput.value),n=this.wrapDegrees(this.numberOrUndefined(this.headingInput.value),this.headingInput),s=this.numberOrUndefined(this.pitchInput.value)??0,r=this.ufoElement.sighting.event,a=this.ufoElement.sighting.observerTrack,o=this.ufoElement.currentTime;r.place=e!==void 0&&t!==void 0?[{lat:e,lng:t}]:void 0,e===void 0&&t===void 0&&n===void 0&&s===0?a.removeKeyframeAt(o):a.addKeyframe(o,{lat:e,lng:t,elevationM:0,headingDeg:n,pitchDeg:s,fovDeg:60}),this.ufoElement.refresh()}updateObservationTime(){const e=this.numberOrUndefined(this.obsYearInput.value),t=this.numberOrUndefined(this.obsMonthInput.value),n=this.numberOrUndefined(this.obsDayInput.value),s=this.numberOrUndefined(this.obsHourInput.value),r=this.numberOrUndefined(this.obsMinuteInput.value),a=this.ufoElement.sighting.event;a.time=e===void 0&&t===void 0&&n===void 0&&s===void 0&&r===void 0?void 0:{year:e,month:t,day:n,hour:s,minute:r},this.ufoElement.refresh()}updateWeather(){this.sceneElement.resumeWeatherAudio();const e=this.ufoElement.sighting,t={cloudCover:Number(this.cloudCoverInput.value),cloudDarkness:Number(this.cloudDarknessInput.value),precipitationType:this.precipitationTypeSelect.value,precipitationIntensity:Number(this.precipitationIntensityInput.value),windDirectionDeg:this.wrapDegrees(this.numberOrUndefined(this.windDirectionInput.value),this.windDirectionInput)??0,windSpeed:Number(this.windSpeedInput.value),lightning:this.lightningInput.checked};e.weather=t,this.sceneElement.setWeather(t)}syncObservationTimeFields(){const e=this.ufoElement.sighting.event;this.obsYearInput.value=e.time?.year!==void 0?String(e.time.year):"",this.obsMonthInput.value=e.time?.month!==void 0?String(e.time.month):"",this.obsDayInput.value=e.time?.day!==void 0?String(e.time.day):"",this.obsHourInput.value=e.time?.hour!==void 0?String(e.time.hour):"",this.obsMinuteInput.value=e.time?.minute!==void 0?String(e.time.minute):""}syncWeatherFromSighting(){const e=this.ufoElement.sighting.weather??Dl;this.cloudCoverInput.value=String(e.cloudCover),this.cloudDarknessInput.value=String(e.cloudDarkness),this.precipitationTypeSelect.value=e.precipitationType,this.precipitationIntensityInput.value=String(e.precipitationIntensity),this.windDirectionInput.value=String(e.windDirectionDeg),this.windSpeedInput.value=String(e.windSpeed),this.lightningInput.checked=e.lightning}syncObserverFromTimeline(){if(this.ufoElement.playbackState==="playing")return;const e=this.ufoElement.sighting,t=e.observerTrack.getInterpolatedPoseAt(this.ufoElement.currentTime),n=e.event.place?.[0],s=this.shadow.activeElement;s!==this.latInput&&(this.latInput.value=t?.lat!==void 0?String(t.lat):n?String(n.lat):""),s!==this.lngInput&&(this.lngInput.value=t?.lng!==void 0?String(t.lng):n?String(n.lng):""),s!==this.headingInput&&(this.headingInput.value=t?.headingDeg!==void 0?String(t.headingDeg):""),s!==this.pitchInput&&(this.pitchInput.value=String(t?.pitchDeg??0))}get appearance(){return{...this.currentAppearance}}set appearance(e){this.setAppearance(e)}setAppearance(e){this.currentAppearance={...this.currentAppearance,...e},this.updatePresetButtons(),!(this.isRecording||this.ufoElement.playbackState==="playing")&&this.applyAppearanceAtPlayhead()}applyAppearanceAtPlayhead(e){const t=this.ufoElement.sighting.timeline,n=this.ufoElement.currentTime,s=t.getInterpolatedShapeAt(n,this.currentSourceId),r=this.buildAppearanceShape(e??s?.bounds??this.defaultBounds(),s);t.addKeyframe(n,[{sourceId:this.currentSourceId,shape:r}]),this.ufoElement.refresh()}buildAppearanceShape(e,t){const n=Hl(e,this.currentAppearance);return t?{...n,angle:t.angle,title:t.title,selected:t.selected}:n}onSelectionOrTimeChanged(){this.syncAppearanceFromTimeline(),this.syncObserverFromTimeline(),this.ufoElement.selectedSourceId=this.currentSourceId}syncAppearanceFromTimeline(){if(this.ufoElement.playbackState==="playing")return;const e=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(this.ufoElement.currentTime,this.currentSourceId);e&&(this.currentAppearance={presetId:c2(e)??this.currentAppearance.presetId,color:e.color,transparency:e.transparency,haloScale:e.haloScale},this.updatePresetButtons(),this.colorInput.value=this.currentAppearance.color,this.transparencyInput.value=String(this.currentAppearance.transparency),this.haloScaleInput.value=String(this.currentAppearance.haloScale))}addShape(){if(this.isRecording)return;const e=this.ufoElement.sighting.timeline,t=new Set([...e.sourceIds,this.currentSourceId]);let n=t.size+1;for(;t.has(`ufo-${n}`);)n++;this.currentSourceId=`ufo-${n}`,this.applyAppearanceAtPlayhead(this.offsetDefaultBounds(e.sourceIds.length)),this.refreshSourceList()}offsetDefaultBounds(e){const t=this.defaultBounds(),n=24;return{...t,x:t.x+e*n,y:t.y+e*n}}refreshSourceList(){const e=this.ufoElement.sighting.timeline,t=[...new Set([...e.sourceIds,this.currentSourceId])];this.sourceSelect.innerHTML="";for(const n of t){const s=document.createElement("option");s.value=n,s.textContent=n,this.sourceSelect.appendChild(s)}this.sourceSelect.value=this.currentSourceId}updatePresetButtons(){for(const e of Nh)this.presetButtons[e]?.setAttribute("aria-pressed",String(e===this.currentAppearance.presetId))}get samplingRate(){return Number(this.samplingRateInput.value)}buildPrototype(e=this.defaultBounds()){return Hl(e,this.currentAppearance)}defaultBounds(){const e=this.ufoElement.canvasElement;return{x:e.width/2-Oi.width/2,y:e.height/2-Oi.height/2,width:Oi.width,height:Oi.height}}toggleRecording(){this.endDrag();const e=this.ufoElement.canvasElement;this.isRecording?(this.recorder?.stop(),this.isRecording=!1,this.setRecordButtonLabel(!1),e.style.cursor="",e.style.touchAction="",this.sourceSelect.disabled=!1,this.addShapeButton.disabled=!1,this.ufoElement.refresh(),this.refreshSourceList()):(this.recorder=new s2(this.ufoElement.sighting.timeline,new r2(this.samplingRate)),this.recorder.start(this.currentSourceId,this.buildPrototype()),this.isRecording=!0,this.setRecordButtonLabel(!0),e.style.cursor="crosshair",e.style.touchAction="none",this.sourceSelect.disabled=!0,this.addShapeButton.disabled=!0)}setRecordButtonLabel(e){this.recordButton.textContent=e?"⏹":"⏺";const t=e?this.messages.stop:this.messages.record;this.recordButton.title=t,this.recordButton.setAttribute("aria-label",t)}async loadLocaleMessages(){const e=fl(navigator.languages,Hh);e!=="en"&&this.applyMessages(await Hd(e))}applyMessages(e){this.messages=e,this.presetButtons.oval.textContent=e.oval,this.presetButtons.saucer.textContent=e.saucer,this.presetButtons.triangle.textContent=e.triangle,this.labelColor.textContent=e.color,this.labelTransparency.textContent=e.transparency,this.labelHalo.textContent=e.halo,this.labelShape.textContent=e.shape,this.labelSamplingRate.textContent=e.samplingRate,this.labelDuration.textContent=e.duration,this.durationInput.placeholder=e.durationPlaceholder,this.addShapeButton.textContent=e.addShape,this.exportButton.textContent=e.export,this.labelLatitude.textContent=e.latitude,this.labelLongitude.textContent=e.longitude,this.labelHeading.textContent=e.heading,this.headingInput.placeholder=e.headingPlaceholder,this.labelPitch.textContent=e.pitch,this.labelObservationTime.textContent=e.observationTime,this.obsYearInput.placeholder=e.yearPlaceholder,this.obsMonthInput.placeholder=e.monthPlaceholder,this.obsDayInput.placeholder=e.dayPlaceholder,this.obsHourInput.placeholder=e.hourPlaceholder,this.obsMinuteInput.placeholder=e.minutePlaceholder,this.labelWeather.textContent=e.weather,this.labelCloudCover.textContent=e.cloudCover,this.labelCloudDarkness.textContent=e.cloudDarkness,this.labelPrecipitationType.textContent=e.precipitationType,this.optionPrecipitationNone.textContent=e.precipitationNone,this.optionPrecipitationRain.textContent=e.precipitationRain,this.optionPrecipitationSnow.textContent=e.precipitationSnow,this.optionPrecipitationHail.textContent=e.precipitationHail,this.labelPrecipitationIntensity.textContent=e.precipitationIntensity,this.labelWindDirection.textContent=e.windDirection,this.labelWindSpeed.textContent=e.windSpeed,this.labelLightning.textContent=e.lightning,this.setRecordButtonLabel(this.isRecording)}onPointerDown(e){if(this.isRecording){this.onPointerMove(e);return}const t=this.canvasPointFromEvent(e);if(!t)return;const n=this.ufoElement.sighting.timeline,s=this.ufoElement.currentTime,r=n.getInterpolatedShapeAt(s,this.currentSourceId),a=r&&Cd(r,t),o=this.ufoElement.playbackState==="playing";if(r&&a){if(o)return;this.beginDrag(a==="rotate"?"rotate":"resize",this.currentSourceId,r,t,a);return}const l=n.hitTest(s,t.x,t.y);if(!l){o||this.beginCameraDrag(t);return}l.sourceId!==this.currentSourceId&&(this.currentSourceId=l.sourceId,this.refreshSourceList(),this.onSelectionOrTimeChanged()),!o&&this.beginDrag("move",l.sourceId,l.shape,t)}beginDrag(e,t,n,s,r){this.dragState={kind:e,sourceId:t,original:n,handle:r,startPointer:s},this.startDragListening()}beginCameraDrag(e){this.cameraDragState={startPointer:e,startHeadingDeg:this.numberOrUndefined(this.headingInput.value)??0,startPitchDeg:this.numberOrUndefined(this.pitchInput.value)??0},this.sceneElement.setCompassForced(!0),this.startDragListening()}startDragListening(){document.addEventListener("pointermove",this.handleDragPointerMove),document.addEventListener("pointerup",this.handleDragPointerUp)}onDragPointerMove(e){if(this.cameraDragState){this.onCameraDragPointerMove(e);return}if(!this.dragState)return;const t=this.canvasPointFromEvent(e);if(!t)return;const{kind:n,sourceId:s,original:r,handle:a,startPointer:o}=this.dragState,l=n==="move"?{...r,bounds:{...r.bounds,x:r.bounds.x+(t.x-o.x),y:r.bounds.y+(t.y-o.y)}}:n==="resize"?Id(r,a,t):Dd(r,t);this.ufoElement.sighting.timeline.addKeyframe(this.ufoElement.currentTime,[{sourceId:s,shape:l}]),this.ufoElement.refresh()}onCameraDragPointerMove(e){if(!this.cameraDragState)return;const t=this.canvasPointFromEvent(e);if(!t)return;const{startPointer:n,startHeadingDeg:s,startPitchDeg:r}=this.cameraDragState,a=s+(t.x-n.x)*Lh,o=Math.max(-90,Math.min(90,r-(t.y-n.y)*Lh));this.headingInput.value=String(a),this.pitchInput.value=String(o),this.updateObserver()}endDrag(){!this.dragState&&!this.cameraDragState||(this.cameraDragState&&this.sceneElement.setCompassForced(!1),this.dragState=void 0,this.cameraDragState=void 0,document.removeEventListener("pointermove",this.handleDragPointerMove),document.removeEventListener("pointerup",this.handleDragPointerUp))}moveOrResizeSelectedShape(e){if(this.isRecording||this.ufoElement.playbackState==="playing")return;const t=this.ufoElement.sighting.timeline,n=this.ufoElement.currentTime,s=t.getInterpolatedShapeAt(n,this.currentSourceId);if(!s)return;const r={...s.bounds};if(e.shiftKey){switch(e.key){case"ArrowLeft":r.width=Math.max(zi,r.width-Hn);break;case"ArrowRight":r.width+=Hn;break;case"ArrowUp":r.height=Math.max(zi,r.height-Hn);break;case"ArrowDown":r.height+=Hn;break}r.x-=(r.width-s.bounds.width)/2,r.y-=(r.height-s.bounds.height)/2}else switch(e.key){case"ArrowLeft":r.x-=Hn;break;case"ArrowRight":r.x+=Hn;break;case"ArrowUp":r.y-=Hn;break;case"ArrowDown":r.y+=Hn;break}e.preventDefault(),t.addKeyframe(n,[{sourceId:this.currentSourceId,shape:{...s,bounds:r}}]),this.ufoElement.refresh()}onPointerMove(e){if(!this.isRecording)return;const t=this.ufoElement.canvasElement,n=t.getBoundingClientRect(),s=e.clientX-n.left,r=e.clientY-n.top;this.recorder?.onPointerMove(s,r),this.ufoElement.renderer.clear(t.width,t.height),this.ufoElement.renderer.paintShape(Bh(this.buildPrototype({x:0,y:0,width:Oi.width,height:Oi.height}),s,r))}canvasPointFromEvent(e){const t=this.ufoElement.canvasElement,n=t.getBoundingClientRect();if(!(n.width===0||n.height===0))return{x:(e.clientX-n.left)/n.width*t.width,y:(e.clientY-n.top)/n.height*t.height}}}const Fh="rr0-ufo-recorder";function u2(){Zr(),customElements.get(Fh)||customElements.define(Fh,h2)}u2();
|