@rr0/ufoathome 0.3.0 → 0.4.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/{assets/UfoRecorderMessages_fr-DRl6tTYJ.js → UfoRecorderMessages_fr-DDDvsOhq.js} +1 -1
- package/dist-embed/rain-BvWZrB9h.ogg +0 -0
- package/dist-embed/rr0-ufo-recorder.mjs +358 -189
- package/dist-embed/thunder-DA48qs_v.wav +0 -0
- package/dist-embed/wind-BjklexY7.ogg +0 -0
- package/dist-embed-scene/rain-BvWZrB9h.ogg +0 -0
- package/dist-embed-scene/rr0-scene.mjs +337 -185
- package/dist-embed-scene/thunder-DA48qs_v.wav +0 -0
- package/dist-embed-scene/wind-BjklexY7.ogg +0 -0
- package/dist-embed-ufo/rr0-ufo.mjs +1 -1
- package/dist-embed-witnesses/rr0-ufo-witnesses.mjs +1 -1
- package/package.json +1 -1
- /package/dist-embed/{assets/UfoMessages_fr-COCxf8Q_.js → UfoMessages_fr-COCxf8Q_.js} +0 -0
- /package/dist-embed/{assets/stars-mag7.5-DDr9QasD.bin → stars-mag7.5-DDr9QasD.bin} +0 -0
- /package/dist-embed-scene/{assets/UfoMessages_fr-COCxf8Q_.js → UfoMessages_fr-COCxf8Q_.js} +0 -0
- /package/dist-embed-scene/{assets/stars-mag7.5-DDr9QasD.bin → stars-mag7.5-DDr9QasD.bin} +0 -0
- /package/dist-embed-ufo/{assets/UfoMessages_fr-COCxf8Q_.js → UfoMessages_fr-COCxf8Q_.js} +0 -0
- /package/dist-embed-witnesses/{assets/UfoMessages_fr-COCxf8Q_.js → UfoMessages_fr-COCxf8Q_.js} +0 -0
- /package/dist-embed-witnesses/{assets/WitnessSelectorMessages_en-D8xgZDfY.js → WitnessSelectorMessages_en-D8xgZDfY.js} +0 -0
- /package/dist-embed-witnesses/{assets/WitnessSelectorMessages_fr-C0GHqC_J.js → WitnessSelectorMessages_fr-C0GHqC_J.js} +0 -0
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Yu=`
|
|
2
2
|
<div class="stage" id="stage">
|
|
3
3
|
<div class="frame" id="frame">
|
|
4
4
|
<canvas id="scene-canvas"></canvas>
|
|
5
5
|
</div>
|
|
6
6
|
<div id="ufo-slot"></div>
|
|
7
7
|
<div id="body-tooltip" class="body-tooltip" hidden></div>
|
|
8
|
+
<div id="terrain-attribution" class="terrain-attribution" hidden></div>
|
|
8
9
|
</div>
|
|
9
|
-
`,
|
|
10
|
+
`,Zu=`
|
|
10
11
|
:host {
|
|
11
12
|
display: block;
|
|
12
13
|
}
|
|
@@ -73,7 +74,22 @@ const K0=`
|
|
|
73
74
|
pointer-events: none;
|
|
74
75
|
white-space: nowrap;
|
|
75
76
|
}
|
|
76
|
-
|
|
77
|
+
/* Bottom-right credit line required by the active terrain imagery provider's license (see
|
|
78
|
+
SceneRenderer.currentTerrainAttribution) — a fixed corner, unlike .body-tooltip's JS-driven
|
|
79
|
+
follow-the-pointer position, since this isn't tied to any one point on screen. */
|
|
80
|
+
.terrain-attribution {
|
|
81
|
+
position: absolute;
|
|
82
|
+
right: 4px;
|
|
83
|
+
bottom: 4px;
|
|
84
|
+
z-index: 1;
|
|
85
|
+
padding: 1px 4px;
|
|
86
|
+
background: rgba(0, 0, 0, 0.4);
|
|
87
|
+
color: rgba(255, 255, 255, 0.7);
|
|
88
|
+
font-family: sans-serif;
|
|
89
|
+
font-size: 0.65em;
|
|
90
|
+
pointer-events: none;
|
|
91
|
+
}
|
|
92
|
+
`,$u=`
|
|
77
93
|
<div class="stage" id="stage">
|
|
78
94
|
<div class="frame" id="frame">
|
|
79
95
|
<canvas id="canvas" width="640" height="360"></canvas>
|
|
@@ -87,7 +103,7 @@ const K0=`
|
|
|
87
103
|
<button id="loop" type="button" title="Auto-replay" aria-label="Auto-replay" aria-pressed="true">↻</button>
|
|
88
104
|
</div>
|
|
89
105
|
</div>
|
|
90
|
-
`,
|
|
106
|
+
`,Ku=`
|
|
91
107
|
:host {
|
|
92
108
|
display: block;
|
|
93
109
|
font-family: sans-serif;
|
|
@@ -205,21 +221,21 @@ input[type=range] {
|
|
|
205
221
|
min-width: 3em;
|
|
206
222
|
text-align: center;
|
|
207
223
|
}
|
|
208
|
-
`;function Q0(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 Ht(i,e,t){return i+(e-i)*t}function ul(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 j0(i){return`#${i.map(e=>Math.round(e).toString(16).padStart(2,"0")).join("")}`}function eu(i,e,t){const n=ul(i),r=ul(e);return!n||!r?t<1?i:e:j0([Ht(n[0],r[0],t),Ht(n[1],r[1],t),Ht(n[2],r[2],t)])}function tu(i,e,t){const n={x:Ht(i.bounds.x,e.bounds.x,t),y:Ht(i.bounds.y,e.bounds.y,t),width:Ht(i.bounds.width,e.bounds.width,t),height:Ht(i.bounds.height,e.bounds.height,t)},r=Ht(i.angle,e.angle,t),s=Ht(i.transparency,e.transparency,t),a=Ht(i.haloScale,e.haloScale,t),o=eu(i.color,e.color,t);return i.kind==="polygon"&&e.kind==="polygon"&&i.points.length===e.points.length?{...i,bounds:n,angle:r,transparency:s,haloScale:a,color:o,points:i.points.map((l,c)=>({x:Ht(l.x,e.points[c].x,t),y:Ht(l.y,e.points[c].y,t)}))}:{...t<1?i:e,bounds:n,angle:r,transparency:s,haloScale:a,color:o}}class Es{keyframes=[];addKeyframe(e,t){const n=this.findInsertIndex(e);if(this.keyframes[n]?.t===e){const r=new Set(t.map(s=>s.sourceId));this.keyframes[n]={t:e,shapes:[...this.keyframes[n].shapes.filter(s=>!r.has(s.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 r=t+n>>>1;this.keyframes[r].t<e?t=r+1:n=r}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 r=this.keyframes[n].shapes.find(s=>s.sourceId===t);if(r)return r.shape}}getInterpolatedShapeAt(e,t){const n=this.findShapeAtOrBefore(e,t);if(n?.t===e)return n.shape;const r=this.findShapeAtOrAfter(e,t);return n?r?tu(n.shape,r.shape,(e-n.t)/(r.t-n.t)):n.shape:r?.shape}findShapeAtOrBefore(e,t){let n=this.findInsertIndex(e);for(this.keyframes[n]?.t!==e&&(n-=1);n>=0;n--){const r=this.keyframes[n].shapes.find(s=>s.sourceId===t);if(r)return{t:this.keyframes[n].t,shape:r.shape}}}findShapeAtOrAfter(e,t){for(let n=this.findInsertIndex(e);n<this.keyframes.length;n++){const r=this.keyframes[n].shapes.find(s=>s.sourceId===t);if(r)return{t:this.keyframes[n].t,shape:r.shape}}}hitTest(e,t,n){const r=this.sourceIds;for(let s=r.length-1;s>=0;s--){const a=this.getInterpolatedShapeAt(e,r[s]);if(a&&Q0(a,t,n))return{sourceId:r[s],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 Es;for(const n of e.keyframes)t.addKeyframe(n.t,n.shapes);return t}}function nu(i,e,t){return Math.max(e,Math.min(t,i))}function iu(i,e,t){const n=((e-i)%360+540)%360-180;return((i+n*t)%360+360)%360}function qi(i,e,t){return i+(e-i)*t}function ru(i,e,t){return{lat:i.lat===void 0||e.lat===void 0?void 0:qi(i.lat,e.lat,t),lng:i.lng===void 0||e.lng===void 0?void 0:qi(i.lng,e.lng,t),elevationM:qi(i.elevationM,e.elevationM,t),headingDeg:i.headingDeg===void 0||e.headingDeg===void 0?void 0:iu(i.headingDeg,e.headingDeg,t),pitchDeg:qi(i.pitchDeg,e.pitchDeg,t),fovDeg:qi(i.fovDeg,e.fovDeg,t)}}class cr{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}findInsertIndex(e){let t=0,n=this.keyframes.length;for(;t<n;){const r=t+n>>>1;this.keyframes[r].t<e?t=r+1:n=r}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 r=this.keyframes[t]?.t===e?void 0:this.keyframes[t];return n?r?ru(n.pose,r.pose,nu((e-n.t)/(r.t-n.t),0,1)):n.pose:r?.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 cr;for(const n of e.keyframes)t.addKeyframe(n.t,n.pose);return t}}function Ma(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 su(i){if(i.durationSeconds!==void 0)return i.durationSeconds*1e3;const e=i.time?Ma(i.time):void 0,t=i.endTime?Ma(i.endTime):void 0;return e!==void 0&&t!==void 0?t-e:void 0}class ys{constructor(e,t,n,r,s,a){this.event=e,this.timeline=t,this.observerTrack=n,this.witnessId=r,this.witnessName=s,this.caseId=a}static create(e,t,n){return new ys({eventType:"sighting",time:e,place:t},new Es,new cr,n)}}const au=0,ou=0,lu=60;function cu(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:au,headingDeg:void 0,pitchDeg:ou,fovDeg:lu}}class uu{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 r=this.timeline.getInterpolatedShapeAt(e,n);r&&t.set(n,r)}this.onFrame(e,t)}}const hu=["nw","n","ne","e","se","s","sw","w"],fu=24;function du(i,e,t){const n=i.x-e.x,r=i.y-e.y,s=Math.cos(t),a=Math.sin(t);return{x:e.x+n*s-r*a,y:e.y+n*a+r*s}}function pu(i){return{x:i.x+i.width/2,y:i.y+i.height/2}}function mu(i){const{x:e,y:t,width:n,height:r}=i.bounds,s={nw:{x:e,y:t},n:{x:e+n/2,y:t},ne:{x:e+n,y:t},e:{x:e+n,y:t+r/2},se:{x:e+n,y:t+r},s:{x:e+n/2,y:t+r},sw:{x:e,y:t+r},w:{x:e,y:t+r/2},rotate:{x:e+n/2,y:t-fu}},a=pu(i.bounds),o={};for(const l of Object.keys(s))o[l]=du(s[l],a,i.angle);return o}const Sa=6,_r=Sa/2,gu=20;class _u{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:r,height:s}=e.bounds,a=r/2,o=s/2;this.ctx.ellipse(t+a,n+o,a,o,e.angle,0,2*Math.PI)}else{const{x:t,y:n,width:r,height:s}=e.bounds;this.ctx.save(),this.ctx.translate(t+r/2,n+s/2),this.ctx.rotate(e.angle),this.ctx.translate(-r/2,-s/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=gu*e.haloScale,this.paintBase(e),this.ctx.restore()}paintSelectionHandles(e){const t=mu(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 hu){const r=t[n];this.ctx.fillRect(r.x-_r,r.y-_r,Sa,Sa)}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,_r+1,_r+1,0,0,2*Math.PI),this.ctx.fill()}}function xu(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()}}function vu(i){return new ys({eventType:"sighting",time:i.time,endTime:i.endTime,durationSeconds:i.durationSeconds,place:i.place},Es.fromJSON(i.timeline),i.observerTrack?cr.fromJSON(i.observerTrack):new cr,i.witnessId,i.witnessName,i.caseId)}function Nc(i,e){for(const t of i){const n=t.toLowerCase().split("-")[0];if(e.includes(n))return n}return"en"}const Mu="modulepreload",Su=function(i,e){return new URL(i,e).href},hl={},fl=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let a=function(h){return Promise.all(h.map(f=>Promise.resolve(f).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");r=a(t.map(h=>{if(h=Su(h,n),h in hl)return;hl[h]=!0;const f=h.endsWith(".css"),u=f?'[rel="stylesheet"]':"";if(!!n)for(let S=o.length-1;S>=0;S--){const m=o[S];if(m.href===h&&(!f||m.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${u}`))return;const _=document.createElement("link");if(_.rel=f?"stylesheet":Mu,f||(_.as="script"),_.crossOrigin="",_.href=h,c&&_.setAttribute("nonce",c),document.head.appendChild(_),f)return new Promise((S,m)=>{_.addEventListener("load",S),_.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${h}`)))})}))}function s(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return r.then(a=>{for(const o of a||[])o.status==="rejected"&&s(o.reason);return e().catch(s)})},Eu=["en","fr"],yu={en:()=>fl(()=>Promise.resolve().then(()=>Tu),void 0,import.meta.url).then(i=>i.ufoMessages_en),fr:()=>fl(()=>import("./assets/UfoMessages_fr-COCxf8Q_.js"),[],import.meta.url).then(i=>i.ufoMessages_fr)};function bu(i){return yu[i]()}const Fc={play:"Play",pause:"Pause",autoReplay:"Auto-replay",currentPosition:"Current position",duration:"Duration",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen"},Tu=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:Fc},Symbol.toStringTag,{value:"Module"}));class Au extends HTMLElement{static get observedAttributes(){return["src"]}shadow;stageElement;canvas;canvasRenderer;toolbar;playPauseButton;loopButton;fullscreenButton;seekInput;timeStartLabel;timeEndLabel;currentSighting=ys.create();player;loopEnabled=!0;highlightedSourceId;enableClickToPlay=!0;fullscreenTarget;messages=Fc;realDurationMs;realStartMs;handleFullscreenChange=()=>this.updateFullscreenButton();constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${J0}</style>${$0}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new _u(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 xu(this.currentSighting)}set sightingData(e){this.currentSighting=vu(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[r,s]of t){const a=n&&r===this.highlightedSourceId;this.canvasRenderer.paintShape(a?{...s,selected:!0}:s)}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 uu(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=Nc(navigator.languages,Eu);e!=="en"&&this.applyMessages(await bu(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=su(e);this.realDurationMs=t!==void 0&&t>0?t:void 0,this.realStartMs=e.time?Ma(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 xr(e);const t=this.currentSighting.timeline.duration,n=t>0&&e<=t?e/t*this.realDurationMs:e;return this.realStartMs!==void 0?pl(dl(this.realStartMs+n)):xr(n)}formatEndOfTimeline(){return this.realDurationMs===void 0?xr(this.currentSighting.timeline.duration):this.realStartMs!==void 0?pl(dl(this.realStartMs+this.realDurationMs)):xr(this.realDurationMs)}}function dl(i){const e=new Date(i);return{hour:e.getUTCHours(),minute:e.getUTCMinutes(),second:e.getUTCSeconds()}}function pl(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 xr(i){const e=Math.round(i/1e3),t=Math.floor(e/60),n=e%60;return`${t}:${String(n).padStart(2,"0")}`}const Ea="rr0-ufo";function Oc(){customElements.get(Ea)||customElements.define(Ea,Au)}/**
|
|
224
|
+
`;function Ju(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 Ye(i,t,e){return i+(t-i)*e}function Ul(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 Qu(i){return`#${i.map(t=>Math.round(t).toString(16).padStart(2,"0")).join("")}`}function ju(i,t,e){const n=Ul(i),r=Ul(t);return!n||!r?e<1?i:t:Qu([Ye(n[0],r[0],e),Ye(n[1],r[1],e),Ye(n[2],r[2],e)])}function t0(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)},r=Ye(i.angle,t.angle,e),s=Ye(i.transparency,t.transparency,e),a=Ye(i.haloScale,t.haloScale,e),o=ju(i.color,t.color,e);return i.kind==="polygon"&&t.kind==="polygon"&&i.points.length===t.points.length?{...i,bounds:n,angle:r,transparency:s,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:r,transparency:s,haloScale:a,color:o}}class Ws{keyframes=[];addKeyframe(t,e){const n=this.findInsertIndex(t);if(this.keyframes[n]?.t===t){const r=new Set(e.map(s=>s.sourceId));this.keyframes[n]={t,shapes:[...this.keyframes[n].shapes.filter(s=>!r.has(s.sourceId)),...e]}}else this.keyframes.splice(n,0,{t,shapes:[...e]})}findInsertIndex(t){let e=0,n=this.keyframes.length;for(;e<n;){const r=e+n>>>1;this.keyframes[r].t<t?e=r+1:n=r}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 r=this.keyframes[n].shapes.find(s=>s.sourceId===e);if(r)return r.shape}}getInterpolatedShapeAt(t,e){const n=this.findShapeAtOrBefore(t,e);if(n?.t===t)return n.shape;const r=this.findShapeAtOrAfter(t,e);return n?r?t0(n.shape,r.shape,(t-n.t)/(r.t-n.t)):n.shape:r?.shape}findShapeAtOrBefore(t,e){let n=this.findInsertIndex(t);for(this.keyframes[n]?.t!==t&&(n-=1);n>=0;n--){const r=this.keyframes[n].shapes.find(s=>s.sourceId===e);if(r)return{t:this.keyframes[n].t,shape:r.shape}}}findShapeAtOrAfter(t,e){for(let n=this.findInsertIndex(t);n<this.keyframes.length;n++){const r=this.keyframes[n].shapes.find(s=>s.sourceId===e);if(r)return{t:this.keyframes[n].t,shape:r.shape}}}hitTest(t,e,n){const r=this.sourceIds;for(let s=r.length-1;s>=0;s--){const a=this.getInterpolatedShapeAt(t,r[s]);if(a&&Ju(a,e,n))return{sourceId:r[s],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 Ws;for(const n of t.keyframes)e.addKeyframe(n.t,n.shapes);return e}}function e0(i,t,e){return Math.max(t,Math.min(e,i))}function n0(i,t,e){const n=((t-i)%360+540)%360-180;return((i+n*e)%360+360)%360}function er(i,t,e){return i+(t-i)*e}function i0(i,t,e){return{lat:i.lat===void 0||t.lat===void 0?void 0:er(i.lat,t.lat,e),lng:i.lng===void 0||t.lng===void 0?void 0:er(i.lng,t.lng,e),elevationM:er(i.elevationM,t.elevationM,e),headingDeg:i.headingDeg===void 0||t.headingDeg===void 0?void 0:n0(i.headingDeg,t.headingDeg,e),pitchDeg:er(i.pitchDeg,t.pitchDeg,e),fovDeg:er(i.fovDeg,t.fovDeg,e)}}class yr{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 r=e+n>>>1;this.keyframes[r].t<t?e=r+1:n=r}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 r=this.keyframes[e]?.t===t?void 0:this.keyframes[e];return n?r?i0(n.pose,r.pose,e0((t-n.t)/(r.t-n.t),0,1)):n.pose:r?.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 yr;for(const n of t.keyframes)e.addKeyframe(n.t,n.pose);return e}}function Wa(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 r0(i){if(i.durationSeconds!==void 0)return i.durationSeconds*1e3;const t=i.time?Wa(i.time):void 0,e=i.endTime?Wa(i.endTime):void 0;return t!==void 0&&e!==void 0?e-t:void 0}class Xs{constructor(t,e,n,r,s,a,o){this.event=t,this.timeline=e,this.observerTrack=n,this.witnessId=r,this.witnessName=s,this.caseId=a,this.weather=o}static create(t,e,n){return new Xs({eventType:"sighting",time:t,place:e},new Ws,new yr,n)}}const s0=0,a0=0,o0=60;function l0(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:s0,headingDeg:void 0,pitchDeg:a0,fovDeg:o0}}class c0{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 r=this.timeline.getInterpolatedShapeAt(t,n);r&&e.set(n,r)}this.onFrame(t,e)}}const h0=["nw","n","ne","e","se","s","sw","w"],u0=24;function d0(i,t,e){const n=i.x-t.x,r=i.y-t.y,s=Math.cos(e),a=Math.sin(e);return{x:t.x+n*s-r*a,y:t.y+n*a+r*s}}function f0(i){return{x:i.x+i.width/2,y:i.y+i.height/2}}function p0(i){const{x:t,y:e,width:n,height:r}=i.bounds,s={nw:{x:t,y:e},n:{x:t+n/2,y:e},ne:{x:t+n,y:e},e:{x:t+n,y:e+r/2},se:{x:t+n,y:e+r},s:{x:t+n/2,y:e+r},sw:{x:t,y:e+r},w:{x:t,y:e+r/2},rotate:{x:t+n/2,y:e-u0}},a=f0(i.bounds),o={};for(const l of Object.keys(s))o[l]=d0(s[l],a,i.angle);return o}const Xa=6,Pr=Xa/2,m0=20;class g0{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:r,height:s}=t.bounds,a=r/2,o=s/2;this.ctx.ellipse(e+a,n+o,a,o,t.angle,0,2*Math.PI)}else{const{x:e,y:n,width:r,height:s}=t.bounds;this.ctx.save(),this.ctx.translate(e+r/2,n+s/2),this.ctx.rotate(t.angle),this.ctx.translate(-r/2,-s/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=m0*t.haloScale,this.paintBase(t),this.ctx.restore()}paintSelectionHandles(t){const e=p0(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 h0){const r=e[n];this.ctx.fillRect(r.x-Pr,r.y-Pr,Xa,Xa)}this.ctx.beginPath(),this.ctx.moveTo(e.n.x,e.n.y),this.ctx.lineTo(e.rotate.x,e.rotate.y),this.ctx.stroke(),this.ctx.beginPath(),this.ctx.ellipse(e.rotate.x,e.rotate.y,Pr+1,Pr+1,0,0,2*Math.PI),this.ctx.fill()}}function _0(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 x0(i){return new Xs({eventType:"sighting",time:i.time,endTime:i.endTime,durationSeconds:i.durationSeconds,place:i.place},Ws.fromJSON(i.timeline),i.observerTrack?yr.fromJSON(i.observerTrack):new yr,i.witnessId,i.witnessName,i.caseId,i.weather)}function Rh(i,t){for(const e of i){const n=e.toLowerCase().split("-")[0];if(t.includes(n))return n}return"en"}const v0="modulepreload",M0=function(i,t){return new URL(i,t).href},Nl={},Fl=function(t,e,n){let r=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");r=a(e.map(h=>{if(h=M0(h,n),h in Nl)return;Nl[h]=!0;const d=h.endsWith(".css"),u=d?'[rel="stylesheet"]':"";if(!!n)for(let S=o.length-1;S>=0;S--){const m=o[S];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":v0,d||(_.as="script"),_.crossOrigin="",_.href=h,c&&_.setAttribute("nonce",c),document.head.appendChild(_),d)return new Promise((S,m)=>{_.addEventListener("load",S),_.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${h}`)))})}))}function s(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return r.then(a=>{for(const o of a||[])o.status==="rejected"&&s(o.reason);return t().catch(s)})},S0=["en","fr"],y0={en:()=>Fl(()=>Promise.resolve().then(()=>b0),void 0,import.meta.url).then(i=>i.ufoMessages_en),fr:()=>Fl(()=>import("./UfoMessages_fr-COCxf8Q_.js"),[],import.meta.url).then(i=>i.ufoMessages_fr)};function E0(i){return y0[i]()}const Ch={play:"Play",pause:"Pause",autoReplay:"Auto-replay",currentPosition:"Current position",duration:"Duration",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen"},b0=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:Ch},Symbol.toStringTag,{value:"Module"}));class T0 extends HTMLElement{static get observedAttributes(){return["src"]}shadow;stageElement;canvas;canvasRenderer;toolbar;playPauseButton;loopButton;fullscreenButton;seekInput;timeStartLabel;timeEndLabel;currentSighting=Xs.create();player;loopEnabled=!0;highlightedSourceId;enableClickToPlay=!0;fullscreenTarget;messages=Ch;realDurationMs;realStartMs;handleFullscreenChange=()=>this.updateFullscreenButton();constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${Ku}</style>${$u}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new g0(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 _0(this.currentSighting)}set sightingData(t){this.currentSighting=x0(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[r,s]of e){const a=n&&r===this.highlightedSourceId;this.canvasRenderer.paintShape(a?{...s,selected:!0}:s)}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 c0(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=Rh(navigator.languages,S0);t!=="en"&&this.applyMessages(await E0(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=r0(t);this.realDurationMs=e!==void 0&&e>0?e:void 0,this.realStartMs=t.time?Wa(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 Ir(t);const e=this.currentSighting.timeline.duration,n=e>0&&t<=e?t/e*this.realDurationMs:t;return this.realStartMs!==void 0?Bl(Ol(this.realStartMs+n)):Ir(n)}formatEndOfTimeline(){return this.realDurationMs===void 0?Ir(this.currentSighting.timeline.duration):this.realStartMs!==void 0?Bl(Ol(this.realStartMs+this.realDurationMs)):Ir(this.realDurationMs)}}function Ol(i){const t=new Date(i);return{hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}function Bl(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 Ir(i){const t=Math.round(i/1e3),e=Math.floor(t/60),n=t%60;return`${e}:${String(n).padStart(2,"0")}`}const qa="rr0-ufo";function Ph(){customElements.get(qa)||customElements.define(qa,T0)}/**
|
|
209
225
|
* @license
|
|
210
226
|
* Copyright 2010-2026 Three.js Authors
|
|
211
227
|
* SPDX-License-Identifier: MIT
|
|
212
|
-
*/const Fo="185",wu=0,ml=1,Ru=2,ts=1,Cu=2,ir=3,Xn=0,Lt=1,En=2,Tn=0,Li=1,ya=2,gl=3,_l=4,Pu=5,Qn=100,Du=101,Iu=102,Lu=103,Uu=104,Nu=200,Fu=201,Ou=202,Bu=203,ba=204,Ta=205,zu=206,Gu=207,Vu=208,ku=209,Hu=210,Wu=211,Xu=212,qu=213,Yu=214,Aa=0,wa=1,Ra=2,Bi=3,Ca=4,Pa=5,Da=6,Ia=7,Bc=0,Ku=1,Zu=2,hn=0,zc=1,Gc=2,Vc=3,kc=4,Hc=5,Wc=6,Xc=7,qc=300,si=301,zi=302,Ls=303,Us=304,bs=306,La=1e3,yn=1001,Ua=1002,yt=1003,$u=1004,vr=1005,Rt=1006,Ns=1007,ti=1008,qt=1009,Yc=1010,Kc=1011,ur=1012,Oo=1013,dn=1014,cn=1015,wn=1016,Bo=1017,zo=1018,hr=1020,Zc=35902,$c=35899,Jc=1021,Qc=1022,en=1023,Rn=1026,ni=1027,jc=1028,Go=1029,ai=1030,Vo=1031,ko=1033,ns=33776,is=33777,rs=33778,ss=33779,Na=35840,Fa=35841,Oa=35842,Ba=35843,za=36196,Ga=37492,Va=37496,ka=37488,Ha=37489,ls=37490,Wa=37491,Xa=37808,qa=37809,Ya=37810,Ka=37811,Za=37812,$a=37813,Ja=37814,Qa=37815,ja=37816,eo=37817,to=37818,no=37819,io=37820,ro=37821,so=36492,ao=36494,oo=36495,lo=36283,co=36284,cs=36285,uo=36286,Ju=3200,xl=0,Qu=1,Gn="",Wt="srgb",us="srgb-linear",hs="linear",Qe="srgb",fi=7680,vl=519,ju=512,eh=513,th=514,Ho=515,nh=516,ih=517,Wo=518,rh=519,ho=35044,Ml="300 es",un=2e3,fs=2001;function sh(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function ds(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function ah(){const i=ds("canvas");return i.style.display="block",i}const Sl={};function ps(...i){const e="THREE."+i.shift();console.log(e,...i)}function e0(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 Ne(...i){i=e0(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=e0(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function Ui(...i){const e=i.join(" ");e in Sl||(Sl[e]=!0,Ne(...i))}function oh(i,e,t){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}const lh={[Aa]:wa,[Ra]:Da,[Ca]:Ia,[Bi]:Pa,[wa]:Aa,[Da]:Ra,[Ia]:Ca,[Pa]:Bi};class ci{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 r=n[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,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 r=n.slice(0);for(let s=0,a=r.length;s<a;s++)r[s].call(this,e);e.target=null}}}const Tt=["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"],Fs=Math.PI/180,fo=180/Math.PI;function Hn(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Tt[i&255]+Tt[i>>8&255]+Tt[i>>16&255]+Tt[i>>24&255]+"-"+Tt[e&255]+Tt[e>>8&255]+"-"+Tt[e>>16&15|64]+Tt[e>>24&255]+"-"+Tt[t&63|128]+Tt[t>>8&255]+"-"+Tt[t>>16&255]+Tt[t>>24&255]+Tt[n&255]+Tt[n>>8&255]+Tt[n>>16&255]+Tt[n>>24&255]).toLowerCase()}function Ye(i,e,t){return Math.max(e,Math.min(t,i))}function ch(i,e){return(i%e+e)%e}function Os(i,e,t){return(1-t)*i+t*e}function ln(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 Ve{static{Ve.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,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[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),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*r+e.x,this.y=s*r+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 Hi{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,s,a,o){let l=n[r+0],c=n[r+1],h=n[r+2],f=n[r+3],u=s[a+0],g=s[a+1],_=s[a+2],S=s[a+3];if(f!==S||l!==u||c!==g||h!==_){let m=l*u+c*g+h*_+f*S;m<0&&(u=-u,g=-g,_=-_,S=-S,m=-m);let d=1-o;if(m<.9995){const A=Math.acos(m),w=Math.sin(A);d=Math.sin(d*A)/w,o=Math.sin(o*A)/w,l=l*d+u*o,c=c*d+g*o,h=h*d+_*o,f=f*d+S*o}else{l=l*d+u*o,c=c*d+g*o,h=h*d+_*o,f=f*d+S*o;const A=1/Math.sqrt(l*l+c*c+h*h+f*f);l*=A,c*=A,h*=A,f*=A}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=f}static multiplyQuaternionsFlat(e,t,n,r,s,a){const o=n[r],l=n[r+1],c=n[r+2],h=n[r+3],f=s[a],u=s[a+1],g=s[a+2],_=s[a+3];return e[t]=o*_+h*f+l*g-c*u,e[t+1]=l*_+h*u+c*f-o*g,e[t+2]=c*_+h*g+o*u-l*f,e[t+3]=h*_-o*f-l*u-c*g,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,r){return this._x=e,this._y=t,this._z=n,this._w=r,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,r=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(r/2),f=o(s/2),u=l(n/2),g=l(r/2),_=l(s/2);switch(a){case"XYZ":this._x=u*h*f+c*g*_,this._y=c*g*f-u*h*_,this._z=c*h*_+u*g*f,this._w=c*h*f-u*g*_;break;case"YXZ":this._x=u*h*f+c*g*_,this._y=c*g*f-u*h*_,this._z=c*h*_-u*g*f,this._w=c*h*f+u*g*_;break;case"ZXY":this._x=u*h*f-c*g*_,this._y=c*g*f+u*h*_,this._z=c*h*_+u*g*f,this._w=c*h*f-u*g*_;break;case"ZYX":this._x=u*h*f-c*g*_,this._y=c*g*f+u*h*_,this._z=c*h*_-u*g*f,this._w=c*h*f+u*g*_;break;case"YZX":this._x=u*h*f+c*g*_,this._y=c*g*f+u*h*_,this._z=c*h*_-u*g*f,this._w=c*h*f-u*g*_;break;case"XZY":this._x=u*h*f-c*g*_,this._y=c*g*f-u*h*_,this._z=c*h*_+u*g*f,this._w=c*h*f+u*g*_;break;default:Ne("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],h=t[6],f=t[10],u=n+o+f;if(u>0){const g=.5/Math.sqrt(u+1);this._w=.25/g,this._x=(h-l)*g,this._y=(s-c)*g,this._z=(a-r)*g}else if(n>o&&n>f){const g=2*Math.sqrt(1+n-o-f);this._w=(h-l)/g,this._x=.25*g,this._y=(r+a)/g,this._z=(s+c)/g}else if(o>f){const g=2*Math.sqrt(1+o-n-f);this._w=(s-c)/g,this._x=(r+a)/g,this._y=.25*g,this._z=(l+h)/g}else{const g=2*Math.sqrt(1+f-n-o);this._w=(a-r)/g,this._x=(s+c)/g,this._y=(l+h)/g,this._z=.25*g}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 r=Math.min(1,t/n);return this.slerp(e,r),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,r=e._y,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,h=t._w;return this._x=n*h+a*o+r*c-s*l,this._y=r*h+a*l+s*o-n*c,this._z=s*h+a*c+n*l-r*o,this._w=a*h-n*o-r*l-s*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,s=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,s=-s,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+r*t,this._z=this._z*l+s*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+n*t,this._y=this._y*l+r*t,this._z=this._z*l+s*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(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*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(El.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(El.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*r,this.y=s[1]*t+s[4]*n+s[7]*r,this.z=s[2]*t+s[5]*n+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*r+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*r-o*n),h=2*(o*t-s*r),f=2*(s*n-a*t);return this.x=t+l*c+a*f-o*h,this.y=n+l*h+o*c-s*f,this.z=r+l*f+s*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,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r,this.y=s[1]*t+s[5]*n+s[9]*r,this.z=s[2]*t+s[6]*n+s[10]*r,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,r=e.y,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=r*l-s*o,this.y=s*a-n*l,this.z=n*o-r*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 Bs.copy(this).projectOnVector(e),this.sub(Bs)}reflect(e){return this.sub(Bs.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,r=this.z-e.z;return t*t+n*n+r*r}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 r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*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(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,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 Bs=new F,El=new Hi;class Fe{static{Fe.prototype.isMatrix3=!0}constructor(e,t,n,r,s,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,a,o,l,c)}set(e,t,n,r,s,a,o,l,c){const h=this.elements;return h[0]=e,h[1]=r,h[2]=o,h[3]=t,h[4]=s,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,r=t.elements,s=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],h=n[4],f=n[7],u=n[2],g=n[5],_=n[8],S=r[0],m=r[3],d=r[6],A=r[1],w=r[4],M=r[7],T=r[2],y=r[5],R=r[8];return s[0]=a*S+o*A+l*T,s[3]=a*m+o*w+l*y,s[6]=a*d+o*M+l*R,s[1]=c*S+h*A+f*T,s[4]=c*m+h*w+f*y,s[7]=c*d+h*M+f*R,s[2]=u*S+g*A+_*T,s[5]=u*m+g*w+_*y,s[8]=u*d+g*M+_*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],r=e[2],s=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*s*h+n*o*l+r*s*c-r*a*l}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],f=h*a-o*c,u=o*l-h*s,g=c*s-a*l,_=t*f+n*u+r*g;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);const S=1/_;return e[0]=f*S,e[1]=(r*c-h*n)*S,e[2]=(o*n-r*a)*S,e[3]=u*S,e[4]=(h*t-r*l)*S,e[5]=(r*s-o*t)*S,e[6]=g*S,e[7]=(n*l-c*t)*S,e[8]=(a*t-n*s)*S,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,r,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*a+c*o)+a+e,-r*c,r*l,-r*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return Ui("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(zs.makeScale(e,t)),this}rotate(e){return Ui("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(zs.makeRotation(-e)),this}translate(e,t){return Ui("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(zs.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 r=0;r<9;r++)if(t[r]!==n[r])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 zs=new Fe,yl=new Fe().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),bl=new Fe().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function uh(){const i={enabled:!0,workingColorSpace:us,spaces:{},convert:function(r,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Qe&&(r.r=An(r.r),r.g=An(r.g),r.b=An(r.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Qe&&(r.r=Ni(r.r),r.g=Ni(r.g),r.b=Ni(r.b))),r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===Gn?hs:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,a){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return Ui("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return Ui("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(r,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[us]:{primaries:e,whitePoint:n,transfer:hs,toXYZ:yl,fromXYZ:bl,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Wt},outputColorSpaceConfig:{drawingBufferColorSpace:Wt}},[Wt]:{primaries:e,whitePoint:n,transfer:Qe,toXYZ:yl,fromXYZ:bl,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Wt}}}),i}const qe=uh();function An(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function Ni(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let di;class hh{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{di===void 0&&(di=ds("canvas")),di.width=e.width,di.height=e.height;const r=di.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=di}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=ds("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a<s.length;a++)s[a]=An(s[a]/255)*255;return n.putImageData(r,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(An(t[n]/255)*255):t[n]=An(t[n]);return{data:t,width:e.width,height:e.height}}else return Ne("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let fh=0;class Xo{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:fh++}),this.uuid=Hn(),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:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let a=0,o=r.length;a<o;a++)r[a].isDataTexture?s.push(Gs(r[a].image)):s.push(Gs(r[a]))}else s=Gs(r);n.url=s}return t||(e.images[this.uuid]=n),n}}function Gs(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?hh.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(Ne("Texture: Unable to serialize Texture."),{})}let dh=0;const Vs=new F;class Ct extends ci{constructor(e=Ct.DEFAULT_IMAGE,t=Ct.DEFAULT_MAPPING,n=yn,r=yn,s=Rt,a=ti,o=en,l=qt,c=Ct.DEFAULT_ANISOTROPY,h=Gn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:dh++}),this.uuid=Hn(),this.name="",this.source=new Xo(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Ve(0,0),this.repeat=new Ve(1,1),this.center=new Ve(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Fe,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(Vs).x}get height(){return this.source.getSize(Vs).y}get depth(){return this.source.getSize(Vs).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){Ne(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){Ne(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.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!==qc)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case La:e.x=e.x-Math.floor(e.x);break;case yn:e.x=e.x<0?0:1;break;case Ua: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 La:e.y=e.y-Math.floor(e.y);break;case yn:e.y=e.y<0?0:1;break;case Ua: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++}}Ct.DEFAULT_IMAGE=null;Ct.DEFAULT_MAPPING=qc;Ct.DEFAULT_ANISOTROPY=1;class dt{static{dt.prototype.isVector4=!0}constructor(e=0,t=0,n=0,r=1){this.x=e,this.y=t,this.z=n,this.w=r}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,r){return this.x=e,this.y=t,this.z=n,this.w=r,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,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*s,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,r,s;const l=e.elements,c=l[0],h=l[4],f=l[8],u=l[1],g=l[5],_=l[9],S=l[2],m=l[6],d=l[10];if(Math.abs(h-u)<.01&&Math.abs(f-S)<.01&&Math.abs(_-m)<.01){if(Math.abs(h+u)<.1&&Math.abs(f+S)<.1&&Math.abs(_+m)<.1&&Math.abs(c+g+d-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const w=(c+1)/2,M=(g+1)/2,T=(d+1)/2,y=(h+u)/4,R=(f+S)/4,x=(_+m)/4;return w>M&&w>T?w<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(w),r=y/n,s=R/n):M>T?M<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(M),n=y/r,s=x/r):T<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(T),n=R/s,r=x/s),this.set(n,r,s,t),this}let A=Math.sqrt((m-_)*(m-_)+(f-S)*(f-S)+(u-h)*(u-h));return Math.abs(A)<.001&&(A=1),this.x=(m-_)/A,this.y=(f-S)/A,this.z=(u-h)/A,this.w=Math.acos((c+g+d-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 ph extends ci{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Rt,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 dt(0,0,e,t),this.scissorTest=!1,this.viewport=new dt(0,0,e,t),this.textures=[];const r={width:e,height:t,depth:n.depth},s=new Ct(r),a=n.count;for(let o=0;o<a;o++)this.textures[o]=s.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:Rt,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 r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].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 r=Object.assign({},e.textures[t].image);this.textures[t].source=new Xo(r)}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 fn extends ph{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class t0 extends Ct{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=yt,this.minFilter=yt,this.wrapR=yn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class mh extends Ct{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=yt,this.minFilter=yt,this.wrapR=yn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class lt{static{lt.prototype.isMatrix4=!0}constructor(e,t,n,r,s,a,o,l,c,h,f,u,g,_,S,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,r,s,a,o,l,c,h,f,u,g,_,S,m)}set(e,t,n,r,s,a,o,l,c,h,f,u,g,_,S,m){const d=this.elements;return d[0]=e,d[4]=t,d[8]=n,d[12]=r,d[1]=s,d[5]=a,d[9]=o,d[13]=l,d[2]=c,d[6]=h,d[10]=f,d[14]=u,d[3]=g,d[7]=_,d[11]=S,d[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,r=1/pi.setFromMatrixColumn(e,0).length(),s=1/pi.setFromMatrixColumn(e,1).length(),a=1/pi.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,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,r=e.y,s=e.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(r),c=Math.sin(r),h=Math.cos(s),f=Math.sin(s);if(e.order==="XYZ"){const u=a*h,g=a*f,_=o*h,S=o*f;t[0]=l*h,t[4]=-l*f,t[8]=c,t[1]=g+_*c,t[5]=u-S*c,t[9]=-o*l,t[2]=S-u*c,t[6]=_+g*c,t[10]=a*l}else if(e.order==="YXZ"){const u=l*h,g=l*f,_=c*h,S=c*f;t[0]=u+S*o,t[4]=_*o-g,t[8]=a*c,t[1]=a*f,t[5]=a*h,t[9]=-o,t[2]=g*o-_,t[6]=S+u*o,t[10]=a*l}else if(e.order==="ZXY"){const u=l*h,g=l*f,_=c*h,S=c*f;t[0]=u-S*o,t[4]=-a*f,t[8]=_+g*o,t[1]=g+_*o,t[5]=a*h,t[9]=S-u*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const u=a*h,g=a*f,_=o*h,S=o*f;t[0]=l*h,t[4]=_*c-g,t[8]=u*c+S,t[1]=l*f,t[5]=S*c+u,t[9]=g*c-_,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const u=a*l,g=a*c,_=o*l,S=o*c;t[0]=l*h,t[4]=S-u*f,t[8]=_*f+g,t[1]=f,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=g*f+_,t[10]=u-S*f}else if(e.order==="XZY"){const u=a*l,g=a*c,_=o*l,S=o*c;t[0]=l*h,t[4]=-f,t[8]=c*h,t[1]=u*f+S,t[5]=a*h,t[9]=g*f-_,t[2]=_*f-g,t[6]=o*h,t[10]=S*f+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(gh,e,_h)}lookAt(e,t,n){const r=this.elements;return Bt.subVectors(e,t),Bt.lengthSq()===0&&(Bt.z=1),Bt.normalize(),In.crossVectors(n,Bt),In.lengthSq()===0&&(Math.abs(n.z)===1?Bt.x+=1e-4:Bt.z+=1e-4,Bt.normalize(),In.crossVectors(n,Bt)),In.normalize(),Mr.crossVectors(Bt,In),r[0]=In.x,r[4]=Mr.x,r[8]=Bt.x,r[1]=In.y,r[5]=Mr.y,r[9]=Bt.y,r[2]=In.z,r[6]=Mr.z,r[10]=Bt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],h=n[1],f=n[5],u=n[9],g=n[13],_=n[2],S=n[6],m=n[10],d=n[14],A=n[3],w=n[7],M=n[11],T=n[15],y=r[0],R=r[4],x=r[8],b=r[12],I=r[1],C=r[5],N=r[9],Y=r[13],K=r[2],O=r[6],W=r[10],H=r[14],Q=r[3],te=r[7],ee=r[11],re=r[15];return s[0]=a*y+o*I+l*K+c*Q,s[4]=a*R+o*C+l*O+c*te,s[8]=a*x+o*N+l*W+c*ee,s[12]=a*b+o*Y+l*H+c*re,s[1]=h*y+f*I+u*K+g*Q,s[5]=h*R+f*C+u*O+g*te,s[9]=h*x+f*N+u*W+g*ee,s[13]=h*b+f*Y+u*H+g*re,s[2]=_*y+S*I+m*K+d*Q,s[6]=_*R+S*C+m*O+d*te,s[10]=_*x+S*N+m*W+d*ee,s[14]=_*b+S*Y+m*H+d*re,s[3]=A*y+w*I+M*K+T*Q,s[7]=A*R+w*C+M*O+T*te,s[11]=A*x+w*N+M*W+T*ee,s[15]=A*b+w*Y+M*H+T*re,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],r=e[8],s=e[12],a=e[1],o=e[5],l=e[9],c=e[13],h=e[2],f=e[6],u=e[10],g=e[14],_=e[3],S=e[7],m=e[11],d=e[15],A=l*g-c*u,w=o*g-c*f,M=o*u-l*f,T=a*g-c*h,y=a*u-l*h,R=a*f-o*h;return t*(S*A-m*w+d*M)-n*(_*A-m*T+d*y)+r*(_*w-S*T+d*R)-s*(_*M-S*y+m*R)}determinantAffine(){const e=this.elements,t=e[0],n=e[4],r=e[8],s=e[1],a=e[5],o=e[9],l=e[2],c=e[6],h=e[10];return t*(a*h-o*c)-n*(s*h-o*l)+r*(s*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 r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],f=e[9],u=e[10],g=e[11],_=e[12],S=e[13],m=e[14],d=e[15],A=t*o-n*a,w=t*l-r*a,M=t*c-s*a,T=n*l-r*o,y=n*c-s*o,R=r*c-s*l,x=h*S-f*_,b=h*m-u*_,I=h*d-g*_,C=f*m-u*S,N=f*d-g*S,Y=u*d-g*m,K=A*Y-w*N+M*C+T*I-y*b+R*x;if(K===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const O=1/K;return e[0]=(o*Y-l*N+c*C)*O,e[1]=(r*N-n*Y-s*C)*O,e[2]=(S*R-m*y+d*T)*O,e[3]=(u*y-f*R-g*T)*O,e[4]=(l*I-a*Y-c*b)*O,e[5]=(t*Y-r*I+s*b)*O,e[6]=(m*M-_*R-d*w)*O,e[7]=(h*R-u*M+g*w)*O,e[8]=(a*N-o*I+c*x)*O,e[9]=(n*I-t*N-s*x)*O,e[10]=(_*y-S*M+d*A)*O,e[11]=(f*M-h*y-g*A)*O,e[12]=(o*b-a*C-l*x)*O,e[13]=(t*C-n*b+r*x)*O,e[14]=(S*w-_*T-m*A)*O,e[15]=(h*T-f*w+u*A)*O,this}scale(e){const t=this.elements,n=e.x,r=e.y,s=e.z;return t[0]*=n,t[4]*=r,t[8]*=s,t[1]*=n,t[5]*=r,t[9]*=s,t[2]*=n,t[6]*=r,t[10]*=s,t[3]*=n,t[7]*=r,t[11]*=s,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],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}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),r=Math.sin(t),s=1-n,a=e.x,o=e.y,l=e.z,c=s*a,h=s*o;return this.set(c*a+n,c*o-r*l,c*l+r*o,0,c*o+r*l,h*o+n,h*l-r*a,0,c*l-r*o,h*l+r*a,s*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,r,s,a){return this.set(1,n,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,s=t._x,a=t._y,o=t._z,l=t._w,c=s+s,h=a+a,f=o+o,u=s*c,g=s*h,_=s*f,S=a*h,m=a*f,d=o*f,A=l*c,w=l*h,M=l*f,T=n.x,y=n.y,R=n.z;return r[0]=(1-(S+d))*T,r[1]=(g+M)*T,r[2]=(_-w)*T,r[3]=0,r[4]=(g-M)*y,r[5]=(1-(u+d))*y,r[6]=(m+A)*y,r[7]=0,r[8]=(_+w)*R,r[9]=(m-A)*R,r[10]=(1-(u+S))*R,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];const s=this.determinantAffine();if(s===0)return n.set(1,1,1),t.identity(),this;let a=pi.set(r[0],r[1],r[2]).length();const o=pi.set(r[4],r[5],r[6]).length(),l=pi.set(r[8],r[9],r[10]).length();s<0&&(a=-a),Jt.copy(this);const c=1/a,h=1/o,f=1/l;return Jt.elements[0]*=c,Jt.elements[1]*=c,Jt.elements[2]*=c,Jt.elements[4]*=h,Jt.elements[5]*=h,Jt.elements[6]*=h,Jt.elements[8]*=f,Jt.elements[9]*=f,Jt.elements[10]*=f,t.setFromRotationMatrix(Jt),n.x=a,n.y=o,n.z=l,this}makePerspective(e,t,n,r,s,a,o=un,l=!1){const c=this.elements,h=2*s/(t-e),f=2*s/(n-r),u=(t+e)/(t-e),g=(n+r)/(n-r);let _,S;if(l)_=s/(a-s),S=a*s/(a-s);else if(o===un)_=-(a+s)/(a-s),S=-2*a*s/(a-s);else if(o===fs)_=-a/(a-s),S=-a*s/(a-s);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]=f,c[9]=g,c[13]=0,c[2]=0,c[6]=0,c[10]=_,c[14]=S,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,r,s,a,o=un,l=!1){const c=this.elements,h=2/(t-e),f=2/(n-r),u=-(t+e)/(t-e),g=-(n+r)/(n-r);let _,S;if(l)_=1/(a-s),S=a/(a-s);else if(o===un)_=-2/(a-s),S=-(a+s)/(a-s);else if(o===fs)_=-1/(a-s),S=-s/(a-s);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]=f,c[9]=0,c[13]=g,c[2]=0,c[6]=0,c[10]=_,c[14]=S,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])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 pi=new F,Jt=new lt,gh=new F(0,0,0),_h=new F(1,1,1),In=new F,Mr=new F,Bt=new F,Tl=new lt,Al=new Hi;class oi{constructor(e=0,t=0,n=0,r=oi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}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,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,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 r=e.elements,s=r[0],a=r[4],o=r[8],l=r[1],c=r[5],h=r[9],f=r[2],u=r[6],g=r[10];switch(t){case"XYZ":this._y=Math.asin(Ye(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,g),this._z=Math.atan2(-a,s)):(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,g),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(Ye(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-f,g),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-Ye(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(u,g),this._z=Math.atan2(l,s)):(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(-f,s)):(this._x=0,this._y=Math.atan2(o,g));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,s)):(this._x=Math.atan2(-h,g),this._y=0);break;default:Ne("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Tl.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Tl,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Al.setFromEuler(this),this.setFromQuaternion(Al,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}}oi.DEFAULT_ORDER="XYZ";class qo{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 xh=0;const wl=new F,mi=new Hi,mn=new lt,Sr=new F,Yi=new F,vh=new F,Mh=new Hi,Rl=new F(1,0,0),Cl=new F(0,1,0),Pl=new F(0,0,1),Dl={type:"added"},Sh={type:"removed"},gi={type:"childadded",child:null},ks={type:"childremoved",child:null};class Ut extends ci{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:xh++}),this.uuid=Hn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ut.DEFAULT_UP.clone();const e=new F,t=new oi,n=new Hi,r=new F(1,1,1);function s(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),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:r},modelViewMatrix:{value:new lt},normalMatrix:{value:new Fe}}),this.matrix=new lt,this.matrixWorld=new lt,this.matrixAutoUpdate=Ut.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Ut.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new qo,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 mi.setFromAxisAngle(e,t),this.quaternion.multiply(mi),this}rotateOnWorldAxis(e,t){return mi.setFromAxisAngle(e,t),this.quaternion.premultiply(mi),this}rotateX(e){return this.rotateOnAxis(Rl,e)}rotateY(e){return this.rotateOnAxis(Cl,e)}rotateZ(e){return this.rotateOnAxis(Pl,e)}translateOnAxis(e,t){return wl.copy(e).applyQuaternion(this.quaternion),this.position.add(wl.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Rl,e)}translateY(e){return this.translateOnAxis(Cl,e)}translateZ(e){return this.translateOnAxis(Pl,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(mn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Sr.copy(e):Sr.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),Yi.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?mn.lookAt(Yi,Sr,this.up):mn.lookAt(Sr,Yi,this.up),this.quaternion.setFromRotationMatrix(mn),r&&(mn.extractRotation(r.matrixWorld),mi.setFromRotationMatrix(mn),this.quaternion.premultiply(mi.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(Dl),gi.child=e,this.dispatchEvent(gi),gi.child=null):Xe("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Sh),ks.child=e,this.dispatchEvent(ks),ks.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),mn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),mn.multiply(e.parent.matrixWorld)),e.applyMatrix4(mn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Dl),gi.child=e,this.dispatchEvent(gi),gi.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;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 r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].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(Yi,e,vh),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Yi,Mh,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,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,r=t.length;n<r;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,r=e.z,s=this.matrix.elements;s[12]+=t-s[0]*t-s[4]*n-s[8]*r,s[13]+=n-s[1]*t-s[5]*n-s[9]*r,s[14]+=r-s[2]*t-s[6]*n-s[10]*r}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,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){const r=this.parent;if(e===!0&&r!==null&&r.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 s=this.children;for(let a=0,o=s.length;a<o;a++)s[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 r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),this.static!==!1&&(r.static=this.static),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(o=>({...o})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(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 f=l[c];s(e.shapes,f)}else s(e.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.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(s(e.materials,this.material[l]));r.material=o}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];r.animations.push(s(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),h=a(e.images),f=a(e.shapes),u=a(e.skeletons),g=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),f.length>0&&(n.shapes=f),u.length>0&&(n.skeletons=u),g.length>0&&(n.animations=g),_.length>0&&(n.nodes=_)}return n.object=r,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 r=e.children[n];this.add(r.clone())}return this}}Ut.DEFAULT_UP=new F(0,1,0);Ut.DEFAULT_MATRIX_AUTO_UPDATE=!0;Ut.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Er extends Ut{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Eh={type:"move"};class Hs{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Er,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 Er,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 Er,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 r=null,s=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 S of e.hand.values()){const m=t.getJointPose(S,n),d=this._getHandJoint(c,S);m!==null&&(d.matrix.fromArray(m.transform.matrix),d.matrix.decompose(d.position,d.rotation,d.scale),d.matrixWorldNeedsUpdate=!0,d.jointRadius=m.radius),d.visible=m!==null}const h=c.joints["index-finger-tip"],f=c.joints["thumb-tip"],u=h.position.distanceTo(f.position),g=.02,_=.005;c.inputState.pinching&&u>g+_?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&u<=g-_&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Eh)))}return o!==null&&(o.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Er;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const n0={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},Ln={h:0,s:0,l:0},yr={h:0,s:0,l:0};function Ws(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 Oe{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 r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Wt){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,r=qe.workingColorSpace){return this.r=e,this.g=t,this.b=n,qe.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=qe.workingColorSpace){if(e=ch(e,1),t=Ye(t,0,1),n=Ye(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,a=2*n-s;this.r=Ws(a,s,e+1/3),this.g=Ws(a,s,e),this.b=Ws(a,s,e-1/3)}return qe.colorSpaceToWorking(this,r),this}setStyle(e,t=Wt){function n(s){s!==void 0&&parseFloat(s)<1&&Ne("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:Ne("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);Ne("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Wt){const n=n0[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Ne("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=An(e.r),this.g=An(e.g),this.b=An(e.b),this}copyLinearToSRGB(e){return this.r=Ni(e.r),this.g=Ni(e.g),this.b=Ni(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Wt){return qe.workingToColorSpace(At.copy(this),e),Math.round(Ye(At.r*255,0,255))*65536+Math.round(Ye(At.g*255,0,255))*256+Math.round(Ye(At.b*255,0,255))}getHexString(e=Wt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=qe.workingColorSpace){qe.workingToColorSpace(At.copy(this),t);const n=At.r,r=At.g,s=At.b,a=Math.max(n,r,s),o=Math.min(n,r,s);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const f=a-o;switch(c=h<=.5?f/(a+o):f/(2-a-o),a){case n:l=(r-s)/f+(r<s?6:0);break;case r:l=(s-n)/f+2;break;case s:l=(n-r)/f+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=qe.workingColorSpace){return qe.workingToColorSpace(At.copy(this),t),e.r=At.r,e.g=At.g,e.b=At.b,e}getStyle(e=Wt){qe.workingToColorSpace(At.copy(this),e);const t=At.r,n=At.g,r=At.b;return e!==Wt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(e,t,n){return this.getHSL(Ln),this.setHSL(Ln.h+e,Ln.s+t,Ln.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(Ln),e.getHSL(yr);const n=Os(Ln.h,yr.h,t),r=Os(Ln.s,yr.s,t),s=Os(Ln.l,yr.l,t);return this.setHSL(n,r,s),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,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*r,this.g=s[1]*t+s[4]*n+s[7]*r,this.b=s[2]*t+s[5]*n+s[8]*r,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 At=new Oe;Oe.NAMES=n0;class Yo{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new Oe(e),this.near=t,this.far=n}clone(){return new Yo(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class yh extends Ut{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 oi,this.environmentIntensity=1,this.environmentRotation=new oi,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 Qt=new F,gn=new F,Xs=new F,_n=new F,_i=new F,xi=new F,Il=new F,qs=new F,Ys=new F,Ks=new F,Zs=new dt,$s=new dt,Js=new dt;class Yt{constructor(e=new F,t=new F,n=new F){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Qt.subVectors(e,t),r.cross(Qt);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,n,r,s){Qt.subVectors(r,t),gn.subVectors(n,t),Xs.subVectors(e,t);const a=Qt.dot(Qt),o=Qt.dot(gn),l=Qt.dot(Xs),c=gn.dot(gn),h=gn.dot(Xs),f=a*c-o*o;if(f===0)return s.set(0,0,0),null;const u=1/f,g=(c*l-o*h)*u,_=(a*h-o*l)*u;return s.set(1-g-_,_,g)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,_n)===null?!1:_n.x>=0&&_n.y>=0&&_n.x+_n.y<=1}static getInterpolation(e,t,n,r,s,a,o,l){return this.getBarycoord(e,t,n,r,_n)===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(s,_n.x),l.addScaledVector(a,_n.y),l.addScaledVector(o,_n.z),l)}static getInterpolatedAttribute(e,t,n,r,s,a){return Zs.setScalar(0),$s.setScalar(0),Js.setScalar(0),Zs.fromBufferAttribute(e,t),$s.fromBufferAttribute(e,n),Js.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(Zs,s.x),a.addScaledVector($s,s.y),a.addScaledVector(Js,s.z),a}static isFrontFacing(e,t,n,r){return Qt.subVectors(n,t),gn.subVectors(e,t),Qt.cross(gn).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),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 Qt.subVectors(this.c,this.b),gn.subVectors(this.a,this.b),Qt.cross(gn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Yt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Yt.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,s){return Yt.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return Yt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Yt.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,s=this.c;let a,o;_i.subVectors(r,n),xi.subVectors(s,n),qs.subVectors(e,n);const l=_i.dot(qs),c=xi.dot(qs);if(l<=0&&c<=0)return t.copy(n);Ys.subVectors(e,r);const h=_i.dot(Ys),f=xi.dot(Ys);if(h>=0&&f<=h)return t.copy(r);const u=l*f-h*c;if(u<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(n).addScaledVector(_i,a);Ks.subVectors(e,s);const g=_i.dot(Ks),_=xi.dot(Ks);if(_>=0&&g<=_)return t.copy(s);const S=g*c-l*_;if(S<=0&&c>=0&&_<=0)return o=c/(c-_),t.copy(n).addScaledVector(xi,o);const m=h*_-g*f;if(m<=0&&f-h>=0&&g-_>=0)return Il.subVectors(s,r),o=(f-h)/(f-h+(g-_)),t.copy(r).addScaledVector(Il,o);const d=1/(m+S+u);return a=S*d,o=u*d,t.copy(n).addScaledVector(_i,a).addScaledVector(xi,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class fr{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(jt.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(jt.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=jt.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 s=n.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,jt):jt.fromBufferAttribute(s,a),jt.applyMatrix4(e.matrixWorld),this.expandByPoint(jt);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),br.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),br.copy(n.boundingBox)),br.applyMatrix4(e.matrixWorld),this.union(br)}const r=e.children;for(let s=0,a=r.length;s<a;s++)this.expandByObject(r[s],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,jt),jt.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(Ki),Tr.subVectors(this.max,Ki),vi.subVectors(e.a,Ki),Mi.subVectors(e.b,Ki),Si.subVectors(e.c,Ki),Un.subVectors(Mi,vi),Nn.subVectors(Si,Mi),Yn.subVectors(vi,Si);let t=[0,-Un.z,Un.y,0,-Nn.z,Nn.y,0,-Yn.z,Yn.y,Un.z,0,-Un.x,Nn.z,0,-Nn.x,Yn.z,0,-Yn.x,-Un.y,Un.x,0,-Nn.y,Nn.x,0,-Yn.y,Yn.x,0];return!Qs(t,vi,Mi,Si,Tr)||(t=[1,0,0,0,1,0,0,0,1],!Qs(t,vi,Mi,Si,Tr))?!1:(Ar.crossVectors(Un,Nn),t=[Ar.x,Ar.y,Ar.z],Qs(t,vi,Mi,Si,Tr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,jt).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(jt).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:(xn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),xn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),xn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),xn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),xn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),xn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),xn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),xn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(xn),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 xn=[new F,new F,new F,new F,new F,new F,new F,new F],jt=new F,br=new fr,vi=new F,Mi=new F,Si=new F,Un=new F,Nn=new F,Yn=new F,Ki=new F,Tr=new F,Ar=new F,Kn=new F;function Qs(i,e,t,n,r){for(let s=0,a=i.length-3;s<=a;s+=3){Kn.fromArray(i,s);const o=r.x*Math.abs(Kn.x)+r.y*Math.abs(Kn.y)+r.z*Math.abs(Kn.z),l=e.dot(Kn),c=t.dot(Kn),h=n.dot(Kn);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const xt=new F,wr=new Ve;let bh=0;class Gt extends ci{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:bh++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=ho,this.updateRanges=[],this.gpuType=cn,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 r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[n+r];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++)wr.fromBufferAttribute(this,t),wr.applyMatrix3(e),this.setXY(t,wr.x,wr.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=ln(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=ln(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=ln(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=ln(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=ln(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,r){return e*=this.itemSize,this.normalized&&(t=et(t,this.array),n=et(n,this.array),r=et(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e*=this.itemSize,this.normalized&&(t=et(t,this.array),n=et(n,this.array),r=et(r,this.array),s=et(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=s,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!==ho&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class i0 extends Gt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class r0 extends Gt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Pt extends Gt{constructor(e,t,n){super(new Float32Array(e),t,n)}}const Th=new fr,Zi=new F,js=new F;class Ts{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):Th.setFromPoints(e).getCenter(n);let r=0;for(let s=0,a=e.length;s<a;s++)r=Math.max(r,n.distanceToSquared(e[s]));return this.radius=Math.sqrt(r),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;Zi.subVectors(e,this.center);const t=Zi.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(Zi,r/n),this.radius+=r}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):(js.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Zi.copy(e.center).add(js)),this.expandByPoint(Zi.copy(e.center).sub(js))),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 Ah=0;const kt=new lt,ea=new Ut,Ei=new F,zt=new fr,$i=new fr,St=new F;class Ft extends ci{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ah++}),this.uuid=Hn(),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(sh(e)?r0:i0)(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 s=new Fe().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return kt.makeRotationFromQuaternion(e),this.applyMatrix4(kt),this}rotateX(e){return kt.makeRotationX(e),this.applyMatrix4(kt),this}rotateY(e){return kt.makeRotationY(e),this.applyMatrix4(kt),this}rotateZ(e){return kt.makeRotationZ(e),this.applyMatrix4(kt),this}translate(e,t,n){return kt.makeTranslation(e,t,n),this.applyMatrix4(kt),this}scale(e,t,n){return kt.makeScale(e,t,n),this.applyMatrix4(kt),this}lookAt(e){return ea.lookAt(e),ea.updateMatrix(),this.applyMatrix4(ea.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ei).negate(),this.translate(Ei.x,Ei.y,Ei.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let r=0,s=e.length;r<s;r++){const a=e[r];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Pt(n,3))}else{const n=Math.min(e.length,t.count);for(let r=0;r<n;r++){const s=e[r];t.setXYZ(r,s.x,s.y,s.z||0)}e.length>t.count&&Ne("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new fr);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){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,r=t.length;n<r;n++){const s=t[n];zt.setFromBufferAttribute(s),this.morphTargetsRelative?(St.addVectors(this.boundingBox.min,zt.min),this.boundingBox.expandByPoint(St),St.addVectors(this.boundingBox.max,zt.max),this.boundingBox.expandByPoint(St)):(this.boundingBox.expandByPoint(zt.min),this.boundingBox.expandByPoint(zt.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 Ts);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(zt.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];$i.setFromBufferAttribute(o),this.morphTargetsRelative?(St.addVectors(zt.min,$i.min),zt.expandByPoint(St),St.addVectors(zt.max,$i.max),zt.expandByPoint(St)):(zt.expandByPoint($i.min),zt.expandByPoint($i.max))}zt.getCenter(n);let r=0;for(let s=0,a=e.count;s<a;s++)St.fromBufferAttribute(e,s),r=Math.max(r,n.distanceToSquared(St));if(t)for(let s=0,a=t.length;s<a;s++){const o=t[s],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)St.fromBufferAttribute(o,c),l&&(Ei.fromBufferAttribute(e,c),St.add(Ei)),r=Math.max(r,n.distanceToSquared(St))}this.boundingSphere.radius=Math.sqrt(r),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,r=t.normal,s=t.uv;let a=this.getAttribute("tangent");(a===void 0||a.count!==n.count)&&(a=new Gt(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));const o=[],l=[];for(let x=0;x<n.count;x++)o[x]=new F,l[x]=new F;const c=new F,h=new F,f=new F,u=new Ve,g=new Ve,_=new Ve,S=new F,m=new F;function d(x,b,I){c.fromBufferAttribute(n,x),h.fromBufferAttribute(n,b),f.fromBufferAttribute(n,I),u.fromBufferAttribute(s,x),g.fromBufferAttribute(s,b),_.fromBufferAttribute(s,I),h.sub(c),f.sub(c),g.sub(u),_.sub(u);const C=1/(g.x*_.y-_.x*g.y);isFinite(C)&&(S.copy(h).multiplyScalar(_.y).addScaledVector(f,-g.y).multiplyScalar(C),m.copy(f).multiplyScalar(g.x).addScaledVector(h,-_.x).multiplyScalar(C),o[x].add(S),o[b].add(S),o[I].add(S),l[x].add(m),l[b].add(m),l[I].add(m))}let A=this.groups;A.length===0&&(A=[{start:0,count:e.count}]);for(let x=0,b=A.length;x<b;++x){const I=A[x],C=I.start,N=I.count;for(let Y=C,K=C+N;Y<K;Y+=3)d(e.getX(Y+0),e.getX(Y+1),e.getX(Y+2))}const w=new F,M=new F,T=new F,y=new F;function R(x){T.fromBufferAttribute(r,x),y.copy(T);const b=o[x];w.copy(b),w.sub(T.multiplyScalar(T.dot(b))).normalize(),M.crossVectors(y,b);const C=M.dot(l[x])<0?-1:1;a.setXYZW(x,w.x,w.y,w.z,C)}for(let x=0,b=A.length;x<b;++x){const I=A[x],C=I.start,N=I.count;for(let Y=C,K=C+N;Y<K;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 Gt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let u=0,g=n.count;u<g;u++)n.setXYZ(u,0,0,0);const r=new F,s=new F,a=new F,o=new F,l=new F,c=new F,h=new F,f=new F;if(e)for(let u=0,g=e.count;u<g;u+=3){const _=e.getX(u+0),S=e.getX(u+1),m=e.getX(u+2);r.fromBufferAttribute(t,_),s.fromBufferAttribute(t,S),a.fromBufferAttribute(t,m),h.subVectors(a,s),f.subVectors(r,s),h.cross(f),o.fromBufferAttribute(n,_),l.fromBufferAttribute(n,S),c.fromBufferAttribute(n,m),o.add(h),l.add(h),c.add(h),n.setXYZ(_,o.x,o.y,o.z),n.setXYZ(S,l.x,l.y,l.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let u=0,g=t.count;u<g;u+=3)r.fromBufferAttribute(t,u+0),s.fromBufferAttribute(t,u+1),a.fromBufferAttribute(t,u+2),h.subVectors(a,s),f.subVectors(r,s),h.cross(f),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++)St.fromBufferAttribute(e,t),St.normalize(),e.setXYZ(t,St.x,St.y,St.z)}toNonIndexed(){function e(o,l){const c=o.array,h=o.itemSize,f=o.normalized,u=new c.constructor(l.length*h);let g=0,_=0;for(let S=0,m=l.length;S<m;S++){o.isInterleavedBufferAttribute?g=l[S]*o.data.stride+o.offset:g=l[S]*h;for(let d=0;d<h;d++)u[_++]=c[g++]}return new Gt(u,h,f)}if(this.index===null)return Ne("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Ft,n=this.index.array,r=this.attributes;for(const o in r){const l=r[o],c=e(l,n);t.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[o];for(let h=0,f=c.length;h<f;h++){const u=c[h],g=e(u,n);l.push(g)}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 r={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let f=0,u=c.length;f<u;f++){const g=c[f];h.push(g.toJSON(e.data))}h.length>0&&(r[l]=h,s=!0)}s&&(e.data.morphAttributes=r,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 r=e.attributes;for(const c in r){const h=r[c];this.setAttribute(c,h.clone(t))}const s=e.morphAttributes;for(const c in s){const h=[],f=s[c];for(let u=0,g=f.length;u<g;u++)h.push(f[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 f=a[c];this.addGroup(f.start,f.count,f.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 wh{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=ho,this.updateRanges=[],this.version=0,this.uuid=Hn()}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 r=0,s=this.stride;r<s;r++)this.array[e+r]=t.array[n+r];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=Hn()),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=Hn()),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 Dt=new F;class ms{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}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++)Dt.fromBufferAttribute(this,t),Dt.applyMatrix4(e),this.setXYZ(t,Dt.x,Dt.y,Dt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Dt.fromBufferAttribute(this,t),Dt.applyNormalMatrix(e),this.setXYZ(t,Dt.x,Dt.y,Dt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Dt.fromBufferAttribute(this,t),Dt.transformDirection(e),this.setXYZ(t,Dt.x,Dt.y,Dt.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=ln(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=ln(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=ln(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=ln(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=ln(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,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=et(t,this.array),n=et(n,this.array),r=et(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=et(t,this.array),n=et(n,this.array),r=et(r,this.array),s=et(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){ps("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new Gt(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 ms(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){ps("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}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 Rh=0;class Wi extends ci{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Rh++}),this.uuid=Hn(),this.name="",this.type="Material",this.blending=Li,this.side=Xn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=ba,this.blendDst=Ta,this.blendEquation=Qn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Oe(0,0,0),this.blendAlpha=0,this.depthFunc=Bi,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=vl,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=fi,this.stencilZFail=fi,this.stencilZPass=fi,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){Ne(`Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){Ne(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector2&&n&&n.isVector2||r&&r.isEuler&&n&&n.isEuler||r&&r.isVector3&&n&&n.isVector3?r.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!==Li&&(n.blending=this.blending),this.side!==Xn&&(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!==ba&&(n.blendSrc=this.blendSrc),this.blendDst!==Ta&&(n.blendDst=this.blendDst),this.blendEquation!==Qn&&(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!==Bi&&(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!==vl&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==fi&&(n.stencilFail=this.stencilFail),this.stencilZFail!==fi&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==fi&&(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 r(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(t){const s=r(e.textures),a=r(e.images);s.length>0&&(n.textures=s),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 Oe().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 Ve().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 Ve().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 r=t.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=t[s].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 rr extends Wi{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Oe(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 yi;const Ji=new F,bi=new F,Ti=new F,Ai=new Ve,Qi=new Ve,s0=new lt,Rr=new F,ji=new F,Cr=new F,Ll=new Ve,ta=new Ve,Ul=new Ve;class Pr extends Ut{constructor(e=new rr){if(super(),this.isSprite=!0,this.type="Sprite",yi===void 0){yi=new Ft;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 wh(t,5);yi.setIndex([0,1,2,0,2,3]),yi.setAttribute("position",new ms(n,3,0,!1)),yi.setAttribute("uv",new ms(n,2,3,!1))}this.geometry=yi,this.material=e,this.center=new Ve(.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.'),bi.setFromMatrixScale(this.matrixWorld),s0.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ti.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&bi.multiplyScalar(-Ti.z);const n=this.material.rotation;let r,s;n!==0&&(s=Math.cos(n),r=Math.sin(n));const a=this.center;Dr(Rr.set(-.5,-.5,0),Ti,a,bi,r,s),Dr(ji.set(.5,-.5,0),Ti,a,bi,r,s),Dr(Cr.set(.5,.5,0),Ti,a,bi,r,s),Ll.set(0,0),ta.set(1,0),Ul.set(1,1);let o=e.ray.intersectTriangle(Rr,ji,Cr,!1,Ji);if(o===null&&(Dr(ji.set(-.5,.5,0),Ti,a,bi,r,s),ta.set(0,1),o=e.ray.intersectTriangle(Rr,Cr,ji,!1,Ji),o===null))return;const l=e.ray.origin.distanceTo(Ji);l<e.near||l>e.far||t.push({distance:l,point:Ji.clone(),uv:Yt.getInterpolation(Ji,Rr,ji,Cr,Ll,ta,Ul,new Ve),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 Dr(i,e,t,n,r,s){Ai.subVectors(i,t).addScalar(.5).multiply(n),r!==void 0?(Qi.x=s*Ai.x-r*Ai.y,Qi.y=r*Ai.x+s*Ai.y):Qi.copy(Ai),i.copy(e),i.x+=Qi.x,i.y+=Qi.y,i.applyMatrix4(s0)}const vn=new F,na=new F,Ir=new F,Fn=new F,ia=new F,Lr=new F,ra=new F;class Ko{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,vn)),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=vn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(vn.copy(this.origin).addScaledVector(this.direction,t),vn.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){na.copy(e).add(t).multiplyScalar(.5),Ir.copy(t).sub(e).normalize(),Fn.copy(this.origin).sub(na);const s=e.distanceTo(t)*.5,a=-this.direction.dot(Ir),o=Fn.dot(this.direction),l=-Fn.dot(Ir),c=Fn.lengthSq(),h=Math.abs(1-a*a);let f,u,g,_;if(h>0)if(f=a*l-o,u=a*o-l,_=s*h,f>=0)if(u>=-_)if(u<=_){const S=1/h;f*=S,u*=S,g=f*(f+a*u+2*o)+u*(a*f+u+2*l)+c}else u=s,f=Math.max(0,-(a*u+o)),g=-f*f+u*(u+2*l)+c;else u=-s,f=Math.max(0,-(a*u+o)),g=-f*f+u*(u+2*l)+c;else u<=-_?(f=Math.max(0,-(-a*s+o)),u=f>0?-s:Math.min(Math.max(-s,-l),s),g=-f*f+u*(u+2*l)+c):u<=_?(f=0,u=Math.min(Math.max(-s,-l),s),g=u*(u+2*l)+c):(f=Math.max(0,-(a*s+o)),u=f>0?s:Math.min(Math.max(-s,-l),s),g=-f*f+u*(u+2*l)+c);else u=a>0?-s:s,f=Math.max(0,-(a*u+o)),g=-f*f+u*(u+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,f),r&&r.copy(na).addScaledVector(Ir,u),g}intersectSphere(e,t){vn.subVectors(e.center,this.origin);const n=vn.dot(this.direction),r=vn.dot(vn)-n*n,s=e.radius*e.radius;if(r>s)return null;const a=Math.sqrt(s-r),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,r,s,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,f=1/this.direction.z,u=this.origin;return c>=0?(n=(e.min.x-u.x)*c,r=(e.max.x-u.x)*c):(n=(e.max.x-u.x)*c,r=(e.min.x-u.x)*c),h>=0?(s=(e.min.y-u.y)*h,a=(e.max.y-u.y)*h):(s=(e.max.y-u.y)*h,a=(e.min.y-u.y)*h),n>a||s>r||((s>n||isNaN(n))&&(n=s),(a<r||isNaN(r))&&(r=a),f>=0?(o=(e.min.z-u.z)*f,l=(e.max.z-u.z)*f):(o=(e.max.z-u.z)*f,l=(e.min.z-u.z)*f),n>l||o>r)||((o>n||n!==n)&&(n=o),(l<r||r!==r)&&(r=l),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,vn)!==null}intersectTriangle(e,t,n,r,s){ia.subVectors(t,e),Lr.subVectors(n,e),ra.crossVectors(ia,Lr);let a=this.direction.dot(ra),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Fn.subVectors(this.origin,e);const l=o*this.direction.dot(Lr.crossVectors(Fn,Lr));if(l<0)return null;const c=o*this.direction.dot(ia.cross(Fn));if(c<0||l+c>a)return null;const h=-o*Fn.dot(ra);return h<0?null:this.at(h/a,s)}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 or extends Wi{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Oe(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 oi,this.combine=Bc,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 Nl=new lt,Zn=new Ko,Ur=new Ts,Fl=new F,Nr=new F,Fr=new F,Or=new F,sa=new F,Br=new F,Ol=new F,zr=new F;class Kt extends Ut{constructor(e=new Ft,t=new or){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 r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(e,t){const n=this.geometry,r=n.attributes.position,s=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);const o=this.morphTargetInfluences;if(s&&o){Br.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=o[l],f=s[l];h!==0&&(sa.fromBufferAttribute(f,e),a?Br.addScaledVector(sa,h):Br.addScaledVector(sa.sub(t),h))}t.add(Br)}return t}raycast(e,t){const n=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Ur.copy(n.boundingSphere),Ur.applyMatrix4(s),Zn.copy(e.ray).recast(e.near),!(Ur.containsPoint(Zn.origin)===!1&&(Zn.intersectSphere(Ur,Fl)===null||Zn.origin.distanceToSquared(Fl)>(e.far-e.near)**2))&&(Nl.copy(s).invert(),Zn.copy(e.ray).applyMatrix4(Nl),!(n.boundingBox!==null&&Zn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Zn)))}_computeIntersections(e,t,n){let r;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,f=s.attributes.normal,u=s.groups,g=s.drawRange;if(o!==null)if(Array.isArray(a))for(let _=0,S=u.length;_<S;_++){const m=u[_],d=a[m.materialIndex],A=Math.max(m.start,g.start),w=Math.min(o.count,Math.min(m.start+m.count,g.start+g.count));for(let M=A,T=w;M<T;M+=3){const y=o.getX(M),R=o.getX(M+1),x=o.getX(M+2);r=Gr(this,d,e,n,c,h,f,y,R,x),r&&(r.faceIndex=Math.floor(M/3),r.face.materialIndex=m.materialIndex,t.push(r))}}else{const _=Math.max(0,g.start),S=Math.min(o.count,g.start+g.count);for(let m=_,d=S;m<d;m+=3){const A=o.getX(m),w=o.getX(m+1),M=o.getX(m+2);r=Gr(this,a,e,n,c,h,f,A,w,M),r&&(r.faceIndex=Math.floor(m/3),t.push(r))}}else if(l!==void 0)if(Array.isArray(a))for(let _=0,S=u.length;_<S;_++){const m=u[_],d=a[m.materialIndex],A=Math.max(m.start,g.start),w=Math.min(l.count,Math.min(m.start+m.count,g.start+g.count));for(let M=A,T=w;M<T;M+=3){const y=M,R=M+1,x=M+2;r=Gr(this,d,e,n,c,h,f,y,R,x),r&&(r.faceIndex=Math.floor(M/3),r.face.materialIndex=m.materialIndex,t.push(r))}}else{const _=Math.max(0,g.start),S=Math.min(l.count,g.start+g.count);for(let m=_,d=S;m<d;m+=3){const A=m,w=m+1,M=m+2;r=Gr(this,a,e,n,c,h,f,A,w,M),r&&(r.faceIndex=Math.floor(m/3),t.push(r))}}}}function Ch(i,e,t,n,r,s,a,o){let l;if(e.side===Lt?l=n.intersectTriangle(a,s,r,!0,o):l=n.intersectTriangle(r,s,a,e.side===Xn,o),l===null)return null;zr.copy(o),zr.applyMatrix4(i.matrixWorld);const c=t.ray.origin.distanceTo(zr);return c<t.near||c>t.far?null:{distance:c,point:zr.clone(),object:i}}function Gr(i,e,t,n,r,s,a,o,l,c){i.getVertexPosition(o,Nr),i.getVertexPosition(l,Fr),i.getVertexPosition(c,Or);const h=Ch(i,e,t,n,Nr,Fr,Or,Ol);if(h){const f=new F;Yt.getBarycoord(Ol,Nr,Fr,Or,f),r&&(h.uv=Yt.getInterpolatedAttribute(r,o,l,c,f,new Ve)),s&&(h.uv1=Yt.getInterpolatedAttribute(s,o,l,c,f,new Ve)),a&&(h.normal=Yt.getInterpolatedAttribute(a,o,l,c,f,new F),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const u={a:o,b:l,c,normal:new F,materialIndex:0};Yt.getNormal(Nr,Fr,Or,u.normal),h.face=u,h.barycoord=f}return h}class Ph extends Ct{constructor(e=null,t=1,n=1,r,s,a,o,l,c=yt,h=yt,f,u){super(null,a,o,l,c,h,r,s,f,u),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const aa=new F,Dh=new F,Ih=new Fe;class Jn{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,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const r=aa.subVectors(n,t).cross(Dh.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,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 r=e.delta(aa),s=this.normal.dot(r);if(s===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/s;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(r,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||Ih.getNormalMatrix(e),r=this.coplanarPoint(aa).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),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 $n=new Ts,Lh=new Ve(.5,.5),Vr=new F;class a0{constructor(e=new Jn,t=new Jn,n=new Jn,r=new Jn,s=new Jn,a=new Jn){this.planes=[e,t,n,r,s,a]}set(e,t,n,r,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(s),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=un,n=!1){const r=this.planes,s=e.elements,a=s[0],o=s[1],l=s[2],c=s[3],h=s[4],f=s[5],u=s[6],g=s[7],_=s[8],S=s[9],m=s[10],d=s[11],A=s[12],w=s[13],M=s[14],T=s[15];if(r[0].setComponents(c-a,g-h,d-_,T-A).normalize(),r[1].setComponents(c+a,g+h,d+_,T+A).normalize(),r[2].setComponents(c+o,g+f,d+S,T+w).normalize(),r[3].setComponents(c-o,g-f,d-S,T-w).normalize(),n)r[4].setComponents(l,u,m,M).normalize(),r[5].setComponents(c-l,g-u,d-m,T-M).normalize();else if(r[4].setComponents(c-l,g-u,d-m,T-M).normalize(),t===un)r[5].setComponents(c+l,g+u,d+m,T+M).normalize();else if(t===fs)r[5].setComponents(l,u,m,M).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),$n.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),$n.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere($n)}intersectsSprite(e){$n.center.set(0,0,0);const t=Lh.distanceTo(e.center);return $n.radius=.7071067811865476+t,$n.applyMatrix4(e.matrixWorld),this.intersectsSphere($n)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const r=t[n];if(Vr.x=r.normal.x>0?e.max.x:e.min.x,Vr.y=r.normal.y>0?e.max.y:e.min.y,Vr.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Vr)<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 o0 extends Wi{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Oe(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 Bl=new lt,po=new Ko,kr=new Ts,Hr=new F;class Uh extends Ut{constructor(e=new Ft,t=new o0){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,r=this.matrixWorld,s=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),kr.copy(n.boundingSphere),kr.applyMatrix4(r),kr.radius+=s,e.ray.intersectsSphere(kr)===!1)return;Bl.copy(r).invert(),po.copy(e.ray).applyMatrix4(Bl);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,f=n.attributes.position;if(c!==null){const u=Math.max(0,a.start),g=Math.min(c.count,a.start+a.count);for(let _=u,S=g;_<S;_++){const m=c.getX(_);Hr.fromBufferAttribute(f,m),zl(Hr,m,l,r,e,t,this)}}else{const u=Math.max(0,a.start),g=Math.min(f.count,a.start+a.count);for(let _=u,S=g;_<S;_++)Hr.fromBufferAttribute(f,_),zl(Hr,_,l,r,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function zl(i,e,t,n,r,s,a){const o=po.distanceSqToPoint(i);if(o<t){const l=new F;po.closestPointToPoint(i,l),l.applyMatrix4(n);const c=r.ray.origin.distanceTo(l);if(c<r.near||c>r.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class l0 extends Ct{constructor(e=[],t=si,n,r,s,a,o,l,c,h){super(e,t,n,r,s,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Zo extends Ct{constructor(e,t,n,r,s,a,o,l,c){super(e,t,n,r,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Gi extends Ct{constructor(e,t,n=dn,r,s,a,o=yt,l=yt,c,h=Rn,f=1){if(h!==Rn&&h!==ni)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const u={width:e,height:t,depth:f};super(u,r,s,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 Xo(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 Nh extends Gi{constructor(e,t=dn,n=si,r,s,a=yt,o=yt,l,c=Rn){const h={width:e,height:e,depth:1},f=[h,h,h,h,h,h];super(e,e,t,n,r,s,a,o,l,c),this.image=f,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class c0 extends Ct{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class dr extends Ft{constructor(e=1,t=1,n=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:s,depthSegments:a};const o=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],h=[],f=[];let u=0,g=0;_("z","y","x",-1,-1,n,t,e,a,s,0),_("z","y","x",1,-1,n,t,-e,a,s,1),_("x","z","y",1,1,e,n,t,r,a,2),_("x","z","y",1,-1,e,n,-t,r,a,3),_("x","y","z",1,-1,e,t,n,r,s,4),_("x","y","z",-1,-1,e,t,-n,r,s,5),this.setIndex(l),this.setAttribute("position",new Pt(c,3)),this.setAttribute("normal",new Pt(h,3)),this.setAttribute("uv",new Pt(f,2));function _(S,m,d,A,w,M,T,y,R,x,b){const I=M/R,C=T/x,N=M/2,Y=T/2,K=y/2,O=R+1,W=x+1;let H=0,Q=0;const te=new F;for(let ee=0;ee<W;ee++){const re=ee*C-Y;for(let ge=0;ge<O;ge++){const He=ge*I-N;te[S]=He*A,te[m]=re*w,te[d]=K,c.push(te.x,te.y,te.z),te[S]=0,te[m]=0,te[d]=y>0?1:-1,h.push(te.x,te.y,te.z),f.push(ge/R),f.push(1-ee/x),H+=1}}for(let ee=0;ee<x;ee++)for(let re=0;re<R;re++){const ge=u+re+O*ee,He=u+re+O*(ee+1),rt=u+(re+1)+O*(ee+1),We=u+(re+1)+O*ee;l.push(ge,He,We),l.push(He,rt,We),Q+=6}o.addGroup(g,Q,b),g+=Q,u+=H}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new dr(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class $o extends Ft{constructor(e=1,t=32,n=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},t=Math.max(3,t);const s=[],a=[],o=[],l=[],c=new F,h=new Ve;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let f=0,u=3;f<=t;f++,u+=3){const g=n+f/t*r;c.x=e*Math.cos(g),c.y=e*Math.sin(g),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 f=1;f<=t;f++)s.push(f,f+1,0);this.setIndex(s),this.setAttribute("position",new Pt(a,3)),this.setAttribute("normal",new Pt(o,3)),this.setAttribute("uv",new Pt(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $o(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class As extends Ft{constructor(e=1,t=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};const s=e/2,a=t/2,o=Math.floor(n),l=Math.floor(r),c=o+1,h=l+1,f=e/o,u=t/l,g=[],_=[],S=[],m=[];for(let d=0;d<h;d++){const A=d*u-a;for(let w=0;w<c;w++){const M=w*f-s;_.push(M,-A,0),S.push(0,0,1),m.push(w/o),m.push(1-d/l)}}for(let d=0;d<l;d++)for(let A=0;A<o;A++){const w=A+c*d,M=A+c*(d+1),T=A+1+c*(d+1),y=A+1+c*d;g.push(w,M,y),g.push(M,T,y)}this.setIndex(g),this.setAttribute("position",new Pt(_,3)),this.setAttribute("normal",new Pt(S,3)),this.setAttribute("uv",new Pt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new As(e.width,e.height,e.widthSegments,e.heightSegments)}}class gs extends Ft{constructor(e=1,t=32,n=16,r=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:s,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=[],f=new F,u=new F,g=[],_=[],S=[],m=[];for(let d=0;d<=n;d++){const A=[],w=d/n,M=a+w*o,T=e*Math.cos(M),y=Math.sqrt(e*e-T*T);let R=0;d===0&&a===0?R=.5/t:d===n&&l===Math.PI&&(R=-.5/t);for(let x=0;x<=t;x++){const b=x/t,I=r+b*s;f.x=-y*Math.cos(I),f.y=T,f.z=y*Math.sin(I),_.push(f.x,f.y,f.z),u.copy(f).normalize(),S.push(u.x,u.y,u.z),m.push(b+R,1-w),A.push(c++)}h.push(A)}for(let d=0;d<n;d++)for(let A=0;A<t;A++){const w=h[d][A+1],M=h[d][A],T=h[d+1][A],y=h[d+1][A+1];(d!==0||a>0)&&g.push(w,M,y),(d!==n-1||l<Math.PI)&&g.push(M,T,y)}this.setIndex(g),this.setAttribute("position",new Pt(_,3)),this.setAttribute("normal",new Pt(S,3)),this.setAttribute("uv",new Pt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new gs(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}function Vi(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const r=i[t][n];if(Gl(r))r.isRenderTargetTexture?(Ne("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=r.clone();else if(Array.isArray(r))if(Gl(r[0])){const s=[];for(let a=0,o=r.length;a<o;a++)s[a]=r[a].clone();e[t][n]=s}else e[t][n]=r.slice();else e[t][n]=r}}return e}function It(i){const e={};for(let t=0;t<i.length;t++){const n=Vi(i[t]);for(const r in n)e[r]=n[r]}return e}function Gl(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function Fh(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function u0(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:qe.workingColorSpace}const Oh={clone:Vi,merge:It};var Bh=`void main() {
|
|
228
|
+
*/const al="185",A0=0,zl=1,w0=2,Ss=1,R0=2,gr=3,Zn=0,Fe=1,bn=2,wn=0,Gi=1,Ya=2,Gl=3,Hl=4,C0=5,ei=100,P0=101,I0=102,D0=103,L0=104,U0=200,N0=201,F0=202,O0=203,Za=204,$a=205,B0=206,z0=207,G0=208,H0=209,k0=210,V0=211,W0=212,X0=213,q0=214,Ka=0,Ja=1,Qa=2,qi=3,ja=4,to=5,eo=6,no=7,Ih=0,Y0=1,Z0=2,pn=0,Dh=1,Lh=2,Uh=3,Nh=4,Fh=5,Oh=6,Bh=7,zh=300,li=301,Yi=302,ea=303,na=304,qs=306,io=1e3,Tn=1001,ro=1002,Ae=1003,$0=1004,Dr=1005,Ie=1006,ia=1007,ri=1008,Ke=1009,Gh=1010,Hh=1011,Er=1012,ol=1013,gn=1014,dn=1015,Cn=1016,ll=1017,cl=1018,br=1020,kh=35902,Vh=35899,Wh=1021,Xh=1022,rn=1023,Pn=1026,si=1027,qh=1028,hl=1029,ci=1030,ul=1031,dl=1033,ys=33776,Es=33777,bs=33778,Ts=33779,so=35840,ao=35841,oo=35842,lo=35843,co=36196,ho=37492,uo=37496,fo=37488,po=37489,Cs=37490,mo=37491,go=37808,_o=37809,xo=37810,vo=37811,Mo=37812,So=37813,yo=37814,Eo=37815,bo=37816,To=37817,Ao=37818,wo=37819,Ro=37820,Co=37821,Po=36492,Io=36494,Do=36495,Lo=36283,Uo=36284,Ps=36285,No=36286,K0=3200,kl=0,J0=1,Vn="",Ze="srgb",Is="srgb-linear",Ds="linear",Qt="srgb",mi=7680,Vl=519,Q0=512,j0=513,td=514,fl=515,ed=516,nd=517,pl=518,id=519,Fo=35044,Wl="300 es",fn=2e3,Ls=2001;function rd(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function Us(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function sd(){const i=Us("canvas");return i.style.display="block",i}const Xl={};function Ns(...i){const t="THREE."+i.shift();console.log(t,...i)}function Yh(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=Yh(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=Yh(i);const t="THREE."+i.shift();{const e=i[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...i)}}function Hi(...i){const t=i.join(" ");t in Xl||(Xl[t]=!0,Ft(...i))}function ad(i,t,e){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(t,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,e);break;default:n()}}setTimeout(s,e)})}const od={[Ka]:Ja,[Qa]:eo,[ja]:no,[qi]:to,[Ja]:Ka,[eo]:Qa,[no]:ja,[to]:qi};class di{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 r=n[t];if(r!==void 0){const s=r.indexOf(e);s!==-1&&r.splice(s,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 r=n.slice(0);for(let s=0,a=r.length;s<a;s++)r[s].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"],ra=Math.PI/180,Oo=180/Math.PI;function qn(){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 ld(i,t){return(i%t+t)%t}function sa(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 Gt{static{Gt.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,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6],this.y=r[1]*e+r[4]*n+r[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),r=Math.sin(e),s=this.x-t.x,a=this.y-t.y;return this.x=s*n-a*r+t.x,this.y=s*r+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 Qi{constructor(t=0,e=0,n=0,r=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=r}static slerpFlat(t,e,n,r,s,a,o){let l=n[r+0],c=n[r+1],h=n[r+2],d=n[r+3],u=s[a+0],p=s[a+1],_=s[a+2],S=s[a+3];if(d!==S||l!==u||c!==p||h!==_){let m=l*u+c*p+h*_+d*S;m<0&&(u=-u,p=-p,_=-_,S=-S,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+S*o}else{l=l*f+u*o,c=c*f+p*o,h=h*f+_*o,d=d*f+S*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,r,s,a){const o=n[r],l=n[r+1],c=n[r+2],h=n[r+3],d=s[a],u=s[a+1],p=s[a+2],_=s[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,r){return this._x=t,this._y=e,this._z=n,this._w=r,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,r=t._y,s=t._z,a=t._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(r/2),d=o(s/2),u=l(n/2),p=l(r/2),_=l(s/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,r=Math.sin(n);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],r=e[4],s=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=(s-c)*p,this._z=(a-r)*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=(r+a)/p,this._z=(s+c)/p}else if(o>d){const p=2*Math.sqrt(1+o-n-d);this._w=(s-c)/p,this._x=(r+a)/p,this._y=.25*p,this._z=(l+h)/p}else{const p=2*Math.sqrt(1+d-n-o);this._w=(a-r)/p,this._x=(s+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 r=Math.min(1,e/n);return this.slerp(t,r),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,r=t._y,s=t._z,a=t._w,o=e._x,l=e._y,c=e._z,h=e._w;return this._x=n*h+a*o+r*c-s*l,this._y=r*h+a*l+s*o-n*c,this._z=s*h+a*c+n*l-r*o,this._w=a*h-n*o-r*l-s*c,this._onChangeCallback(),this}slerp(t,e){let n=t._x,r=t._y,s=t._z,a=t._w,o=this.dot(t);o<0&&(n=-n,r=-r,s=-s,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+r*e,this._z=this._z*l+s*e,this._w=this._w*l+a*e,this._onChangeCallback()}else this._x=this._x*l+n*e,this._y=this._y*l+r*e,this._z=this._z*l+s*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(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(t),r*Math.cos(t),s*Math.sin(e),s*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class 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(ql.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(ql.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,r=this.z,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6]*r,this.y=s[1]*e+s[4]*n+s[7]*r,this.z=s[2]*e+s[5]*n+s[8]*r,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,s=t.elements,a=1/(s[3]*e+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*e+s[4]*n+s[8]*r+s[12])*a,this.y=(s[1]*e+s[5]*n+s[9]*r+s[13])*a,this.z=(s[2]*e+s[6]*n+s[10]*r+s[14])*a,this}applyQuaternion(t){const e=this.x,n=this.y,r=this.z,s=t.x,a=t.y,o=t.z,l=t.w,c=2*(a*r-o*n),h=2*(o*e-s*r),d=2*(s*n-a*e);return this.x=e+l*c+a*d-o*h,this.y=n+l*h+o*c-s*d,this.z=r+l*d+s*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,r=this.z,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*r,this.y=s[1]*e+s[5]*n+s[9]*r,this.z=s[2]*e+s[6]*n+s[10]*r,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,r=t.y,s=t.z,a=e.x,o=e.y,l=e.z;return this.x=r*l-s*o,this.y=s*a-n*l,this.z=n*o-r*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 aa.copy(this).projectOnVector(t),this.sub(aa)}reflect(t){return this.sub(aa.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,r=this.z-t.z;return e*e+n*n+r*r}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 r=Math.sin(e)*t;return this.x=r*Math.sin(n),this.y=Math.cos(e)*t,this.z=r*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(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=r,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 aa=new F,ql=new Qi;class Ot{static{Ot.prototype.isMatrix3=!0}constructor(t,e,n,r,s,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,r,s,a,o,l,c)}set(t,e,n,r,s,a,o,l,c){const h=this.elements;return h[0]=t,h[1]=r,h[2]=o,h[3]=e,h[4]=s,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,r=e.elements,s=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],S=r[0],m=r[3],f=r[6],A=r[1],w=r[4],M=r[7],y=r[2],b=r[5],R=r[8];return s[0]=a*S+o*A+l*y,s[3]=a*m+o*w+l*b,s[6]=a*f+o*M+l*R,s[1]=c*S+h*A+d*y,s[4]=c*m+h*w+d*b,s[7]=c*f+h*M+d*R,s[2]=u*S+p*A+_*y,s[5]=u*m+p*w+_*b,s[8]=u*f+p*M+_*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],r=t[2],s=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*s*h+n*o*l+r*s*c-r*a*l}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],s=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*s,p=c*s-a*l,_=e*d+n*u+r*p;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);const S=1/_;return t[0]=d*S,t[1]=(r*c-h*n)*S,t[2]=(o*n-r*a)*S,t[3]=u*S,t[4]=(h*e-r*l)*S,t[5]=(r*s-o*e)*S,t[6]=p*S,t[7]=(n*l-c*e)*S,t[8]=(a*e-n*s)*S,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,r,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*a+c*o)+a+t,-r*c,r*l,-r*(-c*a+l*o)+o+e,0,0,1),this}scale(t,e){return Hi("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(oa.makeScale(t,e)),this}rotate(t){return Hi("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(oa.makeRotation(-t)),this}translate(t,e){return Hi("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(oa.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 r=0;r<9;r++)if(e[r]!==n[r])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 oa=new Ot,Yl=new Ot().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Zl=new Ot().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function cd(){const i={enabled:!0,workingColorSpace:Is,spaces:{},convert:function(r,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===Qt&&(r.r=Rn(r.r),r.g=Rn(r.g),r.b=Rn(r.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===Qt&&(r.r=ki(r.r),r.g=ki(r.g),r.b=ki(r.b))),r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===Vn?Ds:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,a){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,s){return Hi("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return Hi("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(r,s)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Is]:{primaries:t,whitePoint:n,transfer:Ds,toXYZ:Yl,fromXYZ:Zl,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Ze},outputColorSpaceConfig:{drawingBufferColorSpace:Ze}},[Ze]:{primaries:t,whitePoint:n,transfer:Qt,toXYZ:Yl,fromXYZ:Zl,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Ze}}}),i}const qt=cd();function Rn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function ki(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let gi;class hd{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{gi===void 0&&(gi=Us("canvas")),gi.width=t.width,gi.height=t.height;const r=gi.getContext("2d");t instanceof ImageData?r.putImageData(t,0,0):r.drawImage(t,0,0,t.width,t.height),n=gi}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=Us("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const r=n.getImageData(0,0,t.width,t.height),s=r.data;for(let a=0;a<s.length;a++)s[a]=Rn(s[a]/255)*255;return n.putImageData(r,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 ud=0;class ml{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:ud++}),this.uuid=qn(),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:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let a=0,o=r.length;a<o;a++)r[a].isDataTexture?s.push(la(r[a].image)):s.push(la(r[a]))}else s=la(r);n.url=s}return e||(t.images[this.uuid]=n),n}}function la(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?hd.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 dd=0;const ca=new F;class De extends di{constructor(t=De.DEFAULT_IMAGE,e=De.DEFAULT_MAPPING,n=Tn,r=Tn,s=Ie,a=ri,o=rn,l=Ke,c=De.DEFAULT_ANISOTROPY,h=Vn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:dd++}),this.uuid=qn(),this.name="",this.source=new ml(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Gt(0,0),this.repeat=new Gt(1,1),this.center=new Gt(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(ca).x}get height(){return this.source.getSize(ca).y}get depth(){return this.source.getSize(ca).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 r=this[e];if(r===void 0){Ft(`Texture.setValues(): property '${e}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.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!==zh)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case io:t.x=t.x-Math.floor(t.x);break;case Tn:t.x=t.x<0?0:1;break;case ro: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 io:t.y=t.y-Math.floor(t.y);break;case Tn:t.y=t.y<0?0:1;break;case ro: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=zh;De.DEFAULT_ANISOTROPY=1;class fe{static{fe.prototype.isVector4=!0}constructor(t=0,e=0,n=0,r=1){this.x=t,this.y=e,this.z=n,this.w=r}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,r){return this.x=t,this.y=e,this.z=n,this.w=r,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,r=this.z,s=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*r+a[12]*s,this.y=a[1]*e+a[5]*n+a[9]*r+a[13]*s,this.z=a[2]*e+a[6]*n+a[10]*r+a[14]*s,this.w=a[3]*e+a[7]*n+a[11]*r+a[15]*s,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,r,s;const l=t.elements,c=l[0],h=l[4],d=l[8],u=l[1],p=l[5],_=l[9],S=l[2],m=l[6],f=l[10];if(Math.abs(h-u)<.01&&Math.abs(d-S)<.01&&Math.abs(_-m)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+S)<.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,M=(p+1)/2,y=(f+1)/2,b=(h+u)/4,R=(d+S)/4,x=(_+m)/4;return w>M&&w>y?w<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(w),r=b/n,s=R/n):M>y?M<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(M),n=b/r,s=x/r):y<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(y),n=R/s,r=x/s),this.set(n,r,s,e),this}let A=Math.sqrt((m-_)*(m-_)+(d-S)*(d-S)+(u-h)*(u-h));return Math.abs(A)<.001&&(A=1),this.x=(m-_)/A,this.y=(d-S)/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 fd extends di{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 r={width:t,height:e,depth:n.depth},s=new De(r),a=n.count;for(let o=0;o<a;o++)this.textures[o]=s.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 r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=t,this.textures[r].image.height=e,this.textures[r].image.depth=n,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].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 r=Object.assign({},t.textures[e].image);this.textures[e].source=new ml(r)}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 fd{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class Zh extends De{constructor(t=null,e=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:r},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 pd extends De{constructor(t=null,e=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:r},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,r,s,a,o,l,c,h,d,u,p,_,S,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,r,s,a,o,l,c,h,d,u,p,_,S,m)}set(t,e,n,r,s,a,o,l,c,h,d,u,p,_,S,m){const f=this.elements;return f[0]=t,f[4]=e,f[8]=n,f[12]=r,f[1]=s,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]=S,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,r=1/_i.setFromMatrixColumn(t,0).length(),s=1/_i.setFromMatrixColumn(t,1).length(),a=1/_i.setFromMatrixColumn(t,2).length();return e[0]=n[0]*r,e[1]=n[1]*r,e[2]=n[2]*r,e[3]=0,e[4]=n[4]*s,e[5]=n[5]*s,e[6]=n[6]*s,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,r=t.y,s=t.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(r),c=Math.sin(r),h=Math.cos(s),d=Math.sin(s);if(t.order==="XYZ"){const u=a*h,p=a*d,_=o*h,S=o*d;e[0]=l*h,e[4]=-l*d,e[8]=c,e[1]=p+_*c,e[5]=u-S*c,e[9]=-o*l,e[2]=S-u*c,e[6]=_+p*c,e[10]=a*l}else if(t.order==="YXZ"){const u=l*h,p=l*d,_=c*h,S=c*d;e[0]=u+S*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]=S+u*o,e[10]=a*l}else if(t.order==="ZXY"){const u=l*h,p=l*d,_=c*h,S=c*d;e[0]=u-S*o,e[4]=-a*d,e[8]=_+p*o,e[1]=p+_*o,e[5]=a*h,e[9]=S-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,S=o*d;e[0]=l*h,e[4]=_*c-p,e[8]=u*c+S,e[1]=l*d,e[5]=S*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,S=o*c;e[0]=l*h,e[4]=S-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-S*d}else if(t.order==="XZY"){const u=a*l,p=a*c,_=o*l,S=o*c;e[0]=l*h,e[4]=-d,e[8]=c*h,e[1]=u*d+S,e[5]=a*h,e[9]=p*d-_,e[2]=_*d-p,e[6]=o*h,e[10]=S*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(md,t,gd)}lookAt(t,e,n){const r=this.elements;return Ge.subVectors(t,e),Ge.lengthSq()===0&&(Ge.z=1),Ge.normalize(),Nn.crossVectors(n,Ge),Nn.lengthSq()===0&&(Math.abs(n.z)===1?Ge.x+=1e-4:Ge.z+=1e-4,Ge.normalize(),Nn.crossVectors(n,Ge)),Nn.normalize(),Lr.crossVectors(Ge,Nn),r[0]=Nn.x,r[4]=Lr.x,r[8]=Ge.x,r[1]=Nn.y,r[5]=Lr.y,r[9]=Ge.y,r[2]=Nn.z,r[6]=Lr.z,r[10]=Ge.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,r=e.elements,s=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],S=n[6],m=n[10],f=n[14],A=n[3],w=n[7],M=n[11],y=n[15],b=r[0],R=r[4],x=r[8],T=r[12],I=r[1],C=r[5],U=r[9],Y=r[13],Z=r[2],O=r[6],W=r[10],V=r[14],Q=r[3],et=r[7],tt=r[11],rt=r[15];return s[0]=a*b+o*I+l*Z+c*Q,s[4]=a*R+o*C+l*O+c*et,s[8]=a*x+o*U+l*W+c*tt,s[12]=a*T+o*Y+l*V+c*rt,s[1]=h*b+d*I+u*Z+p*Q,s[5]=h*R+d*C+u*O+p*et,s[9]=h*x+d*U+u*W+p*tt,s[13]=h*T+d*Y+u*V+p*rt,s[2]=_*b+S*I+m*Z+f*Q,s[6]=_*R+S*C+m*O+f*et,s[10]=_*x+S*U+m*W+f*tt,s[14]=_*T+S*Y+m*V+f*rt,s[3]=A*b+w*I+M*Z+y*Q,s[7]=A*R+w*C+M*O+y*et,s[11]=A*x+w*U+M*W+y*tt,s[15]=A*T+w*Y+M*V+y*rt,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],r=t[8],s=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],S=t[7],m=t[11],f=t[15],A=l*p-c*u,w=o*p-c*d,M=o*u-l*d,y=a*p-c*h,b=a*u-l*h,R=a*d-o*h;return e*(S*A-m*w+f*M)-n*(_*A-m*y+f*b)+r*(_*w-S*y+f*R)-s*(_*M-S*b+m*R)}determinantAffine(){const t=this.elements,e=t[0],n=t[4],r=t[8],s=t[1],a=t[5],o=t[9],l=t[2],c=t[6],h=t[10];return e*(a*h-o*c)-n*(s*h-o*l)+r*(s*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 r=this.elements;return t.isVector3?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],s=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],S=t[13],m=t[14],f=t[15],A=e*o-n*a,w=e*l-r*a,M=e*c-s*a,y=n*l-r*o,b=n*c-s*o,R=r*c-s*l,x=h*S-d*_,T=h*m-u*_,I=h*f-p*_,C=d*m-u*S,U=d*f-p*S,Y=u*f-p*m,Z=A*Y-w*U+M*C+y*I-b*T+R*x;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]=(r*U-n*Y-s*C)*O,t[2]=(S*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-r*I+s*T)*O,t[6]=(m*M-_*R-f*w)*O,t[7]=(h*R-u*M+p*w)*O,t[8]=(a*U-o*I+c*x)*O,t[9]=(n*I-e*U-s*x)*O,t[10]=(_*b-S*M+f*A)*O,t[11]=(d*M-h*b-p*A)*O,t[12]=(o*T-a*C-l*x)*O,t[13]=(e*C-n*T+r*x)*O,t[14]=(S*w-_*y-m*A)*O,t[15]=(h*y-d*w+u*A)*O,this}scale(t){const e=this.elements,n=t.x,r=t.y,s=t.z;return e[0]*=n,e[4]*=r,e[8]*=s,e[1]*=n,e[5]*=r,e[9]*=s,e[2]*=n,e[6]*=r,e[10]*=s,e[3]*=n,e[7]*=r,e[11]*=s,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],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,r))}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),r=Math.sin(e),s=1-n,a=t.x,o=t.y,l=t.z,c=s*a,h=s*o;return this.set(c*a+n,c*o-r*l,c*l+r*o,0,c*o+r*l,h*o+n,h*l-r*a,0,c*l-r*o,h*l+r*a,s*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,r,s,a){return this.set(1,n,s,0,t,1,a,0,e,r,1,0,0,0,0,1),this}compose(t,e,n){const r=this.elements,s=e._x,a=e._y,o=e._z,l=e._w,c=s+s,h=a+a,d=o+o,u=s*c,p=s*h,_=s*d,S=a*h,m=a*d,f=o*d,A=l*c,w=l*h,M=l*d,y=n.x,b=n.y,R=n.z;return r[0]=(1-(S+f))*y,r[1]=(p+M)*y,r[2]=(_-w)*y,r[3]=0,r[4]=(p-M)*b,r[5]=(1-(u+f))*b,r[6]=(m+A)*b,r[7]=0,r[8]=(_+w)*R,r[9]=(m-A)*R,r[10]=(1-(u+S))*R,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this}decompose(t,e,n){const r=this.elements;t.x=r[12],t.y=r[13],t.z=r[14];const s=this.determinantAffine();if(s===0)return n.set(1,1,1),e.identity(),this;let a=_i.set(r[0],r[1],r[2]).length();const o=_i.set(r[4],r[5],r[6]).length(),l=_i.set(r[8],r[9],r[10]).length();s<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,r,s,a,o=fn,l=!1){const c=this.elements,h=2*s/(e-t),d=2*s/(n-r),u=(e+t)/(e-t),p=(n+r)/(n-r);let _,S;if(l)_=s/(a-s),S=a*s/(a-s);else if(o===fn)_=-(a+s)/(a-s),S=-2*a*s/(a-s);else if(o===Ls)_=-a/(a-s),S=-a*s/(a-s);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]=S,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,n,r,s,a,o=fn,l=!1){const c=this.elements,h=2/(e-t),d=2/(n-r),u=-(e+t)/(e-t),p=-(n+r)/(n-r);let _,S;if(l)_=1/(a-s),S=a/(a-s);else if(o===fn)_=-2/(a-s),S=-(a+s)/(a-s);else if(o===Ls)_=-1/(a-s),S=-s/(a-s);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]=S,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let r=0;r<16;r++)if(e[r]!==n[r])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 _i=new F,tn=new le,md=new F(0,0,0),gd=new F(1,1,1),Nn=new F,Lr=new F,Ge=new F,$l=new le,Kl=new Qi;class hi{constructor(t=0,e=0,n=0,r=hi.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=r}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,r=this._order){return this._x=t,this._y=e,this._z=n,this._order=r,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 r=t.elements,s=r[0],a=r[4],o=r[8],l=r[1],c=r[5],h=r[9],d=r[2],u=r[6],p=r[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,s)):(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,s),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,s));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,s)):(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,s)):(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,s)):(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 $l.makeRotationFromQuaternion(t),this.setFromRotationMatrix($l,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Kl.setFromEuler(this),this.setFromQuaternion(Kl,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}}hi.DEFAULT_ORDER="XYZ";class gl{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 _d=0;const Jl=new F,xi=new Qi,_n=new le,Ur=new F,nr=new F,xd=new F,vd=new Qi,Ql=new F(1,0,0),jl=new F(0,1,0),tc=new F(0,0,1),ec={type:"added"},Md={type:"removed"},vi={type:"childadded",child:null},ha={type:"childremoved",child:null};class Oe extends di{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:_d++}),this.uuid=qn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Oe.DEFAULT_UP.clone();const t=new F,e=new hi,n=new Qi,r=new F(1,1,1);function s(){n.setFromEuler(e,!1)}function a(){e.setFromQuaternion(n,void 0,!1)}e._onChange(s),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:r},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 gl,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(Ql,t)}rotateY(t){return this.rotateOnAxis(jl,t)}rotateZ(t){return this.rotateOnAxis(tc,t)}translateOnAxis(t,e){return Jl.copy(t).applyQuaternion(this.quaternion),this.position.add(Jl.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Ql,t)}translateY(t){return this.translateOnAxis(jl,t)}translateZ(t){return this.translateOnAxis(tc,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?Ur.copy(t):Ur.set(t,e,n);const r=this.parent;this.updateWorldMatrix(!0,!1),nr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?_n.lookAt(nr,Ur,this.up):_n.lookAt(Ur,nr,this.up),this.quaternion.setFromRotationMatrix(_n),r&&(_n.extractRotation(r.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(ec),vi.child=t,this.dispatchEvent(vi),vi.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(Md),ha.child=t,this.dispatchEvent(ha),ha.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(ec),vi.child=t,this.dispatchEvent(vi),vi.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,r=this.children.length;n<r;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 r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].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(nr,t,xd),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(nr,vd,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,r=e.length;n<r;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let n=0,r=e.length;n<r;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,r=t.z,s=this.matrix.elements;s[12]+=e-s[0]*e-s[4]*n-s[8]*r,s[13]+=n-s[1]*e-s[5]*n-s[9]*r,s[14]+=r-s[2]*e-s[6]*n-s[10]*r}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,r=e.length;n<r;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e,n=!1){const r=this.parent;if(t===!0&&r!==null&&r.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 s=this.children;for(let a=0,o=s.length;a<o;a++)s[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 r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),this.static!==!1&&(r.static=this.static),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(o=>({...o})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(t),r.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(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];s(t.shapes,d)}else s(t.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),r.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(s(t.materials,this.material[l]));r.material=o}else r.material=s(t.materials,this.material);if(this.children.length>0){r.children=[];for(let o=0;o<this.children.length;o++)r.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){r.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];r.animations.push(s(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=r,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 r=t.children[n];this.add(r.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 Nr extends Oe{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Sd={type:"move"};class ua{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Nr,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 Nr,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 Nr,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 r=null,s=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 S of t.hand.values()){const m=e.getJointPose(S,n),f=this._getHandJoint(c,S);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&&(s=e.getPose(t.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:t,target:this})));o!==null&&(r=e.getPose(t.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Sd)))}return o!==null&&(o.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){const n=new Nr;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}const $h={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},Fr={h:0,s:0,l:0};function da(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 r=t;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}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,r=qt.workingColorSpace){return this.r=t,this.g=e,this.b=n,qt.colorSpaceToWorking(this,r),this}setHSL(t,e,n,r=qt.workingColorSpace){if(t=ld(t,1),e=Yt(e,0,1),n=Yt(n,0,1),e===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+e):n+e-n*e,a=2*n-s;this.r=da(a,s,t+1/3),this.g=da(a,s,t),this.b=da(a,s,t-1/3)}return qt.colorSpaceToWorking(this,r),this}setStyle(t,e=Ze){function n(s){s!==void 0&&parseFloat(s)<1&&Ft("Color: Alpha component of "+t+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(t)){let s;const a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:Ft("Color: Unknown color model "+t)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(t)){const s=r[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(s,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=$h[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=ki(t.r),this.g=ki(t.g),this.b=ki(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,r=Ce.g,s=Ce.b,a=Math.max(n,r,s),o=Math.min(n,r,s);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=(r-s)/d+(r<s?6:0);break;case r:l=(s-n)/d+2;break;case s:l=(n-r)/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,r=Ce.b;return t!==Ze?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(r*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(Fr);const n=sa(Fn.h,Fr.h,e),r=sa(Fn.s,Fr.s,e),s=sa(Fn.l,Fr.l,e);return this.setHSL(n,r,s),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,r=this.b,s=t.elements;return this.r=s[0]*e+s[3]*n+s[6]*r,this.g=s[1]*e+s[4]*n+s[7]*r,this.b=s[2]*e+s[5]*n+s[8]*r,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=$h;class _l{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 _l(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class yd 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 hi,this.environmentIntensity=1,this.environmentRotation=new hi,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,xn=new F,fa=new F,vn=new F,Mi=new F,Si=new F,nc=new F,pa=new F,ma=new F,ga=new F,_a=new fe,xa=new fe,va=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,r){r.subVectors(n,e),en.subVectors(t,e),r.cross(en);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(t,e,n,r,s){en.subVectors(r,e),xn.subVectors(n,e),fa.subVectors(t,e);const a=en.dot(en),o=en.dot(xn),l=en.dot(fa),c=xn.dot(xn),h=xn.dot(fa),d=a*c-o*o;if(d===0)return s.set(0,0,0),null;const u=1/d,p=(c*l-o*h)*u,_=(a*h-o*l)*u;return s.set(1-p-_,_,p)}static containsPoint(t,e,n,r){return this.getBarycoord(t,e,n,r,vn)===null?!1:vn.x>=0&&vn.y>=0&&vn.x+vn.y<=1}static getInterpolation(t,e,n,r,s,a,o,l){return this.getBarycoord(t,e,n,r,vn)===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(s,vn.x),l.addScaledVector(a,vn.y),l.addScaledVector(o,vn.z),l)}static getInterpolatedAttribute(t,e,n,r,s,a){return _a.setScalar(0),xa.setScalar(0),va.setScalar(0),_a.fromBufferAttribute(t,e),xa.fromBufferAttribute(t,n),va.fromBufferAttribute(t,r),a.setScalar(0),a.addScaledVector(_a,s.x),a.addScaledVector(xa,s.y),a.addScaledVector(va,s.z),a}static isFrontFacing(t,e,n,r){return en.subVectors(n,e),xn.subVectors(t,e),en.cross(xn).dot(r)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,r){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[r]),this}setFromAttributeAndIndices(t,e,n,r){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,r),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),xn.subVectors(this.a,this.b),en.cross(xn).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,r,s){return Je.getInterpolation(t,this.a,this.b,this.c,e,n,r,s)}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,r=this.b,s=this.c;let a,o;Mi.subVectors(r,n),Si.subVectors(s,n),pa.subVectors(t,n);const l=Mi.dot(pa),c=Si.dot(pa);if(l<=0&&c<=0)return e.copy(n);ma.subVectors(t,r);const h=Mi.dot(ma),d=Si.dot(ma);if(h>=0&&d<=h)return e.copy(r);const u=l*d-h*c;if(u<=0&&l>=0&&h<=0)return a=l/(l-h),e.copy(n).addScaledVector(Mi,a);ga.subVectors(t,s);const p=Mi.dot(ga),_=Si.dot(ga);if(_>=0&&p<=_)return e.copy(s);const S=p*c-l*_;if(S<=0&&c>=0&&_<=0)return o=c/(c-_),e.copy(n).addScaledVector(Si,o);const m=h*_-p*d;if(m<=0&&d-h>=0&&p-_>=0)return nc.subVectors(s,r),o=(d-h)/(d-h+(p-_)),e.copy(r).addScaledVector(nc,o);const f=1/(m+S+u);return a=S*f,o=u*f,e.copy(n).addScaledVector(Mi,a).addScaledVector(Si,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}class Tr{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 s=n.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let a=0,o=s.count;a<o;a++)t.isMesh===!0?t.getVertexPosition(a,nn):nn.fromBufferAttribute(s,a),nn.applyMatrix4(t.matrixWorld),this.expandByPoint(nn);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Or.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Or.copy(n.boundingBox)),Or.applyMatrix4(t.matrixWorld),this.union(Or)}const r=t.children;for(let s=0,a=r.length;s<a;s++)this.expandByObject(r[s],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,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(ir),Br.subVectors(this.max,ir),yi.subVectors(t.a,ir),Ei.subVectors(t.b,ir),bi.subVectors(t.c,ir),On.subVectors(Ei,yi),Bn.subVectors(bi,Ei),Kn.subVectors(yi,bi);let e=[0,-On.z,On.y,0,-Bn.z,Bn.y,0,-Kn.z,Kn.y,On.z,0,-On.x,Bn.z,0,-Bn.x,Kn.z,0,-Kn.x,-On.y,On.x,0,-Bn.y,Bn.x,0,-Kn.y,Kn.x,0];return!Ma(e,yi,Ei,bi,Br)||(e=[1,0,0,0,1,0,0,0,1],!Ma(e,yi,Ei,bi,Br))?!1:(zr.crossVectors(On,Bn),e=[zr.x,zr.y,zr.z],Ma(e,yi,Ei,bi,Br))}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:(Mn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Mn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Mn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Mn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Mn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Mn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Mn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Mn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Mn),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 Mn=[new F,new F,new F,new F,new F,new F,new F,new F],nn=new F,Or=new Tr,yi=new F,Ei=new F,bi=new F,On=new F,Bn=new F,Kn=new F,ir=new F,Br=new F,zr=new F,Jn=new F;function Ma(i,t,e,n,r){for(let s=0,a=i.length-3;s<=a;s+=3){Jn.fromArray(i,s);const o=r.x*Math.abs(Jn.x)+r.y*Math.abs(Jn.y)+r.z*Math.abs(Jn.z),l=t.dot(Jn),c=e.dot(Jn),h=n.dot(Jn);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const ve=new F,Gr=new Gt;let Ed=0;class pe extends di{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:Ed++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=Fo,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 r=0,s=this.itemSize;r<s;r++)this.array[t+r]=e.array[n+r];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++)Gr.fromBufferAttribute(this,e),Gr.applyMatrix3(t),this.setXY(e,Gr.x,Gr.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)ve.fromBufferAttribute(this,e),ve.applyMatrix3(t),this.setXYZ(e,ve.x,ve.y,ve.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)ve.fromBufferAttribute(this,e),ve.applyMatrix4(t),this.setXYZ(e,ve.x,ve.y,ve.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)ve.fromBufferAttribute(this,e),ve.applyNormalMatrix(t),this.setXYZ(e,ve.x,ve.y,ve.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)ve.fromBufferAttribute(this,e),ve.transformDirection(t),this.setXYZ(e,ve.x,ve.y,ve.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,r){return t*=this.itemSize,this.normalized&&(e=te(e,this.array),n=te(n,this.array),r=te(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=r,this}setXYZW(t,e,n,r,s){return t*=this.itemSize,this.normalized&&(e=te(e,this.array),n=te(n,this.array),r=te(r,this.array),s=te(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=r,this.array[t+3]=s,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==Fo&&(t.usage=this.usage),t}dispose(){this.dispatchEvent({type:"dispose"})}}class Kh extends pe{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class Jh 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 bd=new Tr,rr=new F,Sa=new F;class Ys{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):bd.setFromPoints(t).getCenter(n);let r=0;for(let s=0,a=t.length;s<a;s++)r=Math.max(r,n.distanceToSquared(t[s]));return this.radius=Math.sqrt(r),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;rr.subVectors(t,this.center);const e=rr.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),r=(n-this.radius)*.5;this.center.addScaledVector(rr,r/n),this.radius+=r}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):(Sa.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(rr.copy(t.center).add(Sa)),this.expandByPoint(rr.copy(t.center).sub(Sa))),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 Td=0;const Xe=new le,ya=new Oe,Ti=new F,He=new Tr,sr=new Tr,ye=new F;class Te extends di{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Td++}),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(t){return Array.isArray(t)?this.index=new(rd(t)?Jh:Kh)(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 s=new Ot().getNormalMatrix(t);n.applyNormalMatrix(s),n.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(t),r.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 ya.lookAt(t),ya.updateMatrix(),this.applyMatrix4(ya.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ti).negate(),this.translate(Ti.x,Ti.y,Ti.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const n=[];for(let r=0,s=t.length;r<s;r++){const a=t[r];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 r=0;r<n;r++){const s=t[r];e.setXYZ(r,s.x,s.y,s.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 Tr);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,r=e.length;n<r;n++){const s=e[n];He.setFromBufferAttribute(s),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 Ys);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 s=0,a=e.length;s<a;s++){const o=e[s];sr.setFromBufferAttribute(o),this.morphTargetsRelative?(ye.addVectors(He.min,sr.min),He.expandByPoint(ye),ye.addVectors(He.max,sr.max),He.expandByPoint(ye)):(He.expandByPoint(sr.min),He.expandByPoint(sr.max))}He.getCenter(n);let r=0;for(let s=0,a=t.count;s<a;s++)ye.fromBufferAttribute(t,s),r=Math.max(r,n.distanceToSquared(ye));if(e)for(let s=0,a=e.length;s<a;s++){const o=e[s],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)ye.fromBufferAttribute(o,c),l&&(Ti.fromBufferAttribute(t,c),ye.add(Ti)),r=Math.max(r,n.distanceToSquared(ye))}this.boundingSphere.radius=Math.sqrt(r),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,r=e.normal,s=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 x=0;x<n.count;x++)o[x]=new F,l[x]=new F;const c=new F,h=new F,d=new F,u=new Gt,p=new Gt,_=new Gt,S=new F,m=new F;function f(x,T,I){c.fromBufferAttribute(n,x),h.fromBufferAttribute(n,T),d.fromBufferAttribute(n,I),u.fromBufferAttribute(s,x),p.fromBufferAttribute(s,T),_.fromBufferAttribute(s,I),h.sub(c),d.sub(c),p.sub(u),_.sub(u);const C=1/(p.x*_.y-_.x*p.y);isFinite(C)&&(S.copy(h).multiplyScalar(_.y).addScaledVector(d,-p.y).multiplyScalar(C),m.copy(d).multiplyScalar(p.x).addScaledVector(h,-_.x).multiplyScalar(C),o[x].add(S),o[T].add(S),o[I].add(S),l[x].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 x=0,T=A.length;x<T;++x){const I=A[x],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,M=new F,y=new F,b=new F;function R(x){y.fromBufferAttribute(r,x),b.copy(y);const T=o[x];w.copy(T),w.sub(y.multiplyScalar(y.dot(T))).normalize(),M.crossVectors(b,T);const C=M.dot(l[x])<0?-1:1;a.setXYZW(x,w.x,w.y,w.z,C)}for(let x=0,T=A.length;x<T;++x){const I=A[x],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 r=new F,s=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),S=t.getX(u+1),m=t.getX(u+2);r.fromBufferAttribute(e,_),s.fromBufferAttribute(e,S),a.fromBufferAttribute(e,m),h.subVectors(a,s),d.subVectors(r,s),h.cross(d),o.fromBufferAttribute(n,_),l.fromBufferAttribute(n,S),c.fromBufferAttribute(n,m),o.add(h),l.add(h),c.add(h),n.setXYZ(_,o.x,o.y,o.z),n.setXYZ(S,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)r.fromBufferAttribute(e,u+0),s.fromBufferAttribute(e,u+1),a.fromBufferAttribute(e,u+2),h.subVectors(a,s),d.subVectors(r,s),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 S=0,m=l.length;S<m;S++){o.isInterleavedBufferAttribute?p=l[S]*o.data.stride+o.offset:p=l[S]*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,r=this.attributes;for(const o in r){const l=r[o],c=t(l,n);e.setAttribute(o,c)}const s=this.morphAttributes;for(const o in s){const l=[],c=s[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 r={};let s=!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&&(r[l]=h,s=!0)}s&&(t.data.morphAttributes=r,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 r=t.attributes;for(const c in r){const h=r[c];this.setAttribute(c,h.clone(e))}const s=t.morphAttributes;for(const c in s){const h=[],d=s[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 Ad{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=Fo,this.updateRanges=[],this.version=0,this.uuid=qn()}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 r=0,s=this.stride;r<s;r++)this.array[t+r]=e.array[n+r];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=qn()),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=qn()),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 Fs{constructor(t,e,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=r}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,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=te(e,this.array),n=te(n,this.array),r=te(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=r,this}setXYZW(t,e,n,r,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=te(e,this.array),n=te(n,this.array),r=te(r,this.array),s=te(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=r,this.data.array[t+3]=s,this}clone(t){if(t===void 0){Ns("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[r+s])}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 Fs(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){Ns("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let wd=0;class ji extends di{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:wd++}),this.uuid=qn(),this.name="",this.type="Material",this.blending=Gi,this.side=Zn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Za,this.blendDst=$a,this.blendEquation=ei,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new It(0,0,0),this.blendAlpha=0,this.depthFunc=qi,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Vl,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=mi,this.stencilZFail=mi,this.stencilZPass=mi,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 r=this[e];if(r===void 0){Ft(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector2&&n&&n.isVector2||r&&r.isEuler&&n&&n.isEuler||r&&r.isVector3&&n&&n.isVector3?r.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!==Gi&&(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!==Za&&(n.blendSrc=this.blendSrc),this.blendDst!==$a&&(n.blendDst=this.blendDst),this.blendEquation!==ei&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==qi&&(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!==Vl&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==mi&&(n.stencilFail=this.stencilFail),this.stencilZFail!==mi&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==mi&&(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 r(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(e){const s=r(t.textures),a=r(t.images);s.length>0&&(n.textures=s),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 Gt().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 Gt().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 r=e.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=e[s].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 Fi extends ji{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 Ai;const ar=new F,wi=new F,Ri=new F,Ci=new Gt,or=new Gt,Qh=new le,Hr=new F,lr=new F,kr=new F,ic=new Gt,Ea=new Gt,rc=new Gt;class cr extends Oe{constructor(t=new Fi){if(super(),this.isSprite=!0,this.type="Sprite",Ai===void 0){Ai=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 Ad(e,5);Ai.setIndex([0,1,2,0,2,3]),Ai.setAttribute("position",new Fs(n,3,0,!1)),Ai.setAttribute("uv",new Fs(n,2,3,!1))}this.geometry=Ai,this.material=t,this.center=new Gt(.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.'),wi.setFromMatrixScale(this.matrixWorld),Qh.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),Ri.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&wi.multiplyScalar(-Ri.z);const n=this.material.rotation;let r,s;n!==0&&(s=Math.cos(n),r=Math.sin(n));const a=this.center;Vr(Hr.set(-.5,-.5,0),Ri,a,wi,r,s),Vr(lr.set(.5,-.5,0),Ri,a,wi,r,s),Vr(kr.set(.5,.5,0),Ri,a,wi,r,s),ic.set(0,0),Ea.set(1,0),rc.set(1,1);let o=t.ray.intersectTriangle(Hr,lr,kr,!1,ar);if(o===null&&(Vr(lr.set(-.5,.5,0),Ri,a,wi,r,s),Ea.set(0,1),o=t.ray.intersectTriangle(Hr,kr,lr,!1,ar),o===null))return;const l=t.ray.origin.distanceTo(ar);l<t.near||l>t.far||e.push({distance:l,point:ar.clone(),uv:Je.getInterpolation(ar,Hr,lr,kr,ic,Ea,rc,new Gt),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 Vr(i,t,e,n,r,s){Ci.subVectors(i,e).addScalar(.5).multiply(n),r!==void 0?(or.x=s*Ci.x-r*Ci.y,or.y=r*Ci.x+s*Ci.y):or.copy(Ci),i.copy(t),i.x+=or.x,i.y+=or.y,i.applyMatrix4(Qh)}const Sn=new F,ba=new F,Wr=new F,zn=new F,Ta=new F,Xr=new F,Aa=new F;class xl{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,Sn)),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=Sn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Sn.copy(this.origin).addScaledVector(this.direction,e),Sn.distanceToSquared(t))}distanceSqToSegment(t,e,n,r){ba.copy(t).add(e).multiplyScalar(.5),Wr.copy(e).sub(t).normalize(),zn.copy(this.origin).sub(ba);const s=t.distanceTo(e)*.5,a=-this.direction.dot(Wr),o=zn.dot(this.direction),l=-zn.dot(Wr),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,_=s*h,d>=0)if(u>=-_)if(u<=_){const S=1/h;d*=S,u*=S,p=d*(d+a*u+2*o)+u*(a*d+u+2*l)+c}else u=s,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*l)+c;else u=-s,d=Math.max(0,-(a*u+o)),p=-d*d+u*(u+2*l)+c;else u<=-_?(d=Math.max(0,-(-a*s+o)),u=d>0?-s:Math.min(Math.max(-s,-l),s),p=-d*d+u*(u+2*l)+c):u<=_?(d=0,u=Math.min(Math.max(-s,-l),s),p=u*(u+2*l)+c):(d=Math.max(0,-(a*s+o)),u=d>0?s:Math.min(Math.max(-s,-l),s),p=-d*d+u*(u+2*l)+c);else u=a>0?-s:s,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),r&&r.copy(ba).addScaledVector(Wr,u),p}intersectSphere(t,e){Sn.subVectors(t.center,this.origin);const n=Sn.dot(this.direction),r=Sn.dot(Sn)-n*n,s=t.radius*t.radius;if(r>s)return null;const a=Math.sqrt(s-r),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,r,s,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,r=(t.max.x-u.x)*c):(n=(t.max.x-u.x)*c,r=(t.min.x-u.x)*c),h>=0?(s=(t.min.y-u.y)*h,a=(t.max.y-u.y)*h):(s=(t.max.y-u.y)*h,a=(t.min.y-u.y)*h),n>a||s>r||((s>n||isNaN(n))&&(n=s),(a<r||isNaN(r))&&(r=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>r)||((o>n||n!==n)&&(n=o),(l<r||r!==r)&&(r=l),r<0)?null:this.at(n>=0?n:r,e)}intersectsBox(t){return this.intersectBox(t,Sn)!==null}intersectTriangle(t,e,n,r,s){Ta.subVectors(e,t),Xr.subVectors(n,t),Aa.crossVectors(Ta,Xr);let a=this.direction.dot(Aa),o;if(a>0){if(r)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(Xr.crossVectors(zn,Xr));if(l<0)return null;const c=o*this.direction.dot(Ta.cross(zn));if(c<0||l+c>a)return null;const h=-o*zn.dot(Aa);return h<0?null:this.at(h/a,s)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Vi extends ji{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 hi,this.combine=Ih,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 sc=new le,Qn=new xl,qr=new Ys,ac=new F,Yr=new F,Zr=new F,$r=new F,wa=new F,Kr=new F,oc=new F,Jr=new F;class ke extends Oe{constructor(t=new Te,e=new Vi){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 r=e[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(t,e){const n=this.geometry,r=n.attributes.position,s=n.morphAttributes.position,a=n.morphTargetsRelative;e.fromBufferAttribute(r,t);const o=this.morphTargetInfluences;if(s&&o){Kr.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=o[l],d=s[l];h!==0&&(wa.fromBufferAttribute(d,t),a?Kr.addScaledVector(wa,h):Kr.addScaledVector(wa.sub(e),h))}e.add(Kr)}return e}raycast(t,e){const n=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),qr.copy(n.boundingSphere),qr.applyMatrix4(s),Qn.copy(t.ray).recast(t.near),!(qr.containsPoint(Qn.origin)===!1&&(Qn.intersectSphere(qr,ac)===null||Qn.origin.distanceToSquared(ac)>(t.far-t.near)**2))&&(sc.copy(s).invert(),Qn.copy(t.ray).applyMatrix4(sc),!(n.boundingBox!==null&&Qn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,Qn)))}_computeIntersections(t,e,n){let r;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,d=s.attributes.normal,u=s.groups,p=s.drawRange;if(o!==null)if(Array.isArray(a))for(let _=0,S=u.length;_<S;_++){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 M=A,y=w;M<y;M+=3){const b=o.getX(M),R=o.getX(M+1),x=o.getX(M+2);r=Qr(this,f,t,n,c,h,d,b,R,x),r&&(r.faceIndex=Math.floor(M/3),r.face.materialIndex=m.materialIndex,e.push(r))}}else{const _=Math.max(0,p.start),S=Math.min(o.count,p.start+p.count);for(let m=_,f=S;m<f;m+=3){const A=o.getX(m),w=o.getX(m+1),M=o.getX(m+2);r=Qr(this,a,t,n,c,h,d,A,w,M),r&&(r.faceIndex=Math.floor(m/3),e.push(r))}}else if(l!==void 0)if(Array.isArray(a))for(let _=0,S=u.length;_<S;_++){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 M=A,y=w;M<y;M+=3){const b=M,R=M+1,x=M+2;r=Qr(this,f,t,n,c,h,d,b,R,x),r&&(r.faceIndex=Math.floor(M/3),r.face.materialIndex=m.materialIndex,e.push(r))}}else{const _=Math.max(0,p.start),S=Math.min(l.count,p.start+p.count);for(let m=_,f=S;m<f;m+=3){const A=m,w=m+1,M=m+2;r=Qr(this,a,t,n,c,h,d,A,w,M),r&&(r.faceIndex=Math.floor(m/3),e.push(r))}}}}function Rd(i,t,e,n,r,s,a,o){let l;if(t.side===Fe?l=n.intersectTriangle(a,s,r,!0,o):l=n.intersectTriangle(r,s,a,t.side===Zn,o),l===null)return null;Jr.copy(o),Jr.applyMatrix4(i.matrixWorld);const c=e.ray.origin.distanceTo(Jr);return c<e.near||c>e.far?null:{distance:c,point:Jr.clone(),object:i}}function Qr(i,t,e,n,r,s,a,o,l,c){i.getVertexPosition(o,Yr),i.getVertexPosition(l,Zr),i.getVertexPosition(c,$r);const h=Rd(i,t,e,n,Yr,Zr,$r,oc);if(h){const d=new F;Je.getBarycoord(oc,Yr,Zr,$r,d),r&&(h.uv=Je.getInterpolatedAttribute(r,o,l,c,d,new Gt)),s&&(h.uv1=Je.getInterpolatedAttribute(s,o,l,c,d,new Gt)),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(Yr,Zr,$r,u.normal),h.face=u,h.barycoord=d}return h}class Cd extends De{constructor(t=null,e=1,n=1,r,s,a,o,l,c=Ae,h=Ae,d,u){super(null,a,o,l,c,h,r,s,d,u),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Ra=new F,Pd=new F,Id=new Ot;class ti{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,r){return this.normal.set(t,e,n),this.constant=r,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const r=Ra.subVectors(n,e).cross(Pd.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(r,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 r=t.delta(Ra),s=this.normal.dot(r);if(s===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const a=-(t.start.dot(this.normal)+this.constant)/s;return n===!0&&(a<0||a>1)?null:e.copy(t.start).addScaledVector(r,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||Id.getNormalMatrix(t),r=this.coplanarPoint(Ra).applyMatrix4(t),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const jn=new Ys,Dd=new Gt(.5,.5),jr=new F;class jh{constructor(t=new ti,e=new ti,n=new ti,r=new ti,s=new ti,a=new ti){this.planes=[t,e,n,r,s,a]}set(t,e,n,r,s,a){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(r),o[4].copy(s),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 r=this.planes,s=t.elements,a=s[0],o=s[1],l=s[2],c=s[3],h=s[4],d=s[5],u=s[6],p=s[7],_=s[8],S=s[9],m=s[10],f=s[11],A=s[12],w=s[13],M=s[14],y=s[15];if(r[0].setComponents(c-a,p-h,f-_,y-A).normalize(),r[1].setComponents(c+a,p+h,f+_,y+A).normalize(),r[2].setComponents(c+o,p+d,f+S,y+w).normalize(),r[3].setComponents(c-o,p-d,f-S,y-w).normalize(),n)r[4].setComponents(l,u,m,M).normalize(),r[5].setComponents(c-l,p-u,f-m,y-M).normalize();else if(r[4].setComponents(c-l,p-u,f-m,y-M).normalize(),e===fn)r[5].setComponents(c+l,p+u,f+m,y+M).normalize();else if(e===Ls)r[5].setComponents(l,u,m,M).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),jn.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),jn.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(jn)}intersectsSprite(t){jn.center.set(0,0,0);const e=Dd.distanceTo(t.center);return jn.radius=.7071067811865476+e,jn.applyMatrix4(t.matrixWorld),this.intersectsSphere(jn)}intersectsSphere(t){const e=this.planes,n=t.center,r=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(n)<r)return!1;return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const r=e[n];if(jr.x=r.normal.x>0?t.max.x:t.min.x,jr.y=r.normal.y>0?t.max.y:t.min.y,jr.z=r.normal.z>0?t.max.z:t.min.z,r.distanceToPoint(jr)<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 tu extends ji{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 lc=new le,Bo=new xl,ts=new Ys,es=new F;class As extends Oe{constructor(t=new Te,e=new tu){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,r=this.matrixWorld,s=t.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),ts.copy(n.boundingSphere),ts.applyMatrix4(r),ts.radius+=s,t.ray.intersectsSphere(ts)===!1)return;lc.copy(r).invert(),Bo.copy(t.ray).applyMatrix4(lc);const o=s/((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,S=p;_<S;_++){const m=c.getX(_);es.fromBufferAttribute(d,m),cc(es,m,l,r,t,e,this)}}else{const u=Math.max(0,a.start),p=Math.min(d.count,a.start+a.count);for(let _=u,S=p;_<S;_++)es.fromBufferAttribute(d,_),cc(es,_,l,r,t,e,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const r=e[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=r.length;s<a;s++){const o=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function cc(i,t,e,n,r,s,a){const o=Bo.distanceSqToPoint(i);if(o<e){const l=new F;Bo.closestPointToPoint(i,l),l.applyMatrix4(n);const c=r.ray.origin.distanceTo(l);if(c<r.near||c>r.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:t,face:null,faceIndex:null,barycoord:null,object:a})}}class eu extends De{constructor(t=[],e=li,n,r,s,a,o,l,c,h){super(t,e,n,r,s,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,r,s,a,o,l,c){super(t,e,n,r,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Zi extends De{constructor(t,e,n=gn,r,s,a,o=Ae,l=Ae,c,h=Pn,d=1){if(h!==Pn&&h!==si)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const u={width:t,height:e,depth:d};super(u,r,s,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 ml(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 Ld extends Zi{constructor(t,e=gn,n=li,r,s,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,r,s,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 nu extends De{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}}class Ar extends Te{constructor(t=1,e=1,n=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:r,heightSegments:s,depthSegments:a};const o=this;r=Math.floor(r),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],h=[],d=[];let u=0,p=0;_("z","y","x",-1,-1,n,e,t,a,s,0),_("z","y","x",1,-1,n,e,-t,a,s,1),_("x","z","y",1,1,t,n,e,r,a,2),_("x","z","y",1,-1,t,n,-e,r,a,3),_("x","y","z",1,-1,t,e,n,r,s,4),_("x","y","z",-1,-1,t,e,-n,r,s,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 _(S,m,f,A,w,M,y,b,R,x,T){const I=M/R,C=y/x,U=M/2,Y=y/2,Z=b/2,O=R+1,W=x+1;let V=0,Q=0;const et=new F;for(let tt=0;tt<W;tt++){const rt=tt*C-Y;for(let gt=0;gt<O;gt++){const Vt=gt*I-U;et[S]=Vt*A,et[m]=rt*w,et[f]=Z,c.push(et.x,et.y,et.z),et[S]=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/x),V+=1}}for(let tt=0;tt<x;tt++)for(let rt=0;rt<R;rt++){const gt=u+rt+O*tt,Vt=u+rt+O*(tt+1),re=u+(rt+1)+O*(tt+1),Wt=u+(rt+1)+O*tt;l.push(gt,Vt,Wt),l.push(Vt,re,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 Ar(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class vl extends Te{constructor(t=1,e=32,n=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:r},e=Math.max(3,e);const s=[],a=[],o=[],l=[],c=new F,h=new Gt;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*r;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++)s.push(d,d+1,0);this.setIndex(s),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 vl(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class Zs extends Te{constructor(t=1,e=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:r};const s=t/2,a=e/2,o=Math.floor(n),l=Math.floor(r),c=o+1,h=l+1,d=t/o,u=e/l,p=[],_=[],S=[],m=[];for(let f=0;f<h;f++){const A=f*u-a;for(let w=0;w<c;w++){const M=w*d-s;_.push(M,-A,0),S.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,M=A+c*(f+1),y=A+1+c*(f+1),b=A+1+c*f;p.push(w,M,b),p.push(M,y,b)}this.setIndex(p),this.setAttribute("position",new Le(_,3)),this.setAttribute("normal",new Le(S,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 Zs(t.width,t.height,t.widthSegments,t.heightSegments)}}class Os extends Te{constructor(t=1,e=32,n=16,r=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:r,phiLength:s,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=[],_=[],S=[],m=[];for(let f=0;f<=n;f++){const A=[],w=f/n,M=a+w*o,y=t*Math.cos(M),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 x=0;x<=e;x++){const T=x/e,I=r+T*s;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(),S.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],M=h[f][A],y=h[f+1][A],b=h[f+1][A+1];(f!==0||a>0)&&p.push(w,M,b),(f!==n-1||l<Math.PI)&&p.push(M,y,b)}this.setIndex(p),this.setAttribute("position",new Le(_,3)),this.setAttribute("normal",new Le(S,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 Os(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}function $i(i){const t={};for(const e in i){t[e]={};for(const n in i[e]){const r=i[e][n];if(hc(r))r.isRenderTargetTexture?(Ft("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=r.clone();else if(Array.isArray(r))if(hc(r[0])){const s=[];for(let a=0,o=r.length;a<o;a++)s[a]=r[a].clone();t[e][n]=s}else t[e][n]=r.slice();else t[e][n]=r}}return t}function Ne(i){const t={};for(let e=0;e<i.length;e++){const n=$i(i[e]);for(const r in n)t[r]=n[r]}return t}function hc(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function Ud(i){const t=[];for(let e=0;e<i.length;e++)t.push(i[e].clone());return t}function iu(i){const t=i.getRenderTarget();return t===null?i.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:qt.workingColorSpace}const Nd={clone:$i,merge:Ne};var Fd=`void main() {
|
|
213
229
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
214
|
-
}`,
|
|
230
|
+
}`,Od=`void main() {
|
|
215
231
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
216
|
-
}`;class pn extends Wi{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Bh,this.fragmentShader=zh,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=Vi(e.uniforms),this.uniformsGroups=Fh(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 r in this.uniforms){const a=this.uniforms[r].value;a&&a.isTexture?t.uniforms[r]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[r]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[r]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[r]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[r]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[r]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[r]={type:"m4",value:a.toArray()}:t.uniforms[r]={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 r in this.extensions)this.extensions[r]===!0&&(n[r]=!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 r=e.uniforms[n];switch(this.uniforms[n]={},r.type){case"t":this.uniforms[n].value=t[r.value]||null;break;case"c":this.uniforms[n].value=new Oe().setHex(r.value);break;case"v2":this.uniforms[n].value=new Ve().fromArray(r.value);break;case"v3":this.uniforms[n].value=new F().fromArray(r.value);break;case"v4":this.uniforms[n].value=new dt().fromArray(r.value);break;case"m3":this.uniforms[n].value=new Fe().fromArray(r.value);break;case"m4":this.uniforms[n].value=new lt().fromArray(r.value);break;default:this.uniforms[n].value=r.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 Gh extends pn{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Vh extends Wi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Ju,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 kh extends Wi{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 Wr=new F,Xr=new Hi,sn=new F;class h0 extends Ut{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new lt,this.projectionMatrix=new lt,this.projectionMatrixInverse=new lt,this.coordinateSystem=un,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(Wr,Xr,sn),sn.x===1&&sn.y===1&&sn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Wr,Xr,sn.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Wr,Xr,sn),sn.x===1&&sn.y===1&&sn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Wr,Xr,sn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const On=new F,Vl=new Ve,kl=new Ve;class Xt extends h0{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,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=fo*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Fs*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return fo*2*Math.atan(Math.tan(Fs*.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){On.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(On.x,On.y).multiplyScalar(-e/On.z),On.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(On.x,On.y).multiplyScalar(-e/On.z)}getViewSize(e,t){return this.getViewBounds(e,Vl,kl),t.subVectors(kl,Vl)}setViewOffset(e,t,n,r,s,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=r,this.view.width=s,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(Fs*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,s=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*r/l,t-=a.offsetY*n/c,r*=a.width/l,n*=a.height/c}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,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 f0 extends h0{constructor(e=-1,t=1,n=1,r=-1,s=.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=r,this.near=s,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,r,s,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=r,this.view.width=s,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,r=(this.top+this.bottom)/2;let s=n-e,a=n+e,o=r+t,l=r-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;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(s,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 wi=-90,Ri=1;class Hh extends Ut{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Xt(wi,Ri,e,t);r.layers=this.layers,this.add(r);const s=new Xt(wi,Ri,e,t);s.layers=this.layers,this.add(s);const a=new Xt(wi,Ri,e,t);a.layers=this.layers,this.add(a);const o=new Xt(wi,Ri,e,t);o.layers=this.layers,this.add(o);const l=new Xt(wi,Ri,e,t);l.layers=this.layers,this.add(l);const c=new Xt(wi,Ri,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,r,s,a,o,l]=t;for(const c of t)this.remove(c);if(e===un)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.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===fs)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.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:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,l,c,h]=this.children,f=e.getRenderTarget(),u=e.getActiveCubeFace(),g=e.getActiveMipmapLevel(),_=e.xr.enabled;e.xr.enabled=!1;const S=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,r),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(n,1,r),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,r),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,r),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(n,4,r),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),n.texture.generateMipmaps=S,e.setRenderTarget(n,5,r),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(f,u,g),e.xr.enabled=_,n.texture.needsPMREMUpdate=!0}}class Wh extends Xt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const Hl=new lt;class Xh{constructor(e,t,n=0,r=1/0){this.ray=new Ko(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new qo,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 Hl.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Hl),this}intersectObject(e,t=!0,n=[]){return mo(e,this,n,t),n.sort(Wl),n}intersectObjects(e,t=!0,n=[]){for(let r=0,s=e.length;r<s;r++)mo(e[r],this,n,t);return n.sort(Wl),n}}function Wl(i,e){return i.distance-e.distance}function mo(i,e,t,n){let r=!0;if(i.layers.test(e.layers)&&i.raycast(e,t)===!1&&(r=!1),r===!0&&n===!0){const s=i.children;for(let a=0,o=s.length;a<o;a++)mo(s[a],e,t,!0)}}class d0{static{d0.prototype.isMatrix2=!0}constructor(e,t,n,r){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,r)}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,r){const s=this.elements;return s[0]=e,s[2]=t,s[1]=n,s[3]=r,this}}function Xl(i,e,t,n){const r=qh(n);switch(t){case Jc:return i*e;case jc:return i*e/r.components*r.byteLength;case Go:return i*e/r.components*r.byteLength;case ai:return i*e*2/r.components*r.byteLength;case Vo:return i*e*2/r.components*r.byteLength;case Qc:return i*e*3/r.components*r.byteLength;case en:return i*e*4/r.components*r.byteLength;case ko:return i*e*4/r.components*r.byteLength;case ns:case is:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case rs:case ss:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Fa:case Ba:return Math.max(i,16)*Math.max(e,8)/4;case Na:case Oa:return Math.max(i,8)*Math.max(e,8)/2;case za:case Ga:case ka:case Ha:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Va:case ls:case Wa:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Xa:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case qa:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case Ya:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case Ka:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case Za:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case $a:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case Ja:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case Qa:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case ja:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case eo:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case to:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case no:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case io:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case ro:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case so:case ao:case oo:return Math.ceil(i/4)*Math.ceil(e/4)*16;case lo:case co:return Math.ceil(i/4)*Math.ceil(e/4)*8;case cs:case uo:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function qh(i){switch(i){case qt:case Yc:return{byteLength:1,components:1};case ur:case Kc:case wn:return{byteLength:2,components:1};case Bo:case zo:return{byteLength:2,components:4};case dn:case Oo:case cn:return{byteLength:4,components:1};case Zc:case $c: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:Fo}}));typeof window<"u"&&(window.__THREE__?Ne("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Fo);/**
|
|
232
|
+
}`;class Ve extends ji{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Fd,this.fragmentShader=Od,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=$i(t.uniforms),this.uniformsGroups=Ud(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 r in this.uniforms){const a=this.uniforms[r].value;a&&a.isTexture?e.uniforms[r]={type:"t",value:a.toJSON(t).uuid}:a&&a.isColor?e.uniforms[r]={type:"c",value:a.getHex()}:a&&a.isVector2?e.uniforms[r]={type:"v2",value:a.toArray()}:a&&a.isVector3?e.uniforms[r]={type:"v3",value:a.toArray()}:a&&a.isVector4?e.uniforms[r]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?e.uniforms[r]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?e.uniforms[r]={type:"m4",value:a.toArray()}:e.uniforms[r]={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 r in this.extensions)this.extensions[r]===!0&&(n[r]=!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 r=t.uniforms[n];switch(this.uniforms[n]={},r.type){case"t":this.uniforms[n].value=e[r.value]||null;break;case"c":this.uniforms[n].value=new It().setHex(r.value);break;case"v2":this.uniforms[n].value=new Gt().fromArray(r.value);break;case"v3":this.uniforms[n].value=new F().fromArray(r.value);break;case"v4":this.uniforms[n].value=new fe().fromArray(r.value);break;case"m3":this.uniforms[n].value=new Ot().fromArray(r.value);break;case"m4":this.uniforms[n].value=new le().fromArray(r.value);break;default:this.uniforms[n].value=r.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 Bd extends Ve{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class zd extends ji{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=K0,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 Gd extends ji{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 ns=new F,is=new Qi,ln=new F;class ru 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(ns,is,ln),ln.x===1&&ln.y===1&&ln.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(ns,is,ln.set(1,1,1)).invert()}updateWorldMatrix(t,e,n=!1){super.updateWorldMatrix(t,e,n),this.matrixWorld.decompose(ns,is,ln),ln.x===1&&ln.y===1&&ln.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(ns,is,ln.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const Gn=new F,uc=new Gt,dc=new Gt;class $e extends ru{constructor(t=50,e=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=r,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=Oo*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(ra*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return Oo*2*Math.atan(Math.tan(ra*.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){Gn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(Gn.x,Gn.y).multiplyScalar(-t/Gn.z),Gn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Gn.x,Gn.y).multiplyScalar(-t/Gn.z)}getViewSize(t,e){return this.getViewBounds(t,uc,dc),e.subVectors(dc,uc)}setViewOffset(t,e,n,r,s,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=r,this.view.width=s,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(ra*.5*this.fov)/this.zoom,n=2*e,r=this.aspect*n,s=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*r/l,e-=a.offsetY*n/c,r*=a.width/l,n*=a.height/c}const o=this.filmOffset;o!==0&&(s+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,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 su extends ru{constructor(t=-1,e=1,n=1,r=-1,s=.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=r,this.near=s,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,r,s,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=r,this.view.width=s,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,r=(this.top+this.bottom)/2;let s=n-t,a=n+t,o=r+e,l=r-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;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(s,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 Pi=-90,Ii=1;class Hd extends Oe{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new $e(Pi,Ii,t,e);r.layers=this.layers,this.add(r);const s=new $e(Pi,Ii,t,e);s.layers=this.layers,this.add(s);const a=new $e(Pi,Ii,t,e);a.layers=this.layers,this.add(a);const o=new $e(Pi,Ii,t,e);o.layers=this.layers,this.add(o);const l=new $e(Pi,Ii,t,e);l.layers=this.layers,this.add(l);const c=new $e(Pi,Ii,t,e);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,r,s,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),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.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===Ls)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.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:r}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,l,c,h]=this.children,d=t.getRenderTarget(),u=t.getActiveCubeFace(),p=t.getActiveMipmapLevel(),_=t.xr.enabled;t.xr.enabled=!1;const S=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,r),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,s),t.setRenderTarget(n,1,r),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,a),t.setRenderTarget(n,2,r),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,o),t.setRenderTarget(n,3,r),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,l),t.setRenderTarget(n,4,r),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,c),n.texture.generateMipmaps=S,t.setRenderTarget(n,5,r),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,h),t.setRenderTarget(d,u,p),t.xr.enabled=_,n.texture.needsPMREMUpdate=!0}}class kd extends $e{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}const fc=new le;class Vd{constructor(t,e,n=0,r=1/0){this.ray=new xl(t,e),this.near=n,this.far=r,this.camera=null,this.layers=new gl,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 fc.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(fc),this}intersectObject(t,e=!0,n=[]){return zo(t,this,n,e),n.sort(pc),n}intersectObjects(t,e=!0,n=[]){for(let r=0,s=t.length;r<s;r++)zo(t[r],this,n,e);return n.sort(pc),n}}function pc(i,t){return i.distance-t.distance}function zo(i,t,e,n){let r=!0;if(i.layers.test(t.layers)&&i.raycast(t,e)===!1&&(r=!1),r===!0&&n===!0){const s=i.children;for(let a=0,o=s.length;a<o;a++)zo(s[a],t,e,!0)}}class au{static{au.prototype.isMatrix2=!0}constructor(t,e,n,r){this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,n,r)}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,r){const s=this.elements;return s[0]=t,s[2]=e,s[1]=n,s[3]=r,this}}function mc(i,t,e,n){const r=Wd(n);switch(e){case Wh:return i*t;case qh:return i*t/r.components*r.byteLength;case hl:return i*t/r.components*r.byteLength;case ci:return i*t*2/r.components*r.byteLength;case ul:return i*t*2/r.components*r.byteLength;case Xh:return i*t*3/r.components*r.byteLength;case rn:return i*t*4/r.components*r.byteLength;case dl:return i*t*4/r.components*r.byteLength;case ys:case Es:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case bs:case Ts:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case ao:case lo:return Math.max(i,16)*Math.max(t,8)/4;case so:case oo:return Math.max(i,8)*Math.max(t,8)/2;case co:case ho:case fo:case po:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case uo:case Cs:case mo:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case go:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case _o:return Math.floor((i+4)/5)*Math.floor((t+3)/4)*16;case xo:return Math.floor((i+4)/5)*Math.floor((t+4)/5)*16;case vo:return Math.floor((i+5)/6)*Math.floor((t+4)/5)*16;case Mo:return Math.floor((i+5)/6)*Math.floor((t+5)/6)*16;case So:return Math.floor((i+7)/8)*Math.floor((t+4)/5)*16;case yo:return Math.floor((i+7)/8)*Math.floor((t+5)/6)*16;case Eo:return Math.floor((i+7)/8)*Math.floor((t+7)/8)*16;case bo:return Math.floor((i+9)/10)*Math.floor((t+4)/5)*16;case To:return Math.floor((i+9)/10)*Math.floor((t+5)/6)*16;case Ao:return Math.floor((i+9)/10)*Math.floor((t+7)/8)*16;case wo:return Math.floor((i+9)/10)*Math.floor((t+9)/10)*16;case Ro:return Math.floor((i+11)/12)*Math.floor((t+9)/10)*16;case Co:return Math.floor((i+11)/12)*Math.floor((t+11)/12)*16;case Po:case Io:case Do:return Math.ceil(i/4)*Math.ceil(t/4)*16;case Lo:case Uo:return Math.ceil(i/4)*Math.ceil(t/4)*8;case Ps:case No:return Math.ceil(i/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function Wd(i){switch(i){case Ke:case Gh:return{byteLength:1,components:1};case Er:case Hh:case Cn:return{byteLength:2,components:1};case ll:case cl:return{byteLength:2,components:4};case gn:case ol:case dn:return{byteLength:4,components:1};case kh:case Vh: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:al}}));typeof window<"u"&&(window.__THREE__?Ft("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=al);/**
|
|
217
233
|
* @license
|
|
218
234
|
* Copyright 2010-2026 Three.js Authors
|
|
219
235
|
* SPDX-License-Identifier: MIT
|
|
220
|
-
*/function
|
|
236
|
+
*/function ou(){let i=null,t=!1,e=null,n=null;function r(s,a){e(s,a),n=i.requestAnimationFrame(r)}return{start:function(){t!==!0&&e!==null&&i!==null&&(n=i.requestAnimationFrame(r),t=!0)},stop:function(){i!==null&&i.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(s){e=s},setContext:function(s){i=s}}}function Xd(i){const t=new WeakMap;function e(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],S=d[p];S.start<=_.start+_.count+1?_.count=Math.max(_.count,S.start+S.count-_.start):(++u,d[u]=S)}d.length=u+1;for(let p=0,_=d.length;p<_;p++){const S=d[p];i.bufferSubData(c,S.start*h.BYTES_PER_ELEMENT,h,S.start,S.count)}l.clearUpdateRanges()}l.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),t.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=t.get(o);l&&(i.deleteBuffer(l.buffer),t.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const h=t.get(o);(!h||h.version<o.version)&&t.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=t.get(o);if(c===void 0)t.set(o,e(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:r,remove:s,update:a}}var qd=`#ifdef USE_ALPHAHASH
|
|
221
237
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
222
|
-
#endif`,
|
|
238
|
+
#endif`,Yd=`#ifdef USE_ALPHAHASH
|
|
223
239
|
const float ALPHA_HASH_SCALE = 0.05;
|
|
224
240
|
float hash2D( vec2 value ) {
|
|
225
241
|
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
|
|
@@ -254,20 +270,20 @@ input[type=range] {
|
|
|
254
270
|
: cases.z;
|
|
255
271
|
return clamp( threshold , 1.0e-6, 1.0 );
|
|
256
272
|
}
|
|
257
|
-
#endif
|
|
273
|
+
#endif`,Zd=`#ifdef USE_ALPHAMAP
|
|
258
274
|
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
|
259
|
-
#endif
|
|
275
|
+
#endif`,$d=`#ifdef USE_ALPHAMAP
|
|
260
276
|
uniform sampler2D alphaMap;
|
|
261
|
-
#endif`,
|
|
277
|
+
#endif`,Kd=`#ifdef USE_ALPHATEST
|
|
262
278
|
#ifdef ALPHA_TO_COVERAGE
|
|
263
279
|
diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
|
|
264
280
|
if ( diffuseColor.a == 0.0 ) discard;
|
|
265
281
|
#else
|
|
266
282
|
if ( diffuseColor.a < alphaTest ) discard;
|
|
267
283
|
#endif
|
|
268
|
-
#endif`,
|
|
284
|
+
#endif`,Jd=`#ifdef USE_ALPHATEST
|
|
269
285
|
uniform float alphaTest;
|
|
270
|
-
#endif`,
|
|
286
|
+
#endif`,Qd=`#ifdef USE_AOMAP
|
|
271
287
|
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
|
|
272
288
|
reflectedLight.indirectDiffuse *= ambientOcclusion;
|
|
273
289
|
#if defined( USE_CLEARCOAT )
|
|
@@ -280,10 +296,10 @@ input[type=range] {
|
|
|
280
296
|
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
|
|
281
297
|
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
|
|
282
298
|
#endif
|
|
283
|
-
#endif`,
|
|
299
|
+
#endif`,jd=`#ifdef USE_AOMAP
|
|
284
300
|
uniform sampler2D aoMap;
|
|
285
301
|
uniform float aoMapIntensity;
|
|
286
|
-
#endif`,
|
|
302
|
+
#endif`,tf=`#ifdef USE_BATCHING
|
|
287
303
|
#if ! defined( GL_ANGLE_multi_draw )
|
|
288
304
|
#define gl_DrawID _gl_DrawID
|
|
289
305
|
uniform int _gl_DrawID;
|
|
@@ -317,15 +333,15 @@ input[type=range] {
|
|
|
317
333
|
int y = j / size;
|
|
318
334
|
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
|
|
319
335
|
}
|
|
320
|
-
#endif`,
|
|
336
|
+
#endif`,ef=`#ifdef USE_BATCHING
|
|
321
337
|
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
|
322
|
-
#endif`,
|
|
338
|
+
#endif`,nf=`vec3 transformed = vec3( position );
|
|
323
339
|
#ifdef USE_ALPHAHASH
|
|
324
340
|
vPosition = vec3( position );
|
|
325
|
-
#endif`,
|
|
341
|
+
#endif`,rf=`vec3 objectNormal = vec3( normal );
|
|
326
342
|
#ifdef USE_TANGENT
|
|
327
343
|
vec3 objectTangent = vec3( tangent.xyz );
|
|
328
|
-
#endif`,
|
|
344
|
+
#endif`,sf=`float G_BlinnPhong_Implicit( ) {
|
|
329
345
|
return 0.25;
|
|
330
346
|
}
|
|
331
347
|
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
|
|
@@ -339,7 +355,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
339
355
|
float G = G_BlinnPhong_Implicit( );
|
|
340
356
|
float D = D_BlinnPhong( shininess, dotNH );
|
|
341
357
|
return F * ( G * D );
|
|
342
|
-
} // validated`,
|
|
358
|
+
} // validated`,af=`#ifdef USE_IRIDESCENCE
|
|
343
359
|
const mat3 XYZ_TO_REC709 = mat3(
|
|
344
360
|
3.2404542, -0.9692660, 0.0556434,
|
|
345
361
|
-1.5371385, 1.8760108, -0.2040259,
|
|
@@ -402,7 +418,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
402
418
|
}
|
|
403
419
|
return max( I, vec3( 0.0 ) );
|
|
404
420
|
}
|
|
405
|
-
#endif`,
|
|
421
|
+
#endif`,of=`#ifdef USE_BUMPMAP
|
|
406
422
|
uniform sampler2D bumpMap;
|
|
407
423
|
uniform float bumpScale;
|
|
408
424
|
vec2 dHdxy_fwd() {
|
|
@@ -423,7 +439,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
423
439
|
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
|
424
440
|
return normalize( abs( fDet ) * surf_norm - vGrad );
|
|
425
441
|
}
|
|
426
|
-
#endif`,
|
|
442
|
+
#endif`,lf=`#if NUM_CLIPPING_PLANES > 0
|
|
427
443
|
vec4 plane;
|
|
428
444
|
#ifdef ALPHA_TO_COVERAGE
|
|
429
445
|
float distanceToPlane, distanceGradient;
|
|
@@ -469,20 +485,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
469
485
|
if ( clipped ) discard;
|
|
470
486
|
#endif
|
|
471
487
|
#endif
|
|
472
|
-
#endif`,
|
|
488
|
+
#endif`,cf=`#if NUM_CLIPPING_PLANES > 0
|
|
473
489
|
varying vec3 vClipPosition;
|
|
474
490
|
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
|
475
|
-
#endif`,
|
|
491
|
+
#endif`,hf=`#if NUM_CLIPPING_PLANES > 0
|
|
476
492
|
varying vec3 vClipPosition;
|
|
477
|
-
#endif`,
|
|
493
|
+
#endif`,uf=`#if NUM_CLIPPING_PLANES > 0
|
|
478
494
|
vClipPosition = - mvPosition.xyz;
|
|
479
|
-
#endif`,
|
|
495
|
+
#endif`,df=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
|
480
496
|
diffuseColor *= vColor;
|
|
481
|
-
#endif`,
|
|
497
|
+
#endif`,ff=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
|
482
498
|
varying vec4 vColor;
|
|
483
|
-
#endif`,
|
|
499
|
+
#endif`,pf=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
484
500
|
varying vec4 vColor;
|
|
485
|
-
#endif`,
|
|
501
|
+
#endif`,mf=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
486
502
|
vColor = vec4( 1.0 );
|
|
487
503
|
#endif
|
|
488
504
|
#ifdef USE_COLOR_ALPHA
|
|
@@ -495,7 +511,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
495
511
|
#endif
|
|
496
512
|
#ifdef USE_BATCHING_COLOR
|
|
497
513
|
vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
|
|
498
|
-
#endif`,
|
|
514
|
+
#endif`,gf=`#define PI 3.141592653589793
|
|
499
515
|
#define PI2 6.283185307179586
|
|
500
516
|
#define PI_HALF 1.5707963267948966
|
|
501
517
|
#define RECIPROCAL_PI 0.3183098861837907
|
|
@@ -566,7 +582,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
|
|
|
566
582
|
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
|
567
583
|
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
|
568
584
|
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
|
569
|
-
} // validated`,
|
|
585
|
+
} // validated`,_f=`#ifdef ENVMAP_TYPE_CUBE_UV
|
|
570
586
|
#define cubeUV_minMipLevel 4.0
|
|
571
587
|
#define cubeUV_minTileSize 16.0
|
|
572
588
|
float getFace( vec3 direction ) {
|
|
@@ -659,7 +675,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
|
|
659
675
|
return vec4( mix( color0, color1, mipF ), 1.0 );
|
|
660
676
|
}
|
|
661
677
|
}
|
|
662
|
-
#endif`,
|
|
678
|
+
#endif`,xf=`vec3 transformedNormal = objectNormal;
|
|
663
679
|
#ifdef USE_TANGENT
|
|
664
680
|
vec3 transformedTangent = objectTangent;
|
|
665
681
|
#endif
|
|
@@ -685,21 +701,21 @@ transformedNormal = normalMatrix * transformedNormal;
|
|
|
685
701
|
#endif
|
|
686
702
|
#ifdef USE_TANGENT
|
|
687
703
|
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
|
|
688
|
-
#endif`,
|
|
704
|
+
#endif`,vf=`#ifdef USE_DISPLACEMENTMAP
|
|
689
705
|
uniform sampler2D displacementMap;
|
|
690
706
|
uniform float displacementScale;
|
|
691
707
|
uniform float displacementBias;
|
|
692
|
-
#endif`,
|
|
708
|
+
#endif`,Mf=`#ifdef USE_DISPLACEMENTMAP
|
|
693
709
|
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
|
694
|
-
#endif`,
|
|
710
|
+
#endif`,Sf=`#ifdef USE_EMISSIVEMAP
|
|
695
711
|
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
|
696
712
|
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
|
|
697
713
|
emissiveColor = sRGBTransferEOTF( emissiveColor );
|
|
698
714
|
#endif
|
|
699
715
|
totalEmissiveRadiance *= emissiveColor.rgb;
|
|
700
|
-
#endif`,
|
|
716
|
+
#endif`,yf=`#ifdef USE_EMISSIVEMAP
|
|
701
717
|
uniform sampler2D emissiveMap;
|
|
702
|
-
#endif`,
|
|
718
|
+
#endif`,Ef="gl_FragColor = linearToOutputTexel( gl_FragColor );",bf=`vec4 LinearTransferOETF( in vec4 value ) {
|
|
703
719
|
return value;
|
|
704
720
|
}
|
|
705
721
|
vec4 sRGBTransferEOTF( in vec4 value ) {
|
|
@@ -707,7 +723,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {
|
|
|
707
723
|
}
|
|
708
724
|
vec4 sRGBTransferOETF( in vec4 value ) {
|
|
709
725
|
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 );
|
|
710
|
-
}`,
|
|
726
|
+
}`,Tf=`#ifdef USE_ENVMAP
|
|
711
727
|
#ifdef ENV_WORLDPOS
|
|
712
728
|
vec3 cameraToFrag;
|
|
713
729
|
if ( isOrthographic ) {
|
|
@@ -734,7 +750,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
734
750
|
outgoingLight += envColor.xyz * specularStrength * reflectivity;
|
|
735
751
|
#endif
|
|
736
752
|
#endif
|
|
737
|
-
#endif`,
|
|
753
|
+
#endif`,Af=`#ifdef USE_ENVMAP
|
|
738
754
|
uniform float envMapIntensity;
|
|
739
755
|
uniform mat3 envMapRotation;
|
|
740
756
|
#ifdef ENVMAP_TYPE_CUBE
|
|
@@ -742,7 +758,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
742
758
|
#else
|
|
743
759
|
uniform sampler2D envMap;
|
|
744
760
|
#endif
|
|
745
|
-
#endif`,
|
|
761
|
+
#endif`,wf=`#ifdef USE_ENVMAP
|
|
746
762
|
uniform float reflectivity;
|
|
747
763
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
748
764
|
#define ENV_WORLDPOS
|
|
@@ -753,7 +769,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
753
769
|
#else
|
|
754
770
|
varying vec3 vReflect;
|
|
755
771
|
#endif
|
|
756
|
-
#endif`,
|
|
772
|
+
#endif`,Rf=`#ifdef USE_ENVMAP
|
|
757
773
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
758
774
|
#define ENV_WORLDPOS
|
|
759
775
|
#endif
|
|
@@ -764,7 +780,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
764
780
|
varying vec3 vReflect;
|
|
765
781
|
uniform float refractionRatio;
|
|
766
782
|
#endif
|
|
767
|
-
#endif`,
|
|
783
|
+
#endif`,Cf=`#ifdef USE_ENVMAP
|
|
768
784
|
#ifdef ENV_WORLDPOS
|
|
769
785
|
vWorldPosition = worldPosition.xyz;
|
|
770
786
|
#else
|
|
@@ -781,18 +797,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
781
797
|
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
|
|
782
798
|
#endif
|
|
783
799
|
#endif
|
|
784
|
-
#endif`,
|
|
800
|
+
#endif`,Pf=`#ifdef USE_FOG
|
|
785
801
|
vFogDepth = - mvPosition.z;
|
|
786
|
-
#endif`,
|
|
802
|
+
#endif`,If=`#ifdef USE_FOG
|
|
787
803
|
varying float vFogDepth;
|
|
788
|
-
#endif`,
|
|
804
|
+
#endif`,Df=`#ifdef USE_FOG
|
|
789
805
|
#ifdef FOG_EXP2
|
|
790
806
|
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
|
|
791
807
|
#else
|
|
792
808
|
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
|
|
793
809
|
#endif
|
|
794
810
|
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
|
|
795
|
-
#endif`,
|
|
811
|
+
#endif`,Lf=`#ifdef USE_FOG
|
|
796
812
|
uniform vec3 fogColor;
|
|
797
813
|
varying float vFogDepth;
|
|
798
814
|
#ifdef FOG_EXP2
|
|
@@ -801,7 +817,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
801
817
|
uniform float fogNear;
|
|
802
818
|
uniform float fogFar;
|
|
803
819
|
#endif
|
|
804
|
-
#endif`,
|
|
820
|
+
#endif`,Uf=`#ifdef USE_GRADIENTMAP
|
|
805
821
|
uniform sampler2D gradientMap;
|
|
806
822
|
#endif
|
|
807
823
|
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
@@ -813,12 +829,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
|
813
829
|
vec2 fw = fwidth( coord ) * 0.5;
|
|
814
830
|
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
|
|
815
831
|
#endif
|
|
816
|
-
}`,
|
|
832
|
+
}`,Nf=`#ifdef USE_LIGHTMAP
|
|
817
833
|
uniform sampler2D lightMap;
|
|
818
834
|
uniform float lightMapIntensity;
|
|
819
|
-
#endif`,
|
|
835
|
+
#endif`,Ff=`LambertMaterial material;
|
|
820
836
|
material.diffuseColor = diffuseColor.rgb;
|
|
821
|
-
material.specularStrength = specularStrength;`,
|
|
837
|
+
material.specularStrength = specularStrength;`,Of=`varying vec3 vViewPosition;
|
|
822
838
|
struct LambertMaterial {
|
|
823
839
|
vec3 diffuseColor;
|
|
824
840
|
float specularStrength;
|
|
@@ -832,7 +848,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
|
|
|
832
848
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
833
849
|
}
|
|
834
850
|
#define RE_Direct RE_Direct_Lambert
|
|
835
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,
|
|
851
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Bf=`uniform bool receiveShadow;
|
|
836
852
|
uniform vec3 ambientLightColor;
|
|
837
853
|
#if defined( USE_LIGHT_PROBES )
|
|
838
854
|
uniform vec3 lightProbe[ 9 ];
|
|
@@ -949,7 +965,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
949
965
|
return irradiance;
|
|
950
966
|
}
|
|
951
967
|
#endif
|
|
952
|
-
#include <lightprobes_pars_fragment>`,
|
|
968
|
+
#include <lightprobes_pars_fragment>`,zf=`#ifdef USE_ENVMAP
|
|
953
969
|
vec3 getIBLIrradiance( const in vec3 normal ) {
|
|
954
970
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
955
971
|
vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
|
|
@@ -982,7 +998,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
982
998
|
#endif
|
|
983
999
|
}
|
|
984
1000
|
#endif
|
|
985
|
-
#endif`,
|
|
1001
|
+
#endif`,Gf=`ToonMaterial material;
|
|
986
1002
|
material.diffuseColor = diffuseColor.rgb;`,Hf=`varying vec3 vViewPosition;
|
|
987
1003
|
struct ToonMaterial {
|
|
988
1004
|
vec3 diffuseColor;
|
|
@@ -995,11 +1011,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
|
|
|
995
1011
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
996
1012
|
}
|
|
997
1013
|
#define RE_Direct RE_Direct_Toon
|
|
998
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,
|
|
1014
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,kf=`BlinnPhongMaterial material;
|
|
999
1015
|
material.diffuseColor = diffuseColor.rgb;
|
|
1000
1016
|
material.specularColor = specular;
|
|
1001
1017
|
material.specularShininess = shininess;
|
|
1002
|
-
material.specularStrength = specularStrength;`,
|
|
1018
|
+
material.specularStrength = specularStrength;`,Vf=`varying vec3 vViewPosition;
|
|
1003
1019
|
struct BlinnPhongMaterial {
|
|
1004
1020
|
vec3 diffuseColor;
|
|
1005
1021
|
vec3 specularColor;
|
|
@@ -1016,7 +1032,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
|
|
|
1016
1032
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
1017
1033
|
}
|
|
1018
1034
|
#define RE_Direct RE_Direct_BlinnPhong
|
|
1019
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,
|
|
1035
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Wf=`PhysicalMaterial material;
|
|
1020
1036
|
material.diffuseColor = diffuseColor.rgb;
|
|
1021
1037
|
material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
|
1022
1038
|
material.metalness = metalnessFactor;
|
|
@@ -1106,7 +1122,7 @@ material.roughness = min( material.roughness, 1.0 );
|
|
|
1106
1122
|
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
|
|
1107
1123
|
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
|
|
1108
1124
|
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
|
|
1109
|
-
#endif`,
|
|
1125
|
+
#endif`,Xf=`uniform sampler2D dfgLUT;
|
|
1110
1126
|
struct PhysicalMaterial {
|
|
1111
1127
|
vec3 diffuseColor;
|
|
1112
1128
|
vec3 diffuseContribution;
|
|
@@ -1466,7 +1482,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
|
|
|
1466
1482
|
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
|
1467
1483
|
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
|
1468
1484
|
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
|
1469
|
-
}`,
|
|
1485
|
+
}`,qf=`
|
|
1470
1486
|
vec3 geometryPosition = - vViewPosition;
|
|
1471
1487
|
vec3 geometryNormal = normal;
|
|
1472
1488
|
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
@@ -1588,7 +1604,7 @@ IncidentLight directLight;
|
|
|
1588
1604
|
#if defined( RE_IndirectSpecular )
|
|
1589
1605
|
vec3 radiance = vec3( 0.0 );
|
|
1590
1606
|
vec3 clearcoatRadiance = vec3( 0.0 );
|
|
1591
|
-
#endif`,
|
|
1607
|
+
#endif`,Yf=`#if defined( RE_IndirectDiffuse )
|
|
1592
1608
|
#ifdef USE_LIGHTMAP
|
|
1593
1609
|
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
1594
1610
|
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
|
@@ -1609,7 +1625,7 @@ IncidentLight directLight;
|
|
|
1609
1625
|
#ifdef USE_CLEARCOAT
|
|
1610
1626
|
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
|
|
1611
1627
|
#endif
|
|
1612
|
-
#endif
|
|
1628
|
+
#endif`,Zf=`#if defined( RE_IndirectDiffuse )
|
|
1613
1629
|
#if defined( LAMBERT ) || defined( PHONG )
|
|
1614
1630
|
irradiance += iblIrradiance;
|
|
1615
1631
|
#endif
|
|
@@ -1617,7 +1633,7 @@ IncidentLight directLight;
|
|
|
1617
1633
|
#endif
|
|
1618
1634
|
#if defined( RE_IndirectSpecular )
|
|
1619
1635
|
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1620
|
-
#endif
|
|
1636
|
+
#endif`,$f=`#ifdef USE_LIGHT_PROBES_GRID
|
|
1621
1637
|
uniform highp sampler3D probesSH;
|
|
1622
1638
|
uniform vec3 probesMin;
|
|
1623
1639
|
uniform vec3 probesMax;
|
|
@@ -1662,27 +1678,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1662
1678
|
result += c8 * 0.429043 * ( x * x - y * y );
|
|
1663
1679
|
return max( result, vec3( 0.0 ) );
|
|
1664
1680
|
}
|
|
1665
|
-
#endif`,
|
|
1681
|
+
#endif`,Kf=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
1666
1682
|
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
|
1667
|
-
#endif`,
|
|
1683
|
+
#endif`,Jf=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
1668
1684
|
uniform float logDepthBufFC;
|
|
1669
1685
|
varying float vFragDepth;
|
|
1670
1686
|
varying float vIsPerspective;
|
|
1671
|
-
#endif`,
|
|
1687
|
+
#endif`,Qf=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
1672
1688
|
varying float vFragDepth;
|
|
1673
1689
|
varying float vIsPerspective;
|
|
1674
|
-
#endif`,
|
|
1690
|
+
#endif`,jf=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
1675
1691
|
vFragDepth = 1.0 + gl_Position.w;
|
|
1676
1692
|
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
1677
|
-
#endif`,
|
|
1693
|
+
#endif`,tp=`#ifdef USE_MAP
|
|
1678
1694
|
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
|
1679
1695
|
#ifdef DECODE_VIDEO_TEXTURE
|
|
1680
1696
|
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
|
|
1681
1697
|
#endif
|
|
1682
1698
|
diffuseColor *= sampledDiffuseColor;
|
|
1683
|
-
#endif`,
|
|
1699
|
+
#endif`,ep=`#ifdef USE_MAP
|
|
1684
1700
|
uniform sampler2D map;
|
|
1685
|
-
#endif`,
|
|
1701
|
+
#endif`,np=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
1686
1702
|
#if defined( USE_POINTS_UV )
|
|
1687
1703
|
vec2 uv = vUv;
|
|
1688
1704
|
#else
|
|
@@ -1694,7 +1710,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1694
1710
|
#endif
|
|
1695
1711
|
#ifdef USE_ALPHAMAP
|
|
1696
1712
|
diffuseColor.a *= texture2D( alphaMap, uv ).g;
|
|
1697
|
-
#endif`,
|
|
1713
|
+
#endif`,ip=`#if defined( USE_POINTS_UV )
|
|
1698
1714
|
varying vec2 vUv;
|
|
1699
1715
|
#else
|
|
1700
1716
|
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
@@ -1706,19 +1722,19 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1706
1722
|
#endif
|
|
1707
1723
|
#ifdef USE_ALPHAMAP
|
|
1708
1724
|
uniform sampler2D alphaMap;
|
|
1709
|
-
#endif`,
|
|
1725
|
+
#endif`,rp=`float metalnessFactor = metalness;
|
|
1710
1726
|
#ifdef USE_METALNESSMAP
|
|
1711
1727
|
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
|
1712
1728
|
metalnessFactor *= texelMetalness.b;
|
|
1713
|
-
#endif`,
|
|
1729
|
+
#endif`,sp=`#ifdef USE_METALNESSMAP
|
|
1714
1730
|
uniform sampler2D metalnessMap;
|
|
1715
|
-
#endif`,
|
|
1731
|
+
#endif`,ap=`#ifdef USE_INSTANCING_MORPH
|
|
1716
1732
|
float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
1717
1733
|
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
|
|
1718
1734
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1719
1735
|
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
|
|
1720
1736
|
}
|
|
1721
|
-
#endif`,
|
|
1737
|
+
#endif`,op=`#if defined( USE_MORPHCOLORS )
|
|
1722
1738
|
vColor *= morphTargetBaseInfluence;
|
|
1723
1739
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1724
1740
|
#if defined( USE_COLOR_ALPHA )
|
|
@@ -1727,12 +1743,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1727
1743
|
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
|
|
1728
1744
|
#endif
|
|
1729
1745
|
}
|
|
1730
|
-
#endif`,
|
|
1746
|
+
#endif`,lp=`#ifdef USE_MORPHNORMALS
|
|
1731
1747
|
objectNormal *= morphTargetBaseInfluence;
|
|
1732
1748
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1733
1749
|
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
|
|
1734
1750
|
}
|
|
1735
|
-
#endif`,
|
|
1751
|
+
#endif`,cp=`#ifdef USE_MORPHTARGETS
|
|
1736
1752
|
#ifndef USE_INSTANCING_MORPH
|
|
1737
1753
|
uniform float morphTargetBaseInfluence;
|
|
1738
1754
|
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
@@ -1746,12 +1762,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1746
1762
|
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
|
|
1747
1763
|
return texelFetch( morphTargetsTexture, morphUV, 0 );
|
|
1748
1764
|
}
|
|
1749
|
-
#endif`,
|
|
1765
|
+
#endif`,hp=`#ifdef USE_MORPHTARGETS
|
|
1750
1766
|
transformed *= morphTargetBaseInfluence;
|
|
1751
1767
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1752
1768
|
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
|
|
1753
1769
|
}
|
|
1754
|
-
#endif`,
|
|
1770
|
+
#endif`,up=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
|
|
1755
1771
|
#ifdef FLAT_SHADED
|
|
1756
1772
|
vec3 fdx = dFdx( vViewPosition );
|
|
1757
1773
|
vec3 fdy = dFdy( vViewPosition );
|
|
@@ -1792,7 +1808,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1792
1808
|
tbn2[1] *= faceDirection;
|
|
1793
1809
|
#endif
|
|
1794
1810
|
#endif
|
|
1795
|
-
vec3 nonPerturbedNormal = normal;`,
|
|
1811
|
+
vec3 nonPerturbedNormal = normal;`,dp=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
1796
1812
|
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|
1797
1813
|
#ifdef FLIP_SIDED
|
|
1798
1814
|
normal = - normal;
|
|
@@ -1810,19 +1826,19 @@ vec3 nonPerturbedNormal = normal;`,pd=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1810
1826
|
normal = normalize( tbn * mapN );
|
|
1811
1827
|
#elif defined( USE_BUMPMAP )
|
|
1812
1828
|
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
|
|
1813
|
-
#endif`,
|
|
1829
|
+
#endif`,fp=`#ifndef FLAT_SHADED
|
|
1814
1830
|
varying vec3 vNormal;
|
|
1815
1831
|
#ifdef USE_TANGENT
|
|
1816
1832
|
varying vec3 vTangent;
|
|
1817
1833
|
varying vec3 vBitangent;
|
|
1818
1834
|
#endif
|
|
1819
|
-
#endif`,
|
|
1835
|
+
#endif`,pp=`#ifndef FLAT_SHADED
|
|
1820
1836
|
varying vec3 vNormal;
|
|
1821
1837
|
#ifdef USE_TANGENT
|
|
1822
1838
|
varying vec3 vTangent;
|
|
1823
1839
|
varying vec3 vBitangent;
|
|
1824
1840
|
#endif
|
|
1825
|
-
#endif`,
|
|
1841
|
+
#endif`,mp=`#ifndef FLAT_SHADED
|
|
1826
1842
|
vNormal = normalize( transformedNormal );
|
|
1827
1843
|
#ifdef USE_TANGENT
|
|
1828
1844
|
vTangent = normalize( transformedTangent );
|
|
@@ -1831,7 +1847,7 @@ vec3 nonPerturbedNormal = normal;`,pd=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1831
1847
|
vBitangent = - vBitangent;
|
|
1832
1848
|
#endif
|
|
1833
1849
|
#endif
|
|
1834
|
-
#endif`,
|
|
1850
|
+
#endif`,gp=`#ifdef USE_NORMALMAP
|
|
1835
1851
|
uniform sampler2D normalMap;
|
|
1836
1852
|
uniform vec2 normalScale;
|
|
1837
1853
|
#endif
|
|
@@ -1853,13 +1869,13 @@ vec3 nonPerturbedNormal = normal;`,pd=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1853
1869
|
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
|
|
1854
1870
|
return mat3( T * scale, B * scale, N );
|
|
1855
1871
|
}
|
|
1856
|
-
#endif`,
|
|
1872
|
+
#endif`,_p=`#ifdef USE_CLEARCOAT
|
|
1857
1873
|
vec3 clearcoatNormal = nonPerturbedNormal;
|
|
1858
|
-
#endif`,
|
|
1874
|
+
#endif`,xp=`#ifdef USE_CLEARCOAT_NORMALMAP
|
|
1859
1875
|
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
|
1860
1876
|
clearcoatMapN.xy *= clearcoatNormalScale;
|
|
1861
1877
|
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
|
1862
|
-
#endif`,
|
|
1878
|
+
#endif`,vp=`#ifdef USE_CLEARCOATMAP
|
|
1863
1879
|
uniform sampler2D clearcoatMap;
|
|
1864
1880
|
#endif
|
|
1865
1881
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
@@ -1868,18 +1884,18 @@ vec3 nonPerturbedNormal = normal;`,pd=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
1868
1884
|
#endif
|
|
1869
1885
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
1870
1886
|
uniform sampler2D clearcoatRoughnessMap;
|
|
1871
|
-
#endif`,
|
|
1887
|
+
#endif`,Mp=`#ifdef USE_IRIDESCENCEMAP
|
|
1872
1888
|
uniform sampler2D iridescenceMap;
|
|
1873
1889
|
#endif
|
|
1874
1890
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
1875
1891
|
uniform sampler2D iridescenceThicknessMap;
|
|
1876
|
-
#endif`,
|
|
1892
|
+
#endif`,Sp=`#ifdef OPAQUE
|
|
1877
1893
|
diffuseColor.a = 1.0;
|
|
1878
1894
|
#endif
|
|
1879
1895
|
#ifdef USE_TRANSMISSION
|
|
1880
1896
|
diffuseColor.a *= material.transmissionAlpha;
|
|
1881
1897
|
#endif
|
|
1882
|
-
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,
|
|
1898
|
+
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,yp=`vec3 packNormalToRGB( const in vec3 normal ) {
|
|
1883
1899
|
return normalize( normal ) * 0.5 + 0.5;
|
|
1884
1900
|
}
|
|
1885
1901
|
vec3 unpackRGBToNormal( const in vec3 rgb ) {
|
|
@@ -1958,9 +1974,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
|
|
|
1958
1974
|
#else
|
|
1959
1975
|
return ( near * far ) / ( ( far - near ) * depth - far );
|
|
1960
1976
|
#endif
|
|
1961
|
-
}`,
|
|
1977
|
+
}`,Ep=`#ifdef PREMULTIPLIED_ALPHA
|
|
1962
1978
|
gl_FragColor.rgb *= gl_FragColor.a;
|
|
1963
|
-
#endif`,
|
|
1979
|
+
#endif`,bp=`vec4 mvPosition = vec4( transformed, 1.0 );
|
|
1964
1980
|
#ifdef USE_BATCHING
|
|
1965
1981
|
mvPosition = batchingMatrix * mvPosition;
|
|
1966
1982
|
#endif
|
|
@@ -1968,22 +1984,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
|
|
|
1968
1984
|
mvPosition = instanceMatrix * mvPosition;
|
|
1969
1985
|
#endif
|
|
1970
1986
|
mvPosition = modelViewMatrix * mvPosition;
|
|
1971
|
-
gl_Position = projectionMatrix * mvPosition;`,
|
|
1987
|
+
gl_Position = projectionMatrix * mvPosition;`,Tp=`#ifdef DITHERING
|
|
1972
1988
|
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
|
1973
|
-
#endif`,
|
|
1989
|
+
#endif`,Ap=`#ifdef DITHERING
|
|
1974
1990
|
vec3 dithering( vec3 color ) {
|
|
1975
1991
|
float grid_position = rand( gl_FragCoord.xy );
|
|
1976
1992
|
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
|
|
1977
1993
|
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
|
|
1978
1994
|
return color + dither_shift_RGB;
|
|
1979
1995
|
}
|
|
1980
|
-
#endif`,
|
|
1996
|
+
#endif`,wp=`float roughnessFactor = roughness;
|
|
1981
1997
|
#ifdef USE_ROUGHNESSMAP
|
|
1982
1998
|
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
|
1983
1999
|
roughnessFactor *= texelRoughness.g;
|
|
1984
|
-
#endif`,
|
|
2000
|
+
#endif`,Rp=`#ifdef USE_ROUGHNESSMAP
|
|
1985
2001
|
uniform sampler2D roughnessMap;
|
|
1986
|
-
#endif`,
|
|
2002
|
+
#endif`,Cp=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
1987
2003
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
1988
2004
|
#endif
|
|
1989
2005
|
#if NUM_SPOT_LIGHT_MAPS > 0
|
|
@@ -2183,7 +2199,7 @@ gl_Position = projectionMatrix * mvPosition;`,wd=`#ifdef DITHERING
|
|
|
2183
2199
|
}
|
|
2184
2200
|
#endif
|
|
2185
2201
|
#endif
|
|
2186
|
-
#endif`,
|
|
2202
|
+
#endif`,Pp=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
2187
2203
|
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
|
|
2188
2204
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
2189
2205
|
#endif
|
|
@@ -2224,7 +2240,7 @@ gl_Position = projectionMatrix * mvPosition;`,wd=`#ifdef DITHERING
|
|
|
2224
2240
|
};
|
|
2225
2241
|
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
2226
2242
|
#endif
|
|
2227
|
-
#endif`,
|
|
2243
|
+
#endif`,Ip=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
|
|
2228
2244
|
#ifdef HAS_NORMAL
|
|
2229
2245
|
vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
|
|
2230
2246
|
#else
|
|
@@ -2260,7 +2276,7 @@ gl_Position = projectionMatrix * mvPosition;`,wd=`#ifdef DITHERING
|
|
|
2260
2276
|
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
|
|
2261
2277
|
}
|
|
2262
2278
|
#pragma unroll_loop_end
|
|
2263
|
-
#endif`,
|
|
2279
|
+
#endif`,Dp=`float getShadowMask() {
|
|
2264
2280
|
float shadow = 1.0;
|
|
2265
2281
|
#ifdef USE_SHADOWMAP
|
|
2266
2282
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
@@ -2292,12 +2308,12 @@ gl_Position = projectionMatrix * mvPosition;`,wd=`#ifdef DITHERING
|
|
|
2292
2308
|
#endif
|
|
2293
2309
|
#endif
|
|
2294
2310
|
return shadow;
|
|
2295
|
-
}`,
|
|
2311
|
+
}`,Lp=`#ifdef USE_SKINNING
|
|
2296
2312
|
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
|
2297
2313
|
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
|
2298
2314
|
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
|
2299
2315
|
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
|
2300
|
-
#endif`,
|
|
2316
|
+
#endif`,Up=`#ifdef USE_SKINNING
|
|
2301
2317
|
uniform mat4 bindMatrix;
|
|
2302
2318
|
uniform mat4 bindMatrixInverse;
|
|
2303
2319
|
uniform highp sampler2D boneTexture;
|
|
@@ -2312,7 +2328,7 @@ gl_Position = projectionMatrix * mvPosition;`,wd=`#ifdef DITHERING
|
|
|
2312
2328
|
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
|
|
2313
2329
|
return mat4( v1, v2, v3, v4 );
|
|
2314
2330
|
}
|
|
2315
|
-
#endif`,
|
|
2331
|
+
#endif`,Np=`#ifdef USE_SKINNING
|
|
2316
2332
|
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
|
|
2317
2333
|
vec4 skinned = vec4( 0.0 );
|
|
2318
2334
|
skinned += boneMatX * skinVertex * skinWeight.x;
|
|
@@ -2320,7 +2336,7 @@ gl_Position = projectionMatrix * mvPosition;`,wd=`#ifdef DITHERING
|
|
|
2320
2336
|
skinned += boneMatZ * skinVertex * skinWeight.z;
|
|
2321
2337
|
skinned += boneMatW * skinVertex * skinWeight.w;
|
|
2322
2338
|
transformed = ( bindMatrixInverse * skinned ).xyz;
|
|
2323
|
-
#endif`,
|
|
2339
|
+
#endif`,Fp=`#ifdef USE_SKINNING
|
|
2324
2340
|
mat4 skinMatrix = mat4( 0.0 );
|
|
2325
2341
|
skinMatrix += skinWeight.x * boneMatX;
|
|
2326
2342
|
skinMatrix += skinWeight.y * boneMatY;
|
|
@@ -2331,17 +2347,17 @@ gl_Position = projectionMatrix * mvPosition;`,wd=`#ifdef DITHERING
|
|
|
2331
2347
|
#ifdef USE_TANGENT
|
|
2332
2348
|
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
|
2333
2349
|
#endif
|
|
2334
|
-
#endif`,
|
|
2350
|
+
#endif`,Op=`float specularStrength;
|
|
2335
2351
|
#ifdef USE_SPECULARMAP
|
|
2336
2352
|
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
|
2337
2353
|
specularStrength = texelSpecular.r;
|
|
2338
2354
|
#else
|
|
2339
2355
|
specularStrength = 1.0;
|
|
2340
|
-
#endif`,
|
|
2356
|
+
#endif`,Bp=`#ifdef USE_SPECULARMAP
|
|
2341
2357
|
uniform sampler2D specularMap;
|
|
2342
|
-
#endif`,
|
|
2358
|
+
#endif`,zp=`#if defined( TONE_MAPPING )
|
|
2343
2359
|
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
|
2344
|
-
#endif`,
|
|
2360
|
+
#endif`,Gp=`#ifndef saturate
|
|
2345
2361
|
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|
2346
2362
|
#endif
|
|
2347
2363
|
uniform float toneMappingExposure;
|
|
@@ -2438,7 +2454,7 @@ vec3 NeutralToneMapping( vec3 color ) {
|
|
|
2438
2454
|
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
|
|
2439
2455
|
return mix( color, vec3( newPeak ), g );
|
|
2440
2456
|
}
|
|
2441
|
-
vec3 CustomToneMapping( vec3 color ) { return color; }`,
|
|
2457
|
+
vec3 CustomToneMapping( vec3 color ) { return color; }`,Hp=`#ifdef USE_TRANSMISSION
|
|
2442
2458
|
material.transmission = transmission;
|
|
2443
2459
|
material.transmissionAlpha = 1.0;
|
|
2444
2460
|
material.thickness = thickness;
|
|
@@ -2459,7 +2475,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Hd=`#ifdef USE_TRANSMISS
|
|
|
2459
2475
|
material.attenuationColor, material.attenuationDistance );
|
|
2460
2476
|
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
|
|
2461
2477
|
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
|
|
2462
|
-
#endif`,
|
|
2478
|
+
#endif`,kp=`#ifdef USE_TRANSMISSION
|
|
2463
2479
|
uniform float transmission;
|
|
2464
2480
|
uniform float thickness;
|
|
2465
2481
|
uniform float attenuationDistance;
|
|
@@ -2585,7 +2601,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Hd=`#ifdef USE_TRANSMISS
|
|
|
2585
2601
|
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
|
|
2586
2602
|
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
|
|
2587
2603
|
}
|
|
2588
|
-
#endif`,
|
|
2604
|
+
#endif`,Vp=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2589
2605
|
varying vec2 vUv;
|
|
2590
2606
|
#endif
|
|
2591
2607
|
#ifdef USE_MAP
|
|
@@ -2655,7 +2671,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Hd=`#ifdef USE_TRANSMISS
|
|
|
2655
2671
|
#ifdef USE_THICKNESSMAP
|
|
2656
2672
|
uniform mat3 thicknessMapTransform;
|
|
2657
2673
|
varying vec2 vThicknessMapUv;
|
|
2658
|
-
#endif`,
|
|
2674
|
+
#endif`,Wp=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2659
2675
|
varying vec2 vUv;
|
|
2660
2676
|
#endif
|
|
2661
2677
|
#ifdef USE_MAP
|
|
@@ -2749,7 +2765,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Hd=`#ifdef USE_TRANSMISS
|
|
|
2749
2765
|
#ifdef USE_THICKNESSMAP
|
|
2750
2766
|
uniform mat3 thicknessMapTransform;
|
|
2751
2767
|
varying vec2 vThicknessMapUv;
|
|
2752
|
-
#endif`,
|
|
2768
|
+
#endif`,Xp=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2753
2769
|
vUv = vec3( uv, 1 ).xy;
|
|
2754
2770
|
#endif
|
|
2755
2771
|
#ifdef USE_MAP
|
|
@@ -2820,7 +2836,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Hd=`#ifdef USE_TRANSMISS
|
|
|
2820
2836
|
#endif
|
|
2821
2837
|
#ifdef USE_THICKNESSMAP
|
|
2822
2838
|
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
|
|
2823
|
-
#endif`,
|
|
2839
|
+
#endif`,qp=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
|
|
2824
2840
|
vec4 worldPosition = vec4( transformed, 1.0 );
|
|
2825
2841
|
#ifdef USE_BATCHING
|
|
2826
2842
|
worldPosition = batchingMatrix * worldPosition;
|
|
@@ -2829,12 +2845,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,Hd=`#ifdef USE_TRANSMISS
|
|
|
2829
2845
|
worldPosition = instanceMatrix * worldPosition;
|
|
2830
2846
|
#endif
|
|
2831
2847
|
worldPosition = modelMatrix * worldPosition;
|
|
2832
|
-
#endif`;const
|
|
2848
|
+
#endif`;const Yp=`varying vec2 vUv;
|
|
2833
2849
|
uniform mat3 uvTransform;
|
|
2834
2850
|
void main() {
|
|
2835
2851
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
2836
2852
|
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
|
2837
|
-
}
|
|
2853
|
+
}`,Zp=`uniform sampler2D t2D;
|
|
2838
2854
|
uniform float backgroundIntensity;
|
|
2839
2855
|
varying vec2 vUv;
|
|
2840
2856
|
void main() {
|
|
@@ -2846,14 +2862,14 @@ void main() {
|
|
|
2846
2862
|
gl_FragColor = texColor;
|
|
2847
2863
|
#include <tonemapping_fragment>
|
|
2848
2864
|
#include <colorspace_fragment>
|
|
2849
|
-
}
|
|
2865
|
+
}`,$p=`varying vec3 vWorldDirection;
|
|
2850
2866
|
#include <common>
|
|
2851
2867
|
void main() {
|
|
2852
2868
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2853
2869
|
#include <begin_vertex>
|
|
2854
2870
|
#include <project_vertex>
|
|
2855
2871
|
gl_Position.z = gl_Position.w;
|
|
2856
|
-
}`,
|
|
2872
|
+
}`,Kp=`#ifdef ENVMAP_TYPE_CUBE
|
|
2857
2873
|
uniform samplerCube envMap;
|
|
2858
2874
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
2859
2875
|
uniform sampler2D envMap;
|
|
@@ -2875,14 +2891,14 @@ void main() {
|
|
|
2875
2891
|
gl_FragColor = texColor;
|
|
2876
2892
|
#include <tonemapping_fragment>
|
|
2877
2893
|
#include <colorspace_fragment>
|
|
2878
|
-
}`,
|
|
2894
|
+
}`,Jp=`varying vec3 vWorldDirection;
|
|
2879
2895
|
#include <common>
|
|
2880
2896
|
void main() {
|
|
2881
2897
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2882
2898
|
#include <begin_vertex>
|
|
2883
2899
|
#include <project_vertex>
|
|
2884
2900
|
gl_Position.z = gl_Position.w;
|
|
2885
|
-
}`,
|
|
2901
|
+
}`,Qp=`uniform samplerCube tCube;
|
|
2886
2902
|
uniform float tFlip;
|
|
2887
2903
|
uniform float opacity;
|
|
2888
2904
|
varying vec3 vWorldDirection;
|
|
@@ -2892,7 +2908,7 @@ void main() {
|
|
|
2892
2908
|
gl_FragColor.a *= opacity;
|
|
2893
2909
|
#include <tonemapping_fragment>
|
|
2894
2910
|
#include <colorspace_fragment>
|
|
2895
|
-
}`,
|
|
2911
|
+
}`,jp=`#include <common>
|
|
2896
2912
|
#include <batching_pars_vertex>
|
|
2897
2913
|
#include <uv_pars_vertex>
|
|
2898
2914
|
#include <displacementmap_pars_vertex>
|
|
@@ -2919,7 +2935,7 @@ void main() {
|
|
|
2919
2935
|
#include <logdepthbuf_vertex>
|
|
2920
2936
|
#include <clipping_planes_vertex>
|
|
2921
2937
|
vHighPrecisionZW = gl_Position.zw;
|
|
2922
|
-
}`,
|
|
2938
|
+
}`,tm=`#if DEPTH_PACKING == 3200
|
|
2923
2939
|
uniform float opacity;
|
|
2924
2940
|
#endif
|
|
2925
2941
|
#include <common>
|
|
@@ -2957,7 +2973,7 @@ void main() {
|
|
|
2957
2973
|
#elif DEPTH_PACKING == 3203
|
|
2958
2974
|
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
|
|
2959
2975
|
#endif
|
|
2960
|
-
}`,
|
|
2976
|
+
}`,em=`#define DISTANCE
|
|
2961
2977
|
varying vec3 vWorldPosition;
|
|
2962
2978
|
#include <common>
|
|
2963
2979
|
#include <batching_pars_vertex>
|
|
@@ -2984,7 +3000,7 @@ void main() {
|
|
|
2984
3000
|
#include <worldpos_vertex>
|
|
2985
3001
|
#include <clipping_planes_vertex>
|
|
2986
3002
|
vWorldPosition = worldPosition.xyz;
|
|
2987
|
-
}`,
|
|
3003
|
+
}`,nm=`#define DISTANCE
|
|
2988
3004
|
uniform vec3 referencePosition;
|
|
2989
3005
|
uniform float nearDistance;
|
|
2990
3006
|
uniform float farDistance;
|
|
@@ -3007,13 +3023,13 @@ void main() {
|
|
|
3007
3023
|
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
|
3008
3024
|
dist = saturate( dist );
|
|
3009
3025
|
gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
|
|
3010
|
-
}`,
|
|
3026
|
+
}`,im=`varying vec3 vWorldDirection;
|
|
3011
3027
|
#include <common>
|
|
3012
3028
|
void main() {
|
|
3013
3029
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
3014
3030
|
#include <begin_vertex>
|
|
3015
3031
|
#include <project_vertex>
|
|
3016
|
-
}`,
|
|
3032
|
+
}`,rm=`uniform sampler2D tEquirect;
|
|
3017
3033
|
varying vec3 vWorldDirection;
|
|
3018
3034
|
#include <common>
|
|
3019
3035
|
void main() {
|
|
@@ -3022,7 +3038,7 @@ void main() {
|
|
|
3022
3038
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
3023
3039
|
#include <tonemapping_fragment>
|
|
3024
3040
|
#include <colorspace_fragment>
|
|
3025
|
-
}`,
|
|
3041
|
+
}`,sm=`uniform float scale;
|
|
3026
3042
|
attribute float lineDistance;
|
|
3027
3043
|
varying float vLineDistance;
|
|
3028
3044
|
#include <common>
|
|
@@ -3044,7 +3060,7 @@ void main() {
|
|
|
3044
3060
|
#include <logdepthbuf_vertex>
|
|
3045
3061
|
#include <clipping_planes_vertex>
|
|
3046
3062
|
#include <fog_vertex>
|
|
3047
|
-
}`,
|
|
3063
|
+
}`,am=`uniform vec3 diffuse;
|
|
3048
3064
|
uniform float opacity;
|
|
3049
3065
|
uniform float dashSize;
|
|
3050
3066
|
uniform float totalSize;
|
|
@@ -3072,7 +3088,7 @@ void main() {
|
|
|
3072
3088
|
#include <colorspace_fragment>
|
|
3073
3089
|
#include <fog_fragment>
|
|
3074
3090
|
#include <premultiplied_alpha_fragment>
|
|
3075
|
-
}`,
|
|
3091
|
+
}`,om=`#include <common>
|
|
3076
3092
|
#include <batching_pars_vertex>
|
|
3077
3093
|
#include <uv_pars_vertex>
|
|
3078
3094
|
#include <envmap_pars_vertex>
|
|
@@ -3104,7 +3120,7 @@ void main() {
|
|
|
3104
3120
|
#include <worldpos_vertex>
|
|
3105
3121
|
#include <envmap_vertex>
|
|
3106
3122
|
#include <fog_vertex>
|
|
3107
|
-
}`,
|
|
3123
|
+
}`,lm=`uniform vec3 diffuse;
|
|
3108
3124
|
uniform float opacity;
|
|
3109
3125
|
#ifndef FLAT_SHADED
|
|
3110
3126
|
varying vec3 vNormal;
|
|
@@ -3152,7 +3168,7 @@ void main() {
|
|
|
3152
3168
|
#include <fog_fragment>
|
|
3153
3169
|
#include <premultiplied_alpha_fragment>
|
|
3154
3170
|
#include <dithering_fragment>
|
|
3155
|
-
}`,
|
|
3171
|
+
}`,cm=`#define LAMBERT
|
|
3156
3172
|
varying vec3 vViewPosition;
|
|
3157
3173
|
#include <common>
|
|
3158
3174
|
#include <batching_pars_vertex>
|
|
@@ -3191,7 +3207,7 @@ void main() {
|
|
|
3191
3207
|
#include <envmap_vertex>
|
|
3192
3208
|
#include <shadowmap_vertex>
|
|
3193
3209
|
#include <fog_vertex>
|
|
3194
|
-
}`,
|
|
3210
|
+
}`,hm=`#define LAMBERT
|
|
3195
3211
|
uniform vec3 diffuse;
|
|
3196
3212
|
uniform vec3 emissive;
|
|
3197
3213
|
uniform float opacity;
|
|
@@ -3249,7 +3265,7 @@ void main() {
|
|
|
3249
3265
|
#include <fog_fragment>
|
|
3250
3266
|
#include <premultiplied_alpha_fragment>
|
|
3251
3267
|
#include <dithering_fragment>
|
|
3252
|
-
}`,
|
|
3268
|
+
}`,um=`#define MATCAP
|
|
3253
3269
|
varying vec3 vViewPosition;
|
|
3254
3270
|
#include <common>
|
|
3255
3271
|
#include <batching_pars_vertex>
|
|
@@ -3283,7 +3299,7 @@ void main() {
|
|
|
3283
3299
|
#include <clipping_planes_vertex>
|
|
3284
3300
|
#include <fog_vertex>
|
|
3285
3301
|
vViewPosition = - mvPosition.xyz;
|
|
3286
|
-
}`,
|
|
3302
|
+
}`,dm=`#define MATCAP
|
|
3287
3303
|
uniform vec3 diffuse;
|
|
3288
3304
|
uniform float opacity;
|
|
3289
3305
|
uniform sampler2D matcap;
|
|
@@ -3329,7 +3345,7 @@ void main() {
|
|
|
3329
3345
|
#include <fog_fragment>
|
|
3330
3346
|
#include <premultiplied_alpha_fragment>
|
|
3331
3347
|
#include <dithering_fragment>
|
|
3332
|
-
}`,
|
|
3348
|
+
}`,fm=`#define NORMAL
|
|
3333
3349
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3334
3350
|
varying vec3 vViewPosition;
|
|
3335
3351
|
#endif
|
|
@@ -3362,7 +3378,7 @@ void main() {
|
|
|
3362
3378
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3363
3379
|
vViewPosition = - mvPosition.xyz;
|
|
3364
3380
|
#endif
|
|
3365
|
-
}`,
|
|
3381
|
+
}`,pm=`#define NORMAL
|
|
3366
3382
|
uniform float opacity;
|
|
3367
3383
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3368
3384
|
varying vec3 vViewPosition;
|
|
@@ -3383,7 +3399,7 @@ void main() {
|
|
|
3383
3399
|
#ifdef OPAQUE
|
|
3384
3400
|
gl_FragColor.a = 1.0;
|
|
3385
3401
|
#endif
|
|
3386
|
-
}`,
|
|
3402
|
+
}`,mm=`#define PHONG
|
|
3387
3403
|
varying vec3 vViewPosition;
|
|
3388
3404
|
#include <common>
|
|
3389
3405
|
#include <batching_pars_vertex>
|
|
@@ -3422,7 +3438,7 @@ void main() {
|
|
|
3422
3438
|
#include <envmap_vertex>
|
|
3423
3439
|
#include <shadowmap_vertex>
|
|
3424
3440
|
#include <fog_vertex>
|
|
3425
|
-
}`,
|
|
3441
|
+
}`,gm=`#define PHONG
|
|
3426
3442
|
uniform vec3 diffuse;
|
|
3427
3443
|
uniform vec3 emissive;
|
|
3428
3444
|
uniform vec3 specular;
|
|
@@ -3482,7 +3498,7 @@ void main() {
|
|
|
3482
3498
|
#include <fog_fragment>
|
|
3483
3499
|
#include <premultiplied_alpha_fragment>
|
|
3484
3500
|
#include <dithering_fragment>
|
|
3485
|
-
}`,
|
|
3501
|
+
}`,_m=`#define STANDARD
|
|
3486
3502
|
varying vec3 vViewPosition;
|
|
3487
3503
|
#ifdef USE_TRANSMISSION
|
|
3488
3504
|
varying vec3 vWorldPosition;
|
|
@@ -3525,7 +3541,7 @@ void main() {
|
|
|
3525
3541
|
#ifdef USE_TRANSMISSION
|
|
3526
3542
|
vWorldPosition = worldPosition.xyz;
|
|
3527
3543
|
#endif
|
|
3528
|
-
}`,
|
|
3544
|
+
}`,xm=`#define STANDARD
|
|
3529
3545
|
#ifdef PHYSICAL
|
|
3530
3546
|
#define IOR
|
|
3531
3547
|
#define USE_SPECULAR
|
|
@@ -3650,7 +3666,7 @@ void main() {
|
|
|
3650
3666
|
#include <fog_fragment>
|
|
3651
3667
|
#include <premultiplied_alpha_fragment>
|
|
3652
3668
|
#include <dithering_fragment>
|
|
3653
|
-
}`,
|
|
3669
|
+
}`,vm=`#define TOON
|
|
3654
3670
|
varying vec3 vViewPosition;
|
|
3655
3671
|
#include <common>
|
|
3656
3672
|
#include <batching_pars_vertex>
|
|
@@ -3687,7 +3703,7 @@ void main() {
|
|
|
3687
3703
|
#include <worldpos_vertex>
|
|
3688
3704
|
#include <shadowmap_vertex>
|
|
3689
3705
|
#include <fog_vertex>
|
|
3690
|
-
}`,
|
|
3706
|
+
}`,Mm=`#define TOON
|
|
3691
3707
|
uniform vec3 diffuse;
|
|
3692
3708
|
uniform vec3 emissive;
|
|
3693
3709
|
uniform float opacity;
|
|
@@ -3739,7 +3755,7 @@ void main() {
|
|
|
3739
3755
|
#include <fog_fragment>
|
|
3740
3756
|
#include <premultiplied_alpha_fragment>
|
|
3741
3757
|
#include <dithering_fragment>
|
|
3742
|
-
}`,
|
|
3758
|
+
}`,Sm=`uniform float size;
|
|
3743
3759
|
uniform float scale;
|
|
3744
3760
|
#include <common>
|
|
3745
3761
|
#include <color_pars_vertex>
|
|
@@ -3770,7 +3786,7 @@ void main() {
|
|
|
3770
3786
|
#include <clipping_planes_vertex>
|
|
3771
3787
|
#include <worldpos_vertex>
|
|
3772
3788
|
#include <fog_vertex>
|
|
3773
|
-
}`,
|
|
3789
|
+
}`,ym=`uniform vec3 diffuse;
|
|
3774
3790
|
uniform float opacity;
|
|
3775
3791
|
#include <common>
|
|
3776
3792
|
#include <color_pars_fragment>
|
|
@@ -3795,7 +3811,7 @@ void main() {
|
|
|
3795
3811
|
#include <colorspace_fragment>
|
|
3796
3812
|
#include <fog_fragment>
|
|
3797
3813
|
#include <premultiplied_alpha_fragment>
|
|
3798
|
-
}`,
|
|
3814
|
+
}`,Em=`#include <common>
|
|
3799
3815
|
#include <batching_pars_vertex>
|
|
3800
3816
|
#include <fog_pars_vertex>
|
|
3801
3817
|
#include <morphtarget_pars_vertex>
|
|
@@ -3818,7 +3834,7 @@ void main() {
|
|
|
3818
3834
|
#include <worldpos_vertex>
|
|
3819
3835
|
#include <shadowmap_vertex>
|
|
3820
3836
|
#include <fog_vertex>
|
|
3821
|
-
}`,
|
|
3837
|
+
}`,bm=`uniform vec3 color;
|
|
3822
3838
|
uniform float opacity;
|
|
3823
3839
|
#include <common>
|
|
3824
3840
|
#include <fog_pars_fragment>
|
|
@@ -3834,7 +3850,7 @@ void main() {
|
|
|
3834
3850
|
#include <colorspace_fragment>
|
|
3835
3851
|
#include <fog_fragment>
|
|
3836
3852
|
#include <premultiplied_alpha_fragment>
|
|
3837
|
-
}`,
|
|
3853
|
+
}`,Tm=`uniform float rotation;
|
|
3838
3854
|
uniform vec2 center;
|
|
3839
3855
|
#include <common>
|
|
3840
3856
|
#include <uv_pars_vertex>
|
|
@@ -3858,7 +3874,7 @@ void main() {
|
|
|
3858
3874
|
#include <logdepthbuf_vertex>
|
|
3859
3875
|
#include <clipping_planes_vertex>
|
|
3860
3876
|
#include <fog_vertex>
|
|
3861
|
-
}`,
|
|
3877
|
+
}`,Am=`uniform vec3 diffuse;
|
|
3862
3878
|
uniform float opacity;
|
|
3863
3879
|
#include <common>
|
|
3864
3880
|
#include <uv_pars_fragment>
|
|
@@ -3883,7 +3899,7 @@ void main() {
|
|
|
3883
3899
|
#include <tonemapping_fragment>
|
|
3884
3900
|
#include <colorspace_fragment>
|
|
3885
3901
|
#include <fog_fragment>
|
|
3886
|
-
}`,Ge={alphahash_fragment:Kh,alphahash_pars_fragment:Zh,alphamap_fragment:$h,alphamap_pars_fragment:Jh,alphatest_fragment:Qh,alphatest_pars_fragment:jh,aomap_fragment:ef,aomap_pars_fragment:tf,batching_pars_vertex:nf,batching_vertex:rf,begin_vertex:sf,beginnormal_vertex:af,bsdfs:of,iridescence_fragment:lf,bumpmap_pars_fragment:cf,clipping_planes_fragment:uf,clipping_planes_pars_fragment:hf,clipping_planes_pars_vertex:ff,clipping_planes_vertex:df,color_fragment:pf,color_pars_fragment:mf,color_pars_vertex:gf,color_vertex:_f,common:xf,cube_uv_reflection_fragment:vf,defaultnormal_vertex:Mf,displacementmap_pars_vertex:Sf,displacementmap_vertex:Ef,emissivemap_fragment:yf,emissivemap_pars_fragment:bf,colorspace_fragment:Tf,colorspace_pars_fragment:Af,envmap_fragment:wf,envmap_common_pars_fragment:Rf,envmap_pars_fragment:Cf,envmap_pars_vertex:Pf,envmap_physical_pars_fragment:Vf,envmap_vertex:Df,fog_vertex:If,fog_pars_vertex:Lf,fog_fragment:Uf,fog_pars_fragment:Nf,gradientmap_pars_fragment:Ff,lightmap_pars_fragment:Of,lights_lambert_fragment:Bf,lights_lambert_pars_fragment:zf,lights_pars_begin:Gf,lights_toon_fragment:kf,lights_toon_pars_fragment:Hf,lights_phong_fragment:Wf,lights_phong_pars_fragment:Xf,lights_physical_fragment:qf,lights_physical_pars_fragment:Yf,lights_fragment_begin:Kf,lights_fragment_maps:Zf,lights_fragment_end:$f,lightprobes_pars_fragment:Jf,logdepthbuf_fragment:Qf,logdepthbuf_pars_fragment:jf,logdepthbuf_pars_vertex:ed,logdepthbuf_vertex:td,map_fragment:nd,map_pars_fragment:id,map_particle_fragment:rd,map_particle_pars_fragment:sd,metalnessmap_fragment:ad,metalnessmap_pars_fragment:od,morphinstance_vertex:ld,morphcolor_vertex:cd,morphnormal_vertex:ud,morphtarget_pars_vertex:hd,morphtarget_vertex:fd,normal_fragment_begin:dd,normal_fragment_maps:pd,normal_pars_fragment:md,normal_pars_vertex:gd,normal_vertex:_d,normalmap_pars_fragment:xd,clearcoat_normal_fragment_begin:vd,clearcoat_normal_fragment_maps:Md,clearcoat_pars_fragment:Sd,iridescence_pars_fragment:Ed,opaque_fragment:yd,packing:bd,premultiplied_alpha_fragment:Td,project_vertex:Ad,dithering_fragment:wd,dithering_pars_fragment:Rd,roughnessmap_fragment:Cd,roughnessmap_pars_fragment:Pd,shadowmap_pars_fragment:Dd,shadowmap_pars_vertex:Id,shadowmap_vertex:Ld,shadowmask_pars_fragment:Ud,skinbase_vertex:Nd,skinning_pars_vertex:Fd,skinning_vertex:Od,skinnormal_vertex:Bd,specularmap_fragment:zd,specularmap_pars_fragment:Gd,tonemapping_fragment:Vd,tonemapping_pars_fragment:kd,transmission_fragment:Hd,transmission_pars_fragment:Wd,uv_pars_fragment:Xd,uv_pars_vertex:qd,uv_vertex:Yd,worldpos_vertex:Kd,background_vert:Zd,background_frag:$d,backgroundCube_vert:Jd,backgroundCube_frag:Qd,cube_vert:jd,cube_frag:ep,depth_vert:tp,depth_frag:np,distance_vert:ip,distance_frag:rp,equirect_vert:sp,equirect_frag:ap,linedashed_vert:op,linedashed_frag:lp,meshbasic_vert:cp,meshbasic_frag:up,meshlambert_vert:hp,meshlambert_frag:fp,meshmatcap_vert:dp,meshmatcap_frag:pp,meshnormal_vert:mp,meshnormal_frag:gp,meshphong_vert:_p,meshphong_frag:xp,meshphysical_vert:vp,meshphysical_frag:Mp,meshtoon_vert:Sp,meshtoon_frag:Ep,points_vert:yp,points_frag:bp,shadow_vert:Tp,shadow_frag:Ap,sprite_vert:wp,sprite_frag:Rp},fe={common:{diffuse:{value:new Oe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Fe},alphaMap:{value:null},alphaMapTransform:{value:new Fe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Fe}},envmap:{envMap:{value:null},envMapRotation:{value:new Fe},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Fe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Fe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Fe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Fe},normalScale:{value:new Ve(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Fe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Fe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Fe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Fe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Oe(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 Oe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Fe},alphaTest:{value:0},uvTransform:{value:new Fe}},sprite:{diffuse:{value:new Oe(16777215)},opacity:{value:1},center:{value:new Ve(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Fe},alphaMap:{value:null},alphaMapTransform:{value:new Fe},alphaTest:{value:0}}},on={basic:{uniforms:It([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.fog]),vertexShader:Ge.meshbasic_vert,fragmentShader:Ge.meshbasic_frag},lambert:{uniforms:It([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,fe.lights,{emissive:{value:new Oe(0)},envMapIntensity:{value:1}}]),vertexShader:Ge.meshlambert_vert,fragmentShader:Ge.meshlambert_frag},phong:{uniforms:It([fe.common,fe.specularmap,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,fe.lights,{emissive:{value:new Oe(0)},specular:{value:new Oe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ge.meshphong_vert,fragmentShader:Ge.meshphong_frag},standard:{uniforms:It([fe.common,fe.envmap,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.roughnessmap,fe.metalnessmap,fe.fog,fe.lights,{emissive:{value:new Oe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ge.meshphysical_vert,fragmentShader:Ge.meshphysical_frag},toon:{uniforms:It([fe.common,fe.aomap,fe.lightmap,fe.emissivemap,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.gradientmap,fe.fog,fe.lights,{emissive:{value:new Oe(0)}}]),vertexShader:Ge.meshtoon_vert,fragmentShader:Ge.meshtoon_frag},matcap:{uniforms:It([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,fe.fog,{matcap:{value:null}}]),vertexShader:Ge.meshmatcap_vert,fragmentShader:Ge.meshmatcap_frag},points:{uniforms:It([fe.points,fe.fog]),vertexShader:Ge.points_vert,fragmentShader:Ge.points_frag},dashed:{uniforms:It([fe.common,fe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ge.linedashed_vert,fragmentShader:Ge.linedashed_frag},depth:{uniforms:It([fe.common,fe.displacementmap]),vertexShader:Ge.depth_vert,fragmentShader:Ge.depth_frag},normal:{uniforms:It([fe.common,fe.bumpmap,fe.normalmap,fe.displacementmap,{opacity:{value:1}}]),vertexShader:Ge.meshnormal_vert,fragmentShader:Ge.meshnormal_frag},sprite:{uniforms:It([fe.sprite,fe.fog]),vertexShader:Ge.sprite_vert,fragmentShader:Ge.sprite_frag},background:{uniforms:{uvTransform:{value:new Fe},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 Fe}},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:It([fe.common,fe.displacementmap,{referencePosition:{value:new F},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ge.distance_vert,fragmentShader:Ge.distance_frag},shadow:{uniforms:It([fe.lights,fe.fog,{color:{value:new Oe(0)},opacity:{value:1}}]),vertexShader:Ge.shadow_vert,fragmentShader:Ge.shadow_frag}};on.physical={uniforms:It([on.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Fe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Fe},clearcoatNormalScale:{value:new Ve(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Fe},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Fe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Fe},sheen:{value:0},sheenColor:{value:new Oe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Fe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Fe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Fe},transmissionSamplerSize:{value:new Ve},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Fe},attenuationDistance:{value:0},attenuationColor:{value:new Oe(0)},specularColor:{value:new Oe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Fe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Fe},anisotropyVector:{value:new Ve},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Fe}}]),vertexShader:Ge.meshphysical_vert,fragmentShader:Ge.meshphysical_frag};const qr={r:0,b:0,g:0},Cp=new lt,m0=new Fe;m0.set(-1,0,0,0,1,0,0,0,1);function Pp(i,e,t,n,r,s){const a=new Oe(0);let o=r===!0?0:1,l,c,h=null,f=0,u=null;function g(A){let w=A.isScene===!0?A.background:null;if(w&&w.isTexture){const M=A.backgroundBlurriness>0;w=e.get(w,M)}return w}function _(A){let w=!1;const M=g(A);M===null?m(a,o):M&&M.isColor&&(m(M,1),w=!0);const T=i.xr.getEnvironmentBlendMode();T==="additive"?t.buffers.color.setClear(0,0,0,1,s):T==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,s),(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 S(A,w){const M=g(w);M&&(M.isCubeTexture||M.mapping===bs)?(c===void 0&&(c=new Kt(new dr(1,1,1),new pn({name:"BackgroundCubeMaterial",uniforms:Vi(on.backgroundCube.uniforms),vertexShader:on.backgroundCube.vertexShader,fragmentShader:on.backgroundCube.fragmentShader,side:Lt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(T,y,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=M,c.material.uniforms.backgroundBlurriness.value=w.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Cp.makeRotationFromEuler(w.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(m0),c.material.toneMapped=qe.getTransfer(M.colorSpace)!==Qe,(h!==M||f!==M.version||u!==i.toneMapping)&&(c.material.needsUpdate=!0,h=M,f=M.version,u=i.toneMapping),c.layers.enableAll(),A.unshift(c,c.geometry,c.material,0,0,null)):M&&M.isTexture&&(l===void 0&&(l=new Kt(new As(2,2),new pn({name:"BackgroundMaterial",uniforms:Vi(on.background.uniforms),vertexShader:on.background.vertexShader,fragmentShader:on.background.fragmentShader,side:Xn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=M,l.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,l.material.toneMapped=qe.getTransfer(M.colorSpace)!==Qe,M.matrixAutoUpdate===!0&&M.updateMatrix(),l.material.uniforms.uvTransform.value.copy(M.matrix),(h!==M||f!==M.version||u!==i.toneMapping)&&(l.material.needsUpdate=!0,h=M,f=M.version,u=i.toneMapping),l.layers.enableAll(),A.unshift(l,l.geometry,l.material,0,0,null))}function m(A,w){A.getRGB(qr,u0(i)),t.buffers.color.setClear(qr.r,qr.g,qr.b,w,s)}function d(){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:S,dispose:d}}function Dp(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=u(null);let s=r,a=!1;function o(C,N,Y,K,O){let W=!1;const H=f(C,K,Y,N);s!==H&&(s=H,c(s.object)),W=g(C,K,Y,O),W&&_(C,K,Y,O),O!==null&&e.update(O,i.ELEMENT_ARRAY_BUFFER),(W||a)&&(a=!1,M(C,N,Y,K),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 f(C,N,Y,K){const O=K.wireframe===!0;let W=n[N.id];W===void 0&&(W={},n[N.id]=W);const H=C.isInstancedMesh===!0?C.id:0;let Q=W[H];Q===void 0&&(Q={},W[H]=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 N=[],Y=[],K=[];for(let O=0;O<t;O++)N[O]=0,Y[O]=0,K[O]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:N,enabledAttributes:Y,attributeDivisors:K,object:C,attributes:{},index:null}}function g(C,N,Y,K){const O=s.attributes,W=N.attributes;let H=0;const Q=Y.getAttributes();for(const te in Q)if(Q[te].location>=0){const re=O[te];let ge=W[te];if(ge===void 0&&(te==="instanceMatrix"&&C.instanceMatrix&&(ge=C.instanceMatrix),te==="instanceColor"&&C.instanceColor&&(ge=C.instanceColor)),re===void 0||re.attribute!==ge||ge&&re.data!==ge.data)return!0;H++}return s.attributesNum!==H||s.index!==K}function _(C,N,Y,K){const O={},W=N.attributes;let H=0;const Q=Y.getAttributes();for(const te in Q)if(Q[te].location>=0){let re=W[te];re===void 0&&(te==="instanceMatrix"&&C.instanceMatrix&&(re=C.instanceMatrix),te==="instanceColor"&&C.instanceColor&&(re=C.instanceColor));const ge={};ge.attribute=re,re&&re.data&&(ge.data=re.data),O[te]=ge,H++}s.attributes=O,s.attributesNum=H,s.index=K}function S(){const C=s.newAttributes;for(let N=0,Y=C.length;N<Y;N++)C[N]=0}function m(C){d(C,0)}function d(C,N){const Y=s.newAttributes,K=s.enabledAttributes,O=s.attributeDivisors;Y[C]=1,K[C]===0&&(i.enableVertexAttribArray(C),K[C]=1),O[C]!==N&&(i.vertexAttribDivisor(C,N),O[C]=N)}function A(){const C=s.newAttributes,N=s.enabledAttributes;for(let Y=0,K=N.length;Y<K;Y++)N[Y]!==C[Y]&&(i.disableVertexAttribArray(Y),N[Y]=0)}function w(C,N,Y,K,O,W,H){H===!0?i.vertexAttribIPointer(C,N,Y,O,W):i.vertexAttribPointer(C,N,Y,K,O,W)}function M(C,N,Y,K){S();const O=K.attributes,W=Y.getAttributes(),H=N.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 re=ee.normalized,ge=ee.itemSize,He=e.get(ee);if(He===void 0)continue;const rt=He.buffer,We=He.type,Z=He.bytesPerElement,se=We===i.INT||We===i.UNSIGNED_INT||ee.gpuType===Oo;if(ee.isInterleavedBufferAttribute){const ne=ee.data,G=ne.stride,Ce=ee.offset;if(ne.isInstancedInterleavedBuffer){for(let Pe=0;Pe<te.locationSize;Pe++)d(te.location+Pe,ne.meshPerAttribute);C.isInstancedMesh!==!0&&K._maxInstanceCount===void 0&&(K._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let Pe=0;Pe<te.locationSize;Pe++)m(te.location+Pe);i.bindBuffer(i.ARRAY_BUFFER,rt);for(let Pe=0;Pe<te.locationSize;Pe++)w(te.location+Pe,ge/te.locationSize,We,re,G*Z,(Ce+ge/te.locationSize*Pe)*Z,se)}else{if(ee.isInstancedBufferAttribute){for(let ne=0;ne<te.locationSize;ne++)d(te.location+ne,ee.meshPerAttribute);C.isInstancedMesh!==!0&&K._maxInstanceCount===void 0&&(K._maxInstanceCount=ee.meshPerAttribute*ee.count)}else for(let ne=0;ne<te.locationSize;ne++)m(te.location+ne);i.bindBuffer(i.ARRAY_BUFFER,rt);for(let ne=0;ne<te.locationSize;ne++)w(te.location+ne,ge/te.locationSize,We,re,ge*Z,ge/te.locationSize*ne*Z,se)}}else if(H!==void 0){const re=H[Q];if(re!==void 0)switch(re.length){case 2:i.vertexAttrib2fv(te.location,re);break;case 3:i.vertexAttrib3fv(te.location,re);break;case 4:i.vertexAttrib4fv(te.location,re);break;default:i.vertexAttrib1fv(te.location,re)}}}}A()}function T(){b();for(const C in n){const N=n[C];for(const Y in N){const K=N[Y];for(const O in K){const W=K[O];for(const H in W)h(W[H].object),delete W[H];delete K[O]}}delete n[C]}}function y(C){if(n[C.id]===void 0)return;const N=n[C.id];for(const Y in N){const K=N[Y];for(const O in K){const W=K[O];for(const H in W)h(W[H].object),delete W[H];delete K[O]}}delete n[C.id]}function R(C){for(const N in n){const Y=n[N];for(const K in Y){const O=Y[K];if(O[C.id]===void 0)continue;const W=O[C.id];for(const H in W)h(W[H].object),delete W[H];delete O[C.id]}}}function x(C){for(const N in n){const Y=n[N],K=C.isInstancedMesh===!0?C.id:0,O=Y[K];if(O!==void 0){for(const W in O){const H=O[W];for(const Q in H)h(H[Q].object),delete H[Q];delete O[W]}delete Y[K],Object.keys(Y).length===0&&delete n[N]}}}function b(){I(),a=!0,s!==r&&(s=r,c(s.object))}function I(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:b,resetDefaultState:I,dispose:T,releaseStatesOfGeometry:y,releaseStatesOfObject:x,releaseStatesOfProgram:R,initAttributes:S,enableAttribute:m,disableUnusedAttributes:A}}function Ip(i,e,t){let n;function r(l){n=l}function s(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 g=0;g<h;g++)u+=c[g];t.update(u,n,1)}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=o}function Lp(i,e,t,n){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const R=e.get("EXT_texture_filter_anisotropic");r=i.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(R){return!(R!==en&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(R){const x=R===wn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(R!==qt&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==cn&&!x)}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&&(Ne("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const f=t.logarithmicDepthBuffer===!0,u=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&u===!1&&Ne("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const g=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),_=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),S=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),d=i.getParameter(i.MAX_VERTEX_ATTRIBS),A=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),w=i.getParameter(i.MAX_VARYING_VECTORS),M=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),T=i.getParameter(i.MAX_SAMPLES),y=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:f,reversedDepthBuffer:u,maxTextures:g,maxVertexTextures:_,maxTextureSize:S,maxCubemapSize:m,maxAttributes:d,maxVertexUniforms:A,maxVaryings:w,maxFragmentUniforms:M,maxSamples:T,samples:y}}function Up(i){const e=this;let t=null,n=0,r=!1,s=!1;const a=new Jn,o=new Fe,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(f,u){const g=f.length!==0||u||n!==0||r;return r=u,n=f.length,g},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,u){t=h(f,u,0)},this.setState=function(f,u,g){const _=f.clippingPlanes,S=f.clipIntersection,m=f.clipShadows,d=i.get(f);if(!r||_===null||_.length===0||s&&!m)s?h(null):c();else{const A=s?0:n,w=A*4;let M=d.clippingState||null;l.value=M,M=h(_,u,w,g);for(let T=0;T!==w;++T)M[T]=t[T];d.clippingState=M,this.numIntersection=S?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(f,u,g,_){const S=f!==null?f.length:0;let m=null;if(S!==0){if(m=l.value,_!==!0||m===null){const d=g+S*4,A=u.matrixWorldInverse;o.getNormalMatrix(A),(m===null||m.length<d)&&(m=new Float32Array(d));for(let w=0,M=g;w!==S;++w,M+=4)a.copy(f[w]).applyMatrix4(A,o),a.normal.toArray(m,M),m[M+3]=a.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=S,e.numIntersection=0,m}}const Vn=4,ql=[.125,.215,.35,.446,.526,.582],jn=20,Np=256,er=new f0,Yl=new Oe;let oa=null,la=0,ca=0,ua=!1;const Fp=new F;class Kl{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,r=100,s={}){const{size:a=256,position:o=Fp}=s;oa=this._renderer.getRenderTarget(),la=this._renderer.getActiveCubeFace(),ca=this._renderer.getActiveMipmapLevel(),ua=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,n,r,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=Jl(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=$l(),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(oa,la,ca),this._renderer.xr.enabled=ua,e.scissorTest=!1,Ci(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===si||e.mapping===zi?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),oa=this._renderer.getRenderTarget(),la=this._renderer.getActiveCubeFace(),ca=this._renderer.getActiveMipmapLevel(),ua=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:Rt,minFilter:Rt,generateMipmaps:!1,type:wn,format:en,colorSpace:us,depthBuffer:!1},r=Zl(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Zl(e,t,n);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Op(s)),this._blurMaterial=zp(s,e,t),this._ggxMaterial=Bp(s,e,t)}return r}_compileMaterial(e){const t=new Kt(new Ft,e);this._renderer.compile(t,er)}_sceneToCubeUV(e,t,n,r,s){const l=new Xt(90,1,t,n),c=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],f=this._renderer,u=f.autoClear,g=f.toneMapping;f.getClearColor(Yl),f.toneMapping=hn,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(r),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Kt(new dr,new or({name:"PMREM.Background",side:Lt,depthWrite:!1,depthTest:!1})));const S=this._backgroundBox,m=S.material;let d=!1;const A=e.background;A?A.isColor&&(m.color.copy(A),e.background=null,d=!0):(m.color.copy(Yl),d=!0);for(let w=0;w<6;w++){const M=w%3;M===0?(l.up.set(0,c[w],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x+h[w],s.y,s.z)):M===1?(l.up.set(0,0,c[w]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+h[w],s.z)):(l.up.set(0,c[w],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+h[w]));const T=this._cubeSize;Ci(r,M*T,w>2?T:0,T,T),f.setRenderTarget(r),d&&f.render(S,l),f.render(e,l)}f.toneMapping=g,f.autoClear=u,e.background=A}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===si||e.mapping===zi;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Jl()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=$l());const s=r?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=s;const o=s.uniforms;o.envMap.value=e;const l=this._cubeSize;Ci(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,er)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodMeshes.length;for(let s=1;s<r;s++)this._applyGGXFilter(e,s-1,s);t.autoClear=n}_applyGGXFilter(e,t,n){const r=this._renderer,s=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),f=Math.sqrt(c*c-h*h),u=0+c*1.25,g=f*u,{_lodMax:_}=this,S=this._sizeLods[n],m=3*S*(n>_-Vn?n-_+Vn:0),d=4*(this._cubeSize-S);l.envMap.value=e.texture,l.roughness.value=g,l.mipInt.value=_-t,Ci(s,m,d,3*S,2*S),r.setRenderTarget(s),r.render(o,er),l.envMap.value=s.texture,l.roughness.value=0,l.mipInt.value=_-n,Ci(e,m,d,3*S,2*S),r.setRenderTarget(e),r.render(o,er)}_blur(e,t,n,r,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,"latitudinal",s),this._halfBlur(a,e,n,n,r,"longitudinal",s)}_halfBlur(e,t,n,r,s,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,f=this._lodMeshes[r];f.material=c;const u=c.uniforms,g=this._sizeLods[n]-1,_=isFinite(s)?Math.PI/(2*g):2*Math.PI/(2*jn-1),S=s/_,m=isFinite(s)?1+Math.floor(h*S):jn;m>jn&&Ne(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${jn}`);const d=[];let A=0;for(let R=0;R<jn;++R){const x=R/S,b=Math.exp(-x*x/2);d.push(b),R===0?A+=b:R<m&&(A+=2*b)}for(let R=0;R<d.length;R++)d[R]=d[R]/A;u.envMap.value=e.texture,u.samples.value=m,u.weights.value=d,u.latitudinal.value=a==="latitudinal",o&&(u.poleAxis.value=o);const{_lodMax:w}=this;u.dTheta.value=_,u.mipInt.value=w-n;const M=this._sizeLods[r],T=3*M*(r>w-Vn?r-w+Vn:0),y=4*(this._cubeSize-M);Ci(t,T,y,3*M,2*M),l.setRenderTarget(t),l.render(f,er)}}function Op(i){const e=[],t=[],n=[];let r=i;const s=i-Vn+1+ql.length;for(let a=0;a<s;a++){const o=Math.pow(2,r);e.push(o);let l=1/o;a>i-Vn?l=ql[a-i+Vn-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),h=-c,f=1+c,u=[h,h,f,h,f,f,h,h,f,f,h,f],g=6,_=6,S=3,m=2,d=1,A=new Float32Array(S*_*g),w=new Float32Array(m*_*g),M=new Float32Array(d*_*g);for(let y=0;y<g;y++){const R=y%3*2/3-1,x=y>2?0:-1,b=[R,x,0,R+2/3,x,0,R+2/3,x+1,0,R,x,0,R+2/3,x+1,0,R,x+1,0];A.set(b,S*_*y),w.set(u,m*_*y);const I=[y,y,y,y,y,y];M.set(I,d*_*y)}const T=new Ft;T.setAttribute("position",new Gt(A,S)),T.setAttribute("uv",new Gt(w,m)),T.setAttribute("faceIndex",new Gt(M,d)),n.push(new Kt(T,null)),r>Vn&&r--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function Zl(i,e,t){const n=new fn(i,e,t);return n.texture.mapping=bs,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Ci(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function Bp(i,e,t){return new pn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Np,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:ws(),fragmentShader:`
|
|
3902
|
+
}`,Ht={alphahash_fragment:qd,alphahash_pars_fragment:Yd,alphamap_fragment:Zd,alphamap_pars_fragment:$d,alphatest_fragment:Kd,alphatest_pars_fragment:Jd,aomap_fragment:Qd,aomap_pars_fragment:jd,batching_pars_vertex:tf,batching_vertex:ef,begin_vertex:nf,beginnormal_vertex:rf,bsdfs:sf,iridescence_fragment:af,bumpmap_pars_fragment:of,clipping_planes_fragment:lf,clipping_planes_pars_fragment:cf,clipping_planes_pars_vertex:hf,clipping_planes_vertex:uf,color_fragment:df,color_pars_fragment:ff,color_pars_vertex:pf,color_vertex:mf,common:gf,cube_uv_reflection_fragment:_f,defaultnormal_vertex:xf,displacementmap_pars_vertex:vf,displacementmap_vertex:Mf,emissivemap_fragment:Sf,emissivemap_pars_fragment:yf,colorspace_fragment:Ef,colorspace_pars_fragment:bf,envmap_fragment:Tf,envmap_common_pars_fragment:Af,envmap_pars_fragment:wf,envmap_pars_vertex:Rf,envmap_physical_pars_fragment:zf,envmap_vertex:Cf,fog_vertex:Pf,fog_pars_vertex:If,fog_fragment:Df,fog_pars_fragment:Lf,gradientmap_pars_fragment:Uf,lightmap_pars_fragment:Nf,lights_lambert_fragment:Ff,lights_lambert_pars_fragment:Of,lights_pars_begin:Bf,lights_toon_fragment:Gf,lights_toon_pars_fragment:Hf,lights_phong_fragment:kf,lights_phong_pars_fragment:Vf,lights_physical_fragment:Wf,lights_physical_pars_fragment:Xf,lights_fragment_begin:qf,lights_fragment_maps:Yf,lights_fragment_end:Zf,lightprobes_pars_fragment:$f,logdepthbuf_fragment:Kf,logdepthbuf_pars_fragment:Jf,logdepthbuf_pars_vertex:Qf,logdepthbuf_vertex:jf,map_fragment:tp,map_pars_fragment:ep,map_particle_fragment:np,map_particle_pars_fragment:ip,metalnessmap_fragment:rp,metalnessmap_pars_fragment:sp,morphinstance_vertex:ap,morphcolor_vertex:op,morphnormal_vertex:lp,morphtarget_pars_vertex:cp,morphtarget_vertex:hp,normal_fragment_begin:up,normal_fragment_maps:dp,normal_pars_fragment:fp,normal_pars_vertex:pp,normal_vertex:mp,normalmap_pars_fragment:gp,clearcoat_normal_fragment_begin:_p,clearcoat_normal_fragment_maps:xp,clearcoat_pars_fragment:vp,iridescence_pars_fragment:Mp,opaque_fragment:Sp,packing:yp,premultiplied_alpha_fragment:Ep,project_vertex:bp,dithering_fragment:Tp,dithering_pars_fragment:Ap,roughnessmap_fragment:wp,roughnessmap_pars_fragment:Rp,shadowmap_pars_fragment:Cp,shadowmap_pars_vertex:Pp,shadowmap_vertex:Ip,shadowmask_pars_fragment:Dp,skinbase_vertex:Lp,skinning_pars_vertex:Up,skinning_vertex:Np,skinnormal_vertex:Fp,specularmap_fragment:Op,specularmap_pars_fragment:Bp,tonemapping_fragment:zp,tonemapping_pars_fragment:Gp,transmission_fragment:Hp,transmission_pars_fragment:kp,uv_pars_fragment:Vp,uv_pars_vertex:Wp,uv_vertex:Xp,worldpos_vertex:qp,background_vert:Yp,background_frag:Zp,backgroundCube_vert:$p,backgroundCube_frag:Kp,cube_vert:Jp,cube_frag:Qp,depth_vert:jp,depth_frag:tm,distance_vert:em,distance_frag:nm,equirect_vert:im,equirect_frag:rm,linedashed_vert:sm,linedashed_frag:am,meshbasic_vert:om,meshbasic_frag:lm,meshlambert_vert:cm,meshlambert_frag:hm,meshmatcap_vert:um,meshmatcap_frag:dm,meshnormal_vert:fm,meshnormal_frag:pm,meshphong_vert:mm,meshphong_frag:gm,meshphysical_vert:_m,meshphysical_frag:xm,meshtoon_vert:vm,meshtoon_frag:Mm,points_vert:Sm,points_frag:ym,shadow_vert:Em,shadow_frag:bm,sprite_vert:Tm,sprite_frag:Am},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 Gt(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 Gt(.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 Gt(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 Gt},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 Gt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ot}}]),vertexShader:Ht.meshphysical_vert,fragmentShader:Ht.meshphysical_frag};const rs={r:0,b:0,g:0},wm=new le,lu=new Ot;lu.set(-1,0,0,0,1,0,0,0,1);function Rm(i,t,e,n,r,s){const a=new It(0);let o=r===!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 M=A.backgroundBlurriness>0;w=t.get(w,M)}return w}function _(A){let w=!1;const M=p(A);M===null?m(a,o):M&&M.isColor&&(m(M,1),w=!0);const y=i.xr.getEnvironmentBlendMode();y==="additive"?e.buffers.color.setClear(0,0,0,1,s):y==="alpha-blend"&&e.buffers.color.setClear(0,0,0,0,s),(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 S(A,w){const M=p(w);M&&(M.isCubeTexture||M.mapping===qs)?(c===void 0&&(c=new ke(new Ar(1,1,1),new Ve({name:"BackgroundCubeMaterial",uniforms:$i(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=M,c.material.uniforms.backgroundBlurriness.value=w.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(wm.makeRotationFromEuler(w.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(lu),c.material.toneMapped=qt.getTransfer(M.colorSpace)!==Qt,(h!==M||d!==M.version||u!==i.toneMapping)&&(c.material.needsUpdate=!0,h=M,d=M.version,u=i.toneMapping),c.layers.enableAll(),A.unshift(c,c.geometry,c.material,0,0,null)):M&&M.isTexture&&(l===void 0&&(l=new ke(new Zs(2,2),new Ve({name:"BackgroundMaterial",uniforms:$i(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=M,l.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,l.material.toneMapped=qt.getTransfer(M.colorSpace)!==Qt,M.matrixAutoUpdate===!0&&M.updateMatrix(),l.material.uniforms.uvTransform.value.copy(M.matrix),(h!==M||d!==M.version||u!==i.toneMapping)&&(l.material.needsUpdate=!0,h=M,d=M.version,u=i.toneMapping),l.layers.enableAll(),A.unshift(l,l.geometry,l.material,0,0,null))}function m(A,w){A.getRGB(rs,iu(i)),e.buffers.color.setClear(rs.r,rs.g,rs.b,w,s)}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:S,dispose:f}}function Cm(i,t){const e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=u(null);let s=r,a=!1;function o(C,U,Y,Z,O){let W=!1;const V=d(C,Z,Y,U);s!==V&&(s=V,c(s.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,M(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=s.attributes,W=U.attributes;let V=0;const Q=Y.getAttributes();for(const et in Q)if(Q[et].location>=0){const rt=O[et];let gt=W[et];if(gt===void 0&&(et==="instanceMatrix"&&C.instanceMatrix&&(gt=C.instanceMatrix),et==="instanceColor"&&C.instanceColor&&(gt=C.instanceColor)),rt===void 0||rt.attribute!==gt||gt&&rt.data!==gt.data)return!0;V++}return s.attributesNum!==V||s.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 rt=W[et];rt===void 0&&(et==="instanceMatrix"&&C.instanceMatrix&&(rt=C.instanceMatrix),et==="instanceColor"&&C.instanceColor&&(rt=C.instanceColor));const gt={};gt.attribute=rt,rt&&rt.data&&(gt.data=rt.data),O[et]=gt,V++}s.attributes=O,s.attributesNum=V,s.index=Z}function S(){const C=s.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=s.newAttributes,Z=s.enabledAttributes,O=s.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=s.newAttributes,U=s.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 M(C,U,Y,Z){S();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 rt=tt.normalized,gt=tt.itemSize,Vt=t.get(tt);if(Vt===void 0)continue;const re=Vt.buffer,Wt=Vt.type,$=Vt.bytesPerElement,st=Wt===i.INT||Wt===i.UNSIGNED_INT||tt.gpuType===ol;if(tt.isInterleavedBufferAttribute){const nt=tt.data,G=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,re);for(let Pt=0;Pt<et.locationSize;Pt++)w(et.location+Pt,gt/et.locationSize,Wt,rt,G*$,(Ct+gt/et.locationSize*Pt)*$,st)}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,re);for(let nt=0;nt<et.locationSize;nt++)w(et.location+nt,gt/et.locationSize,Wt,rt,gt*$,gt/et.locationSize*nt*$,st)}}else if(V!==void 0){const rt=V[Q];if(rt!==void 0)switch(rt.length){case 2:i.vertexAttrib2fv(et.location,rt);break;case 3:i.vertexAttrib3fv(et.location,rt);break;case 4:i.vertexAttrib4fv(et.location,rt);break;default:i.vertexAttrib1fv(et.location,rt)}}}}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 x(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,s!==r&&(s=r,c(s.object))}function I(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:T,resetDefaultState:I,dispose:y,releaseStatesOfGeometry:b,releaseStatesOfObject:x,releaseStatesOfProgram:R,initAttributes:S,enableAttribute:m,disableUnusedAttributes:A}}function Pm(i,t,e){let n;function r(l){n=l}function s(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=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=o}function Im(i,t,e,n){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){const R=t.get("EXT_texture_filter_anisotropic");r=i.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(R){return!(R!==rn&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(R){const x=R===Cn&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(R!==Ke&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==dn&&!x)}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),S=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),f=i.getParameter(i.MAX_VERTEX_ATTRIBS),A=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),w=i.getParameter(i.MAX_VARYING_VECTORS),M=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),y=i.getParameter(i.MAX_SAMPLES),b=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:u,maxTextures:p,maxVertexTextures:_,maxTextureSize:S,maxCubemapSize:m,maxAttributes:f,maxVertexUniforms:A,maxVaryings:w,maxFragmentUniforms:M,maxSamples:y,samples:b}}function Dm(i){const t=this;let e=null,n=0,r=!1,s=!1;const a=new ti,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||r;return r=u,n=d.length,p},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,u){e=h(d,u,0)},this.setState=function(d,u,p){const _=d.clippingPlanes,S=d.clipIntersection,m=d.clipShadows,f=i.get(d);if(!r||_===null||_.length===0||s&&!m)s?h(null):c();else{const A=s?0:n,w=A*4;let M=f.clippingState||null;l.value=M,M=h(_,u,w,p);for(let y=0;y!==w;++y)M[y]=e[y];f.clippingState=M,this.numIntersection=S?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 S=d!==null?d.length:0;let m=null;if(S!==0){if(m=l.value,_!==!0||m===null){const f=p+S*4,A=u.matrixWorldInverse;o.getNormalMatrix(A),(m===null||m.length<f)&&(m=new Float32Array(f));for(let w=0,M=p;w!==S;++w,M+=4)a.copy(d[w]).applyMatrix4(A,o),a.normal.toArray(m,M),m[M+3]=a.constant}l.value=m,l.needsUpdate=!0}return t.numPlanes=S,t.numIntersection=0,m}}const Wn=4,gc=[.125,.215,.35,.446,.526,.582],ni=20,Lm=256,hr=new su,_c=new It;let Ca=null,Pa=0,Ia=0,Da=!1;const Um=new F;class xc{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,r=100,s={}){const{size:a=256,position:o=Um}=s;Ca=this._renderer.getRenderTarget(),Pa=this._renderer.getActiveCubeFace(),Ia=this._renderer.getActiveMipmapLevel(),Da=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(t,n,r,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=Sc(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Mc(),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(Ca,Pa,Ia),this._renderer.xr.enabled=Da,t.scissorTest=!1,Di(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===li||t.mapping===Yi?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Ca=this._renderer.getRenderTarget(),Pa=this._renderer.getActiveCubeFace(),Ia=this._renderer.getActiveMipmapLevel(),Da=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:rn,colorSpace:Is,depthBuffer:!1},r=vc(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=vc(t,e,n);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Nm(s)),this._blurMaterial=Om(s,t,e),this._ggxMaterial=Fm(s,t,e)}return r}_compileMaterial(t){const e=new ke(new Te,t);this._renderer.compile(e,hr)}_sceneToCubeUV(t,e,n,r,s){const l=new $e(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(_c),d.toneMapping=pn,d.autoClear=!1,d.state.buffers.depth.getReversed()&&(d.setRenderTarget(r),d.clearDepth(),d.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new ke(new Ar,new Vi({name:"PMREM.Background",side:Fe,depthWrite:!1,depthTest:!1})));const S=this._backgroundBox,m=S.material;let f=!1;const A=t.background;A?A.isColor&&(m.color.copy(A),t.background=null,f=!0):(m.color.copy(_c),f=!0);for(let w=0;w<6;w++){const M=w%3;M===0?(l.up.set(0,c[w],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x+h[w],s.y,s.z)):M===1?(l.up.set(0,0,c[w]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+h[w],s.z)):(l.up.set(0,c[w],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+h[w]));const y=this._cubeSize;Di(r,M*y,w>2?y:0,y,y),d.setRenderTarget(r),f&&d.render(S,l),d.render(t,l)}d.toneMapping=p,d.autoClear=u,t.background=A}_textureToCubeUV(t,e){const n=this._renderer,r=t.mapping===li||t.mapping===Yi;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Sc()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Mc());const s=r?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=s;const o=s.uniforms;o.envMap.value=t;const l=this._cubeSize;Di(e,0,0,3*l,2*l),n.setRenderTarget(e),n.render(a,hr)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const r=this._lodMeshes.length;for(let s=1;s<r;s++)this._applyGGXFilter(t,s-1,s);e.autoClear=n}_applyGGXFilter(t,e,n){const r=this._renderer,s=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,S=this._sizeLods[n],m=3*S*(n>_-Wn?n-_+Wn:0),f=4*(this._cubeSize-S);l.envMap.value=t.texture,l.roughness.value=p,l.mipInt.value=_-e,Di(s,m,f,3*S,2*S),r.setRenderTarget(s),r.render(o,hr),l.envMap.value=s.texture,l.roughness.value=0,l.mipInt.value=_-n,Di(t,m,f,3*S,2*S),r.setRenderTarget(t),r.render(o,hr)}_blur(t,e,n,r,s){const a=this._pingPongRenderTarget;this._halfBlur(t,a,e,n,r,"latitudinal",s),this._halfBlur(a,t,n,n,r,"longitudinal",s)}_halfBlur(t,e,n,r,s,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[r];d.material=c;const u=c.uniforms,p=this._sizeLods[n]-1,_=isFinite(s)?Math.PI/(2*p):2*Math.PI/(2*ni-1),S=s/_,m=isFinite(s)?1+Math.floor(h*S):ni;m>ni&&Ft(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${ni}`);const f=[];let A=0;for(let R=0;R<ni;++R){const x=R/S,T=Math.exp(-x*x/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 M=this._sizeLods[r],y=3*M*(r>w-Wn?r-w+Wn:0),b=4*(this._cubeSize-M);Di(e,y,b,3*M,2*M),l.setRenderTarget(e),l.render(d,hr)}}function Nm(i){const t=[],e=[],n=[];let r=i;const s=i-Wn+1+gc.length;for(let a=0;a<s;a++){const o=Math.pow(2,r);t.push(o);let l=1/o;a>i-Wn?l=gc[a-i+Wn-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,S=3,m=2,f=1,A=new Float32Array(S*_*p),w=new Float32Array(m*_*p),M=new Float32Array(f*_*p);for(let b=0;b<p;b++){const R=b%3*2/3-1,x=b>2?0:-1,T=[R,x,0,R+2/3,x,0,R+2/3,x+1,0,R,x,0,R+2/3,x+1,0,R,x+1,0];A.set(T,S*_*b),w.set(u,m*_*b);const I=[b,b,b,b,b,b];M.set(I,f*_*b)}const y=new Te;y.setAttribute("position",new pe(A,S)),y.setAttribute("uv",new pe(w,m)),y.setAttribute("faceIndex",new pe(M,f)),n.push(new ke(y,null)),r>Wn&&r--}return{lodMeshes:n,sizeLods:t,sigmas:e}}function vc(i,t,e){const n=new mn(i,t,e);return n.texture.mapping=qs,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Di(i,t,e,n,r){i.viewport.set(t,e,n,r),i.scissor.set(t,e,n,r)}function Fm(i,t,e){return new Ve({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Lm,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:$s(),fragmentShader:`
|
|
3887
3903
|
|
|
3888
3904
|
precision highp float;
|
|
3889
3905
|
precision highp int;
|
|
@@ -3987,7 +4003,7 @@ void main() {
|
|
|
3987
4003
|
|
|
3988
4004
|
gl_FragColor = vec4(prefilteredColor, 1.0);
|
|
3989
4005
|
}
|
|
3990
|
-
`,blending:
|
|
4006
|
+
`,blending:wn,depthTest:!1,depthWrite:!1})}function Om(i,t,e){const n=new Float32Array(ni),r=new F(0,1,0);return new Ve({name:"SphericalGaussianBlur",defines:{n:ni,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:$s(),fragmentShader:`
|
|
3991
4007
|
|
|
3992
4008
|
precision mediump float;
|
|
3993
4009
|
precision mediump int;
|
|
@@ -4047,7 +4063,7 @@ void main() {
|
|
|
4047
4063
|
}
|
|
4048
4064
|
|
|
4049
4065
|
}
|
|
4050
|
-
`,blending:
|
|
4066
|
+
`,blending:wn,depthTest:!1,depthWrite:!1})}function Mc(){return new Ve({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:$s(),fragmentShader:`
|
|
4051
4067
|
|
|
4052
4068
|
precision mediump float;
|
|
4053
4069
|
precision mediump int;
|
|
@@ -4066,7 +4082,7 @@ void main() {
|
|
|
4066
4082
|
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
|
|
4067
4083
|
|
|
4068
4084
|
}
|
|
4069
|
-
`,blending:
|
|
4085
|
+
`,blending:wn,depthTest:!1,depthWrite:!1})}function Sc(){return new Ve({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:$s(),fragmentShader:`
|
|
4070
4086
|
|
|
4071
4087
|
precision mediump float;
|
|
4072
4088
|
precision mediump int;
|
|
@@ -4082,7 +4098,7 @@ void main() {
|
|
|
4082
4098
|
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
|
|
4083
4099
|
|
|
4084
4100
|
}
|
|
4085
|
-
`,blending:
|
|
4101
|
+
`,blending:wn,depthTest:!1,depthWrite:!1})}function $s(){return`
|
|
4086
4102
|
|
|
4087
4103
|
precision mediump float;
|
|
4088
4104
|
precision mediump int;
|
|
@@ -4137,7 +4153,7 @@ void main() {
|
|
|
4137
4153
|
gl_Position = vec4( position, 1.0 );
|
|
4138
4154
|
|
|
4139
4155
|
}
|
|
4140
|
-
`}class
|
|
4156
|
+
`}class cu extends mn{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},r=[n,n,n,n,n,n];this.texture=new eu(r),this._setTextureOptions(e),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
|
|
4141
4157
|
|
|
4142
4158
|
varying vec3 vWorldDirection;
|
|
4143
4159
|
|
|
@@ -4172,7 +4188,7 @@ void main() {
|
|
|
4172
4188
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
4173
4189
|
|
|
4174
4190
|
}
|
|
4175
|
-
`},r=new
|
|
4191
|
+
`},r=new Ar(5,5,5),s=new Ve({name:"CubemapFromEquirect",uniforms:$i(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Fe,blending:wn});s.uniforms.tEquirect.value=e;const a=new ke(r,s),o=e.minFilter;return e.minFilter===ri&&(e.minFilter=Ie),new Hd(1,10,this).update(t,a),e.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(t,e=!0,n=!0,r=!0){const s=t.getRenderTarget();for(let a=0;a<6;a++)t.setRenderTarget(this,a),t.clear(e,n,r);t.setRenderTarget(s)}}function Bm(i){let t=new WeakMap,e=new WeakMap,n=null;function r(u,p=!1){return u==null?null:p?a(u):s(u)}function s(u){if(u&&u.isTexture){const p=u.mapping;if(p===ea||p===na)if(t.has(u)){const _=t.get(u).texture;return o(_,u.mapping)}else{const _=u.image;if(_&&_.height>0){const S=new cu(_.height);return S.fromEquirectangularTexture(i,u),t.set(u,S),u.addEventListener("dispose",c),o(S.texture,u.mapping)}else return null}}return u}function a(u){if(u&&u.isTexture){const p=u.mapping,_=p===ea||p===na,S=p===li||p===Yi;if(_||S){let m=e.get(u);const f=m!==void 0?m.texture.pmremVersion:0;if(u.isRenderTargetTexture&&u.pmremVersion!==f)return n===null&&(n=new xc(i)),m=_?n.fromEquirectangular(u,m):n.fromCubemap(u,m),m.texture.pmremVersion=u.pmremVersion,e.set(u,m),m.texture;if(m!==void 0)return m.texture;{const A=u.image;return _&&A&&A.height>0||S&&A&&l(A)?(n===null&&(n=new xc(i)),m=_?n.fromEquirectangular(u):n.fromCubemap(u),m.texture.pmremVersion=u.pmremVersion,e.set(u,m),u.addEventListener("dispose",h),m.texture):null}}}return u}function o(u,p){return p===ea?u.mapping=li:p===na&&(u.mapping=Yi),u}function l(u){let p=0;const _=6;for(let S=0;S<_;S++)u[S]!==void 0&&p++;return p===_}function c(u){const p=u.target;p.removeEventListener("dispose",c);const _=t.get(p);_!==void 0&&(t.delete(p),_.dispose())}function h(u){const p=u.target;p.removeEventListener("dispose",h);const _=e.get(p);_!==void 0&&(e.delete(p),_.dispose())}function d(){t=new WeakMap,e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:d}}function zm(i){const t={};function e(n){if(t[n]!==void 0)return t[n];const r=i.getExtension(n);return t[n]=r,r}return{has:function(n){return e(n)!==null},init:function(){e("EXT_color_buffer_float"),e("WEBGL_clip_cull_distance"),e("OES_texture_float_linear"),e("EXT_color_buffer_half_float"),e("WEBGL_multisampled_render_to_texture"),e("WEBGL_render_shared_exponent")},get:function(n){const r=e(n);return r===null&&Hi("WebGLRenderer: "+n+" extension not supported."),r}}}function Gm(i,t,e,n){const r={},s=new WeakMap;function a(d){const u=d.target;u.index!==null&&t.remove(u.index);for(const _ in u.attributes)t.remove(u.attributes[_]);u.removeEventListener("dispose",a),delete r[u.id];const p=s.get(u);p&&(t.remove(p),s.delete(u)),n.releaseStatesOfGeometry(u),u.isInstancedBufferGeometry===!0&&delete u._maxInstanceCount,e.memory.geometries--}function o(d,u){return r[u.id]===!0||(u.addEventListener("dispose",a),r[u.id]=!0,e.memory.geometries++),u}function l(d){const u=d.attributes;for(const p in u)t.update(u[p],i.ARRAY_BUFFER)}function c(d){const u=[],p=d.index,_=d.attributes.position;let S=0;if(_===void 0)return;if(p!==null){const A=p.array;S=p.version;for(let w=0,M=A.length;w<M;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;S=_.version;for(let w=0,M=A.length/3-1;w<M;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?Jh:Kh)(u,1);m.version=S;const f=s.get(d);f&&t.remove(f),s.set(d,m)}function h(d){const u=s.get(d);if(u){const p=d.index;p!==null&&u.version<p.version&&c(d)}else c(d);return s.get(d)}return{get:o,update:l,getWireframeAttribute:h}}function Hm(i,t,e){let n;function r(d){n=d}let s,a;function o(d){s=d.type,a=d.bytesPerElement}function l(d,u){i.drawElements(n,u,s,d*a),e.update(u,n,1)}function c(d,u,p){p!==0&&(i.drawElementsInstanced(n,u,s,d*a,p),e.update(u,n,p))}function h(d,u,p){if(p===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,u,0,s,d,0,p);let S=0;for(let m=0;m<p;m++)S+=u[m];e.update(S,n,1)}this.setMode=r,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=h}function km(i){const t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,a,o){switch(e.calls++,a){case i.TRIANGLES:e.triangles+=o*(s/3);break;case i.LINES:e.lines+=o*(s/2);break;case i.LINE_STRIP:e.lines+=o*(s-1);break;case i.LINE_LOOP:e.lines+=o*s;break;case i.POINTS:e.points+=o*s;break;default:Xt("WebGLInfo: Unknown draw mode:",a);break}}function r(){e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:r,update:n}}function Vm(i,t,e){const n=new WeakMap,r=new fe;function s(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,S=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),S===!0&&(w=3);let M=o.attributes.position.count*w,y=1;M>t.maxTextureSize&&(y=Math.ceil(M/t.maxTextureSize),M=t.maxTextureSize);const b=new Float32Array(M*y*4*d),R=new Zh(b,M,y,d);R.type=dn,R.needsUpdate=!0;const x=w*4;for(let I=0;I<d;I++){const C=m[I],U=f[I],Y=A[I],Z=M*y*4*I;for(let O=0;O<C.count;O++){const W=O*x;p===!0&&(r.fromBufferAttribute(C,O),b[Z+W+0]=r.x,b[Z+W+1]=r.y,b[Z+W+2]=r.z,b[Z+W+3]=0),_===!0&&(r.fromBufferAttribute(U,O),b[Z+W+4]=r.x,b[Z+W+5]=r.y,b[Z+W+6]=r.z,b[Z+W+7]=0),S===!0&&(r.fromBufferAttribute(Y,O),b[Z+W+8]=r.x,b[Z+W+9]=r.y,b[Z+W+10]=r.z,b[Z+W+11]=Y.itemSize===4?r.w:1)}}u={count:d,texture:R,size:new Gt(M,y)},n.set(o,u),o.addEventListener("dispose",T)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(i,"morphTexture",a.morphTexture,e);else{let p=0;for(let S=0;S<c.length;S++)p+=c[S];const _=o.morphTargetsRelative?1:1-p;l.getUniforms().setValue(i,"morphTargetBaseInfluence",_),l.getUniforms().setValue(i,"morphTargetInfluences",c)}l.getUniforms().setValue(i,"morphTargetsTexture",u.texture,e),l.getUniforms().setValue(i,"morphTargetsTextureSize",u.size)}return{update:s}}function Wm(i,t,e,n,r){let s=new WeakMap;function a(c){const h=r.render.frame,d=c.geometry,u=t.get(c,d);if(s.get(u)!==h&&(t.update(u),s.set(u,h)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),s.get(c)!==h&&(e.update(c.instanceMatrix,i.ARRAY_BUFFER),c.instanceColor!==null&&e.update(c.instanceColor,i.ARRAY_BUFFER),s.set(c,h))),c.isSkinnedMesh){const p=c.skeleton;s.get(p)!==h&&(p.update(),s.set(p,h))}return u}function o(){s=new WeakMap}function l(c){const h=c.target;h.removeEventListener("dispose",l),n.releaseStatesOfObject(h),e.remove(h.instanceMatrix),h.instanceColor!==null&&e.remove(h.instanceColor)}return{update:a,dispose:o}}const Xm={[Dh]:"LINEAR_TONE_MAPPING",[Lh]:"REINHARD_TONE_MAPPING",[Uh]:"CINEON_TONE_MAPPING",[Nh]:"ACES_FILMIC_TONE_MAPPING",[Oh]:"AGX_TONE_MAPPING",[Bh]:"NEUTRAL_TONE_MAPPING",[Fh]:"CUSTOM_TONE_MAPPING"};function qm(i,t,e,n,r,s){const a=new mn(t,e,{type:i,depthBuffer:r,stencilBuffer:s,samples:n?4:0,depthTexture:r?new Zi(t,e):void 0}),o=new mn(t,e,{type:Cn,depthBuffer:!1,stencilBuffer:!1}),l=new Te;l.setAttribute("position",new Le([-1,3,0,-1,-1,0,3,-1,0],3)),l.setAttribute("uv",new Le([0,2,0,0,2,0],2));const c=new Bd({uniforms:{tDiffuse:{value:null}},vertexShader:`
|
|
4176
4192
|
precision highp float;
|
|
4177
4193
|
|
|
4178
4194
|
uniform mat4 modelViewMatrix;
|
|
@@ -4218,17 +4234,17 @@ void main() {
|
|
|
4218
4234
|
#ifdef SRGB_TRANSFER
|
|
4219
4235
|
gl_FragColor = sRGBTransferOETF( gl_FragColor );
|
|
4220
4236
|
#endif
|
|
4221
|
-
}`,depthTest:!1,depthWrite:!1}),h=new
|
|
4222
|
-
`),n=[],r=Math.max(
|
|
4223
|
-
`)}const
|
|
4237
|
+
}`,depthTest:!1,depthWrite:!1}),h=new ke(l,c),d=new su(-1,1,1,-1,0,1);let u=null,p=null,_=!1,S,m=null,f=[],A=!1;this.setSize=function(w,M){a.setSize(w,M),o.setSize(w,M);for(let y=0;y<f.length;y++){const b=f[y];b.setSize&&b.setSize(w,M)}},this.setEffects=function(w){f=w,A=f.length>0&&f[0].isRenderPass===!0;const M=a.width,y=a.height;for(let b=0;b<f.length;b++){const R=f[b];R.setSize&&R.setSize(M,y)}},this.begin=function(w,M){if(_||w.toneMapping===pn&&f.length===0)return!1;if(m=M,M!==null){const y=M.width,b=M.height;(a.width!==y||a.height!==b)&&this.setSize(y,b)}return A===!1&&w.setRenderTarget(a),S=w.toneMapping,w.toneMapping=pn,!0},this.hasRenderPass=function(){return A},this.end=function(w,M){w.toneMapping=S,_=!0;let y=a,b=o;for(let R=0;R<f.length;R++){const x=f[R];if(x.enabled!==!1&&(x.render(w,b,y,M),x.needsSwap!==!1)){const T=y;y=b,b=T}}if(u!==w.outputColorSpace||p!==w.toneMapping){u=w.outputColorSpace,p=w.toneMapping,c.defines={},qt.getTransfer(u)===Qt&&(c.defines.SRGB_TRANSFER="");const R=Xm[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 hu=new De,Go=new Zi(1,1),uu=new Zh,du=new pd,fu=new eu,yc=[],Ec=[],bc=new Float32Array(16),Tc=new Float32Array(9),Ac=new Float32Array(4);function tr(i,t,e){const n=i[0];if(n<=0||n>0)return i;const r=t*e;let s=yc[r];if(s===void 0&&(s=new Float32Array(r),yc[r]=s),t!==0){n.toArray(s,0);for(let a=1,o=0;a!==t;++a)o+=e,i[a].toArray(s,o)}return s}function Me(i,t){if(i.length!==t.length)return!1;for(let e=0,n=i.length;e<n;e++)if(i[e]!==t[e])return!1;return!0}function Se(i,t){for(let e=0,n=t.length;e<n;e++)i[e]=t[e]}function Ks(i,t){let e=Ec[t];e===void 0&&(e=new Int32Array(t),Ec[t]=e);for(let n=0;n!==t;++n)e[n]=i.allocateTextureUnit();return e}function Ym(i,t){const e=this.cache;e[0]!==t&&(i.uniform1f(this.addr,t),e[0]=t)}function Zm(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Me(e,t))return;i.uniform2fv(this.addr,t),Se(e,t)}}function $m(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(i.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(Me(e,t))return;i.uniform3fv(this.addr,t),Se(e,t)}}function Km(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Me(e,t))return;i.uniform4fv(this.addr,t),Se(e,t)}}function Jm(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(Me(e,t))return;i.uniformMatrix2fv(this.addr,!1,t),Se(e,t)}else{if(Me(e,n))return;Ac.set(n),i.uniformMatrix2fv(this.addr,!1,Ac),Se(e,n)}}function Qm(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(Me(e,t))return;i.uniformMatrix3fv(this.addr,!1,t),Se(e,t)}else{if(Me(e,n))return;Tc.set(n),i.uniformMatrix3fv(this.addr,!1,Tc),Se(e,n)}}function jm(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(Me(e,t))return;i.uniformMatrix4fv(this.addr,!1,t),Se(e,t)}else{if(Me(e,n))return;bc.set(n),i.uniformMatrix4fv(this.addr,!1,bc),Se(e,n)}}function tg(i,t){const e=this.cache;e[0]!==t&&(i.uniform1i(this.addr,t),e[0]=t)}function eg(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Me(e,t))return;i.uniform2iv(this.addr,t),Se(e,t)}}function ng(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(Me(e,t))return;i.uniform3iv(this.addr,t),Se(e,t)}}function ig(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4i(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Me(e,t))return;i.uniform4iv(this.addr,t),Se(e,t)}}function rg(i,t){const e=this.cache;e[0]!==t&&(i.uniform1ui(this.addr,t),e[0]=t)}function sg(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Me(e,t))return;i.uniform2uiv(this.addr,t),Se(e,t)}}function ag(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(Me(e,t))return;i.uniform3uiv(this.addr,t),Se(e,t)}}function og(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4ui(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Me(e,t))return;i.uniform4uiv(this.addr,t),Se(e,t)}}function lg(i,t,e){const n=this.cache,r=e.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r);let s;this.type===i.SAMPLER_2D_SHADOW?(Go.compareFunction=e.isReversedDepthBuffer()?pl:fl,s=Go):s=hu,e.setTexture2D(t||s,r)}function cg(i,t,e){const n=this.cache,r=e.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),e.setTexture3D(t||du,r)}function hg(i,t,e){const n=this.cache,r=e.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),e.setTextureCube(t||fu,r)}function ug(i,t,e){const n=this.cache,r=e.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),e.setTexture2DArray(t||uu,r)}function dg(i){switch(i){case 5126:return Ym;case 35664:return Zm;case 35665:return $m;case 35666:return Km;case 35674:return Jm;case 35675:return Qm;case 35676:return jm;case 5124:case 35670:return tg;case 35667:case 35671:return eg;case 35668:case 35672:return ng;case 35669:case 35673:return ig;case 5125:return rg;case 36294:return sg;case 36295:return ag;case 36296:return og;case 35678:case 36198:case 36298:case 36306:case 35682:return lg;case 35679:case 36299:case 36307:return cg;case 35680:case 36300:case 36308:case 36293:return hg;case 36289:case 36303:case 36311:case 36292:return ug}}function fg(i,t){i.uniform1fv(this.addr,t)}function pg(i,t){const e=tr(t,this.size,2);i.uniform2fv(this.addr,e)}function mg(i,t){const e=tr(t,this.size,3);i.uniform3fv(this.addr,e)}function gg(i,t){const e=tr(t,this.size,4);i.uniform4fv(this.addr,e)}function _g(i,t){const e=tr(t,this.size,4);i.uniformMatrix2fv(this.addr,!1,e)}function xg(i,t){const e=tr(t,this.size,9);i.uniformMatrix3fv(this.addr,!1,e)}function vg(i,t){const e=tr(t,this.size,16);i.uniformMatrix4fv(this.addr,!1,e)}function Mg(i,t){i.uniform1iv(this.addr,t)}function Sg(i,t){i.uniform2iv(this.addr,t)}function yg(i,t){i.uniform3iv(this.addr,t)}function Eg(i,t){i.uniform4iv(this.addr,t)}function bg(i,t){i.uniform1uiv(this.addr,t)}function Tg(i,t){i.uniform2uiv(this.addr,t)}function Ag(i,t){i.uniform3uiv(this.addr,t)}function wg(i,t){i.uniform4uiv(this.addr,t)}function Rg(i,t,e){const n=this.cache,r=t.length,s=Ks(e,r);Me(n,s)||(i.uniform1iv(this.addr,s),Se(n,s));let a;this.type===i.SAMPLER_2D_SHADOW?a=Go:a=hu;for(let o=0;o!==r;++o)e.setTexture2D(t[o]||a,s[o])}function Cg(i,t,e){const n=this.cache,r=t.length,s=Ks(e,r);Me(n,s)||(i.uniform1iv(this.addr,s),Se(n,s));for(let a=0;a!==r;++a)e.setTexture3D(t[a]||du,s[a])}function Pg(i,t,e){const n=this.cache,r=t.length,s=Ks(e,r);Me(n,s)||(i.uniform1iv(this.addr,s),Se(n,s));for(let a=0;a!==r;++a)e.setTextureCube(t[a]||fu,s[a])}function Ig(i,t,e){const n=this.cache,r=t.length,s=Ks(e,r);Me(n,s)||(i.uniform1iv(this.addr,s),Se(n,s));for(let a=0;a!==r;++a)e.setTexture2DArray(t[a]||uu,s[a])}function Dg(i){switch(i){case 5126:return fg;case 35664:return pg;case 35665:return mg;case 35666:return gg;case 35674:return _g;case 35675:return xg;case 35676:return vg;case 5124:case 35670:return Mg;case 35667:case 35671:return Sg;case 35668:case 35672:return yg;case 35669:case 35673:return Eg;case 5125:return bg;case 36294:return Tg;case 36295:return Ag;case 36296:return wg;case 35678:case 36198:case 36298:case 36306:case 35682:return Rg;case 35679:case 36299:case 36307:return Cg;case 35680:case 36300:case 36308:case 36293:return Pg;case 36289:case 36303:case 36311:case 36292:return Ig}}class Lg{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=dg(e.type)}}class Ug{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=Dg(e.type)}}class Ng{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const r=this.seq;for(let s=0,a=r.length;s!==a;++s){const o=r[s];o.setValue(t,e[o.id],n)}}}const La=/(\w+)(\])?(\[|\.)?/g;function wc(i,t){i.seq.push(t),i.map[t.id]=t}function Fg(i,t,e){const n=i.name,r=n.length;for(La.lastIndex=0;;){const s=La.exec(n),a=La.lastIndex;let o=s[1];const l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===r){wc(e,c===void 0?new Lg(o,i,t):new Ug(o,i,t));break}else{let d=e.map[o];d===void 0&&(d=new Ng(o),wc(e,d)),e=d}}}class ws{constructor(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let a=0;a<n;++a){const o=t.getActiveUniform(e,a),l=t.getUniformLocation(e,o.name);Fg(o,l,this)}const r=[],s=[];for(const a of this.seq)a.type===t.SAMPLER_2D_SHADOW||a.type===t.SAMPLER_CUBE_SHADOW||a.type===t.SAMPLER_2D_ARRAY_SHADOW?r.push(a):s.push(a);r.length>0&&(this.seq=r.concat(s))}setValue(t,e,n,r){const s=this.map[e];s!==void 0&&s.setValue(t,n,r)}setOptional(t,e,n){const r=e[n];r!==void 0&&this.setValue(t,n,r)}static upload(t,e,n,r){for(let s=0,a=e.length;s!==a;++s){const o=e[s],l=n[o.id];l.needsUpdate!==!1&&o.setValue(t,l.value,r)}}static seqWithValue(t,e){const n=[];for(let r=0,s=t.length;r!==s;++r){const a=t[r];a.id in e&&n.push(a)}return n}}function Rc(i,t,e){const n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}const Og=37297;let Bg=0;function zg(i,t){const e=i.split(`
|
|
4238
|
+
`),n=[],r=Math.max(t-6,0),s=Math.min(t+6,e.length);for(let a=r;a<s;a++){const o=a+1;n.push(`${o===t?">":" "} ${o}: ${e[a]}`)}return n.join(`
|
|
4239
|
+
`)}const Cc=new Ot;function Gg(i){qt._getMatrix(Cc,qt.workingColorSpace,i);const t=`mat3( ${Cc.elements.map(e=>e.toFixed(4))} )`;switch(qt.getTransfer(i)){case Ds:return[t,"LinearTransferOETF"];case Qt:return[t,"sRGBTransferOETF"];default:return Ft("WebGLProgram: Unsupported color space: ",i),[t,"LinearTransferOETF"]}}function Pc(i,t,e){const n=i.getShaderParameter(t,i.COMPILE_STATUS),s=(i.getShaderInfoLog(t)||"").trim();if(n&&s==="")return"";const a=/ERROR: 0:(\d+)/.exec(s);if(a){const o=parseInt(a[1]);return e.toUpperCase()+`
|
|
4224
4240
|
|
|
4225
4241
|
`+s+`
|
|
4226
4242
|
|
|
4227
|
-
`+
|
|
4228
|
-
`)}const
|
|
4229
|
-
`)}function
|
|
4230
|
-
`)}function
|
|
4231
|
-
`)}function
|
|
4243
|
+
`+zg(i.getShaderSource(t),o)}else return s}function Hg(i,t){const e=Gg(t);return[`vec4 ${i}( vec4 value ) {`,` return ${e[1]}( vec4( value.rgb * ${e[0]}, value.a ) );`,"}"].join(`
|
|
4244
|
+
`)}const kg={[Dh]:"Linear",[Lh]:"Reinhard",[Uh]:"Cineon",[Nh]:"ACESFilmic",[Oh]:"AgX",[Bh]:"Neutral",[Fh]:"Custom"};function Vg(i,t){const e=kg[t];return e===void 0?(Ft("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}const ss=new F;function Wg(){qt.getLuminanceCoefficients(ss);const i=ss.x.toFixed(4),t=ss.y.toFixed(4),e=ss.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${t}, ${e} );`," return dot( weights, rgb );","}"].join(`
|
|
4245
|
+
`)}function Xg(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(_r).join(`
|
|
4246
|
+
`)}function qg(i){const t=[];for(const e in i){const n=i[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(`
|
|
4247
|
+
`)}function Yg(i,t){const e={},n=i.getProgramParameter(t,i.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){const s=i.getActiveAttrib(t,r),a=s.name;let o=1;s.type===i.FLOAT_MAT2&&(o=2),s.type===i.FLOAT_MAT3&&(o=3),s.type===i.FLOAT_MAT4&&(o=4),e[a]={type:s.type,location:i.getAttribLocation(t,a),locationSize:o}}return e}function _r(i){return i!==""}function Ic(i,t){const e=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,e).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Dc(i,t){return i.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const Zg=/^[ \t]*#include +<([\w\d./]+)>/gm;function Ho(i){return i.replace(Zg,Kg)}const $g=new Map;function Kg(i,t){let e=Ht[t];if(e===void 0){const n=$g.get(t);if(n!==void 0)e=Ht[n],Ft('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return Ho(e)}const Jg=/#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 Lc(i){return i.replace(Jg,Qg)}function Qg(i,t,e,n){let r="";for(let s=parseInt(t);s<parseInt(e);s++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function Uc(i){let t=`precision ${i.precision} float;
|
|
4232
4248
|
precision ${i.precision} int;
|
|
4233
4249
|
precision ${i.precision} sampler2D;
|
|
4234
4250
|
precision ${i.precision} samplerCube;
|
|
@@ -4245,33 +4261,33 @@ void main() {
|
|
|
4245
4261
|
precision ${i.precision} usampler3D;
|
|
4246
4262
|
precision ${i.precision} usamplerCube;
|
|
4247
4263
|
precision ${i.precision} usampler2DArray;
|
|
4248
|
-
`;return i.precision==="highp"?
|
|
4249
|
-
#define HIGH_PRECISION`:i.precision==="mediump"?
|
|
4250
|
-
#define MEDIUM_PRECISION`:i.precision==="lowp"&&(
|
|
4251
|
-
#define LOW_PRECISION`),
|
|
4252
|
-
`:"";
|
|
4264
|
+
`;return i.precision==="highp"?t+=`
|
|
4265
|
+
#define HIGH_PRECISION`:i.precision==="mediump"?t+=`
|
|
4266
|
+
#define MEDIUM_PRECISION`:i.precision==="lowp"&&(t+=`
|
|
4267
|
+
#define LOW_PRECISION`),t}const jg={[Ss]:"SHADOWMAP_TYPE_PCF",[gr]:"SHADOWMAP_TYPE_VSM"};function t_(i){return jg[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const e_={[li]:"ENVMAP_TYPE_CUBE",[Yi]:"ENVMAP_TYPE_CUBE",[qs]:"ENVMAP_TYPE_CUBE_UV"};function n_(i){return i.envMap===!1?"ENVMAP_TYPE_CUBE":e_[i.envMapMode]||"ENVMAP_TYPE_CUBE"}const i_={[Yi]:"ENVMAP_MODE_REFRACTION"};function r_(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":i_[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}const s_={[Ih]:"ENVMAP_BLENDING_MULTIPLY",[Y0]:"ENVMAP_BLENDING_MIX",[Z0]:"ENVMAP_BLENDING_ADD"};function a_(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":s_[i.combine]||"ENVMAP_BLENDING_NONE"}function o_(i){const t=i.envMapCubeUVHeight;if(t===null)return null;const e=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:n,maxMip:e}}function l_(i,t,e,n){const r=i.getContext(),s=e.defines;let a=e.vertexShader,o=e.fragmentShader;const l=t_(e),c=n_(e),h=r_(e),d=a_(e),u=o_(e),p=Xg(e),_=qg(s),S=r.createProgram();let m,f,A=e.glslVersion?"#version "+e.glslVersion+`
|
|
4268
|
+
`:"";e.isRawShaderMaterial?(m=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,_].filter(_r).join(`
|
|
4253
4269
|
`),m.length>0&&(m+=`
|
|
4254
|
-
`),
|
|
4255
|
-
`),
|
|
4256
|
-
`)):(m=[
|
|
4257
|
-
`].filter(
|
|
4258
|
-
`),
|
|
4259
|
-
`].filter(
|
|
4260
|
-
`)),a=
|
|
4261
|
-
`,m=[
|
|
4270
|
+
`),f=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,_].filter(_r).join(`
|
|
4271
|
+
`),f.length>0&&(f+=`
|
|
4272
|
+
`)):(m=[Uc(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,_,e.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",e.batching?"#define USE_BATCHING":"",e.batchingColor?"#define USE_BATCHING_COLOR":"",e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.instancingMorph?"#define USE_INSTANCING_MORPH":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+h:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.displacementMap?"#define USE_DISPLACEMENTMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.mapUv?"#define MAP_UV "+e.mapUv:"",e.alphaMapUv?"#define ALPHAMAP_UV "+e.alphaMapUv:"",e.lightMapUv?"#define LIGHTMAP_UV "+e.lightMapUv:"",e.aoMapUv?"#define AOMAP_UV "+e.aoMapUv:"",e.emissiveMapUv?"#define EMISSIVEMAP_UV "+e.emissiveMapUv:"",e.bumpMapUv?"#define BUMPMAP_UV "+e.bumpMapUv:"",e.normalMapUv?"#define NORMALMAP_UV "+e.normalMapUv:"",e.displacementMapUv?"#define DISPLACEMENTMAP_UV "+e.displacementMapUv:"",e.metalnessMapUv?"#define METALNESSMAP_UV "+e.metalnessMapUv:"",e.roughnessMapUv?"#define ROUGHNESSMAP_UV "+e.roughnessMapUv:"",e.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+e.anisotropyMapUv:"",e.clearcoatMapUv?"#define CLEARCOATMAP_UV "+e.clearcoatMapUv:"",e.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+e.clearcoatNormalMapUv:"",e.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+e.clearcoatRoughnessMapUv:"",e.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+e.iridescenceMapUv:"",e.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+e.iridescenceThicknessMapUv:"",e.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+e.sheenColorMapUv:"",e.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+e.sheenRoughnessMapUv:"",e.specularMapUv?"#define SPECULARMAP_UV "+e.specularMapUv:"",e.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+e.specularColorMapUv:"",e.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+e.specularIntensityMapUv:"",e.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+e.transmissionMapUv:"",e.thicknessMapUv?"#define THICKNESSMAP_UV "+e.thicknessMapUv:"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexNormals?"#define HAS_NORMAL":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
|
|
4273
|
+
`].filter(_r).join(`
|
|
4274
|
+
`),f=[Uc(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,_,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+c:"",e.envMap?"#define "+h:"",e.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":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.dispersion?"#define USE_DISPERSION":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor?"#define USE_COLOR":"",e.vertexAlphas||e.batchingColor?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==pn?"#define TONE_MAPPING":"",e.toneMapping!==pn?Ht.tonemapping_pars_fragment:"",e.toneMapping!==pn?Vg("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",Ht.colorspace_pars_fragment,Hg("linearToOutputTexel",e.outputColorSpace),Wg(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`
|
|
4275
|
+
`].filter(_r).join(`
|
|
4276
|
+
`)),a=Ho(a),a=Ic(a,e),a=Dc(a,e),o=Ho(o),o=Ic(o,e),o=Dc(o,e),a=Lc(a),o=Lc(o),e.isRawShaderMaterial!==!0&&(A=`#version 300 es
|
|
4277
|
+
`,m=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
4262
4278
|
`)+`
|
|
4263
|
-
`+m,
|
|
4279
|
+
`+m,f=["#define varying in",e.glslVersion===Wl?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===Wl?"":"#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(`
|
|
4264
4280
|
`)+`
|
|
4265
|
-
`+
|
|
4281
|
+
`+f);const w=A+m+a,M=A+f+o,y=Rc(r,r.VERTEX_SHADER,w),b=Rc(r,r.FRAGMENT_SHADER,M);r.attachShader(S,y),r.attachShader(S,b),e.index0AttributeName!==void 0?r.bindAttribLocation(S,0,e.index0AttributeName):e.hasPositionAttribute===!0&&r.bindAttribLocation(S,0,"position"),r.linkProgram(S);function R(C){if(i.debug.checkShaderErrors){const U=r.getProgramInfoLog(S)||"",Y=r.getShaderInfoLog(y)||"",Z=r.getShaderInfoLog(b)||"",O=U.trim(),W=Y.trim(),V=Z.trim();let Q=!0,et=!0;if(r.getProgramParameter(S,r.LINK_STATUS)===!1)if(Q=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,S,y,b);else{const tt=Pc(r,y,"vertex"),rt=Pc(r,b,"fragment");Xt("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(S,r.VALIDATE_STATUS)+`
|
|
4266
4282
|
|
|
4267
4283
|
Material Name: `+C.name+`
|
|
4268
4284
|
Material Type: `+C.type+`
|
|
4269
4285
|
|
|
4270
4286
|
Program Info Log: `+O+`
|
|
4271
|
-
`+
|
|
4272
|
-
`+re)}else O!==""?Ne("WebGLProgram: Program Info Log:",O):(W===""||H==="")&&(te=!1);te&&(C.diagnostics={runnable:Q,programLog:O,vertexShader:{log:W,prefix:m},fragmentShader:{log:H,prefix:d}})}r.deleteShader(T),r.deleteShader(y),x=new as(r,S),b=Zm(r,S)}let x;this.getUniforms=function(){return x===void 0&&R(this),x};let b;this.getAttributes=function(){return b===void 0&&R(this),b};let I=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=r.getProgramParameter(S,zm)),I},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(S),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Gm++,this.cacheKey=e,this.usedTimes=1,this.program=S,this.vertexShader=T,this.fragmentShader=y,this}let hg=0;class fg{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){const r=this._getShaderCacheForMaterial(e);return r.has(t)===!1&&(r.add(t),t.usedTimes++),r.has(n)===!1&&(r.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 dg(e),t.set(e,n)),n}}class dg{constructor(e){this.id=hg++,this.code=e,this.usedTimes=0}}function pg(i){return i===ai||i===ls||i===cs}function mg(i,e,t,n,r,s){const a=new qo,o=new fg,l=new Set,c=[],h=new Map,f=n.logarithmicDepthBuffer;let u=n.precision;const g={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 _(x){return l.add(x),x===0?"uv":`uv${x}`}function S(x,b,I,C,N,Y){const K=C.fog,O=N.geometry,W=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?C.environment:null,H=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,Q=e.get(x.envMap||W,H),te=Q&&Q.mapping===bs?Q.image.height:null,ee=g[x.type];x.precision!==null&&(u=n.getMaxPrecision(x.precision),u!==x.precision&&Ne("WebGLProgram.getParameters:",x.precision,"not supported, using",u,"instead."));const re=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,ge=re!==void 0?re.length:0;let He=0;O.morphAttributes.position!==void 0&&(He=1),O.morphAttributes.normal!==void 0&&(He=2),O.morphAttributes.color!==void 0&&(He=3);let rt,We,Z,se;if(ee){const Me=on[ee];rt=Me.vertexShader,We=Me.fragmentShader}else{rt=x.vertexShader,We=x.fragmentShader;const Me=o.getVertexShaderStage(x),ht=o.getFragmentShaderStage(x);o.update(x,Me,ht),Z=Me.id,se=ht.id}const ne=i.getRenderTarget(),G=i.state.buffers.depth.getReversed(),Ce=N.isInstancedMesh===!0,Pe=N.isBatchedMesh===!0,we=!!x.map,ve=!!x.matcap,Ue=!!Q,De=!!x.aoMap,Ie=!!x.lightMap,Ze=!!x.bumpMap&&x.wireframe===!1,$e=!!x.normalMap,ct=!!x.displacementMap,ot=!!x.emissiveMap,ut=!!x.metalnessMap,_t=!!x.roughnessMap,D=x.anisotropy>0,Nt=x.clearcoat>0,Je=x.dispersion>0,E=x.iridescence>0,p=x.sheen>0,U=x.transmission>0,V=D&&!!x.anisotropyMap,X=Nt&&!!x.clearcoatMap,ie=Nt&&!!x.clearcoatNormalMap,oe=Nt&&!!x.clearcoatRoughnessMap,q=E&&!!x.iridescenceMap,J=E&&!!x.iridescenceThicknessMap,le=p&&!!x.sheenColorMap,be=p&&!!x.sheenRoughnessMap,he=!!x.specularMap,ce=!!x.specularColorMap,Re=!!x.specularIntensityMap,Le=U&&!!x.transmissionMap,Be=U&&!!x.thicknessMap,P=!!x.gradientMap,ae=!!x.alphaMap,$=x.alphaTest>0,ue=!!x.alphaHash,me=!!x.extensions;let j=hn;x.toneMapped&&(ne===null||ne.isXRRenderTarget===!0)&&(j=i.toneMapping);const ye={shaderID:ee,shaderType:x.type,shaderName:x.name,vertexShader:rt,fragmentShader:We,defines:x.defines,customVertexShaderID:Z,customFragmentShaderID:se,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:u,batching:Pe,batchingColor:Pe&&N._colorsTexture!==null,instancing:Ce,instancingColor:Ce&&N.instanceColor!==null,instancingMorph:Ce&&N.morphTexture!==null,outputColorSpace:ne===null?i.outputColorSpace:ne.isXRRenderTarget===!0?ne.texture.colorSpace:qe.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:we,matcap:ve,envMap:Ue,envMapMode:Ue&&Q.mapping,envMapCubeUVHeight:te,aoMap:De,lightMap:Ie,bumpMap:Ze,normalMap:$e,displacementMap:ct,emissiveMap:ot,normalMapObjectSpace:$e&&x.normalMapType===Qu,normalMapTangentSpace:$e&&x.normalMapType===xl,packedNormalMap:$e&&x.normalMapType===xl&&pg(x.normalMap.format),metalnessMap:ut,roughnessMap:_t,anisotropy:D,anisotropyMap:V,clearcoat:Nt,clearcoatMap:X,clearcoatNormalMap:ie,clearcoatRoughnessMap:oe,dispersion:Je,iridescence:E,iridescenceMap:q,iridescenceThicknessMap:J,sheen:p,sheenColorMap:le,sheenRoughnessMap:be,specularMap:he,specularColorMap:ce,specularIntensityMap:Re,transmission:U,transmissionMap:Le,thicknessMap:Be,gradientMap:P,opaque:x.transparent===!1&&x.blending===Li&&x.alphaToCoverage===!1,alphaMap:ae,alphaTest:$,alphaHash:ue,combine:x.combine,mapUv:we&&_(x.map.channel),aoMapUv:De&&_(x.aoMap.channel),lightMapUv:Ie&&_(x.lightMap.channel),bumpMapUv:Ze&&_(x.bumpMap.channel),normalMapUv:$e&&_(x.normalMap.channel),displacementMapUv:ct&&_(x.displacementMap.channel),emissiveMapUv:ot&&_(x.emissiveMap.channel),metalnessMapUv:ut&&_(x.metalnessMap.channel),roughnessMapUv:_t&&_(x.roughnessMap.channel),anisotropyMapUv:V&&_(x.anisotropyMap.channel),clearcoatMapUv:X&&_(x.clearcoatMap.channel),clearcoatNormalMapUv:ie&&_(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:oe&&_(x.clearcoatRoughnessMap.channel),iridescenceMapUv:q&&_(x.iridescenceMap.channel),iridescenceThicknessMapUv:J&&_(x.iridescenceThicknessMap.channel),sheenColorMapUv:le&&_(x.sheenColorMap.channel),sheenRoughnessMapUv:be&&_(x.sheenRoughnessMap.channel),specularMapUv:he&&_(x.specularMap.channel),specularColorMapUv:ce&&_(x.specularColorMap.channel),specularIntensityMapUv:Re&&_(x.specularIntensityMap.channel),transmissionMapUv:Le&&_(x.transmissionMap.channel),thicknessMapUv:Be&&_(x.thicknessMap.channel),alphaMapUv:ae&&_(x.alphaMap.channel),vertexTangents:!!O.attributes.tangent&&($e||D),vertexNormals:!!O.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,pointsUvs:N.isPoints===!0&&!!O.attributes.uv&&(we||ae),fog:!!K,useFog:x.fog===!0,fogExp2:!!K&&K.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||O.attributes.normal===void 0&&$e===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:G,skinning:N.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:He,numDirLights:b.directional.length,numPointLights:b.point.length,numSpotLights:b.spot.length,numSpotLightMaps:b.spotLightMap.length,numRectAreaLights:b.rectArea.length,numHemiLights:b.hemi.length,numDirLightShadows:b.directionalShadowMap.length,numPointLightShadows:b.pointShadowMap.length,numSpotLightShadows:b.spotShadowMap.length,numSpotLightShadowsWithMaps:b.numSpotLightShadowsWithMaps,numLightProbes:b.numLightProbes,numLightProbeGrids:Y.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:x.dithering,shadowMapEnabled:i.shadowMap.enabled&&I.length>0,shadowMapType:i.shadowMap.type,toneMapping:j,decodeVideoTexture:we&&x.map.isVideoTexture===!0&&qe.getTransfer(x.map.colorSpace)===Qe,decodeVideoTextureEmissive:ot&&x.emissiveMap.isVideoTexture===!0&&qe.getTransfer(x.emissiveMap.colorSpace)===Qe,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===En,flipSided:x.side===Lt,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:me&&x.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(me&&x.extensions.multiDraw===!0||Pe)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return ye.vertexUv1s=l.has(1),ye.vertexUv2s=l.has(2),ye.vertexUv3s=l.has(3),l.clear(),ye}function m(x){const b=[];if(x.shaderID?b.push(x.shaderID):(b.push(x.customVertexShaderID),b.push(x.customFragmentShaderID)),x.defines!==void 0)for(const I in x.defines)b.push(I),b.push(x.defines[I]);return x.isRawShaderMaterial===!1&&(d(b,x),A(b,x),b.push(i.outputColorSpace)),b.push(x.customProgramCacheKey),b.join()}function d(x,b){x.push(b.precision),x.push(b.outputColorSpace),x.push(b.envMapMode),x.push(b.envMapCubeUVHeight),x.push(b.mapUv),x.push(b.alphaMapUv),x.push(b.lightMapUv),x.push(b.aoMapUv),x.push(b.bumpMapUv),x.push(b.normalMapUv),x.push(b.displacementMapUv),x.push(b.emissiveMapUv),x.push(b.metalnessMapUv),x.push(b.roughnessMapUv),x.push(b.anisotropyMapUv),x.push(b.clearcoatMapUv),x.push(b.clearcoatNormalMapUv),x.push(b.clearcoatRoughnessMapUv),x.push(b.iridescenceMapUv),x.push(b.iridescenceThicknessMapUv),x.push(b.sheenColorMapUv),x.push(b.sheenRoughnessMapUv),x.push(b.specularMapUv),x.push(b.specularColorMapUv),x.push(b.specularIntensityMapUv),x.push(b.transmissionMapUv),x.push(b.thicknessMapUv),x.push(b.combine),x.push(b.fogExp2),x.push(b.sizeAttenuation),x.push(b.morphTargetsCount),x.push(b.morphAttributeCount),x.push(b.numDirLights),x.push(b.numPointLights),x.push(b.numSpotLights),x.push(b.numSpotLightMaps),x.push(b.numHemiLights),x.push(b.numRectAreaLights),x.push(b.numDirLightShadows),x.push(b.numPointLightShadows),x.push(b.numSpotLightShadows),x.push(b.numSpotLightShadowsWithMaps),x.push(b.numLightProbes),x.push(b.shadowMapType),x.push(b.toneMapping),x.push(b.numClippingPlanes),x.push(b.numClipIntersection),x.push(b.depthPacking)}function A(x,b){a.disableAll(),b.instancing&&a.enable(0),b.instancingColor&&a.enable(1),b.instancingMorph&&a.enable(2),b.matcap&&a.enable(3),b.envMap&&a.enable(4),b.normalMapObjectSpace&&a.enable(5),b.normalMapTangentSpace&&a.enable(6),b.clearcoat&&a.enable(7),b.iridescence&&a.enable(8),b.alphaTest&&a.enable(9),b.vertexColors&&a.enable(10),b.vertexAlphas&&a.enable(11),b.vertexUv1s&&a.enable(12),b.vertexUv2s&&a.enable(13),b.vertexUv3s&&a.enable(14),b.vertexTangents&&a.enable(15),b.anisotropy&&a.enable(16),b.alphaHash&&a.enable(17),b.batching&&a.enable(18),b.dispersion&&a.enable(19),b.batchingColor&&a.enable(20),b.gradientMap&&a.enable(21),b.packedNormalMap&&a.enable(22),b.vertexNormals&&a.enable(23),x.push(a.mask),a.disableAll(),b.fog&&a.enable(0),b.useFog&&a.enable(1),b.flatShading&&a.enable(2),b.logarithmicDepthBuffer&&a.enable(3),b.reversedDepthBuffer&&a.enable(4),b.skinning&&a.enable(5),b.morphTargets&&a.enable(6),b.morphNormals&&a.enable(7),b.morphColors&&a.enable(8),b.premultipliedAlpha&&a.enable(9),b.shadowMapEnabled&&a.enable(10),b.doubleSided&&a.enable(11),b.flipSided&&a.enable(12),b.useDepthPacking&&a.enable(13),b.dithering&&a.enable(14),b.transmission&&a.enable(15),b.sheen&&a.enable(16),b.opaque&&a.enable(17),b.pointsUvs&&a.enable(18),b.decodeVideoTexture&&a.enable(19),b.decodeVideoTextureEmissive&&a.enable(20),b.alphaToCoverage&&a.enable(21),b.numLightProbeGrids>0&&a.enable(22),b.hasPositionAttribute&&a.enable(23),x.push(a.mask)}function w(x){const b=g[x.type];let I;if(b){const C=on[b];I=Oh.clone(C.uniforms)}else I=x.uniforms;return I}function M(x,b){let I=h.get(b);return I!==void 0?++I.usedTimes:(I=new ug(i,b,x,r),c.push(I),h.set(b,I)),I}function T(x){if(--x.usedTimes===0){const b=c.indexOf(x);c[b]=c[c.length-1],c.pop(),h.delete(x.cacheKey),x.destroy()}}function y(x){o.remove(x)}function R(){o.dispose()}return{getParameters:S,getProgramCacheKey:m,getUniforms:w,acquireProgram:M,releaseProgram:T,releaseShaderCache:y,programs:c,dispose:R}}function gg(){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 r(a,o,l){i.get(a)[o]=l}function s(){i=new WeakMap}return{has:e,get:t,remove:n,update:r,dispose:s}}function _g(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 hc(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 fc(){const i=[];let e=0;const t=[],n=[],r=[];function s(){e=0,t.length=0,n.length=0,r.length=0}function a(u){let g=0;return u.isInstancedMesh&&(g+=2),u.isSkinnedMesh&&(g+=1),g}function o(u,g,_,S,m,d){let A=i[e];return A===void 0?(A={id:u.id,object:u,geometry:g,material:_,materialVariant:a(u),groupOrder:S,renderOrder:u.renderOrder,z:m,group:d},i[e]=A):(A.id=u.id,A.object=u,A.geometry=g,A.material=_,A.materialVariant=a(u),A.groupOrder=S,A.renderOrder=u.renderOrder,A.z=m,A.group=d),e++,A}function l(u,g,_,S,m,d){const A=o(u,g,_,S,m,d);_.transmission>0?n.push(A):_.transparent===!0?r.push(A):t.push(A)}function c(u,g,_,S,m,d){const A=o(u,g,_,S,m,d);_.transmission>0?n.unshift(A):_.transparent===!0?r.unshift(A):t.unshift(A)}function h(u,g,_){t.length>1&&t.sort(u||_g),n.length>1&&n.sort(g||hc),r.length>1&&r.sort(g||hc),_&&(t.reverse(),n.reverse(),r.reverse())}function f(){for(let u=e,g=i.length;u<g;u++){const _=i[u];if(_.id===null)break;_.id=null,_.object=null,_.geometry=null,_.material=null,_.group=null}}return{opaque:t,transmissive:n,transparent:r,init:s,push:l,unshift:c,finish:f,sort:h}}function xg(){let i=new WeakMap;function e(n,r){const s=i.get(n);let a;return s===void 0?(a=new fc,i.set(n,[a])):r>=s.length?(a=new fc,s.push(a)):a=s[r],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function vg(){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 Oe};break;case"SpotLight":t={position:new F,direction:new F,color:new Oe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new F,color:new Oe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new F,skyColor:new Oe,groundColor:new Oe};break;case"RectAreaLight":t={color:new Oe,position:new F,halfWidth:new F,halfHeight:new F};break}return i[e.id]=t,t}}}function Mg(){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 Ve};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ve};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ve,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let Sg=0;function Eg(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function yg(i){const e=new vg,t=Mg(),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 r=new F,s=new lt,a=new lt;function o(c){let h=0,f=0,u=0;for(let b=0;b<9;b++)n.probe[b].set(0,0,0);let g=0,_=0,S=0,m=0,d=0,A=0,w=0,M=0,T=0,y=0,R=0;c.sort(Eg);for(let b=0,I=c.length;b<I;b++){const C=c[b],N=C.color,Y=C.intensity,K=C.distance;let O=null;if(C.shadow&&C.shadow.map&&(C.shadow.map.texture.format===ai?O=C.shadow.map.texture:O=C.shadow.map.depthTexture||C.shadow.map.texture),C.isAmbientLight)h+=N.r*Y,f+=N.g*Y,u+=N.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 H=C.shadow,Q=t.get(C);Q.shadowIntensity=H.intensity,Q.shadowBias=H.bias,Q.shadowNormalBias=H.normalBias,Q.shadowRadius=H.radius,Q.shadowMapSize=H.mapSize,n.directionalShadow[g]=Q,n.directionalShadowMap[g]=O,n.directionalShadowMatrix[g]=C.shadow.matrix,A++}n.directional[g]=W,g++}else if(C.isSpotLight){const W=e.get(C);W.position.setFromMatrixPosition(C.matrixWorld),W.color.copy(N).multiplyScalar(Y),W.distance=K,W.coneCos=Math.cos(C.angle),W.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),W.decay=C.decay,n.spot[S]=W;const H=C.shadow;if(C.map&&(n.spotLightMap[T]=C.map,T++,H.updateMatrices(C),C.castShadow&&y++),n.spotLightMatrix[S]=H.matrix,C.castShadow){const Q=t.get(C);Q.shadowIntensity=H.intensity,Q.shadowBias=H.bias,Q.shadowNormalBias=H.normalBias,Q.shadowRadius=H.radius,Q.shadowMapSize=H.mapSize,n.spotShadow[S]=Q,n.spotShadowMap[S]=O,M++}S++}else if(C.isRectAreaLight){const W=e.get(C);W.color.copy(N).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 H=C.shadow,Q=t.get(C);Q.shadowIntensity=H.intensity,Q.shadowBias=H.bias,Q.shadowNormalBias=H.normalBias,Q.shadowRadius=H.radius,Q.shadowMapSize=H.mapSize,Q.shadowCameraNear=H.camera.near,Q.shadowCameraFar=H.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[d]=W,d++}}m>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=fe.LTC_FLOAT_1,n.rectAreaLTC2=fe.LTC_FLOAT_2):(n.rectAreaLTC1=fe.LTC_HALF_1,n.rectAreaLTC2=fe.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=f,n.ambient[2]=u;const x=n.hash;(x.directionalLength!==g||x.pointLength!==_||x.spotLength!==S||x.rectAreaLength!==m||x.hemiLength!==d||x.numDirectionalShadows!==A||x.numPointShadows!==w||x.numSpotShadows!==M||x.numSpotMaps!==T||x.numLightProbes!==R)&&(n.directional.length=g,n.spot.length=S,n.rectArea.length=m,n.point.length=_,n.hemi.length=d,n.directionalShadow.length=A,n.directionalShadowMap.length=A,n.pointShadow.length=w,n.pointShadowMap.length=w,n.spotShadow.length=M,n.spotShadowMap.length=M,n.directionalShadowMatrix.length=A,n.pointShadowMatrix.length=w,n.spotLightMatrix.length=M+T-y,n.spotLightMap.length=T,n.numSpotLightShadowsWithMaps=y,n.numLightProbes=R,x.directionalLength=g,x.pointLength=_,x.spotLength=S,x.rectAreaLength=m,x.hemiLength=d,x.numDirectionalShadows=A,x.numPointShadows=w,x.numSpotShadows=M,x.numSpotMaps=T,x.numLightProbes=R,n.version=Sg++)}function l(c,h){let f=0,u=0,g=0,_=0,S=0;const m=h.matrixWorldInverse;for(let d=0,A=c.length;d<A;d++){const w=c[d];if(w.isDirectionalLight){const M=n.directional[f];M.direction.setFromMatrixPosition(w.matrixWorld),r.setFromMatrixPosition(w.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(m),f++}else if(w.isSpotLight){const M=n.spot[g];M.position.setFromMatrixPosition(w.matrixWorld),M.position.applyMatrix4(m),M.direction.setFromMatrixPosition(w.matrixWorld),r.setFromMatrixPosition(w.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(m),g++}else if(w.isRectAreaLight){const M=n.rectArea[_];M.position.setFromMatrixPosition(w.matrixWorld),M.position.applyMatrix4(m),a.identity(),s.copy(w.matrixWorld),s.premultiply(m),a.extractRotation(s),M.halfWidth.set(w.width*.5,0,0),M.halfHeight.set(0,w.height*.5,0),M.halfWidth.applyMatrix4(a),M.halfHeight.applyMatrix4(a),_++}else if(w.isPointLight){const M=n.point[u];M.position.setFromMatrixPosition(w.matrixWorld),M.position.applyMatrix4(m),u++}else if(w.isHemisphereLight){const M=n.hemi[S];M.direction.setFromMatrixPosition(w.matrixWorld),M.direction.transformDirection(m),S++}}}return{setup:o,setupView:l,state:n}}function dc(i){const e=new yg(i),t=[],n=[],r=[];function s(u){f.camera=u,t.length=0,n.length=0,r.length=0}function a(u){t.push(u)}function o(u){n.push(u)}function l(u){r.push(u)}function c(){e.setup(t)}function h(u){e.setupView(t,u)}const f={lightsArray:t,shadowsArray:n,lightProbeGridArray:r,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:f,setupLights:c,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:l}}function bg(i){let e=new WeakMap;function t(r,s=0){const a=e.get(r);let o;return a===void 0?(o=new dc(i),e.set(r,[o])):s>=a.length?(o=new dc(i),a.push(o)):o=a[s],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const Tg=`void main() {
|
|
4287
|
+
`+tt+`
|
|
4288
|
+
`+rt)}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}})}r.deleteShader(y),r.deleteShader(b),x=new ws(r,S),T=Yg(r,S)}let x;this.getUniforms=function(){return x===void 0&&R(this),x};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=r.getProgramParameter(S,Og)),I},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(S),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=Bg++,this.cacheKey=t,this.usedTimes=1,this.program=S,this.vertexShader=y,this.fragmentShader=b,this}let c_=0;class h_{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t,e,n){const r=this._getShaderCacheForMaterial(t);return r.has(e)===!1&&(r.add(e),e.usedTimes++),r.has(n)===!1&&(r.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=c_++,this.code=t,this.usedTimes=0}}function d_(i){return i===ci||i===Cs||i===Ps}function f_(i,t,e,n,r,s){const a=new gl,o=new h_,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 _(x){return l.add(x),x===0?"uv":`uv${x}`}function S(x,T,I,C,U,Y){const Z=C.fog,O=U.geometry,W=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?C.environment:null,V=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,Q=t.get(x.envMap||W,V),et=Q&&Q.mapping===qs?Q.image.height:null,tt=p[x.type];x.precision!==null&&(u=n.getMaxPrecision(x.precision),u!==x.precision&&Ft("WebGLProgram.getParameters:",x.precision,"not supported, using",u,"instead."));const rt=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,gt=rt!==void 0?rt.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 re,Wt,$,st;if(tt){const Mt=hn[tt];re=Mt.vertexShader,Wt=Mt.fragmentShader}else{re=x.vertexShader,Wt=x.fragmentShader;const Mt=o.getVertexShaderStage(x),ue=o.getFragmentShaderStage(x);o.update(x,Mt,ue),$=Mt.id,st=ue.id}const nt=i.getRenderTarget(),G=i.state.buffers.depth.getReversed(),Ct=U.isInstancedMesh===!0,Pt=U.isBatchedMesh===!0,wt=!!x.map,vt=!!x.matcap,Nt=!!Q,Dt=!!x.aoMap,Lt=!!x.lightMap,$t=!!x.bumpMap&&x.wireframe===!1,Kt=!!x.normalMap,ce=!!x.displacementMap,oe=!!x.emissiveMap,he=!!x.metalnessMap,xe=!!x.roughnessMap,D=x.anisotropy>0,Be=x.clearcoat>0,Jt=x.dispersion>0,E=x.iridescence>0,g=x.sheen>0,N=x.transmission>0,H=D&&!!x.anisotropyMap,X=Be&&!!x.clearcoatMap,it=Be&&!!x.clearcoatNormalMap,ot=Be&&!!x.clearcoatRoughnessMap,q=E&&!!x.iridescenceMap,J=E&&!!x.iridescenceThicknessMap,lt=g&&!!x.sheenColorMap,bt=g&&!!x.sheenRoughnessMap,ut=!!x.specularMap,ct=!!x.specularColorMap,Rt=!!x.specularIntensityMap,Ut=N&&!!x.transmissionMap,Bt=N&&!!x.thicknessMap,P=!!x.gradientMap,at=!!x.alphaMap,K=x.alphaTest>0,ht=!!x.alphaHash,mt=!!x.extensions;let j=pn;x.toneMapped&&(nt===null||nt.isXRRenderTarget===!0)&&(j=i.toneMapping);const Et={shaderID:tt,shaderType:x.type,shaderName:x.name,vertexShader:re,fragmentShader:Wt,defines:x.defines,customVertexShaderID:$,customFragmentShaderID:st,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.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:!!x.alphaToCoverage,map:wt,matcap:vt,envMap:Nt,envMapMode:Nt&&Q.mapping,envMapCubeUVHeight:et,aoMap:Dt,lightMap:Lt,bumpMap:$t,normalMap:Kt,displacementMap:ce,emissiveMap:oe,normalMapObjectSpace:Kt&&x.normalMapType===J0,normalMapTangentSpace:Kt&&x.normalMapType===kl,packedNormalMap:Kt&&x.normalMapType===kl&&d_(x.normalMap.format),metalnessMap:he,roughnessMap:xe,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:x.transparent===!1&&x.blending===Gi&&x.alphaToCoverage===!1,alphaMap:at,alphaTest:K,alphaHash:ht,combine:x.combine,mapUv:wt&&_(x.map.channel),aoMapUv:Dt&&_(x.aoMap.channel),lightMapUv:Lt&&_(x.lightMap.channel),bumpMapUv:$t&&_(x.bumpMap.channel),normalMapUv:Kt&&_(x.normalMap.channel),displacementMapUv:ce&&_(x.displacementMap.channel),emissiveMapUv:oe&&_(x.emissiveMap.channel),metalnessMapUv:he&&_(x.metalnessMap.channel),roughnessMapUv:xe&&_(x.roughnessMap.channel),anisotropyMapUv:H&&_(x.anisotropyMap.channel),clearcoatMapUv:X&&_(x.clearcoatMap.channel),clearcoatNormalMapUv:it&&_(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ot&&_(x.clearcoatRoughnessMap.channel),iridescenceMapUv:q&&_(x.iridescenceMap.channel),iridescenceThicknessMapUv:J&&_(x.iridescenceThicknessMap.channel),sheenColorMapUv:lt&&_(x.sheenColorMap.channel),sheenRoughnessMapUv:bt&&_(x.sheenRoughnessMap.channel),specularMapUv:ut&&_(x.specularMap.channel),specularColorMapUv:ct&&_(x.specularColorMap.channel),specularIntensityMapUv:Rt&&_(x.specularIntensityMap.channel),transmissionMapUv:Ut&&_(x.transmissionMap.channel),thicknessMapUv:Bt&&_(x.thicknessMap.channel),alphaMapUv:at&&_(x.alphaMap.channel),vertexTangents:!!O.attributes.tangent&&(Kt||D),vertexNormals:!!O.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,pointsUvs:U.isPoints===!0&&!!O.attributes.uv&&(wt||at),fog:!!Z,useFog:x.fog===!0,fogExp2:!!Z&&Z.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||O.attributes.normal===void 0&&Kt===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:G,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:s.numPlanes,numClipIntersection:s.numIntersection,dithering:x.dithering,shadowMapEnabled:i.shadowMap.enabled&&I.length>0,shadowMapType:i.shadowMap.type,toneMapping:j,decodeVideoTexture:wt&&x.map.isVideoTexture===!0&&qt.getTransfer(x.map.colorSpace)===Qt,decodeVideoTextureEmissive:oe&&x.emissiveMap.isVideoTexture===!0&&qt.getTransfer(x.emissiveMap.colorSpace)===Qt,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===bn,flipSided:x.side===Fe,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:mt&&x.extensions.clipCullDistance===!0&&e.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(mt&&x.extensions.multiDraw===!0||Pt)&&e.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:e.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return Et.vertexUv1s=l.has(1),Et.vertexUv2s=l.has(2),Et.vertexUv3s=l.has(3),l.clear(),Et}function m(x){const T=[];if(x.shaderID?T.push(x.shaderID):(T.push(x.customVertexShaderID),T.push(x.customFragmentShaderID)),x.defines!==void 0)for(const I in x.defines)T.push(I),T.push(x.defines[I]);return x.isRawShaderMaterial===!1&&(f(T,x),A(T,x),T.push(i.outputColorSpace)),T.push(x.customProgramCacheKey),T.join()}function f(x,T){x.push(T.precision),x.push(T.outputColorSpace),x.push(T.envMapMode),x.push(T.envMapCubeUVHeight),x.push(T.mapUv),x.push(T.alphaMapUv),x.push(T.lightMapUv),x.push(T.aoMapUv),x.push(T.bumpMapUv),x.push(T.normalMapUv),x.push(T.displacementMapUv),x.push(T.emissiveMapUv),x.push(T.metalnessMapUv),x.push(T.roughnessMapUv),x.push(T.anisotropyMapUv),x.push(T.clearcoatMapUv),x.push(T.clearcoatNormalMapUv),x.push(T.clearcoatRoughnessMapUv),x.push(T.iridescenceMapUv),x.push(T.iridescenceThicknessMapUv),x.push(T.sheenColorMapUv),x.push(T.sheenRoughnessMapUv),x.push(T.specularMapUv),x.push(T.specularColorMapUv),x.push(T.specularIntensityMapUv),x.push(T.transmissionMapUv),x.push(T.thicknessMapUv),x.push(T.combine),x.push(T.fogExp2),x.push(T.sizeAttenuation),x.push(T.morphTargetsCount),x.push(T.morphAttributeCount),x.push(T.numDirLights),x.push(T.numPointLights),x.push(T.numSpotLights),x.push(T.numSpotLightMaps),x.push(T.numHemiLights),x.push(T.numRectAreaLights),x.push(T.numDirLightShadows),x.push(T.numPointLightShadows),x.push(T.numSpotLightShadows),x.push(T.numSpotLightShadowsWithMaps),x.push(T.numLightProbes),x.push(T.shadowMapType),x.push(T.toneMapping),x.push(T.numClippingPlanes),x.push(T.numClipIntersection),x.push(T.depthPacking)}function A(x,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),x.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),x.push(a.mask)}function w(x){const T=p[x.type];let I;if(T){const C=hn[T];I=Nd.clone(C.uniforms)}else I=x.uniforms;return I}function M(x,T){let I=h.get(T);return I!==void 0?++I.usedTimes:(I=new l_(i,T,x,r),c.push(I),h.set(T,I)),I}function y(x){if(--x.usedTimes===0){const T=c.indexOf(x);c[T]=c[c.length-1],c.pop(),h.delete(x.cacheKey),x.destroy()}}function b(x){o.remove(x)}function R(){o.dispose()}return{getParameters:S,getProgramCacheKey:m,getUniforms:w,acquireProgram:M,releaseProgram:y,releaseShaderCache:b,programs:c,dispose:R}}function p_(){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 r(a,o,l){i.get(a)[o]=l}function s(){i=new WeakMap}return{has:t,get:e,remove:n,update:r,dispose:s}}function m_(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 Nc(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 Fc(){const i=[];let t=0;const e=[],n=[],r=[];function s(){t=0,e.length=0,n.length=0,r.length=0}function a(u){let p=0;return u.isInstancedMesh&&(p+=2),u.isSkinnedMesh&&(p+=1),p}function o(u,p,_,S,m,f){let A=i[t];return A===void 0?(A={id:u.id,object:u,geometry:p,material:_,materialVariant:a(u),groupOrder:S,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=S,A.renderOrder=u.renderOrder,A.z=m,A.group=f),t++,A}function l(u,p,_,S,m,f){const A=o(u,p,_,S,m,f);_.transmission>0?n.push(A):_.transparent===!0?r.push(A):e.push(A)}function c(u,p,_,S,m,f){const A=o(u,p,_,S,m,f);_.transmission>0?n.unshift(A):_.transparent===!0?r.unshift(A):e.unshift(A)}function h(u,p,_){e.length>1&&e.sort(u||m_),n.length>1&&n.sort(p||Nc),r.length>1&&r.sort(p||Nc),_&&(e.reverse(),n.reverse(),r.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:r,init:s,push:l,unshift:c,finish:d,sort:h}}function g_(){let i=new WeakMap;function t(n,r){const s=i.get(n);let a;return s===void 0?(a=new Fc,i.set(n,[a])):r>=s.length?(a=new Fc,s.push(a)):a=s[r],a}function e(){i=new WeakMap}return{get:t,dispose:e}}function __(){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 x_(){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 Gt};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Gt};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Gt,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}let v_=0;function M_(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function S_(i){const t=new __,e=x_(),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 r=new F,s=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,S=0,m=0,f=0,A=0,w=0,M=0,y=0,b=0,R=0;c.sort(M_);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===ci?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[S]=W;const V=C.shadow;if(C.map&&(n.spotLightMap[y]=C.map,y++,V.updateMatrices(C),C.castShadow&&b++),n.spotLightMatrix[S]=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[S]=Q,n.spotShadowMap[S]=O,M++}S++}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 x=n.hash;(x.directionalLength!==p||x.pointLength!==_||x.spotLength!==S||x.rectAreaLength!==m||x.hemiLength!==f||x.numDirectionalShadows!==A||x.numPointShadows!==w||x.numSpotShadows!==M||x.numSpotMaps!==y||x.numLightProbes!==R)&&(n.directional.length=p,n.spot.length=S,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=M,n.spotShadowMap.length=M,n.directionalShadowMatrix.length=A,n.pointShadowMatrix.length=w,n.spotLightMatrix.length=M+y-b,n.spotLightMap.length=y,n.numSpotLightShadowsWithMaps=b,n.numLightProbes=R,x.directionalLength=p,x.pointLength=_,x.spotLength=S,x.rectAreaLength=m,x.hemiLength=f,x.numDirectionalShadows=A,x.numPointShadows=w,x.numSpotShadows=M,x.numSpotMaps=y,x.numLightProbes=R,n.version=v_++)}function l(c,h){let d=0,u=0,p=0,_=0,S=0;const m=h.matrixWorldInverse;for(let f=0,A=c.length;f<A;f++){const w=c[f];if(w.isDirectionalLight){const M=n.directional[d];M.direction.setFromMatrixPosition(w.matrixWorld),r.setFromMatrixPosition(w.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(m),d++}else if(w.isSpotLight){const M=n.spot[p];M.position.setFromMatrixPosition(w.matrixWorld),M.position.applyMatrix4(m),M.direction.setFromMatrixPosition(w.matrixWorld),r.setFromMatrixPosition(w.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(m),p++}else if(w.isRectAreaLight){const M=n.rectArea[_];M.position.setFromMatrixPosition(w.matrixWorld),M.position.applyMatrix4(m),a.identity(),s.copy(w.matrixWorld),s.premultiply(m),a.extractRotation(s),M.halfWidth.set(w.width*.5,0,0),M.halfHeight.set(0,w.height*.5,0),M.halfWidth.applyMatrix4(a),M.halfHeight.applyMatrix4(a),_++}else if(w.isPointLight){const M=n.point[u];M.position.setFromMatrixPosition(w.matrixWorld),M.position.applyMatrix4(m),u++}else if(w.isHemisphereLight){const M=n.hemi[S];M.direction.setFromMatrixPosition(w.matrixWorld),M.direction.transformDirection(m),S++}}}return{setup:o,setupView:l,state:n}}function Oc(i){const t=new S_(i),e=[],n=[],r=[];function s(u){d.camera=u,e.length=0,n.length=0,r.length=0}function a(u){e.push(u)}function o(u){n.push(u)}function l(u){r.push(u)}function c(){t.setup(e)}function h(u){t.setupView(e,u)}const d={lightsArray:e,shadowsArray:n,lightProbeGridArray:r,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:d,setupLights:c,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:l}}function y_(i){let t=new WeakMap;function e(r,s=0){const a=t.get(r);let o;return a===void 0?(o=new Oc(i),t.set(r,[o])):s>=a.length?(o=new Oc(i),a.push(o)):o=a[s],o}function n(){t=new WeakMap}return{get:e,dispose:n}}const E_=`void main() {
|
|
4273
4289
|
gl_Position = vec4( position, 1.0 );
|
|
4274
|
-
}`,
|
|
4290
|
+
}`,b_=`uniform sampler2D shadow_pass;
|
|
4275
4291
|
uniform vec2 resolution;
|
|
4276
4292
|
uniform float radius;
|
|
4277
4293
|
void main() {
|
|
@@ -4296,12 +4312,12 @@ void main() {
|
|
|
4296
4312
|
squared_mean = squared_mean / samples;
|
|
4297
4313
|
float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
|
|
4298
4314
|
gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
|
|
4299
|
-
}`,wg=[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)],Rg=[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)],pc=new lt,tr=new F,fa=new F;function Cg(i,e,t){let n=new a0;const r=new Ve,s=new Ve,a=new dt,o=new Vh,l=new kh,c={},h=t.maxTextureSize,f={[Xn]:Lt,[Lt]:Xn,[En]:En},u=new pn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ve},radius:{value:4}},vertexShader:Tg,fragmentShader:Ag}),g=u.clone();g.defines.HORIZONTAL_PASS=1;const _=new Ft;_.setAttribute("position",new Gt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const S=new Kt(_,u),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ts;let d=this.type;this.render=function(y,R,x){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||y.length===0)return;this.type===Cu&&(Ne("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=ts);const b=i.getRenderTarget(),I=i.getActiveCubeFace(),C=i.getActiveMipmapLevel(),N=i.state;N.setBlending(Tn),N.buffers.depth.getReversed()===!0?N.buffers.color.setClear(0,0,0,0):N.buffers.color.setClear(1,1,1,1),N.buffers.depth.setTest(!0),N.setScissorTest(!1);const Y=d!==this.type;Y&&R.traverse(function(K){K.material&&(Array.isArray(K.material)?K.material.forEach(O=>O.needsUpdate=!0):K.material.needsUpdate=!0)});for(let K=0,O=y.length;K<O;K++){const W=y[K],H=W.shadow;if(H===void 0){Ne("WebGLShadowMap:",W,"has no shadow.");continue}if(H.autoUpdate===!1&&H.needsUpdate===!1)continue;r.copy(H.mapSize);const Q=H.getFrameExtents();r.multiply(Q),s.copy(H.mapSize),(r.x>h||r.y>h)&&(r.x>h&&(s.x=Math.floor(h/Q.x),r.x=s.x*Q.x,H.mapSize.x=s.x),r.y>h&&(s.y=Math.floor(h/Q.y),r.y=s.y*Q.y,H.mapSize.y=s.y));const te=i.state.buffers.depth.getReversed();if(H.camera._reversedDepth=te,H.map===null||Y===!0){if(H.map!==null&&(H.map.depthTexture!==null&&(H.map.depthTexture.dispose(),H.map.depthTexture=null),H.map.dispose()),this.type===ir){if(W.isPointLight){Ne("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}H.map=new fn(r.x,r.y,{format:ai,type:wn,minFilter:Rt,magFilter:Rt,generateMipmaps:!1}),H.map.texture.name=W.name+".shadowMap",H.map.depthTexture=new Gi(r.x,r.y,cn),H.map.depthTexture.name=W.name+".shadowMapDepth",H.map.depthTexture.format=Rn,H.map.depthTexture.compareFunction=null,H.map.depthTexture.minFilter=yt,H.map.depthTexture.magFilter=yt}else W.isPointLight?(H.map=new g0(r.x),H.map.depthTexture=new Nh(r.x,dn)):(H.map=new fn(r.x,r.y),H.map.depthTexture=new Gi(r.x,r.y,dn)),H.map.depthTexture.name=W.name+".shadowMap",H.map.depthTexture.format=Rn,this.type===ts?(H.map.depthTexture.compareFunction=te?Wo:Ho,H.map.depthTexture.minFilter=Rt,H.map.depthTexture.magFilter=Rt):(H.map.depthTexture.compareFunction=null,H.map.depthTexture.minFilter=yt,H.map.depthTexture.magFilter=yt);H.camera.updateProjectionMatrix()}const ee=H.map.isWebGLCubeRenderTarget?6:1;for(let re=0;re<ee;re++){if(H.map.isWebGLCubeRenderTarget)i.setRenderTarget(H.map,re),i.clear();else{re===0&&(i.setRenderTarget(H.map),i.clear());const ge=H.getViewport(re);a.set(s.x*ge.x,s.y*ge.y,s.x*ge.z,s.y*ge.w),N.viewport(a)}if(W.isPointLight){const ge=H.camera,He=H.matrix,rt=W.distance||ge.far;rt!==ge.far&&(ge.far=rt,ge.updateProjectionMatrix()),tr.setFromMatrixPosition(W.matrixWorld),ge.position.copy(tr),fa.copy(ge.position),fa.add(wg[re]),ge.up.copy(Rg[re]),ge.lookAt(fa),ge.updateMatrixWorld(),He.makeTranslation(-tr.x,-tr.y,-tr.z),pc.multiplyMatrices(ge.projectionMatrix,ge.matrixWorldInverse),H._frustum.setFromProjectionMatrix(pc,ge.coordinateSystem,ge.reversedDepth)}else H.updateMatrices(W);n=H.getFrustum(),M(R,x,H.camera,W,this.type)}H.isPointLightShadow!==!0&&this.type===ir&&A(H,x),H.needsUpdate=!1}d=this.type,m.needsUpdate=!1,i.setRenderTarget(b,I,C)};function A(y,R){const x=e.update(S);u.defines.VSM_SAMPLES!==y.blurSamples&&(u.defines.VSM_SAMPLES=y.blurSamples,g.defines.VSM_SAMPLES=y.blurSamples,u.needsUpdate=!0,g.needsUpdate=!0),y.mapPass===null&&(y.mapPass=new fn(r.x,r.y,{format:ai,type:wn})),u.uniforms.shadow_pass.value=y.map.depthTexture,u.uniforms.resolution.value=y.mapSize,u.uniforms.radius.value=y.radius,i.setRenderTarget(y.mapPass),i.clear(),i.renderBufferDirect(R,null,x,u,S,null),g.uniforms.shadow_pass.value=y.mapPass.texture,g.uniforms.resolution.value=y.mapSize,g.uniforms.radius.value=y.radius,i.setRenderTarget(y.map),i.clear(),i.renderBufferDirect(R,null,x,g,S,null)}function w(y,R,x,b){let I=null;const C=x.isPointLight===!0?y.customDistanceMaterial:y.customDepthMaterial;if(C!==void 0)I=C;else if(I=x.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 N=I.uuid,Y=R.uuid;let K=c[N];K===void 0&&(K={},c[N]=K);let O=K[Y];O===void 0&&(O=I.clone(),K[Y]=O,R.addEventListener("dispose",T)),I=O}if(I.visible=R.visible,I.wireframe=R.wireframe,b===ir?I.side=R.shadowSide!==null?R.shadowSide:R.side:I.side=R.shadowSide!==null?R.shadowSide:f[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,x.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const N=i.properties.get(I);N.light=x}return I}function M(y,R,x,b,I){if(y.visible===!1)return;if(y.layers.test(R.layers)&&(y.isMesh||y.isLine||y.isPoints)&&(y.castShadow||y.receiveShadow&&I===ir)&&(!y.frustumCulled||n.intersectsObject(y))){y.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,y.matrixWorld);const Y=e.update(y),K=y.material;if(Array.isArray(K)){const O=Y.groups;for(let W=0,H=O.length;W<H;W++){const Q=O[W],te=K[Q.materialIndex];if(te&&te.visible){const ee=w(y,te,b,I);y.onBeforeShadow(i,y,R,x,Y,ee,Q),i.renderBufferDirect(x,null,Y,ee,y,Q),y.onAfterShadow(i,y,R,x,Y,ee,Q)}}}else if(K.visible){const O=w(y,K,b,I);y.onBeforeShadow(i,y,R,x,Y,O,null),i.renderBufferDirect(x,null,Y,O,y,null),y.onAfterShadow(i,y,R,x,Y,O,null)}}const N=y.children;for(let Y=0,K=N.length;Y<K;Y++)M(N[Y],R,x,b,I)}function T(y){y.target.removeEventListener("dispose",T);for(const x in c){const b=c[x],I=y.target.uuid;I in b&&(b[I].dispose(),delete b[I])}}}function Pg(i,e){function t(){let P=!1;const ae=new dt;let $=null;const ue=new dt(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,ye,Me,ht){ht===!0&&(me*=Me,j*=Me,ye*=Me),ae.set(me,j,ye,Me),ue.equals(ae)===!1&&(i.clearColor(me,j,ye,Me),ue.copy(ae))},reset:function(){P=!1,$=null,ue.set(-1,0,0,0)}}}function n(){let P=!1,ae=!1,$=null,ue=null,me=null;return{setReversed:function(j){if(ae!==j){const ye=e.get("EXT_clip_control");j?ye.clipControlEXT(ye.LOWER_LEFT_EXT,ye.ZERO_TO_ONE_EXT):ye.clipControlEXT(ye.LOWER_LEFT_EXT,ye.NEGATIVE_ONE_TO_ONE_EXT),ae=j;const Me=me;me=null,this.setClear(Me)}},getReversed:function(){return ae},setTest:function(j){j?ne(i.DEPTH_TEST):G(i.DEPTH_TEST)},setMask:function(j){$!==j&&!P&&(i.depthMask(j),$=j)},setFunc:function(j){if(ae&&(j=lh[j]),ue!==j){switch(j){case Aa:i.depthFunc(i.NEVER);break;case wa:i.depthFunc(i.ALWAYS);break;case Ra:i.depthFunc(i.LESS);break;case Bi:i.depthFunc(i.LEQUAL);break;case Ca:i.depthFunc(i.EQUAL);break;case Pa:i.depthFunc(i.GEQUAL);break;case Da:i.depthFunc(i.GREATER);break;case Ia:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}ue=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,ue=null,me=null,ae=!1}}}function r(){let P=!1,ae=null,$=null,ue=null,me=null,j=null,ye=null,Me=null,ht=null;return{setTest:function(st){P||(st?ne(i.STENCIL_TEST):G(i.STENCIL_TEST))},setMask:function(st){ae!==st&&!P&&(i.stencilMask(st),ae=st)},setFunc:function(st,tn,nn){($!==st||ue!==tn||me!==nn)&&(i.stencilFunc(st,tn,nn),$=st,ue=tn,me=nn)},setOp:function(st,tn,nn){(j!==st||ye!==tn||Me!==nn)&&(i.stencilOp(st,tn,nn),j=st,ye=tn,Me=nn)},setLocked:function(st){P=st},setClear:function(st){ht!==st&&(i.clearStencil(st),ht=st)},reset:function(){P=!1,ae=null,$=null,ue=null,me=null,j=null,ye=null,Me=null,ht=null}}}const s=new t,a=new n,o=new r,l=new WeakMap,c=new WeakMap;let h={},f={},u={},g=new WeakMap,_=[],S=null,m=!1,d=null,A=null,w=null,M=null,T=null,y=null,R=null,x=new Oe(0,0,0),b=0,I=!1,C=null,N=null,Y=null,K=null,O=null;const W=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let H=!1,Q=0;const te=i.getParameter(i.VERSION);te.indexOf("WebGL")!==-1?(Q=parseFloat(/^WebGL (\d)/.exec(te)[1]),H=Q>=1):te.indexOf("OpenGL ES")!==-1&&(Q=parseFloat(/^OpenGL ES (\d)/.exec(te)[1]),H=Q>=2);let ee=null,re={};const ge=i.getParameter(i.SCISSOR_BOX),He=i.getParameter(i.VIEWPORT),rt=new dt().fromArray(ge),We=new dt().fromArray(He);function Z(P,ae,$,ue){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 ye=0;ye<$;ye++)P===i.TEXTURE_3D||P===i.TEXTURE_2D_ARRAY?i.texImage3D(ae,0,i.RGBA,1,1,ue,0,i.RGBA,i.UNSIGNED_BYTE,me):i.texImage2D(ae+ye,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,me);return j}const se={};se[i.TEXTURE_2D]=Z(i.TEXTURE_2D,i.TEXTURE_2D,1),se[i.TEXTURE_CUBE_MAP]=Z(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),se[i.TEXTURE_2D_ARRAY]=Z(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),se[i.TEXTURE_3D]=Z(i.TEXTURE_3D,i.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),ne(i.DEPTH_TEST),a.setFunc(Bi),Ze(!1),$e(ml),ne(i.CULL_FACE),De(Tn);function ne(P){h[P]!==!0&&(i.enable(P),h[P]=!0)}function G(P){h[P]!==!1&&(i.disable(P),h[P]=!1)}function Ce(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 Pe(P,ae){let $=_,ue=!1;if(P){$=g.get(ae),$===void 0&&($=[],g.set(ae,$));const me=P.textures;if($.length!==me.length||$[0]!==i.COLOR_ATTACHMENT0){for(let j=0,ye=me.length;j<ye;j++)$[j]=i.COLOR_ATTACHMENT0+j;$.length=me.length,ue=!0}}else $[0]!==i.BACK&&($[0]=i.BACK,ue=!0);ue&&i.drawBuffers($)}function we(P){return S!==P?(i.useProgram(P),S=P,!0):!1}const ve={[Qn]:i.FUNC_ADD,[Du]:i.FUNC_SUBTRACT,[Iu]:i.FUNC_REVERSE_SUBTRACT};ve[Lu]=i.MIN,ve[Uu]=i.MAX;const Ue={[Nu]:i.ZERO,[Fu]:i.ONE,[Ou]:i.SRC_COLOR,[ba]:i.SRC_ALPHA,[Hu]:i.SRC_ALPHA_SATURATE,[Vu]:i.DST_COLOR,[zu]:i.DST_ALPHA,[Bu]:i.ONE_MINUS_SRC_COLOR,[Ta]:i.ONE_MINUS_SRC_ALPHA,[ku]:i.ONE_MINUS_DST_COLOR,[Gu]:i.ONE_MINUS_DST_ALPHA,[Wu]:i.CONSTANT_COLOR,[Xu]:i.ONE_MINUS_CONSTANT_COLOR,[qu]:i.CONSTANT_ALPHA,[Yu]:i.ONE_MINUS_CONSTANT_ALPHA};function De(P,ae,$,ue,me,j,ye,Me,ht,st){if(P===Tn){m===!0&&(G(i.BLEND),m=!1);return}if(m===!1&&(ne(i.BLEND),m=!0),P!==Pu){if(P!==d||st!==I){if((A!==Qn||T!==Qn)&&(i.blendEquation(i.FUNC_ADD),A=Qn,T=Qn),st)switch(P){case Li:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case ya:i.blendFunc(i.ONE,i.ONE);break;case gl: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:Xe("WebGLState: Invalid blending: ",P);break}else switch(P){case Li:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case ya:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case gl:Xe("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case _l:Xe("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Xe("WebGLState: Invalid blending: ",P);break}w=null,M=null,y=null,R=null,x.set(0,0,0),b=0,d=P,I=st}return}me=me||ae,j=j||$,ye=ye||ue,(ae!==A||me!==T)&&(i.blendEquationSeparate(ve[ae],ve[me]),A=ae,T=me),($!==w||ue!==M||j!==y||ye!==R)&&(i.blendFuncSeparate(Ue[$],Ue[ue],Ue[j],Ue[ye]),w=$,M=ue,y=j,R=ye),(Me.equals(x)===!1||ht!==b)&&(i.blendColor(Me.r,Me.g,Me.b,ht),x.copy(Me),b=ht),d=P,I=!1}function Ie(P,ae){P.side===En?G(i.CULL_FACE):ne(i.CULL_FACE);let $=P.side===Lt;ae&&($=!$),Ze($),P.blending===Li&&P.transparent===!1?De(Tn):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),s.setMask(P.colorWrite);const ue=P.stencilWrite;o.setTest(ue),ue&&(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):G(i.SAMPLE_ALPHA_TO_COVERAGE)}function Ze(P){C!==P&&(P?i.frontFace(i.CW):i.frontFace(i.CCW),C=P)}function $e(P){P!==wu?(ne(i.CULL_FACE),P!==N&&(P===ml?i.cullFace(i.BACK):P===Ru?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):G(i.CULL_FACE),N=P}function ct(P){P!==Y&&(H&&i.lineWidth(P),Y=P)}function ot(P,ae,$){P?(ne(i.POLYGON_OFFSET_FILL),(K!==ae||O!==$)&&(K=ae,O=$,a.getReversed()&&(ae=-ae),i.polygonOffset(ae,$))):G(i.POLYGON_OFFSET_FILL)}function ut(P){P?ne(i.SCISSOR_TEST):G(i.SCISSOR_TEST)}function _t(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 ue=re[$];ue===void 0&&(ue={type:void 0,texture:void 0},re[$]=ue),(ue.type!==P||ue.texture!==ae)&&(ee!==$&&(i.activeTexture($),ee=$),i.bindTexture(P,ae||se[P]),ue.type=P,ue.texture=ae)}function Nt(){const P=re[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 p(){try{i.texSubImage2D(...arguments)}catch(P){Xe("WebGLState:",P)}}function U(){try{i.texSubImage3D(...arguments)}catch(P){Xe("WebGLState:",P)}}function V(){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 f[P]!==void 0?f[P]:i.getParameter(P)}function be(P,ae){f[P]!==ae&&(i.pixelStorei(P,ae),f[P]=ae)}function he(P){rt.equals(P)===!1&&(i.scissor(P.x,P.y,P.z,P.w),rt.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 ue=$.get(P);ue===void 0&&(ue=i.getUniformBlockIndex(ae,P.name),$.set(P,ue))}function Le(P,ae){const ue=c.get(ae).get(P);l.get(ae)!==ue&&(i.uniformBlockBinding(ae,ue,P.__bindingPointIndex),l.set(ae,ue))}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={},f={},ee=null,re={},u={},g=new WeakMap,_=[],S=null,m=!1,d=null,A=null,w=null,M=null,T=null,y=null,R=null,x=new Oe(0,0,0),b=0,I=!1,C=null,N=null,Y=null,K=null,O=null,rt.set(0,0,i.canvas.width,i.canvas.height),We.set(0,0,i.canvas.width,i.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:ne,disable:G,bindFramebuffer:Ce,drawBuffers:Pe,useProgram:we,setBlending:De,setMaterial:Ie,setFlipSided:Ze,setCullFace:$e,setLineWidth:ct,setPolygonOffset:ot,setScissorTest:ut,activeTexture:_t,bindTexture:D,unbindTexture:Nt,compressedTexImage2D:Je,compressedTexImage3D:E,texImage2D:q,texImage3D:J,pixelStorei:be,getParameter:le,updateUBOMapping:Re,uniformBlockBinding:Le,texStorage2D:ie,texStorage3D:oe,texSubImage2D:p,texSubImage3D:U,compressedTexSubImage2D:V,compressedTexSubImage3D:X,scissor:he,viewport:ce,reset:Be}}function Dg(i,e,t,n,r,s,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 Ve,h=new WeakMap,f=new Set;let u;const g=new WeakMap;let _=!1;try{_=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function S(E,p){return _?new OffscreenCanvas(E,p):ds("canvas")}function m(E,p,U){let V=1;const X=Je(E);if((X.width>U||X.height>U)&&(V=U/Math.max(X.width,X.height)),V<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(V*X.width),oe=Math.floor(V*X.height);u===void 0&&(u=S(ie,oe));const q=p?S(ie,oe):u;return q.width=ie,q.height=oe,q.getContext("2d").drawImage(E,0,0,ie,oe),Ne("WebGLRenderer: Texture has been resized from ("+X.width+"x"+X.height+") to ("+ie+"x"+oe+")."),q}else return"data"in E&&Ne("WebGLRenderer: Image in DataTexture is too big ("+X.width+"x"+X.height+")."),E;return E}function d(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 M(E,p,U,V,X,ie=!1){if(E!==null){if(i[E]!==void 0)return i[E];Ne("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+E+"'")}let oe;V&&(oe=e.get("EXT_texture_norm16"),oe||Ne("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let q=p;if(p===i.RED&&(U===i.FLOAT&&(q=i.R32F),U===i.HALF_FLOAT&&(q=i.R16F),U===i.UNSIGNED_BYTE&&(q=i.R8),U===i.UNSIGNED_SHORT&&oe&&(q=oe.R16_EXT),U===i.SHORT&&oe&&(q=oe.R16_SNORM_EXT)),p===i.RED_INTEGER&&(U===i.UNSIGNED_BYTE&&(q=i.R8UI),U===i.UNSIGNED_SHORT&&(q=i.R16UI),U===i.UNSIGNED_INT&&(q=i.R32UI),U===i.BYTE&&(q=i.R8I),U===i.SHORT&&(q=i.R16I),U===i.INT&&(q=i.R32I)),p===i.RG&&(U===i.FLOAT&&(q=i.RG32F),U===i.HALF_FLOAT&&(q=i.RG16F),U===i.UNSIGNED_BYTE&&(q=i.RG8),U===i.UNSIGNED_SHORT&&oe&&(q=oe.RG16_EXT),U===i.SHORT&&oe&&(q=oe.RG16_SNORM_EXT)),p===i.RG_INTEGER&&(U===i.UNSIGNED_BYTE&&(q=i.RG8UI),U===i.UNSIGNED_SHORT&&(q=i.RG16UI),U===i.UNSIGNED_INT&&(q=i.RG32UI),U===i.BYTE&&(q=i.RG8I),U===i.SHORT&&(q=i.RG16I),U===i.INT&&(q=i.RG32I)),p===i.RGB_INTEGER&&(U===i.UNSIGNED_BYTE&&(q=i.RGB8UI),U===i.UNSIGNED_SHORT&&(q=i.RGB16UI),U===i.UNSIGNED_INT&&(q=i.RGB32UI),U===i.BYTE&&(q=i.RGB8I),U===i.SHORT&&(q=i.RGB16I),U===i.INT&&(q=i.RGB32I)),p===i.RGBA_INTEGER&&(U===i.UNSIGNED_BYTE&&(q=i.RGBA8UI),U===i.UNSIGNED_SHORT&&(q=i.RGBA16UI),U===i.UNSIGNED_INT&&(q=i.RGBA32UI),U===i.BYTE&&(q=i.RGBA8I),U===i.SHORT&&(q=i.RGBA16I),U===i.INT&&(q=i.RGBA32I)),p===i.RGB&&(U===i.UNSIGNED_SHORT&&oe&&(q=oe.RGB16_EXT),U===i.SHORT&&oe&&(q=oe.RGB16_SNORM_EXT),U===i.UNSIGNED_INT_5_9_9_9_REV&&(q=i.RGB9_E5),U===i.UNSIGNED_INT_10F_11F_11F_REV&&(q=i.R11F_G11F_B10F)),p===i.RGBA){const J=ie?hs:qe.getTransfer(X);U===i.FLOAT&&(q=i.RGBA32F),U===i.HALF_FLOAT&&(q=i.RGBA16F),U===i.UNSIGNED_BYTE&&(q=J===Qe?i.SRGB8_ALPHA8:i.RGBA8),U===i.UNSIGNED_SHORT&&oe&&(q=oe.RGBA16_EXT),U===i.SHORT&&oe&&(q=oe.RGBA16_SNORM_EXT),U===i.UNSIGNED_SHORT_4_4_4_4&&(q=i.RGBA4),U===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 T(E,p){let U;return E?p===null||p===dn||p===hr?U=i.DEPTH24_STENCIL8:p===cn?U=i.DEPTH32F_STENCIL8:p===ur&&(U=i.DEPTH24_STENCIL8,Ne("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):p===null||p===dn||p===hr?U=i.DEPTH_COMPONENT24:p===cn?U=i.DEPTH_COMPONENT32F:p===ur&&(U=i.DEPTH_COMPONENT16),U}function y(E,p){return d(E)===!0||E.isFramebufferTexture&&E.minFilter!==yt&&E.minFilter!==Rt?Math.log2(Math.max(p.width,p.height))+1:E.mipmaps!==void 0&&E.mipmaps.length>0?E.mipmaps.length:E.isCompressedTexture&&Array.isArray(E.image)?p.mipmaps.length:1}function R(E){const p=E.target;p.removeEventListener("dispose",R),b(p),p.isVideoTexture&&h.delete(p),p.isHTMLTexture&&f.delete(p)}function x(E){const p=E.target;p.removeEventListener("dispose",x),C(p)}function b(E){const p=n.get(E);if(p.__webglInit===void 0)return;const U=E.source,V=g.get(U);if(V){const X=V[p.__cacheKey];X.usedTimes--,X.usedTimes===0&&I(E),Object.keys(V).length===0&&g.delete(U)}n.remove(E)}function I(E){const p=n.get(E);i.deleteTexture(p.__webglTexture);const U=E.source,V=g.get(U);delete V[p.__cacheKey],a.memory.textures--}function C(E){const p=n.get(E);if(E.depthTexture&&(E.depthTexture.dispose(),n.remove(E.depthTexture)),E.isWebGLCubeRenderTarget)for(let V=0;V<6;V++){if(Array.isArray(p.__webglFramebuffer[V]))for(let X=0;X<p.__webglFramebuffer[V].length;X++)i.deleteFramebuffer(p.__webglFramebuffer[V][X]);else i.deleteFramebuffer(p.__webglFramebuffer[V]);p.__webglDepthbuffer&&i.deleteRenderbuffer(p.__webglDepthbuffer[V])}else{if(Array.isArray(p.__webglFramebuffer))for(let V=0;V<p.__webglFramebuffer.length;V++)i.deleteFramebuffer(p.__webglFramebuffer[V]);else i.deleteFramebuffer(p.__webglFramebuffer);if(p.__webglDepthbuffer&&i.deleteRenderbuffer(p.__webglDepthbuffer),p.__webglMultisampledFramebuffer&&i.deleteFramebuffer(p.__webglMultisampledFramebuffer),p.__webglColorRenderbuffer)for(let V=0;V<p.__webglColorRenderbuffer.length;V++)p.__webglColorRenderbuffer[V]&&i.deleteRenderbuffer(p.__webglColorRenderbuffer[V]);p.__webglDepthRenderbuffer&&i.deleteRenderbuffer(p.__webglDepthRenderbuffer)}const U=E.textures;for(let V=0,X=U.length;V<X;V++){const ie=n.get(U[V]);ie.__webglTexture&&(i.deleteTexture(ie.__webglTexture),a.memory.textures--),n.remove(U[V])}n.remove(E)}let N=0;function Y(){N=0}function K(){return N}function O(E){N=E}function W(){const E=N;return E>=r.maxTextures&&Ne("WebGLTextures: Trying to use "+E+" texture units while this GPU supports only "+r.maxTextures),N+=1,E}function H(E){const p=[];return p.push(E.wrapS),p.push(E.wrapT),p.push(E.wrapR||0),p.push(E.magFilter),p.push(E.minFilter),p.push(E.anisotropy),p.push(E.internalFormat),p.push(E.format),p.push(E.type),p.push(E.generateMipmaps),p.push(E.premultiplyAlpha),p.push(E.flipY),p.push(E.unpackAlignment),p.push(E.colorSpace),p.join()}function Q(E,p){const U=n.get(E);if(E.isVideoTexture&&D(E),E.isRenderTargetTexture===!1&&E.isExternalTexture!==!0&&E.version>0&&U.__version!==E.version){const V=E.image;if(V===null)Ne("WebGLRenderer: Texture marked for update but no image data found.");else if(V.complete===!1)Ne("WebGLRenderer: Texture marked for update but image is incomplete");else{G(U,E,p);return}}else E.isExternalTexture&&(U.__webglTexture=E.sourceTexture?E.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,U.__webglTexture,i.TEXTURE0+p)}function te(E,p){const U=n.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&U.__version!==E.version){G(U,E,p);return}else E.isExternalTexture&&(U.__webglTexture=E.sourceTexture?E.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,U.__webglTexture,i.TEXTURE0+p)}function ee(E,p){const U=n.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&U.__version!==E.version){G(U,E,p);return}t.bindTexture(i.TEXTURE_3D,U.__webglTexture,i.TEXTURE0+p)}function re(E,p){const U=n.get(E);if(E.isCubeDepthTexture!==!0&&E.version>0&&U.__version!==E.version){Ce(U,E,p);return}t.bindTexture(i.TEXTURE_CUBE_MAP,U.__webglTexture,i.TEXTURE0+p)}const ge={[La]:i.REPEAT,[yn]:i.CLAMP_TO_EDGE,[Ua]:i.MIRRORED_REPEAT},He={[yt]:i.NEAREST,[$u]:i.NEAREST_MIPMAP_NEAREST,[vr]:i.NEAREST_MIPMAP_LINEAR,[Rt]:i.LINEAR,[Ns]:i.LINEAR_MIPMAP_NEAREST,[ti]:i.LINEAR_MIPMAP_LINEAR},rt={[ju]:i.NEVER,[rh]:i.ALWAYS,[eh]:i.LESS,[Ho]:i.LEQUAL,[th]:i.EQUAL,[Wo]:i.GEQUAL,[nh]:i.GREATER,[ih]:i.NOTEQUAL};function We(E,p){if(p.type===cn&&e.has("OES_texture_float_linear")===!1&&(p.magFilter===Rt||p.magFilter===Ns||p.magFilter===vr||p.magFilter===ti||p.minFilter===Rt||p.minFilter===Ns||p.minFilter===vr||p.minFilter===ti)&&Ne("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[p.wrapS]),i.texParameteri(E,i.TEXTURE_WRAP_T,ge[p.wrapT]),(E===i.TEXTURE_3D||E===i.TEXTURE_2D_ARRAY)&&i.texParameteri(E,i.TEXTURE_WRAP_R,ge[p.wrapR]),i.texParameteri(E,i.TEXTURE_MAG_FILTER,He[p.magFilter]),i.texParameteri(E,i.TEXTURE_MIN_FILTER,He[p.minFilter]),p.compareFunction&&(i.texParameteri(E,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(E,i.TEXTURE_COMPARE_FUNC,rt[p.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(p.magFilter===yt||p.minFilter!==vr&&p.minFilter!==ti||p.type===cn&&e.has("OES_texture_float_linear")===!1)return;if(p.anisotropy>1||n.get(p).__currentAnisotropy){const U=e.get("EXT_texture_filter_anisotropic");i.texParameterf(E,U.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(p.anisotropy,r.getMaxAnisotropy())),n.get(p).__currentAnisotropy=p.anisotropy}}}function Z(E,p){let U=!1;E.__webglInit===void 0&&(E.__webglInit=!0,p.addEventListener("dispose",R));const V=p.source;let X=g.get(V);X===void 0&&(X={},g.set(V,X));const ie=H(p);if(ie!==E.__cacheKey){X[ie]===void 0&&(X[ie]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,U=!0),X[ie].usedTimes++;const oe=X[E.__cacheKey];oe!==void 0&&(X[E.__cacheKey].usedTimes--,oe.usedTimes===0&&I(p)),E.__cacheKey=ie,E.__webglTexture=X[ie].texture}return U}function se(E,p,U){return Math.floor(Math.floor(E/U)/p)}function ne(E,p,U,V){const ie=E.updateRanges;if(ie.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,p.width,p.height,U,V,p.data);else{ie.sort((be,he)=>be.start-he.start);let oe=0;for(let be=1;be<ie.length;be++){const he=ie[oe],ce=ie[be],Re=he.start+he.count,Le=se(ce.start,p.width,4),Be=se(he.start,p.width,4);ce.start<=Re+1&&Le===Be&&se(ce.start+ce.count-1,p.width,4)===Le?he.count=Math.max(he.count,ce.start+ce.count-he.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,p.width);for(let be=0,he=ie.length;be<he;be++){const ce=ie[be],Re=Math.floor(ce.start/4),Le=Math.ceil(ce.count/4),Be=Re%p.width,P=Math.floor(Re/p.width),ae=Le,$=1;t.pixelStorei(i.UNPACK_SKIP_PIXELS,Be),t.pixelStorei(i.UNPACK_SKIP_ROWS,P),t.texSubImage2D(i.TEXTURE_2D,0,Be,P,ae,$,U,V,p.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 G(E,p,U){let V=i.TEXTURE_2D;(p.isDataArrayTexture||p.isCompressedArrayTexture)&&(V=i.TEXTURE_2D_ARRAY),p.isData3DTexture&&(V=i.TEXTURE_3D);const X=Z(E,p),ie=p.source;t.bindTexture(V,E.__webglTexture,i.TEXTURE0+U);const oe=n.get(ie);if(ie.version!==oe.__version||X===!0){if(t.activeTexture(i.TEXTURE0+U),(typeof ImageBitmap<"u"&&p.image instanceof ImageBitmap)===!1){const $=qe.getPrimaries(qe.workingColorSpace),ue=p.colorSpace===Gn?null:qe.getPrimaries(p.colorSpace),me=p.colorSpace===Gn||$===ue?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,p.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,p.premultiplyAlpha),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,me)}t.pixelStorei(i.UNPACK_ALIGNMENT,p.unpackAlignment);let J=m(p.image,!1,r.maxTextureSize);J=Nt(p,J);const le=s.convert(p.format,p.colorSpace),be=s.convert(p.type);let he=M(p.internalFormat,le,be,p.normalized,p.colorSpace,p.isVideoTexture);We(V,p);let ce;const Re=p.mipmaps,Le=p.isVideoTexture!==!0,Be=oe.__version===void 0||X===!0,P=ie.dataReady,ae=y(p,J);if(p.isDepthTexture)he=T(p.format===ni,p.type),Be&&(Le?t.texStorage2D(i.TEXTURE_2D,1,he,J.width,J.height):t.texImage2D(i.TEXTURE_2D,0,he,J.width,J.height,0,le,be,null));else if(p.isDataTexture)if(Re.length>0){Le&&Be&&t.texStorage2D(i.TEXTURE_2D,ae,he,Re[0].width,Re[0].height);for(let $=0,ue=Re.length;$<ue;$++)ce=Re[$],Le?P&&t.texSubImage2D(i.TEXTURE_2D,$,0,0,ce.width,ce.height,le,be,ce.data):t.texImage2D(i.TEXTURE_2D,$,he,ce.width,ce.height,0,le,be,ce.data);p.generateMipmaps=!1}else Le?(Be&&t.texStorage2D(i.TEXTURE_2D,ae,he,J.width,J.height),P&&ne(p,J,le,be)):t.texImage2D(i.TEXTURE_2D,0,he,J.width,J.height,0,le,be,J.data);else if(p.isCompressedTexture)if(p.isCompressedArrayTexture){Le&&Be&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ae,he,Re[0].width,Re[0].height,J.depth);for(let $=0,ue=Re.length;$<ue;$++)if(ce=Re[$],p.format!==en)if(le!==null)if(Le){if(P)if(p.layerUpdates.size>0){const me=Xl(ce.width,ce.height,p.format,p.type);for(const j of p.layerUpdates){const ye=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,ye)}p.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,$,he,ce.width,ce.height,J.depth,0,ce.data,0,0);else Ne("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Le?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,$,he,ce.width,ce.height,J.depth,0,le,be,ce.data)}else{Le&&Be&&t.texStorage2D(i.TEXTURE_2D,ae,he,Re[0].width,Re[0].height);for(let $=0,ue=Re.length;$<ue;$++)ce=Re[$],p.format!==en?le!==null?Le?P&&t.compressedTexSubImage2D(i.TEXTURE_2D,$,0,0,ce.width,ce.height,le,ce.data):t.compressedTexImage2D(i.TEXTURE_2D,$,he,ce.width,ce.height,0,ce.data):Ne("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Le?P&&t.texSubImage2D(i.TEXTURE_2D,$,0,0,ce.width,ce.height,le,be,ce.data):t.texImage2D(i.TEXTURE_2D,$,he,ce.width,ce.height,0,le,be,ce.data)}else if(p.isDataArrayTexture)if(Le){if(Be&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ae,he,J.width,J.height,J.depth),P)if(p.layerUpdates.size>0){const $=Xl(J.width,J.height,p.format,p.type);for(const ue of p.layerUpdates){const me=J.data.subarray(ue*$/J.data.BYTES_PER_ELEMENT,(ue+1)*$/J.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,ue,J.width,J.height,1,le,be,me)}p.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,he,J.width,J.height,J.depth,0,le,be,J.data);else if(p.isData3DTexture)Le?(Be&&t.texStorage3D(i.TEXTURE_3D,ae,he,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,he,J.width,J.height,J.depth,0,le,be,J.data);else if(p.isFramebufferTexture){if(Be)if(Le)t.texStorage2D(i.TEXTURE_2D,ae,he,J.width,J.height);else{let $=J.width,ue=J.height;for(let me=0;me<ae;me++)t.texImage2D(i.TEXTURE_2D,me,he,$,ue,0,le,be,null),$>>=1,ue>>=1}}else if(p.isHTMLTexture){if("texElementImage2D"in i){const $=i.canvas;if($.hasAttribute("layoutsubtree")||$.setAttribute("layoutsubtree","true"),J.parentNode!==$){$.appendChild(J),f.add(p),$.onpaint=ue=>{const me=ue.changedElements;for(const j of f)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,ye=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,me,j,ye,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(Le&&Be){const $=Je(Re[0]);t.texStorage2D(i.TEXTURE_2D,ae,he,$.width,$.height)}for(let $=0,ue=Re.length;$<ue;$++)ce=Re[$],Le?P&&t.texSubImage2D(i.TEXTURE_2D,$,0,0,le,be,ce):t.texImage2D(i.TEXTURE_2D,$,he,le,be,ce);p.generateMipmaps=!1}else if(Le){if(Be){const $=Je(J);t.texStorage2D(i.TEXTURE_2D,ae,he,$.width,$.height)}P&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,le,be,J)}else t.texImage2D(i.TEXTURE_2D,0,he,le,be,J);d(p)&&A(V),oe.__version=ie.version,p.onUpdate&&p.onUpdate(p)}E.__version=p.version}function Ce(E,p,U){if(p.image.length!==6)return;const V=Z(E,p),X=p.source;t.bindTexture(i.TEXTURE_CUBE_MAP,E.__webglTexture,i.TEXTURE0+U);const ie=n.get(X);if(X.version!==ie.__version||V===!0){t.activeTexture(i.TEXTURE0+U);const oe=qe.getPrimaries(qe.workingColorSpace),q=p.colorSpace===Gn?null:qe.getPrimaries(p.colorSpace),J=p.colorSpace===Gn||oe===q?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,p.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,p.premultiplyAlpha),t.pixelStorei(i.UNPACK_ALIGNMENT,p.unpackAlignment),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,J);const le=p.isCompressedTexture||p.image[0].isCompressedTexture,be=p.image[0]&&p.image[0].isDataTexture,he=[];for(let j=0;j<6;j++)!le&&!be?he[j]=m(p.image[j],!0,r.maxCubemapSize):he[j]=be?p.image[j].image:p.image[j],he[j]=Nt(p,he[j]);const ce=he[0],Re=s.convert(p.format,p.colorSpace),Le=s.convert(p.type),Be=M(p.internalFormat,Re,Le,p.normalized,p.colorSpace),P=p.isVideoTexture!==!0,ae=ie.__version===void 0||V===!0,$=X.dataReady;let ue=y(p,ce);We(i.TEXTURE_CUBE_MAP,p);let me;if(le){P&&ae&&t.texStorage2D(i.TEXTURE_CUBE_MAP,ue,Be,ce.width,ce.height);for(let j=0;j<6;j++){me=he[j].mipmaps;for(let ye=0;ye<me.length;ye++){const Me=me[ye];p.format!==en?Re!==null?P?$&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,ye,0,0,Me.width,Me.height,Re,Me.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,ye,Be,Me.width,Me.height,0,Me.data):Ne("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):P?$&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,ye,0,0,Me.width,Me.height,Re,Le,Me.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,ye,Be,Me.width,Me.height,0,Re,Le,Me.data)}}}else{if(me=p.mipmaps,P&&ae){me.length>0&&ue++;const j=Je(he[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,ue,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,he[j].width,he[j].height,Re,Le,he[j].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,Be,he[j].width,he[j].height,0,Re,Le,he[j].data);for(let ye=0;ye<me.length;ye++){const ht=me[ye].image[j].image;P?$&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,ye+1,0,0,ht.width,ht.height,Re,Le,ht.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,ye+1,Be,ht.width,ht.height,0,Re,Le,ht.data)}}else{P?$&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,0,0,Re,Le,he[j]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,Be,Re,Le,he[j]);for(let ye=0;ye<me.length;ye++){const Me=me[ye];P?$&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,ye+1,0,0,Re,Le,Me.image[j]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,ye+1,Be,Re,Le,Me.image[j])}}}d(p)&&A(i.TEXTURE_CUBE_MAP),ie.__version=X.version,p.onUpdate&&p.onUpdate(p)}E.__version=p.version}function Pe(E,p,U,V,X,ie){const oe=s.convert(U.format,U.colorSpace),q=s.convert(U.type),J=M(U.internalFormat,oe,q,U.normalized,U.colorSpace),le=n.get(p),be=n.get(U);if(be.__renderTarget=p,!le.__hasExternalTextures){const he=Math.max(1,p.width>>ie),ce=Math.max(1,p.height>>ie);X===i.TEXTURE_3D||X===i.TEXTURE_2D_ARRAY?t.texImage3D(X,ie,J,he,ce,p.depth,0,oe,q,null):t.texImage2D(X,ie,J,he,ce,0,oe,q,null)}t.bindFramebuffer(i.FRAMEBUFFER,E),_t(p)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,V,X,be.__webglTexture,0,ut(p)):(X===i.TEXTURE_2D||X>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&X<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,V,X,be.__webglTexture,ie),t.bindFramebuffer(i.FRAMEBUFFER,null)}function we(E,p,U){if(i.bindRenderbuffer(i.RENDERBUFFER,E),p.depthBuffer){const V=p.depthTexture,X=V&&V.isDepthTexture?V.type:null,ie=T(p.stencilBuffer,X),oe=p.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;_t(p)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ut(p),ie,p.width,p.height):U?i.renderbufferStorageMultisample(i.RENDERBUFFER,ut(p),ie,p.width,p.height):i.renderbufferStorage(i.RENDERBUFFER,ie,p.width,p.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,oe,i.RENDERBUFFER,E)}else{const V=p.textures;for(let X=0;X<V.length;X++){const ie=V[X],oe=s.convert(ie.format,ie.colorSpace),q=s.convert(ie.type),J=M(ie.internalFormat,oe,q,ie.normalized,ie.colorSpace);_t(p)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ut(p),J,p.width,p.height):U?i.renderbufferStorageMultisample(i.RENDERBUFFER,ut(p),J,p.width,p.height):i.renderbufferStorage(i.RENDERBUFFER,J,p.width,p.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function ve(E,p,U){const V=p.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(i.FRAMEBUFFER,E),!(p.depthTexture&&p.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const X=n.get(p.depthTexture);if(X.__renderTarget=p,(!X.__webglTexture||p.depthTexture.image.width!==p.width||p.depthTexture.image.height!==p.height)&&(p.depthTexture.image.width=p.width,p.depthTexture.image.height=p.height,p.depthTexture.needsUpdate=!0),V){if(X.__webglInit===void 0&&(X.__webglInit=!0,p.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,p.depthTexture);const le=s.convert(p.depthTexture.format),be=s.convert(p.depthTexture.type);let he;p.depthTexture.format===Rn?he=i.DEPTH_COMPONENT24:p.depthTexture.format===ni&&(he=i.DEPTH24_STENCIL8);for(let ce=0;ce<6;ce++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,he,p.width,p.height,0,le,be,null)}}else Q(p.depthTexture,0);const ie=X.__webglTexture,oe=ut(p),q=V?i.TEXTURE_CUBE_MAP_POSITIVE_X+U:i.TEXTURE_2D,J=p.depthTexture.format===ni?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(p.depthTexture.format===Rn)_t(p)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,J,q,ie,0,oe):i.framebufferTexture2D(i.FRAMEBUFFER,J,q,ie,0);else if(p.depthTexture.format===ni)_t(p)?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 Ue(E){const p=n.get(E),U=E.isWebGLCubeRenderTarget===!0;if(p.__boundDepthTexture!==E.depthTexture){const V=E.depthTexture;if(p.__depthDisposeCallback&&p.__depthDisposeCallback(),V){const X=()=>{delete p.__boundDepthTexture,delete p.__depthDisposeCallback,V.removeEventListener("dispose",X)};V.addEventListener("dispose",X),p.__depthDisposeCallback=X}p.__boundDepthTexture=V}if(E.depthTexture&&!p.__autoAllocateDepthBuffer)if(U)for(let V=0;V<6;V++)ve(p.__webglFramebuffer[V],E,V);else{const V=E.texture.mipmaps;V&&V.length>0?ve(p.__webglFramebuffer[0],E,0):ve(p.__webglFramebuffer,E,0)}else if(U){p.__webglDepthbuffer=[];for(let V=0;V<6;V++)if(t.bindFramebuffer(i.FRAMEBUFFER,p.__webglFramebuffer[V]),p.__webglDepthbuffer[V]===void 0)p.__webglDepthbuffer[V]=i.createRenderbuffer(),we(p.__webglDepthbuffer[V],E,!1);else{const X=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ie=p.__webglDepthbuffer[V];i.bindRenderbuffer(i.RENDERBUFFER,ie),i.framebufferRenderbuffer(i.FRAMEBUFFER,X,i.RENDERBUFFER,ie)}}else{const V=E.texture.mipmaps;if(V&&V.length>0?t.bindFramebuffer(i.FRAMEBUFFER,p.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,p.__webglFramebuffer),p.__webglDepthbuffer===void 0)p.__webglDepthbuffer=i.createRenderbuffer(),we(p.__webglDepthbuffer,E,!1);else{const X=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ie=p.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,ie),i.framebufferRenderbuffer(i.FRAMEBUFFER,X,i.RENDERBUFFER,ie)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function De(E,p,U){const V=n.get(E);p!==void 0&&Pe(V.__webglFramebuffer,E,E.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),U!==void 0&&Ue(E)}function Ie(E){const p=E.texture,U=n.get(E),V=n.get(p);E.addEventListener("dispose",x);const X=E.textures,ie=E.isWebGLCubeRenderTarget===!0,oe=X.length>1;if(oe||(V.__webglTexture===void 0&&(V.__webglTexture=i.createTexture()),V.__version=p.version,a.memory.textures++),ie){U.__webglFramebuffer=[];for(let q=0;q<6;q++)if(p.mipmaps&&p.mipmaps.length>0){U.__webglFramebuffer[q]=[];for(let J=0;J<p.mipmaps.length;J++)U.__webglFramebuffer[q][J]=i.createFramebuffer()}else U.__webglFramebuffer[q]=i.createFramebuffer()}else{if(p.mipmaps&&p.mipmaps.length>0){U.__webglFramebuffer=[];for(let q=0;q<p.mipmaps.length;q++)U.__webglFramebuffer[q]=i.createFramebuffer()}else U.__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&&_t(E)===!1){U.__webglMultisampledFramebuffer=i.createFramebuffer(),U.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,U.__webglMultisampledFramebuffer);for(let q=0;q<X.length;q++){const J=X[q];U.__webglColorRenderbuffer[q]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,U.__webglColorRenderbuffer[q]);const le=s.convert(J.format,J.colorSpace),be=s.convert(J.type),he=M(J.internalFormat,le,be,J.normalized,J.colorSpace,E.isXRRenderTarget===!0),ce=ut(E);i.renderbufferStorageMultisample(i.RENDERBUFFER,ce,he,E.width,E.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+q,i.RENDERBUFFER,U.__webglColorRenderbuffer[q])}i.bindRenderbuffer(i.RENDERBUFFER,null),E.depthBuffer&&(U.__webglDepthRenderbuffer=i.createRenderbuffer(),we(U.__webglDepthRenderbuffer,E,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(ie){t.bindTexture(i.TEXTURE_CUBE_MAP,V.__webglTexture),We(i.TEXTURE_CUBE_MAP,p);for(let q=0;q<6;q++)if(p.mipmaps&&p.mipmaps.length>0)for(let J=0;J<p.mipmaps.length;J++)Pe(U.__webglFramebuffer[q][J],E,p,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+q,J);else Pe(U.__webglFramebuffer[q],E,p,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+q,0);d(p)&&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 he=i.TEXTURE_2D;(E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)&&(he=E.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(he,be.__webglTexture),We(he,le),Pe(U.__webglFramebuffer,E,le,i.COLOR_ATTACHMENT0+q,he,0),d(le)&&A(he)}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,V.__webglTexture),We(q,p),p.mipmaps&&p.mipmaps.length>0)for(let J=0;J<p.mipmaps.length;J++)Pe(U.__webglFramebuffer[J],E,p,i.COLOR_ATTACHMENT0,q,J);else Pe(U.__webglFramebuffer,E,p,i.COLOR_ATTACHMENT0,q,0);d(p)&&A(q),t.unbindTexture()}E.depthBuffer&&Ue(E)}function Ze(E){const p=E.textures;for(let U=0,V=p.length;U<V;U++){const X=p[U];if(d(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(_t(E)===!1){const p=E.textures,U=E.width,V=E.height;let X=i.COLOR_BUFFER_BIT;const ie=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,oe=n.get(E),q=p.length>1;if(q)for(let le=0;le<p.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<p.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(p[le]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,be,0)}i.blitFramebuffer(0,0,U,V,0,0,U,V,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<p.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(p[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 p=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[p])}}}function ut(E){return Math.min(r.maxSamples,E.samples)}function _t(E){const p=n.get(E);return E.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&p.__useRenderToTexture!==!1}function D(E){const p=a.render.frame;h.get(E)!==p&&(h.set(E,p),E.update())}function Nt(E,p){const U=E.colorSpace,V=E.format,X=E.type;return E.isCompressedTexture===!0||E.isVideoTexture===!0||U!==us&&U!==Gn&&(qe.getTransfer(U)===Qe?(V!==en||X!==qt)&&Ne("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Xe("WebGLTextures: Unsupported texture color space:",U)),p}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=K,this.setTextureUnits=O,this.setTexture2D=Q,this.setTexture2DArray=te,this.setTexture3D=ee,this.setTextureCube=re,this.rebindTextures=De,this.setupRenderTarget=Ie,this.updateRenderTargetMipmap=Ze,this.updateMultisampleRenderTarget=ot,this.setupDepthRenderbuffer=Ue,this.setupFrameBufferTexture=Pe,this.useMultisampledRTT=_t,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Ig(i,e){function t(n,r=Gn){let s;const a=qe.getTransfer(r);if(n===qt)return i.UNSIGNED_BYTE;if(n===Bo)return i.UNSIGNED_SHORT_4_4_4_4;if(n===zo)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Zc)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===$c)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===Yc)return i.BYTE;if(n===Kc)return i.SHORT;if(n===ur)return i.UNSIGNED_SHORT;if(n===Oo)return i.INT;if(n===dn)return i.UNSIGNED_INT;if(n===cn)return i.FLOAT;if(n===wn)return i.HALF_FLOAT;if(n===Jc)return i.ALPHA;if(n===Qc)return i.RGB;if(n===en)return i.RGBA;if(n===Rn)return i.DEPTH_COMPONENT;if(n===ni)return i.DEPTH_STENCIL;if(n===jc)return i.RED;if(n===Go)return i.RED_INTEGER;if(n===ai)return i.RG;if(n===Vo)return i.RG_INTEGER;if(n===ko)return i.RGBA_INTEGER;if(n===ns||n===is||n===rs||n===ss)if(a===Qe)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===ns)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===is)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===rs)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===ss)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===ns)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===is)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===rs)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===ss)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Na||n===Fa||n===Oa||n===Ba)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===Na)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Fa)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Oa)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Ba)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===za||n===Ga||n===Va||n===ka||n===Ha||n===ls||n===Wa)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===za||n===Ga)return a===Qe?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===Va)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(n===ka)return s.COMPRESSED_R11_EAC;if(n===Ha)return s.COMPRESSED_SIGNED_R11_EAC;if(n===ls)return s.COMPRESSED_RG11_EAC;if(n===Wa)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Xa||n===qa||n===Ya||n===Ka||n===Za||n===$a||n===Ja||n===Qa||n===ja||n===eo||n===to||n===no||n===io||n===ro)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===Xa)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===qa)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Ya)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Ka)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Za)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===$a)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Ja)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Qa)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===ja)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===eo)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===to)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===no)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===io)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===ro)return a===Qe?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===so||n===ao||n===oo)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===so)return a===Qe?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===ao)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===oo)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===lo||n===co||n===cs||n===uo)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===lo)return s.COMPRESSED_RED_RGTC1_EXT;if(n===co)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===cs)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===uo)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===hr?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const Lg=`
|
|
4315
|
+
}`,T_=[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)],A_=[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)],Bc=new le,ur=new F,Ua=new F;function w_(i,t,e){let n=new jh;const r=new Gt,s=new Gt,a=new fe,o=new zd,l=new Gd,c={},h=e.maxTextureSize,d={[Zn]:Fe,[Fe]:Zn,[bn]:bn},u=new Ve({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Gt},radius:{value:4}},vertexShader:E_,fragmentShader:b_}),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 S=new ke(_,u),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ss;let f=this.type;this.render=function(b,R,x){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||b.length===0)return;this.type===R0&&(Ft("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Ss);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;r.copy(V.mapSize);const Q=V.getFrameExtents();r.multiply(Q),s.copy(V.mapSize),(r.x>h||r.y>h)&&(r.x>h&&(s.x=Math.floor(h/Q.x),r.x=s.x*Q.x,V.mapSize.x=s.x),r.y>h&&(s.y=Math.floor(h/Q.y),r.y=s.y*Q.y,V.mapSize.y=s.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===gr){if(W.isPointLight){Ft("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}V.map=new mn(r.x,r.y,{format:ci,type:Cn,minFilter:Ie,magFilter:Ie,generateMipmaps:!1}),V.map.texture.name=W.name+".shadowMap",V.map.depthTexture=new Zi(r.x,r.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 cu(r.x),V.map.depthTexture=new Ld(r.x,gn)):(V.map=new mn(r.x,r.y),V.map.depthTexture=new Zi(r.x,r.y,gn)),V.map.depthTexture.name=W.name+".shadowMap",V.map.depthTexture.format=Pn,this.type===Ss?(V.map.depthTexture.compareFunction=et?pl:fl,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 rt=0;rt<tt;rt++){if(V.map.isWebGLCubeRenderTarget)i.setRenderTarget(V.map,rt),i.clear();else{rt===0&&(i.setRenderTarget(V.map),i.clear());const gt=V.getViewport(rt);a.set(s.x*gt.x,s.y*gt.y,s.x*gt.z,s.y*gt.w),U.viewport(a)}if(W.isPointLight){const gt=V.camera,Vt=V.matrix,re=W.distance||gt.far;re!==gt.far&&(gt.far=re,gt.updateProjectionMatrix()),ur.setFromMatrixPosition(W.matrixWorld),gt.position.copy(ur),Ua.copy(gt.position),Ua.add(T_[rt]),gt.up.copy(A_[rt]),gt.lookAt(Ua),gt.updateMatrixWorld(),Vt.makeTranslation(-ur.x,-ur.y,-ur.z),Bc.multiplyMatrices(gt.projectionMatrix,gt.matrixWorldInverse),V._frustum.setFromProjectionMatrix(Bc,gt.coordinateSystem,gt.reversedDepth)}else V.updateMatrices(W);n=V.getFrustum(),M(R,x,V.camera,W,this.type)}V.isPointLightShadow!==!0&&this.type===gr&&A(V,x),V.needsUpdate=!1}f=this.type,m.needsUpdate=!1,i.setRenderTarget(T,I,C)};function A(b,R){const x=t.update(S);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(r.x,r.y,{format:ci,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,x,u,S,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,x,p,S,null)}function w(b,R,x,T){let I=null;const C=x.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(C!==void 0)I=C;else if(I=x.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===gr?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,x.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const U=i.properties.get(I);U.light=x}return I}function M(b,R,x,T,I){if(b.visible===!1)return;if(b.layers.test(R.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&I===gr)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(x.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,x,Y,tt,Q),i.renderBufferDirect(x,null,Y,tt,b,Q),b.onAfterShadow(i,b,R,x,Y,tt,Q)}}}else if(Z.visible){const O=w(b,Z,T,I);b.onBeforeShadow(i,b,R,x,Y,O,null),i.renderBufferDirect(x,null,Y,O,b,null),b.onAfterShadow(i,b,R,x,Y,O,null)}}const U=b.children;for(let Y=0,Z=U.length;Y<Z;Y++)M(U[Y],R,x,T,I)}function y(b){b.target.removeEventListener("dispose",y);for(const x in c){const T=c[x],I=b.target.uuid;I in T&&(T[I].dispose(),delete T[I])}}}function R_(i,t){function e(){let P=!1;const at=new fe;let K=null;const ht=new fe(0,0,0,0);return{setMask:function(mt){K!==mt&&!P&&(i.colorMask(mt,mt,mt,mt),K=mt)},setLocked:function(mt){P=mt},setClear:function(mt,j,Et,Mt,ue){ue===!0&&(mt*=Mt,j*=Mt,Et*=Mt),at.set(mt,j,Et,Mt),ht.equals(at)===!1&&(i.clearColor(mt,j,Et,Mt),ht.copy(at))},reset:function(){P=!1,K=null,ht.set(-1,0,0,0)}}}function n(){let P=!1,at=!1,K=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 Mt=mt;mt=null,this.setClear(Mt)}},getReversed:function(){return at},setTest:function(j){j?nt(i.DEPTH_TEST):G(i.DEPTH_TEST)},setMask:function(j){K!==j&&!P&&(i.depthMask(j),K=j)},setFunc:function(j){if(at&&(j=od[j]),ht!==j){switch(j){case Ka:i.depthFunc(i.NEVER);break;case Ja:i.depthFunc(i.ALWAYS);break;case Qa:i.depthFunc(i.LESS);break;case qi:i.depthFunc(i.LEQUAL);break;case ja:i.depthFunc(i.EQUAL);break;case to:i.depthFunc(i.GEQUAL);break;case eo:i.depthFunc(i.GREATER);break;case no: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,K=null,ht=null,mt=null,at=!1}}}function r(){let P=!1,at=null,K=null,ht=null,mt=null,j=null,Et=null,Mt=null,ue=null;return{setTest:function(se){P||(se?nt(i.STENCIL_TEST):G(i.STENCIL_TEST))},setMask:function(se){at!==se&&!P&&(i.stencilMask(se),at=se)},setFunc:function(se,sn,an){(K!==se||ht!==sn||mt!==an)&&(i.stencilFunc(se,sn,an),K=se,ht=sn,mt=an)},setOp:function(se,sn,an){(j!==se||Et!==sn||Mt!==an)&&(i.stencilOp(se,sn,an),j=se,Et=sn,Mt=an)},setLocked:function(se){P=se},setClear:function(se){ue!==se&&(i.clearStencil(se),ue=se)},reset:function(){P=!1,at=null,K=null,ht=null,mt=null,j=null,Et=null,Mt=null,ue=null}}}const s=new e,a=new n,o=new r,l=new WeakMap,c=new WeakMap;let h={},d={},u={},p=new WeakMap,_=[],S=null,m=!1,f=null,A=null,w=null,M=null,y=null,b=null,R=null,x=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,rt={};const gt=i.getParameter(i.SCISSOR_BOX),Vt=i.getParameter(i.VIEWPORT),re=new fe().fromArray(gt),Wt=new fe().fromArray(Vt);function $(P,at,K,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<K;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 st={};st[i.TEXTURE_2D]=$(i.TEXTURE_2D,i.TEXTURE_2D,1),st[i.TEXTURE_CUBE_MAP]=$(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),st[i.TEXTURE_2D_ARRAY]=$(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),st[i.TEXTURE_3D]=$(i.TEXTURE_3D,i.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),nt(i.DEPTH_TEST),a.setFunc(qi),$t(!1),Kt(zl),nt(i.CULL_FACE),Dt(wn);function nt(P){h[P]!==!0&&(i.enable(P),h[P]=!0)}function G(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 K=_,ht=!1;if(P){K=p.get(at),K===void 0&&(K=[],p.set(at,K));const mt=P.textures;if(K.length!==mt.length||K[0]!==i.COLOR_ATTACHMENT0){for(let j=0,Et=mt.length;j<Et;j++)K[j]=i.COLOR_ATTACHMENT0+j;K.length=mt.length,ht=!0}}else K[0]!==i.BACK&&(K[0]=i.BACK,ht=!0);ht&&i.drawBuffers(K)}function wt(P){return S!==P?(i.useProgram(P),S=P,!0):!1}const vt={[ei]:i.FUNC_ADD,[P0]:i.FUNC_SUBTRACT,[I0]:i.FUNC_REVERSE_SUBTRACT};vt[D0]=i.MIN,vt[L0]=i.MAX;const Nt={[U0]:i.ZERO,[N0]:i.ONE,[F0]:i.SRC_COLOR,[Za]:i.SRC_ALPHA,[k0]:i.SRC_ALPHA_SATURATE,[G0]:i.DST_COLOR,[B0]:i.DST_ALPHA,[O0]:i.ONE_MINUS_SRC_COLOR,[$a]:i.ONE_MINUS_SRC_ALPHA,[H0]:i.ONE_MINUS_DST_COLOR,[z0]:i.ONE_MINUS_DST_ALPHA,[V0]:i.CONSTANT_COLOR,[W0]:i.ONE_MINUS_CONSTANT_COLOR,[X0]:i.CONSTANT_ALPHA,[q0]:i.ONE_MINUS_CONSTANT_ALPHA};function Dt(P,at,K,ht,mt,j,Et,Mt,ue,se){if(P===wn){m===!0&&(G(i.BLEND),m=!1);return}if(m===!1&&(nt(i.BLEND),m=!0),P!==C0){if(P!==f||se!==I){if((A!==ei||y!==ei)&&(i.blendEquation(i.FUNC_ADD),A=ei,y=ei),se)switch(P){case Gi:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Ya:i.blendFunc(i.ONE,i.ONE);break;case Gl:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Hl: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 Gi:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Ya:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case Gl:Xt("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Hl:Xt("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Xt("WebGLState: Invalid blending: ",P);break}w=null,M=null,b=null,R=null,x.set(0,0,0),T=0,f=P,I=se}return}mt=mt||at,j=j||K,Et=Et||ht,(at!==A||mt!==y)&&(i.blendEquationSeparate(vt[at],vt[mt]),A=at,y=mt),(K!==w||ht!==M||j!==b||Et!==R)&&(i.blendFuncSeparate(Nt[K],Nt[ht],Nt[j],Nt[Et]),w=K,M=ht,b=j,R=Et),(Mt.equals(x)===!1||ue!==T)&&(i.blendColor(Mt.r,Mt.g,Mt.b,ue),x.copy(Mt),T=ue),f=P,I=!1}function Lt(P,at){P.side===bn?G(i.CULL_FACE):nt(i.CULL_FACE);let K=P.side===Fe;at&&(K=!K),$t(K),P.blending===Gi&&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),s.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):G(i.SAMPLE_ALPHA_TO_COVERAGE)}function $t(P){C!==P&&(P?i.frontFace(i.CW):i.frontFace(i.CCW),C=P)}function Kt(P){P!==A0?(nt(i.CULL_FACE),P!==U&&(P===zl?i.cullFace(i.BACK):P===w0?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):G(i.CULL_FACE),U=P}function ce(P){P!==Y&&(V&&i.lineWidth(P),Y=P)}function oe(P,at,K){P?(nt(i.POLYGON_OFFSET_FILL),(Z!==at||O!==K)&&(Z=at,O=K,a.getReversed()&&(at=-at),i.polygonOffset(at,K))):G(i.POLYGON_OFFSET_FILL)}function he(P){P?nt(i.SCISSOR_TEST):G(i.SCISSOR_TEST)}function xe(P){P===void 0&&(P=i.TEXTURE0+W-1),tt!==P&&(i.activeTexture(P),tt=P)}function D(P,at,K){K===void 0&&(tt===null?K=i.TEXTURE0+W-1:K=tt);let ht=rt[K];ht===void 0&&(ht={type:void 0,texture:void 0},rt[K]=ht),(ht.type!==P||ht.texture!==at)&&(tt!==K&&(i.activeTexture(K),tt=K),i.bindTexture(P,at||st[P]),ht.type=P,ht.texture=at)}function Be(){const P=rt[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){re.equals(P)===!1&&(i.scissor(P.x,P.y,P.z,P.w),re.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 K=c.get(at);K===void 0&&(K=new WeakMap,c.set(at,K));let ht=K.get(P);ht===void 0&&(ht=i.getUniformBlockIndex(at,P.name),K.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,rt={},u={},p=new WeakMap,_=[],S=null,m=!1,f=null,A=null,w=null,M=null,y=null,b=null,R=null,x=new It(0,0,0),T=0,I=!1,C=null,U=null,Y=null,Z=null,O=null,re.set(0,0,i.canvas.width,i.canvas.height),Wt.set(0,0,i.canvas.width,i.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:nt,disable:G,bindFramebuffer:Ct,drawBuffers:Pt,useProgram:wt,setBlending:Dt,setMaterial:Lt,setFlipSided:$t,setCullFace:Kt,setLineWidth:ce,setPolygonOffset:oe,setScissorTest:he,activeTexture:xe,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 C_(i,t,e,n,r,s,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 Gt,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 S(E,g){return _?new OffscreenCanvas(E,g):Us("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=S(it,ot));const q=g?S(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 M(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?Ds: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===br?N=i.DEPTH24_STENCIL8:g===dn?N=i.DEPTH32F_STENCIL8:g===Er&&(N=i.DEPTH24_STENCIL8,Ft("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):g===null||g===gn||g===br?N=i.DEPTH_COMPONENT24:g===dn?N=i.DEPTH_COMPONENT32F:g===Er&&(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 x(E){const g=E.target;g.removeEventListener("dispose",x),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>=r.maxTextures&&Ft("WebGLTextures: Trying to use "+E+" texture units while this GPU supports only "+r.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{G(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){G(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){G(N,E,g);return}e.bindTexture(i.TEXTURE_3D,N.__webglTexture,i.TEXTURE0+g)}function rt(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={[io]:i.REPEAT,[Tn]:i.CLAMP_TO_EDGE,[ro]:i.MIRRORED_REPEAT},Vt={[Ae]:i.NEAREST,[$0]:i.NEAREST_MIPMAP_NEAREST,[Dr]:i.NEAREST_MIPMAP_LINEAR,[Ie]:i.LINEAR,[ia]:i.LINEAR_MIPMAP_NEAREST,[ri]:i.LINEAR_MIPMAP_LINEAR},re={[Q0]:i.NEVER,[id]:i.ALWAYS,[j0]:i.LESS,[fl]:i.LEQUAL,[td]:i.EQUAL,[pl]:i.GEQUAL,[ed]:i.GREATER,[nd]:i.NOTEQUAL};function Wt(E,g){if(g.type===dn&&t.has("OES_texture_float_linear")===!1&&(g.magFilter===Ie||g.magFilter===ia||g.magFilter===Dr||g.magFilter===ri||g.minFilter===Ie||g.minFilter===ia||g.minFilter===Dr||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,re[g.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(g.magFilter===Ae||g.minFilter!==Dr&&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,r.getMaxAnisotropy())),n.get(g).__currentAnisotropy=g.anisotropy}}}function $(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 st(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=st(ct.start,g.width,4),Bt=st(ut.start,g.width,4);ct.start<=Rt+1&&Ut===Bt&&st(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,K=1;e.pixelStorei(i.UNPACK_SKIP_PIXELS,Bt),e.pixelStorei(i.UNPACK_SKIP_ROWS,P),e.texSubImage2D(i.TEXTURE_2D,0,Bt,P,at,K,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 G(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=$(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 K=qt.getPrimaries(qt.workingColorSpace),ht=g.colorSpace===Vn?null:qt.getPrimaries(g.colorSpace),mt=g.colorSpace===Vn||K===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,r.maxTextureSize);J=Be(g,J);const lt=s.convert(g.format,g.colorSpace),bt=s.convert(g.type);let ut=M(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===si,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 K=0,ht=Rt.length;K<ht;K++)ct=Rt[K],Ut?P&&e.texSubImage2D(i.TEXTURE_2D,K,0,0,ct.width,ct.height,lt,bt,ct.data):e.texImage2D(i.TEXTURE_2D,K,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 K=0,ht=Rt.length;K<ht;K++)if(ct=Rt[K],g.format!==rn)if(lt!==null)if(Ut){if(P)if(g.layerUpdates.size>0){const mt=mc(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,K,0,0,j,ct.width,ct.height,1,lt,Et)}g.clearLayerUpdates()}else e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,K,0,0,0,ct.width,ct.height,J.depth,lt,ct.data)}else e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,K,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,K,0,0,0,ct.width,ct.height,J.depth,lt,bt,ct.data):e.texImage3D(i.TEXTURE_2D_ARRAY,K,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 K=0,ht=Rt.length;K<ht;K++)ct=Rt[K],g.format!==rn?lt!==null?Ut?P&&e.compressedTexSubImage2D(i.TEXTURE_2D,K,0,0,ct.width,ct.height,lt,ct.data):e.compressedTexImage2D(i.TEXTURE_2D,K,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,K,0,0,ct.width,ct.height,lt,bt,ct.data):e.texImage2D(i.TEXTURE_2D,K,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 K=mc(J.width,J.height,g.format,g.type);for(const ht of g.layerUpdates){const mt=J.data.subarray(ht*K/J.data.BYTES_PER_ELEMENT,(ht+1)*K/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 K=J.width,ht=J.height;for(let mt=0;mt<at;mt++)e.texImage2D(i.TEXTURE_2D,mt,ut,K,ht,0,lt,bt,null),K>>=1,ht>>=1}}else if(g.isHTMLTexture){if("texElementImage2D"in i){const K=i.canvas;if(K.hasAttribute("layoutsubtree")||K.setAttribute("layoutsubtree","true"),J.parentNode!==K){K.appendChild(J),d.add(g),K.onpaint=ht=>{const mt=ht.changedElements;for(const j of d)mt.includes(j.image)&&(j.needsUpdate=!0)},K.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 K=Jt(Rt[0]);e.texStorage2D(i.TEXTURE_2D,at,ut,K.width,K.height)}for(let K=0,ht=Rt.length;K<ht;K++)ct=Rt[K],Ut?P&&e.texSubImage2D(i.TEXTURE_2D,K,0,0,lt,bt,ct):e.texImage2D(i.TEXTURE_2D,K,ut,lt,bt,ct);g.generateMipmaps=!1}else if(Ut){if(Bt){const K=Jt(J);e.texStorage2D(i.TEXTURE_2D,at,ut,K.width,K.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=$(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===Vn?null:qt.getPrimaries(g.colorSpace),J=g.colorSpace===Vn||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,r.maxCubemapSize):ut[j]=bt?g.image[j].image:g.image[j],ut[j]=Be(g,ut[j]);const ct=ut[0],Rt=s.convert(g.format,g.colorSpace),Ut=s.convert(g.type),Bt=M(g.internalFormat,Rt,Ut,g.normalized,g.colorSpace),P=g.isVideoTexture!==!0,at=it.__version===void 0||H===!0,K=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 Mt=mt[Et];g.format!==rn?Rt!==null?P?K&&e.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Et,0,0,Mt.width,Mt.height,Rt,Mt.data):e.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Et,Bt,Mt.width,Mt.height,0,Mt.data):Ft("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):P?K&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Et,0,0,Mt.width,Mt.height,Rt,Ut,Mt.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Et,Bt,Mt.width,Mt.height,0,Rt,Ut,Mt.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?K&&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?K&&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?K&&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 Mt=mt[Et];P?K&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Et+1,0,0,Rt,Ut,Mt.image[j]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Et+1,Bt,Rt,Ut,Mt.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=s.convert(N.format,N.colorSpace),q=s.convert(N.type),J=M(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),xe(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;xe(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=s.convert(it.format,it.colorSpace),q=s.convert(it.type),J=M(it.internalFormat,ot,q,it.normalized,it.colorSpace);xe(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 vt(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=s.convert(g.depthTexture.format),bt=s.convert(g.depthTexture.type);let ut;g.depthTexture.format===Pn?ut=i.DEPTH_COMPONENT24:g.depthTexture.format===si&&(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===si?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(g.depthTexture.format===Pn)xe(g)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,J,q,it,0,ot):i.framebufferTexture2D(i.FRAMEBUFFER,J,q,it,0);else if(g.depthTexture.format===si)xe(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++)vt(g.__webglFramebuffer[H],E,H);else{const H=E.texture.mipmaps;H&&H.length>0?vt(g.__webglFramebuffer[0],E,0):vt(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",x);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&&xe(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=s.convert(J.format,J.colorSpace),bt=s.convert(J.type),ut=M(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 $t(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 Kt=[],ce=[];function oe(E){if(E.samples>0){if(xe(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&&(Kt.length=0,ce.length=0,Kt.push(i.COLOR_ATTACHMENT0+lt),E.depthBuffer&&E.resolveDepthBuffer===!1&&(Kt.push(it),ce.push(it),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,ce)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,Kt))}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(r.maxSamples,E.samples)}function xe(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!==Is&&N!==Vn&&(qt.getTransfer(N)===Qt?(H!==rn||X!==Ke)&&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=rt,this.rebindTextures=Dt,this.setupRenderTarget=Lt,this.updateRenderTargetMipmap=$t,this.updateMultisampleRenderTarget=oe,this.setupDepthRenderbuffer=Nt,this.setupFrameBufferTexture=Pt,this.useMultisampledRTT=xe,this.isReversedDepthBuffer=function(){return e.buffers.depth.getReversed()}}function P_(i,t){function e(n,r=Vn){let s;const a=qt.getTransfer(r);if(n===Ke)return i.UNSIGNED_BYTE;if(n===ll)return i.UNSIGNED_SHORT_4_4_4_4;if(n===cl)return i.UNSIGNED_SHORT_5_5_5_1;if(n===kh)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Vh)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===Gh)return i.BYTE;if(n===Hh)return i.SHORT;if(n===Er)return i.UNSIGNED_SHORT;if(n===ol)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===Wh)return i.ALPHA;if(n===Xh)return i.RGB;if(n===rn)return i.RGBA;if(n===Pn)return i.DEPTH_COMPONENT;if(n===si)return i.DEPTH_STENCIL;if(n===qh)return i.RED;if(n===hl)return i.RED_INTEGER;if(n===ci)return i.RG;if(n===ul)return i.RG_INTEGER;if(n===dl)return i.RGBA_INTEGER;if(n===ys||n===Es||n===bs||n===Ts)if(a===Qt)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===ys)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Es)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===bs)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Ts)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===ys)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Es)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===bs)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Ts)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===so||n===ao||n===oo||n===lo)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===so)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===ao)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===oo)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===lo)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===co||n===ho||n===uo||n===fo||n===po||n===Cs||n===mo)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(n===co||n===ho)return a===Qt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===uo)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(n===fo)return s.COMPRESSED_R11_EAC;if(n===po)return s.COMPRESSED_SIGNED_R11_EAC;if(n===Cs)return s.COMPRESSED_RG11_EAC;if(n===mo)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===go||n===_o||n===xo||n===vo||n===Mo||n===So||n===yo||n===Eo||n===bo||n===To||n===Ao||n===wo||n===Ro||n===Co)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(n===go)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===_o)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===xo)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===vo)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Mo)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===So)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===yo)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Eo)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===bo)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===To)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Ao)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===wo)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Ro)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Co)return a===Qt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Po||n===Io||n===Do)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(n===Po)return a===Qt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Io)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Do)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Lo||n===Uo||n===Ps||n===No)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(n===Lo)return s.COMPRESSED_RED_RGTC1_EXT;if(n===Uo)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Ps)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===No)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===br?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:e}}const I_=`
|
|
4300
4316
|
void main() {
|
|
4301
4317
|
|
|
4302
4318
|
gl_Position = vec4( position, 1.0 );
|
|
4303
4319
|
|
|
4304
|
-
}`,
|
|
4320
|
+
}`,D_=`
|
|
4305
4321
|
uniform sampler2DArray depthColor;
|
|
4306
4322
|
uniform float depthWidth;
|
|
4307
4323
|
uniform float depthHeight;
|
|
@@ -4320,7 +4336,7 @@ void main() {
|
|
|
4320
4336
|
|
|
4321
4337
|
}
|
|
4322
4338
|
|
|
4323
|
-
}`;class Ng{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new c0(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 pn({vertexShader:Lg,fragmentShader:Ug,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Kt(new As(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Fg extends ci{constructor(e,t){super();const n=this;let r=null,s=1,a=null,o="local-floor",l=1,c=null,h=null,f=null,u=null,g=null,_=null;const S=typeof XRWebGLBinding<"u",m=new Ng,d={},A=t.getContextAttributes();let w=null,M=null;const T=[],y=[],R=new Ve;let x=null;const b=new Xt;b.viewport=new dt;const I=new Xt;I.viewport=new dt;const C=[b,I],N=new Wh;let Y=null,K=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let se=T[Z];return se===void 0&&(se=new Hs,T[Z]=se),se.getTargetRaySpace()},this.getControllerGrip=function(Z){let se=T[Z];return se===void 0&&(se=new Hs,T[Z]=se),se.getGripSpace()},this.getHand=function(Z){let se=T[Z];return se===void 0&&(se=new Hs,T[Z]=se),se.getHandSpace()};function O(Z){const se=y.indexOf(Z.inputSource);if(se===-1)return;const ne=T[se];ne!==void 0&&(ne.update(Z.inputSource,Z.frame,c||a),ne.dispatchEvent({type:Z.type,data:Z.inputSource}))}function W(){r.removeEventListener("select",O),r.removeEventListener("selectstart",O),r.removeEventListener("selectend",O),r.removeEventListener("squeeze",O),r.removeEventListener("squeezestart",O),r.removeEventListener("squeezeend",O),r.removeEventListener("end",W),r.removeEventListener("inputsourceschange",H);for(let Z=0;Z<T.length;Z++){const se=y[Z];se!==null&&(y[Z]=null,T[Z].disconnect(se))}Y=null,K=null,m.reset();for(const Z in d)delete d[Z];e.setRenderTarget(w),g=null,u=null,f=null,r=null,M=null,We.stop(),n.isPresenting=!1,e.setPixelRatio(x),e.setSize(R.width,R.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Z){s=Z,n.isPresenting===!0&&Ne("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Z){o=Z,n.isPresenting===!0&&Ne("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(Z){c=Z},this.getBaseLayer=function(){return u!==null?u:g},this.getBinding=function(){return f===null&&S&&(f=new XRWebGLBinding(r,t)),f},this.getFrame=function(){return _},this.getSession=function(){return r},this.setSession=async function(Z){if(r=Z,r!==null){if(w=e.getRenderTarget(),r.addEventListener("select",O),r.addEventListener("selectstart",O),r.addEventListener("selectend",O),r.addEventListener("squeeze",O),r.addEventListener("squeezestart",O),r.addEventListener("squeezeend",O),r.addEventListener("end",W),r.addEventListener("inputsourceschange",H),A.xrCompatible!==!0&&await t.makeXRCompatible(),x=e.getPixelRatio(),e.getSize(R),S&&"createProjectionLayer"in XRWebGLBinding.prototype){let ne=null,G=null,Ce=null;A.depth&&(Ce=A.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ne=A.stencil?ni:Rn,G=A.stencil?hr:dn);const Pe={colorFormat:t.RGBA8,depthFormat:Ce,scaleFactor:s};f=this.getBinding(),u=f.createProjectionLayer(Pe),r.updateRenderState({layers:[u]}),e.setPixelRatio(1),e.setSize(u.textureWidth,u.textureHeight,!1),M=new fn(u.textureWidth,u.textureHeight,{format:en,type:qt,depthTexture:new Gi(u.textureWidth,u.textureHeight,G,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:s};g=new XRWebGLLayer(r,t,ne),r.updateRenderState({baseLayer:g}),e.setPixelRatio(1),e.setSize(g.framebufferWidth,g.framebufferHeight,!1),M=new fn(g.framebufferWidth,g.framebufferHeight,{format:en,type:qt,colorSpace:e.outputColorSpace,stencilBuffer:A.stencil,resolveDepthBuffer:g.ignoreDepthValues===!1,resolveStencilBuffer:g.ignoreDepthValues===!1})}M.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await r.requestReferenceSpace(o),We.setContext(r),We.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function H(Z){for(let se=0;se<Z.removed.length;se++){const ne=Z.removed[se],G=y.indexOf(ne);G>=0&&(y[G]=null,T[G].disconnect(ne))}for(let se=0;se<Z.added.length;se++){const ne=Z.added[se];let G=y.indexOf(ne);if(G===-1){for(let Pe=0;Pe<T.length;Pe++)if(Pe>=y.length){y.push(ne),G=Pe;break}else if(y[Pe]===null){y[Pe]=ne,G=Pe;break}if(G===-1)break}const Ce=T[G];Ce&&Ce.connect(ne)}}const Q=new F,te=new F;function ee(Z,se,ne){Q.setFromMatrixPosition(se.matrixWorld),te.setFromMatrixPosition(ne.matrixWorld);const G=Q.distanceTo(te),Ce=se.projectionMatrix.elements,Pe=ne.projectionMatrix.elements,we=Ce[14]/(Ce[10]-1),ve=Ce[14]/(Ce[10]+1),Ue=(Ce[9]+1)/Ce[5],De=(Ce[9]-1)/Ce[5],Ie=(Ce[8]-1)/Ce[0],Ze=(Pe[8]+1)/Pe[0],$e=we*Ie,ct=we*Ze,ot=G/(-Ie+Ze),ut=ot*-Ie;if(se.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(ut),Z.translateZ(ot),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert(),Ce[10]===-1)Z.projectionMatrix.copy(se.projectionMatrix),Z.projectionMatrixInverse.copy(se.projectionMatrixInverse);else{const _t=we+ot,D=ve+ot,Nt=$e-ut,Je=ct+(G-ut),E=Ue*ve/D*_t,p=De*ve/D*_t;Z.projectionMatrix.makePerspective(Nt,Je,E,p,_t,D),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert()}}function re(Z,se){se===null?Z.matrixWorld.copy(Z.matrix):Z.matrixWorld.multiplyMatrices(se.matrixWorld,Z.matrix),Z.matrixWorldInverse.copy(Z.matrixWorld).invert()}this.updateCamera=function(Z){if(r===null)return;let se=Z.near,ne=Z.far;m.texture!==null&&(m.depthNear>0&&(se=m.depthNear),m.depthFar>0&&(ne=m.depthFar)),N.near=I.near=b.near=se,N.far=I.far=b.far=ne,(Y!==N.near||K!==N.far)&&(r.updateRenderState({depthNear:N.near,depthFar:N.far}),Y=N.near,K=N.far),N.layers.mask=Z.layers.mask|6,b.layers.mask=N.layers.mask&-5,I.layers.mask=N.layers.mask&-3;const G=Z.parent,Ce=N.cameras;re(N,G);for(let Pe=0;Pe<Ce.length;Pe++)re(Ce[Pe],G);Ce.length===2?ee(N,b,I):N.projectionMatrix.copy(b.projectionMatrix),ge(Z,N,G)};function ge(Z,se,ne){ne===null?Z.matrix.copy(se.matrixWorld):(Z.matrix.copy(ne.matrixWorld),Z.matrix.invert(),Z.matrix.multiply(se.matrixWorld)),Z.matrix.decompose(Z.position,Z.quaternion,Z.scale),Z.updateMatrixWorld(!0),Z.projectionMatrix.copy(se.projectionMatrix),Z.projectionMatrixInverse.copy(se.projectionMatrixInverse),Z.isPerspectiveCamera&&(Z.fov=fo*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1)}this.getCamera=function(){return N},this.getFoveation=function(){if(!(u===null&&g===null))return l},this.setFoveation=function(Z){l=Z,u!==null&&(u.fixedFoveation=Z),g!==null&&g.fixedFoveation!==void 0&&(g.fixedFoveation=Z)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(N)},this.getCameraTexture=function(Z){return d[Z]};let He=null;function rt(Z,se){if(h=se.getViewerPose(c||a),_=se,h!==null){const ne=h.views;g!==null&&(e.setRenderTargetFramebuffer(M,g.framebuffer),e.setRenderTarget(M));let G=!1;ne.length!==N.cameras.length&&(N.cameras.length=0,G=!0);for(let ve=0;ve<ne.length;ve++){const Ue=ne[ve];let De=null;if(g!==null)De=g.getViewport(Ue);else{const Ze=f.getViewSubImage(u,Ue);De=Ze.viewport,ve===0&&(e.setRenderTargetTextures(M,Ze.colorTexture,Ze.depthStencilTexture),e.setRenderTarget(M))}let Ie=C[ve];Ie===void 0&&(Ie=new Xt,Ie.layers.enable(ve),Ie.viewport=new dt,C[ve]=Ie),Ie.matrix.fromArray(Ue.transform.matrix),Ie.matrix.decompose(Ie.position,Ie.quaternion,Ie.scale),Ie.projectionMatrix.fromArray(Ue.projectionMatrix),Ie.projectionMatrixInverse.copy(Ie.projectionMatrix).invert(),Ie.viewport.set(De.x,De.y,De.width,De.height),ve===0&&(N.matrix.copy(Ie.matrix),N.matrix.decompose(N.position,N.quaternion,N.scale)),G===!0&&N.cameras.push(Ie)}const Ce=r.enabledFeatures;if(Ce&&Ce.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&S){f=n.getBinding();const ve=f.getDepthInformation(ne[0]);ve&&ve.isValid&&ve.texture&&m.init(ve,r.renderState)}if(Ce&&Ce.includes("camera-access")&&S){e.state.unbindTexture(),f=n.getBinding();for(let ve=0;ve<ne.length;ve++){const Ue=ne[ve].camera;if(Ue){let De=d[Ue];De||(De=new c0,d[Ue]=De);const Ie=f.getCameraImage(Ue);De.sourceTexture=Ie}}}}for(let ne=0;ne<T.length;ne++){const G=y[ne],Ce=T[ne];G!==null&&Ce!==void 0&&Ce.update(G,se,c||a)}He&&He(Z,se),se.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:se}),_=null}const We=new p0;We.setAnimationLoop(rt),this.setAnimationLoop=function(Z){He=Z},this.dispose=function(){}}}const Og=new lt,S0=new Fe;S0.set(-1,0,0,0,1,0,0,0,1);function Bg(i,e){function t(m,d){m.matrixAutoUpdate===!0&&m.updateMatrix(),d.value.copy(m.matrix)}function n(m,d){d.color.getRGB(m.fogColor.value,u0(i)),d.isFog?(m.fogNear.value=d.near,m.fogFar.value=d.far):d.isFogExp2&&(m.fogDensity.value=d.density)}function r(m,d,A,w,M){d.isNodeMaterial?d.uniformsNeedUpdate=!1:d.isMeshBasicMaterial?s(m,d):d.isMeshLambertMaterial?(s(m,d),d.envMap&&(m.envMapIntensity.value=d.envMapIntensity)):d.isMeshToonMaterial?(s(m,d),f(m,d)):d.isMeshPhongMaterial?(s(m,d),h(m,d),d.envMap&&(m.envMapIntensity.value=d.envMapIntensity)):d.isMeshStandardMaterial?(s(m,d),u(m,d),d.isMeshPhysicalMaterial&&g(m,d,M)):d.isMeshMatcapMaterial?(s(m,d),_(m,d)):d.isMeshDepthMaterial?s(m,d):d.isMeshDistanceMaterial?(s(m,d),S(m,d)):d.isMeshNormalMaterial?s(m,d):d.isLineBasicMaterial?(a(m,d),d.isLineDashedMaterial&&o(m,d)):d.isPointsMaterial?l(m,d,A,w):d.isSpriteMaterial?c(m,d):d.isShadowMaterial?(m.color.value.copy(d.color),m.opacity.value=d.opacity):d.isShaderMaterial&&(d.uniformsNeedUpdate=!1)}function s(m,d){m.opacity.value=d.opacity,d.color&&m.diffuse.value.copy(d.color),d.emissive&&m.emissive.value.copy(d.emissive).multiplyScalar(d.emissiveIntensity),d.map&&(m.map.value=d.map,t(d.map,m.mapTransform)),d.alphaMap&&(m.alphaMap.value=d.alphaMap,t(d.alphaMap,m.alphaMapTransform)),d.bumpMap&&(m.bumpMap.value=d.bumpMap,t(d.bumpMap,m.bumpMapTransform),m.bumpScale.value=d.bumpScale,d.side===Lt&&(m.bumpScale.value*=-1)),d.normalMap&&(m.normalMap.value=d.normalMap,t(d.normalMap,m.normalMapTransform),m.normalScale.value.copy(d.normalScale),d.side===Lt&&m.normalScale.value.negate()),d.displacementMap&&(m.displacementMap.value=d.displacementMap,t(d.displacementMap,m.displacementMapTransform),m.displacementScale.value=d.displacementScale,m.displacementBias.value=d.displacementBias),d.emissiveMap&&(m.emissiveMap.value=d.emissiveMap,t(d.emissiveMap,m.emissiveMapTransform)),d.specularMap&&(m.specularMap.value=d.specularMap,t(d.specularMap,m.specularMapTransform)),d.alphaTest>0&&(m.alphaTest.value=d.alphaTest);const A=e.get(d),w=A.envMap,M=A.envMapRotation;w&&(m.envMap.value=w,m.envMapRotation.value.setFromMatrix4(Og.makeRotationFromEuler(M)).transpose(),w.isCubeTexture&&w.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(S0),m.reflectivity.value=d.reflectivity,m.ior.value=d.ior,m.refractionRatio.value=d.refractionRatio),d.lightMap&&(m.lightMap.value=d.lightMap,m.lightMapIntensity.value=d.lightMapIntensity,t(d.lightMap,m.lightMapTransform)),d.aoMap&&(m.aoMap.value=d.aoMap,m.aoMapIntensity.value=d.aoMapIntensity,t(d.aoMap,m.aoMapTransform))}function a(m,d){m.diffuse.value.copy(d.color),m.opacity.value=d.opacity,d.map&&(m.map.value=d.map,t(d.map,m.mapTransform))}function o(m,d){m.dashSize.value=d.dashSize,m.totalSize.value=d.dashSize+d.gapSize,m.scale.value=d.scale}function l(m,d,A,w){m.diffuse.value.copy(d.color),m.opacity.value=d.opacity,m.size.value=d.size*A,m.scale.value=w*.5,d.map&&(m.map.value=d.map,t(d.map,m.uvTransform)),d.alphaMap&&(m.alphaMap.value=d.alphaMap,t(d.alphaMap,m.alphaMapTransform)),d.alphaTest>0&&(m.alphaTest.value=d.alphaTest)}function c(m,d){m.diffuse.value.copy(d.color),m.opacity.value=d.opacity,m.rotation.value=d.rotation,d.map&&(m.map.value=d.map,t(d.map,m.mapTransform)),d.alphaMap&&(m.alphaMap.value=d.alphaMap,t(d.alphaMap,m.alphaMapTransform)),d.alphaTest>0&&(m.alphaTest.value=d.alphaTest)}function h(m,d){m.specular.value.copy(d.specular),m.shininess.value=Math.max(d.shininess,1e-4)}function f(m,d){d.gradientMap&&(m.gradientMap.value=d.gradientMap)}function u(m,d){m.metalness.value=d.metalness,d.metalnessMap&&(m.metalnessMap.value=d.metalnessMap,t(d.metalnessMap,m.metalnessMapTransform)),m.roughness.value=d.roughness,d.roughnessMap&&(m.roughnessMap.value=d.roughnessMap,t(d.roughnessMap,m.roughnessMapTransform)),d.envMap&&(m.envMapIntensity.value=d.envMapIntensity)}function g(m,d,A){m.ior.value=d.ior,d.sheen>0&&(m.sheenColor.value.copy(d.sheenColor).multiplyScalar(d.sheen),m.sheenRoughness.value=d.sheenRoughness,d.sheenColorMap&&(m.sheenColorMap.value=d.sheenColorMap,t(d.sheenColorMap,m.sheenColorMapTransform)),d.sheenRoughnessMap&&(m.sheenRoughnessMap.value=d.sheenRoughnessMap,t(d.sheenRoughnessMap,m.sheenRoughnessMapTransform))),d.clearcoat>0&&(m.clearcoat.value=d.clearcoat,m.clearcoatRoughness.value=d.clearcoatRoughness,d.clearcoatMap&&(m.clearcoatMap.value=d.clearcoatMap,t(d.clearcoatMap,m.clearcoatMapTransform)),d.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=d.clearcoatRoughnessMap,t(d.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),d.clearcoatNormalMap&&(m.clearcoatNormalMap.value=d.clearcoatNormalMap,t(d.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(d.clearcoatNormalScale),d.side===Lt&&m.clearcoatNormalScale.value.negate())),d.dispersion>0&&(m.dispersion.value=d.dispersion),d.iridescence>0&&(m.iridescence.value=d.iridescence,m.iridescenceIOR.value=d.iridescenceIOR,m.iridescenceThicknessMinimum.value=d.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=d.iridescenceThicknessRange[1],d.iridescenceMap&&(m.iridescenceMap.value=d.iridescenceMap,t(d.iridescenceMap,m.iridescenceMapTransform)),d.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=d.iridescenceThicknessMap,t(d.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),d.transmission>0&&(m.transmission.value=d.transmission,m.transmissionSamplerMap.value=A.texture,m.transmissionSamplerSize.value.set(A.width,A.height),d.transmissionMap&&(m.transmissionMap.value=d.transmissionMap,t(d.transmissionMap,m.transmissionMapTransform)),m.thickness.value=d.thickness,d.thicknessMap&&(m.thicknessMap.value=d.thicknessMap,t(d.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=d.attenuationDistance,m.attenuationColor.value.copy(d.attenuationColor)),d.anisotropy>0&&(m.anisotropyVector.value.set(d.anisotropy*Math.cos(d.anisotropyRotation),d.anisotropy*Math.sin(d.anisotropyRotation)),d.anisotropyMap&&(m.anisotropyMap.value=d.anisotropyMap,t(d.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=d.specularIntensity,m.specularColor.value.copy(d.specularColor),d.specularColorMap&&(m.specularColorMap.value=d.specularColorMap,t(d.specularColorMap,m.specularColorMapTransform)),d.specularIntensityMap&&(m.specularIntensityMap.value=d.specularIntensityMap,t(d.specularIntensityMap,m.specularIntensityMapTransform))}function _(m,d){d.matcap&&(m.matcap.value=d.matcap)}function S(m,d){const A=e.get(d).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:r}}function zg(i,e,t,n){let r={},s={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(M,T){const y=T.program;n.uniformBlockBinding(M,y)}function c(M,T){let y=r[M.id];y===void 0&&(m(M),y=h(M),r[M.id]=y,M.addEventListener("dispose",A));const R=T.program;n.updateUBOMapping(M,R);const x=e.render.frame;s[M.id]!==x&&(u(M),s[M.id]=x)}function h(M){const T=f();M.__bindingPointIndex=T;const y=i.createBuffer(),R=M.__size,x=M.usage;return i.bindBuffer(i.UNIFORM_BUFFER,y),i.bufferData(i.UNIFORM_BUFFER,R,x),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,T,y),y}function f(){for(let M=0;M<o;M++)if(a.indexOf(M)===-1)return a.push(M),M;return Xe("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(M){const T=r[M.id],y=M.uniforms,R=M.__cache;i.bindBuffer(i.UNIFORM_BUFFER,T);for(let x=0,b=y.length;x<b;x++){const I=y[x];if(Array.isArray(I))for(let C=0,N=I.length;C<N;C++)g(I[C],x,C,R);else g(I,x,0,R)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function g(M,T,y,R){if(S(M,T,y,R)===!0){const x=M.__offset,b=M.value;if(Array.isArray(b)){let I=0;for(let C=0;C<b.length;C++){const N=b[C],Y=d(N);_(N,M.__data,I),typeof N!="number"&&typeof N!="boolean"&&!N.isMatrix3&&!ArrayBuffer.isView(N)&&(I+=Y.storage/Float32Array.BYTES_PER_ELEMENT)}}else _(b,M.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,x,M.__data)}}function _(M,T,y){typeof M=="number"||typeof M=="boolean"?T[0]=M:M.isMatrix3?(T[0]=M.elements[0],T[1]=M.elements[1],T[2]=M.elements[2],T[3]=0,T[4]=M.elements[3],T[5]=M.elements[4],T[6]=M.elements[5],T[7]=0,T[8]=M.elements[6],T[9]=M.elements[7],T[10]=M.elements[8],T[11]=0):ArrayBuffer.isView(M)?T.set(new M.constructor(M.buffer,M.byteOffset,T.length)):M.toArray(T,y)}function S(M,T,y,R){const x=M.value,b=T+"_"+y;if(R[b]===void 0)return typeof x=="number"||typeof x=="boolean"?R[b]=x:ArrayBuffer.isView(x)?R[b]=x.slice():R[b]=x.clone(),!0;{const I=R[b];if(typeof x=="number"||typeof x=="boolean"){if(I!==x)return R[b]=x,!0}else{if(ArrayBuffer.isView(x))return!0;if(I.equals(x)===!1)return I.copy(x),!0}}return!1}function m(M){const T=M.uniforms;let y=0;const R=16;for(let b=0,I=T.length;b<I;b++){const C=Array.isArray(T[b])?T[b]:[T[b]];for(let N=0,Y=C.length;N<Y;N++){const K=C[N],O=Array.isArray(K.value)?K.value:[K.value];for(let W=0,H=O.length;W<H;W++){const Q=O[W],te=d(Q),ee=y%R,re=ee%te.boundary,ge=ee+re;y+=re,ge!==0&&R-ge<te.storage&&(y+=R-ge),K.__data=new Float32Array(te.storage/Float32Array.BYTES_PER_ELEMENT),K.__offset=y,y+=te.storage}}}const x=y%R;return x>0&&(y+=R-x),M.__size=y,M.__cache={},this}function d(M){const T={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(T.boundary=4,T.storage=4):M.isVector2?(T.boundary=8,T.storage=8):M.isVector3||M.isColor?(T.boundary=16,T.storage=12):M.isVector4?(T.boundary=16,T.storage=16):M.isMatrix3?(T.boundary=48,T.storage=48):M.isMatrix4?(T.boundary=64,T.storage=64):M.isTexture?Ne("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(T.boundary=16,T.storage=M.byteLength):Ne("WebGLRenderer: Unsupported uniform value type.",M),T}function A(M){const T=M.target;T.removeEventListener("dispose",A);const y=a.indexOf(T.__bindingPointIndex);a.splice(y,1),i.deleteBuffer(r[T.id]),delete r[T.id],delete s[T.id]}function w(){for(const M in r)i.deleteBuffer(r[M]);a=[],r={},s={}}return{bind:l,update:c,dispose:w}}const Gg=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 an=null;function Vg(){return an===null&&(an=new Ph(Gg,16,16,ai,wn),an.name="DFG_LUT",an.minFilter=Rt,an.magFilter=Rt,an.wrapS=yn,an.wrapT=yn,an.generateMipmaps=!1,an.needsUpdate=!0),an}class kg{constructor(e={}){const{canvas:t=ah(),context:n=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:u=!1,outputBufferType:g=qt}=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 S=g,m=new Set([ko,Vo,Go]),d=new Set([qt,dn,ur,hr,Bo,zo]),A=new Uint32Array(4),w=new Int32Array(4),M=new F;let T=null,y=null;const R=[],x=[];let b=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=hn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const I=this;let C=!1,N=null,Y=null,K=null,O=null;this._outputColorSpace=Wt;let W=0,H=0,Q=null,te=-1,ee=null;const re=new dt,ge=new dt;let He=null;const rt=new Oe(0);let We=0,Z=t.width,se=t.height,ne=1,G=null,Ce=null;const Pe=new dt(0,0,Z,se),we=new dt(0,0,Z,se);let ve=!1;const Ue=new a0;let De=!1,Ie=!1;const Ze=new lt,$e=new F,ct=new dt,ot={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ut=!1;function _t(){return Q===null?ne:1}let D=n;function Nt(v,L){return t.getContext(v,L)}try{const v={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:f};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Fo}`),t.addEventListener("webglcontextlost",ht,!1),t.addEventListener("webglcontextrestored",st,!1),t.addEventListener("webglcontextcreationerror",tn,!1),D===null){const L="webgl2";if(D=Nt(L,v),D===null)throw Nt(L)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(v){throw Xe("WebGLRenderer: "+v.message),v}let Je,E,p,U,V,X,ie,oe,q,J,le,be,he,ce,Re,Le,Be,P,ae,$,ue,me,j;function ye(){Je=new Vp(D),Je.init(),ue=new Ig(D,Je),E=new Lp(D,Je,e,ue),p=new Pg(D,Je),E.reversedDepthBuffer&&u&&p.buffers.depth.setReversed(!0),Y=D.createFramebuffer(),K=D.createFramebuffer(),O=D.createFramebuffer(),U=new Wp(D),V=new gg,X=new Dg(D,Je,p,V,E,ue,U),ie=new Gp(I),oe=new Yh(D),me=new Dp(D,oe),q=new kp(D,oe,U,me),J=new qp(D,q,oe,me,U),P=new Xp(D,E,X),Re=new Up(V),le=new mg(I,ie,Je,E,me,Re),be=new Bg(I,V),he=new xg,ce=new bg(Je),Be=new Pp(I,ie,p,J,_,l),Le=new Cg(I,J,E),j=new zg(D,U,E,p),ae=new Ip(D,Je,U),$=new Hp(D,Je,U),U.programs=le.programs,I.capabilities=E,I.extensions=Je,I.properties=V,I.renderLists=he,I.shadowMap=Le,I.state=p,I.info=U}ye(),S!==qt&&(b=new Kp(S,t.width,t.height,o,r,s));const Me=new Fg(I,D);this.xr=Me,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){const v=Je.get("WEBGL_lose_context");v&&v.loseContext()},this.forceContextRestore=function(){const v=Je.get("WEBGL_lose_context");v&&v.restoreContext()},this.getPixelRatio=function(){return ne},this.setPixelRatio=function(v){v!==void 0&&(ne=v,this.setSize(Z,se,!1))},this.getSize=function(v){return v.set(Z,se)},this.setSize=function(v,L,k=!0){if(Me.isPresenting){Ne("WebGLRenderer: Can't change size while VR device is presenting.");return}Z=v,se=L,t.width=Math.floor(v*ne),t.height=Math.floor(L*ne),k===!0&&(t.style.width=v+"px",t.style.height=L+"px"),b!==null&&b.setSize(t.width,t.height),this.setViewport(0,0,v,L)},this.getDrawingBufferSize=function(v){return v.set(Z*ne,se*ne).floor()},this.setDrawingBufferSize=function(v,L,k){Z=v,se=L,ne=k,t.width=Math.floor(v*k),t.height=Math.floor(L*k),this.setViewport(0,0,v,L)},this.setEffects=function(v){if(S===qt){Xe("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(v){for(let L=0;L<v.length;L++)if(v[L].isOutputPass===!0){Ne("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}b.setEffects(v||[])},this.getCurrentViewport=function(v){return v.copy(re)},this.getViewport=function(v){return v.copy(Pe)},this.setViewport=function(v,L,k,B){v.isVector4?Pe.set(v.x,v.y,v.z,v.w):Pe.set(v,L,k,B),p.viewport(re.copy(Pe).multiplyScalar(ne).round())},this.getScissor=function(v){return v.copy(we)},this.setScissor=function(v,L,k,B){v.isVector4?we.set(v.x,v.y,v.z,v.w):we.set(v,L,k,B),p.scissor(ge.copy(we).multiplyScalar(ne).round())},this.getScissorTest=function(){return ve},this.setScissorTest=function(v){p.setScissorTest(ve=v)},this.setOpaqueSort=function(v){G=v},this.setTransparentSort=function(v){Ce=v},this.getClearColor=function(v){return v.copy(Be.getClearColor())},this.setClearColor=function(){Be.setClearColor(...arguments)},this.getClearAlpha=function(){return Be.getClearAlpha()},this.setClearAlpha=function(){Be.setClearAlpha(...arguments)},this.clear=function(v=!0,L=!0,k=!0){let B=0;if(v){let z=!1;if(Q!==null){const pe=Q.texture.format;z=m.has(pe)}if(z){const pe=Q.texture.type,xe=d.has(pe),de=Be.getClearColor(),Se=Be.getClearAlpha(),Te=de.r,ze=de.g,ke=de.b;xe?(A[0]=Te,A[1]=ze,A[2]=ke,A[3]=Se,D.clearBufferuiv(D.COLOR,0,A)):(w[0]=Te,w[1]=ze,w[2]=ke,w[3]=Se,D.clearBufferiv(D.COLOR,0,w))}else B|=D.COLOR_BUFFER_BIT}L&&(B|=D.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),k&&(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(v){v.setRenderer(this),N=v},this.dispose=function(){t.removeEventListener("webglcontextlost",ht,!1),t.removeEventListener("webglcontextrestored",st,!1),t.removeEventListener("webglcontextcreationerror",tn,!1),Be.dispose(),he.dispose(),ce.dispose(),V.dispose(),ie.dispose(),J.dispose(),me.dispose(),j.dispose(),le.dispose(),Me.dispose(),Me.removeEventListener("sessionstart",nl),Me.removeEventListener("sessionend",il),qn.stop()};function ht(v){v.preventDefault(),ps("WebGLRenderer: Context Lost."),C=!0}function st(){ps("WebGLRenderer: Context Restored."),C=!1;const v=U.autoReset,L=Le.enabled,k=Le.autoUpdate,B=Le.needsUpdate,z=Le.type;ye(),U.autoReset=v,Le.enabled=L,Le.autoUpdate=k,Le.needsUpdate=B,Le.type=z}function tn(v){Xe("WebGLRenderer: A WebGL context could not be created. Reason: ",v.statusMessage)}function nn(v){const L=v.target;L.removeEventListener("dispose",nn),V0(L)}function V0(v){k0(v),V.remove(v)}function k0(v){const L=V.get(v).programs;L!==void 0&&(L.forEach(function(k){le.releaseProgram(k)}),v.isShaderMaterial&&le.releaseShaderCache(v))}this.renderBufferDirect=function(v,L,k,B,z,pe){L===null&&(L=ot);const xe=z.isMesh&&z.matrixWorld.determinantAffine()<0,de=X0(v,L,k,B,z);p.setMaterial(B,xe);let Se=k.index,Te=1;if(B.wireframe===!0){if(Se=q.getWireframeAttribute(k),Se===void 0)return;Te=2}const ze=k.drawRange,ke=k.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)),Se!==null?(Ae=Math.max(Ae,0),je=Math.min(je,Se.count)):ke!=null&&(Ae=Math.max(Ae,0),je=Math.min(je,ke.count));const pt=je-Ae;if(pt<0||pt===1/0)return;me.setup(z,B,de,k,Se);let ft,tt=ae;if(Se!==null&&(ft=oe.get(Se),tt=$,tt.setIndex(ft)),z.isMesh)B.wireframe===!0?(p.setLineWidth(B.wireframeLinewidth*_t()),tt.setMode(D.LINES)):tt.setMode(D.TRIANGLES);else if(z.isLine){let bt=B.linewidth;bt===void 0&&(bt=1),p.setLineWidth(bt*_t()),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 bt=z._multiDrawStarts,_e=z._multiDrawCounts,Ot=z._multiDrawCount,Ke=Se?oe.get(Se).bytesPerElement:1,Vt=V.get(B).currentProgram.getUniforms();for(let rn=0;rn<Ot;rn++)Vt.setValue(D,"_gl_DrawID",rn),tt.render(bt[rn]/Ke,_e[rn])}else if(z.isInstancedMesh)tt.renderInstances(Ae,pt,z.count);else if(k.isInstancedBufferGeometry){const bt=k._maxInstanceCount!==void 0?k._maxInstanceCount:1/0,_e=Math.min(k.instanceCount,bt);tt.renderInstances(Ae,pt,_e)}else tt.render(Ae,pt)};function tl(v,L,k){v.transparent===!0&&v.side===En&&v.forceSinglePass===!1?(v.side=Lt,v.needsUpdate=!0,gr(v,L,k),v.side=Xn,v.needsUpdate=!0,gr(v,L,k),v.side=En):gr(v,L,k)}this.compile=function(v,L,k=null){k===null&&(k=v),y=ce.get(k),y.init(L),x.push(y),k.traverseVisible(function(z){z.isLight&&z.layers.test(L.layers)&&(y.pushLight(z),z.castShadow&&y.pushShadow(z))}),v!==k&&v.traverseVisible(function(z){z.isLight&&z.layers.test(L.layers)&&(y.pushLight(z),z.castShadow&&y.pushShadow(z))}),y.setupLights();const B=new Set;return v.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 xe=0;xe<pe.length;xe++){const de=pe[xe];tl(de,k,z),B.add(de)}else tl(pe,k,z),B.add(pe)}),y=x.pop(),B},this.compileAsync=function(v,L,k=null){const B=this.compile(v,L,k);return new Promise(z=>{function pe(){if(B.forEach(function(xe){V.get(xe).currentProgram.isReady()&&B.delete(xe)}),B.size===0){z(v);return}setTimeout(pe,10)}Je.get("KHR_parallel_shader_compile")!==null?pe():setTimeout(pe,10)})};let Ds=null;function H0(v){Ds&&Ds(v)}function nl(){qn.stop()}function il(){qn.start()}const qn=new p0;qn.setAnimationLoop(H0),typeof self<"u"&&qn.setContext(self),this.setAnimationLoop=function(v){Ds=v,Me.setAnimationLoop(v),v===null?qn.stop():qn.start()},Me.addEventListener("sessionstart",nl),Me.addEventListener("sessionend",il),this.render=function(v,L){if(L!==void 0&&L.isCamera!==!0){Xe("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;N!==null&&N.renderStart(v,L);const k=Me.enabled===!0&&Me.isPresenting===!0,B=b!==null&&(Q===null||k)&&b.begin(I,Q);if(v.matrixWorldAutoUpdate===!0&&v.updateMatrixWorld(),L.parent===null&&L.matrixWorldAutoUpdate===!0&&L.updateMatrixWorld(),Me.enabled===!0&&Me.isPresenting===!0&&(b===null||b.isCompositing()===!1)&&(Me.cameraAutoUpdate===!0&&Me.updateCamera(L),L=Me.getCamera()),v.isScene===!0&&v.onBeforeRender(I,v,L,Q),y=ce.get(v,x.length),y.init(L),y.state.textureUnits=X.getTextureUnits(),x.push(y),Ze.multiplyMatrices(L.projectionMatrix,L.matrixWorldInverse),Ue.setFromProjectionMatrix(Ze,un,L.reversedDepth),Ie=this.localClippingEnabled,De=Re.init(this.clippingPlanes,Ie),T=he.get(v,R.length),T.init(),R.push(T),Me.enabled===!0&&Me.isPresenting===!0){const xe=I.xr.getDepthSensingMesh();xe!==null&&Is(xe,L,-1/0,I.sortObjects)}Is(v,L,0,I.sortObjects),T.finish(),I.sortObjects===!0&&T.sort(G,Ce,L.reversedDepth),ut=Me.enabled===!1||Me.isPresenting===!1||Me.hasDepthSensing()===!1,ut&&Be.addToRenderList(T,v),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),De===!0&&Re.beginShadows();const z=y.state.shadowsArray;if(Le.render(z,v,L),De===!0&&Re.endShadows(),(B&&b.hasRenderPass())===!1){const xe=T.opaque,de=T.transmissive;if(y.setupLights(),L.isArrayCamera){const Se=L.cameras;if(de.length>0)for(let Te=0,ze=Se.length;Te<ze;Te++){const ke=Se[Te];sl(xe,de,v,ke)}ut&&Be.render(v);for(let Te=0,ze=Se.length;Te<ze;Te++){const ke=Se[Te];rl(T,v,ke,ke.viewport)}}else de.length>0&&sl(xe,de,v,L),ut&&Be.render(v),rl(T,v,L)}Q!==null&&H===0&&(X.updateMultisampleRenderTarget(Q),X.updateRenderTargetMipmap(Q)),B&&b.end(I),v.isScene===!0&&v.onAfterRender(I,v,L),me.resetDefaultState(),te=-1,ee=null,x.pop(),x.length>0?(y=x[x.length-1],X.setTextureUnits(y.state.textureUnits),De===!0&&Re.setGlobalState(I.clippingPlanes,y.state.camera)):y=null,R.pop(),R.length>0?T=R[R.length-1]:T=null,N!==null&&N.renderEnd()};function Is(v,L,k,B){if(v.visible===!1)return;if(v.layers.test(L.layers)){if(v.isGroup)k=v.renderOrder;else if(v.isLOD)v.autoUpdate===!0&&v.update(L);else if(v.isLightProbeGrid)y.pushLightProbeGrid(v);else if(v.isLight)y.pushLight(v),v.castShadow&&y.pushShadow(v);else if(v.isSprite){if(!v.frustumCulled||Ue.intersectsSprite(v)){B&&ct.setFromMatrixPosition(v.matrixWorld).applyMatrix4(Ze);const xe=J.update(v),de=v.material;de.visible&&T.push(v,xe,de,k,ct.z,null)}}else if((v.isMesh||v.isLine||v.isPoints)&&(!v.frustumCulled||Ue.intersectsObject(v))){const xe=J.update(v),de=v.material;if(B&&(v.boundingSphere!==void 0?(v.boundingSphere===null&&v.computeBoundingSphere(),ct.copy(v.boundingSphere.center)):(xe.boundingSphere===null&&xe.computeBoundingSphere(),ct.copy(xe.boundingSphere.center)),ct.applyMatrix4(v.matrixWorld).applyMatrix4(Ze)),Array.isArray(de)){const Se=xe.groups;for(let Te=0,ze=Se.length;Te<ze;Te++){const ke=Se[Te],Ae=de[ke.materialIndex];Ae&&Ae.visible&&T.push(v,xe,Ae,k,ct.z,ke)}}else de.visible&&T.push(v,xe,de,k,ct.z,null)}}const pe=v.children;for(let xe=0,de=pe.length;xe<de;xe++)Is(pe[xe],L,k,B)}function rl(v,L,k,B){const{opaque:z,transmissive:pe,transparent:xe}=v;y.setupLightsView(k),De===!0&&Re.setGlobalState(I.clippingPlanes,k),B&&p.viewport(re.copy(B)),z.length>0&&mr(z,L,k),pe.length>0&&mr(pe,L,k),xe.length>0&&mr(xe,L,k),p.buffers.depth.setTest(!0),p.buffers.depth.setMask(!0),p.buffers.color.setMask(!0),p.setPolygonOffset(!1)}function sl(v,L,k,B){if((k.isScene===!0?k.overrideMaterial:null)!==null)return;if(y.state.transmissionRenderTarget[B.id]===void 0){const Ae=Je.has("EXT_color_buffer_half_float")||Je.has("EXT_color_buffer_float");y.state.transmissionRenderTarget[B.id]=new fn(1,1,{generateMipmaps:!0,type:Ae?wn:qt,minFilter:ti,samples:Math.max(4,E.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:qe.workingColorSpace})}const pe=y.state.transmissionRenderTarget[B.id],xe=B.viewport||re;pe.setSize(xe.z*I.transmissionResolutionScale,xe.w*I.transmissionResolutionScale);const de=I.getRenderTarget(),Se=I.getActiveCubeFace(),Te=I.getActiveMipmapLevel();I.setRenderTarget(pe),I.getClearColor(rt),We=I.getClearAlpha(),We<1&&I.setClearColor(16777215,.5),I.clear(),ut&&Be.render(k);const ze=I.toneMapping;I.toneMapping=hn;const ke=B.viewport;if(B.viewport!==void 0&&(B.viewport=void 0),y.setupLightsView(B),De===!0&&Re.setGlobalState(I.clippingPlanes,B),mr(v,k,B),X.updateMultisampleRenderTarget(pe),X.updateRenderTargetMipmap(pe),Je.has("WEBGL_multisampled_render_to_texture")===!1){let Ae=!1;for(let je=0,pt=L.length;je<pt;je++){const ft=L[je],{object:tt,geometry:bt,material:_e,group:Ot}=ft;if(_e.side===En&&tt.layers.test(B.layers)){const Ke=_e.side;_e.side=Lt,_e.needsUpdate=!0,al(tt,k,B,bt,_e,Ot),_e.side=Ke,_e.needsUpdate=!0,Ae=!0}}Ae===!0&&(X.updateMultisampleRenderTarget(pe),X.updateRenderTargetMipmap(pe))}I.setRenderTarget(de,Se,Te),I.setClearColor(rt,We),ke!==void 0&&(B.viewport=ke),I.toneMapping=ze}function mr(v,L,k){const B=L.isScene===!0?L.overrideMaterial:null;for(let z=0,pe=v.length;z<pe;z++){const xe=v[z],{object:de,geometry:Se,group:Te}=xe;let ze=xe.material;ze.allowOverride===!0&&B!==null&&(ze=B),de.layers.test(k.layers)&&al(de,L,k,Se,ze,Te)}}function al(v,L,k,B,z,pe){v.onBeforeRender(I,L,k,B,z,pe),v.modelViewMatrix.multiplyMatrices(k.matrixWorldInverse,v.matrixWorld),v.normalMatrix.getNormalMatrix(v.modelViewMatrix),z.onBeforeRender(I,L,k,B,v,pe),z.transparent===!0&&z.side===En&&z.forceSinglePass===!1?(z.side=Lt,z.needsUpdate=!0,I.renderBufferDirect(k,L,B,z,v,pe),z.side=Xn,z.needsUpdate=!0,I.renderBufferDirect(k,L,B,z,v,pe),z.side=En):I.renderBufferDirect(k,L,B,z,v,pe),v.onAfterRender(I,L,k,B,z,pe)}function gr(v,L,k){L.isScene!==!0&&(L=ot);const B=V.get(v),z=y.state.lights,pe=y.state.shadowsArray,xe=z.state.version,de=le.getParameters(v,z.state,pe,L,k,y.state.lightProbeGridArray),Se=le.getProgramCacheKey(de);let Te=B.programs;B.environment=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?L.environment:null,B.fog=L.fog;const ze=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap;B.envMap=ie.get(v.envMap||B.environment,ze),B.envMapRotation=B.environment!==null&&v.envMap===null?L.environmentRotation:v.envMapRotation,Te===void 0&&(v.addEventListener("dispose",nn),Te=new Map,B.programs=Te);let ke=Te.get(Se);if(ke!==void 0){if(B.currentProgram===ke&&B.lightsStateVersion===xe)return ll(v,de),ke}else de.uniforms=le.getUniforms(v),N!==null&&v.isNodeMaterial&&N.build(v,k,de),v.onBeforeCompile(de,I),ke=le.acquireProgram(de,Se),Te.set(Se,ke),B.uniforms=de.uniforms;const Ae=B.uniforms;return(!v.isShaderMaterial&&!v.isRawShaderMaterial||v.clipping===!0)&&(Ae.clippingPlanes=Re.uniform),ll(v,de),B.needsLights=Y0(v),B.lightsStateVersion=xe,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=y.state.lightProbeGridArray.length>0,B.currentProgram=ke,B.uniformsList=null,ke}function ol(v){if(v.uniformsList===null){const L=v.currentProgram.getUniforms();v.uniformsList=as.seqWithValue(L.seq,v.uniforms)}return v.uniformsList}function ll(v,L){const k=V.get(v);k.outputColorSpace=L.outputColorSpace,k.batching=L.batching,k.batchingColor=L.batchingColor,k.instancing=L.instancing,k.instancingColor=L.instancingColor,k.instancingMorph=L.instancingMorph,k.skinning=L.skinning,k.morphTargets=L.morphTargets,k.morphNormals=L.morphNormals,k.morphColors=L.morphColors,k.morphTargetsCount=L.morphTargetsCount,k.numClippingPlanes=L.numClippingPlanes,k.numIntersection=L.numClipIntersection,k.vertexAlphas=L.vertexAlphas,k.vertexTangents=L.vertexTangents,k.toneMapping=L.toneMapping}function W0(v,L){if(v.length===0)return null;if(v.length===1)return v[0].texture!==null?v[0]:null;M.setFromMatrixPosition(L.matrixWorld);for(let k=0,B=v.length;k<B;k++){const z=v[k];if(z.texture!==null&&z.boundingBox.containsPoint(M))return z}return null}function X0(v,L,k,B,z){L.isScene!==!0&&(L=ot),X.resetTextureUnits();const pe=L.fog,xe=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?L.environment:null,de=Q===null?I.outputColorSpace:Q.isXRRenderTarget===!0?Q.texture.colorSpace:qe.workingColorSpace,Se=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Te=ie.get(B.envMap||xe,Se),ze=B.vertexColors===!0&&!!k.attributes.color&&k.attributes.color.itemSize===4,ke=!!k.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Ae=!!k.morphAttributes.position,je=!!k.morphAttributes.normal,pt=!!k.morphAttributes.color;let ft=hn;B.toneMapped&&(Q===null||Q.isXRRenderTarget===!0)&&(ft=I.toneMapping);const tt=k.morphAttributes.position||k.morphAttributes.normal||k.morphAttributes.color,bt=tt!==void 0?tt.length:0,_e=V.get(B),Ot=y.state.lights;if(De===!0&&(Ie===!0||v!==ee)){const at=v===ee&&B.id===te;Re.setState(B,v,at)}let Ke=!1;B.version===_e.__version?(_e.needsLights&&_e.lightsStateVersion!==Ot.state.version||_e.outputColorSpace!==de||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!==ke||_e.morphTargets!==Ae||_e.morphNormals!==je||_e.morphColors!==pt||_e.toneMapping!==ft||_e.morphTargetsCount!==bt||!!_e.lightProbeGrid!=y.state.lightProbeGridArray.length>0)&&(Ke=!0):(Ke=!0,_e.__version=B.version);let Vt=_e.currentProgram;Ke===!0&&(Vt=gr(B,L,z),N&&B.isNodeMaterial&&N.onUpdateProgram(B,Vt,_e));let rn=!1,Cn=!1,ui=!1;const nt=Vt.getUniforms(),mt=_e.uniforms;if(p.useProgram(Vt.program)&&(rn=!0,Cn=!0,ui=!0),B.id!==te&&(te=B.id,Cn=!0),_e.needsLights){const at=W0(y.state.lightProbeGridArray,z);_e.lightProbeGrid!==at&&(_e.lightProbeGrid=at,Cn=!0)}if(rn||ee!==v){p.buffers.depth.getReversed()&&v.reversedDepth!==!0&&(v._reversedDepth=!0,v.updateProjectionMatrix()),nt.setValue(D,"projectionMatrix",v.projectionMatrix),nt.setValue(D,"viewMatrix",v.matrixWorldInverse);const Dn=nt.map.cameraPosition;Dn!==void 0&&Dn.setValue(D,$e.setFromMatrixPosition(v.matrixWorld)),E.logarithmicDepthBuffer&&nt.setValue(D,"logDepthBufFC",2/(Math.log(v.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&nt.setValue(D,"isOrthographic",v.isOrthographicCamera===!0),ee!==v&&(ee=v,Cn=!0,ui=!0)}if(_e.needsLights&&(Ot.state.directionalShadowMap.length>0&&nt.setValue(D,"directionalShadowMap",Ot.state.directionalShadowMap,X),Ot.state.spotShadowMap.length>0&&nt.setValue(D,"spotShadowMap",Ot.state.spotShadowMap,X),Ot.state.pointShadowMap.length>0&&nt.setValue(D,"pointShadowMap",Ot.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 Pn=k.morphAttributes;if((Pn.position!==void 0||Pn.normal!==void 0||Pn.color!==void 0)&&P.update(z,k,Vt),(Cn||_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&&(mt.envMapIntensity.value=L.environmentIntensity),mt.dfgLUT!==void 0&&(mt.dfgLUT.value=Vg()),Cn){if(nt.setValue(D,"toneMappingExposure",I.toneMappingExposure),_e.needsLights&&q0(mt,ui),pe&&B.fog===!0&&be.refreshFogUniforms(mt,pe),be.refreshMaterialUniforms(mt,B,ne,se,y.state.transmissionRenderTarget[v.id]),_e.needsLights&&_e.lightProbeGrid){const at=_e.lightProbeGrid;mt.probesSH.value=at.texture,mt.probesMin.value.copy(at.boundingBox.min),mt.probesMax.value.copy(at.boundingBox.max),mt.probesResolution.value.copy(at.resolution)}as.upload(D,ol(_e),mt,X)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(as.upload(D,ol(_e),mt,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 Dn=0,hi=at.length;Dn<hi;Dn++){const cl=at[Dn];j.update(cl,Vt),j.bind(cl,Vt)}}return Vt}function q0(v,L){v.ambientLightColor.needsUpdate=L,v.lightProbe.needsUpdate=L,v.directionalLights.needsUpdate=L,v.directionalLightShadows.needsUpdate=L,v.pointLights.needsUpdate=L,v.pointLightShadows.needsUpdate=L,v.spotLights.needsUpdate=L,v.spotLightShadows.needsUpdate=L,v.rectAreaLights.needsUpdate=L,v.hemisphereLights.needsUpdate=L}function Y0(v){return v.isMeshLambertMaterial||v.isMeshToonMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isShadowMaterial||v.isShaderMaterial&&v.lights===!0}this.getActiveCubeFace=function(){return W},this.getActiveMipmapLevel=function(){return H},this.getRenderTarget=function(){return Q},this.setRenderTargetTextures=function(v,L,k){const B=V.get(v);B.__autoAllocateDepthBuffer=v.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1&&(B.__useRenderToTexture=!1),V.get(v.texture).__webglTexture=L,V.get(v.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:k,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(v,L){const k=V.get(v);k.__webglFramebuffer=L,k.__useDefaultFramebuffer=L===void 0},this.setRenderTarget=function(v,L=0,k=0){Q=v,W=L,H=k;let B=null,z=!1,pe=!1;if(v){const de=V.get(v);if(de.__useDefaultFramebuffer!==void 0){p.bindFramebuffer(D.FRAMEBUFFER,de.__webglFramebuffer),re.copy(v.viewport),ge.copy(v.scissor),He=v.scissorTest,p.viewport(re),p.scissor(ge),p.setScissorTest(He),te=-1;return}else if(de.__webglFramebuffer===void 0)X.setupRenderTarget(v);else if(de.__hasExternalTextures)X.rebindTextures(v,V.get(v.texture).__webglTexture,V.get(v.depthTexture).__webglTexture);else if(v.depthBuffer){const ze=v.depthTexture;if(de.__boundDepthTexture!==ze){if(ze!==null&&V.has(ze)&&(v.width!==ze.image.width||v.height!==ze.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");X.setupDepthRenderbuffer(v)}}const Se=v.texture;(Se.isData3DTexture||Se.isDataArrayTexture||Se.isCompressedArrayTexture)&&(pe=!0);const Te=V.get(v).__webglFramebuffer;v.isWebGLCubeRenderTarget?(Array.isArray(Te[L])?B=Te[L][k]:B=Te[L],z=!0):v.samples>0&&X.useMultisampledRTT(v)===!1?B=V.get(v).__webglMultisampledFramebuffer:Array.isArray(Te)?B=Te[k]:B=Te,re.copy(v.viewport),ge.copy(v.scissor),He=v.scissorTest}else re.copy(Pe).multiplyScalar(ne).floor(),ge.copy(we).multiplyScalar(ne).floor(),He=ve;if(k!==0&&(B=Y),p.bindFramebuffer(D.FRAMEBUFFER,B)&&p.drawBuffers(v,B),p.viewport(re),p.scissor(ge),p.setScissorTest(He),z){const de=V.get(v.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+L,de.__webglTexture,k)}else if(pe){const de=L;for(let Se=0;Se<v.textures.length;Se++){const Te=V.get(v.textures[Se]);D.framebufferTextureLayer(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0+Se,Te.__webglTexture,k,de)}}else if(v!==null&&k!==0){const de=V.get(v.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,de.__webglTexture,k)}te=-1},this.readRenderTargetPixels=function(v,L,k,B,z,pe,xe,de=0){if(!(v&&v.isWebGLRenderTarget)){Xe("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Se=V.get(v).__webglFramebuffer;if(v.isWebGLCubeRenderTarget&&xe!==void 0&&(Se=Se[xe]),Se){p.bindFramebuffer(D.FRAMEBUFFER,Se);try{const Te=v.textures[de],ze=Te.format,ke=Te.type;if(v.textures.length>1&&D.readBuffer(D.COLOR_ATTACHMENT0+de),!E.textureFormatReadable(ze)){Xe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!E.textureTypeReadable(ke)){Xe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}L>=0&&L<=v.width-B&&k>=0&&k<=v.height-z&&D.readPixels(L,k,B,z,ue.convert(ze),ue.convert(ke),pe)}finally{const Te=Q!==null?V.get(Q).__webglFramebuffer:null;p.bindFramebuffer(D.FRAMEBUFFER,Te)}}},this.readRenderTargetPixelsAsync=async function(v,L,k,B,z,pe,xe,de=0){if(!(v&&v.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Se=V.get(v).__webglFramebuffer;if(v.isWebGLCubeRenderTarget&&xe!==void 0&&(Se=Se[xe]),Se)if(L>=0&&L<=v.width-B&&k>=0&&k<=v.height-z){p.bindFramebuffer(D.FRAMEBUFFER,Se);const Te=v.textures[de],ze=Te.format,ke=Te.type;if(v.textures.length>1&&D.readBuffer(D.COLOR_ATTACHMENT0+de),!E.textureFormatReadable(ze))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!E.textureTypeReadable(ke))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,k,B,z,ue.convert(ze),ue.convert(ke),0);const je=Q!==null?V.get(Q).__webglFramebuffer:null;p.bindFramebuffer(D.FRAMEBUFFER,je);const pt=D.fenceSync(D.SYNC_GPU_COMMANDS_COMPLETE,0);return D.flush(),await oh(D,pt,4),D.bindBuffer(D.PIXEL_PACK_BUFFER,Ae),D.getBufferSubData(D.PIXEL_PACK_BUFFER,0,pe),D.deleteBuffer(Ae),D.deleteSync(pt),pe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(v,L=null,k=0){const B=Math.pow(2,-k),z=Math.floor(v.image.width*B),pe=Math.floor(v.image.height*B),xe=L!==null?L.x:0,de=L!==null?L.y:0;X.setTexture2D(v,0),D.copyTexSubImage2D(D.TEXTURE_2D,k,0,0,xe,de,z,pe),p.unbindTexture()},this.copyTextureToTexture=function(v,L,k=null,B=null,z=0,pe=0){let xe,de,Se,Te,ze,ke,Ae,je,pt;const ft=v.isCompressedTexture?v.mipmaps[pe]:v.image;if(k!==null)xe=k.max.x-k.min.x,de=k.max.y-k.min.y,Se=k.isBox3?k.max.z-k.min.z:1,Te=k.min.x,ze=k.min.y,ke=k.isBox3?k.min.z:0;else{const mt=Math.pow(2,-z);xe=Math.floor(ft.width*mt),de=Math.floor(ft.height*mt),v.isDataArrayTexture?Se=ft.depth:v.isData3DTexture?Se=Math.floor(ft.depth*mt):Se=1,Te=0,ze=0,ke=0}B!==null?(Ae=B.x,je=B.y,pt=B.z):(Ae=0,je=0,pt=0);const tt=ue.convert(L.format),bt=ue.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),p.activeTexture(D.TEXTURE0),p.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,L.flipY),p.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),p.pixelStorei(D.UNPACK_ALIGNMENT,L.unpackAlignment);const Ot=p.getParameter(D.UNPACK_ROW_LENGTH),Ke=p.getParameter(D.UNPACK_IMAGE_HEIGHT),Vt=p.getParameter(D.UNPACK_SKIP_PIXELS),rn=p.getParameter(D.UNPACK_SKIP_ROWS),Cn=p.getParameter(D.UNPACK_SKIP_IMAGES);p.pixelStorei(D.UNPACK_ROW_LENGTH,ft.width),p.pixelStorei(D.UNPACK_IMAGE_HEIGHT,ft.height),p.pixelStorei(D.UNPACK_SKIP_PIXELS,Te),p.pixelStorei(D.UNPACK_SKIP_ROWS,ze),p.pixelStorei(D.UNPACK_SKIP_IMAGES,ke);const ui=v.isDataArrayTexture||v.isData3DTexture,nt=L.isDataArrayTexture||L.isData3DTexture;if(v.isDepthTexture){const mt=V.get(v),Pn=V.get(L),at=V.get(mt.__renderTarget),Dn=V.get(Pn.__renderTarget);p.bindFramebuffer(D.READ_FRAMEBUFFER,at.__webglFramebuffer),p.bindFramebuffer(D.DRAW_FRAMEBUFFER,Dn.__webglFramebuffer);for(let hi=0;hi<Se;hi++)ui&&(D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,V.get(v).__webglTexture,z,ke+hi),D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,V.get(L).__webglTexture,pe,pt+hi)),D.blitFramebuffer(Te,ze,xe,de,Ae,je,xe,de,D.DEPTH_BUFFER_BIT,D.NEAREST);p.bindFramebuffer(D.READ_FRAMEBUFFER,null),p.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else if(z!==0||v.isRenderTargetTexture||V.has(v)){const mt=V.get(v),Pn=V.get(L);p.bindFramebuffer(D.READ_FRAMEBUFFER,K),p.bindFramebuffer(D.DRAW_FRAMEBUFFER,O);for(let at=0;at<Se;at++)ui?D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,mt.__webglTexture,z,ke+at):D.framebufferTexture2D(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,mt.__webglTexture,z),nt?D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,Pn.__webglTexture,pe,pt+at):D.framebufferTexture2D(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,Pn.__webglTexture,pe),z!==0?D.blitFramebuffer(Te,ze,xe,de,Ae,je,xe,de,D.COLOR_BUFFER_BIT,D.NEAREST):nt?D.copyTexSubImage3D(_e,pe,Ae,je,pt+at,Te,ze,xe,de):D.copyTexSubImage2D(_e,pe,Ae,je,Te,ze,xe,de);p.bindFramebuffer(D.READ_FRAMEBUFFER,null),p.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else nt?v.isDataTexture||v.isData3DTexture?D.texSubImage3D(_e,pe,Ae,je,pt,xe,de,Se,tt,bt,ft.data):L.isCompressedArrayTexture?D.compressedTexSubImage3D(_e,pe,Ae,je,pt,xe,de,Se,tt,ft.data):D.texSubImage3D(_e,pe,Ae,je,pt,xe,de,Se,tt,bt,ft):v.isDataTexture?D.texSubImage2D(D.TEXTURE_2D,pe,Ae,je,xe,de,tt,bt,ft.data):v.isCompressedTexture?D.compressedTexSubImage2D(D.TEXTURE_2D,pe,Ae,je,ft.width,ft.height,tt,ft.data):D.texSubImage2D(D.TEXTURE_2D,pe,Ae,je,xe,de,tt,bt,ft);p.pixelStorei(D.UNPACK_ROW_LENGTH,Ot),p.pixelStorei(D.UNPACK_IMAGE_HEIGHT,Ke),p.pixelStorei(D.UNPACK_SKIP_PIXELS,Vt),p.pixelStorei(D.UNPACK_SKIP_ROWS,rn),p.pixelStorei(D.UNPACK_SKIP_IMAGES,Cn),pe===0&&L.generateMipmaps&&D.generateMipmap(_e),p.unbindTexture()},this.initRenderTarget=function(v){V.get(v).__webglFramebuffer===void 0&&X.setupRenderTarget(v)},this.initTexture=function(v){v.isCubeTexture?X.setTextureCube(v,0):v.isData3DTexture?X.setTexture3D(v,0):v.isDataArrayTexture||v.isCompressedArrayTexture?X.setTexture2DArray(v,0):X.setTexture2D(v,0),p.unbindTexture()},this.resetState=function(){W=0,H=0,Q=null,p.reset(),me.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return un}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 xo=Math.PI/180,mc=180/Math.PI;function pr(i,e,t){return Math.max(e,Math.min(t,i))}const Bn=[{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 os(i,e,t){return i+(e-i)*t}function _s(i,e,t){return[os(i[0],e[0],t),os(i[1],e[1],t),os(i[2],e[2],t)]}function E0(i){const e=Math.max(Bn[0].altitudeDeg,Math.min(Bn[Bn.length-1].altitudeDeg,i));for(let n=0;n<Bn.length-1;n++){const r=Bn[n],s=Bn[n+1];if(e>=r.altitudeDeg&&e<=s.altitudeDeg){const a=(e-r.altitudeDeg)/(s.altitudeDeg-r.altitudeDeg);return{zenith:_s(r.zenith,s.zenith,a),horizon:_s(r.horizon,s.horizon,a)}}}const t=Bn[Bn.length-1];return{zenith:t.zenith,horizon:t.horizon}}function Hg(i){if(i<=-18)return 7.5;if(i>=0)return-4;const n=(i+18)/18;return os(7.5,-4,n)}const Wg=-1.5,Xg=7.5;function gc(i){const e=10**(-.4*i),t=10**(-.4*Wg),n=10**(-.4*Xg);return pr((e-n)/(t-n),0,1)}function Kr(i,e,t){const n=i*xo,r=e*xo,s=t*Math.cos(n);return{x:s*Math.sin(r),y:t*Math.sin(n),z:-s*Math.cos(r)}}function qg(i,e,t){const n=Math.sqrt(i*i+e*e+t*t),r=n===0?0:Math.asin(pr(e/n,-1,1))*mc,s=(Math.atan2(i,-t)*mc+360)%360;return{altitudeDeg:r,azimuthDeg:s}}function Yg(i,e){const t=Math.abs(i-e)%360;return t>180?360-t:t}function Kg(i,e,t){const n=Math.max(0,1-Yg(i,e)/90),r=Math.max(0,1-Math.abs(t)/18);return n*r}function Zg(i,e,t,n){const{zenith:r,horizon:s}=E0(n),a=pr((i+90)/180,0,1),o=_s(s,r,a),l=Kg(e,t,n);return l<=0?o:_s(o,s,l*(1-a)*.8)}function _c(i){return .3+.7*i}const $g=-4;function Jg(i){return Math.max(0,$g-i)}const Qg=6,jg=60;function e_(i){return Math.min(jg,Qg*Math.sqrt(i))}const t_=3,n_=.55;function i_(i){return n_*pr(i/t_,0,1)}function r_(i){const e=Math.max(i,-4),t=Math.sin(e*xo)+.50572*Math.pow(e+6.07995,-1.6364);return pr(1/t,1,40)}function xc(i){const e=r_(i)-1;return[1,Math.exp(-.022*e),Math.exp(-.062*e)]}const y0=[{maxBrightness:.5,size:1.2},{maxBrightness:.85,size:2},{maxBrightness:1/0,size:3.2}];function s_(i){return y0.findIndex(e=>i<=e.maxBrightness)}const a_=.25,vc=.3,o_=2.2;function l_(i,{phase:e,speedFactor:t},n){const s=1+a_*(vc+(1-vc)*i)*Math.sin(n*o_*t+e);return Math.min(1,Math.max(0,s))}/**
|
|
4339
|
+
}`;class L_{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){const n=new nu(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:I_,fragmentShader:D_,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new ke(new Zs(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class U_ extends di{constructor(t,e){super();const n=this;let r=null,s=1,a=null,o="local-floor",l=1,c=null,h=null,d=null,u=null,p=null,_=null;const S=typeof XRWebGLBinding<"u",m=new L_,f={},A=e.getContextAttributes();let w=null,M=null;const y=[],b=[],R=new Gt;let x=null;const T=new $e;T.viewport=new fe;const I=new $e;I.viewport=new fe;const C=[T,I],U=new kd;let Y=null,Z=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function($){let st=y[$];return st===void 0&&(st=new ua,y[$]=st),st.getTargetRaySpace()},this.getControllerGrip=function($){let st=y[$];return st===void 0&&(st=new ua,y[$]=st),st.getGripSpace()},this.getHand=function($){let st=y[$];return st===void 0&&(st=new ua,y[$]=st),st.getHandSpace()};function O($){const st=b.indexOf($.inputSource);if(st===-1)return;const nt=y[st];nt!==void 0&&(nt.update($.inputSource,$.frame,c||a),nt.dispatchEvent({type:$.type,data:$.inputSource}))}function W(){r.removeEventListener("select",O),r.removeEventListener("selectstart",O),r.removeEventListener("selectend",O),r.removeEventListener("squeeze",O),r.removeEventListener("squeezestart",O),r.removeEventListener("squeezeend",O),r.removeEventListener("end",W),r.removeEventListener("inputsourceschange",V);for(let $=0;$<y.length;$++){const st=b[$];st!==null&&(b[$]=null,y[$].disconnect(st))}Y=null,Z=null,m.reset();for(const $ in f)delete f[$];t.setRenderTarget(w),p=null,u=null,d=null,r=null,M=null,Wt.stop(),n.isPresenting=!1,t.setPixelRatio(x),t.setSize(R.width,R.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function($){s=$,n.isPresenting===!0&&Ft("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function($){o=$,n.isPresenting===!0&&Ft("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function($){c=$},this.getBaseLayer=function(){return u!==null?u:p},this.getBinding=function(){return d===null&&S&&(d=new XRWebGLBinding(r,e)),d},this.getFrame=function(){return _},this.getSession=function(){return r},this.setSession=async function($){if(r=$,r!==null){if(w=t.getRenderTarget(),r.addEventListener("select",O),r.addEventListener("selectstart",O),r.addEventListener("selectend",O),r.addEventListener("squeeze",O),r.addEventListener("squeezestart",O),r.addEventListener("squeezeend",O),r.addEventListener("end",W),r.addEventListener("inputsourceschange",V),A.xrCompatible!==!0&&await e.makeXRCompatible(),x=t.getPixelRatio(),t.getSize(R),S&&"createProjectionLayer"in XRWebGLBinding.prototype){let nt=null,G=null,Ct=null;A.depth&&(Ct=A.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,nt=A.stencil?si:Pn,G=A.stencil?br:gn);const Pt={colorFormat:e.RGBA8,depthFormat:Ct,scaleFactor:s};d=this.getBinding(),u=d.createProjectionLayer(Pt),r.updateRenderState({layers:[u]}),t.setPixelRatio(1),t.setSize(u.textureWidth,u.textureHeight,!1),M=new mn(u.textureWidth,u.textureHeight,{format:rn,type:Ke,depthTexture:new Zi(u.textureWidth,u.textureHeight,G,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:s};p=new XRWebGLLayer(r,e,nt),r.updateRenderState({baseLayer:p}),t.setPixelRatio(1),t.setSize(p.framebufferWidth,p.framebufferHeight,!1),M=new mn(p.framebufferWidth,p.framebufferHeight,{format:rn,type:Ke,colorSpace:t.outputColorSpace,stencilBuffer:A.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}M.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await r.requestReferenceSpace(o),Wt.setContext(r),Wt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function V($){for(let st=0;st<$.removed.length;st++){const nt=$.removed[st],G=b.indexOf(nt);G>=0&&(b[G]=null,y[G].disconnect(nt))}for(let st=0;st<$.added.length;st++){const nt=$.added[st];let G=b.indexOf(nt);if(G===-1){for(let Pt=0;Pt<y.length;Pt++)if(Pt>=b.length){b.push(nt),G=Pt;break}else if(b[Pt]===null){b[Pt]=nt,G=Pt;break}if(G===-1)break}const Ct=y[G];Ct&&Ct.connect(nt)}}const Q=new F,et=new F;function tt($,st,nt){Q.setFromMatrixPosition(st.matrixWorld),et.setFromMatrixPosition(nt.matrixWorld);const G=Q.distanceTo(et),Ct=st.projectionMatrix.elements,Pt=nt.projectionMatrix.elements,wt=Ct[14]/(Ct[10]-1),vt=Ct[14]/(Ct[10]+1),Nt=(Ct[9]+1)/Ct[5],Dt=(Ct[9]-1)/Ct[5],Lt=(Ct[8]-1)/Ct[0],$t=(Pt[8]+1)/Pt[0],Kt=wt*Lt,ce=wt*$t,oe=G/(-Lt+$t),he=oe*-Lt;if(st.matrixWorld.decompose($.position,$.quaternion,$.scale),$.translateX(he),$.translateZ(oe),$.matrixWorld.compose($.position,$.quaternion,$.scale),$.matrixWorldInverse.copy($.matrixWorld).invert(),Ct[10]===-1)$.projectionMatrix.copy(st.projectionMatrix),$.projectionMatrixInverse.copy(st.projectionMatrixInverse);else{const xe=wt+oe,D=vt+oe,Be=Kt-he,Jt=ce+(G-he),E=Nt*vt/D*xe,g=Dt*vt/D*xe;$.projectionMatrix.makePerspective(Be,Jt,E,g,xe,D),$.projectionMatrixInverse.copy($.projectionMatrix).invert()}}function rt($,st){st===null?$.matrixWorld.copy($.matrix):$.matrixWorld.multiplyMatrices(st.matrixWorld,$.matrix),$.matrixWorldInverse.copy($.matrixWorld).invert()}this.updateCamera=function($){if(r===null)return;let st=$.near,nt=$.far;m.texture!==null&&(m.depthNear>0&&(st=m.depthNear),m.depthFar>0&&(nt=m.depthFar)),U.near=I.near=T.near=st,U.far=I.far=T.far=nt,(Y!==U.near||Z!==U.far)&&(r.updateRenderState({depthNear:U.near,depthFar:U.far}),Y=U.near,Z=U.far),U.layers.mask=$.layers.mask|6,T.layers.mask=U.layers.mask&-5,I.layers.mask=U.layers.mask&-3;const G=$.parent,Ct=U.cameras;rt(U,G);for(let Pt=0;Pt<Ct.length;Pt++)rt(Ct[Pt],G);Ct.length===2?tt(U,T,I):U.projectionMatrix.copy(T.projectionMatrix),gt($,U,G)};function gt($,st,nt){nt===null?$.matrix.copy(st.matrixWorld):($.matrix.copy(nt.matrixWorld),$.matrix.invert(),$.matrix.multiply(st.matrixWorld)),$.matrix.decompose($.position,$.quaternion,$.scale),$.updateMatrixWorld(!0),$.projectionMatrix.copy(st.projectionMatrix),$.projectionMatrixInverse.copy(st.projectionMatrixInverse),$.isPerspectiveCamera&&($.fov=Oo*2*Math.atan(1/$.projectionMatrix.elements[5]),$.zoom=1)}this.getCamera=function(){return U},this.getFoveation=function(){if(!(u===null&&p===null))return l},this.setFoveation=function($){l=$,u!==null&&(u.fixedFoveation=$),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=$)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(U)},this.getCameraTexture=function($){return f[$]};let Vt=null;function re($,st){if(h=st.getViewerPose(c||a),_=st,h!==null){const nt=h.views;p!==null&&(t.setRenderTargetFramebuffer(M,p.framebuffer),t.setRenderTarget(M));let G=!1;nt.length!==U.cameras.length&&(U.cameras.length=0,G=!0);for(let vt=0;vt<nt.length;vt++){const Nt=nt[vt];let Dt=null;if(p!==null)Dt=p.getViewport(Nt);else{const $t=d.getViewSubImage(u,Nt);Dt=$t.viewport,vt===0&&(t.setRenderTargetTextures(M,$t.colorTexture,$t.depthStencilTexture),t.setRenderTarget(M))}let Lt=C[vt];Lt===void 0&&(Lt=new $e,Lt.layers.enable(vt),Lt.viewport=new fe,C[vt]=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),vt===0&&(U.matrix.copy(Lt.matrix),U.matrix.decompose(U.position,U.quaternion,U.scale)),G===!0&&U.cameras.push(Lt)}const Ct=r.enabledFeatures;if(Ct&&Ct.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&S){d=n.getBinding();const vt=d.getDepthInformation(nt[0]);vt&&vt.isValid&&vt.texture&&m.init(vt,r.renderState)}if(Ct&&Ct.includes("camera-access")&&S){t.state.unbindTexture(),d=n.getBinding();for(let vt=0;vt<nt.length;vt++){const Nt=nt[vt].camera;if(Nt){let Dt=f[Nt];Dt||(Dt=new nu,f[Nt]=Dt);const Lt=d.getCameraImage(Nt);Dt.sourceTexture=Lt}}}}for(let nt=0;nt<y.length;nt++){const G=b[nt],Ct=y[nt];G!==null&&Ct!==void 0&&Ct.update(G,st,c||a)}Vt&&Vt($,st),st.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:st}),_=null}const Wt=new ou;Wt.setAnimationLoop(re),this.setAnimationLoop=function($){Vt=$},this.dispose=function(){}}}const N_=new le,pu=new Ot;pu.set(-1,0,0,0,1,0,0,0,1);function F_(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,iu(i)),f.isFog?(m.fogNear.value=f.near,m.fogFar.value=f.far):f.isFogExp2&&(m.fogDensity.value=f.density)}function r(m,f,A,w,M){f.isNodeMaterial?f.uniformsNeedUpdate=!1:f.isMeshBasicMaterial?s(m,f):f.isMeshLambertMaterial?(s(m,f),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)):f.isMeshToonMaterial?(s(m,f),d(m,f)):f.isMeshPhongMaterial?(s(m,f),h(m,f),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)):f.isMeshStandardMaterial?(s(m,f),u(m,f),f.isMeshPhysicalMaterial&&p(m,f,M)):f.isMeshMatcapMaterial?(s(m,f),_(m,f)):f.isMeshDepthMaterial?s(m,f):f.isMeshDistanceMaterial?(s(m,f),S(m,f)):f.isMeshNormalMaterial?s(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 s(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,M=A.envMapRotation;w&&(m.envMap.value=w,m.envMapRotation.value.setFromMatrix4(N_.makeRotationFromEuler(M)).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 S(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:r}}function O_(i,t,e,n){let r={},s={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(M,y){const b=y.program;n.uniformBlockBinding(M,b)}function c(M,y){let b=r[M.id];b===void 0&&(m(M),b=h(M),r[M.id]=b,M.addEventListener("dispose",A));const R=y.program;n.updateUBOMapping(M,R);const x=t.render.frame;s[M.id]!==x&&(u(M),s[M.id]=x)}function h(M){const y=d();M.__bindingPointIndex=y;const b=i.createBuffer(),R=M.__size,x=M.usage;return i.bindBuffer(i.UNIFORM_BUFFER,b),i.bufferData(i.UNIFORM_BUFFER,R,x),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,y,b),b}function d(){for(let M=0;M<o;M++)if(a.indexOf(M)===-1)return a.push(M),M;return Xt("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(M){const y=r[M.id],b=M.uniforms,R=M.__cache;i.bindBuffer(i.UNIFORM_BUFFER,y);for(let x=0,T=b.length;x<T;x++){const I=b[x];if(Array.isArray(I))for(let C=0,U=I.length;C<U;C++)p(I[C],x,C,R);else p(I,x,0,R)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function p(M,y,b,R){if(S(M,y,b,R)===!0){const x=M.__offset,T=M.value;if(Array.isArray(T)){let I=0;for(let C=0;C<T.length;C++){const U=T[C],Y=f(U);_(U,M.__data,I),typeof U!="number"&&typeof U!="boolean"&&!U.isMatrix3&&!ArrayBuffer.isView(U)&&(I+=Y.storage/Float32Array.BYTES_PER_ELEMENT)}}else _(T,M.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,x,M.__data)}}function _(M,y,b){typeof M=="number"||typeof M=="boolean"?y[0]=M:M.isMatrix3?(y[0]=M.elements[0],y[1]=M.elements[1],y[2]=M.elements[2],y[3]=0,y[4]=M.elements[3],y[5]=M.elements[4],y[6]=M.elements[5],y[7]=0,y[8]=M.elements[6],y[9]=M.elements[7],y[10]=M.elements[8],y[11]=0):ArrayBuffer.isView(M)?y.set(new M.constructor(M.buffer,M.byteOffset,y.length)):M.toArray(y,b)}function S(M,y,b,R){const x=M.value,T=y+"_"+b;if(R[T]===void 0)return typeof x=="number"||typeof x=="boolean"?R[T]=x:ArrayBuffer.isView(x)?R[T]=x.slice():R[T]=x.clone(),!0;{const I=R[T];if(typeof x=="number"||typeof x=="boolean"){if(I!==x)return R[T]=x,!0}else{if(ArrayBuffer.isView(x))return!0;if(I.equals(x)===!1)return I.copy(x),!0}}return!1}function m(M){const y=M.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,rt=tt%et.boundary,gt=tt+rt;b+=rt,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 x=b%R;return x>0&&(b+=R-x),M.__size=b,M.__cache={},this}function f(M){const y={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(y.boundary=4,y.storage=4):M.isVector2?(y.boundary=8,y.storage=8):M.isVector3||M.isColor?(y.boundary=16,y.storage=12):M.isVector4?(y.boundary=16,y.storage=16):M.isMatrix3?(y.boundary=48,y.storage=48):M.isMatrix4?(y.boundary=64,y.storage=64):M.isTexture?Ft("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(y.boundary=16,y.storage=M.byteLength):Ft("WebGLRenderer: Unsupported uniform value type.",M),y}function A(M){const y=M.target;y.removeEventListener("dispose",A);const b=a.indexOf(y.__bindingPointIndex);a.splice(b,1),i.deleteBuffer(r[y.id]),delete r[y.id],delete s[y.id]}function w(){for(const M in r)i.deleteBuffer(r[M]);a=[],r={},s={}}return{bind:l,update:c,dispose:w}}const B_=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 z_(){return cn===null&&(cn=new Cd(B_,16,16,ci,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 G_{constructor(t={}){const{canvas:e=sd(),context:n=null,depth:r=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:u=!1,outputBufferType:p=Ke}=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 S=p,m=new Set([dl,ul,hl]),f=new Set([Ke,gn,Er,br,ll,cl]),A=new Uint32Array(4),w=new Int32Array(4),M=new F;let y=null,b=null;const R=[],x=[];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 rt=new fe,gt=new fe;let Vt=null;const re=new It(0);let Wt=0,$=e.width,st=e.height,nt=1,G=null,Ct=null;const Pt=new fe(0,0,$,st),wt=new fe(0,0,$,st);let vt=!1;const Nt=new jh;let Dt=!1,Lt=!1;const $t=new le,Kt=new F,ce=new fe,oe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let he=!1;function xe(){return Q===null?nt:1}let D=n;function Be(v,L){return e.getContext(v,L)}try{const v={alpha:!0,depth:r,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${al}`),e.addEventListener("webglcontextlost",ue,!1),e.addEventListener("webglcontextrestored",se,!1),e.addEventListener("webglcontextcreationerror",sn,!1),D===null){const L="webgl2";if(D=Be(L,v),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(v){throw Xt("WebGLRenderer: "+v.message),v}let Jt,E,g,N,H,X,it,ot,q,J,lt,bt,ut,ct,Rt,Ut,Bt,P,at,K,ht,mt,j;function Et(){Jt=new zm(D),Jt.init(),ht=new P_(D,Jt),E=new Im(D,Jt,t,ht),g=new R_(D,Jt),E.reversedDepthBuffer&&u&&g.buffers.depth.setReversed(!0),Y=D.createFramebuffer(),Z=D.createFramebuffer(),O=D.createFramebuffer(),N=new km(D),H=new p_,X=new C_(D,Jt,g,H,E,ht,N),it=new Bm(I),ot=new Xd(D),mt=new Cm(D,ot),q=new Gm(D,ot,N,mt),J=new Wm(D,q,ot,mt,N),P=new Vm(D,E,X),Rt=new Dm(H),lt=new f_(I,it,Jt,E,mt,Rt),bt=new F_(I,H),ut=new g_,ct=new y_(Jt),Bt=new Rm(I,it,g,J,_,l),Ut=new w_(I,J,E),j=new O_(D,N,E,g),at=new Pm(D,Jt,N),K=new Hm(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(),S!==Ke&&(T=new qm(S,e.width,e.height,o,r,s));const Mt=new U_(I,D);this.xr=Mt,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){const v=Jt.get("WEBGL_lose_context");v&&v.loseContext()},this.forceContextRestore=function(){const v=Jt.get("WEBGL_lose_context");v&&v.restoreContext()},this.getPixelRatio=function(){return nt},this.setPixelRatio=function(v){v!==void 0&&(nt=v,this.setSize($,st,!1))},this.getSize=function(v){return v.set($,st)},this.setSize=function(v,L,k=!0){if(Mt.isPresenting){Ft("WebGLRenderer: Can't change size while VR device is presenting.");return}$=v,st=L,e.width=Math.floor(v*nt),e.height=Math.floor(L*nt),k===!0&&(e.style.width=v+"px",e.style.height=L+"px"),T!==null&&T.setSize(e.width,e.height),this.setViewport(0,0,v,L)},this.getDrawingBufferSize=function(v){return v.set($*nt,st*nt).floor()},this.setDrawingBufferSize=function(v,L,k){$=v,st=L,nt=k,e.width=Math.floor(v*k),e.height=Math.floor(L*k),this.setViewport(0,0,v,L)},this.setEffects=function(v){if(S===Ke){Xt("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(v){for(let L=0;L<v.length;L++)if(v[L].isOutputPass===!0){Ft("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}T.setEffects(v||[])},this.getCurrentViewport=function(v){return v.copy(rt)},this.getViewport=function(v){return v.copy(Pt)},this.setViewport=function(v,L,k,B){v.isVector4?Pt.set(v.x,v.y,v.z,v.w):Pt.set(v,L,k,B),g.viewport(rt.copy(Pt).multiplyScalar(nt).round())},this.getScissor=function(v){return v.copy(wt)},this.setScissor=function(v,L,k,B){v.isVector4?wt.set(v.x,v.y,v.z,v.w):wt.set(v,L,k,B),g.scissor(gt.copy(wt).multiplyScalar(nt).round())},this.getScissorTest=function(){return vt},this.setScissorTest=function(v){g.setScissorTest(vt=v)},this.setOpaqueSort=function(v){G=v},this.setTransparentSort=function(v){Ct=v},this.getClearColor=function(v){return v.copy(Bt.getClearColor())},this.setClearColor=function(){Bt.setClearColor(...arguments)},this.getClearAlpha=function(){return Bt.getClearAlpha()},this.setClearAlpha=function(){Bt.setClearAlpha(...arguments)},this.clear=function(v=!0,L=!0,k=!0){let B=0;if(v){let z=!1;if(Q!==null){const pt=Q.texture.format;z=m.has(pt)}if(z){const pt=Q.texture.type,xt=f.has(pt),ft=Bt.getClearColor(),St=Bt.getClearAlpha(),Tt=ft.r,zt=ft.g,kt=ft.b;xt?(A[0]=Tt,A[1]=zt,A[2]=kt,A[3]=St,D.clearBufferuiv(D.COLOR,0,A)):(w[0]=Tt,w[1]=zt,w[2]=kt,w[3]=St,D.clearBufferiv(D.COLOR,0,w))}else B|=D.COLOR_BUFFER_BIT}L&&(B|=D.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),k&&(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(v){v.setRenderer(this),U=v},this.dispose=function(){e.removeEventListener("webglcontextlost",ue,!1),e.removeEventListener("webglcontextrestored",se,!1),e.removeEventListener("webglcontextcreationerror",sn,!1),Bt.dispose(),ut.dispose(),ct.dispose(),H.dispose(),it.dispose(),J.dispose(),mt.dispose(),j.dispose(),lt.dispose(),Mt.dispose(),Mt.removeEventListener("sessionstart",Al),Mt.removeEventListener("sessionend",wl),$n.stop()};function ue(v){v.preventDefault(),Ns("WebGLRenderer: Context Lost."),C=!0}function se(){Ns("WebGLRenderer: Context Restored."),C=!1;const v=N.autoReset,L=Ut.enabled,k=Ut.autoUpdate,B=Ut.needsUpdate,z=Ut.type;Et(),N.autoReset=v,Ut.enabled=L,Ut.autoUpdate=k,Ut.needsUpdate=B,Ut.type=z}function sn(v){Xt("WebGLRenderer: A WebGL context could not be created. Reason: ",v.statusMessage)}function an(v){const L=v.target;L.removeEventListener("dispose",an),Gu(L)}function Gu(v){Hu(v),H.remove(v)}function Hu(v){const L=H.get(v).programs;L!==void 0&&(L.forEach(function(k){lt.releaseProgram(k)}),v.isShaderMaterial&<.releaseShaderCache(v))}this.renderBufferDirect=function(v,L,k,B,z,pt){L===null&&(L=oe);const xt=z.isMesh&&z.matrixWorld.determinantAffine()<0,ft=Wu(v,L,k,B,z);g.setMaterial(B,xt);let St=k.index,Tt=1;if(B.wireframe===!0){if(St=q.getWireframeAttribute(k),St===void 0)return;Tt=2}const zt=k.drawRange,kt=k.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)),St!==null?(At=Math.max(At,0),jt=Math.min(jt,St.count)):kt!=null&&(At=Math.max(At,0),jt=Math.min(jt,kt.count));const me=jt-At;if(me<0||me===1/0)return;mt.setup(z,B,ft,k,St);let de,ee=at;if(St!==null&&(de=ot.get(St),ee=K,ee.setIndex(de)),z.isMesh)B.wireframe===!0?(g.setLineWidth(B.wireframeLinewidth*xe()),ee.setMode(D.LINES)):ee.setMode(D.TRIANGLES);else if(z.isLine){let we=B.linewidth;we===void 0&&(we=1),g.setLineWidth(we*xe()),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=St?ot.get(St).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(k.isInstancedBufferGeometry){const we=k._maxInstanceCount!==void 0?k._maxInstanceCount:1/0,_t=Math.min(k.instanceCount,we);ee.renderInstances(At,me,_t)}else ee.render(At,me)};function Tl(v,L,k){v.transparent===!0&&v.side===bn&&v.forceSinglePass===!1?(v.side=Fe,v.needsUpdate=!0,Cr(v,L,k),v.side=Zn,v.needsUpdate=!0,Cr(v,L,k),v.side=bn):Cr(v,L,k)}this.compile=function(v,L,k=null){k===null&&(k=v),b=ct.get(k),b.init(L),x.push(b),k.traverseVisible(function(z){z.isLight&&z.layers.test(L.layers)&&(b.pushLight(z),z.castShadow&&b.pushShadow(z))}),v!==k&&v.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 v.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 xt=0;xt<pt.length;xt++){const ft=pt[xt];Tl(ft,k,z),B.add(ft)}else Tl(pt,k,z),B.add(pt)}),b=x.pop(),B},this.compileAsync=function(v,L,k=null){const B=this.compile(v,L,k);return new Promise(z=>{function pt(){if(B.forEach(function(xt){H.get(xt).currentProgram.isReady()&&B.delete(xt)}),B.size===0){z(v);return}setTimeout(pt,10)}Jt.get("KHR_parallel_shader_compile")!==null?pt():setTimeout(pt,10)})};let js=null;function ku(v){js&&js(v)}function Al(){$n.stop()}function wl(){$n.start()}const $n=new ou;$n.setAnimationLoop(ku),typeof self<"u"&&$n.setContext(self),this.setAnimationLoop=function(v){js=v,Mt.setAnimationLoop(v),v===null?$n.stop():$n.start()},Mt.addEventListener("sessionstart",Al),Mt.addEventListener("sessionend",wl),this.render=function(v,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(v,L);const k=Mt.enabled===!0&&Mt.isPresenting===!0,B=T!==null&&(Q===null||k)&&T.begin(I,Q);if(v.matrixWorldAutoUpdate===!0&&v.updateMatrixWorld(),L.parent===null&&L.matrixWorldAutoUpdate===!0&&L.updateMatrixWorld(),Mt.enabled===!0&&Mt.isPresenting===!0&&(T===null||T.isCompositing()===!1)&&(Mt.cameraAutoUpdate===!0&&Mt.updateCamera(L),L=Mt.getCamera()),v.isScene===!0&&v.onBeforeRender(I,v,L,Q),b=ct.get(v,x.length),b.init(L),b.state.textureUnits=X.getTextureUnits(),x.push(b),$t.multiplyMatrices(L.projectionMatrix,L.matrixWorldInverse),Nt.setFromProjectionMatrix($t,fn,L.reversedDepth),Lt=this.localClippingEnabled,Dt=Rt.init(this.clippingPlanes,Lt),y=ut.get(v,R.length),y.init(),R.push(y),Mt.enabled===!0&&Mt.isPresenting===!0){const xt=I.xr.getDepthSensingMesh();xt!==null&&ta(xt,L,-1/0,I.sortObjects)}ta(v,L,0,I.sortObjects),y.finish(),I.sortObjects===!0&&y.sort(G,Ct,L.reversedDepth),he=Mt.enabled===!1||Mt.isPresenting===!1||Mt.hasDepthSensing()===!1,he&&Bt.addToRenderList(y,v),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Dt===!0&&Rt.beginShadows();const z=b.state.shadowsArray;if(Ut.render(z,v,L),Dt===!0&&Rt.endShadows(),(B&&T.hasRenderPass())===!1){const xt=y.opaque,ft=y.transmissive;if(b.setupLights(),L.isArrayCamera){const St=L.cameras;if(ft.length>0)for(let Tt=0,zt=St.length;Tt<zt;Tt++){const kt=St[Tt];Cl(xt,ft,v,kt)}he&&Bt.render(v);for(let Tt=0,zt=St.length;Tt<zt;Tt++){const kt=St[Tt];Rl(y,v,kt,kt.viewport)}}else ft.length>0&&Cl(xt,ft,v,L),he&&Bt.render(v),Rl(y,v,L)}Q!==null&&V===0&&(X.updateMultisampleRenderTarget(Q),X.updateRenderTargetMipmap(Q)),B&&T.end(I),v.isScene===!0&&v.onAfterRender(I,v,L),mt.resetDefaultState(),et=-1,tt=null,x.pop(),x.length>0?(b=x[x.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 ta(v,L,k,B){if(v.visible===!1)return;if(v.layers.test(L.layers)){if(v.isGroup)k=v.renderOrder;else if(v.isLOD)v.autoUpdate===!0&&v.update(L);else if(v.isLightProbeGrid)b.pushLightProbeGrid(v);else if(v.isLight)b.pushLight(v),v.castShadow&&b.pushShadow(v);else if(v.isSprite){if(!v.frustumCulled||Nt.intersectsSprite(v)){B&&ce.setFromMatrixPosition(v.matrixWorld).applyMatrix4($t);const xt=J.update(v),ft=v.material;ft.visible&&y.push(v,xt,ft,k,ce.z,null)}}else if((v.isMesh||v.isLine||v.isPoints)&&(!v.frustumCulled||Nt.intersectsObject(v))){const xt=J.update(v),ft=v.material;if(B&&(v.boundingSphere!==void 0?(v.boundingSphere===null&&v.computeBoundingSphere(),ce.copy(v.boundingSphere.center)):(xt.boundingSphere===null&&xt.computeBoundingSphere(),ce.copy(xt.boundingSphere.center)),ce.applyMatrix4(v.matrixWorld).applyMatrix4($t)),Array.isArray(ft)){const St=xt.groups;for(let Tt=0,zt=St.length;Tt<zt;Tt++){const kt=St[Tt],At=ft[kt.materialIndex];At&&At.visible&&y.push(v,xt,At,k,ce.z,kt)}}else ft.visible&&y.push(v,xt,ft,k,ce.z,null)}}const pt=v.children;for(let xt=0,ft=pt.length;xt<ft;xt++)ta(pt[xt],L,k,B)}function Rl(v,L,k,B){const{opaque:z,transmissive:pt,transparent:xt}=v;b.setupLightsView(k),Dt===!0&&Rt.setGlobalState(I.clippingPlanes,k),B&&g.viewport(rt.copy(B)),z.length>0&&Rr(z,L,k),pt.length>0&&Rr(pt,L,k),xt.length>0&&Rr(xt,L,k),g.buffers.depth.setTest(!0),g.buffers.depth.setMask(!0),g.buffers.color.setMask(!0),g.setPolygonOffset(!1)}function Cl(v,L,k,B){if((k.isScene===!0?k.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:Ke,minFilter:ri,samples:Math.max(4,E.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:qt.workingColorSpace})}const pt=b.state.transmissionRenderTarget[B.id],xt=B.viewport||rt;pt.setSize(xt.z*I.transmissionResolutionScale,xt.w*I.transmissionResolutionScale);const ft=I.getRenderTarget(),St=I.getActiveCubeFace(),Tt=I.getActiveMipmapLevel();I.setRenderTarget(pt),I.getClearColor(re),Wt=I.getClearAlpha(),Wt<1&&I.setClearColor(16777215,.5),I.clear(),he&&Bt.render(k);const zt=I.toneMapping;I.toneMapping=pn;const kt=B.viewport;if(B.viewport!==void 0&&(B.viewport=void 0),b.setupLightsView(B),Dt===!0&&Rt.setGlobalState(I.clippingPlanes,B),Rr(v,k,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,Pl(ee,k,B,we,_t,ze),_t.side=Zt,_t.needsUpdate=!0,At=!0}}At===!0&&(X.updateMultisampleRenderTarget(pt),X.updateRenderTargetMipmap(pt))}I.setRenderTarget(ft,St,Tt),I.setClearColor(re,Wt),kt!==void 0&&(B.viewport=kt),I.toneMapping=zt}function Rr(v,L,k){const B=L.isScene===!0?L.overrideMaterial:null;for(let z=0,pt=v.length;z<pt;z++){const xt=v[z],{object:ft,geometry:St,group:Tt}=xt;let zt=xt.material;zt.allowOverride===!0&&B!==null&&(zt=B),ft.layers.test(k.layers)&&Pl(ft,L,k,St,zt,Tt)}}function Pl(v,L,k,B,z,pt){v.onBeforeRender(I,L,k,B,z,pt),v.modelViewMatrix.multiplyMatrices(k.matrixWorldInverse,v.matrixWorld),v.normalMatrix.getNormalMatrix(v.modelViewMatrix),z.onBeforeRender(I,L,k,B,v,pt),z.transparent===!0&&z.side===bn&&z.forceSinglePass===!1?(z.side=Fe,z.needsUpdate=!0,I.renderBufferDirect(k,L,B,z,v,pt),z.side=Zn,z.needsUpdate=!0,I.renderBufferDirect(k,L,B,z,v,pt),z.side=bn):I.renderBufferDirect(k,L,B,z,v,pt),v.onAfterRender(I,L,k,B,z,pt)}function Cr(v,L,k){L.isScene!==!0&&(L=oe);const B=H.get(v),z=b.state.lights,pt=b.state.shadowsArray,xt=z.state.version,ft=lt.getParameters(v,z.state,pt,L,k,b.state.lightProbeGridArray),St=lt.getProgramCacheKey(ft);let Tt=B.programs;B.environment=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?L.environment:null,B.fog=L.fog;const zt=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap;B.envMap=it.get(v.envMap||B.environment,zt),B.envMapRotation=B.environment!==null&&v.envMap===null?L.environmentRotation:v.envMapRotation,Tt===void 0&&(v.addEventListener("dispose",an),Tt=new Map,B.programs=Tt);let kt=Tt.get(St);if(kt!==void 0){if(B.currentProgram===kt&&B.lightsStateVersion===xt)return Dl(v,ft),kt}else ft.uniforms=lt.getUniforms(v),U!==null&&v.isNodeMaterial&&U.build(v,k,ft),v.onBeforeCompile(ft,I),kt=lt.acquireProgram(ft,St),Tt.set(St,kt),B.uniforms=ft.uniforms;const At=B.uniforms;return(!v.isShaderMaterial&&!v.isRawShaderMaterial||v.clipping===!0)&&(At.clippingPlanes=Rt.uniform),Dl(v,ft),B.needsLights=qu(v),B.lightsStateVersion=xt,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=kt,B.uniformsList=null,kt}function Il(v){if(v.uniformsList===null){const L=v.currentProgram.getUniforms();v.uniformsList=ws.seqWithValue(L.seq,v.uniforms)}return v.uniformsList}function Dl(v,L){const k=H.get(v);k.outputColorSpace=L.outputColorSpace,k.batching=L.batching,k.batchingColor=L.batchingColor,k.instancing=L.instancing,k.instancingColor=L.instancingColor,k.instancingMorph=L.instancingMorph,k.skinning=L.skinning,k.morphTargets=L.morphTargets,k.morphNormals=L.morphNormals,k.morphColors=L.morphColors,k.morphTargetsCount=L.morphTargetsCount,k.numClippingPlanes=L.numClippingPlanes,k.numIntersection=L.numClipIntersection,k.vertexAlphas=L.vertexAlphas,k.vertexTangents=L.vertexTangents,k.toneMapping=L.toneMapping}function Vu(v,L){if(v.length===0)return null;if(v.length===1)return v[0].texture!==null?v[0]:null;M.setFromMatrixPosition(L.matrixWorld);for(let k=0,B=v.length;k<B;k++){const z=v[k];if(z.texture!==null&&z.boundingBox.containsPoint(M))return z}return null}function Wu(v,L,k,B,z){L.isScene!==!0&&(L=oe),X.resetTextureUnits();const pt=L.fog,xt=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?L.environment:null,ft=Q===null?I.outputColorSpace:Q.isXRRenderTarget===!0?Q.texture.colorSpace:qt.workingColorSpace,St=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Tt=it.get(B.envMap||xt,St),zt=B.vertexColors===!0&&!!k.attributes.color&&k.attributes.color.itemSize===4,kt=!!k.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),At=!!k.morphAttributes.position,jt=!!k.morphAttributes.normal,me=!!k.morphAttributes.color;let de=pn;B.toneMapped&&(Q===null||Q.isXRRenderTarget===!0)&&(de=I.toneMapping);const ee=k.morphAttributes.position||k.morphAttributes.normal||k.morphAttributes.color,we=ee!==void 0?ee.length:0,_t=H.get(B),ze=b.state.lights;if(Dt===!0&&(Lt===!0||v!==tt)){const ae=v===tt&&B.id===et;Rt.setState(B,v,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!==kt||_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=Cr(B,L,z),U&&B.isNodeMaterial&&U.onUpdateProgram(B,We,_t));let on=!1,Dn=!1,fi=!1;const ne=We.getUniforms(),ge=_t.uniforms;if(g.useProgram(We.program)&&(on=!0,Dn=!0,fi=!0),B.id!==et&&(et=B.id,Dn=!0),_t.needsLights){const ae=Vu(b.state.lightProbeGridArray,z);_t.lightProbeGrid!==ae&&(_t.lightProbeGrid=ae,Dn=!0)}if(on||tt!==v){g.buffers.depth.getReversed()&&v.reversedDepth!==!0&&(v._reversedDepth=!0,v.updateProjectionMatrix()),ne.setValue(D,"projectionMatrix",v.projectionMatrix),ne.setValue(D,"viewMatrix",v.matrixWorldInverse);const Un=ne.map.cameraPosition;Un!==void 0&&Un.setValue(D,Kt.setFromMatrixPosition(v.matrixWorld)),E.logarithmicDepthBuffer&&ne.setValue(D,"logDepthBufFC",2/(Math.log(v.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&ne.setValue(D,"isOrthographic",v.isOrthographicCamera===!0),tt!==v&&(tt=v,Dn=!0,fi=!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=k.morphAttributes;if((Ln.position!==void 0||Ln.normal!==void 0||Ln.color!==void 0)&&P.update(z,k,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=z_()),Dn){if(ne.setValue(D,"toneMappingExposure",I.toneMappingExposure),_t.needsLights&&Xu(ge,fi),pt&&B.fog===!0&&bt.refreshFogUniforms(ge,pt),bt.refreshMaterialUniforms(ge,B,nt,st,b.state.transmissionRenderTarget[v.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)}ws.upload(D,Il(_t),ge,X)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(ws.upload(D,Il(_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,pi=ae.length;Un<pi;Un++){const Ll=ae[Un];j.update(Ll,We),j.bind(Ll,We)}}return We}function Xu(v,L){v.ambientLightColor.needsUpdate=L,v.lightProbe.needsUpdate=L,v.directionalLights.needsUpdate=L,v.directionalLightShadows.needsUpdate=L,v.pointLights.needsUpdate=L,v.pointLightShadows.needsUpdate=L,v.spotLights.needsUpdate=L,v.spotLightShadows.needsUpdate=L,v.rectAreaLights.needsUpdate=L,v.hemisphereLights.needsUpdate=L}function qu(v){return v.isMeshLambertMaterial||v.isMeshToonMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isShadowMaterial||v.isShaderMaterial&&v.lights===!0}this.getActiveCubeFace=function(){return W},this.getActiveMipmapLevel=function(){return V},this.getRenderTarget=function(){return Q},this.setRenderTargetTextures=function(v,L,k){const B=H.get(v);B.__autoAllocateDepthBuffer=v.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1&&(B.__useRenderToTexture=!1),H.get(v.texture).__webglTexture=L,H.get(v.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:k,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(v,L){const k=H.get(v);k.__webglFramebuffer=L,k.__useDefaultFramebuffer=L===void 0},this.setRenderTarget=function(v,L=0,k=0){Q=v,W=L,V=k;let B=null,z=!1,pt=!1;if(v){const ft=H.get(v);if(ft.__useDefaultFramebuffer!==void 0){g.bindFramebuffer(D.FRAMEBUFFER,ft.__webglFramebuffer),rt.copy(v.viewport),gt.copy(v.scissor),Vt=v.scissorTest,g.viewport(rt),g.scissor(gt),g.setScissorTest(Vt),et=-1;return}else if(ft.__webglFramebuffer===void 0)X.setupRenderTarget(v);else if(ft.__hasExternalTextures)X.rebindTextures(v,H.get(v.texture).__webglTexture,H.get(v.depthTexture).__webglTexture);else if(v.depthBuffer){const zt=v.depthTexture;if(ft.__boundDepthTexture!==zt){if(zt!==null&&H.has(zt)&&(v.width!==zt.image.width||v.height!==zt.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");X.setupDepthRenderbuffer(v)}}const St=v.texture;(St.isData3DTexture||St.isDataArrayTexture||St.isCompressedArrayTexture)&&(pt=!0);const Tt=H.get(v).__webglFramebuffer;v.isWebGLCubeRenderTarget?(Array.isArray(Tt[L])?B=Tt[L][k]:B=Tt[L],z=!0):v.samples>0&&X.useMultisampledRTT(v)===!1?B=H.get(v).__webglMultisampledFramebuffer:Array.isArray(Tt)?B=Tt[k]:B=Tt,rt.copy(v.viewport),gt.copy(v.scissor),Vt=v.scissorTest}else rt.copy(Pt).multiplyScalar(nt).floor(),gt.copy(wt).multiplyScalar(nt).floor(),Vt=vt;if(k!==0&&(B=Y),g.bindFramebuffer(D.FRAMEBUFFER,B)&&g.drawBuffers(v,B),g.viewport(rt),g.scissor(gt),g.setScissorTest(Vt),z){const ft=H.get(v.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+L,ft.__webglTexture,k)}else if(pt){const ft=L;for(let St=0;St<v.textures.length;St++){const Tt=H.get(v.textures[St]);D.framebufferTextureLayer(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0+St,Tt.__webglTexture,k,ft)}}else if(v!==null&&k!==0){const ft=H.get(v.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,ft.__webglTexture,k)}et=-1},this.readRenderTargetPixels=function(v,L,k,B,z,pt,xt,ft=0){if(!(v&&v.isWebGLRenderTarget)){Xt("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let St=H.get(v).__webglFramebuffer;if(v.isWebGLCubeRenderTarget&&xt!==void 0&&(St=St[xt]),St){g.bindFramebuffer(D.FRAMEBUFFER,St);try{const Tt=v.textures[ft],zt=Tt.format,kt=Tt.type;if(v.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(kt)){Xt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}L>=0&&L<=v.width-B&&k>=0&&k<=v.height-z&&D.readPixels(L,k,B,z,ht.convert(zt),ht.convert(kt),pt)}finally{const Tt=Q!==null?H.get(Q).__webglFramebuffer:null;g.bindFramebuffer(D.FRAMEBUFFER,Tt)}}},this.readRenderTargetPixelsAsync=async function(v,L,k,B,z,pt,xt,ft=0){if(!(v&&v.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let St=H.get(v).__webglFramebuffer;if(v.isWebGLCubeRenderTarget&&xt!==void 0&&(St=St[xt]),St)if(L>=0&&L<=v.width-B&&k>=0&&k<=v.height-z){g.bindFramebuffer(D.FRAMEBUFFER,St);const Tt=v.textures[ft],zt=Tt.format,kt=Tt.type;if(v.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(kt))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,k,B,z,ht.convert(zt),ht.convert(kt),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 ad(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(v,L=null,k=0){const B=Math.pow(2,-k),z=Math.floor(v.image.width*B),pt=Math.floor(v.image.height*B),xt=L!==null?L.x:0,ft=L!==null?L.y:0;X.setTexture2D(v,0),D.copyTexSubImage2D(D.TEXTURE_2D,k,0,0,xt,ft,z,pt),g.unbindTexture()},this.copyTextureToTexture=function(v,L,k=null,B=null,z=0,pt=0){let xt,ft,St,Tt,zt,kt,At,jt,me;const de=v.isCompressedTexture?v.mipmaps[pt]:v.image;if(k!==null)xt=k.max.x-k.min.x,ft=k.max.y-k.min.y,St=k.isBox3?k.max.z-k.min.z:1,Tt=k.min.x,zt=k.min.y,kt=k.isBox3?k.min.z:0;else{const ge=Math.pow(2,-z);xt=Math.floor(de.width*ge),ft=Math.floor(de.height*ge),v.isDataArrayTexture?St=de.depth:v.isData3DTexture?St=Math.floor(de.depth*ge):St=1,Tt=0,zt=0,kt=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,kt);const fi=v.isDataArrayTexture||v.isData3DTexture,ne=L.isDataArrayTexture||L.isData3DTexture;if(v.isDepthTexture){const ge=H.get(v),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 pi=0;pi<St;pi++)fi&&(D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,H.get(v).__webglTexture,z,kt+pi),D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,H.get(L).__webglTexture,pt,me+pi)),D.blitFramebuffer(Tt,zt,xt,ft,At,jt,xt,ft,D.DEPTH_BUFFER_BIT,D.NEAREST);g.bindFramebuffer(D.READ_FRAMEBUFFER,null),g.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else if(z!==0||v.isRenderTargetTexture||H.has(v)){const ge=H.get(v),Ln=H.get(L);g.bindFramebuffer(D.READ_FRAMEBUFFER,Z),g.bindFramebuffer(D.DRAW_FRAMEBUFFER,O);for(let ae=0;ae<St;ae++)fi?D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,ge.__webglTexture,z,kt+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,xt,ft,At,jt,xt,ft,D.COLOR_BUFFER_BIT,D.NEAREST):ne?D.copyTexSubImage3D(_t,pt,At,jt,me+ae,Tt,zt,xt,ft):D.copyTexSubImage2D(_t,pt,At,jt,Tt,zt,xt,ft);g.bindFramebuffer(D.READ_FRAMEBUFFER,null),g.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else ne?v.isDataTexture||v.isData3DTexture?D.texSubImage3D(_t,pt,At,jt,me,xt,ft,St,ee,we,de.data):L.isCompressedArrayTexture?D.compressedTexSubImage3D(_t,pt,At,jt,me,xt,ft,St,ee,de.data):D.texSubImage3D(_t,pt,At,jt,me,xt,ft,St,ee,we,de):v.isDataTexture?D.texSubImage2D(D.TEXTURE_2D,pt,At,jt,xt,ft,ee,we,de.data):v.isCompressedTexture?D.compressedTexSubImage2D(D.TEXTURE_2D,pt,At,jt,de.width,de.height,ee,de.data):D.texSubImage2D(D.TEXTURE_2D,pt,At,jt,xt,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(v){H.get(v).__webglFramebuffer===void 0&&X.setupRenderTarget(v)},this.initTexture=function(v){v.isCubeTexture?X.setTextureCube(v,0):v.isData3DTexture?X.setTexture3D(v,0):v.isDataArrayTexture||v.isCompressedArrayTexture?X.setTexture2DArray(v,0):X.setTexture2D(v,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 ko=Math.PI/180,zc=180/Math.PI;function wr(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 Rs(i,t,e){return i+(t-i)*e}function Bs(i,t,e){return[Rs(i[0],t[0],e),Rs(i[1],t[1],e),Rs(i[2],t[2],e)]}function mu(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 r=Hn[n],s=Hn[n+1];if(t>=r.altitudeDeg&&t<=s.altitudeDeg){const a=(t-r.altitudeDeg)/(s.altitudeDeg-r.altitudeDeg);return{zenith:Bs(r.zenith,s.zenith,a),horizon:Bs(r.horizon,s.horizon,a)}}}const e=Hn[Hn.length-1];return{zenith:e.zenith,horizon:e.horizon}}function H_(i){if(i<=-18)return 7.5;if(i>=0)return-4;const n=(i+18)/18;return Rs(7.5,-4,n)}const k_=-1.5,V_=7.5;function Gc(i){const t=10**(-.4*i),e=10**(-.4*k_),n=10**(-.4*V_);return wr((t-n)/(e-n),0,1)}function dr(i,t,e){const n=i*ko,r=t*ko,s=e*Math.cos(n);return{x:s*Math.sin(r),y:e*Math.sin(n),z:-s*Math.cos(r)}}function W_(i,t,e){const n=Math.sqrt(i*i+t*t+e*e),r=n===0?0:Math.asin(wr(t/n,-1,1))*zc,s=(Math.atan2(i,-e)*zc+360)%360;return{altitudeDeg:r,azimuthDeg:s}}function X_(i,t){const e=Math.abs(i-t)%360;return e>180?360-e:e}function q_(i,t,e){const n=Math.max(0,1-X_(i,t)/90),r=Math.max(0,1-Math.abs(e)/18);return n*r}function Y_(i,t,e,n){const{zenith:r,horizon:s}=mu(n),a=wr((i+90)/180,0,1),o=Bs(s,r,a),l=q_(t,e,n);return l<=0?o:Bs(o,s,l*(1-a)*.8)}function Hc(i){return .3+.7*i}const Z_=-4;function $_(i){return Math.max(0,Z_-i)}const K_=6,J_=60;function Q_(i){return Math.min(J_,K_*Math.sqrt(i))}const j_=3,t1=.55;function e1(i){return t1*wr(i/j_,0,1)}function n1(i){const t=Math.max(i,-4),e=Math.sin(t*ko)+.50572*Math.pow(t+6.07995,-1.6364);return wr(1/e,1,40)}function kc(i){const t=n1(i)-1;return[1,Math.exp(-.022*t),Math.exp(-.062*t)]}const gu=[{maxBrightness:.5,size:1.2},{maxBrightness:.85,size:2},{maxBrightness:1/0,size:3.2}];function i1(i){return gu.findIndex(t=>i<=t.maxBrightness)}const r1=.25,Vc=.3,s1=2.2;function a1(i,{phase:t,speedFactor:e},n){const s=1+r1*(Vc+(1-Vc)*i)*Math.sin(n*s1*e+t);return Math.min(1,Math.max(0,s))}/**
|
|
4324
4340
|
@preserve
|
|
4325
4341
|
|
|
4326
4342
|
Astronomy library for JavaScript (browser and Node.js).
|
|
@@ -4351,4 +4367,140 @@ void main() {
|
|
|
4351
4367
|
* @fileoverview Astronomy calculation library for browser scripting and Node.js.
|
|
4352
4368
|
* @author Don Cross <cosinekitty@gmail.com>
|
|
4353
4369
|
* @license MIT
|
|
4354
|
-
*/const b0=173.1446326846693,ei=14959787069098932e-8,it=.017453292519943295,Mc=.26179938779914946,Wn=57.29577951308232,T0=3.819718634205488,c_=365.24217,Sc=new Date("2000-01-01T12:00:00Z"),Mn=2*Math.PI,zn=3600*(180/Math.PI),Di=484813681109536e-20,A0=10800*60,u_=2*A0,Ec=7292115e-11,h_=A0/Math.PI,f_=-.17-5*Math.log10(h_),vo=.996647180302104,d_=vo*vo,Mo=6378.1366,p_=Mo/ei,w0=81.30056,Jo=.0002959122082855911,So=2825345909524226e-22,Eo=8459715185680659e-23,yo=1292024916781969e-23,bo=1524358900784276e-23;function xs(i){if(i!==!0&&i!==!1)throw console.trace(),`Value is not boolean: ${i}`;return i}function Et(i){if(!Number.isFinite(i))throw console.trace(),`Value is not a finite number: ${i}`;return i}function Pi(i){return i-Math.floor(i)}function m_(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 r=(i.x*e.x+i.y*e.y+i.z*e.z)/Math.sqrt(t*n);return r<=-1?180:r>=1?0:Wn*Math.acos(r)}var Ee;(function(i){i.Sun="Sun",i.Moon="Moon",i.Mercury="Mercury",i.Venus="Venus",i.Earth="Earth",i.Mars="Mars",i.Jupiter="Jupiter",i.Saturn="Saturn",i.Uranus="Uranus",i.Neptune="Neptune",i.Pluto="Pluto",i.SSB="SSB",i.EMB="EMB",i.Star1="Star1",i.Star2="Star2",i.Star3="Star3",i.Star4="Star4",i.Star5="Star5",i.Star6="Star6",i.Star7="Star7",i.Star8="Star8"})(Ee||(Ee={}));const g_=[Ee.Star1,Ee.Star2,Ee.Star3,Ee.Star4,Ee.Star5,Ee.Star6,Ee.Star7,Ee.Star8],__=[{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 x_(i){const e=g_.indexOf(i);return e>=0?__[e]:null}function Qo(i){const e=x_(i);return e&&e.dist>0?e:null}var Zt;(function(i){i[i.From2000=0]="From2000",i[i.Into2000=1]="Into2000"})(Zt||(Zt={}));const bn={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 v_(i){var e,t,n,r,s,a,o;const l=2e3+(i-14)/c_;return l<-500?(e=(l-1820)/100,-20+32*e*e):l<500?(e=l/100,t=e*e,n=e*t,r=t*t,s=t*n,a=n*n,10583.6-1014.41*e+33.78311*t-5.952053*n-.1798452*r+.022174192*s+.0090316521*a):l<1600?(e=(l-1e3)/100,t=e*e,n=e*t,r=t*t,s=t*n,a=n*n,1574.2-556.01*e+71.23472*t+.319781*n-.8503463*r-.005050998*s+.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,r=t*t,8.83+.1603*e-.0059285*t+13336e-8*n-r/1174e3):l<1860?(e=l-1800,t=e*e,n=e*t,r=t*t,s=t*n,a=n*n,o=n*r,13.72-.332447*e+.0068612*t+.0041116*n-37436e-8*r+121272e-10*s-1699e-10*a+875e-12*o):l<1900?(e=l-1860,t=e*e,n=e*t,r=t*t,s=t*n,7.62+.5737*e-.251754*t+.01680668*n-.0004473624*r+s/233174):l<1920?(e=l-1900,t=e*e,n=e*t,r=t*t,-2.79+1.494119*e-.0598939*t+.0061966*n-197e-6*r):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,r=t*t,s=t*n,63.86+.3345*e-.060374*t+.0017275*n+651814e-9*r+2373599e-11*s):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 M_=v_;function yc(i){return i+M_(i)/86400}class Fi{constructor(e){if(e instanceof Fi){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()-Sc.getTime())/t,this.tt=yc(this.ut);return}if(Number.isFinite(e)){this.date=new Date(Sc.getTime()+e*t),this.ut=e,this.tt=yc(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 Fi(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 Fi(this.ut+e)}}function $t(i){return i instanceof Fi?i:new Fi(i)}function S_(i){function e(u){return u%u_*Di}const t=i.tt/36525,n=e(128710479305e-5+t*1295965810481e-4),r=e(335779.526232+t*17395272628478e-4),s=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,f=2*(r-s+a);return o=Math.sin(f),l=Math.cos(f),c+=(-13170906-1675*t)*o-13696*l,h+=(5730336-3015*t)*l-4587*o,f=2*(r+a),o=Math.sin(f),l=Math.cos(f),c+=(-2276413-234*t)*o+2796*l,h+=(978459-485*t)*l+1374*o,f=2*a,o=Math.sin(f),l=Math.cos(f),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 R0(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 Zr;function jo(i){if(!Zr||Math.abs(Zr.tt-i.tt)>1e-6){const e=S_(i),t=R0(i),n=t+e.deps/3600;Zr={tt:i.tt,dpsi:e.dpsi,deps:e.deps,ee:e.dpsi*Math.cos(t*it)/15,mobl:t,tobl:n}}return Zr}function E_(i,e){const t=i*it,n=Math.cos(t),r=Math.sin(t);return[e[0],e[1]*n-e[2]*r,e[1]*r+e[2]*n]}function y_(i,e){return E_(R0(i),e)}function b_(i){const e=i.tt/36525;function t(we,ve){const Ue=[];let De;for(De=0;De<=ve-we;++De)Ue.push(0);return{min:we,array:Ue}}function n(we,ve,Ue,De){const Ie=[];for(let Ze=0;Ze<=ve-we;++Ze)Ie.push(t(Ue,De));return{min:we,array:Ie}}function r(we,ve,Ue){const De=we.array[ve-we.min];return De.array[Ue-De.min]}function s(we,ve,Ue,De){const Ie=we.array[ve-we.min];Ie.array[Ue-Ie.min]=De}let a,o,l,c,h,f,u,g,_,S,m,d,A,w,M,T,y,R,x,b,I,C,N,Y=n(-6,6,1,4),K=n(-6,6,1,4);function O(we,ve){return r(Y,we,ve)}function W(we,ve){return r(K,we,ve)}function H(we,ve,Ue){return s(Y,we,ve,Ue)}function Q(we,ve,Ue){return s(K,we,ve,Ue)}function te(we,ve,Ue,De,Ie){Ie(we*Ue-ve*De,ve*Ue+we*De)}function ee(we){return Math.sin(Mn*we)}u=e*e,_=0,N=0,m=0,d=3422.7;var re=ee(.19833+.05611*e),ge=ee(.27869+.04508*e),He=ee(.16827-.36903*e),rt=ee(.34734-5.37261*e),We=ee(.10498-5.37899*e),Z=ee(.42681-.41855*e),se=ee(.14943-5.37511*e);for(R=.84*re+.31*ge+14.27*He+7.26*rt+.28*We+.24*Z,x=2.94*re+.31*ge+14.27*He+9.34*rt+1.12*We+.83*Z,b=-6.4*re-1.89*Z,I=.21*re+.31*ge+14.27*He-88.7*rt-15.3*We+.24*Z-1.86*se,C=R-b,g=-3332e-9*ee(.59734-5.37261*e)-539e-9*ee(.35498-5.37899*e)-64e-9*ee(.39943-5.37511*e),A=Mn*Pi(.60643382+1336.85522467*e-313e-8*u)+R/zn,w=Mn*Pi(.37489701+1325.55240982*e+2565e-8*u)+x/zn,M=Mn*Pi(.99312619+99.99735956*e-44e-8*u)+b/zn,T=Mn*Pi(.25909118+1342.2278298*e-892e-8*u)+I/zn,y=Mn*Pi(.82736186+1236.85308708*e-397e-8*u)+C/zn,h=1;h<=4;++h){switch(h){case 1:l=w,o=4,c=1.000002208;break;case 2:l=M,o=3,c=.997504612-.002495388*e;break;case 3:l=T,o=4,c=1.000002708+139.978*g;break;case 4:l=y,o=6,c=1;break;default:throw`Internal error: I = ${h}`}for(H(0,h,1),H(1,h,Math.cos(l)*c),Q(0,h,0),Q(1,h,Math.sin(l)*c),f=2;f<=o;++f)te(O(f-1,h),W(f-1,h),O(1,h),W(1,h),(we,ve)=>(H(f,h,we),Q(f,h,ve)));for(f=1;f<=o;++f)H(-f,h,O(f,h)),Q(-f,h,-W(f,h))}function ne(we,ve,Ue,De){for(var Ie={x:1,y:0},Ze=[0,we,ve,Ue,De],$e=1;$e<=4;++$e)Ze[$e]!==0&&te(Ie.x,Ie.y,O(Ze[$e],$e),W(Ze[$e],$e),(ct,ot)=>(Ie.x=ct,Ie.y=ot));return Ie}function G(we,ve,Ue,De,Ie,Ze,$e,ct){var ot=ne(Ie,Ze,$e,ct);_+=we*ot.y,N+=ve*ot.y,m+=Ue*ot.x,d+=De*ot.x}G(13.902,14.06,-.001,.2607,0,0,0,4),G(.403,-4.01,.394,.0023,0,0,0,3),G(2369.912,2373.36,.601,28.2333,0,0,0,2),G(-125.154,-112.79,-.725,-.9781,0,0,0,1),G(1.979,6.98,-.445,.0433,1,0,0,4),G(191.953,192.72,.029,3.0861,1,0,0,2),G(-8.466,-13.51,.455,-.1093,1,0,0,1),G(22639.5,22609.07,.079,186.5398,1,0,0,0),G(18.609,3.59,-.094,.0118,1,0,0,-1),G(-4586.465,-4578.13,-.077,34.3117,1,0,0,-2),G(3.215,5.44,.192,-.0386,1,0,0,-3),G(-38.428,-38.64,.001,.6008,1,0,0,-4),G(-.393,-1.43,-.092,.0086,1,0,0,-6),G(-.289,-1.59,.123,-.0053,0,1,0,4),G(-24.42,-25.1,.04,-.3,0,1,0,2),G(18.023,17.93,.007,.1494,0,1,0,1),G(-668.146,-126.98,-1.302,-.3997,0,1,0,0),G(.56,.32,-.001,-.0037,0,1,0,-1),G(-165.145,-165.06,.054,1.9178,0,1,0,-2),G(-1.877,-6.46,-.416,.0339,0,1,0,-4),G(.213,1.02,-.074,.0054,2,0,0,4),G(14.387,14.78,-.017,.2833,2,0,0,2),G(-.586,-1.2,.054,-.01,2,0,0,1),G(769.016,767.96,.107,10.1657,2,0,0,0),G(1.75,2.01,-.018,.0155,2,0,0,-1),G(-211.656,-152.53,5.679,-.3039,2,0,0,-2),G(1.225,.91,-.03,-.0088,2,0,0,-3),G(-30.773,-34.07,-.308,.3722,2,0,0,-4),G(-.57,-1.4,-.074,.0109,2,0,0,-6),G(-2.921,-11.75,.787,-.0484,1,1,0,2),G(1.267,1.52,-.022,.0164,1,1,0,1),G(-109.673,-115.18,.461,-.949,1,1,0,0),G(-205.962,-182.36,2.056,1.4437,1,1,0,-2),G(.233,.36,.012,-.0025,1,1,0,-3),G(-4.391,-9.66,-.471,.0673,1,1,0,-4),G(.283,1.53,-.111,.006,1,-1,0,4),G(14.577,31.7,-1.54,.2302,1,-1,0,2),G(147.687,138.76,.679,1.1528,1,-1,0,0),G(-1.089,.55,.021,0,1,-1,0,-1),G(28.475,23.59,-.443,-.2257,1,-1,0,-2),G(-.276,-.38,-.006,-.0036,1,-1,0,-3),G(.636,2.27,.146,-.0102,1,-1,0,-4),G(-.189,-1.68,.131,-.0028,0,2,0,2),G(-7.486,-.66,-.037,-.0086,0,2,0,0),G(-8.096,-16.35,-.74,.0918,0,2,0,-2),G(-5.741,-.04,0,-9e-4,0,0,2,2),G(.255,0,0,0,0,0,2,1),G(-411.608,-.2,0,-.0124,0,0,2,0),G(.584,.84,0,.0071,0,0,2,-1),G(-55.173,-52.14,0,-.1052,0,0,2,-2),G(.254,.25,0,-.0017,0,0,2,-3),G(.025,-1.67,0,.0031,0,0,2,-4),G(1.06,2.96,-.166,.0243,3,0,0,2),G(36.124,50.64,-1.3,.6215,3,0,0,0),G(-13.193,-16.4,.258,-.1187,3,0,0,-2),G(-1.187,-.74,.042,.0074,3,0,0,-4),G(-.293,-.31,-.002,.0046,3,0,0,-6),G(-.29,-1.45,.116,-.0051,2,1,0,2),G(-7.649,-10.56,.259,-.1038,2,1,0,0),G(-8.627,-7.59,.078,-.0192,2,1,0,-2),G(-2.74,-2.54,.022,.0324,2,1,0,-4),G(1.181,3.32,-.212,.0213,2,-1,0,2),G(9.703,11.67,-.151,.1268,2,-1,0,0),G(-.352,-.37,.001,-.0028,2,-1,0,-1),G(-2.494,-1.17,-.003,-.0017,2,-1,0,-2),G(.36,.2,-.012,-.0043,2,-1,0,-4),G(-1.167,-1.25,.008,-.0106,1,2,0,0),G(-7.412,-6.12,.117,.0484,1,2,0,-2),G(-.311,-.65,-.032,.0044,1,2,0,-4),G(.757,1.82,-.105,.0112,1,-2,0,2),G(2.58,2.32,.027,.0196,1,-2,0,0),G(2.533,2.4,-.014,-.0212,1,-2,0,-2),G(-.344,-.57,-.025,.0036,0,3,0,-2),G(-.992,-.02,0,0,1,0,2,2),G(-45.099,-.02,0,-.001,1,0,2,0),G(-.179,-9.52,0,-.0833,1,0,2,-2),G(-.301,-.33,0,.0014,1,0,2,-4),G(-6.382,-3.37,0,-.0481,1,0,-2,2),G(39.528,85.13,0,-.7136,1,0,-2,0),G(9.366,.71,0,-.0112,1,0,-2,-2),G(.202,.02,0,0,1,0,-2,-4),G(.415,.1,0,.0013,0,1,2,0),G(-2.152,-2.26,0,-.0066,0,1,2,-2),G(-1.44,-1.3,0,.0014,0,1,-2,2),G(.384,-.04,0,0,0,1,-2,-2),G(1.938,3.6,-.145,.0401,4,0,0,0),G(-.952,-1.58,.052,-.013,4,0,0,-2),G(-.551,-.94,.032,-.0097,3,1,0,0),G(-.482,-.57,.005,-.0045,3,1,0,-2),G(.681,.96,-.026,.0115,3,-1,0,0),G(-.297,-.27,.002,-9e-4,2,2,0,-2),G(.254,.21,-.003,0,2,-2,0,-2),G(-.25,-.22,.004,.0014,1,3,0,-2),G(-3.996,0,0,4e-4,2,0,2,0),G(.557,-.75,0,-.009,2,0,2,-2),G(-.459,-.38,0,-.0053,2,0,-2,2),G(-1.298,.74,0,4e-4,2,0,-2,0),G(.538,1.14,0,-.0141,2,0,-2,-2),G(.263,.02,0,0,1,1,2,0),G(.426,.07,0,-6e-4,1,1,-2,-2),G(-.304,.03,0,3e-4,1,-1,2,0),G(-.372,-.19,0,-.0027,1,-1,-2,2),G(.418,0,0,0,0,0,4,0),G(-.33,-.04,0,0,3,0,2,0);function Ce(we,ve,Ue,De,Ie){return we*ne(ve,Ue,De,Ie).y}S=0,S+=Ce(-526.069,0,0,1,-2),S+=Ce(-3.352,0,0,1,-4),S+=Ce(44.297,1,0,1,-2),S+=Ce(-6,1,0,1,-4),S+=Ce(20.599,-1,0,1,0),S+=Ce(-30.598,-1,0,1,-2),S+=Ce(-24.649,-2,0,1,0),S+=Ce(-2,-2,0,1,-2),S+=Ce(-22.571,0,1,1,-2),S+=Ce(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=T+N/zn;let Pe=(1.000002708+139.978*g)*(18518.511+1.189+m)*Math.sin(a)-6.24*Math.sin(3*a)+S;return{geo_eclip_lon:Mn*Pi((A+_/zn)/Mn),geo_eclip_lat:Math.PI/(180*3600)*Pe,distance_au:zn*p_/(.999953253*d)}}function C0(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 vs(i,e,t){const n=T_(e,t);return C0(n,i)}function T_(i,e){const t=i.tt/36525;let n=84381.406,r=((((-951e-10*t+132851e-9)*t-.00114045)*t-1.0790069)*t+5038.481507)*t,s=((((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*=Di,r*=Di,s*=Di,a*=Di;const o=Math.sin(n),l=Math.cos(n),c=Math.sin(-r),h=Math.cos(-r),f=Math.sin(-s),u=Math.cos(-s),g=Math.sin(a),_=Math.cos(a),S=_*h-c*g*u,m=_*c*l+g*u*h*l-o*g*f,d=_*c*o+g*u*h*o+l*g*f,A=-g*h-c*_*u,w=-g*c*l+_*u*h*l-o*_*f,M=-g*c*o+_*u*h*o+l*_*f,T=c*f,y=-f*h*l-o*u,R=-f*h*o+u*l;if(e===Zt.Into2000)return new Ms([[S,m,d],[A,w,M],[T,y,R]]);if(e===Zt.From2000)return new Ms([[S,A,T],[m,w,y],[d,M,R]]);throw"Invalid precess direction"}function A_(i){const e=.779057273264+.00273781191135448*i.ut,t=i.ut%1;let n=360*((e+t)%1);return n<0&&(n+=360),n}let $r;function P0(i){if(!$r||$r.tt!==i.tt){const e=i.tt/36525;let t=15*jo(i).ee;const n=A_(i);let s=((t+.014506+((((-368e-10*e-29956e-9)*e-44e-8)*e+1.3915817)*e+4612.156534)*e)/3600+n)%360/15;s<0&&(s+=24),$r={tt:i.tt,st:s}}return $r.st}function w_(i,e){const t=i.latitude*it,n=Math.sin(t),r=Math.cos(t),s=1/Math.hypot(r,vo*n),a=d_*s,o=i.height/1e3,l=Mo*s+o,c=Mo*a+o,h=(15*e+i.longitude)*it,f=Math.sin(h),u=Math.cos(h);return{pos:[l*r*u/ei,l*r*f/ei,c*n/ei],vel:[-Ec*l*r*f*86400/ei,Ec*l*r*u*86400/ei,0]}}function To(i,e,t){const n=R_(e,t);return C0(n,i)}function R_(i,e){const t=jo(i),n=t.mobl*it,r=t.tobl*it,s=t.dpsi*Di,a=Math.cos(n),o=Math.sin(n),l=Math.cos(r),c=Math.sin(r),h=Math.cos(s),f=Math.sin(s),u=h,g=-f*a,_=-f*o,S=f*l,m=h*a*l+o*c,d=h*o*l-a*c,A=f*c,w=h*a*c-o*l,M=h*o*c+a*l;if(e===Zt.From2000)return new Ms([[u,S,A],[g,m,w],[_,d,M]]);if(e===Zt.Into2000)return new Ms([[u,g,_],[S,m,d],[A,w,M]]);throw"Invalid precess direction"}function D0(i,e,t){return t===Zt.Into2000?vs(To(i,e,t),e,t):To(vs(i,e,t),e,t)}function C_(i,e){const t=P0(i),n=w_(e,t).pos;return D0(n,i,Zt.Into2000)}class gt{constructor(e,t,n,r){this.x=e,this.y=t,this.z=n,this.t=r}Length(){return Math.hypot(this.x,this.y,this.z)}}class kn{constructor(e,t,n,r,s,a,o){this.x=e,this.y=t,this.z=n,this.vx=r,this.vy=s,this.vz=a,this.t=o}}class P_{constructor(e,t,n){this.lat=Et(e),this.lon=Et(t),this.dist=Et(n)}}class bc{constructor(e,t,n,r){this.ra=Et(e),this.dec=Et(t),this.dist=Et(n),this.vec=r}}class Ms{constructor(e){this.rot=e}}class D_{constructor(e,t,n,r){this.azimuth=Et(e),this.altitude=Et(t),this.ra=Et(n),this.dec=Et(r)}}class I_{constructor(e,t,n){this.vec=e,this.elat=Et(t),this.elon=Et(n)}}function L_(i,e){return new gt(i[0],i[1],i[2],e)}function U_(i,e){const t=L_(i,e),n=t.x*t.x+t.y*t.y,r=Math.sqrt(n+t.z*t.z);if(n===0){if(t.z===0)throw"Indeterminate sky coordinates";return new bc(0,t.z<0?-90:90,r,t)}let s=T0*Math.atan2(t.y,t.x);s<0&&(s+=24);const a=Wn*Math.atan2(i[2],Math.sqrt(n));return new bc(s,a,r,t)}function da(i,e){const t=i*it,n=Math.cos(t),r=Math.sin(t);return[n*e[0]+r*e[1],n*e[1]-r*e[0],e[2]]}function I0(i,e,t,n,r){let s=$t(i);el(e),Et(t),Et(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),f=Math.cos(n*it),u=Math.sin(t*Mc),g=Math.cos(t*Mc);let _=[o*c,o*l,a],S=[-a*c,-a*l,o],m=[l,-c,0];const d=-15*P0(s);let A=da(d,_),w=da(d,S),M=da(d,m),T=[f*g,f*u,h];const y=T[0]*A[0]+T[1]*A[1]+T[2]*A[2],R=T[0]*w[0]+T[1]*w[1]+T[2]*w[2],x=T[0]*M[0]+T[1]*M[1]+T[2]*M[2];let b=Math.hypot(R,x),I;b>0?(I=-Wn*Math.atan2(x,R),I<0&&(I+=360)):I=0;let C=Wn*Math.atan2(b,y),N=t,Y=n;{let K=C,O=n1(r,90-C);if(C-=O,O>0&&C>3e-4){const W=Math.sin(C*it),H=Math.cos(C*it),Q=Math.sin(K*it),te=Math.cos(K*it),ee=[];for(let re=0;re<3;++re)ee.push((T[re]-te*A[re])/Q*W+A[re]*H);b=Math.hypot(ee[0],ee[1]),b>0?(N=T0*Math.atan2(ee[1],ee[0]),N<0&&(N+=24)):N=0,Y=Wn*Math.atan2(ee[2],b)}}return new D_(I,90-C,N,Y)}function el(i){if(!(i instanceof L0))throw`Not an instance of the Observer class: ${i}`;if(Et(i.latitude),Et(i.longitude),Et(i.height),i.latitude<-90||i.latitude>90)throw`Latitude ${i.latitude} is out of range. Must be -90..+90.`;return i}class L0{constructor(e,t,n){this.latitude=e,this.longitude=t,this.height=n,el(this)}}function N_(i,e,t,n,r){el(t),xs(n),xs(r);const s=$t(e),a=C_(s,t),o=No(i,s,r),l=[o.x-a[0],o.y-a[1],o.z-a[2]],c=D0(l,s,Zt.From2000);return U_(c,s)}function F_(i,e,t){const n=i.x,r=i.y*e+i.z*t,s=-i.y*t+i.z*e,a=Math.hypot(n,r);let o=0;a>0&&(o=Wn*Math.atan2(r,n),o<0&&(o+=360));let l=Wn*Math.atan2(s,a),c=new gt(n,r,s,i.t);return new I_(c,l,o)}function Ao(i){const e=jo(i.t),t=[i.x,i.y,i.z],n=vs(t,i.t,Zt.From2000),[r,s,a]=To(n,i.t,Zt.From2000),o=new gt(r,s,a,i.t),l=e.tobl*it;return F_(o,Math.cos(l),Math.sin(l))}function ki(i){const e=$t(i),t=b_(e),n=t.distance_au*Math.cos(t.geo_eclip_lat),r=[n*Math.cos(t.geo_eclip_lon),n*Math.sin(t.geo_eclip_lon),t.distance_au*Math.sin(t.geo_eclip_lat)],s=y_(e,r),a=vs(s,e,Zt.Into2000);return new gt(a[0],a[1],a[2],e)}function U0(i){const e=$t(i),t=1e-5,n=e.AddDays(-t),r=e.AddDays(+t),s=ki(n),a=ki(r);return new kn((s.x+a.x)/2,(s.y+a.y)/2,(s.z+a.z)/2,(a.x-s.x)/(2*t),(a.y-s.y)/(2*t),(a.z-s.z)/(2*t),e)}function O_(i){const e=$t(i),t=U0(e),n=1+w0;return new kn(t.x/n,t.y/n,t.z/n,t.vx/n,t.vy/n,t.vz/n,e)}function Oi(i,e,t){let n=1,r=0;for(let s of i){let a=0;for(let[l,c,h]of s)a+=l*Math.cos(c+e*h);let o=n*a;t&&(o%=Mn),r+=o,n*=e}return r}function pa(i,e){let t=1,n=0,r=0,s=0;for(let a of i){let o=0,l=0;for(let[c,h,f]of a){let u=h+e*f;o+=c*f*Math.sin(u),s>0&&(l+=c*Math.cos(u))}r+=s*n*l-t*o,n=t,t*=e,++s}return r}const ar=365250,wo=0,Ro=1,Co=2;function Po(i){return new wt(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 N0(i,e,t){const n=t*Math.cos(e),r=Math.cos(i),s=Math.sin(i);return[n*r,n*s,t*Math.sin(e)]}function lr(i,e){const t=e.tt/ar,n=Oi(i[wo],t,!0),r=Oi(i[Ro],t,!1),s=Oi(i[Co],t,!1),a=N0(n,r,s);return Po(a).ToAstroVector(e)}function Do(i,e){const t=e/ar,n=Oi(i[wo],t,!0),r=Oi(i[Ro],t,!1),s=Oi(i[Co],t,!1),a=pa(i[wo],t),o=pa(i[Ro],t),l=pa(i[Co],t),c=Math.cos(n),h=Math.sin(n),f=Math.cos(r),u=Math.sin(r),g=+(l*f*c)-s*u*c*o-s*f*h*a,_=+(l*f*h)-s*u*h*o+s*f*c*a,S=+(l*u)+s*f*o,m=N0(n,r,s),d=[g/ar,_/ar,S/ar],A=Po(m),w=Po(d);return new li(e,A,w)}function Jr(i,e,t,n){const r=n/(n+Jo),s=lr(bn[t],e);i.x+=r*s.x,i.y+=r*s.y,i.z+=r*s.z}function B_(i){const e=new gt(0,0,0,i);return Jr(e,i,Ee.Jupiter,So),Jr(e,i,Ee.Saturn,Eo),Jr(e,i,Ee.Uranus,yo),Jr(e,i,Ee.Neptune,bo),e}const Io=51,z_=29200,Ii=146,Sn=201,ii=[[-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 wt{constructor(e,t,n){this.x=e,this.y=t,this.z=n}clone(){return new wt(this.x,this.y,this.z)}ToAstroVector(e){return new gt(this.x,this.y,this.z,e)}static zero(){return new wt(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(e){return new wt(this.x+e.x,this.y+e.y,this.z+e.z)}sub(e){return new wt(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 wt(e*this.x,e*this.y,e*this.z)}div(e){return new wt(this.x/e,this.y/e,this.z/e)}mean(e){return new wt((this.x+e.x)/2,(this.y+e.y)/2,(this.z+e.z)/2)}neg(){return new wt(-this.x,-this.y,-this.z)}}class li{constructor(e,t,n){this.tt=e,this.r=t,this.v=n}clone(){return new li(this.tt,this.r,this.v)}sub(e){return new li(this.tt,this.r.sub(e.r),this.v.sub(e.v))}}function G_(i){let[e,[t,n,r],[s,a,o]]=i;return new li(e,new wt(t,n,r),new wt(s,a,o))}function Qr(i,e,t,n){const r=n/(n+Jo),s=Do(bn[t],e);return i.r.incr(s.r.mul(r)),i.v.incr(s.v.mul(r)),s}function nr(i,e,t){const n=t.sub(i),r=n.quadrature();return n.mul(e/(r*Math.sqrt(r)))}class Cs{constructor(e){let t=new li(e,new wt(0,0,0),new wt(0,0,0));this.Jupiter=Qr(t,e,Ee.Jupiter,So),this.Saturn=Qr(t,e,Ee.Saturn,Eo),this.Uranus=Qr(t,e,Ee.Uranus,yo),this.Neptune=Qr(t,e,Ee.Neptune,bo),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 li(e,t.r.mul(-1),t.v.mul(-1))}Acceleration(e){let t=nr(e,Jo,this.Sun.r);return t.incr(nr(e,So,this.Jupiter.r)),t.incr(nr(e,Eo,this.Saturn.r)),t.incr(nr(e,yo,this.Uranus.r)),t.incr(nr(e,bo,this.Neptune.r)),t}}class Ps{constructor(e,t,n,r){this.tt=e,this.r=t,this.v=n,this.a=r}clone(){return new Ps(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class F0{constructor(e,t){this.bary=e,this.grav=t}}function Ss(i,e,t,n){return new wt(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 Tc(i,e,t){return new wt(e.x+i*t.x,e.y+i*t.y,e.z+i*t.z)}function Lo(i,e){const t=i-e.tt,n=new Cs(i),r=Ss(t,e.r,e.v,e.a),s=n.Acceleration(r).mean(e.a),a=Ss(t,e.r,e.v,s),o=e.v.add(s.mul(t)),l=n.Acceleration(a),c=new Ps(i,a,o,l);return new F0(n,c)}const V_=[];function O0(i,e){const t=Math.floor(i);return t<0?0:t>=e?e-1:t}function Uo(i){const e=G_(i),t=new Cs(e.tt),n=e.r.add(t.Sun.r),r=e.v.add(t.Sun.v),s=t.Acceleration(n),a=new Ps(e.tt,n,r,s);return new F0(t,a)}function k_(i,e){const t=ii[0][0];if(e<t||e>ii[Io-1][0])return null;const n=O0((e-t)/z_,Io-1);if(!i[n]){const s=i[n]=[];s[0]=Uo(ii[n]).grav,s[Sn-1]=Uo(ii[n+1]).grav;let a,o=s[0].tt;for(a=1;a<Sn-1;++a)s[a]=Lo(o+=Ii,s[a-1]).grav;o=s[Sn-1].tt;var r=[];for(r[Sn-1]=s[Sn-1],a=Sn-2;a>0;--a)r[a]=Lo(o-=Ii,r[a+1]).grav;for(a=Sn-2;a>0;--a){const l=a/(Sn-1);s[a].r=s[a].r.mul(1-l).add(r[a].r.mul(l)),s[a].v=s[a].v.mul(1-l).add(r[a].v.mul(l)),s[a].a=s[a].a.mul(1-l).add(r[a].a.mul(l))}}return i[n]}function Ac(i,e,t){let n=Uo(i);const r=Math.ceil((e-n.grav.tt)/t);for(let s=0;s<r;++s)n=Lo(s+1===r?e:n.grav.tt+t,n.grav);return n}function B0(i,e){let t,n,r;const s=k_(V_,i.tt);if(s){const a=O0((i.tt-s[0].tt)/Ii,Sn-1),o=s[a],l=s[a+1],c=o.a.mean(l.a),h=Ss(i.tt-o.tt,o.r,o.v,c),f=Tc(i.tt-o.tt,o.v,c),u=Ss(i.tt-l.tt,l.r,l.v,c),g=Tc(i.tt-l.tt,l.v,c),_=(i.tt-o.tt)/Ii;t=h.mul(1-_).add(u.mul(_)),n=f.mul(1-_).add(g.mul(_))}else{let a;i.tt<ii[0][0]?a=Ac(ii[0],i.tt,-Ii):a=Ac(ii[Io-1],i.tt,+Ii),t=a.grav.r,n=a.grav.v,r=a.bary}return r||(r=new Cs(i.tt)),t=t.sub(r.Sun.r),n=n.sub(r.Sun.v),new kn(t.x,t.y,t.z,n.x,n.y,n.z,i)}function ri(i,e){var t=$t(e);if(i in bn)return lr(bn[i],t);if(i===Ee.Pluto){const a=B0(t);return new gt(a.x,a.y,a.z,t)}if(i===Ee.Sun)return new gt(0,0,0,t);if(i===Ee.Moon){var n=lr(bn.Earth,t),r=ki(t);return new gt(n.x+r.x,n.y+r.y,n.z+r.z,t)}if(i===Ee.EMB){const a=lr(bn.Earth,t),o=ki(t),l=1+w0;return new gt(a.x+o.x/l,a.y+o.y/l,a.z+o.z/l,t)}if(i===Ee.SSB)return B_(t);const s=Qo(i);if(s){const a=new P_(s.dec,15*s.ra,s.dist);return t1(a,t)}throw`HelioVector: Unknown body "${i}"`}function H_(i,e){let t=e,n=0;for(let r=0;r<10;++r){const s=i(t),a=s.Length()/b0;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 s;t=o}throw`Light-travel time solver did not converge: dt = ${n}`}class W_{constructor(e,t,n,r){this.observerBody=e,this.targetBody=t,this.aberration=n,this.observerPos=r}Position(e){this.aberration&&(this.observerPos=ri(this.observerBody,e));const t=ri(this.targetBody,e);return new gt(t.x-this.observerPos.x,t.y-this.observerPos.y,t.z-this.observerPos.z,e)}}function X_(i,e,t,n){xs(n);const r=$t(i);if(Qo(t)){const o=ri(t,r);if(n){const c=Y_(e,r),h=new gt(o.x-c.x,o.y-c.y,o.z-c.z,r),f=b0/h.Length();return new gt(h.x+c.vx/f,h.y+c.vy/f,h.z+c.vz/f,r)}const l=ri(e,r);return new gt(o.x-l.x,o.y-l.y,o.z-l.z,r)}let s;n?s=new gt(0,0,0,r):s=ri(e,r);const a=new W_(e,t,n,s);return H_(o=>a.Position(o),r)}function No(i,e,t){xs(t);const n=$t(e);switch(i){case Ee.Earth:return new gt(0,0,0,n);case Ee.Moon:return ki(n);default:const r=X_(n,Ee.Earth,i,t);return r.t=n,r}}function q_(i,e){return new kn(i.r.x,i.r.y,i.r.z,i.v.x,i.v.y,i.v.z,e)}function Y_(i,e){const t=$t(e);switch(i){case Ee.Sun:return new kn(0,0,0,0,0,0,t);case Ee.SSB:const n=new Cs(t.tt);return new kn(-n.Sun.r.x,-n.Sun.r.y,-n.Sun.r.z,-n.Sun.v.x,-n.Sun.v.y,-n.Sun.v.z,t);case Ee.Mercury:case Ee.Venus:case Ee.Earth:case Ee.Mars:case Ee.Jupiter:case Ee.Saturn:case Ee.Uranus:case Ee.Neptune:const r=Do(bn[i],t.tt);return q_(r,t);case Ee.Pluto:return B0(t);case Ee.Moon:case Ee.EMB:const s=Do(bn.Earth,t.tt),a=i==Ee.Moon?U0(t):O_(t);return new kn(a.x+s.r.x,a.y+s.r.y,a.z+s.r.z,a.vx+s.v.x,a.vy+s.v.y,a.vz+s.v.z,t);default:if(Qo(i)){const o=ri(i,t);return new kn(o.x,o.y,o.z,0,0,0,t)}throw`HelioState: Unsupported body "${i}"`}}function K_(i){for(;i<0;)i+=360;for(;i>=360;)i-=360;return i}function Z_(i,e,t){if(i===Ee.Earth||e===Ee.Earth)throw"The Earth does not have a longitude as seen from itself.";const n=$t(t),r=No(i,n,!1),s=Ao(r),a=No(e,n,!1),o=Ao(a);return K_(s.elon-o.elon)}function $_(i,e,t,n){let r,s=0,a=0,o=0;switch(i){case Ee.Mercury:r=-.6,s=4.98,a=-4.88,o=3.02;break;case Ee.Venus:e<163.6?(r=-4.47,s=1.03,a=.57,o=.13):(r=.98,s=-1.02);break;case Ee.Mars:r=-1.52,s=1.6;break;case Ee.Jupiter:r=-9.4,s=.5;break;case Ee.Uranus:r=-7.19,s=.25;break;case Ee.Neptune:r=-6.87;break;case Ee.Pluto:r=-1,s=4;break;default:throw`VisualMagnitude: unsupported body ${i}`}const l=e/100;let c=r+l*(s+l*(a+l*o));return c+=5*Math.log10(t*n),c}function J_(i,e,t,n,r){const s=Ao(n),a=it*28.06,o=it*(169.51+382e-7*r.tt),l=it*s.elat,c=it*s.elon,h=Math.asin(Math.sin(l)*Math.cos(a)-Math.cos(l)*Math.sin(a)*Math.sin(c-o)),f=Math.sin(Math.abs(h));let u=-9+.044*i;return u+=f*(-2.6+1.2*f),u+=5*Math.log10(e*t),{mag:u,ring_tilt:Wn*h}}function Q_(i,e,t){let n=i*it,r=n*n,s=r*r,a=-12.717+1.49*Math.abs(n)+.0431*s;const o=385000.6/ei;let l=t/o;return a+=5*Math.log10(e*l),a}class j_{constructor(e,t,n,r,s,a,o,l){this.time=e,this.mag=t,this.phase_angle=n,this.helio_dist=r,this.geo_dist=s,this.gc=a,this.hc=o,this.ring_tilt=l,this.phase_fraction=(1+Math.cos(it*n))/2}}function z0(i,e){if(i===Ee.Earth)throw"The illumination of the Earth is not defined.";const t=$t(e),n=lr(bn.Earth,t);let r,s,a,o;i===Ee.Sun?(a=new gt(-n.x,-n.y,-n.z,t),s=new gt(0,0,0,t),r=0):(i===Ee.Moon?(a=ki(t),s=new gt(n.x+a.x,n.y+a.y,n.z+a.z,t)):(s=ri(i,e),a=new gt(s.x-n.x,s.y-n.y,s.z-n.z,t)),r=m_(a,s));let l=a.Length(),c=s.Length(),h;if(i===Ee.Sun)o=f_+5*Math.log10(l);else if(i===Ee.Moon)o=Q_(r,c,l);else if(i===Ee.Saturn){const f=J_(r,c,l,a,t);o=f.mag,h=f.ring_tilt}else o=$_(i,r,c,l);return new j_(t,o,r,c,l,a,s,h)}function e1(i){return Z_(Ee.Moon,Ee.Sun,i)}var wc;(function(i){i[i.Pericenter=0]="Pericenter",i[i.Apocenter=1]="Apocenter"})(wc||(wc={}));function t1(i,e){e=$t(e);const t=i.lat*it,n=i.lon*it,r=i.dist*Math.cos(t);return new gt(r*Math.cos(n),r*Math.sin(n),i.dist*Math.sin(t),e)}function n1(i,e){let t;if(Et(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 Rc;(function(i){i.Penumbral="penumbral",i.Partial="partial",i.Annular="annular",i.Total="total"})(Rc||(Rc={}));var Cc;(function(i){i[i.Invalid=0]="Invalid",i[i.Ascending=1]="Ascending",i[i.Descending=-1]="Descending"})(Cc||(Cc={}));const i1=["Venus","Mars","Jupiter","Saturn"];function G0(i){return new L0(i.lat,i.lng,i.elevationM)}function r1(i,e,t,n){const r=I0(t,G0(n),i,e,"normal");return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}function ma(i,e,t){const n=G0(t),r=N_(Ee[i],e,n,!0,!0),s=I0(e,n,r.ra,r.dec,"normal");return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}function ga(i,e){return z0(Ee[i],e).mag}function s1(i){const e=e1(i),t=z0(Ee.Moon,i);return{phaseFraction:e/360,illuminatedFraction:t.phase_fraction}}const a1=2e3,o1=3,l1=20;function c1(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??a1,r=i.month??(t?1:o1),s=i.day??(t?1:l1),a=Math.round(e/15);return new Date(Date.UTC(n,r-1,s,(i.hour??12)-a,i.minute??0,i.second??0))}const jr=900,u1=900,h1=850,Pc=850,_a=4,f1=1.5,d1=-1,p1=6,Dc=-4,m1=[{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"}],g1=880,Ic=40,_1={Venus:new Oe(1,.96,.85),Mars:new Oe(1,.55,.4),Jupiter:new Oe(.95,.87,.72),Saturn:new Oe(.92,.86,.68)};class x1{renderer;scene=new yh;camera;skyMesh;groundMesh;starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;compassSprites=[];showCompass=!1;animationFrameId=null;raycaster=new Xh;constructor(e){this.renderer=new kg({canvas:e,antialias:!0}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),this.camera=new Xt(60,e.width/Math.max(e.height,1),.1,jr*1.2),this.camera.position.set(0,1.6,0)}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*xa,-e.headingDeg*xa,0,"YXZ"):this.camera.rotation.set(e.pitchDeg*xa,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())}setShowCompass(e){this.showCompass!==e&&(this.showCompass=e,this.disposeCompassLabels(),e&&this.buildCompassLabels(),this.render())}setAstronomy(e){const t=E0(e.sun.altitudeDeg).horizon;this.buildSky(e.sun),this.buildGround(t),this.buildStars(e.stars,e.sun.altitudeDeg),this.setBodyMesh("sun",e.sun,_a,new Oe(1,.96,.88),e.sun.magnitude),this.setMoonMesh(e.moon),this.buildPlanets(e.planets),this.scene.fog=new Yo(new Oe(...t),jr*.2,jr),this.render()}render(){this.renderer.render(this.scene,this.camera)}pickBodyAt(e,t){this.raycaster.setFromCamera(new Ve(e,t),this.camera);const n=[...this.hitAreas.entries()],r=this.raycaster.intersectObjects(n.map(([,s])=>s))[0];if(r)return n.find(([,s])=>s===r.object)?.[0]}dispose(){this.stopTwinkle(),this.disposeMesh(this.skyMesh),this.disposeMesh(this.groundMesh),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.starTiers.length===0)return;const e=t=>{this.updateTwinkle(t/1e3),this.render(),this.animationFrameId=requestAnimationFrame(e)};this.animationFrameId=requestAnimationFrame(e)}stopTwinkle(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}buildSky(e){this.disposeMesh(this.skyMesh);const t=new gs(jr,32,16),n=t.attributes.position,r=[];for(let a=0;a<n.count;a++){const{altitudeDeg:o,azimuthDeg:l}=qg(n.getX(a),n.getY(a),n.getZ(a)),c=Zg(o,l,e.azimuthDeg,e.altitudeDeg);r.push(c[0],c[1],c[2])}t.setAttribute("color",new Pt(r,3));const s=new or({vertexColors:!0,side:Lt,fog:!1});this.skyMesh=new Kt(t,s),this.scene.add(this.skyMesh)}buildGround(e){this.disposeMesh(this.groundMesh);const t=new $o(u1,48),n=new Oe(e[0]*.35,e[1]*.35,e[2]*.35),r=new or({color:n,fog:!0});this.groundMesh=new Kt(t,r),this.groundMesh.rotation.x=-Math.PI/2,this.groundMesh.position.y=-.5,this.scene.add(this.groundMesh)}setBodyMesh(e,t,n,r,s){if(this.disposeMesh(this.bodyMeshes.get(e)),this.disposeHitArea(e),this.disposeGlare(e),t.altitudeDeg<Dc){this.bodyMeshes.delete(e);return}const{x:a,y:o,z:l}=Kr(t.altitudeDeg,t.azimuthDeg,Pc),c=xc(t.altitudeDeg),h=new Oe(r.r*c[0],r.g*c[1],r.b*c[2]),f=new gs(n,16,16),u=new or({color:h,fog:!1}),g=new Kt(f,u);g.position.set(a,o,l),this.scene.add(g),this.bodyMeshes.set(e,g),this.setHitArea(e,a,o,l,n),this.setGlare(e,a,o,l,s,h)}setMoonMesh(e){const t="moon";if(this.disposeMesh(this.bodyMeshes.get(t)),this.disposeHitArea(t),this.disposeGlare(t),e.altitudeDeg<Dc){this.bodyMeshes.delete(t);return}const{x:n,y:r,z:s}=Kr(e.altitudeDeg,e.azimuthDeg,Pc),a=xc(e.altitudeDeg),o=new Oe(a[0],a[1],a[2]),l=new rr({map:S1(e.phase),color:o,fog:!1}),c=new Pr(l);c.position.set(n,r,s);const h=_a*2;c.scale.set(h,h,1),this.scene.add(c),this.bodyMeshes.set(t,c),this.setHitArea(t,n,r,s,_a),this.setGlare(t,n,r,s,e.magnitude,o)}setHitArea(e,t,n,r,s){const a=new rr({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1}),o=new Pr(a);o.position.set(t,n,r);const l=s*p1;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,r,s,a){this.disposeGlare(e);const o=Jg(s);if(o<=0)return;const l=e_(o),c=new rr({map:M1(),color:a,transparent:!0,opacity:i_(o),blending:ya,depthWrite:!1,fog:!1}),h=new Pr(c);h.position.set(t,n,r),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 r=gc(n.magnitude),s=_c(r),a=_1[n.body]??new Oe(1,1,1),o=new Oe(a.r*s,a.g*s,a.b*s),l=f1*(.5+.5*r);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.stopTwinkle();return}const{catalog:n,date:r,observer:s}=e,a=Hg(t),o=y1(1337),l=[];for(let c=0;c<n.count;c++){const h=n.mag[c];if(h>a)continue;const{altitudeDeg:f,azimuthDeg:u}=r1(n.ra[c],n.dec[c],r,s);if(f<d1)continue;const{x:g,y:_,z:S}=Kr(f,u,h1);l.push({x:g,y:_,z:S,brightness:gc(h),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}this.starTiers=y0.map((c,h)=>{const f=l.filter(M=>s_(M.brightness)===h),u=new Float32Array(f.length*3),g=new Float32Array(f.length),_=new Float32Array(f.length),S=new Float32Array(f.length);f.forEach((M,T)=>{u[T*3]=M.x,u[T*3+1]=M.y,u[T*3+2]=M.z,g[T]=M.brightness,_[T]=M.phase,S[T]=M.speedFactor});const m=new Ft;m.setAttribute("position",new Gt(u,3));const d=new Gt(new Float32Array(f.length*3),3);m.setAttribute("color",d);const A=new o0({vertexColors:!0,size:c.size,sizeAttenuation:!1,fog:!1}),w=new Uh(m,A);return this.scene.add(w),{points:w,colorAttribute:d,brightness:g,phase:_,speedFactor:S}}),this.updateTwinkle(0),this.startTwinkle()}updateTwinkle(e){for(const t of this.starTiers){const n=t.colorAttribute.array;for(let r=0;r<t.brightness.length;r++){const s=l_(t.brightness[r],{phase:t.phase[r],speedFactor:t.speedFactor[r]},e),a=_c(t.brightness[r])*s;n[r*3]=a,n[r*3+1]=a,n[r*3+2]=a}t.colorAttribute.needsUpdate=!0}}buildCompassLabels(){this.compassSprites=m1.map(({azimuthDeg:e,label:t})=>{const n=new rr({map:E1(t),depthTest:!1,fog:!1}),r=new Pr(n),{x:s,y:a,z:o}=Kr(0,e,g1);return r.position.set(s,a,o),r.scale.set(Ic,Ic,1),this.scene.add(r),r})}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;Array.isArray(t)?t.forEach(n=>n.dispose()):t.dispose()}}const xa=Math.PI/180;function v1(i,e,t){return Math.max(e,Math.min(t,i))}let es;function M1(){if(es)return es;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),es=new Zo(e),es}function S1(i){const t=document.createElement("canvas");t.width=128,t.height=128;const n=t.getContext("2d"),r=128/2-2,s=128/2,a=128/2,o="#2e2b26",l="#f4f1e2";n.fillStyle=o,n.beginPath(),n.arc(s,a,r,0,Math.PI*2),n.fill();const c=v1(i.illuminatedFraction,0,1),h=i.phaseFraction<.5,f=r*Math.abs(1-2*c),u=c<.5;return n.save(),n.beginPath(),n.arc(s,a,r,0,Math.PI*2),n.clip(),n.fillStyle=l,n.beginPath(),h?(n.arc(s,a,r,-Math.PI/2,Math.PI/2,!1),n.ellipse(s,a,f,r,0,Math.PI/2,-Math.PI/2,u)):(n.arc(s,a,r,Math.PI/2,-Math.PI/2,!1),n.ellipse(s,a,f,r,0,-Math.PI/2,Math.PI/2,u)),n.fill(),n.restore(),new Zo(t)}function E1(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 Zo(e)}function y1(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 Lc=new Map;function b1(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 T1(i){let e=Lc.get(i);return e||(e=fetch(i).then(t=>t.arrayBuffer()).then(b1),Lc.set(i,e)),e}Oc();const A1={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"}},w1=["en","fr"],R1=new URL(""+new URL("assets/stars-mag7.5-DDr9QasD.bin",import.meta.url).href,import.meta.url).href,C1={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},va={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class P1 extends HTMLElement{static get observedAttributes(){return["src","star-catalog-src","show-compass"]}shadow;stageElement;frameElement;sceneCanvas;ufoElement;sceneRenderer;bodyTooltip;resizeObserver;lastTimeMs=0;starCatalog;handleFullscreenChange=()=>this.resizeToStage();handlePointerMove=e=>{const n=this.ufoElement.canvasElement.getBoundingClientRect();if(n.width===0||n.height===0)return;const r=(e.clientX-n.left)/n.width*2-1,s=-((e.clientY-n.top)/n.height*2-1),a=this.sceneRenderer.pickBodyAt(r,s);if(!a){this.bodyTooltip.hidden=!0;return}const o=Nc(navigator.languages,w1);this.bodyTooltip.textContent=A1[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};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>${Z0}</style>${K0}`,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 x1(this.sceneCanvas),this.bodyTooltip=this.shadow.getElementById("body-tooltip"),this.ufoElement=document.createElement(Ea),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)}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()}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"))}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)}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")??R1;this.starCatalog=await T1(e),this.updateAstronomy(this.lastTimeMs)}updateAstronomy(e){const t=this.ufoElement.sighting,n=cu(t,e);this.sceneRenderer.setObserverPose(n??va);const r=n?.lat??va.lat,s=n?.lng??va.lng,a=c1(t.event.time??{},s);if(!a){this.sceneRenderer.setAstronomy(C1);return}const o=new Date(a.getTime()+e),l={lat:r,lng:s,elevationM:n?.elevationM??0},c={...ma("Sun",o,l),magnitude:ga("Sun",o)},h={...ma("Moon",o,l),phase:s1(o),magnitude:ga("Moon",o)},f=i1.map(u=>({body:u,position:ma(u,o,l),magnitude:ga(u,o)}));this.sceneRenderer.setAstronomy({sun:c,moon:h,planets:f,stars:this.starCatalog?{catalog:this.starCatalog,date:o,observer:l}:void 0})}}const Uc="rr0-scene";function D1(){Oc(),customElements.get(Uc)||customElements.define(Uc,P1)}D1();
|
|
4370
|
+
*/const _u=173.1446326846693,ii=14959787069098932e-8,ie=.017453292519943295,Wc=.26179938779914946,Yn=57.29577951308232,xu=3.819718634205488,o1=365.24217,Xc=new Date("2000-01-01T12:00:00Z"),yn=2*Math.PI,kn=3600*(180/Math.PI),Bi=484813681109536e-20,vu=10800*60,l1=2*vu,qc=7292115e-11,c1=vu/Math.PI,h1=-.17-5*Math.log10(c1),Vo=.996647180302104,u1=Vo*Vo,Wo=6378.1366,d1=Wo/ii,Mu=81.30056,Ml=.0002959122082855911,Xo=2825345909524226e-22,qo=8459715185680659e-23,Yo=1292024916781969e-23,Zo=1524358900784276e-23;function zs(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 Li(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 r=(i.x*t.x+i.y*t.y+i.z*t.z)/Math.sqrt(e*n);return r<=-1?180:r>=1?0:Yn*Math.acos(r)}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 p1=[yt.Star1,yt.Star2,yt.Star3,yt.Star4,yt.Star5,yt.Star6,yt.Star7,yt.Star8],m1=[{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 g1(i){const t=p1.indexOf(i);return t>=0?m1[t]:null}function Sl(i){const t=g1(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 _1(i){var t,e,n,r,s,a,o;const l=2e3+(i-14)/o1;return l<-500?(t=(l-1820)/100,-20+32*t*t):l<500?(t=l/100,e=t*t,n=t*e,r=e*e,s=e*n,a=n*n,10583.6-1014.41*t+33.78311*e-5.952053*n-.1798452*r+.022174192*s+.0090316521*a):l<1600?(t=(l-1e3)/100,e=t*t,n=t*e,r=e*e,s=e*n,a=n*n,1574.2-556.01*t+71.23472*e+.319781*n-.8503463*r-.005050998*s+.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,r=e*e,8.83+.1603*t-.0059285*e+13336e-8*n-r/1174e3):l<1860?(t=l-1800,e=t*t,n=t*e,r=e*e,s=e*n,a=n*n,o=n*r,13.72-.332447*t+.0068612*e+.0041116*n-37436e-8*r+121272e-10*s-1699e-10*a+875e-12*o):l<1900?(t=l-1860,e=t*t,n=t*e,r=e*e,s=e*n,7.62+.5737*t-.251754*e+.01680668*n-.0004473624*r+s/233174):l<1920?(t=l-1900,e=t*t,n=t*e,r=e*e,-2.79+1.494119*t-.0598939*e+.0061966*n-197e-6*r):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,r=e*e,s=e*n,63.86+.3345*t-.060374*e+.0017275*n+651814e-9*r+2373599e-11*s):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 x1=_1;function Yc(i){return i+x1(i)/86400}class Wi{constructor(t){if(t instanceof Wi){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()-Xc.getTime())/e,this.tt=Yc(this.ut);return}if(Number.isFinite(t)){this.date=new Date(Xc.getTime()+t*e),this.ut=t,this.tt=Yc(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 Wi(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 Wi(this.ut+t)}}function je(i){return i instanceof Wi?i:new Wi(i)}function v1(i){function t(u){return u%l1*Bi}const e=i.tt/36525,n=t(128710479305e-5+e*1295965810481e-4),r=t(335779.526232+e*17395272628478e-4),s=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*(r-s+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*(r+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 Su(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 as;function yl(i){if(!as||Math.abs(as.tt-i.tt)>1e-6){const t=v1(i),e=Su(i),n=e+t.deps/3600;as={tt:i.tt,dpsi:t.dpsi,deps:t.deps,ee:t.dpsi*Math.cos(e*ie)/15,mobl:e,tobl:n}}return as}function M1(i,t){const e=i*ie,n=Math.cos(e),r=Math.sin(e);return[t[0],t[1]*n-t[2]*r,t[1]*r+t[2]*n]}function S1(i,t){return M1(Su(i),t)}function y1(i){const t=i.tt/36525;function e(wt,vt){const Nt=[];let Dt;for(Dt=0;Dt<=vt-wt;++Dt)Nt.push(0);return{min:wt,array:Nt}}function n(wt,vt,Nt,Dt){const Lt=[];for(let $t=0;$t<=vt-wt;++$t)Lt.push(e(Nt,Dt));return{min:wt,array:Lt}}function r(wt,vt,Nt){const Dt=wt.array[vt-wt.min];return Dt.array[Nt-Dt.min]}function s(wt,vt,Nt,Dt){const Lt=wt.array[vt-wt.min];Lt.array[Nt-Lt.min]=Dt}let a,o,l,c,h,d,u,p,_,S,m,f,A,w,M,y,b,R,x,T,I,C,U,Y=n(-6,6,1,4),Z=n(-6,6,1,4);function O(wt,vt){return r(Y,wt,vt)}function W(wt,vt){return r(Z,wt,vt)}function V(wt,vt,Nt){return s(Y,wt,vt,Nt)}function Q(wt,vt,Nt){return s(Z,wt,vt,Nt)}function et(wt,vt,Nt,Dt,Lt){Lt(wt*Nt-vt*Dt,vt*Nt+wt*Dt)}function tt(wt){return Math.sin(yn*wt)}u=t*t,_=0,U=0,m=0,f=3422.7;var rt=tt(.19833+.05611*t),gt=tt(.27869+.04508*t),Vt=tt(.16827-.36903*t),re=tt(.34734-5.37261*t),Wt=tt(.10498-5.37899*t),$=tt(.42681-.41855*t),st=tt(.14943-5.37511*t);for(R=.84*rt+.31*gt+14.27*Vt+7.26*re+.28*Wt+.24*$,x=2.94*rt+.31*gt+14.27*Vt+9.34*re+1.12*Wt+.83*$,T=-6.4*rt-1.89*$,I=.21*rt+.31*gt+14.27*Vt-88.7*re-15.3*Wt+.24*$-1.86*st,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*Li(.60643382+1336.85522467*t-313e-8*u)+R/kn,w=yn*Li(.37489701+1325.55240982*t+2565e-8*u)+x/kn,M=yn*Li(.99312619+99.99735956*t-44e-8*u)+T/kn,y=yn*Li(.25909118+1342.2278298*t-892e-8*u)+I/kn,b=yn*Li(.82736186+1236.85308708*t-397e-8*u)+C/kn,h=1;h<=4;++h){switch(h){case 1:l=w,o=4,c=1.000002208;break;case 2:l=M,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,vt)=>(V(d,h,wt),Q(d,h,vt)));for(d=1;d<=o;++d)V(-d,h,O(d,h)),Q(-d,h,-W(d,h))}function nt(wt,vt,Nt,Dt){for(var Lt={x:1,y:0},$t=[0,wt,vt,Nt,Dt],Kt=1;Kt<=4;++Kt)$t[Kt]!==0&&et(Lt.x,Lt.y,O($t[Kt],Kt),W($t[Kt],Kt),(ce,oe)=>(Lt.x=ce,Lt.y=oe));return Lt}function G(wt,vt,Nt,Dt,Lt,$t,Kt,ce){var oe=nt(Lt,$t,Kt,ce);_+=wt*oe.y,U+=vt*oe.y,m+=Nt*oe.x,f+=Dt*oe.x}G(13.902,14.06,-.001,.2607,0,0,0,4),G(.403,-4.01,.394,.0023,0,0,0,3),G(2369.912,2373.36,.601,28.2333,0,0,0,2),G(-125.154,-112.79,-.725,-.9781,0,0,0,1),G(1.979,6.98,-.445,.0433,1,0,0,4),G(191.953,192.72,.029,3.0861,1,0,0,2),G(-8.466,-13.51,.455,-.1093,1,0,0,1),G(22639.5,22609.07,.079,186.5398,1,0,0,0),G(18.609,3.59,-.094,.0118,1,0,0,-1),G(-4586.465,-4578.13,-.077,34.3117,1,0,0,-2),G(3.215,5.44,.192,-.0386,1,0,0,-3),G(-38.428,-38.64,.001,.6008,1,0,0,-4),G(-.393,-1.43,-.092,.0086,1,0,0,-6),G(-.289,-1.59,.123,-.0053,0,1,0,4),G(-24.42,-25.1,.04,-.3,0,1,0,2),G(18.023,17.93,.007,.1494,0,1,0,1),G(-668.146,-126.98,-1.302,-.3997,0,1,0,0),G(.56,.32,-.001,-.0037,0,1,0,-1),G(-165.145,-165.06,.054,1.9178,0,1,0,-2),G(-1.877,-6.46,-.416,.0339,0,1,0,-4),G(.213,1.02,-.074,.0054,2,0,0,4),G(14.387,14.78,-.017,.2833,2,0,0,2),G(-.586,-1.2,.054,-.01,2,0,0,1),G(769.016,767.96,.107,10.1657,2,0,0,0),G(1.75,2.01,-.018,.0155,2,0,0,-1),G(-211.656,-152.53,5.679,-.3039,2,0,0,-2),G(1.225,.91,-.03,-.0088,2,0,0,-3),G(-30.773,-34.07,-.308,.3722,2,0,0,-4),G(-.57,-1.4,-.074,.0109,2,0,0,-6),G(-2.921,-11.75,.787,-.0484,1,1,0,2),G(1.267,1.52,-.022,.0164,1,1,0,1),G(-109.673,-115.18,.461,-.949,1,1,0,0),G(-205.962,-182.36,2.056,1.4437,1,1,0,-2),G(.233,.36,.012,-.0025,1,1,0,-3),G(-4.391,-9.66,-.471,.0673,1,1,0,-4),G(.283,1.53,-.111,.006,1,-1,0,4),G(14.577,31.7,-1.54,.2302,1,-1,0,2),G(147.687,138.76,.679,1.1528,1,-1,0,0),G(-1.089,.55,.021,0,1,-1,0,-1),G(28.475,23.59,-.443,-.2257,1,-1,0,-2),G(-.276,-.38,-.006,-.0036,1,-1,0,-3),G(.636,2.27,.146,-.0102,1,-1,0,-4),G(-.189,-1.68,.131,-.0028,0,2,0,2),G(-7.486,-.66,-.037,-.0086,0,2,0,0),G(-8.096,-16.35,-.74,.0918,0,2,0,-2),G(-5.741,-.04,0,-9e-4,0,0,2,2),G(.255,0,0,0,0,0,2,1),G(-411.608,-.2,0,-.0124,0,0,2,0),G(.584,.84,0,.0071,0,0,2,-1),G(-55.173,-52.14,0,-.1052,0,0,2,-2),G(.254,.25,0,-.0017,0,0,2,-3),G(.025,-1.67,0,.0031,0,0,2,-4),G(1.06,2.96,-.166,.0243,3,0,0,2),G(36.124,50.64,-1.3,.6215,3,0,0,0),G(-13.193,-16.4,.258,-.1187,3,0,0,-2),G(-1.187,-.74,.042,.0074,3,0,0,-4),G(-.293,-.31,-.002,.0046,3,0,0,-6),G(-.29,-1.45,.116,-.0051,2,1,0,2),G(-7.649,-10.56,.259,-.1038,2,1,0,0),G(-8.627,-7.59,.078,-.0192,2,1,0,-2),G(-2.74,-2.54,.022,.0324,2,1,0,-4),G(1.181,3.32,-.212,.0213,2,-1,0,2),G(9.703,11.67,-.151,.1268,2,-1,0,0),G(-.352,-.37,.001,-.0028,2,-1,0,-1),G(-2.494,-1.17,-.003,-.0017,2,-1,0,-2),G(.36,.2,-.012,-.0043,2,-1,0,-4),G(-1.167,-1.25,.008,-.0106,1,2,0,0),G(-7.412,-6.12,.117,.0484,1,2,0,-2),G(-.311,-.65,-.032,.0044,1,2,0,-4),G(.757,1.82,-.105,.0112,1,-2,0,2),G(2.58,2.32,.027,.0196,1,-2,0,0),G(2.533,2.4,-.014,-.0212,1,-2,0,-2),G(-.344,-.57,-.025,.0036,0,3,0,-2),G(-.992,-.02,0,0,1,0,2,2),G(-45.099,-.02,0,-.001,1,0,2,0),G(-.179,-9.52,0,-.0833,1,0,2,-2),G(-.301,-.33,0,.0014,1,0,2,-4),G(-6.382,-3.37,0,-.0481,1,0,-2,2),G(39.528,85.13,0,-.7136,1,0,-2,0),G(9.366,.71,0,-.0112,1,0,-2,-2),G(.202,.02,0,0,1,0,-2,-4),G(.415,.1,0,.0013,0,1,2,0),G(-2.152,-2.26,0,-.0066,0,1,2,-2),G(-1.44,-1.3,0,.0014,0,1,-2,2),G(.384,-.04,0,0,0,1,-2,-2),G(1.938,3.6,-.145,.0401,4,0,0,0),G(-.952,-1.58,.052,-.013,4,0,0,-2),G(-.551,-.94,.032,-.0097,3,1,0,0),G(-.482,-.57,.005,-.0045,3,1,0,-2),G(.681,.96,-.026,.0115,3,-1,0,0),G(-.297,-.27,.002,-9e-4,2,2,0,-2),G(.254,.21,-.003,0,2,-2,0,-2),G(-.25,-.22,.004,.0014,1,3,0,-2),G(-3.996,0,0,4e-4,2,0,2,0),G(.557,-.75,0,-.009,2,0,2,-2),G(-.459,-.38,0,-.0053,2,0,-2,2),G(-1.298,.74,0,4e-4,2,0,-2,0),G(.538,1.14,0,-.0141,2,0,-2,-2),G(.263,.02,0,0,1,1,2,0),G(.426,.07,0,-6e-4,1,1,-2,-2),G(-.304,.03,0,3e-4,1,-1,2,0),G(-.372,-.19,0,-.0027,1,-1,-2,2),G(.418,0,0,0,0,0,4,0),G(-.33,-.04,0,0,3,0,2,0);function Ct(wt,vt,Nt,Dt,Lt){return wt*nt(vt,Nt,Dt,Lt).y}S=0,S+=Ct(-526.069,0,0,1,-2),S+=Ct(-3.352,0,0,1,-4),S+=Ct(44.297,1,0,1,-2),S+=Ct(-6,1,0,1,-4),S+=Ct(20.599,-1,0,1,0),S+=Ct(-30.598,-1,0,1,-2),S+=Ct(-24.649,-2,0,1,0),S+=Ct(-2,-2,0,1,-2),S+=Ct(-22.571,0,1,1,-2),S+=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/kn;let Pt=(1.000002708+139.978*p)*(18518.511+1.189+m)*Math.sin(a)-6.24*Math.sin(3*a)+S;return{geo_eclip_lon:yn*Li((A+_/kn)/yn),geo_eclip_lat:Math.PI/(180*3600)*Pt,distance_au:kn*d1/(.999953253*f)}}function yu(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 Gs(i,t,e){const n=E1(t,e);return yu(n,i)}function E1(i,t){const e=i.tt/36525;let n=84381.406,r=((((-951e-10*e+132851e-9)*e-.00114045)*e-1.0790069)*e+5038.481507)*e,s=((((3337e-10*e-467e-9)*e-.00772503)*e+.0512623)*e-.025754)*e+n,a=((((-56e-9*e+170663e-9)*e-.00121197)*e-2.3814292)*e+10.556403)*e;n*=Bi,r*=Bi,s*=Bi,a*=Bi;const o=Math.sin(n),l=Math.cos(n),c=Math.sin(-r),h=Math.cos(-r),d=Math.sin(-s),u=Math.cos(-s),p=Math.sin(a),_=Math.cos(a),S=_*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,M=-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 Hs([[S,m,f],[A,w,M],[y,b,R]]);if(t===Qe.From2000)return new Hs([[S,A,y],[m,w,b],[f,M,R]]);throw"Invalid precess direction"}function b1(i){const t=.779057273264+.00273781191135448*i.ut,e=i.ut%1;let n=360*((t+e)%1);return n<0&&(n+=360),n}let os;function Eu(i){if(!os||os.tt!==i.tt){const t=i.tt/36525;let e=15*yl(i).ee;const n=b1(i);let s=((e+.014506+((((-368e-10*t-29956e-9)*t-44e-8)*t+1.3915817)*t+4612.156534)*t)/3600+n)%360/15;s<0&&(s+=24),os={tt:i.tt,st:s}}return os.st}function T1(i,t){const e=i.latitude*ie,n=Math.sin(e),r=Math.cos(e),s=1/Math.hypot(r,Vo*n),a=u1*s,o=i.height/1e3,l=Wo*s+o,c=Wo*a+o,h=(15*t+i.longitude)*ie,d=Math.sin(h),u=Math.cos(h);return{pos:[l*r*u/ii,l*r*d/ii,c*n/ii],vel:[-qc*l*r*d*86400/ii,qc*l*r*u*86400/ii,0]}}function $o(i,t,e){const n=A1(t,e);return yu(n,i)}function A1(i,t){const e=yl(i),n=e.mobl*ie,r=e.tobl*ie,s=e.dpsi*Bi,a=Math.cos(n),o=Math.sin(n),l=Math.cos(r),c=Math.sin(r),h=Math.cos(s),d=Math.sin(s),u=h,p=-d*a,_=-d*o,S=d*l,m=h*a*l+o*c,f=h*o*l-a*c,A=d*c,w=h*a*c-o*l,M=h*o*c+a*l;if(t===Qe.From2000)return new Hs([[u,S,A],[p,m,w],[_,f,M]]);if(t===Qe.Into2000)return new Hs([[u,p,_],[S,m,f],[A,w,M]]);throw"Invalid precess direction"}function bu(i,t,e){return e===Qe.Into2000?Gs($o(i,t,e),t,e):$o(Gs(i,t,e),t,e)}function w1(i,t){const e=Eu(i),n=T1(t,e).pos;return bu(n,i,Qe.Into2000)}class _e{constructor(t,e,n,r){this.x=t,this.y=e,this.z=n,this.t=r}Length(){return Math.hypot(this.x,this.y,this.z)}}class Xn{constructor(t,e,n,r,s,a,o){this.x=t,this.y=e,this.z=n,this.vx=r,this.vy=s,this.vz=a,this.t=o}}class R1{constructor(t,e,n){this.lat=be(t),this.lon=be(e),this.dist=be(n)}}class Zc{constructor(t,e,n,r){this.ra=be(t),this.dec=be(e),this.dist=be(n),this.vec=r}}class Hs{constructor(t){this.rot=t}}class C1{constructor(t,e,n,r){this.azimuth=be(t),this.altitude=be(e),this.ra=be(n),this.dec=be(r)}}class P1{constructor(t,e,n){this.vec=t,this.elat=be(e),this.elon=be(n)}}function I1(i,t){return new _e(i[0],i[1],i[2],t)}function D1(i,t){const e=I1(i,t),n=e.x*e.x+e.y*e.y,r=Math.sqrt(n+e.z*e.z);if(n===0){if(e.z===0)throw"Indeterminate sky coordinates";return new Zc(0,e.z<0?-90:90,r,e)}let s=xu*Math.atan2(e.y,e.x);s<0&&(s+=24);const a=Yn*Math.atan2(i[2],Math.sqrt(n));return new Zc(s,a,r,e)}function Na(i,t){const e=i*ie,n=Math.cos(e),r=Math.sin(e);return[n*t[0]+r*t[1],n*t[1]-r*t[0],t[2]]}function Tu(i,t,e,n,r){let s=je(i);El(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*Wc),p=Math.cos(e*Wc);let _=[o*c,o*l,a],S=[-a*c,-a*l,o],m=[l,-c,0];const f=-15*Eu(s);let A=Na(f,_),w=Na(f,S),M=Na(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],x=y[0]*M[0]+y[1]*M[1]+y[2]*M[2];let T=Math.hypot(R,x),I;T>0?(I=-Yn*Math.atan2(x,R),I<0&&(I+=360)):I=0;let C=Yn*Math.atan2(T,b),U=e,Y=n;{let Z=C,O=tx(r,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 rt=0;rt<3;++rt)tt.push((y[rt]-et*A[rt])/Q*W+A[rt]*V);T=Math.hypot(tt[0],tt[1]),T>0?(U=xu*Math.atan2(tt[1],tt[0]),U<0&&(U+=24)):U=0,Y=Yn*Math.atan2(tt[2],T)}}return new C1(I,90-C,U,Y)}function El(i){if(!(i instanceof Au))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 Au{constructor(t,e,n){this.latitude=t,this.longitude=e,this.height=n,El(this)}}function L1(i,t,e,n,r){El(e),zs(n),zs(r);const s=je(t),a=w1(s,e),o=sl(i,s,r),l=[o.x-a[0],o.y-a[1],o.z-a[2]],c=bu(l,s,Qe.From2000);return D1(c,s)}function U1(i,t,e){const n=i.x,r=i.y*t+i.z*e,s=-i.y*e+i.z*t,a=Math.hypot(n,r);let o=0;a>0&&(o=Yn*Math.atan2(r,n),o<0&&(o+=360));let l=Yn*Math.atan2(s,a),c=new _e(n,r,s,i.t);return new P1(c,l,o)}function Ko(i){const t=yl(i.t),e=[i.x,i.y,i.z],n=Gs(e,i.t,Qe.From2000),[r,s,a]=$o(n,i.t,Qe.From2000),o=new _e(r,s,a,i.t),l=t.tobl*ie;return U1(o,Math.cos(l),Math.sin(l))}function Ki(i){const t=je(i),e=y1(t),n=e.distance_au*Math.cos(e.geo_eclip_lat),r=[n*Math.cos(e.geo_eclip_lon),n*Math.sin(e.geo_eclip_lon),e.distance_au*Math.sin(e.geo_eclip_lat)],s=S1(t,r),a=Gs(s,t,Qe.Into2000);return new _e(a[0],a[1],a[2],t)}function wu(i){const t=je(i),e=1e-5,n=t.AddDays(-e),r=t.AddDays(+e),s=Ki(n),a=Ki(r);return new Xn((s.x+a.x)/2,(s.y+a.y)/2,(s.z+a.z)/2,(a.x-s.x)/(2*e),(a.y-s.y)/(2*e),(a.z-s.z)/(2*e),t)}function N1(i){const t=je(i),e=wu(t),n=1+Mu;return new Xn(e.x/n,e.y/n,e.z/n,e.vx/n,e.vy/n,e.vz/n,t)}function Xi(i,t,e){let n=1,r=0;for(let s of i){let a=0;for(let[l,c,h]of s)a+=l*Math.cos(c+t*h);let o=n*a;e&&(o%=yn),r+=o,n*=t}return r}function Fa(i,t){let e=1,n=0,r=0,s=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),s>0&&(l+=c*Math.cos(u))}r+=s*n*l-e*o,n=e,e*=t,++s}return r}const xr=365250,Jo=0,Qo=1,jo=2;function tl(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 Ru(i,t,e){const n=e*Math.cos(t),r=Math.cos(i),s=Math.sin(i);return[n*r,n*s,e*Math.sin(t)]}function Sr(i,t){const e=t.tt/xr,n=Xi(i[Jo],e,!0),r=Xi(i[Qo],e,!1),s=Xi(i[jo],e,!1),a=Ru(n,r,s);return tl(a).ToAstroVector(t)}function el(i,t){const e=t/xr,n=Xi(i[Jo],e,!0),r=Xi(i[Qo],e,!1),s=Xi(i[jo],e,!1),a=Fa(i[Jo],e),o=Fa(i[Qo],e),l=Fa(i[jo],e),c=Math.cos(n),h=Math.sin(n),d=Math.cos(r),u=Math.sin(r),p=+(l*d*c)-s*u*c*o-s*d*h*a,_=+(l*d*h)-s*u*h*o+s*d*c*a,S=+(l*u)+s*d*o,m=Ru(n,r,s),f=[p/xr,_/xr,S/xr],A=tl(m),w=tl(f);return new ui(t,A,w)}function ls(i,t,e,n){const r=n/(n+Ml),s=Sr(An[e],t);i.x+=r*s.x,i.y+=r*s.y,i.z+=r*s.z}function F1(i){const t=new _e(0,0,0,i);return ls(t,i,yt.Jupiter,Xo),ls(t,i,yt.Saturn,qo),ls(t,i,yt.Uranus,Yo),ls(t,i,yt.Neptune,Zo),t}const nl=51,O1=29200,zi=146,En=201,ai=[[-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 ui{constructor(t,e,n){this.tt=t,this.r=e,this.v=n}clone(){return new ui(this.tt,this.r,this.v)}sub(t){return new ui(this.tt,this.r.sub(t.r),this.v.sub(t.v))}}function B1(i){let[t,[e,n,r],[s,a,o]]=i;return new ui(t,new Pe(e,n,r),new Pe(s,a,o))}function cs(i,t,e,n){const r=n/(n+Ml),s=el(An[e],t);return i.r.incr(s.r.mul(r)),i.v.incr(s.v.mul(r)),s}function fr(i,t,e){const n=e.sub(i),r=n.quadrature();return n.mul(t/(r*Math.sqrt(r)))}class Js{constructor(t){let e=new ui(t,new Pe(0,0,0),new Pe(0,0,0));this.Jupiter=cs(e,t,yt.Jupiter,Xo),this.Saturn=cs(e,t,yt.Saturn,qo),this.Uranus=cs(e,t,yt.Uranus,Yo),this.Neptune=cs(e,t,yt.Neptune,Zo),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 ui(t,e.r.mul(-1),e.v.mul(-1))}Acceleration(t){let e=fr(t,Ml,this.Sun.r);return e.incr(fr(t,Xo,this.Jupiter.r)),e.incr(fr(t,qo,this.Saturn.r)),e.incr(fr(t,Yo,this.Uranus.r)),e.incr(fr(t,Zo,this.Neptune.r)),e}}class Qs{constructor(t,e,n,r){this.tt=t,this.r=e,this.v=n,this.a=r}clone(){return new Qs(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class Cu{constructor(t,e){this.bary=t,this.grav=e}}function ks(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 $c(i,t,e){return new Pe(t.x+i*e.x,t.y+i*e.y,t.z+i*e.z)}function il(i,t){const e=i-t.tt,n=new Js(i),r=ks(e,t.r,t.v,t.a),s=n.Acceleration(r).mean(t.a),a=ks(e,t.r,t.v,s),o=t.v.add(s.mul(e)),l=n.Acceleration(a),c=new Qs(i,a,o,l);return new Cu(n,c)}const z1=[];function Pu(i,t){const e=Math.floor(i);return e<0?0:e>=t?t-1:e}function rl(i){const t=B1(i),e=new Js(t.tt),n=t.r.add(e.Sun.r),r=t.v.add(e.Sun.v),s=e.Acceleration(n),a=new Qs(t.tt,n,r,s);return new Cu(e,a)}function G1(i,t){const e=ai[0][0];if(t<e||t>ai[nl-1][0])return null;const n=Pu((t-e)/O1,nl-1);if(!i[n]){const s=i[n]=[];s[0]=rl(ai[n]).grav,s[En-1]=rl(ai[n+1]).grav;let a,o=s[0].tt;for(a=1;a<En-1;++a)s[a]=il(o+=zi,s[a-1]).grav;o=s[En-1].tt;var r=[];for(r[En-1]=s[En-1],a=En-2;a>0;--a)r[a]=il(o-=zi,r[a+1]).grav;for(a=En-2;a>0;--a){const l=a/(En-1);s[a].r=s[a].r.mul(1-l).add(r[a].r.mul(l)),s[a].v=s[a].v.mul(1-l).add(r[a].v.mul(l)),s[a].a=s[a].a.mul(1-l).add(r[a].a.mul(l))}}return i[n]}function Kc(i,t,e){let n=rl(i);const r=Math.ceil((t-n.grav.tt)/e);for(let s=0;s<r;++s)n=il(s+1===r?t:n.grav.tt+e,n.grav);return n}function Iu(i,t){let e,n,r;const s=G1(z1,i.tt);if(s){const a=Pu((i.tt-s[0].tt)/zi,En-1),o=s[a],l=s[a+1],c=o.a.mean(l.a),h=ks(i.tt-o.tt,o.r,o.v,c),d=$c(i.tt-o.tt,o.v,c),u=ks(i.tt-l.tt,l.r,l.v,c),p=$c(i.tt-l.tt,l.v,c),_=(i.tt-o.tt)/zi;e=h.mul(1-_).add(u.mul(_)),n=d.mul(1-_).add(p.mul(_))}else{let a;i.tt<ai[0][0]?a=Kc(ai[0],i.tt,-zi):a=Kc(ai[nl-1],i.tt,+zi),e=a.grav.r,n=a.grav.v,r=a.bary}return r||(r=new Js(i.tt)),e=e.sub(r.Sun.r),n=n.sub(r.Sun.v),new Xn(e.x,e.y,e.z,n.x,n.y,n.z,i)}function oi(i,t){var e=je(t);if(i in An)return Sr(An[i],e);if(i===yt.Pluto){const a=Iu(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=Sr(An.Earth,e),r=Ki(e);return new _e(n.x+r.x,n.y+r.y,n.z+r.z,e)}if(i===yt.EMB){const a=Sr(An.Earth,e),o=Ki(e),l=1+Mu;return new _e(a.x+o.x/l,a.y+o.y/l,a.z+o.z/l,e)}if(i===yt.SSB)return F1(e);const s=Sl(i);if(s){const a=new R1(s.dec,15*s.ra,s.dist);return j1(a,e)}throw`HelioVector: Unknown body "${i}"`}function H1(i,t){let e=t,n=0;for(let r=0;r<10;++r){const s=i(e),a=s.Length()/_u;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 s;e=o}throw`Light-travel time solver did not converge: dt = ${n}`}class k1{constructor(t,e,n,r){this.observerBody=t,this.targetBody=e,this.aberration=n,this.observerPos=r}Position(t){this.aberration&&(this.observerPos=oi(this.observerBody,t));const e=oi(this.targetBody,t);return new _e(e.x-this.observerPos.x,e.y-this.observerPos.y,e.z-this.observerPos.z,t)}}function V1(i,t,e,n){zs(n);const r=je(i);if(Sl(e)){const o=oi(e,r);if(n){const c=X1(t,r),h=new _e(o.x-c.x,o.y-c.y,o.z-c.z,r),d=_u/h.Length();return new _e(h.x+c.vx/d,h.y+c.vy/d,h.z+c.vz/d,r)}const l=oi(t,r);return new _e(o.x-l.x,o.y-l.y,o.z-l.z,r)}let s;n?s=new _e(0,0,0,r):s=oi(t,r);const a=new k1(t,e,n,s);return H1(o=>a.Position(o),r)}function sl(i,t,e){zs(e);const n=je(t);switch(i){case yt.Earth:return new _e(0,0,0,n);case yt.Moon:return Ki(n);default:const r=V1(n,yt.Earth,i,e);return r.t=n,r}}function W1(i,t){return new Xn(i.r.x,i.r.y,i.r.z,i.v.x,i.v.y,i.v.z,t)}function X1(i,t){const e=je(t);switch(i){case yt.Sun:return new Xn(0,0,0,0,0,0,e);case yt.SSB:const n=new Js(e.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,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 r=el(An[i],e.tt);return W1(r,e);case yt.Pluto:return Iu(e);case yt.Moon:case yt.EMB:const s=el(An.Earth,e.tt),a=i==yt.Moon?wu(e):N1(e);return new Xn(a.x+s.r.x,a.y+s.r.y,a.z+s.r.z,a.vx+s.v.x,a.vy+s.v.y,a.vz+s.v.z,e);default:if(Sl(i)){const o=oi(i,e);return new Xn(o.x,o.y,o.z,0,0,0,e)}throw`HelioState: Unsupported body "${i}"`}}function q1(i){for(;i<0;)i+=360;for(;i>=360;)i-=360;return i}function Y1(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),r=sl(i,n,!1),s=Ko(r),a=sl(t,n,!1),o=Ko(a);return q1(s.elon-o.elon)}function Z1(i,t,e,n){let r,s=0,a=0,o=0;switch(i){case yt.Mercury:r=-.6,s=4.98,a=-4.88,o=3.02;break;case yt.Venus:t<163.6?(r=-4.47,s=1.03,a=.57,o=.13):(r=.98,s=-1.02);break;case yt.Mars:r=-1.52,s=1.6;break;case yt.Jupiter:r=-9.4,s=.5;break;case yt.Uranus:r=-7.19,s=.25;break;case yt.Neptune:r=-6.87;break;case yt.Pluto:r=-1,s=4;break;default:throw`VisualMagnitude: unsupported body ${i}`}const l=t/100;let c=r+l*(s+l*(a+l*o));return c+=5*Math.log10(e*n),c}function $1(i,t,e,n,r){const s=Ko(n),a=ie*28.06,o=ie*(169.51+382e-7*r.tt),l=ie*s.elat,c=ie*s.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:Yn*h}}function K1(i,t,e){let n=i*ie,r=n*n,s=r*r,a=-12.717+1.49*Math.abs(n)+.0431*s;const o=385000.6/ii;let l=e/o;return a+=5*Math.log10(t*l),a}class J1{constructor(t,e,n,r,s,a,o,l){this.time=t,this.mag=e,this.phase_angle=n,this.helio_dist=r,this.geo_dist=s,this.gc=a,this.hc=o,this.ring_tilt=l,this.phase_fraction=(1+Math.cos(ie*n))/2}}function Du(i,t){if(i===yt.Earth)throw"The illumination of the Earth is not defined.";const e=je(t),n=Sr(An.Earth,e);let r,s,a,o;i===yt.Sun?(a=new _e(-n.x,-n.y,-n.z,e),s=new _e(0,0,0,e),r=0):(i===yt.Moon?(a=Ki(e),s=new _e(n.x+a.x,n.y+a.y,n.z+a.z,e)):(s=oi(i,t),a=new _e(s.x-n.x,s.y-n.y,s.z-n.z,e)),r=f1(a,s));let l=a.Length(),c=s.Length(),h;if(i===yt.Sun)o=h1+5*Math.log10(l);else if(i===yt.Moon)o=K1(r,c,l);else if(i===yt.Saturn){const d=$1(r,c,l,a,e);o=d.mag,h=d.ring_tilt}else o=Z1(i,r,c,l);return new J1(e,o,r,c,l,a,s,h)}function Q1(i){return Y1(yt.Moon,yt.Sun,i)}var Jc;(function(i){i[i.Pericenter=0]="Pericenter",i[i.Apocenter=1]="Apocenter"})(Jc||(Jc={}));function j1(i,t){t=je(t);const e=i.lat*ie,n=i.lon*ie,r=i.dist*Math.cos(e);return new _e(r*Math.cos(n),r*Math.sin(n),i.dist*Math.sin(e),t)}function tx(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 Qc;(function(i){i.Penumbral="penumbral",i.Partial="partial",i.Annular="annular",i.Total="total"})(Qc||(Qc={}));var jc;(function(i){i[i.Invalid=0]="Invalid",i[i.Ascending=1]="Ascending",i[i.Descending=-1]="Descending"})(jc||(jc={}));const ex=["Venus","Mars","Jupiter","Saturn"];function Lu(i){return new Au(i.lat,i.lng,i.elevationM)}function nx(i,t,e,n){const r=Tu(e,Lu(n),i,t,"normal");return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}function Oa(i,t,e){const n=Lu(e),r=L1(yt[i],t,n,!0,!0),s=Tu(t,n,r.ra,r.dec,"normal");return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}function Ba(i,t){return Du(yt[i],t).mag}function ix(i){const t=Q1(i),e=Du(yt.Moon,i);return{phaseFraction:t/360,illuminatedFraction:e.phase_fraction}}const rx=2e3,sx=3,ax=20;function ox(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??rx,r=i.month??(e?1:sx),s=i.day??(e?1:ax),a=Math.round(t/15);return new Date(Date.UTC(n,r-1,s,(i.hour??12)-a,i.minute??0,i.second??0))}const Uu=Math.PI/180,lx=180/Math.PI,cx=256,hx=19;function ux(i,t){return 156543.03392*Math.cos(i*Uu)/2**t}function dx(i,t){return ux(i,t)*cx}function Nu(i,t){let e=0;for(;e<hx&&dx(i,e+1)>=t;)e++;return e}function Fu(i,t,e){const n=2**e,r=(i+180)/360*n,s=t*Uu,a=(1-Math.log(Math.tan(s)+1/Math.cos(s))/Math.PI)/2*n;return{x:r,y:a}}function fx(i,t,e){const{x:n,y:r}=Fu(i,t,e);return{x:Math.floor(n),y:Math.floor(r),z:e}}function px(i){const t=2**i.z,e=i.x/t*360-180,n=(i.x+1)/t*360-180,r=th(i.y,t);return{south:th(i.y+1,t),north:r,west:e,east:n}}function th(i,t){const e=i/t;return Math.atan(Math.sinh(Math.PI*(1-2*e)))*lx}function Ou(i,t,e,n){const r=fx(i,t,e),s=Math.floor(n/2),a=[];for(let c=-s;c<=s;c++)for(let h=-s;h<=s;h++)a.push({x:r.x+h,y:r.y+c,z:e});const o=a.map(px),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 Bu=Math.PI/180,Vs=111320;function Ji(i,t,e,n){const r=Vs*Math.cos(e*Bu),s=(i-e)*Vs;return{x:(t-n)*r,z:-s}}function hs(i,t,e,n){const r=Vs*Math.cos(e*Bu),s=-t,a=i;return{lat:e+s/Vs,lng:n+a/r}}const qe=256,eh=3,mx=32768;class gx{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,r=(t.west+t.east)/2,s=Math.abs(Ji(n,t.east,n,t.west).x),a=Math.abs(Ji(t.north,r,t.south,r).z),o=Nu(n,Math.max(s,a)),{tiles:l}=Ou(r,n,o,eh),c=eh*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 S=0;S<e.width;S++){const m=t.west+(t.east-t.west)*(S/(e.width-1));u[p*e.width+S]=this.sampleAt(_,m,o,d,h,c)}}return{heights:u,width:e.width,height:e.height,bounds:t}}async decodeTileInto(t,e,n,r){const s=this.tileUrlTemplate.replace("{z}",String(t.z)).replace("{x}",String(t.x)).replace("{y}",String(t.y)),a=await this.fetchImpl(s);if(!a.ok)throw new Error(`Elevation tile fetch failed (${a.status}): ${s}`);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 S=(p*qe+_)*4,m=h[S]*256+h[S+1]+h[S+2]/256-mx,f=d+_,A=u+p;n[A*r+f]=m}}sampleAt(t,e,n,r,s,a){const{x:o,y:l}=Fu(e,t,n),c=(o-r.x)*qe,h=(l-r.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),S=c-d,m=h-u,f=s[u*a+d],A=s[u*a+p],w=s[_*a+d],M=s[_*a+p],y=f+(A-f)*S,b=w+(M-w)*S;return y+(b-y)*m}}const za=256,nh=3;async function _x(i,t,e,n){const r=(i.south+i.north)/2,s=(i.west+i.east)/2,a=Math.abs(Ji(r,i.east,r,i.west).x),o=Math.abs(Ji(i.north,s,i.south,s).z),l=Nu(r,Math.max(a,o)),{tiles:c}=Ou(s,r,l,nh),h=nh*za,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)*za,(m.y-p.y)*za)}));const _=document.createElement("canvas");_.width=t.width,_.height=t.height;const S=_.getContext("2d");if(!S)throw new Error("2D canvas context unavailable");return S.drawImage(d,0,0,h,h,0,0,t.width,t.height),_}class xx{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 _x(t,e,r=>this.tileUrlTemplate.replace("{z}",String(r.z)).replace("{y}",String(r.y)).replace("{x}",String(r.x)),this.fetchImpl),width:e.width,height:e.height}}}function vx(){return{elevation:new gx,imagery:new xx}}const vr=64,Ee=vr+1,ih=512,rh=700,sh=900,Mx=-.5,Sx=.01;function yx(i,t,e){return{north:hs(0,-e,i,t).lat,south:hs(0,e,i,t).lat,east:hs(e,0,i,t).lng,west:hs(-e,0,i,t).lng}}async function Ex(i,t,e){const n=yx(i,t,sh),r={width:Ee,height:Ee},[s,a]=await Promise.all([e.elevation.getElevationGrid(n,r),e.imagery.getImageryTexture(n,{width:ih,height:ih})]),o=Math.floor(Ee/2),l=s.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),M=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,z:T}=Ji(M,R,i,t),I=s.heights[A*Ee+y],C=Mx+Sx+(I-l),U=A*Ee+y;c[U*3]=x,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(x),Math.abs(T)),Z=1-bx((Y-rh)/(sh-rh),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(vr*vr*6);let p=0;for(let A=0;A<vr;A++)for(let w=0;w<vr;w++){const M=A*Ee+w,y=M+1,b=M+Ee,R=b+1;u[p++]=M,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 S=new In(a.source);S.flipY=!1;const m=new Vi({map:S,color:new It(1,1,1),vertexColors:!0,transparent:!0,fog:!0,depthTest:!1});return{mesh:new ke(_,m),attribution:e.imagery.attribution}}function bx(i,t,e){return Math.max(t,Math.min(e,i))}const zu={cloudCover:0,cloudDarkness:0,precipitationType:"none",precipitationIntensity:0,windDirectionDeg:0,windSpeed:0,lightning:!1},Tx=18,Ax=.55,wx=.5,Rx=`
|
|
4371
|
+
attribute float aSpeed;
|
|
4372
|
+
uniform float uTime;
|
|
4373
|
+
uniform float uOverallSpeed;
|
|
4374
|
+
uniform float uPixelSize;
|
|
4375
|
+
uniform float uHeight;
|
|
4376
|
+
uniform float uBottomY;
|
|
4377
|
+
uniform float uHalfWidth;
|
|
4378
|
+
uniform vec2 uWindOffset;
|
|
4379
|
+
uniform float uNearFocusDistance;
|
|
4380
|
+
uniform float uHazeDistance;
|
|
4381
|
+
varying float vNearBlur;
|
|
4382
|
+
varying float vHaze;
|
|
4383
|
+
|
|
4384
|
+
void main() {
|
|
4385
|
+
// uOverallSpeed*aSpeed, not a real-world m/s value — see RainSystemConfig.overallSpeed's own
|
|
4386
|
+
// comment on why the recycle animation's own rate is deliberately unrelated to real rain physics.
|
|
4387
|
+
float wrappedY = mod(position.y - uTime * uOverallSpeed * aSpeed, uHeight) + uBottomY;
|
|
4388
|
+
// Wraps horizontally too (a torus, not a bounded box) so a continuously-growing wind offset never
|
|
4389
|
+
// needs its own respawn/reset logic — any offset magnitude wraps back into [-uHalfWidth, uHalfWidth].
|
|
4390
|
+
float driftedX = mod(position.x + uWindOffset.x + uHalfWidth, uHalfWidth * 2.0) - uHalfWidth;
|
|
4391
|
+
float driftedZ = mod(position.z + uWindOffset.y + uHalfWidth, uHalfWidth * 2.0) - uHalfWidth;
|
|
4392
|
+
vec4 mvPosition = modelViewMatrix * vec4(driftedX, wrappedY, driftedZ, 1.0);
|
|
4393
|
+
gl_Position = projectionMatrix * mvPosition;
|
|
4394
|
+
float dist = max(1.0, -mvPosition.z);
|
|
4395
|
+
// Near-camera optical defocus: 1 right at the camera, fading to 0 by uNearFocusDistance — a
|
|
4396
|
+
// witness's eyes aren't focused at arm's length on individual raindrops.
|
|
4397
|
+
vNearBlur = clamp(1.0 - dist / uNearFocusDistance, 0.0, 1.0);
|
|
4398
|
+
// Distance haze: 0 close in, ramping to 1 by uHazeDistance — real atmospheric haze, monotonic
|
|
4399
|
+
// (unlike defocus, there's no "in-focus band", it just keeps increasing with distance). Does NOT
|
|
4400
|
+
// add to gl_PointSize below — real haze dims/desaturates a distant object, it doesn't enlarge it;
|
|
4401
|
+
// only vNearBlur (real optical defocus, which genuinely does spread a too-close point into a
|
|
4402
|
+
// bigger, softer disc) should. Feeding vHaze into size too meant a distant, hazy streak could
|
|
4403
|
+
// randomly end up as big or bigger than a closer, sharper one, purely from perspective/dt noise —
|
|
4404
|
+
// a real, caught bug (a user directly noticed "darker/farther streaks equal-or-bigger than
|
|
4405
|
+
// lighter/closer ones"), not just a stylistic overcorrection.
|
|
4406
|
+
vHaze = clamp(dist / uHazeDistance, 0.0, 1.0);
|
|
4407
|
+
gl_PointSize = uPixelSize / dist + vNearBlur * ${Tx.toFixed(1)};
|
|
4408
|
+
}
|
|
4409
|
+
`,Cx=`
|
|
4410
|
+
precision mediump float;
|
|
4411
|
+
uniform sampler2D uTexture;
|
|
4412
|
+
uniform vec3 uColor;
|
|
4413
|
+
uniform float uOpacity;
|
|
4414
|
+
uniform float uUvSquash;
|
|
4415
|
+
uniform float uSpeedStreak;
|
|
4416
|
+
uniform vec3 uHazeColor;
|
|
4417
|
+
varying float vNearBlur;
|
|
4418
|
+
varying float vHaze;
|
|
4419
|
+
|
|
4420
|
+
void main() {
|
|
4421
|
+
vec2 uv = gl_PointCoord;
|
|
4422
|
+
// Squashes sampled UV.x toward the texture's own center column — at a steep camera pitch this
|
|
4423
|
+
// keeps the streak reading as a normal-width drop instead of the full-width bar you'd get from
|
|
4424
|
+
// sampling the (already very thin) streak texture undistorted at a near-face-on angle.
|
|
4425
|
+
uv.x = 0.5 + (uv.x - 0.5) * uUvSquash;
|
|
4426
|
+
// Stands in for real motion blur: dividing by a SMALLER uSpeedStreak (slow fall speed) expands
|
|
4427
|
+
// the sampled UV.y range beyond [0,1] for pixels away from the point's center, which — since the
|
|
4428
|
+
// texture clamps to its own fully-transparent edge outside [0,1] — crops the visible streak down
|
|
4429
|
+
// to a short mark near the center instead of the full pre-baked length. uSpeedStreak=1 (fast)
|
|
4430
|
+
// samples the texture undistorted, showing the whole streak.
|
|
4431
|
+
uv.y = 0.5 + (uv.y - 0.5) / uSpeedStreak;
|
|
4432
|
+
vec4 tex = texture2D(uTexture, uv);
|
|
4433
|
+
// Distance haze blends color toward the real ambient sky color (atmospheric perspective); near
|
|
4434
|
+
// defocus doesn't change color, only spreads+dims (see vertex shader's own gl_PointSize term) —
|
|
4435
|
+
// both dim the alpha so a maximally blurred/hazy drop doesn't stay as visually "solid" as a sharp
|
|
4436
|
+
// one right in the middle distance.
|
|
4437
|
+
vec3 color = mix(uColor, uHazeColor, vHaze * ${Ax.toFixed(2)});
|
|
4438
|
+
float blur = max(vNearBlur, vHaze);
|
|
4439
|
+
gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * ${wx.toFixed(2)}));
|
|
4440
|
+
}
|
|
4441
|
+
`;function Px(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 us;function Ix(){if(us)return us;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 r=e.createLinearGradient(0,0,0,i);return r.addColorStop(0,"rgba(0,0,0,1)"),r.addColorStop(.1,"rgba(0,0,0,0)"),r.addColorStop(.9,"rgba(0,0,0,0)"),r.addColorStop(1,"rgba(0,0,0,1)"),e.globalCompositeOperation="destination-out",e.fillStyle=r,e.fillRect(0,0,i,i),e.globalCompositeOperation="source-over",us=new In(t),us}function Dx(i){const t=Px(i.seed),e=new Float32Array(i.count*3),n=new Float32Array(i.count),r=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 s=new Te;s.setAttribute("position",new pe(e,3)),s.setAttribute("aSpeed",new pe(n,1)),s.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 Gt(0,0)},uHeight:{value:i.heightM},uBottomY:{value:i.bottomYM},uHalfWidth:{value:r},uTexture:{value:Ix()},uNearFocusDistance:{value:i.nearFocusDistanceM},uHazeDistance:{value:i.hazeDistanceM},uHazeColor:{value:i.hazeColor}},o=new Ve({uniforms:a,vertexShader:Rx,fragmentShader:Cx,transparent:!0,depthWrite:!1,depthTest:!0}),l=new As(s,o);return l.frustumCulled=!1,{points:l,uniforms:a}}const ds=900,Lx=900,Ux=850,ah=850,Ga=4,Nx=1.5,Fx=-1,Ox=6,oh=-4,Bx=[{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"}],zx=880,lh=40,Gx=10,Hx=1,kx=150,ch=24,Vx=700,Wx=260,Xx=5,Ui=[.92,.92,.95],Ha=[.15,.15,.19],hh={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}},Oi=-.5,fs=6,uh=3e3,pr=20,qx=15,dh=Oi,Yx=40,fh=1,Zx=9;function $x(i){return fh+(Zx-fh)*i}const Kx=new It(.75,.82,.92),Jx=10,Qx=.5;function jx(i){return bl(i/Jx,Qx,1)}const Ni=200,ph=.18,mh=.32,tv=.35,ev=new It(.85,.9,.98),gh=5,_h=.85,xh=.01;function ka(i,t){return Math.round(i*(xh+(1-xh)*t))}const vh=230,Mh=.7,Sh=.05,nv=.6,iv=.7,rv=.15,yh=.35,sv=3,av=1/12,ov=.5,Eh=8,bh=25,Th=.12,lv={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 cv{renderer;scene=new yd;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 Vd;weather=zu;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=vx(),n){this.renderer=new G_({canvas:t,antialias:!0}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),this.camera=new $e(60,t.width/Math.max(t.height,1),.1,ds*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*mr,-t.headingDeg*mr,0,"YXZ"):this.camera.rotation.set(t.pitchDeg*mr,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:s,z:a}=Ji(t,e,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(s*s+a*a)<kx)return}this.terrainOrigin={lat:t,lng:e};const r=++this.terrainBuildToken;Ex(t,e,this.terrainProviders).then(({mesh:s,attribution:a})=>{r===this.terrainBuildToken&&(this.disposeMesh(this.terrainMesh),s.renderOrder=Hx,this.terrainMesh=s,this.terrainAttribution=a,this.scene.add(s),this.render(),n?.())}).catch(s=>{console.warn("Terrain build failed, keeping the flat ground fallback:",s),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>=ov,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=mu(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,Ga,new It(1,.96,.88),t.sun.magnitude),this.setMoonMesh(t.moon),this.buildPlanets(t.planets),this.scene.fog=new _l(new It(...e),ds*.2,ds),this.render()}render(){this.renderer.render(this.scene,this.camera)}pickBodyAt(t,e){this.raycaster.setFromCamera(new Gt(t,e),this.camera);const n=[...this.hitAreas.entries()],r=this.raycaster.intersectObjects(n.map(([,s])=>s))[0];if(r)return n.find(([,s])=>s===r.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 r=t===void 0?0:Math.min((n-t)/1e3,av);t=n,this.updateTwinkle(n/1e3),this.updatePrecipitation(n/1e3,r),this.updateRain(r),this.updateLightning(n/1e3,r),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 Os(ds,32,16),n=e.attributes.position,r=[];for(let a=0;a<n.count;a++){const{altitudeDeg:o,azimuthDeg:l}=W_(n.getX(a),n.getY(a),n.getZ(a)),c=Y_(o,l,t.azimuthDeg,t.altitudeDeg);r.push(c[0],c[1],c[2])}e.setAttribute("color",new Le(r,3));const s=new Vi({vertexColors:!0,side:Fe,fog:!1});this.skyMesh=new ke(e,s),this.scene.add(this.skyMesh)}buildGround(t){this.disposeMesh(this.groundMesh);const e=new vl(Lx,48),n=new It(t[0]*.35,t[1]*.35,t[2]*.35),r=new Vi({color:n,fog:!0});this.groundMesh=new ke(e,r),this.groundMesh.rotation.x=-Math.PI/2,this.groundMesh.position.y=-.5,this.scene.add(this.groundMesh)}setBodyMesh(t,e,n,r,s){if(this.disposeMesh(this.bodyMeshes.get(t)),this.disposeHitArea(t),this.disposeGlare(t),e.altitudeDeg<oh){this.bodyMeshes.delete(t);return}const{x:a,y:o,z:l}=dr(e.altitudeDeg,e.azimuthDeg,ah),c=kc(e.altitudeDeg),h=new It(r.r*c[0],r.g*c[1],r.b*c[2]),d=new Os(n,16,16),u=new Vi({color:h,fog:!1}),p=new ke(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,s,h)}setMoonMesh(t){const e="moon";if(this.disposeMesh(this.bodyMeshes.get(e)),this.disposeHitArea(e),this.disposeGlare(e),t.altitudeDeg<oh){this.bodyMeshes.delete(e);return}const{x:n,y:r,z:s}=dr(t.altitudeDeg,t.azimuthDeg,ah),a=kc(t.altitudeDeg),o=new It(a[0],a[1],a[2]),l=new Fi({map:Mv(t.phase),color:o,fog:!1}),c=new cr(l);c.position.set(n,r,s);const h=Ga*2;c.scale.set(h,h,1),this.scene.add(c),this.bodyMeshes.set(e,c),this.setHitArea(e,n,r,s,Ga),this.setGlare(e,n,r,s,t.magnitude,o)}setHitArea(t,e,n,r,s){const a=new Fi({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1}),o=new cr(a);o.position.set(e,n,r);const l=s*Ox;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,r,s,a){this.disposeGlare(t);const o=$_(s);if(o<=0)return;const l=Q_(o),c=new Fi({map:vv(),color:a,transparent:!0,opacity:e1(o),blending:Ya,depthWrite:!1,fog:!1}),h=new cr(c);h.position.set(e,n,r),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 r=Gc(n.magnitude),s=Hc(r),a=lv[n.body]??new It(1,1,1),o=new It(a.r*s,a.g*s,a.b*s),l=Nx*(.5+.5*r);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:r,observer:s}=t,a=H_(e),o=Mr(1337),l=[];for(let c=0;c<n.count;c++){const h=n.mag[c];if(h>a)continue;const{altitudeDeg:d,azimuthDeg:u}=nx(n.ra[c],n.dec[c],r,s);if(d<Fx)continue;const{x:p,y:_,z:S}=dr(d,u,Ux);l.push({x:p,y:_,z:S,brightness:Gc(h),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}this.starTiers=gu.map((c,h)=>{const d=l.filter(M=>i1(M.brightness)===h),u=new Float32Array(d.length*3),p=new Float32Array(d.length),_=new Float32Array(d.length),S=new Float32Array(d.length);d.forEach((M,y)=>{u[y*3]=M.x,u[y*3+1]=M.y,u[y*3+2]=M.z,p[y]=M.brightness,_[y]=M.phase,S[y]=M.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 tu({vertexColors:!0,size:c.size,sizeAttenuation:!1,fog:!1}),w=new As(m,A);return this.scene.add(w),{points:w,colorAttribute:f,brightness:p,phase:_,speedFactor:S}}),this.updateTwinkle(0),this.startTwinkle()}updateTwinkle(t){for(const e of this.starTiers){const n=e.colorAttribute.array;for(let r=0;r<e.brightness.length;r++){const s=a1(e.brightness[r],{phase:e.phase[r],speedFactor:e.speedFactor[r]},t),a=Hc(e.brightness[r])*s;n[r*3]=a,n[r*3+1]=a,n[r*3+2]=a}e.colorAttribute.needsUpdate=!0}}buildClouds(){this.disposeCloudSprites();const t=Math.round(this.weather.cloudCover*ch);if(t===0)return;const e=Mr(4242),n=hv();for(let r=0;r<ch;r++){const s=15+e()*55,a=e()*360,o=.4+e()*.45,l=Wx*(.7+e()*.6);if(r>=t)continue;const{x:c,y:h,z:d}=dr(s,a,Vx),u=new Fi({map:n,color:new It(1,1,1),transparent:!0,opacity:o,fog:!1,depthTest:!1}),p=new cr(u);p.position.set(c,h,d),p.scale.set(l,l*.6,1),p.renderOrder=Xx,this.scene.add(p),this.cloudSprites.push(p)}}retintClouds(t){if(this.cloudSprites.length===0)return;const e=this.weather.cloudDarkness,n=Ui[0]+(Ha[0]-Ui[0])*e,r=Ui[1]+(Ha[1]-Ui[1])*e,s=Ui[2]+(Ha[2]-Ui[2])*e,a=(t[0]+t[1]+t[2])/3,o=bl(a*1.8,.15,1);for(const l of this.cloudSprites)l.material.color.setRGB(n*o,r*o,s*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=hh[t],n=e.poolSize,r=Mr(9001),s=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 M=r()*Math.PI*2,y=r()*e.radiusM;s[w*3]=Math.cos(M)*y,s[w*3+1]=Oi+r()*(e.topYM-Oi),s[w*3+2]=Math.sin(M)*y,a[w]=r()*Math.PI*2,o[w]=.7+r()*.6,l[w]=.6+r()*.8,c[w]=.4+r()*1.2}const S=new Te;S.setAttribute("position",new pe(s,3)),S.setDrawRange(0,ka(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:uv(t)},uNearFocusDistance:{value:gh},uHazeDistance:{value:e.radiusM*_h}},f=new Ve({uniforms:m,vertexShader:_v,fragmentShader:xv,transparent:!0,depthWrite:!1});this.precipitationUniforms=m;const A=new As(S,f);this.scene.add(A),this.precipitationPoints=A,this.precipitationPositions=s,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 r=hh[n],s=this.weather.windDirectionDeg*mr,a=Math.sin(s)*this.weather.windSpeed*r.driftSensitivity*fs,o=-Math.cos(s)*this.weather.windSpeed*r.driftSensitivity*fs,l=this.precipitationPositions,c=this.precipitationPhase,h=this.precipitationSpeedJitter,d=this.precipitationWobbleFreqJitter,u=this.precipitationWobbleAmpJitter,p=this.precipitationBounceRemaining,_=this.precipitationBounceHeight,S=this.precipitationBounceDuration,m=this.precipitationBounceVelX,f=this.precipitationBounceVelZ,A=n==="snow"&&d&&u,w=n==="hail"&&p&&_&&S&&m&&f;for(let M=0,y=0;M<l.length;M+=3,y++){if(w&&p[y]>0){if(p[y]-=e,p[y]<=0){const x=Math.random()*Math.PI*2,T=Math.sqrt(Math.random())*r.radiusM;l[M]=Math.cos(x)*T,l[M+1]=r.topYM,l[M+2]=Math.sin(x)*T,p[y]=0}else{const x=1-p[y]/S[y];l[M+1]=Oi+Math.sin(Math.PI*x)*_[y],l[M]=ms(l[M]+(a+m[y])*e,r.radiusM),l[M+2]=ms(l[M+2]+(o+f[y])*e,r.radiusM)}continue}let b=0,R=0;if(A){const x=nv*d[y],T=iv*u[y];b=Math.sin(t*x*Math.PI*2+c[y])*T,R=Math.sin(t*x*Math.PI*2+c[y]+Math.PI/2)*T}if(l[M]+=(a+b)*e,l[M+1]-=r.fallSpeedMPerS*h[y]*e,l[M+2]+=(o+R)*e,l[M]=ms(l[M],r.radiusM),l[M+2]=ms(l[M+2],r.radiusM),l[M+1]<Oi){if(w){_[y]=yh*(.2+Math.random()*1.6),S[y]=rv*(.5+Math.random()),p[y]=S[y];const I=Math.random()*Math.PI*2,C=sv*(_[y]/yh);m[y]=Math.cos(I)*C,f[y]=Math.sin(I)*C,l[M+1]=Oi;continue}const x=Math.random()*Math.PI*2,T=Math.sqrt(Math.random())*r.radiusM;l[M]=Math.cos(x)*T,l[M+1]=r.topYM,l[M+2]=Math.sin(x)*T}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const t=$x(this.weather.precipitationIntensity);this.rainSystem=Dx({count:uh,radiusM:pr,heightM:qx,bottomYM:dh,overallSpeed:Yx,color:Kx,opacity:.85,visibleCount:ka(uh,this.weather.precipitationIntensity),speedStreak:jx(t),pixelSize:vh,seed:9001,nearFocusDistanceM:gh,hazeDistanceM:pr*_h,hazeColor:new It(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const t=Mr(4242),e=new Float32Array(Ni*3),n=new Float32Array(Ni),r=new Float32Array(Ni),s=new Float32Array(Ni);for(let h=0;h<Ni;h++){const d=t()*Math.PI*2,u=Math.sqrt(t())*pr;e[h*3]=Math.cos(d)*u,e[h*3+1]=dh,e[h*3+2]=Math.sin(d)*u,r[h]=ps(ph,mh),n[h]=t()*r[h],s[h]=n[h]/r[h]}const a=new Te;a.setAttribute("position",new pe(e,3));const o=new pe(s,1);a.setAttribute("aLife",o),a.setDrawRange(0,ka(Ni,this.weather.precipitationIntensity));const l=new Ve({uniforms:{uMaxSize:{value:tv},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:ev},uTexture:{value:pv()}},vertexShader:mv,fragmentShader:gv,transparent:!0,depthWrite:!1}),c=new As(a,l);this.scene.add(c),this.rainSplashSystem={points:c,positions:e,life:n,duration:r,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*mr,r=Math.sin(n)*this.weather.windSpeed*fs,s=-Math.cos(n)*this.weather.windSpeed*fs,a=pr,o=c=>(c%(a*2)+a*3)%(a*2)-a;e.uniforms.uWindOffset.value.set(o(e.uniforms.uWindOffset.value.x+r*t),o(e.uniforms.uWindOffset.value.y+s*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=Mh+(1-Mh)*(1-l),h=Sh+(1-Sh)*(1-l);e.uniforms.uUvSquash.value=h,e.uniforms.uPixelSize.value=vh*c*(.5+.5*h)}this.updateRainSplashes(t)}updateRainSplashes(t){const e=this.rainSplashSystem;if(!e||t<=0)return;const{positions:n,life:r,duration:s,lifeAttribute:a}=e,o=a.array;for(let l=0,c=0;l<n.length;l+=3,c++){if(r[c]+=t,r[c]>=s[c]){const h=Math.random()*Math.PI*2,d=Math.sqrt(Math.random())*pr;n[l]=Math.cos(h)*d,n[l+2]=Math.sin(h)*d,s[c]=ps(ph,mh),r[c]=0}o[c]=r[c]/s[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/Th;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+ps(Eh,bh);return}t>=this.nextLightningAtS&&(this.lightningFlashRemainingS=Th,this.nextLightningAtS=t+ps(Eh,bh),this.onLightningFlash?.())}}buildCompassLabels(){this.compassSprites=Bx.map(({azimuthDeg:t,label:e})=>{const n=new Fi({map:Sv(e),depthTest:!1,fog:!1}),r=new cr(n),{x:s,y:a,z:o}=dr(0,t,zx);return r.position.set(s,a,o),r.scale.set(lh,lh,1),r.renderOrder=Gx,r.visible=this.compassHovered||this.compassForced,this.scene.add(r),r})}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 r=n.map;r&&r.dispose(),n.dispose()}}}const mr=Math.PI/180;function bl(i,t,e){return Math.max(t,Math.min(e,i))}function ps(i,t){return i+Math.random()*(t-i)}function ms(i,t){return(i%(t*2)+t*3)%(t*2)-t}let gs;function hv(){if(gs)return gs;const i=256,t=document.createElement("canvas");t.width=i,t.height=i;const e=t.getContext("2d"),n=Mr(77);for(let r=0;r<6;r++){const s=i*(.3+n()*.4),a=i*(.35+n()*.3),o=i*(.18+n()*.14),l=e.createRadialGradient(s,a,0,s,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(s,a,o,0,Math.PI*2),e.fill()}return gs=new In(t),gs}let _s,xs;function uv(i){switch(i){case"snow":return dv();case"hail":return fv()}}function dv(){if(_s)return _s;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),_s=new In(t),_s}function fv(){if(xs)return xs;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),xs=new In(t),xs}let vs;function pv(){if(vs)return vs;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),vs=new In(t),vs}const mv=`
|
|
4442
|
+
uniform float uMaxSize;
|
|
4443
|
+
uniform float uScale;
|
|
4444
|
+
attribute float aLife;
|
|
4445
|
+
varying float vOpacity;
|
|
4446
|
+
|
|
4447
|
+
void main() {
|
|
4448
|
+
vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);
|
|
4449
|
+
float dist = max(1.0, -mvPosition.z);
|
|
4450
|
+
gl_PointSize = uMaxSize * aLife * uScale / dist;
|
|
4451
|
+
vOpacity = 1.0 - aLife;
|
|
4452
|
+
gl_Position = projectionMatrix * mvPosition;
|
|
4453
|
+
}
|
|
4454
|
+
`,gv=`
|
|
4455
|
+
uniform vec3 uColor;
|
|
4456
|
+
uniform sampler2D uTexture;
|
|
4457
|
+
varying float vOpacity;
|
|
4458
|
+
|
|
4459
|
+
void main() {
|
|
4460
|
+
vec4 tex = texture2D(uTexture, gl_PointCoord);
|
|
4461
|
+
float alpha = tex.a * vOpacity;
|
|
4462
|
+
if (alpha < 0.01) discard;
|
|
4463
|
+
gl_FragColor = vec4(uColor, alpha);
|
|
4464
|
+
}
|
|
4465
|
+
`,_v=`
|
|
4466
|
+
uniform float uSize;
|
|
4467
|
+
uniform float uScale;
|
|
4468
|
+
uniform float uNearFocusDistance;
|
|
4469
|
+
uniform float uHazeDistance;
|
|
4470
|
+
varying float vNearBlur;
|
|
4471
|
+
varying float vHaze;
|
|
4472
|
+
|
|
4473
|
+
void main() {
|
|
4474
|
+
vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);
|
|
4475
|
+
float dist = max(1.0, -mvPosition.z);
|
|
4476
|
+
vNearBlur = clamp(1.0 - dist / uNearFocusDistance, 0.0, 1.0);
|
|
4477
|
+
vHaze = clamp(dist / uHazeDistance, 0.0, 1.0);
|
|
4478
|
+
// Real physical flake/stone size is uniform (uSize) — only perspective (1/dist) should make one
|
|
4479
|
+
// look bigger or smaller than another; a random per-particle size multiplier read as physically
|
|
4480
|
+
// wrong (a user directly caught it: darker/hazier — i.e. farther — particles could randomly end up
|
|
4481
|
+
// as big or bigger than closer, less-hazy ones, since the old random jitter had no relationship to
|
|
4482
|
+
// distance at all). Only vNearBlur adds to size — real optical defocus genuinely spreads a
|
|
4483
|
+
// too-close point into a bigger, softer disc; vHaze does NOT add size (real atmospheric haze dims
|
|
4484
|
+
// and desaturates a distant object, it doesn't enlarge it — see the fragment shader, which still
|
|
4485
|
+
// uses vHaze for color/opacity, just not size). max(1.0, ...) is a hard floor: the farthest
|
|
4486
|
+
// particles genuinely bottom out at a single pixel rather than shrinking to an invisible/flickery
|
|
4487
|
+
// fractional size.
|
|
4488
|
+
gl_PointSize = max(1.0, uSize * uScale / dist + vNearBlur * 12.0);
|
|
4489
|
+
gl_Position = projectionMatrix * mvPosition;
|
|
4490
|
+
}
|
|
4491
|
+
`,xv=`
|
|
4492
|
+
precision mediump float;
|
|
4493
|
+
uniform sampler2D uTexture;
|
|
4494
|
+
uniform vec3 uColor;
|
|
4495
|
+
uniform vec3 uHazeColor;
|
|
4496
|
+
uniform float uOpacity;
|
|
4497
|
+
varying float vNearBlur;
|
|
4498
|
+
varying float vHaze;
|
|
4499
|
+
|
|
4500
|
+
void main() {
|
|
4501
|
+
vec4 tex = texture2D(uTexture, gl_PointCoord);
|
|
4502
|
+
vec3 color = mix(uColor, uHazeColor, vHaze * 0.55);
|
|
4503
|
+
float blur = max(vNearBlur, vHaze);
|
|
4504
|
+
gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * 0.5));
|
|
4505
|
+
}
|
|
4506
|
+
`;let Ms;function vv(){if(Ms)return Ms;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),Ms=new In(t),Ms}function Mv(i){const e=document.createElement("canvas");e.width=128,e.height=128;const n=e.getContext("2d"),r=128/2-2,s=128/2,a=128/2,o="#2e2b26",l="#f4f1e2";n.fillStyle=o,n.beginPath(),n.arc(s,a,r,0,Math.PI*2),n.fill();const c=bl(i.illuminatedFraction,0,1),h=i.phaseFraction<.5,d=r*Math.abs(1-2*c),u=c<.5;return n.save(),n.beginPath(),n.arc(s,a,r,0,Math.PI*2),n.clip(),n.fillStyle=l,n.beginPath(),h?(n.arc(s,a,r,-Math.PI/2,Math.PI/2,!1),n.ellipse(s,a,d,r,0,Math.PI/2,-Math.PI/2,u)):(n.arc(s,a,r,Math.PI/2,-Math.PI/2,!1),n.ellipse(s,a,d,r,0,-Math.PI/2,Math.PI/2,u)),n.fill(),n.restore(),new In(e)}function Sv(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 Mr(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 Ah=new Map;function yv(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 Ev(i){let t=Ah.get(i);return t||(t=fetch(i).then(e=>e.arrayBuffer()).then(yv),Ah.set(i,t)),t}const bv=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,Tv=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,Av=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href;class wv{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 r=t==="rain"||t==="hail"?t:"none";if(this.ambientVolume=r==="hail"?Math.min(1,e*1.3+.2):r==="rain"?e:0,r!==this.ambientKey){this.ambientKey=r;const a=++this.ambientToken;this.stopSource(this.ambientSource,this.ambientGain),this.ambientSource=void 0,this.ambientGain=void 0,r!=="none"&&this.startLoop(bv,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 s=n>.03;if(s!==this.windActive){this.windActive=s;const a=++this.windToken;this.stopSource(this.windSource,this.windGain),this.windSource=void 0,this.windGain=void 0,s&&this.startLoop(Tv,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(Av,.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,r){if(e!==n()){t?.source.stop();return}r(t)}async startLoop(t,e){const n=this.context;if(n)try{const r=await this.getBuffer(t),s=n.createBufferSource();s.buffer=r,s.loop=!0;const a=n.createGain();return a.gain.value=e,s.connect(a).connect(n.destination),s.start(),{source:s,gain:a}}catch(r){console.warn("Weather ambient sound failed to load, staying silent:",r);return}}async playOneShot(t,e){const n=this.context;if(n)try{const r=await this.getBuffer(t),s=n.createBufferSource();s.buffer=r;const a=n.createGain();a.gain.value=e,s.connect(a).connect(n.destination),s.start()}catch(r){console.warn("Thunder sound failed to load:",r)}}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(r=>{if(!r.ok)throw new Error(`Audio fetch failed (${r.status}): ${t}`);return r.arrayBuffer()}).then(r=>e.decodeAudioData(r)),this.buffers.set(t,n)),n}stopSource(t,e){try{t?.stop()}catch{}t?.disconnect(),e?.disconnect()}}Ph();const Rv={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"}},Cv=["en","fr"],Pv=new URL(""+new URL("stars-mag7.5-DDr9QasD.bin",import.meta.url).href,import.meta.url).href,Iv={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},Va={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class Dv 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 wv;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 r=(t.clientX-n.left)/n.width*2-1,s=-((t.clientY-n.top)/n.height*2-1),a=this.sceneRenderer.pickBodyAt(r,s);if(!a){this.bodyTooltip.hidden=!0;return}const o=Rh(navigator.languages,Cv);this.bodyTooltip.textContent=Rv[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>${Zu}</style>${Yu}`,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 cv(this.sceneCanvas,void 0,this.handleLightningFlash),this.bodyTooltip=this.shadow.getElementById("body-tooltip"),this.terrainAttributionElement=this.shadow.getElementById("terrain-attribution"),this.ufoElement=document.createElement(qa),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??zu;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")??Pv;this.starCatalog=await Ev(t),this.updateAstronomy(this.lastTimeMs)}updateAstronomy(t){const e=this.ufoElement.sighting,n=l0(e,t);this.sceneRenderer.setObserverPose(n??Va),this.sceneRenderer.setTerrainOrigin(n?.lat,n?.lng,()=>this.updateTerrainAttribution()),this.updateTerrainAttribution();const r=n?.lat??Va.lat,s=n?.lng??Va.lng,a=ox(e.event.time??{},s);if(!a){this.sceneRenderer.setAstronomy(Iv);return}const o=new Date(a.getTime()+t),l={lat:r,lng:s,elevationM:n?.elevationM??0},c={...Oa("Sun",o,l),magnitude:Ba("Sun",o)},h={...Oa("Moon",o,l),phase:ix(o),magnitude:Ba("Moon",o)},d=ex.map(u=>({body:u,position:Oa(u,o,l),magnitude:Ba(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 wh="rr0-scene";function Lv(){Ph(),customElements.get(wh)||customElements.define(wh,Dv)}Lv();
|