mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-03-28 17:43:05 +01:00
4031 lines
576 KiB
JavaScript
4031 lines
576 KiB
JavaScript
import{c as ql,V as Qc,W as ft,U as Xs,j as J,X as an,r as he,Y as eu,k as tu,Z as nu,$ as iu,a0 as _o,a1 as xo,a2 as vo,l as Mo}from"./index-DSM_ctlA.js";/**
|
|
* @license lucide-react v0.562.0 - ISC
|
|
*
|
|
* This source code is licensed under the ISC license.
|
|
* See the LICENSE file in the root directory of this source tree.
|
|
*/const ru=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],su=ql("maximize-2",ru);/**
|
|
* @license lucide-react v0.562.0 - ISC
|
|
*
|
|
* This source code is licensed under the ISC license.
|
|
* See the LICENSE file in the root directory of this source tree.
|
|
*/const au=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],ou=ql("minimize-2",au),Yl="remoteterm-visualizer-settings",Tt={showAmbiguousPaths:!0,showAmbiguousNodes:!1,useAdvertPathHints:!0,collapseLikelyKnownSiblingRepeaters:!0,splitAmbiguousByTraffic:!0,chargeStrength:-200,observationWindowSec:15,letEmDrift:!0,particleSpeedMultiplier:2,pruneStaleNodes:!1,pruneStaleMinutes:5,autoOrbit:!1,showControls:!0,hidePacketFeed:!1};function qr(){try{const n=localStorage.getItem(Yl);if(!n)return{...Tt};const e=JSON.parse(n);return{showAmbiguousPaths:typeof e.showAmbiguousPaths=="boolean"?e.showAmbiguousPaths:Tt.showAmbiguousPaths,showAmbiguousNodes:typeof e.showAmbiguousNodes=="boolean"?e.showAmbiguousNodes:Tt.showAmbiguousNodes,useAdvertPathHints:typeof e.useAdvertPathHints=="boolean"?e.useAdvertPathHints:Tt.useAdvertPathHints,collapseLikelyKnownSiblingRepeaters:typeof e.collapseLikelyKnownSiblingRepeaters=="boolean"?e.collapseLikelyKnownSiblingRepeaters:Tt.collapseLikelyKnownSiblingRepeaters,splitAmbiguousByTraffic:typeof e.splitAmbiguousByTraffic=="boolean"?e.splitAmbiguousByTraffic:Tt.splitAmbiguousByTraffic,chargeStrength:typeof e.chargeStrength=="number"?e.chargeStrength:Tt.chargeStrength,observationWindowSec:typeof e.observationWindowSec=="number"?e.observationWindowSec:Tt.observationWindowSec,letEmDrift:typeof e.letEmDrift=="boolean"?e.letEmDrift:Tt.letEmDrift,particleSpeedMultiplier:typeof e.particleSpeedMultiplier=="number"?e.particleSpeedMultiplier:Tt.particleSpeedMultiplier,pruneStaleNodes:typeof e.pruneStaleNodes=="boolean"?e.pruneStaleNodes:Tt.pruneStaleNodes,pruneStaleMinutes:typeof e.pruneStaleMinutes=="number"&&e.pruneStaleMinutes>=1?e.pruneStaleMinutes:Tt.pruneStaleMinutes,autoOrbit:typeof e.autoOrbit=="boolean"?e.autoOrbit:Tt.autoOrbit,showControls:typeof e.showControls=="boolean"?e.showControls:Tt.showControls,hidePacketFeed:typeof e.hidePacketFeed=="boolean"?e.hidePacketFeed:Tt.hidePacketFeed}}catch{return{...Tt}}}function jl(n){try{localStorage.setItem(Yl,JSON.stringify(n))}catch{}}const _t={background:"#0a0a0a",link:"#4b5563",ambiguous:"#9ca3af",particleAD:"#f59e0b",particleGT:"#06b6d4",particleDM:"#8b5cf6",particleACK:"#22c55e",particleTR:"#f97316",particleRQ:"#ec4899",particleRS:"#14b8a6",particleUnknown:"#6b7280"},lu={AD:_t.particleAD,GT:_t.particleGT,DM:_t.particleDM,ACK:_t.particleACK,TR:_t.particleTR,RQ:_t.particleRQ,RS:_t.particleRS,"?":_t.particleUnknown},cu=.008,uu=20,So=200,Kl=1800*1e3,hu=[{label:"AD",color:_t.particleAD,description:"Advertisement"},{label:"GT",color:_t.particleGT,description:"Group Text"},{label:"DM",color:_t.particleDM,description:"Direct Message"},{label:"ACK",color:_t.particleACK,description:"Acknowledgment"},{label:"TR",color:_t.particleTR,description:"Trace"},{label:"RQ",color:_t.particleRQ,description:"Request"},{label:"RS",color:_t.particleRS,description:"Response"},{label:"?",color:_t.particleUnknown,description:"Other"}];function Ei(n){const e=(n==null?void 0:n.trim().toLowerCase())??"";return e.length>0?e:null}function yo(n,e){const t=Ei(n);if(!t)return"?";const i=Ei(e);return i?`?${t}:>${i}`:`?${t}`}function bo(n,e){var r,s;const t=(r=Ei(n))==null?void 0:r.toUpperCase();if(!t)return"?";const i=(s=Ei(e))==null?void 0:s.toUpperCase();return i?`${t}:>${i}`:t}function fu(n){var e;try{const t=ft.MeshCoreDecoder.decode(n);if(!t.isValid)return null;const i=t.payloadType===ft.PayloadType.Trace&&t.payload.decoded?t.payload.decoded:null,r={payloadType:t.payloadType,messageHash:t.messageHash||null,pathBytes:(i==null?void 0:i.pathHashes)||t.path||[],srcHash:null,dstHash:null,advertPubkey:null,groupTextSender:null,anonRequestPubkey:null};if(t.payloadType===ft.PayloadType.TextMessage&&t.payload.decoded){const s=t.payload.decoded;r.srcHash=s.sourceHash||null,r.dstHash=s.destinationHash||null}else if(t.payloadType===ft.PayloadType.Advert&&t.payload.decoded)r.advertPubkey=t.payload.decoded.publicKey||null;else if(t.payloadType===ft.PayloadType.GroupText&&t.payload.decoded){const s=t.payload.decoded;r.groupTextSender=((e=s.decrypted)==null?void 0:e.sender)||null}else if(t.payloadType===ft.PayloadType.AnonRequest&&t.payload.decoded){const s=t.payload.decoded;r.anonRequestPubkey=s.senderPublicKey||null}return r}catch{return null}}function du(n){switch(n){case ft.PayloadType.Advert:return"AD";case ft.PayloadType.GroupText:return"GT";case ft.PayloadType.TextMessage:return"DM";case ft.PayloadType.Ack:return"ACK";case ft.PayloadType.Trace:return"TR";case ft.PayloadType.Request:case ft.PayloadType.AnonRequest:return"RQ";case ft.PayloadType.Response:return"RS";default:return"?"}}function pu(n,e){var i,r;const t=(n.messageHash||Qc(e.data).toString(16).padStart(8,"0")).slice(0,8);if(n.payloadType===ft.PayloadType.Advert&&n.advertPubkey)return`ad:${n.advertPubkey.slice(0,12)}`;if(n.payloadType===ft.PayloadType.GroupText){const s=n.groupTextSender||((i=e.decrypted_info)==null?void 0:i.sender)||"?";return`gt:${((r=e.decrypted_info)==null?void 0:r.channel_name)||"?"}:${s}:${t}`}return n.payloadType===ft.PayloadType.TextMessage?`dm:${n.srcHash||"?"}:${n.dstHash||"?"}:${t}`:n.payloadType===ft.PayloadType.AnonRequest&&n.anonRequestPubkey?`rq:${n.anonRequestPubkey.slice(0,12)}:${t}`:`other:${t}`}function lr(n){return{sourceId:typeof n.source=="string"?n.source:n.source.id,targetId:typeof n.target=="string"?n.target:n.target.id}}function ts(n,e){return[n,e].sort().join("->")}function cr(n){return(n==null?void 0:n.type)===Xs?"repeater":"client"}function Wa(n){return n.filter((e,t)=>t===0||e!==n[t-1])}function mu(n){const e=[],t=new Map;let i=!1,r=[];for(const s of n){if(s.nodeId){const a=e.length>0?e[e.length-1]:null;if(a&&i&&a!==s.nodeId){const o=ts(a,s.nodeId),l=t.get(o)??[];for(const c of r)l.includes(c)||l.push(c);t.set(o,l)}a!==s.nodeId&&e.push(s.nodeId),i=!1,r=[];continue}s.markHiddenLinkWhenOmitted&&e.length>0&&(i=!0,s.hiddenLabel&&!r.includes(s.hiddenLabel)&&r.push(s.hiddenLabel))}return{nodes:e,dashedLinkDetails:t}}function gu(n){const e=Date.now(),t=n.observations.filter(s=>e-s.timestamp<Kl),i=new Map;for(const s of t){const a=s.nextHop??"self";i.has(a)||i.set(a,new Set),i.get(a).add(s.source)}if(i.size<=1)return{shouldSplit:!1,disjointGroups:null};const r=new Map;for(const[s,a]of i)for(const o of a)r.has(o)||r.set(o,[]),r.get(o).push(s);for(const[,s]of r)if(s.length>1)return{shouldSplit:!1,disjointGroups:null};for(const[,s]of i)if(s.size<uu)return{shouldSplit:!1,disjointGroups:null};return{shouldSplit:!0,disjointGroups:i}}function _u(n,e,t,i){const r=Ei(e);if(!r)return;const s=Ei(i),a=Date.now();n.has(r)||n.set(r,{hopKey:r,observations:[]});const o=n.get(r);o.observations.push({source:t,nextHop:s,timestamp:a}),o.observations=o.observations.filter(l=>a-l.timestamp<Kl),o.observations.length>So&&(o.observations=o.observations.slice(-So))}const ur={self:2278750,repeater:3900150,client:16777215,ambiguous:10265519},xu=[{color:"#22c55e",label:"You",size:14},{color:"#3b82f6",label:"Repeater",size:10},{color:"#ffffff",label:"Node",size:10},{color:"#9ca3af",label:"Ambiguous",size:10}];function Eo(n){return n.type==="self"?ur.self:n.type==="repeater"?ur.repeater:n.isAmbiguous?ur.ambiguous:ur.client}function Ii(n,e){let t=Math.max(12,n.length);for(;t<e;)t*=2;return new Float32Array(t)}function vu(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;return!0}function Mu(n){const e=Math.floor((Date.now()-n)/1e3);if(e<5)return"just now";if(e<60)return`${e}s ago`;const t=Math.floor(e/60),i=e%60;return i>0?`${t}m ${i}s ago`:`${t}m ago`}function Su(n){const e=n.name||(n.type==="self"?"Me":n.id.slice(0,8));return n.isAmbiguous?`${e} (?)`:e}function yu(n){if(!Number.isFinite(n)||!n||n<=0)return Date.now();const e=Number(n);return e>1e12?e:e*1e3}function bu({showControls:n,setShowControls:e,fullScreen:t,onFullScreenChange:i,showAmbiguousPaths:r,setShowAmbiguousPaths:s,showAmbiguousNodes:a,setShowAmbiguousNodes:o,useAdvertPathHints:l,setUseAdvertPathHints:c,collapseLikelyKnownSiblingRepeaters:h,setCollapseLikelyKnownSiblingRepeaters:f,splitAmbiguousByTraffic:d,setSplitAmbiguousByTraffic:m,observationWindowSec:g,setObservationWindowSec:x,pruneStaleNodes:p,setPruneStaleNodes:u,pruneStaleMinutes:y,setPruneStaleMinutes:v,letEmDrift:M,setLetEmDrift:b,autoOrbit:w,setAutoOrbit:R,chargeStrength:I,setChargeStrength:S,particleSpeedMultiplier:T,setParticleSpeedMultiplier:P,nodeCount:B,linkCount:z,onExpandContract:j,onClearAndReset:K}){return J.jsxs(J.Fragment,{children:[n&&J.jsx("div",{className:"absolute bottom-4 left-4 bg-background/80 backdrop-blur-sm rounded-lg p-3 text-xs border border-border z-10",children:J.jsxs("div",{className:"flex gap-6",children:[J.jsxs("div",{className:"flex flex-col gap-1.5",children:[J.jsx("div",{className:"text-muted-foreground font-medium mb-1",children:"Packets"}),hu.map(L=>J.jsxs("div",{className:"flex items-center gap-2",children:[J.jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[8px] font-bold text-white",style:{backgroundColor:L.color},children:L.label}),J.jsx("span",{children:L.description})]},L.label))]}),J.jsxs("div",{className:"flex flex-col gap-1.5",children:[J.jsx("div",{className:"text-muted-foreground font-medium mb-1",children:"Nodes"}),xu.map(L=>J.jsxs("div",{className:"flex items-center gap-2",children:[J.jsx("div",{className:"rounded-full",style:{width:L.size,height:L.size,backgroundColor:L.color}}),J.jsx("span",{children:L.label})]},L.label))]})]})}),J.jsx("div",{className:`absolute top-4 left-4 bg-background/80 backdrop-blur-sm rounded-lg p-3 text-xs border border-border z-10 transition-opacity ${n?"":"opacity-40 hover:opacity-100"}`,children:J.jsxs("div",{className:"flex flex-col gap-2",children:[J.jsxs("div",{className:"flex flex-col gap-2",children:[J.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[J.jsx(an,{checked:n,onCheckedChange:L=>e(L===!0)}),J.jsx("span",{title:"Toggle legends and controls visibility",children:"Show controls"})]}),i&&J.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[J.jsx(an,{checked:!t,onCheckedChange:L=>i(L!==!0)}),J.jsx("span",{title:"Show or hide the packet feed sidebar",children:"Show packet feed sidebar"})]})]}),n&&J.jsxs(J.Fragment,{children:[J.jsxs("div",{className:"border-t border-border pt-2 mt-1 flex flex-col gap-2",children:[J.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[J.jsx(an,{checked:r,onCheckedChange:L=>s(L===!0)}),J.jsx("span",{title:"Show placeholder nodes for repeaters when the 1-byte prefix matches multiple contacts",children:"Show ambiguous repeaters"})]}),J.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[J.jsx(an,{checked:a,onCheckedChange:L=>o(L===!0)}),J.jsx("span",{title:"Show placeholder nodes for senders/recipients when only a 1-byte prefix is known",children:"Show ambiguous sender/recipient"})]}),J.jsxs("details",{className:"rounded border border-border/60 px-2 py-1",children:[J.jsx("summary",{className:"cursor-pointer select-none text-muted-foreground",children:"Advanced"}),J.jsxs("div",{className:"mt-2 flex flex-col gap-2",children:[J.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[J.jsx(an,{checked:l,onCheckedChange:L=>c(L===!0),disabled:!r}),J.jsx("span",{title:"Use stored repeater advert paths to assign likely identity labels for ambiguous repeater nodes.",className:r?"":"text-muted-foreground",children:"Use repeater advert-path identity hints"})]}),J.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[J.jsx(an,{checked:h,onCheckedChange:L=>f(L===!0),disabled:!r||!l}),J.jsx("span",{title:"When an ambiguous repeater has a high-confidence likely-identity that matches a sibling definitely-known repeater, and they both connect to the same next hop, collapse them into the known repeater. This should resolve more ambiguity as the mesh navigates the 1.14 upgrade.",className:!r||!l?"text-muted-foreground":"",children:"Collapse likely sibling repeaters"})]}),J.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[J.jsx(an,{checked:d,onCheckedChange:L=>m(L===!0),disabled:!r}),J.jsx("span",{title:"Split ambiguous repeaters into separate nodes based on traffic patterns (prev→next). Helps identify colliding prefixes representing different physical nodes, but requires enough traffic to disambiguate.",className:r?"":"text-muted-foreground",children:"Heuristically group repeaters by traffic pattern"})]}),J.jsxs("div",{className:"flex items-center gap-2",children:[J.jsx("label",{htmlFor:"observation-window-3d",className:"text-muted-foreground",title:"How long to wait for duplicate packets via different paths before animating",children:"Ack/echo listen window:"}),J.jsx("input",{id:"observation-window-3d",type:"number",min:"1",max:"60",value:g,onChange:L=>x(Math.max(1,Math.min(60,parseInt(L.target.value,10)||1))),className:"w-12 px-1 py-0.5 bg-background border border-border rounded text-xs text-center"}),J.jsx("span",{className:"text-muted-foreground",children:"sec"})]})]})]}),J.jsxs("div",{className:"border-t border-border pt-2 mt-1 flex flex-col gap-2",children:[J.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[J.jsx(an,{checked:p,onCheckedChange:L=>u(L===!0)}),J.jsx("span",{title:"Automatically remove nodes with no traffic within the configured window to keep the mesh manageable",children:"Only show recently heard/in-a-path nodes"})]}),p&&J.jsxs("div",{className:"flex items-center gap-2 pl-6",children:[J.jsx("label",{htmlFor:"prune-window",className:"text-muted-foreground whitespace-nowrap",children:"Window:"}),J.jsx("input",{id:"prune-window",type:"number",min:1,max:60,value:y,onChange:L=>{const k=parseInt(L.target.value,10);!isNaN(k)&&k>=1&&k<=60&&v(k)},className:"w-14 rounded border border-border bg-background px-2 py-0.5 text-sm"}),J.jsx("span",{className:"text-muted-foreground","aria-hidden":"true",children:"min"})]}),J.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[J.jsx(an,{checked:M,onCheckedChange:L=>b(L===!0)}),J.jsx("span",{title:"When enabled, the graph continuously reorganizes itself into a better layout",children:"Let 'em drift"})]}),J.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[J.jsx(an,{checked:w,onCheckedChange:L=>R(L===!0)}),J.jsx("span",{title:"Automatically orbit the camera around the scene",children:"Orbit the mesh"})]}),J.jsxs("div",{className:"flex flex-col gap-1 mt-1",children:[J.jsxs("label",{htmlFor:"viz-repulsion",className:"text-muted-foreground",title:"How strongly nodes repel each other. Higher values spread nodes out more.",children:["Repulsion: ",Math.abs(I)]}),J.jsx("input",{id:"viz-repulsion",type:"range",min:"50",max:"2500",value:Math.abs(I),onChange:L=>S(-parseInt(L.target.value,10)),className:"w-full h-2 bg-border rounded-lg appearance-none cursor-pointer accent-primary"})]}),J.jsxs("div",{className:"flex flex-col gap-1 mt-1",children:[J.jsxs("label",{htmlFor:"viz-packet-speed",className:"text-muted-foreground",title:"How fast particles travel along links. Higher values make packets move faster.",children:["Packet speed: ",T,"x"]}),J.jsx("input",{id:"viz-packet-speed",type:"range",min:"1",max:"5",step:"0.5",value:T,onChange:L=>P(parseFloat(L.target.value)),className:"w-full h-2 bg-border rounded-lg appearance-none cursor-pointer accent-primary"})]})]}),J.jsx("button",{onClick:j,className:"mt-1 px-3 py-1.5 bg-primary/20 hover:bg-primary/30 text-primary rounded text-xs transition-colors",title:"Expand nodes apart then contract back - can help untangle the graph",children:"Oooh Big Stretch!"}),J.jsx("button",{onClick:K,className:"mt-1 rounded border border-warning/40 bg-warning/10 px-3 py-1.5 text-warning text-xs transition-colors hover:bg-warning/20",title:"Clear all nodes and links from the visualization - packets are preserved",children:"Clear & Reset"})]}),J.jsxs("div",{className:"border-t border-border pt-2 mt-1",children:[J.jsxs("div",{children:["Nodes: ",B]}),J.jsxs("div",{children:["Links: ",z]})]})]})]})})]})}function Eu({activeNodeId:n,canonicalNodes:e,canonicalNeighborIds:t,renderedNodeIds:i}){if(!n)return null;const r=e.get(n);if(!r)return null;const a=(t.get(n)??[]).map(o=>{const l=e.get(o);if(!l)return null;const c=l.name||(l.type==="self"?"Me":l.id.slice(0,8));return{id:o,name:c,ambiguousNames:l.ambiguousNames,hidden:!i.has(o)}}).filter(o=>o!==null);return J.jsx("div",{className:"absolute top-4 right-4 bg-background/90 backdrop-blur-sm rounded-lg p-3 text-xs border border-border z-10 max-w-72 max-h-[calc(100%-2rem)] overflow-y-auto",children:J.jsxs("div",{className:"flex flex-col gap-1",children:[J.jsx("div",{className:"font-medium",children:r.name||(r.type==="self"?"Me":r.id.slice(0,8))}),J.jsxs("div",{className:"text-muted-foreground",children:["ID: ",r.id]}),J.jsxs("div",{className:"text-muted-foreground",children:["Type: ",r.type,r.isAmbiguous?" (ambiguous)":""]}),r.probableIdentity&&J.jsxs("div",{className:"text-muted-foreground",children:["Probably: ",r.probableIdentity]}),r.ambiguousNames&&r.ambiguousNames.length>0&&J.jsxs("div",{className:"text-muted-foreground",children:[r.probableIdentity?"Other possible: ":"Possible: ",r.ambiguousNames.join(", ")]}),r.type!=="self"&&J.jsxs("div",{className:"text-muted-foreground border-t border-border pt-1 mt-1",children:[J.jsxs("div",{children:["Last active: ",Mu(r.lastActivity)]}),r.lastActivityReason&&J.jsxs("div",{children:["Reason: ",r.lastActivityReason]})]}),a.length>0&&J.jsxs("div",{className:"text-muted-foreground border-t border-border pt-1 mt-1",children:[J.jsx("div",{className:"mb-0.5",children:"Traffic exchanged with:"}),J.jsx("ul",{className:"pl-3 flex flex-col gap-0.5",children:a.map(o=>J.jsxs("li",{children:[o.name,o.hidden&&J.jsx("span",{className:"text-muted-foreground/60",children:" (hidden)"}),o.ambiguousNames&&o.ambiguousNames.length>0&&J.jsxs("span",{className:"text-muted-foreground/60",children:[" ","(",o.ambiguousNames.join(", "),")"]})]},o.id))})]})]})})}function Tu(n,e,t){var i,r=1;n==null&&(n=0),e==null&&(e=0),t==null&&(t=0);function s(){var a,o=i.length,l,c=0,h=0,f=0;for(a=0;a<o;++a)l=i[a],c+=l.x||0,h+=l.y||0,f+=l.z||0;for(c=(c/o-n)*r,h=(h/o-e)*r,f=(f/o-t)*r,a=0;a<o;++a)l=i[a],c&&(l.x-=c),h&&(l.y-=h),f&&(l.z-=f)}return s.initialize=function(a){i=a},s.x=function(a){return arguments.length?(n=+a,s):n},s.y=function(a){return arguments.length?(e=+a,s):e},s.z=function(a){return arguments.length?(t=+a,s):t},s.strength=function(a){return arguments.length?(r=+a,s):r},s}function Au(n){const e=+this._x.call(null,n);return $l(this.cover(e),e,n)}function $l(n,e,t){if(isNaN(e))return n;var i,r=n._root,s={data:t},a=n._x0,o=n._x1,l,c,h,f,d;if(!r)return n._root=s,n;for(;r.length;)if((h=e>=(l=(a+o)/2))?a=l:o=l,i=r,!(r=r[f=+h]))return i[f]=s,n;if(c=+n._x.call(null,r.data),e===c)return s.next=r,i?i[f]=s:n._root=s,n;do i=i?i[f]=new Array(2):n._root=new Array(2),(h=e>=(l=(a+o)/2))?a=l:o=l;while((f=+h)==(d=+(c>=l)));return i[d]=r,i[f]=s,n}function wu(n){Array.isArray(n)||(n=Array.from(n));const e=n.length,t=new Float64Array(e);let i=1/0,r=-1/0;for(let s=0,a;s<e;++s)isNaN(a=+this._x.call(null,n[s]))||(t[s]=a,a<i&&(i=a),a>r&&(r=a));if(i>r)return this;this.cover(i).cover(r);for(let s=0;s<e;++s)$l(this,t[s],n[s]);return this}function Ru(n){if(isNaN(n=+n))return this;var e=this._x0,t=this._x1;if(isNaN(e))t=(e=Math.floor(n))+1;else{for(var i=t-e||1,r=this._root,s,a;e>n||n>=t;)switch(a=+(n<e),s=new Array(2),s[a]=r,r=s,i*=2,a){case 0:t=e+i;break;case 1:e=t-i;break}this._root&&this._root.length&&(this._root=r)}return this._x0=e,this._x1=t,this}function Cu(){var n=[];return this.visit(function(e){if(!e.length)do n.push(e.data);while(e=e.next)}),n}function Pu(n){return arguments.length?this.cover(+n[0][0]).cover(+n[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]}function Tn(n,e,t){this.node=n,this.x0=e,this.x1=t}function Du(n,e){var t,i=this._x0,r,s,a=this._x1,o=[],l=this._root,c,h;for(l&&o.push(new Tn(l,i,a)),e==null?e=1/0:(i=n-e,a=n+e);c=o.pop();)if(!(!(l=c.node)||(r=c.x0)>a||(s=c.x1)<i))if(l.length){var f=(r+s)/2;o.push(new Tn(l[1],f,s),new Tn(l[0],r,f)),(h=+(n>=f))&&(c=o[o.length-1],o[o.length-1]=o[o.length-1-h],o[o.length-1-h]=c)}else{var d=Math.abs(n-+this._x.call(null,l.data));d<e&&(e=d,i=n-d,a=n+d,t=l.data)}return t}function Lu(n){if(isNaN(l=+this._x.call(null,n)))return this;var e,t=this._root,i,r,s,a=this._x0,o=this._x1,l,c,h,f,d;if(!t)return this;if(t.length)for(;;){if((h=l>=(c=(a+o)/2))?a=c:o=c,e=t,!(t=t[f=+h]))return this;if(!t.length)break;e[f+1&1]&&(i=e,d=f)}for(;t.data!==n;)if(r=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,r?(s?r.next=s:delete r.next,this):e?(s?e[f]=s:delete e[f],(t=e[0]||e[1])&&t===(e[1]||e[0])&&!t.length&&(i?i[d]=t:this._root=t),this):(this._root=s,this)}function Nu(n){for(var e=0,t=n.length;e<t;++e)this.remove(n[e]);return this}function Iu(){return this._root}function Uu(){var n=0;return this.visit(function(e){if(!e.length)do++n;while(e=e.next)}),n}function Fu(n){var e=[],t,i=this._root,r,s,a;for(i&&e.push(new Tn(i,this._x0,this._x1));t=e.pop();)if(!n(i=t.node,s=t.x0,a=t.x1)&&i.length){var o=(s+a)/2;(r=i[1])&&e.push(new Tn(r,o,a)),(r=i[0])&&e.push(new Tn(r,s,o))}return this}function Ou(n){var e=[],t=[],i;for(this._root&&e.push(new Tn(this._root,this._x0,this._x1));i=e.pop();){var r=i.node;if(r.length){var s,a=i.x0,o=i.x1,l=(a+o)/2;(s=r[0])&&e.push(new Tn(s,a,l)),(s=r[1])&&e.push(new Tn(s,l,o))}t.push(i)}for(;i=t.pop();)n(i.node,i.x0,i.x1);return this}function Bu(n){return n[0]}function zu(n){return arguments.length?(this._x=n,this):this._x}function Zl(n,e){var t=new Xa(e??Bu,NaN,NaN);return n==null?t:t.addAll(n)}function Xa(n,e,t){this._x=n,this._x0=e,this._x1=t,this._root=void 0}function To(n){for(var e={data:n.data},t=e;n=n.next;)t=t.next={data:n.data};return e}var Gt=Zl.prototype=Xa.prototype;Gt.copy=function(){var n=new Xa(this._x,this._x0,this._x1),e=this._root,t,i;if(!e)return n;if(!e.length)return n._root=To(e),n;for(t=[{source:e,target:n._root=new Array(2)}];e=t.pop();)for(var r=0;r<2;++r)(i=e.source[r])&&(i.length?t.push({source:i,target:e.target[r]=new Array(2)}):e.target[r]=To(i));return n};Gt.add=Au;Gt.addAll=wu;Gt.cover=Ru;Gt.data=Cu;Gt.extent=Pu;Gt.find=Du;Gt.remove=Lu;Gt.removeAll=Nu;Gt.root=Iu;Gt.size=Uu;Gt.visit=Fu;Gt.visitAfter=Ou;Gt.x=zu;function ku(n){const e=+this._x.call(null,n),t=+this._y.call(null,n);return Jl(this.cover(e,t),e,t,n)}function Jl(n,e,t,i){if(isNaN(e)||isNaN(t))return n;var r,s=n._root,a={data:i},o=n._x0,l=n._y0,c=n._x1,h=n._y1,f,d,m,g,x,p,u,y;if(!s)return n._root=a,n;for(;s.length;)if((x=e>=(f=(o+c)/2))?o=f:c=f,(p=t>=(d=(l+h)/2))?l=d:h=d,r=s,!(s=s[u=p<<1|x]))return r[u]=a,n;if(m=+n._x.call(null,s.data),g=+n._y.call(null,s.data),e===m&&t===g)return a.next=s,r?r[u]=a:n._root=a,n;do r=r?r[u]=new Array(4):n._root=new Array(4),(x=e>=(f=(o+c)/2))?o=f:c=f,(p=t>=(d=(l+h)/2))?l=d:h=d;while((u=p<<1|x)===(y=(g>=d)<<1|m>=f));return r[y]=s,r[u]=a,n}function Vu(n){var e,t,i=n.length,r,s,a=new Array(i),o=new Array(i),l=1/0,c=1/0,h=-1/0,f=-1/0;for(t=0;t<i;++t)isNaN(r=+this._x.call(null,e=n[t]))||isNaN(s=+this._y.call(null,e))||(a[t]=r,o[t]=s,r<l&&(l=r),r>h&&(h=r),s<c&&(c=s),s>f&&(f=s));if(l>h||c>f)return this;for(this.cover(l,c).cover(h,f),t=0;t<i;++t)Jl(this,a[t],o[t],n[t]);return this}function Hu(n,e){if(isNaN(n=+n)||isNaN(e=+e))return this;var t=this._x0,i=this._y0,r=this._x1,s=this._y1;if(isNaN(t))r=(t=Math.floor(n))+1,s=(i=Math.floor(e))+1;else{for(var a=r-t||1,o=this._root,l,c;t>n||n>=r||i>e||e>=s;)switch(c=(e<i)<<1|n<t,l=new Array(4),l[c]=o,o=l,a*=2,c){case 0:r=t+a,s=i+a;break;case 1:t=r-a,s=i+a;break;case 2:r=t+a,i=s-a;break;case 3:t=r-a,i=s-a;break}this._root&&this._root.length&&(this._root=o)}return this._x0=t,this._y0=i,this._x1=r,this._y1=s,this}function Gu(){var n=[];return this.visit(function(e){if(!e.length)do n.push(e.data);while(e=e.next)}),n}function Wu(n){return arguments.length?this.cover(+n[0][0],+n[0][1]).cover(+n[1][0],+n[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function It(n,e,t,i,r){this.node=n,this.x0=e,this.y0=t,this.x1=i,this.y1=r}function Xu(n,e,t){var i,r=this._x0,s=this._y0,a,o,l,c,h=this._x1,f=this._y1,d=[],m=this._root,g,x;for(m&&d.push(new It(m,r,s,h,f)),t==null?t=1/0:(r=n-t,s=e-t,h=n+t,f=e+t,t*=t);g=d.pop();)if(!(!(m=g.node)||(a=g.x0)>h||(o=g.y0)>f||(l=g.x1)<r||(c=g.y1)<s))if(m.length){var p=(a+l)/2,u=(o+c)/2;d.push(new It(m[3],p,u,l,c),new It(m[2],a,u,p,c),new It(m[1],p,o,l,u),new It(m[0],a,o,p,u)),(x=(e>=u)<<1|n>=p)&&(g=d[d.length-1],d[d.length-1]=d[d.length-1-x],d[d.length-1-x]=g)}else{var y=n-+this._x.call(null,m.data),v=e-+this._y.call(null,m.data),M=y*y+v*v;if(M<t){var b=Math.sqrt(t=M);r=n-b,s=e-b,h=n+b,f=e+b,i=m.data}}return i}function qu(n){if(isNaN(h=+this._x.call(null,n))||isNaN(f=+this._y.call(null,n)))return this;var e,t=this._root,i,r,s,a=this._x0,o=this._y0,l=this._x1,c=this._y1,h,f,d,m,g,x,p,u;if(!t)return this;if(t.length)for(;;){if((g=h>=(d=(a+l)/2))?a=d:l=d,(x=f>=(m=(o+c)/2))?o=m:c=m,e=t,!(t=t[p=x<<1|g]))return this;if(!t.length)break;(e[p+1&3]||e[p+2&3]||e[p+3&3])&&(i=e,u=p)}for(;t.data!==n;)if(r=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,r?(s?r.next=s:delete r.next,this):e?(s?e[p]=s:delete e[p],(t=e[0]||e[1]||e[2]||e[3])&&t===(e[3]||e[2]||e[1]||e[0])&&!t.length&&(i?i[u]=t:this._root=t),this):(this._root=s,this)}function Yu(n){for(var e=0,t=n.length;e<t;++e)this.remove(n[e]);return this}function ju(){return this._root}function Ku(){var n=0;return this.visit(function(e){if(!e.length)do++n;while(e=e.next)}),n}function $u(n){var e=[],t,i=this._root,r,s,a,o,l;for(i&&e.push(new It(i,this._x0,this._y0,this._x1,this._y1));t=e.pop();)if(!n(i=t.node,s=t.x0,a=t.y0,o=t.x1,l=t.y1)&&i.length){var c=(s+o)/2,h=(a+l)/2;(r=i[3])&&e.push(new It(r,c,h,o,l)),(r=i[2])&&e.push(new It(r,s,h,c,l)),(r=i[1])&&e.push(new It(r,c,a,o,h)),(r=i[0])&&e.push(new It(r,s,a,c,h))}return this}function Zu(n){var e=[],t=[],i;for(this._root&&e.push(new It(this._root,this._x0,this._y0,this._x1,this._y1));i=e.pop();){var r=i.node;if(r.length){var s,a=i.x0,o=i.y0,l=i.x1,c=i.y1,h=(a+l)/2,f=(o+c)/2;(s=r[0])&&e.push(new It(s,a,o,h,f)),(s=r[1])&&e.push(new It(s,h,o,l,f)),(s=r[2])&&e.push(new It(s,a,f,h,c)),(s=r[3])&&e.push(new It(s,h,f,l,c))}t.push(i)}for(;i=t.pop();)n(i.node,i.x0,i.y0,i.x1,i.y1);return this}function Ju(n){return n[0]}function Qu(n){return arguments.length?(this._x=n,this):this._x}function eh(n){return n[1]}function th(n){return arguments.length?(this._y=n,this):this._y}function Ql(n,e,t){var i=new qa(e??Ju,t??eh,NaN,NaN,NaN,NaN);return n==null?i:i.addAll(n)}function qa(n,e,t,i,r,s){this._x=n,this._y=e,this._x0=t,this._y0=i,this._x1=r,this._y1=s,this._root=void 0}function Ao(n){for(var e={data:n.data},t=e;n=n.next;)t=t.next={data:n.data};return e}var Ft=Ql.prototype=qa.prototype;Ft.copy=function(){var n=new qa(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,t,i;if(!e)return n;if(!e.length)return n._root=Ao(e),n;for(t=[{source:e,target:n._root=new Array(4)}];e=t.pop();)for(var r=0;r<4;++r)(i=e.source[r])&&(i.length?t.push({source:i,target:e.target[r]=new Array(4)}):e.target[r]=Ao(i));return n};Ft.add=ku;Ft.addAll=Vu;Ft.cover=Hu;Ft.data=Gu;Ft.extent=Wu;Ft.find=Xu;Ft.remove=qu;Ft.removeAll=Yu;Ft.root=ju;Ft.size=Ku;Ft.visit=$u;Ft.visitAfter=Zu;Ft.x=Qu;Ft.y=th;function nh(n){const e=+this._x.call(null,n),t=+this._y.call(null,n),i=+this._z.call(null,n);return ec(this.cover(e,t,i),e,t,i,n)}function ec(n,e,t,i,r){if(isNaN(e)||isNaN(t)||isNaN(i))return n;var s,a=n._root,o={data:r},l=n._x0,c=n._y0,h=n._z0,f=n._x1,d=n._y1,m=n._z1,g,x,p,u,y,v,M,b,w,R,I;if(!a)return n._root=o,n;for(;a.length;)if((M=e>=(g=(l+f)/2))?l=g:f=g,(b=t>=(x=(c+d)/2))?c=x:d=x,(w=i>=(p=(h+m)/2))?h=p:m=p,s=a,!(a=a[R=w<<2|b<<1|M]))return s[R]=o,n;if(u=+n._x.call(null,a.data),y=+n._y.call(null,a.data),v=+n._z.call(null,a.data),e===u&&t===y&&i===v)return o.next=a,s?s[R]=o:n._root=o,n;do s=s?s[R]=new Array(8):n._root=new Array(8),(M=e>=(g=(l+f)/2))?l=g:f=g,(b=t>=(x=(c+d)/2))?c=x:d=x,(w=i>=(p=(h+m)/2))?h=p:m=p;while((R=w<<2|b<<1|M)===(I=(v>=p)<<2|(y>=x)<<1|u>=g));return s[I]=a,s[R]=o,n}function ih(n){Array.isArray(n)||(n=Array.from(n));const e=n.length,t=new Float64Array(e),i=new Float64Array(e),r=new Float64Array(e);let s=1/0,a=1/0,o=1/0,l=-1/0,c=-1/0,h=-1/0;for(let f=0,d,m,g,x;f<e;++f)isNaN(m=+this._x.call(null,d=n[f]))||isNaN(g=+this._y.call(null,d))||isNaN(x=+this._z.call(null,d))||(t[f]=m,i[f]=g,r[f]=x,m<s&&(s=m),m>l&&(l=m),g<a&&(a=g),g>c&&(c=g),x<o&&(o=x),x>h&&(h=x));if(s>l||a>c||o>h)return this;this.cover(s,a,o).cover(l,c,h);for(let f=0;f<e;++f)ec(this,t[f],i[f],r[f],n[f]);return this}function rh(n,e,t){if(isNaN(n=+n)||isNaN(e=+e)||isNaN(t=+t))return this;var i=this._x0,r=this._y0,s=this._z0,a=this._x1,o=this._y1,l=this._z1;if(isNaN(i))a=(i=Math.floor(n))+1,o=(r=Math.floor(e))+1,l=(s=Math.floor(t))+1;else{for(var c=a-i||1,h=this._root,f,d;i>n||n>=a||r>e||e>=o||s>t||t>=l;)switch(d=(t<s)<<2|(e<r)<<1|n<i,f=new Array(8),f[d]=h,h=f,c*=2,d){case 0:a=i+c,o=r+c,l=s+c;break;case 1:i=a-c,o=r+c,l=s+c;break;case 2:a=i+c,r=o-c,l=s+c;break;case 3:i=a-c,r=o-c,l=s+c;break;case 4:a=i+c,o=r+c,s=l-c;break;case 5:i=a-c,o=r+c,s=l-c;break;case 6:a=i+c,r=o-c,s=l-c;break;case 7:i=a-c,r=o-c,s=l-c;break}this._root&&this._root.length&&(this._root=h)}return this._x0=i,this._y0=r,this._z0=s,this._x1=a,this._y1=o,this._z1=l,this}function sh(){var n=[];return this.visit(function(e){if(!e.length)do n.push(e.data);while(e=e.next)}),n}function ah(n){return arguments.length?this.cover(+n[0][0],+n[0][1],+n[0][2]).cover(+n[1][0],+n[1][1],+n[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]}function ot(n,e,t,i,r,s,a){this.node=n,this.x0=e,this.y0=t,this.z0=i,this.x1=r,this.y1=s,this.z1=a}function oh(n,e,t,i){var r,s=this._x0,a=this._y0,o=this._z0,l,c,h,f,d,m,g=this._x1,x=this._y1,p=this._z1,u=[],y=this._root,v,M;for(y&&u.push(new ot(y,s,a,o,g,x,p)),i==null?i=1/0:(s=n-i,a=e-i,o=t-i,g=n+i,x=e+i,p=t+i,i*=i);v=u.pop();)if(!(!(y=v.node)||(l=v.x0)>g||(c=v.y0)>x||(h=v.z0)>p||(f=v.x1)<s||(d=v.y1)<a||(m=v.z1)<o))if(y.length){var b=(l+f)/2,w=(c+d)/2,R=(h+m)/2;u.push(new ot(y[7],b,w,R,f,d,m),new ot(y[6],l,w,R,b,d,m),new ot(y[5],b,c,R,f,w,m),new ot(y[4],l,c,R,b,w,m),new ot(y[3],b,w,h,f,d,R),new ot(y[2],l,w,h,b,d,R),new ot(y[1],b,c,h,f,w,R),new ot(y[0],l,c,h,b,w,R)),(M=(t>=R)<<2|(e>=w)<<1|n>=b)&&(v=u[u.length-1],u[u.length-1]=u[u.length-1-M],u[u.length-1-M]=v)}else{var I=n-+this._x.call(null,y.data),S=e-+this._y.call(null,y.data),T=t-+this._z.call(null,y.data),P=I*I+S*S+T*T;if(P<i){var B=Math.sqrt(i=P);s=n-B,a=e-B,o=t-B,g=n+B,x=e+B,p=t+B,r=y.data}}return r}const lh=(n,e,t,i,r,s)=>Math.sqrt((n-i)**2+(e-r)**2+(t-s)**2);function ch(n,e,t,i){const r=[],s=n-i,a=e-i,o=t-i,l=n+i,c=e+i,h=t+i;return this.visit((f,d,m,g,x,p,u)=>{if(!f.length)do{const y=f.data;lh(n,e,t,this._x(y),this._y(y),this._z(y))<=i&&r.push(y)}while(f=f.next);return d>l||m>c||g>h||x<s||p<a||u<o}),r}function uh(n){if(isNaN(d=+this._x.call(null,n))||isNaN(m=+this._y.call(null,n))||isNaN(g=+this._z.call(null,n)))return this;var e,t=this._root,i,r,s,a=this._x0,o=this._y0,l=this._z0,c=this._x1,h=this._y1,f=this._z1,d,m,g,x,p,u,y,v,M,b,w;if(!t)return this;if(t.length)for(;;){if((y=d>=(x=(a+c)/2))?a=x:c=x,(v=m>=(p=(o+h)/2))?o=p:h=p,(M=g>=(u=(l+f)/2))?l=u:f=u,e=t,!(t=t[b=M<<2|v<<1|y]))return this;if(!t.length)break;(e[b+1&7]||e[b+2&7]||e[b+3&7]||e[b+4&7]||e[b+5&7]||e[b+6&7]||e[b+7&7])&&(i=e,w=b)}for(;t.data!==n;)if(r=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,r?(s?r.next=s:delete r.next,this):e?(s?e[b]=s:delete e[b],(t=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&t===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!t.length&&(i?i[w]=t:this._root=t),this):(this._root=s,this)}function hh(n){for(var e=0,t=n.length;e<t;++e)this.remove(n[e]);return this}function fh(){return this._root}function dh(){var n=0;return this.visit(function(e){if(!e.length)do++n;while(e=e.next)}),n}function ph(n){var e=[],t,i=this._root,r,s,a,o,l,c,h;for(i&&e.push(new ot(i,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));t=e.pop();)if(!n(i=t.node,s=t.x0,a=t.y0,o=t.z0,l=t.x1,c=t.y1,h=t.z1)&&i.length){var f=(s+l)/2,d=(a+c)/2,m=(o+h)/2;(r=i[7])&&e.push(new ot(r,f,d,m,l,c,h)),(r=i[6])&&e.push(new ot(r,s,d,m,f,c,h)),(r=i[5])&&e.push(new ot(r,f,a,m,l,d,h)),(r=i[4])&&e.push(new ot(r,s,a,m,f,d,h)),(r=i[3])&&e.push(new ot(r,f,d,o,l,c,m)),(r=i[2])&&e.push(new ot(r,s,d,o,f,c,m)),(r=i[1])&&e.push(new ot(r,f,a,o,l,d,m)),(r=i[0])&&e.push(new ot(r,s,a,o,f,d,m))}return this}function mh(n){var e=[],t=[],i;for(this._root&&e.push(new ot(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));i=e.pop();){var r=i.node;if(r.length){var s,a=i.x0,o=i.y0,l=i.z0,c=i.x1,h=i.y1,f=i.z1,d=(a+c)/2,m=(o+h)/2,g=(l+f)/2;(s=r[0])&&e.push(new ot(s,a,o,l,d,m,g)),(s=r[1])&&e.push(new ot(s,d,o,l,c,m,g)),(s=r[2])&&e.push(new ot(s,a,m,l,d,h,g)),(s=r[3])&&e.push(new ot(s,d,m,l,c,h,g)),(s=r[4])&&e.push(new ot(s,a,o,g,d,m,f)),(s=r[5])&&e.push(new ot(s,d,o,g,c,m,f)),(s=r[6])&&e.push(new ot(s,a,m,g,d,h,f)),(s=r[7])&&e.push(new ot(s,d,m,g,c,h,f))}t.push(i)}for(;i=t.pop();)n(i.node,i.x0,i.y0,i.z0,i.x1,i.y1,i.z1);return this}function gh(n){return n[0]}function _h(n){return arguments.length?(this._x=n,this):this._x}function xh(n){return n[1]}function vh(n){return arguments.length?(this._y=n,this):this._y}function Mh(n){return n[2]}function Sh(n){return arguments.length?(this._z=n,this):this._z}function tc(n,e,t,i){var r=new Ya(e??gh,t??xh,i??Mh,NaN,NaN,NaN,NaN,NaN,NaN);return n==null?r:r.addAll(n)}function Ya(n,e,t,i,r,s,a,o,l){this._x=n,this._y=e,this._z=t,this._x0=i,this._y0=r,this._z0=s,this._x1=a,this._y1=o,this._z1=l,this._root=void 0}function wo(n){for(var e={data:n.data},t=e;n=n.next;)t=t.next={data:n.data};return e}var Et=tc.prototype=Ya.prototype;Et.copy=function(){var n=new Ya(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),e=this._root,t,i;if(!e)return n;if(!e.length)return n._root=wo(e),n;for(t=[{source:e,target:n._root=new Array(8)}];e=t.pop();)for(var r=0;r<8;++r)(i=e.source[r])&&(i.length?t.push({source:i,target:e.target[r]=new Array(8)}):e.target[r]=wo(i));return n};Et.add=nh;Et.addAll=ih;Et.cover=rh;Et.data=sh;Et.extent=ah;Et.find=oh;Et.findAllWithinRadius=ch;Et.remove=uh;Et.removeAll=hh;Et.root=fh;Et.size=dh;Et.visit=ph;Et.visitAfter=mh;Et.x=_h;Et.y=vh;Et.z=Sh;function yt(n){return function(){return n}}function yn(n){return(n()-.5)*1e-6}function yh(n){return n.index}function Ro(n,e){var t=n.get(e);if(!t)throw new Error("node not found: "+e);return t}function us(n){var e=yh,t=d,i,r=yt(30),s,a,o,l,c,h,f=1;n==null&&(n=[]);function d(u){return 1/Math.min(l[u.source.index],l[u.target.index])}function m(u){for(var y=0,v=n.length;y<f;++y)for(var M=0,b,w,R,I=0,S=0,T=0,P,B;M<v;++M)b=n[M],w=b.source,R=b.target,I=R.x+R.vx-w.x-w.vx||yn(h),o>1&&(S=R.y+R.vy-w.y-w.vy||yn(h)),o>2&&(T=R.z+R.vz-w.z-w.vz||yn(h)),P=Math.sqrt(I*I+S*S+T*T),P=(P-s[M])/P*u*i[M],I*=P,S*=P,T*=P,R.vx-=I*(B=c[M]),o>1&&(R.vy-=S*B),o>2&&(R.vz-=T*B),w.vx+=I*(B=1-B),o>1&&(w.vy+=S*B),o>2&&(w.vz+=T*B)}function g(){if(a){var u,y=a.length,v=n.length,M=new Map(a.map((w,R)=>[e(w,R,a),w])),b;for(u=0,l=new Array(y);u<v;++u)b=n[u],b.index=u,typeof b.source!="object"&&(b.source=Ro(M,b.source)),typeof b.target!="object"&&(b.target=Ro(M,b.target)),l[b.source.index]=(l[b.source.index]||0)+1,l[b.target.index]=(l[b.target.index]||0)+1;for(u=0,c=new Array(v);u<v;++u)b=n[u],c[u]=l[b.source.index]/(l[b.source.index]+l[b.target.index]);i=new Array(v),x(),s=new Array(v),p()}}function x(){if(a)for(var u=0,y=n.length;u<y;++u)i[u]=+t(n[u],u,n)}function p(){if(a)for(var u=0,y=n.length;u<y;++u)s[u]=+r(n[u],u,n)}return m.initialize=function(u,...y){a=u,h=y.find(v=>typeof v=="function")||Math.random,o=y.find(v=>[1,2,3].includes(v))||2,g()},m.links=function(u){return arguments.length?(n=u,g(),m):n},m.id=function(u){return arguments.length?(e=u,m):e},m.iterations=function(u){return arguments.length?(f=+u,m):f},m.strength=function(u){return arguments.length?(t=typeof u=="function"?u:yt(+u),x(),m):t},m.distance=function(u){return arguments.length?(r=typeof u=="function"?u:yt(+u),p(),m):r},m}var bh={value:()=>{}};function nc(){for(var n=0,e=arguments.length,t={},i;n<e;++n){if(!(i=arguments[n]+"")||i in t||/[\s.]/.test(i))throw new Error("illegal type: "+i);t[i]=[]}return new Br(t)}function Br(n){this._=n}function Eh(n,e){return n.trim().split(/^|\s+/).map(function(t){var i="",r=t.indexOf(".");if(r>=0&&(i=t.slice(r+1),t=t.slice(0,r)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:i}})}Br.prototype=nc.prototype={constructor:Br,on:function(n,e){var t=this._,i=Eh(n+"",t),r,s=-1,a=i.length;if(arguments.length<2){for(;++s<a;)if((r=(n=i[s]).type)&&(r=Th(t[r],n.name)))return r;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++s<a;)if(r=(n=i[s]).type)t[r]=Co(t[r],n.name,e);else if(e==null)for(r in t)t[r]=Co(t[r],n.name,null);return this},copy:function(){var n={},e=this._;for(var t in e)n[t]=e[t].slice();return new Br(n)},call:function(n,e){if((r=arguments.length-2)>0)for(var t=new Array(r),i=0,r,s;i<r;++i)t[i]=arguments[i+2];if(!this._.hasOwnProperty(n))throw new Error("unknown type: "+n);for(s=this._[n],i=0,r=s.length;i<r;++i)s[i].value.apply(e,t)},apply:function(n,e,t){if(!this._.hasOwnProperty(n))throw new Error("unknown type: "+n);for(var i=this._[n],r=0,s=i.length;r<s;++r)i[r].value.apply(e,t)}};function Th(n,e){for(var t=0,i=n.length,r;t<i;++t)if((r=n[t]).name===e)return r.value}function Co(n,e,t){for(var i=0,r=n.length;i<r;++i)if(n[i].name===e){n[i]=bh,n=n.slice(0,i).concat(n.slice(i+1));break}return t!=null&&n.push({name:e,value:t}),n}var Ti=0,qi=0,Ui=0,ic=1e3,Yr,Yi,jr=0,Qn=0,ns=0,$i=typeof performance=="object"&&performance.now?performance:Date,rc=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(n){setTimeout(n,17)};function sc(){return Qn||(rc(Ah),Qn=$i.now()+ns)}function Ah(){Qn=0}function qs(){this._call=this._time=this._next=null}qs.prototype=ac.prototype={constructor:qs,restart:function(n,e,t){if(typeof n!="function")throw new TypeError("callback is not a function");t=(t==null?sc():+t)+(e==null?0:+e),!this._next&&Yi!==this&&(Yi?Yi._next=this:Yr=this,Yi=this),this._call=n,this._time=t,Ys()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ys())}};function ac(n,e,t){var i=new qs;return i.restart(n,e,t),i}function wh(){sc(),++Ti;for(var n=Yr,e;n;)(e=Qn-n._time)>=0&&n._call.call(void 0,e),n=n._next;--Ti}function Po(){Qn=(jr=$i.now())+ns,Ti=qi=0;try{wh()}finally{Ti=0,Ch(),Qn=0}}function Rh(){var n=$i.now(),e=n-jr;e>ic&&(ns-=e,jr=n)}function Ch(){for(var n,e=Yr,t,i=1/0;e;)e._call?(i>e._time&&(i=e._time),n=e,e=e._next):(t=e._next,e._next=null,e=n?n._next=t:Yr=t);Yi=n,Ys(i)}function Ys(n){if(!Ti){qi&&(qi=clearTimeout(qi));var e=n-Qn;e>24?(n<1/0&&(qi=setTimeout(Po,n-$i.now()-ns)),Ui&&(Ui=clearInterval(Ui))):(Ui||(jr=$i.now(),Ui=setInterval(Rh,ic)),Ti=1,rc(Po))}}const Ph=1664525,Dh=1013904223,Do=4294967296;function Lh(){let n=1;return()=>(n=(Ph*n+Dh)%Do)/Do}var Lo=3;function hs(n){return n.x}function No(n){return n.y}function Nh(n){return n.z}var Ih=10,Uh=Math.PI*(3-Math.sqrt(5)),Fh=Math.PI*20/(9+Math.sqrt(221));function Oh(n,e){e=e||2;var t=Math.min(Lo,Math.max(1,Math.round(e))),i,r=1,s=.001,a=1-Math.pow(s,1/300),o=0,l=.6,c=new Map,h=ac(m),f=nc("tick","end"),d=Lh();n==null&&(n=[]);function m(){g(),f.call("tick",i),r<s&&(h.stop(),f.call("end",i))}function g(u){var y,v=n.length,M;u===void 0&&(u=1);for(var b=0;b<u;++b)for(r+=(o-r)*a,c.forEach(function(w){w(r)}),y=0;y<v;++y)M=n[y],M.fx==null?M.x+=M.vx*=l:(M.x=M.fx,M.vx=0),t>1&&(M.fy==null?M.y+=M.vy*=l:(M.y=M.fy,M.vy=0)),t>2&&(M.fz==null?M.z+=M.vz*=l:(M.z=M.fz,M.vz=0));return i}function x(){for(var u=0,y=n.length,v;u<y;++u){if(v=n[u],v.index=u,v.fx!=null&&(v.x=v.fx),v.fy!=null&&(v.y=v.fy),v.fz!=null&&(v.z=v.fz),isNaN(v.x)||t>1&&isNaN(v.y)||t>2&&isNaN(v.z)){var M=Ih*(t>2?Math.cbrt(.5+u):t>1?Math.sqrt(.5+u):u),b=u*Uh,w=u*Fh;t===1?v.x=M:t===2?(v.x=M*Math.cos(b),v.y=M*Math.sin(b)):(v.x=M*Math.sin(b)*Math.cos(w),v.y=M*Math.cos(b),v.z=M*Math.sin(b)*Math.sin(w))}(isNaN(v.vx)||t>1&&isNaN(v.vy)||t>2&&isNaN(v.vz))&&(v.vx=0,t>1&&(v.vy=0),t>2&&(v.vz=0))}}function p(u){return u.initialize&&u.initialize(n,d,t),u}return x(),i={tick:g,restart:function(){return h.restart(m),i},stop:function(){return h.stop(),i},numDimensions:function(u){return arguments.length?(t=Math.min(Lo,Math.max(1,Math.round(u))),c.forEach(p),i):t},nodes:function(u){return arguments.length?(n=u,x(),c.forEach(p),i):n},alpha:function(u){return arguments.length?(r=+u,i):r},alphaMin:function(u){return arguments.length?(s=+u,i):s},alphaDecay:function(u){return arguments.length?(a=+u,i):+a},alphaTarget:function(u){return arguments.length?(o=+u,i):o},velocityDecay:function(u){return arguments.length?(l=1-u,i):1-l},randomSource:function(u){return arguments.length?(d=u,c.forEach(p),i):d},force:function(u,y){return arguments.length>1?(y==null?c.delete(u):c.set(u,p(y)),i):c.get(u)},find:function(){var u=Array.prototype.slice.call(arguments),y=u.shift()||0,v=(t>1?u.shift():null)||0,M=(t>2?u.shift():null)||0,b=u.shift()||1/0,w=0,R=n.length,I,S,T,P,B,z;for(b*=b,w=0;w<R;++w)B=n[w],I=y-B.x,S=v-(B.y||0),T=M-(B.z||0),P=I*I+S*S+T*T,P<b&&(z=B,b=P);return z},on:function(u,y){return arguments.length>1?(f.on(u,y),i):f.on(u)}}}function hr(){var n,e,t,i,r,s=yt(-30),a,o=1,l=1/0,c=.81;function h(g){var x,p=n.length,u=(e===1?Zl(n,hs):e===2?Ql(n,hs,No):e===3?tc(n,hs,No,Nh):null).visitAfter(d);for(r=g,x=0;x<p;++x)t=n[x],u.visit(m)}function f(){if(n){var g,x=n.length,p;for(a=new Array(x),g=0;g<x;++g)p=n[g],a[p.index]=+s(p,g,n)}}function d(g){var x=0,p,u,y=0,v,M,b,w,R=g.length;if(R){for(v=M=b=w=0;w<R;++w)(p=g[w])&&(u=Math.abs(p.value))&&(x+=p.value,y+=u,v+=u*(p.x||0),M+=u*(p.y||0),b+=u*(p.z||0));x*=Math.sqrt(4/R),g.x=v/y,e>1&&(g.y=M/y),e>2&&(g.z=b/y)}else{p=g,p.x=p.data.x,e>1&&(p.y=p.data.y),e>2&&(p.z=p.data.z);do x+=a[p.data.index];while(p=p.next)}g.value=x}function m(g,x,p,u,y){if(!g.value)return!0;var v=[p,u,y][e-1],M=g.x-t.x,b=e>1?g.y-t.y:0,w=e>2?g.z-t.z:0,R=v-x,I=M*M+b*b+w*w;if(R*R/c<I)return I<l&&(M===0&&(M=yn(i),I+=M*M),e>1&&b===0&&(b=yn(i),I+=b*b),e>2&&w===0&&(w=yn(i),I+=w*w),I<o&&(I=Math.sqrt(o*I)),t.vx+=M*g.value*r/I,e>1&&(t.vy+=b*g.value*r/I),e>2&&(t.vz+=w*g.value*r/I)),!0;if(g.length||I>=l)return;(g.data!==t||g.next)&&(M===0&&(M=yn(i),I+=M*M),e>1&&b===0&&(b=yn(i),I+=b*b),e>2&&w===0&&(w=yn(i),I+=w*w),I<o&&(I=Math.sqrt(o*I)));do g.data!==t&&(R=a[g.data.index]*r/I,t.vx+=M*R,e>1&&(t.vy+=b*R),e>2&&(t.vz+=w*R));while(g=g.next)}return h.initialize=function(g,...x){n=g,i=x.find(p=>typeof p=="function")||Math.random,e=x.find(p=>[1,2,3].includes(p))||2,f()},h.strength=function(g){return arguments.length?(s=typeof g=="function"?g:yt(+g),f(),h):s},h.distanceMin=function(g){return arguments.length?(o=g*g,h):Math.sqrt(o)},h.distanceMax=function(g){return arguments.length?(l=g*g,h):Math.sqrt(l)},h.theta=function(g){return arguments.length?(c=g*g,h):Math.sqrt(c)},h}function Bh(n){var e=yt(.1),t,i,r;typeof n!="function"&&(n=yt(n==null?0:+n));function s(o){for(var l=0,c=t.length,h;l<c;++l)h=t[l],h.vx+=(r[l]-h.x)*i[l]*o}function a(){if(t){var o,l=t.length;for(i=new Array(l),r=new Array(l),o=0;o<l;++o)i[o]=isNaN(r[o]=+n(t[o],o,t))?0:+e(t[o],o,t)}}return s.initialize=function(o){t=o,a()},s.strength=function(o){return arguments.length?(e=typeof o=="function"?o:yt(+o),a(),s):e},s.x=function(o){return arguments.length?(n=typeof o=="function"?o:yt(+o),a(),s):n},s}function zh(n){var e=yt(.1),t,i,r;typeof n!="function"&&(n=yt(n==null?0:+n));function s(o){for(var l=0,c=t.length,h;l<c;++l)h=t[l],h.vy+=(r[l]-h.y)*i[l]*o}function a(){if(t){var o,l=t.length;for(i=new Array(l),r=new Array(l),o=0;o<l;++o)i[o]=isNaN(r[o]=+n(t[o],o,t))?0:+e(t[o],o,t)}}return s.initialize=function(o){t=o,a()},s.strength=function(o){return arguments.length?(e=typeof o=="function"?o:yt(+o),a(),s):e},s.y=function(o){return arguments.length?(n=typeof o=="function"?o:yt(+o),a(),s):n},s}function kh(n){var e=yt(.1),t,i,r;typeof n!="function"&&(n=yt(n==null?0:+n));function s(o){for(var l=0,c=t.length,h;l<c;++l)h=t[l],h.vz+=(r[l]-h.z)*i[l]*o}function a(){if(t){var o,l=t.length;for(i=new Array(l),r=new Array(l),o=0;o<l;++o)i[o]=isNaN(r[o]=+n(t[o],o,t))?0:+e(t[o],o,t)}}return s.initialize=function(o){t=o,a()},s.strength=function(o){return arguments.length?(e=typeof o=="function"?o:yt(+o),a(),s):e},s.z=function(o){return arguments.length?(n=typeof o=="function"?o:yt(+o),a(),s):n},s}function Vh({config:n,contacts:e,repeaterAdvertPaths:t,splitAmbiguousByTraffic:i,useAdvertPathHints:r}){var c;const s=new Map,a=new Map,o=new Map;for(const h of e){const f=h.public_key.slice(0,12).toLowerCase();s.set(f,h),h.name&&!a.has(h.name)&&a.set(h.name,h);for(let d=1;d<=12;d++){const m=f.slice(0,d),g=o.get(m);g?g.push(h):o.set(m,[h])}}const l=new Map;for(const h of t){const f=h.public_key.slice(0,12).toLowerCase();l.set(f,h.paths)}return{contactIndex:{byPrefix12:s,byName:a,byPrefix:o},advertPathIndex:{byRepeater:l},myPrefix:((c=n==null?void 0:n.public_key)==null?void 0:c.slice(0,12).toLowerCase())||null,splitAmbiguousByTraffic:i,useAdvertPathHints:r}}function Hh(n="Me"){const e=Date.now();return{nodes:new Map([["self",{id:"self",name:n,type:"self",isAmbiguous:!1,lastActivity:e}]]),links:new Map,neighborIds:new Map,observations:[],trafficPatterns:new Map}}function Gh(n,e="Me"){const t=n.nodes.get("self");if(t){t.name=e;return}n.nodes.set("self",{id:"self",name:e,type:"self",isAmbiguous:!1,lastActivity:Date.now()})}function Io(n,{selfName:e="Me"}={}){n.links.clear(),n.neighborIds.clear(),n.observations=[],n.trafficPatterns.clear();const t=n.nodes.get("self");n.nodes.clear(),n.nodes.set("self",{id:"self",name:e,type:"self",isAmbiguous:!1,lastActivity:Date.now(),lastActivityReason:void 0,lastSeen:null,probableIdentity:void 0,probableIdentityNodeId:void 0,ambiguousNames:void 0}),t!=null&&t.name&&t.name!==e&&(n.nodes.get("self").name=e)}function ri(n,{activityAtMs:e,ambiguousNames:t,id:i,isAmbiguous:r,lastSeen:s,name:a,probableIdentity:o,probableIdentityNodeId:l,type:c}){const h=n.nodes.get(i);if(h){h.lastActivity=Math.max(h.lastActivity,e),a&&(h.name=a),o!==void 0&&(h.probableIdentity=o),l!==void 0&&(h.probableIdentityNodeId=l),t&&(h.ambiguousNames=t),s!==void 0&&(h.lastSeen=s);return}n.nodes.set(i,{id:i,name:a,type:c,isAmbiguous:r,lastActivity:e,probableIdentity:o,probableIdentityNodeId:l,ambiguousNames:t,lastSeen:s})}function Wh(n,e,t,i){const r=ts(e,t),s=n.links.get(r);s?s.lastActivity=Math.max(s.lastActivity,i):n.links.set(r,{sourceId:e,targetId:t,lastActivity:i})}function oc(n,e,t){const i=r=>{const s=n.neighborIds.get(r);if(s)return s;const a=new Set;return n.neighborIds.set(r,a),a};i(e).add(t),i(t).add(e)}function Xh(n,e,t){const i=(t==null?void 0:t.toLowerCase())??null,r=e.map(o=>{var d;const l=o.public_key.slice(0,12).toLowerCase(),c=n.advertPathIndex.byRepeater.get(l)??[];let h=0,f=0;for(const m of c)f+=m.heard_count,(((d=m.next_hop)==null?void 0:d.toLowerCase())??null)===i&&(h+=m.heard_count);return{candidate:o,matchScore:h,totalScore:f}}).filter(o=>o.totalScore>0).sort((o,l)=>l.matchScore-o.matchScore||l.totalScore-o.totalScore||o.candidate.public_key.localeCompare(l.candidate.public_key));if(r.length===0)return null;const s=r[0],a=r[1]??null;return s.matchScore<2||a&&s.matchScore<a.matchScore*2?null:s.candidate}function Fi(n,e,t,i,r,s,a){var y;if(t.type==="pubkey"){if(t.value.length<12)return null;const v=t.value.slice(0,12).toLowerCase();if(e.myPrefix&&v===e.myPrefix)return"self";const M=e.contactIndex.byPrefix12.get(v);return ri(n,{id:v,name:(M==null?void 0:M.name)||null,type:cr(M),isAmbiguous:!1,lastSeen:M==null?void 0:M.last_seen,activityAtMs:s}),v}if(t.type==="name"){const v=e.contactIndex.byName.get(t.value)??null;if(v){const b=v.public_key.slice(0,12).toLowerCase();return e.myPrefix&&b===e.myPrefix?"self":(ri(n,{id:b,name:v.name,type:cr(v),isAmbiguous:!1,lastSeen:v.last_seen,activityAtMs:s}),b)}const M=`name:${t.value}`;return ri(n,{id:M,name:t.value,type:"client",isAmbiguous:!1,activityAtMs:s}),M}const o=t.value.toLowerCase(),l=e.contactIndex.byPrefix.get(o)??[],c=l.length===1?l[0]:null;if(c){const v=c.public_key.slice(0,12).toLowerCase();return e.myPrefix&&v===e.myPrefix?"self":(ri(n,{id:v,name:c.name,type:cr(c),isAmbiguous:!1,lastSeen:c.last_seen,activityAtMs:s}),v)}if(!r)return null;const h=i?l.filter(v=>v.type===Xs):l.filter(v=>v.type!==Xs);if(h.length===1){const v=h[0],M=v.public_key.slice(0,12).toLowerCase();return ri(n,{id:M,name:v.name,type:cr(v),isAmbiguous:!1,lastSeen:v.last_seen,activityAtMs:s}),M}if(h.length===0&&!i)return null;const f=h.map(v=>v.name||v.public_key.slice(0,8)),d=h.reduce((v,M)=>M.last_seen&&(!v||M.last_seen>v)?M.last_seen:v,null);let m=yo(o),g=bo(o),x=null,p=null,u=f.length>0?f:void 0;if(e.useAdvertPathHints&&i&&a){const v=Xh(e,h,a.nextPrefix);if(v){const M=v.name||v.public_key.slice(0,12).toUpperCase();x=M,p=v.public_key.slice(0,12).toLowerCase(),g=M,u=h.filter(b=>b.public_key!==v.public_key).map(b=>b.name||b.public_key.slice(0,8))}}if(e.splitAmbiguousByTraffic&&i&&a){const v=((y=a.nextPrefix)==null?void 0:y.toLowerCase())??null;a.packetSource&&_u(n.trafficPatterns,o,a.packetSource,v);const M=n.trafficPatterns.get(o);M&&gu(M).shouldSplit&&v&&(m=yo(o,v),x||(g=bo(o,v)))}return ri(n,{id:m,name:g,type:i?"repeater":"client",isAmbiguous:!0,probableIdentity:x,probableIdentityNodeId:p,ambiguousNames:u,lastSeen:d,activityAtMs:s}),m}function qh(n,e,t,i,r){var c,h;const s=[];let a=null;const l=t.payloadType===ft.PayloadType.TextMessage&&!!e.myPrefix&&((c=t.srcHash)==null?void 0:c.toLowerCase())===e.myPrefix;if(t.payloadType===ft.PayloadType.Advert&&t.advertPubkey){const f=Fi(n,e,{type:"pubkey",value:t.advertPubkey},!1,!1,r);f&&(s.push(f),a=f)}else if(t.payloadType===ft.PayloadType.AnonRequest&&t.anonRequestPubkey){const f=Fi(n,e,{type:"pubkey",value:t.anonRequestPubkey},!1,!1,r);f&&(s.push(f),a=f)}else if(t.payloadType===ft.PayloadType.TextMessage&&t.srcHash)if(e.myPrefix&&t.srcHash.toLowerCase()===e.myPrefix)s.push("self"),a="self";else{const f=Fi(n,e,{type:"prefix",value:t.srcHash},!1,!0,r);f&&(s.push(f),a=f)}else if(t.payloadType===ft.PayloadType.GroupText){const f=t.groupTextSender||((h=i.decrypted_info)==null?void 0:h.sender);if(f){const d=Fi(n,e,{type:"name",value:f},!1,!1,r);d&&(s.push(d),a=d)}}for(let f=0;f<t.pathBytes.length;f++){const d=Fi(n,e,{type:"prefix",value:t.pathBytes[f]},!0,!0,r,{packetSource:a,nextPrefix:t.pathBytes[f+1]||null});d&&s.push(d)}return t.payloadType===ft.PayloadType.TextMessage&&t.dstHash?(e.myPrefix&&t.dstHash.toLowerCase()===e.myPrefix||!l&&s.length>0)&&s.push("self"):s.length>0&&s.push("self"),Wa(s)}function Yh(n,e,t){const i=fu(t.data);if(!i)return null;const r=yu(t.timestamp),s=qh(n,e,i,t,r);if(s.length<2)return null;const a=du(i.payloadType);for(let o=0;o<s.length;o++){const l=n.nodes.get(s[o]);l&&l.id!=="self"&&(l.lastActivityReason=o===0?`${a} source`:`Relayed ${a}`)}n.observations.push({nodes:s,activityAtMs:r});for(let o=0;o<s.length-1;o++)s[o]!==s[o+1]&&(Wh(n,s[o],s[o+1],r),oc(n,s[o],s[o+1]));return{parsed:i,label:a,canonicalPath:s,activityAtMs:r}}function jh(n,e){return n?n.id==="self"||!n.isAmbiguous?!0:n.type==="repeater"?e.showAmbiguousPaths:e.showAmbiguousNodes:!1}function lc(n,e){if(!e.collapseLikelyKnownSiblingRepeaters||!e.showAmbiguousPaths)return new Map;const t=new Map;for(const r of n.observations)for(let s=0;s<r.nodes.length-1;s++){const a=n.nodes.get(r.nodes[s]);if(!a||a.type!=="repeater"||a.isAmbiguous)continue;const o=r.nodes[s+1],l=t.get(a.id);l?l.add(o):t.set(a.id,new Set([o]))}const i=new Map;for(const r of n.observations)for(let s=0;s<r.nodes.length-1;s++){const a=r.nodes[s],o=n.nodes.get(a);if(!o||o.type!=="repeater"||!o.isAmbiguous||!o.probableIdentityNodeId)continue;const l=n.nodes.get(o.probableIdentityNodeId);if(!l||l.type!=="repeater"||l.isAmbiguous)continue;const c=r.nodes[s+1],h=t.get(l.id);h!=null&&h.has(c)&&i.set(a,l.id)}return i}function cc(n,e,t,i){const r=mu(e.map((s,a)=>{const o=n.nodes.get(s),l=jh(o,t);return{nodeId:l?i.get(s)??s:null,markHiddenLinkWhenOmitted:!l&&!!o&&o.type==="repeater"&&a>0&&a<e.length-1,hiddenLabel:null}}));return{nodes:Wa(r.nodes),dashedLinkDetails:r.dashedLinkDetails}}function Kh(n,e,t){return cc(n,e,t,lc(n,t))}function $h(n,e){const t=lc(n,e),i=new Map,r=n.nodes.get("self");r&&i.set("self",r);const s=new Map;for(const a of n.observations){const o=cc(n,a.nodes,e,t);if(!(o.nodes.length<2)){for(const l of o.nodes){const c=n.nodes.get(l);c&&i.set(l,c)}for(let l=0;l<o.nodes.length-1;l++){const c=o.nodes[l],h=o.nodes[l+1];if(c===h)continue;const f=ts(c,h),d=o.dashedLinkDetails.has(f),m=s.get(f);if(m){if(m.lastActivity=Math.max(m.lastActivity,a.activityAtMs),d){m.hasHiddenIntermediate=!0;for(const g of o.dashedLinkDetails.get(f)??[])m.hiddenHopLabels.includes(g)||m.hiddenHopLabels.push(g)}else m.hasDirectObservation=!0;continue}s.set(f,{sourceId:c,targetId:h,lastActivity:a.activityAtMs,hasDirectObservation:!d,hasHiddenIntermediate:d,hiddenHopLabels:[...o.dashedLinkDetails.get(f)??[]]})}}}return{nodes:i,links:s,renderedNodeIds:new Set(i.keys())}}function Zh(n,e){let t=!1;for(const[i,r]of n.nodes)i!=="self"&&r.lastActivity<e&&(n.nodes.delete(i),t=!0);if(!t)return!1;for(const[i,r]of n.links)(!n.nodes.has(r.sourceId)||!n.nodes.has(r.targetId))&&n.links.delete(i);n.observations=n.observations.filter(i=>i.nodes.every(r=>n.nodes.has(r))),n.neighborIds.clear();for(const i of n.links.values())oc(n,i.sourceId,i.targetId);return!0}function Jh(n){return new Map(Array.from(n.neighborIds.entries()).map(([e,t])=>[e,Array.from(t).sort()]))}function Qh(n){if(n.id==="self")return{...n,x:0,y:0,z:0,fx:0,fy:0,fz:0,vx:0,vy:0,vz:0};const e=Math.random()*Math.PI*2,t=Math.acos(2*Math.random()-1),i=80+Math.random()*100;return{...n,x:i*Math.sin(t)*Math.cos(e),y:i*Math.sin(t)*Math.sin(e),z:i*Math.cos(t)}}function ef({packets:n,contacts:e,config:t,repeaterAdvertPaths:i,showAmbiguousPaths:r,showAmbiguousNodes:s,useAdvertPathHints:a,collapseLikelyKnownSiblingRepeaters:o,splitAmbiguousByTraffic:l,chargeStrength:c,letEmDrift:h,particleSpeedMultiplier:f,observationWindowSec:d,pruneStaleNodes:m,pruneStaleMinutes:g}){const x=he.useRef(Hh((t==null?void 0:t.name)||"Me")),p=he.useRef(new Map),u=he.useRef(new Map),y=he.useRef([]),v=he.useRef(null),M=he.useRef(new Set),b=he.useRef(new Map),w=he.useRef(new Map),R=he.useRef(f),I=he.useRef(d*1e3),S=he.useRef(null),[T,P]=he.useState({processed:0,animated:0,nodes:0,links:0}),[,B]=he.useState(0),z=he.useMemo(()=>Vh({contacts:e,config:t,repeaterAdvertPaths:i,splitAmbiguousByTraffic:l,useAdvertPathHints:a}),[e,t,i,l,a]);he.useEffect(()=>{R.current=f},[f]),he.useEffect(()=>{I.current=d*1e3},[d]),he.useEffect(()=>{const V=Oh([]).numDimensions(3).force("link",us([]).id(W=>W.id).distance(120).strength(.3)).force("charge",hr().strength(W=>W.id==="self"?-1200:-200).distanceMax(800)).force("center",Tu(0,0,0)).force("selfX",Bh(0).strength(W=>W.id==="self"?.1:0)).force("selfY",zh(0).strength(W=>W.id==="self"?.1:0)).force("selfZ",kh(0).strength(W=>W.id==="self"?.1:0)).alphaDecay(.02).velocityDecay(.5).alphaTarget(.03);return v.current=V,()=>{V.stop()}},[]),he.useEffect(()=>{const V=v.current;V&&(V.force("charge",hr().strength(W=>W.id==="self"?c*6:c).distanceMax(800)),V.alpha(.3).restart())},[c]),he.useEffect(()=>{const V=v.current;V&&V.alphaTarget(h?.05:0)},[h]);const j=he.useCallback(()=>{const V=v.current;if(!V)return;const W=Array.from(p.current.values()),ce=Array.from(u.current.values());V.nodes(W);const se=V.force("link");se==null||se.links(ce),V.alpha(.15).restart(),P(we=>we.nodes===W.length&&we.links===ce.length?we:{...we,nodes:W.length,links:ce.length}),B(we=>we+1)},[]),K=he.useCallback((V,W)=>W?(W.name=V.name,W.type=V.type,W.isAmbiguous=V.isAmbiguous,W.lastActivity=V.lastActivity,W.lastActivityReason=V.lastActivityReason,W.lastSeen=V.lastSeen,W.probableIdentity=V.probableIdentity,W.ambiguousNames=V.ambiguousNames,V.id==="self"&&(W.x=0,W.y=0,W.z=0,W.fx=0,W.fy=0,W.fz=0,W.vx=0,W.vy=0,W.vz=0),W):Qh(V),[]),L=he.useCallback(()=>{const V=$h(x.current,{showAmbiguousNodes:s,showAmbiguousPaths:r,collapseLikelyKnownSiblingRepeaters:o}),W=p.current,ce=new Map;for(const[we,Se]of V.nodes)ce.set(we,K(Se,W.get(we)));const se=new Map;for(const[we,Se]of V.links)se.set(we,{source:Se.sourceId,target:Se.targetId,lastActivity:Se.lastActivity,hasDirectObservation:Se.hasDirectObservation,hasHiddenIntermediate:Se.hasHiddenIntermediate,hiddenHopLabels:[...Se.hiddenHopLabels]});p.current=ce,u.current=se,j()},[o,s,r,j,K]);he.useEffect(()=>{Gh(x.current,(t==null?void 0:t.name)||"Me");const V=x.current.nodes.get("self");V&&p.current.set("self",K(V,p.current.get("self"))),j()},[t==null?void 0:t.name,j,K]),he.useEffect(()=>{M.current.clear(),Io(x.current,{selfName:(t==null?void 0:t.name)||"Me"}),p.current.clear(),u.current.clear(),y.current=[],b.current.clear(),w.current.forEach(W=>clearTimeout(W)),w.current.clear();const V=x.current.nodes.get("self");V&&p.current.set("self",K(V)),P({processed:0,animated:0,nodes:V?1:0,links:0}),j()},[t==null?void 0:t.name,l,j,K,a]),he.useEffect(()=>{L()},[L]);const k=he.useCallback(V=>{const W=b.current.get(V);if(W&&(b.current.delete(V),w.current.delete(V),!document.hidden))for(const ce of W.paths){const se=Wa(ce.nodes);if(!(se.length<2))for(let we=0;we<se.length-1;we++)y.current.push({linkKey:ts(se[we],se[we+1]),progress:-we,speed:cu*R.current,color:lu[W.label],label:W.label,fromNodeId:se[we],toNodeId:se[we+1]})}},[]);he.useEffect(()=>{let V=0,W=0,ce=!1;for(const se of n){const we=eu(se);if(M.current.has(we))continue;M.current.add(we),V++,M.current.size>1e3&&(M.current=new Set(Array.from(M.current).slice(-500)));const Se=Yh(x.current,z,se);if(!Se)continue;ce=!0;const Y=Kh(x.current,Se.canonicalPath,{showAmbiguousNodes:s,showAmbiguousPaths:r,collapseLikelyKnownSiblingRepeaters:o});if(Y.nodes.length<2)continue;const Q=pu(Se.parsed,se),ge=Date.now(),Ce=b.current.get(Q);if(Ce&&ge<Ce.expiresAt)Ce.paths.push({nodes:Y.nodes,snr:se.snr??null,timestamp:ge});else{const le=w.current.get(Q);le&&clearTimeout(le);const De=I.current;b.current.set(Q,{key:Q,label:Se.label,paths:[{nodes:Y.nodes,snr:se.snr??null,timestamp:ge}],firstSeen:ge,expiresAt:ge+De}),w.current.set(Q,setTimeout(()=>k(Q),De))}if(b.current.size>100){const le=Array.from(b.current.entries()).sort((De,Ve)=>De[1].firstSeen-Ve[1].firstSeen).slice(0,50);for(const[De]of le){const Ve=w.current.get(De);Ve&&clearTimeout(Ve),w.current.delete(De),b.current.delete(De)}}W++}ce&&L(),V>0&&P(se=>({...se,processed:se.processed+V,animated:se.animated+W}))},[n,z,k,o,L,s,r]);const Z=he.useCallback(()=>{const V=v.current;if(!V)return;S.current!==null&&(cancelAnimationFrame(S.current),S.current=null);const W=c,ce=-5e3,se=.3,we=.02,Se=1e3,Y=2e3,Q=1e3,ge=performance.now(),Ce=le=>{const De=le-ge;let Ve,Ne;if(De<Se){const Fe=De/Se;Ve=W+(ce-W)*Fe,Ne=se+(we-se)*Fe}else if(De<Se+Y)Ve=ce,Ne=we;else if(De<Se+Y+Q){const Fe=(De-Se-Y)/Q;Ve=ce+(W-ce)*Fe,Ne=we+(se-we)*Fe}else{V.force("charge",hr().strength(Fe=>Fe.id==="self"?W*6:W).distanceMax(800)),V.force("link",us(Array.from(u.current.values())).id(Fe=>Fe.id).distance(120).strength(se)),V.alpha(.3).restart(),S.current=null;return}V.force("charge",hr().strength(Fe=>Fe.id==="self"?Ve*6:Ve).distanceMax(800)),V.force("link",us(Array.from(u.current.values())).id(Fe=>Fe.id).distance(120).strength(Ne)),V.alpha(.5).restart(),S.current=requestAnimationFrame(Ce)};S.current=requestAnimationFrame(Ce)},[c]),re=he.useCallback(()=>{S.current!==null&&(cancelAnimationFrame(S.current),S.current=null);for(const ce of w.current.values())clearTimeout(ce);w.current.clear(),b.current.clear(),M.current.clear(),y.current.length=0,Io(x.current,{selfName:(t==null?void 0:t.name)||"Me"}),u.current.clear(),p.current.clear();const V=x.current.nodes.get("self");V&&p.current.set("self",K(V));const W=v.current;if(W){W.nodes(Array.from(p.current.values()));const ce=W.force("link");ce==null||ce.links([]),W.alpha(.3).restart()}P({processed:0,animated:0,nodes:V?1:0,links:0})},[t==null?void 0:t.name,K]);return he.useEffect(()=>{const V=S,W=w.current,ce=b.current;return()=>{V.current!==null&&cancelAnimationFrame(V.current);for(const se of W.values())clearTimeout(se);W.clear(),ce.clear()}},[]),he.useEffect(()=>{if(!m)return;const V=g*60*1e3,ce=setInterval(()=>{const se=Date.now()-V;Zh(x.current,se)&&L()},1e3);return()=>clearInterval(ce)},[g,m,L]),{nodes:p.current,links:u.current,canonicalNodes:x.current.nodes,canonicalNeighborIds:Jh(x.current),renderedNodeIds:new Set(p.current.keys()),particles:y.current,stats:T,expandContract:Z,clearAndReset:re}}/**
|
|
* @license
|
|
* Copyright 2010-2025 Three.js Authors
|
|
* SPDX-License-Identifier: MIT
|
|
*/const ja="182",Si={ROTATE:0,DOLLY:1,PAN:2},Mi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},tf=0,Uo=1,nf=2,zr=1,rf=2,ji=3,kn=0,Vt=1,bn=2,An=0,yi=1,Fo=2,Oo=3,Bo=4,sf=5,Kn=100,af=101,of=102,lf=103,cf=104,uf=200,hf=201,ff=202,df=203,js=204,Ks=205,pf=206,mf=207,gf=208,_f=209,xf=210,vf=211,Mf=212,Sf=213,yf=214,$s=0,Zs=1,Js=2,Ai=3,Qs=4,ea=5,ta=6,na=7,uc=0,bf=1,Ef=2,hn=0,hc=1,fc=2,dc=3,pc=4,mc=5,gc=6,_c=7,xc=300,ei=301,wi=302,ia=303,ra=304,is=306,sa=1e3,En=1001,aa=1002,bt=1003,Tf=1004,fr=1005,Rt=1006,fs=1007,Zn=1008,Jt=1009,vc=1010,Mc=1011,Zi=1012,Ka=1013,dn=1014,cn=1015,Rn=1016,$a=1017,Za=1018,Ji=1020,Sc=35902,yc=35899,bc=1021,Ec=1022,rn=1023,Cn=1026,Jn=1027,Tc=1028,Ja=1029,Ri=1030,Qa=1031,eo=1033,kr=33776,Vr=33777,Hr=33778,Gr=33779,oa=35840,la=35841,ca=35842,ua=35843,ha=36196,fa=37492,da=37496,pa=37488,ma=37489,ga=37490,_a=37491,xa=37808,va=37809,Ma=37810,Sa=37811,ya=37812,ba=37813,Ea=37814,Ta=37815,Aa=37816,wa=37817,Ra=37818,Ca=37819,Pa=37820,Da=37821,La=36492,Na=36494,Ia=36495,Ua=36283,Fa=36284,Oa=36285,Ba=36286,Af=3200,wf=0,Rf=1,Bn="",$t="srgb",Ci="srgb-linear",Kr="linear",it="srgb",si=7680,zo=519,Cf=512,Pf=513,Df=514,to=515,Lf=516,Nf=517,no=518,If=519,ko=35044,Oi=35048,Vo="300 es",un=2e3,$r=2001;function Ac(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function Zr(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function Uf(){const n=Zr("canvas");return n.style.display="block",n}const Ho={};function Go(...n){const e="THREE."+n.shift();console.log(e,...n)}function Be(...n){const e="THREE."+n.shift();console.warn(e,...n)}function $e(...n){const e="THREE."+n.shift();console.error(e,...n)}function Qi(...n){const e=n.join(" ");e in Ho||(Ho[e]=!0,Be(...n))}function Ff(n,e,t){return new Promise(function(i,r){function s(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:r();break;case n.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:i()}}setTimeout(s,t)})}class ni{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const r=i[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 i=t[e.type];if(i!==void 0){e.target=this;const r=i.slice(0);for(let s=0,a=r.length;s<a;s++)r[s].call(this,e);e.target=null}}}const At=["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"],Wr=Math.PI/180,za=180/Math.PI;function tr(){const n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(At[n&255]+At[n>>8&255]+At[n>>16&255]+At[n>>24&255]+"-"+At[e&255]+At[e>>8&255]+"-"+At[e>>16&15|64]+At[e>>24&255]+"-"+At[t&63|128]+At[t>>8&255]+"-"+At[t>>16&255]+At[t>>24&255]+At[i&255]+At[i>>8&255]+At[i>>16&255]+At[i>>24&255]).toLowerCase()}function Ye(n,e,t){return Math.max(e,Math.min(t,n))}function Of(n,e){return(n%e+e)%e}function ds(n,e,t){return(1-t)*n+t*e}function Bi(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function zt(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}const Bf={DEG2RAD:Wr};class Ge{constructor(e=0,t=0){Ge.prototype.isVector2=!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("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("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,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+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 i=this.length();return this.divideScalar(i||1).multiplyScalar(Ye(i,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 i=this.dot(e)/t;return Math.acos(Ye(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,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 i=Math.cos(t),r=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*i-a*r+e.x,this.y=s*r+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ti{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,s,a,o){let l=i[r+0],c=i[r+1],h=i[r+2],f=i[r+3],d=s[a+0],m=s[a+1],g=s[a+2],x=s[a+3];if(o<=0){e[t+0]=l,e[t+1]=c,e[t+2]=h,e[t+3]=f;return}if(o>=1){e[t+0]=d,e[t+1]=m,e[t+2]=g,e[t+3]=x;return}if(f!==x||l!==d||c!==m||h!==g){let p=l*d+c*m+h*g+f*x;p<0&&(d=-d,m=-m,g=-g,x=-x,p=-p);let u=1-o;if(p<.9995){const y=Math.acos(p),v=Math.sin(y);u=Math.sin(u*y)/v,o=Math.sin(o*y)/v,l=l*u+d*o,c=c*u+m*o,h=h*u+g*o,f=f*u+x*o}else{l=l*u+d*o,c=c*u+m*o,h=h*u+g*o,f=f*u+x*o;const y=1/Math.sqrt(l*l+c*c+h*h+f*f);l*=y,c*=y,h*=y,f*=y}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=f}static multiplyQuaternionsFlat(e,t,i,r,s,a){const o=i[r],l=i[r+1],c=i[r+2],h=i[r+3],f=s[a],d=s[a+1],m=s[a+2],g=s[a+3];return e[t]=o*g+h*f+l*m-c*d,e[t+1]=l*g+h*d+c*f-o*m,e[t+2]=c*g+h*m+o*d-l*f,e[t+3]=h*g-o*f-l*d-c*m,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,i,r){return this._x=e,this._y=t,this._z=i,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 i=e._x,r=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),h=o(r/2),f=o(s/2),d=l(i/2),m=l(r/2),g=l(s/2);switch(a){case"XYZ":this._x=d*h*f+c*m*g,this._y=c*m*f-d*h*g,this._z=c*h*g+d*m*f,this._w=c*h*f-d*m*g;break;case"YXZ":this._x=d*h*f+c*m*g,this._y=c*m*f-d*h*g,this._z=c*h*g-d*m*f,this._w=c*h*f+d*m*g;break;case"ZXY":this._x=d*h*f-c*m*g,this._y=c*m*f+d*h*g,this._z=c*h*g+d*m*f,this._w=c*h*f-d*m*g;break;case"ZYX":this._x=d*h*f-c*m*g,this._y=c*m*f+d*h*g,this._z=c*h*g-d*m*f,this._w=c*h*f+d*m*g;break;case"YZX":this._x=d*h*f+c*m*g,this._y=c*m*f+d*h*g,this._z=c*h*g-d*m*f,this._w=c*h*f-d*m*g;break;case"XZY":this._x=d*h*f-c*m*g,this._y=c*m*f-d*h*g,this._z=c*h*g+d*m*f,this._w=c*h*f+d*m*g;break;default:Be("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=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],d=i+o+f;if(d>0){const m=.5/Math.sqrt(d+1);this._w=.25/m,this._x=(h-l)*m,this._y=(s-c)*m,this._z=(a-r)*m}else if(i>o&&i>f){const m=2*Math.sqrt(1+i-o-f);this._w=(h-l)/m,this._x=.25*m,this._y=(r+a)/m,this._z=(s+c)/m}else if(o>f){const m=2*Math.sqrt(1+o-i-f);this._w=(s-c)/m,this._x=(r+a)/m,this._y=.25*m,this._z=(l+h)/m}else{const m=2*Math.sqrt(1+f-i-o);this._w=(a-r)/m,this._x=(s+c)/m,this._y=(l+h)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(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=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ye(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const r=Math.min(1,t/i);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 i=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=i*h+a*o+r*c-s*l,this._y=r*h+a*l+s*o-i*c,this._z=s*h+a*c+i*l-r*o,this._w=a*h-i*o-r*l-s*c,this._onChangeCallback(),this}slerp(e,t){if(t<=0)return this;if(t>=1)return this.copy(e);let i=e._x,r=e._y,s=e._z,a=e._w,o=this.dot(e);o<0&&(i=-i,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+i*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+i*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,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),s=Math.sqrt(i);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{constructor(e=0,t=0,i=0){F.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,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("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("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(Wo.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Wo.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6]*r,this.y=s[1]*t+s[4]*i+s[7]*r,this.z=s[2]*t+s[5]*i+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,s=e.elements,a=1/(s[3]*t+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*i+s[8]*r+s[12])*a,this.y=(s[1]*t+s[5]*i+s[9]*r+s[13])*a,this.z=(s[2]*t+s[6]*i+s[10]*r+s[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,r=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*r-o*i),h=2*(o*t-s*r),f=2*(s*i-a*t);return this.x=t+l*c+a*f-o*h,this.y=i+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,i=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r,this.y=s[1]*t+s[5]*i+s[9]*r,this.z=s[2]*t+s[6]*i+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 i=this.length();return this.divideScalar(i||1).multiplyScalar(Ye(i,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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=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-i*l,this.z=i*o-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return ps.copy(this).projectOnVector(e),this.sub(ps)}reflect(e){return this.sub(ps.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 i=this.dot(e)/t;return Math.acos(Ye(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+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,i){const r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,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(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,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,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const ps=new F,Wo=new ti;class We{constructor(e,t,i,r,s,a,o,l,c){We.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,s,a,o,l,c)}set(e,t,i,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]=i,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,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.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 i=e.elements,r=t.elements,s=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],h=i[4],f=i[7],d=i[2],m=i[5],g=i[8],x=r[0],p=r[3],u=r[6],y=r[1],v=r[4],M=r[7],b=r[2],w=r[5],R=r[8];return s[0]=a*x+o*y+l*b,s[3]=a*p+o*v+l*w,s[6]=a*u+o*M+l*R,s[1]=c*x+h*y+f*b,s[4]=c*p+h*v+f*w,s[7]=c*u+h*M+f*R,s[2]=d*x+m*y+g*b,s[5]=d*p+m*v+g*w,s[8]=d*u+m*M+g*R,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=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-i*s*h+i*o*l+r*s*c-r*a*l}invert(){const e=this.elements,t=e[0],i=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,d=o*l-h*s,m=c*s-a*l,g=t*f+i*d+r*m;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/g;return e[0]=f*x,e[1]=(r*c-h*i)*x,e[2]=(o*i-r*a)*x,e[3]=d*x,e[4]=(h*t-r*l)*x,e[5]=(r*s-o*t)*x,e[6]=m*x,e[7]=(i*l-c*t)*x,e[8]=(a*t-i*s)*x,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(i*l,i*c,-i*(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 this.premultiply(ms.makeScale(e,t)),this}rotate(e){return this.premultiply(ms.makeRotation(-e)),this}translate(e,t){return this.premultiply(ms.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),i=Math.sin(e);return this.set(t,-i,0,i,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,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const ms=new We,Xo=new We().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),qo=new We().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function zf(){const n={enabled:!0,workingColorSpace:Ci,spaces:{},convert:function(r,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===it&&(r.r=wn(r.r),r.g=wn(r.g),r.b=wn(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===it&&(r.r=bi(r.r),r.g=bi(r.g),r.b=bi(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===Bn?Kr: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 Qi("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(r,s)},toWorkingColorSpace:function(r,s){return Qi("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(r,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[Ci]:{primaries:e,whitePoint:i,transfer:Kr,toXYZ:Xo,fromXYZ:qo,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:$t},outputColorSpaceConfig:{drawingBufferColorSpace:$t}},[$t]:{primaries:e,whitePoint:i,transfer:it,toXYZ:Xo,fromXYZ:qo,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:$t}}}),n}const Ze=zf();function wn(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function bi(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let ai;class kf{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{ai===void 0&&(ai=Zr("canvas")),ai.width=e.width,ai.height=e.height;const r=ai.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),i=ai}return i.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=Zr("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const r=i.getImageData(0,0,e.width,e.height),s=r.data;for(let a=0;a<s.length;a++)s[a]=wn(s[a]/255)*255;return i.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(wn(t[i]/255)*255):t[i]=wn(t[i]);return{data:t,width:e.width,height:e.height}}else return Be("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let Vf=0;class io{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Vf++}),this.uuid=tr(),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.displayHeight,t.displayWidth,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 i={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);i.url=s}return t||(e.images[this.uuid]=i),i}}function gs(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?kf.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(Be("Texture: Unable to serialize Texture."),{})}let Hf=0;const _s=new F;class Pt extends ni{constructor(e=Pt.DEFAULT_IMAGE,t=Pt.DEFAULT_MAPPING,i=En,r=En,s=Rt,a=Zn,o=rn,l=Jt,c=Pt.DEFAULT_ANISOTROPY,h=Bn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Hf++}),this.uuid=tr(),this.name="",this.source=new io(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=s,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Ge(0,0),this.repeat=new Ge(1,1),this.center=new Ge(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new We,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}get width(){return this.source.getSize(_s).x}get height(){return this.source.getSize(_s).y}get depth(){return this.source.getSize(_s).z}get image(){return this.source.data}set image(e=null){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.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 i=e[t];if(i===void 0){Be(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){Be(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&i&&r.isVector2&&i.isVector2||r&&i&&r.isVector3&&i.isVector3||r&&i&&r.isMatrix3&&i.isMatrix3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={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,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&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==xc)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case sa:e.x=e.x-Math.floor(e.x);break;case En:e.x=e.x<0?0:1;break;case aa: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 sa:e.y=e.y-Math.floor(e.y);break;case En:e.y=e.y<0?0:1;break;case aa: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++}}Pt.DEFAULT_IMAGE=null;Pt.DEFAULT_MAPPING=xc;Pt.DEFAULT_ANISOTROPY=1;class mt{constructor(e=0,t=0,i=0,r=1){mt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,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,i,r){return this.x=e,this.y=t,this.z=i,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("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("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,i=this.y,r=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r+a[12]*s,this.y=a[1]*t+a[5]*i+a[9]*r+a[13]*s,this.z=a[2]*t+a[6]*i+a[10]*r+a[14]*s,this.w=a[3]*t+a[7]*i+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,i,r,s;const l=e.elements,c=l[0],h=l[4],f=l[8],d=l[1],m=l[5],g=l[9],x=l[2],p=l[6],u=l[10];if(Math.abs(h-d)<.01&&Math.abs(f-x)<.01&&Math.abs(g-p)<.01){if(Math.abs(h+d)<.1&&Math.abs(f+x)<.1&&Math.abs(g+p)<.1&&Math.abs(c+m+u-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const v=(c+1)/2,M=(m+1)/2,b=(u+1)/2,w=(h+d)/4,R=(f+x)/4,I=(g+p)/4;return v>M&&v>b?v<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(v),r=w/i,s=R/i):M>b?M<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(M),i=w/r,s=I/r):b<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(b),i=R/s,r=I/s),this.set(i,r,s,t),this}let y=Math.sqrt((p-g)*(p-g)+(f-x)*(f-x)+(d-h)*(d-h));return Math.abs(y)<.001&&(y=1),this.x=(p-g)/y,this.y=(f-x)/y,this.z=(d-h)/y,this.w=Math.acos((c+m+u-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 i=this.length();return this.divideScalar(i||1).multiplyScalar(Ye(i,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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,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 Gf extends ni{constructor(e=1,t=1,i={}){super(),i=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},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new mt(0,0,e,t),this.scissorTest=!1,this.viewport=new mt(0,0,e,t);const r={width:e,height:t,depth:i.depth},s=new Pt(r);this.textures=[];const a=i.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(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview}_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 i=0;i<this.textures.length;i++)this.textures[i].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,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;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=i,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,i=e.textures.length;t<i;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 io(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}dispose(){this.dispatchEvent({type:"dispose"})}}class fn extends Gf{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class wc extends Pt{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=bt,this.minFilter=bt,this.wrapR=En,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Wf extends Pt{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=bt,this.minFilter=bt,this.wrapR=En,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class nr{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,i=e.length;t<i;t+=3)this.expandByPoint(Qt.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(Qt.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=Qt.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),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 i=e.geometry;if(i!==void 0){const s=i.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,Qt):Qt.fromBufferAttribute(s,a),Qt.applyMatrix4(e.matrixWorld),this.expandByPoint(Qt);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),dr.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),dr.copy(i.boundingBox)),dr.applyMatrix4(e.matrixWorld),this.union(dr)}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,Qt),Qt.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(zi),pr.subVectors(this.max,zi),oi.subVectors(e.a,zi),li.subVectors(e.b,zi),ci.subVectors(e.c,zi),Dn.subVectors(li,oi),Ln.subVectors(ci,li),Gn.subVectors(oi,ci);let t=[0,-Dn.z,Dn.y,0,-Ln.z,Ln.y,0,-Gn.z,Gn.y,Dn.z,0,-Dn.x,Ln.z,0,-Ln.x,Gn.z,0,-Gn.x,-Dn.y,Dn.x,0,-Ln.y,Ln.x,0,-Gn.y,Gn.x,0];return!xs(t,oi,li,ci,pr)||(t=[1,0,0,0,1,0,0,0,1],!xs(t,oi,li,ci,pr))?!1:(mr.crossVectors(Dn,Ln),t=[mr.x,mr.y,mr.z],xs(t,oi,li,ci,pr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Qt).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Qt).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:(_n[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),_n[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),_n[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),_n[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),_n[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),_n[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),_n[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),_n[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(_n),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 _n=[new F,new F,new F,new F,new F,new F,new F,new F],Qt=new F,dr=new nr,oi=new F,li=new F,ci=new F,Dn=new F,Ln=new F,Gn=new F,zi=new F,pr=new F,mr=new F,Wn=new F;function xs(n,e,t,i,r){for(let s=0,a=n.length-3;s<=a;s+=3){Wn.fromArray(n,s);const o=r.x*Math.abs(Wn.x)+r.y*Math.abs(Wn.y)+r.z*Math.abs(Wn.z),l=e.dot(Wn),c=t.dot(Wn),h=i.dot(Wn);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const Xf=new nr,ki=new F,vs=new F;class ir{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 i=this.center;t!==void 0?i.copy(t):Xf.setFromPoints(e).getCenter(i);let r=0;for(let s=0,a=e.length;s<a;s++)r=Math.max(r,i.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 i=this.center.distanceToSquared(e);return t.copy(e),i>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;ki.subVectors(e,this.center);const t=ki.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(ki,r/i),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):(vs.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ki.copy(e.center).add(vs)),this.expandByPoint(ki.copy(e.center).sub(vs))),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}}const xn=new F,Ms=new F,gr=new F,Nn=new F,Ss=new F,_r=new F,ys=new F;class rr{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,xn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=xn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(xn.copy(this.origin).addScaledVector(this.direction,t),xn.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){Ms.copy(e).add(t).multiplyScalar(.5),gr.copy(t).sub(e).normalize(),Nn.copy(this.origin).sub(Ms);const s=e.distanceTo(t)*.5,a=-this.direction.dot(gr),o=Nn.dot(this.direction),l=-Nn.dot(gr),c=Nn.lengthSq(),h=Math.abs(1-a*a);let f,d,m,g;if(h>0)if(f=a*l-o,d=a*o-l,g=s*h,f>=0)if(d>=-g)if(d<=g){const x=1/h;f*=x,d*=x,m=f*(f+a*d+2*o)+d*(a*f+d+2*l)+c}else d=s,f=Math.max(0,-(a*d+o)),m=-f*f+d*(d+2*l)+c;else d=-s,f=Math.max(0,-(a*d+o)),m=-f*f+d*(d+2*l)+c;else d<=-g?(f=Math.max(0,-(-a*s+o)),d=f>0?-s:Math.min(Math.max(-s,-l),s),m=-f*f+d*(d+2*l)+c):d<=g?(f=0,d=Math.min(Math.max(-s,-l),s),m=d*(d+2*l)+c):(f=Math.max(0,-(a*s+o)),d=f>0?s:Math.min(Math.max(-s,-l),s),m=-f*f+d*(d+2*l)+c);else d=a>0?-s:s,f=Math.max(0,-(a*d+o)),m=-f*f+d*(d+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,f),r&&r.copy(Ms).addScaledVector(gr,d),m}intersectSphere(e,t){xn.subVectors(e.center,this.origin);const i=xn.dot(this.direction),r=xn.dot(xn)-i*i,s=e.radius*e.radius;if(r>s)return null;const a=Math.sqrt(s-r),o=i-a,l=i+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 i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,s,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,f=1/this.direction.z,d=this.origin;return c>=0?(i=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(i=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),h>=0?(s=(e.min.y-d.y)*h,a=(e.max.y-d.y)*h):(s=(e.max.y-d.y)*h,a=(e.min.y-d.y)*h),i>a||s>r||((s>i||isNaN(i))&&(i=s),(a<r||isNaN(r))&&(r=a),f>=0?(o=(e.min.z-d.z)*f,l=(e.max.z-d.z)*f):(o=(e.max.z-d.z)*f,l=(e.min.z-d.z)*f),i>l||o>r)||((o>i||i!==i)&&(i=o),(l<r||r!==r)&&(r=l),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,xn)!==null}intersectTriangle(e,t,i,r,s){Ss.subVectors(t,e),_r.subVectors(i,e),ys.crossVectors(Ss,_r);let a=this.direction.dot(ys),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Nn.subVectors(this.origin,e);const l=o*this.direction.dot(_r.crossVectors(Nn,_r));if(l<0)return null;const c=o*this.direction.dot(Ss.cross(Nn));if(c<0||l+c>a)return null;const h=-o*Nn.dot(ys);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 ht{constructor(e,t,i,r,s,a,o,l,c,h,f,d,m,g,x,p){ht.prototype.isMatrix4=!0,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,i,r,s,a,o,l,c,h,f,d,m,g,x,p)}set(e,t,i,r,s,a,o,l,c,h,f,d,m,g,x,p){const u=this.elements;return u[0]=e,u[4]=t,u[8]=i,u[12]=r,u[1]=s,u[5]=a,u[9]=o,u[13]=l,u[2]=c,u[6]=h,u[10]=f,u[14]=d,u[3]=m,u[7]=g,u[11]=x,u[15]=p,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new ht().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[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,i){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),i.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();const t=this.elements,i=e.elements,r=1/ui.setFromMatrixColumn(e,0).length(),s=1/ui.setFromMatrixColumn(e,1).length(),a=1/ui.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*s,t[5]=i[5]*s,t[6]=i[6]*s,t[7]=0,t[8]=i[8]*a,t[9]=i[9]*a,t[10]=i[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,r=e.y,s=e.z,a=Math.cos(i),o=Math.sin(i),l=Math.cos(r),c=Math.sin(r),h=Math.cos(s),f=Math.sin(s);if(e.order==="XYZ"){const d=a*h,m=a*f,g=o*h,x=o*f;t[0]=l*h,t[4]=-l*f,t[8]=c,t[1]=m+g*c,t[5]=d-x*c,t[9]=-o*l,t[2]=x-d*c,t[6]=g+m*c,t[10]=a*l}else if(e.order==="YXZ"){const d=l*h,m=l*f,g=c*h,x=c*f;t[0]=d+x*o,t[4]=g*o-m,t[8]=a*c,t[1]=a*f,t[5]=a*h,t[9]=-o,t[2]=m*o-g,t[6]=x+d*o,t[10]=a*l}else if(e.order==="ZXY"){const d=l*h,m=l*f,g=c*h,x=c*f;t[0]=d-x*o,t[4]=-a*f,t[8]=g+m*o,t[1]=m+g*o,t[5]=a*h,t[9]=x-d*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const d=a*h,m=a*f,g=o*h,x=o*f;t[0]=l*h,t[4]=g*c-m,t[8]=d*c+x,t[1]=l*f,t[5]=x*c+d,t[9]=m*c-g,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const d=a*l,m=a*c,g=o*l,x=o*c;t[0]=l*h,t[4]=x-d*f,t[8]=g*f+m,t[1]=f,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=m*f+g,t[10]=d-x*f}else if(e.order==="XZY"){const d=a*l,m=a*c,g=o*l,x=o*c;t[0]=l*h,t[4]=-f,t[8]=c*h,t[1]=d*f+x,t[5]=a*h,t[9]=m*f-g,t[2]=g*f-m,t[6]=o*h,t[10]=x*f+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(qf,e,Yf)}lookAt(e,t,i){const r=this.elements;return qt.subVectors(e,t),qt.lengthSq()===0&&(qt.z=1),qt.normalize(),In.crossVectors(i,qt),In.lengthSq()===0&&(Math.abs(i.z)===1?qt.x+=1e-4:qt.z+=1e-4,qt.normalize(),In.crossVectors(i,qt)),In.normalize(),xr.crossVectors(qt,In),r[0]=In.x,r[4]=xr.x,r[8]=qt.x,r[1]=In.y,r[5]=xr.y,r[9]=qt.y,r[2]=In.z,r[6]=xr.z,r[10]=qt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,s=this.elements,a=i[0],o=i[4],l=i[8],c=i[12],h=i[1],f=i[5],d=i[9],m=i[13],g=i[2],x=i[6],p=i[10],u=i[14],y=i[3],v=i[7],M=i[11],b=i[15],w=r[0],R=r[4],I=r[8],S=r[12],T=r[1],P=r[5],B=r[9],z=r[13],j=r[2],K=r[6],L=r[10],k=r[14],Z=r[3],re=r[7],V=r[11],W=r[15];return s[0]=a*w+o*T+l*j+c*Z,s[4]=a*R+o*P+l*K+c*re,s[8]=a*I+o*B+l*L+c*V,s[12]=a*S+o*z+l*k+c*W,s[1]=h*w+f*T+d*j+m*Z,s[5]=h*R+f*P+d*K+m*re,s[9]=h*I+f*B+d*L+m*V,s[13]=h*S+f*z+d*k+m*W,s[2]=g*w+x*T+p*j+u*Z,s[6]=g*R+x*P+p*K+u*re,s[10]=g*I+x*B+p*L+u*V,s[14]=g*S+x*z+p*k+u*W,s[3]=y*w+v*T+M*j+b*Z,s[7]=y*R+v*P+M*K+b*re,s[11]=y*I+v*B+M*L+b*V,s[15]=y*S+v*z+M*k+b*W,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],i=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],d=e[10],m=e[14],g=e[3],x=e[7],p=e[11],u=e[15],y=l*m-c*d,v=o*m-c*f,M=o*d-l*f,b=a*m-c*h,w=a*d-l*h,R=a*f-o*h;return t*(x*y-p*v+u*M)-i*(g*y-p*b+u*w)+r*(g*v-x*b+u*R)-s*(g*M-x*w+p*R)}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,i){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]=i),this}invert(){const e=this.elements,t=e[0],i=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],d=e[10],m=e[11],g=e[12],x=e[13],p=e[14],u=e[15],y=f*p*c-x*d*c+x*l*m-o*p*m-f*l*u+o*d*u,v=g*d*c-h*p*c-g*l*m+a*p*m+h*l*u-a*d*u,M=h*x*c-g*f*c+g*o*m-a*x*m-h*o*u+a*f*u,b=g*f*l-h*x*l-g*o*d+a*x*d+h*o*p-a*f*p,w=t*y+i*v+r*M+s*b;if(w===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const R=1/w;return e[0]=y*R,e[1]=(x*d*s-f*p*s-x*r*m+i*p*m+f*r*u-i*d*u)*R,e[2]=(o*p*s-x*l*s+x*r*c-i*p*c-o*r*u+i*l*u)*R,e[3]=(f*l*s-o*d*s-f*r*c+i*d*c+o*r*m-i*l*m)*R,e[4]=v*R,e[5]=(h*p*s-g*d*s+g*r*m-t*p*m-h*r*u+t*d*u)*R,e[6]=(g*l*s-a*p*s-g*r*c+t*p*c+a*r*u-t*l*u)*R,e[7]=(a*d*s-h*l*s+h*r*c-t*d*c-a*r*m+t*l*m)*R,e[8]=M*R,e[9]=(g*f*s-h*x*s-g*i*m+t*x*m+h*i*u-t*f*u)*R,e[10]=(a*x*s-g*o*s+g*i*c-t*x*c-a*i*u+t*o*u)*R,e[11]=(h*o*s-a*f*s-h*i*c+t*f*c+a*i*m-t*o*m)*R,e[12]=b*R,e[13]=(h*x*r-g*f*r+g*i*d-t*x*d-h*i*p+t*f*p)*R,e[14]=(g*o*r-a*x*r-g*i*l+t*x*l+a*i*p-t*o*p)*R,e[15]=(a*f*r-h*o*r+h*i*l-t*f*l-a*i*d+t*o*d)*R,this}scale(e){const t=this.elements,i=e.x,r=e.y,s=e.z;return t[0]*=i,t[4]*=r,t[8]*=s,t[1]*=i,t[5]*=r,t[9]*=s,t[2]*=i,t[6]*=r,t[10]*=s,t[3]*=i,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],i=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,i,r))}makeTranslation(e,t,i){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,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),r=Math.sin(t),s=1-i,a=e.x,o=e.y,l=e.z,c=s*a,h=s*o;return this.set(c*a+i,c*o-r*l,c*l+r*o,0,c*o+r*l,h*o+i,h*l-r*a,0,c*l-r*o,h*l+r*a,s*l*l+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,s,a){return this.set(1,i,s,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){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,d=s*c,m=s*h,g=s*f,x=a*h,p=a*f,u=o*f,y=l*c,v=l*h,M=l*f,b=i.x,w=i.y,R=i.z;return r[0]=(1-(x+u))*b,r[1]=(m+M)*b,r[2]=(g-v)*b,r[3]=0,r[4]=(m-M)*w,r[5]=(1-(d+u))*w,r[6]=(p+y)*w,r[7]=0,r[8]=(g+v)*R,r[9]=(p-y)*R,r[10]=(1-(d+x))*R,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){const r=this.elements;if(e.x=r[12],e.y=r[13],e.z=r[14],this.determinant()===0)return i.set(1,1,1),t.identity(),this;let s=ui.set(r[0],r[1],r[2]).length();const a=ui.set(r[4],r[5],r[6]).length(),o=ui.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),en.copy(this);const c=1/s,h=1/a,f=1/o;return en.elements[0]*=c,en.elements[1]*=c,en.elements[2]*=c,en.elements[4]*=h,en.elements[5]*=h,en.elements[6]*=h,en.elements[8]*=f,en.elements[9]*=f,en.elements[10]*=f,t.setFromRotationMatrix(en),i.x=s,i.y=a,i.z=o,this}makePerspective(e,t,i,r,s,a,o=un,l=!1){const c=this.elements,h=2*s/(t-e),f=2*s/(i-r),d=(t+e)/(t-e),m=(i+r)/(i-r);let g,x;if(l)g=s/(a-s),x=a*s/(a-s);else if(o===un)g=-(a+s)/(a-s),x=-2*a*s/(a-s);else if(o===$r)g=-a/(a-s),x=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=f,c[9]=m,c[13]=0,c[2]=0,c[6]=0,c[10]=g,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,i,r,s,a,o=un,l=!1){const c=this.elements,h=2/(t-e),f=2/(i-r),d=-(t+e)/(t-e),m=-(i+r)/(i-r);let g,x;if(l)g=1/(a-s),x=a/(a-s);else if(o===un)g=-2/(a-s),x=-(a+s)/(a-s);else if(o===$r)g=-1/(a-s),x=-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]=d,c[1]=0,c[5]=f,c[9]=0,c[13]=m,c[2]=0,c[6]=0,c[10]=g,c[14]=x,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const ui=new F,en=new ht,qf=new F(0,0,0),Yf=new F(1,1,1),In=new F,xr=new F,qt=new F,Yo=new ht,jo=new ti;class Pn{constructor(e=0,t=0,i=0,r=Pn.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,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,i,r=this._order){return this._x=e,this._y=t,this._z=i,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,i=!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],d=r[6],m=r[10];switch(t){case"XYZ":this._y=Math.asin(Ye(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,m),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Ye(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(Ye(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-f,m),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(d,m),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,m));break;case"XZY":this._z=Math.asin(-Ye(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,m),this._y=0);break;default:Be("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return Yo.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Yo,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return jo.setFromEuler(this),this.setFromQuaternion(jo,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}}Pn.DEFAULT_ORDER="XYZ";class ro{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 jf=0;const Ko=new F,hi=new ti,vn=new ht,vr=new F,Vi=new F,Kf=new F,$f=new ti,$o=new F(1,0,0),Zo=new F(0,1,0),Jo=new F(0,0,1),Qo={type:"added"},Zf={type:"removed"},fi={type:"childadded",child:null},bs={type:"childremoved",child:null};class Dt extends ni{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:jf++}),this.uuid=tr(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Dt.DEFAULT_UP.clone();const e=new F,t=new Pn,i=new ti,r=new F(1,1,1);function s(){i.setFromEuler(t,!1)}function a(){t.setFromQuaternion(i,void 0,!1)}t._onChange(s),i._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:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new ht},normalMatrix:{value:new We}}),this.matrix=new ht,this.matrixWorld=new ht,this.matrixAutoUpdate=Dt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Dt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new ro,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.userData={}}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 hi.setFromAxisAngle(e,t),this.quaternion.multiply(hi),this}rotateOnWorldAxis(e,t){return hi.setFromAxisAngle(e,t),this.quaternion.premultiply(hi),this}rotateX(e){return this.rotateOnAxis($o,e)}rotateY(e){return this.rotateOnAxis(Zo,e)}rotateZ(e){return this.rotateOnAxis(Jo,e)}translateOnAxis(e,t){return Ko.copy(e).applyQuaternion(this.quaternion),this.position.add(Ko.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis($o,e)}translateY(e){return this.translateOnAxis(Zo,e)}translateZ(e){return this.translateOnAxis(Jo,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(vn.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?vr.copy(e):vr.set(e,t,i);const r=this.parent;this.updateWorldMatrix(!0,!1),Vi.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?vn.lookAt(Vi,vr,this.up):vn.lookAt(vr,Vi,this.up),this.quaternion.setFromRotationMatrix(vn),r&&(vn.extractRotation(r.matrixWorld),hi.setFromRotationMatrix(vn),this.quaternion.premultiply(hi.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?($e("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(Qo),fi.child=e,this.dispatchEvent(fi),fi.child=null):$e("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Zf),bs.child=e,this.dispatchEvent(bs),bs.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),vn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),vn.multiply(e.parent.matrixWorld)),e.applyMatrix4(vn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Qo),fi.child=e,this.dispatchEvent(fi),fi.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 i=0,r=this.children.length;i<r;i++){const a=this.children[i].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Vi,e,Kf),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Vi,$f,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 i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].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),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 i=0,r=t.length;i<r;i++)t[i].updateMatrixWorld(e)}updateWorldMatrix(e,t){const i=this.parent;if(e===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const r=this.children;for(let s=0,a=r.length;s<a;s++)r[s].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.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),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.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),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),d=a(e.skeletons),m=a(e.animations),g=a(e.nodes);o.length>0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),h.length>0&&(i.images=h),f.length>0&&(i.shapes=f),d.length>0&&(i.skeletons=d),m.length>0&&(i.animations=m),g.length>0&&(i.nodes=g)}return i.object=r,i;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.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.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;i<e.children.length;i++){const r=e.children[i];this.add(r.clone())}return this}}Dt.DEFAULT_UP=new F(0,1,0);Dt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Dt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const tn=new F,Mn=new F,Es=new F,Sn=new F,di=new F,pi=new F,el=new F,Ts=new F,As=new F,ws=new F,Rs=new mt,Cs=new mt,Ps=new mt;class nn{constructor(e=new F,t=new F,i=new F){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),tn.subVectors(e,t),r.cross(tn);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,i,r,s){tn.subVectors(r,t),Mn.subVectors(i,t),Es.subVectors(e,t);const a=tn.dot(tn),o=tn.dot(Mn),l=tn.dot(Es),c=Mn.dot(Mn),h=Mn.dot(Es),f=a*c-o*o;if(f===0)return s.set(0,0,0),null;const d=1/f,m=(c*l-o*h)*d,g=(a*h-o*l)*d;return s.set(1-m-g,g,m)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,Sn)===null?!1:Sn.x>=0&&Sn.y>=0&&Sn.x+Sn.y<=1}static getInterpolation(e,t,i,r,s,a,o,l){return this.getBarycoord(e,t,i,r,Sn)===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,Sn.x),l.addScaledVector(a,Sn.y),l.addScaledVector(o,Sn.z),l)}static getInterpolatedAttribute(e,t,i,r,s,a){return Rs.setScalar(0),Cs.setScalar(0),Ps.setScalar(0),Rs.fromBufferAttribute(e,t),Cs.fromBufferAttribute(e,i),Ps.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(Rs,s.x),a.addScaledVector(Cs,s.y),a.addScaledVector(Ps,s.z),a}static isFrontFacing(e,t,i,r){return tn.subVectors(i,t),Mn.subVectors(e,t),tn.cross(Mn).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),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 tn.subVectors(this.c,this.b),Mn.subVectors(this.a,this.b),tn.cross(Mn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return nn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return nn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,r,s){return nn.getInterpolation(e,this.a,this.b,this.c,t,i,r,s)}containsPoint(e){return nn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return nn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,r=this.b,s=this.c;let a,o;di.subVectors(r,i),pi.subVectors(s,i),Ts.subVectors(e,i);const l=di.dot(Ts),c=pi.dot(Ts);if(l<=0&&c<=0)return t.copy(i);As.subVectors(e,r);const h=di.dot(As),f=pi.dot(As);if(h>=0&&f<=h)return t.copy(r);const d=l*f-h*c;if(d<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(i).addScaledVector(di,a);ws.subVectors(e,s);const m=di.dot(ws),g=pi.dot(ws);if(g>=0&&m<=g)return t.copy(s);const x=m*c-l*g;if(x<=0&&c>=0&&g<=0)return o=c/(c-g),t.copy(i).addScaledVector(pi,o);const p=h*g-m*f;if(p<=0&&f-h>=0&&m-g>=0)return el.subVectors(s,r),o=(f-h)/(f-h+(m-g)),t.copy(r).addScaledVector(el,o);const u=1/(p+x+d);return a=x*u,o=d*u,t.copy(i).addScaledVector(di,a).addScaledVector(pi,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const Rc={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},Un={h:0,s:0,l:0},Mr={h:0,s:0,l:0};function Ds(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class Qe{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===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,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=$t){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ze.colorSpaceToWorking(this,t),this}setRGB(e,t,i,r=Ze.workingColorSpace){return this.r=e,this.g=t,this.b=i,Ze.colorSpaceToWorking(this,r),this}setHSL(e,t,i,r=Ze.workingColorSpace){if(e=Of(e,1),t=Ye(t,0,1),i=Ye(i,0,1),t===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+t):i+t-i*t,a=2*i-s;this.r=Ds(a,s,e+1/3),this.g=Ds(a,s,e),this.b=Ds(a,s,e-1/3)}return Ze.colorSpaceToWorking(this,r),this}setStyle(e,t=$t){function i(s){s!==void 0&&parseFloat(s)<1&&Be("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 i(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 i(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 i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:Be("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);Be("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=$t){const i=Rc[e.toLowerCase()];return i!==void 0?this.setHex(i,t):Be("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=wn(e.r),this.g=wn(e.g),this.b=wn(e.b),this}copyLinearToSRGB(e){return this.r=bi(e.r),this.g=bi(e.g),this.b=bi(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=$t){return Ze.workingToColorSpace(wt.copy(this),e),Math.round(Ye(wt.r*255,0,255))*65536+Math.round(Ye(wt.g*255,0,255))*256+Math.round(Ye(wt.b*255,0,255))}getHexString(e=$t){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ze.workingColorSpace){Ze.workingToColorSpace(wt.copy(this),t);const i=wt.r,r=wt.g,s=wt.b,a=Math.max(i,r,s),o=Math.min(i,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 i:l=(r-s)/f+(r<s?6:0);break;case r:l=(s-i)/f+2;break;case s:l=(i-r)/f+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=Ze.workingColorSpace){return Ze.workingToColorSpace(wt.copy(this),t),e.r=wt.r,e.g=wt.g,e.b=wt.b,e}getStyle(e=$t){Ze.workingToColorSpace(wt.copy(this),e);const t=wt.r,i=wt.g,r=wt.b;return e!==$t?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,t,i){return this.getHSL(Un),this.setHSL(Un.h+e,Un.s+t,Un.l+i)}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,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(Un),e.getHSL(Mr);const i=ds(Un.h,Mr.h,t),r=ds(Un.s,Mr.s,t),s=ds(Un.l,Mr.l,t);return this.setHSL(i,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,i=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*i+s[6]*r,this.g=s[1]*t+s[4]*i+s[7]*r,this.b=s[2]*t+s[5]*i+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 wt=new Qe;Qe.NAMES=Rc;let Jf=0;class Di extends ni{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Jf++}),this.uuid=tr(),this.name="",this.type="Material",this.blending=yi,this.side=kn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=js,this.blendDst=Ks,this.blendEquation=Kn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Qe(0,0,0),this.blendAlpha=0,this.depthFunc=Ai,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=zo,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=si,this.stencilZFail=si,this.stencilZPass=si,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 i=e[t];if(i===void 0){Be(`Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){Be(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==yi&&(i.blending=this.blending),this.side!==kn&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==js&&(i.blendSrc=this.blendSrc),this.blendDst!==Ks&&(i.blendDst=this.blendDst),this.blendEquation!==Kn&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Ai&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==zo&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==si&&(i.stencilFail=this.stencilFail),this.stencilZFail!==si&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==si&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.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&&(i.textures=s),a.length>0&&(i.images=a)}return i}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 i=null;if(t!==null){const r=t.length;i=new Array(r);for(let s=0;s!==r;++s)i[s]=t[s].clone()}return this.clippingPlanes=i,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 so extends Di{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Qe(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 Pn,this.combine=uc,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 gt=new F,Sr=new Ge;let Qf=0;class Ut{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Qf++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=ko,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,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)Sr.fromBufferAttribute(this,t),Sr.applyMatrix3(e),this.setXY(t,Sr.x,Sr.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)gt.fromBufferAttribute(this,t),gt.applyMatrix3(e),this.setXYZ(t,gt.x,gt.y,gt.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)gt.fromBufferAttribute(this,t),gt.applyMatrix4(e),this.setXYZ(t,gt.x,gt.y,gt.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)gt.fromBufferAttribute(this,t),gt.applyNormalMatrix(e),this.setXYZ(t,gt.x,gt.y,gt.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)gt.fromBufferAttribute(this,t),gt.transformDirection(e),this.setXYZ(t,gt.x,gt.y,gt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=Bi(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=zt(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Bi(t,this.array)),t}setX(e,t){return this.normalized&&(t=zt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Bi(t,this.array)),t}setY(e,t){return this.normalized&&(t=zt(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=Bi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=zt(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=Bi(t,this.array)),t}setW(e,t){return this.normalized&&(t=zt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=zt(t,this.array),i=zt(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=zt(t,this.array),i=zt(i,this.array),r=zt(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,s){return e*=this.itemSize,this.normalized&&(t=zt(t,this.array),i=zt(i,this.array),r=zt(r,this.array),s=zt(s,this.array)),this.array[e+0]=t,this.array[e+1]=i,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!==ko&&(e.usage=this.usage),e}}class Cc extends Ut{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class Pc extends Ut{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class Ht extends Ut{constructor(e,t,i){super(new Float32Array(e),t,i)}}let ed=0;const Kt=new ht,Ls=new Dt,mi=new F,Yt=new nr,Hi=new nr,St=new F;class Ct extends ni{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:ed++}),this.uuid=tr(),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={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Ac(e)?Pc:Cc)(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,i=0){this.groups.push({start:e,count:t,materialIndex:i})}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 i=this.attributes.normal;if(i!==void 0){const s=new We().getNormalMatrix(e);i.applyNormalMatrix(s),i.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}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,i){return Kt.makeTranslation(e,t,i),this.applyMatrix4(Kt),this}scale(e,t,i){return Kt.makeScale(e,t,i),this.applyMatrix4(Kt),this}lookAt(e){return Ls.lookAt(e),Ls.updateMatrix(),this.applyMatrix4(Ls.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(mi).negate(),this.translate(mi.x,mi.y,mi.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let r=0,s=e.length;r<s;r++){const a=e[r];i.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Ht(i,3))}else{const i=Math.min(e.length,t.count);for(let r=0;r<i;r++){const s=e[r];t.setXYZ(r,s.x,s.y,s.z||0)}e.length>t.count&&Be("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 nr);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){$e("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 i=0,r=t.length;i<r;i++){const s=t[i];Yt.setFromBufferAttribute(s),this.morphTargetsRelative?(St.addVectors(this.boundingBox.min,Yt.min),this.boundingBox.expandByPoint(St),St.addVectors(this.boundingBox.max,Yt.max),this.boundingBox.expandByPoint(St)):(this.boundingBox.expandByPoint(Yt.min),this.boundingBox.expandByPoint(Yt.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&$e('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 ir);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){$e("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new F,1/0);return}if(e){const i=this.boundingSphere.center;if(Yt.setFromBufferAttribute(e),t)for(let s=0,a=t.length;s<a;s++){const o=t[s];Hi.setFromBufferAttribute(o),this.morphTargetsRelative?(St.addVectors(Yt.min,Hi.min),Yt.expandByPoint(St),St.addVectors(Yt.max,Hi.max),Yt.expandByPoint(St)):(Yt.expandByPoint(Hi.min),Yt.expandByPoint(Hi.max))}Yt.getCenter(i);let r=0;for(let s=0,a=e.count;s<a;s++)St.fromBufferAttribute(e,s),r=Math.max(r,i.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&&(mi.fromBufferAttribute(e,c),St.add(mi)),r=Math.max(r,i.distanceToSquared(St))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&$e('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){$e("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Ut(new Float32Array(4*i.count),4));const a=this.getAttribute("tangent"),o=[],l=[];for(let I=0;I<i.count;I++)o[I]=new F,l[I]=new F;const c=new F,h=new F,f=new F,d=new Ge,m=new Ge,g=new Ge,x=new F,p=new F;function u(I,S,T){c.fromBufferAttribute(i,I),h.fromBufferAttribute(i,S),f.fromBufferAttribute(i,T),d.fromBufferAttribute(s,I),m.fromBufferAttribute(s,S),g.fromBufferAttribute(s,T),h.sub(c),f.sub(c),m.sub(d),g.sub(d);const P=1/(m.x*g.y-g.x*m.y);isFinite(P)&&(x.copy(h).multiplyScalar(g.y).addScaledVector(f,-m.y).multiplyScalar(P),p.copy(f).multiplyScalar(m.x).addScaledVector(h,-g.x).multiplyScalar(P),o[I].add(x),o[S].add(x),o[T].add(x),l[I].add(p),l[S].add(p),l[T].add(p))}let y=this.groups;y.length===0&&(y=[{start:0,count:e.count}]);for(let I=0,S=y.length;I<S;++I){const T=y[I],P=T.start,B=T.count;for(let z=P,j=P+B;z<j;z+=3)u(e.getX(z+0),e.getX(z+1),e.getX(z+2))}const v=new F,M=new F,b=new F,w=new F;function R(I){b.fromBufferAttribute(r,I),w.copy(b);const S=o[I];v.copy(S),v.sub(b.multiplyScalar(b.dot(S))).normalize(),M.crossVectors(w,S);const P=M.dot(l[I])<0?-1:1;a.setXYZW(I,v.x,v.y,v.z,P)}for(let I=0,S=y.length;I<S;++I){const T=y[I],P=T.start,B=T.count;for(let z=P,j=P+B;z<j;z+=3)R(e.getX(z+0)),R(e.getX(z+1)),R(e.getX(z+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new Ut(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let d=0,m=i.count;d<m;d++)i.setXYZ(d,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 d=0,m=e.count;d<m;d+=3){const g=e.getX(d+0),x=e.getX(d+1),p=e.getX(d+2);r.fromBufferAttribute(t,g),s.fromBufferAttribute(t,x),a.fromBufferAttribute(t,p),h.subVectors(a,s),f.subVectors(r,s),h.cross(f),o.fromBufferAttribute(i,g),l.fromBufferAttribute(i,x),c.fromBufferAttribute(i,p),o.add(h),l.add(h),c.add(h),i.setXYZ(g,o.x,o.y,o.z),i.setXYZ(x,l.x,l.y,l.z),i.setXYZ(p,c.x,c.y,c.z)}else for(let d=0,m=t.count;d<m;d+=3)r.fromBufferAttribute(t,d+0),s.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,d+2),h.subVectors(a,s),f.subVectors(r,s),h.cross(f),i.setXYZ(d+0,h.x,h.y,h.z),i.setXYZ(d+1,h.x,h.y,h.z),i.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;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,d=new c.constructor(l.length*h);let m=0,g=0;for(let x=0,p=l.length;x<p;x++){o.isInterleavedBufferAttribute?m=l[x]*o.data.stride+o.offset:m=l[x]*h;for(let u=0;u<h;u++)d[g++]=c[m++]}return new Ut(d,h,f)}if(this.index===null)return Be("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Ct,i=this.index.array,r=this.attributes;for(const o in r){const l=r[o],c=e(l,i);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 d=c[h],m=e(d,i);l.push(m)}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.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 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 i=this.attributes;for(const l in i){const c=i[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,d=c.length;f<d;f++){const m=c[f];h.push(m.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 i=e.index;i!==null&&this.setIndex(i.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 d=0,m=f.length;d<m;d++)h.push(f[d].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,h=a.length;c<h;c++){const 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}dispose(){this.dispatchEvent({type:"dispose"})}}const tl=new ht,Xn=new rr,yr=new ir,nl=new F,br=new F,Er=new F,Tr=new F,Ns=new F,Ar=new F,il=new F,wr=new F;class pn extends Dt{constructor(e=new Ct,t=new so){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,i=Object.keys(t);if(i.length>0){const r=t[i[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 i=this.geometry,r=i.attributes.position,s=i.morphAttributes.position,a=i.morphTargetsRelative;t.fromBufferAttribute(r,e);const o=this.morphTargetInfluences;if(s&&o){Ar.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const h=o[l],f=s[l];h!==0&&(Ns.fromBufferAttribute(f,e),a?Ar.addScaledVector(Ns,h):Ar.addScaledVector(Ns.sub(t),h))}t.add(Ar)}return t}raycast(e,t){const i=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),yr.copy(i.boundingSphere),yr.applyMatrix4(s),Xn.copy(e.ray).recast(e.near),!(yr.containsPoint(Xn.origin)===!1&&(Xn.intersectSphere(yr,nl)===null||Xn.origin.distanceToSquared(nl)>(e.far-e.near)**2))&&(tl.copy(s).invert(),Xn.copy(e.ray).applyMatrix4(tl),!(i.boundingBox!==null&&Xn.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Xn)))}_computeIntersections(e,t,i){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,d=s.groups,m=s.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,x=d.length;g<x;g++){const p=d[g],u=a[p.materialIndex],y=Math.max(p.start,m.start),v=Math.min(o.count,Math.min(p.start+p.count,m.start+m.count));for(let M=y,b=v;M<b;M+=3){const w=o.getX(M),R=o.getX(M+1),I=o.getX(M+2);r=Rr(this,u,e,i,c,h,f,w,R,I),r&&(r.faceIndex=Math.floor(M/3),r.face.materialIndex=p.materialIndex,t.push(r))}}else{const g=Math.max(0,m.start),x=Math.min(o.count,m.start+m.count);for(let p=g,u=x;p<u;p+=3){const y=o.getX(p),v=o.getX(p+1),M=o.getX(p+2);r=Rr(this,a,e,i,c,h,f,y,v,M),r&&(r.faceIndex=Math.floor(p/3),t.push(r))}}else if(l!==void 0)if(Array.isArray(a))for(let g=0,x=d.length;g<x;g++){const p=d[g],u=a[p.materialIndex],y=Math.max(p.start,m.start),v=Math.min(l.count,Math.min(p.start+p.count,m.start+m.count));for(let M=y,b=v;M<b;M+=3){const w=M,R=M+1,I=M+2;r=Rr(this,u,e,i,c,h,f,w,R,I),r&&(r.faceIndex=Math.floor(M/3),r.face.materialIndex=p.materialIndex,t.push(r))}}else{const g=Math.max(0,m.start),x=Math.min(l.count,m.start+m.count);for(let p=g,u=x;p<u;p+=3){const y=p,v=p+1,M=p+2;r=Rr(this,a,e,i,c,h,f,y,v,M),r&&(r.faceIndex=Math.floor(p/3),t.push(r))}}}}function td(n,e,t,i,r,s,a,o){let l;if(e.side===Vt?l=i.intersectTriangle(a,s,r,!0,o):l=i.intersectTriangle(r,s,a,e.side===kn,o),l===null)return null;wr.copy(o),wr.applyMatrix4(n.matrixWorld);const c=t.ray.origin.distanceTo(wr);return c<t.near||c>t.far?null:{distance:c,point:wr.clone(),object:n}}function Rr(n,e,t,i,r,s,a,o,l,c){n.getVertexPosition(o,br),n.getVertexPosition(l,Er),n.getVertexPosition(c,Tr);const h=td(n,e,t,i,br,Er,Tr,il);if(h){const f=new F;nn.getBarycoord(il,br,Er,Tr,f),r&&(h.uv=nn.getInterpolatedAttribute(r,o,l,c,f,new Ge)),s&&(h.uv1=nn.getInterpolatedAttribute(s,o,l,c,f,new Ge)),a&&(h.normal=nn.getInterpolatedAttribute(a,o,l,c,f,new F),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:l,c,normal:new F,materialIndex:0};nn.getNormal(br,Er,Tr,d.normal),h.face=d,h.barycoord=f}return h}class sr extends Ct{constructor(e=1,t=1,i=1,r=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,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 d=0,m=0;g("z","y","x",-1,-1,i,t,e,a,s,0),g("z","y","x",1,-1,i,t,-e,a,s,1),g("x","z","y",1,1,e,i,t,r,a,2),g("x","z","y",1,-1,e,i,-t,r,a,3),g("x","y","z",1,-1,e,t,i,r,s,4),g("x","y","z",-1,-1,e,t,-i,r,s,5),this.setIndex(l),this.setAttribute("position",new Ht(c,3)),this.setAttribute("normal",new Ht(h,3)),this.setAttribute("uv",new Ht(f,2));function g(x,p,u,y,v,M,b,w,R,I,S){const T=M/R,P=b/I,B=M/2,z=b/2,j=w/2,K=R+1,L=I+1;let k=0,Z=0;const re=new F;for(let V=0;V<L;V++){const W=V*P-z;for(let ce=0;ce<K;ce++){const se=ce*T-B;re[x]=se*y,re[p]=W*v,re[u]=j,c.push(re.x,re.y,re.z),re[x]=0,re[p]=0,re[u]=w>0?1:-1,h.push(re.x,re.y,re.z),f.push(ce/R),f.push(1-V/I),k+=1}}for(let V=0;V<I;V++)for(let W=0;W<R;W++){const ce=d+W+K*V,se=d+W+K*(V+1),we=d+(W+1)+K*(V+1),Se=d+(W+1)+K*V;l.push(ce,se,Se),l.push(se,we,Se),Z+=6}o.addGroup(m,Z,S),m+=Z,d+=k}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new sr(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Pi(n){const e={};for(const t in n){e[t]={};for(const i in n[t]){const r=n[t][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(Be("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=r.clone():Array.isArray(r)?e[t][i]=r.slice():e[t][i]=r}}return e}function Nt(n){const e={};for(let t=0;t<n.length;t++){const i=Pi(n[t]);for(const r in i)e[r]=i[r]}return e}function nd(n){const e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function Dc(n){const e=n.getRenderTarget();return e===null?n.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Ze.workingColorSpace}const id={clone:Pi,merge:Nt};var rd=`void main() {
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
}`,sd=`void main() {
|
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
}`;class mn extends Di{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=rd,this.fragmentShader=sd,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=Pi(e.uniforms),this.uniformsGroups=nd(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 i={};for(const r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class Lc extends Dt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ht,this.projectionMatrix=new ht,this.projectionMatrixInverse=new ht,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.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const Fn=new F,rl=new Ge,sl=new Ge;class Zt extends Lc{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,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=za*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Wr*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return za*2*Math.atan(Math.tan(Wr*.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,i){Fn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Fn.x,Fn.y).multiplyScalar(-e/Fn.z),Fn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Fn.x,Fn.y).multiplyScalar(-e/Fn.z)}getViewSize(e,t){return this.getViewBounds(e,rl,sl),t.subVectors(sl,rl)}setViewOffset(e,t,i,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=i,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(Wr*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,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*i/c,r*=a.width/l,i*=a.height/c}const o=this.filmOffset;o!==0&&(s+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-i,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}}const gi=-90,_i=1;class ad extends Dt{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Zt(gi,_i,e,t);r.layers=this.layers,this.add(r);const s=new Zt(gi,_i,e,t);s.layers=this.layers,this.add(s);const a=new Zt(gi,_i,e,t);a.layers=this.layers,this.add(a);const o=new Zt(gi,_i,e,t);o.layers=this.layers,this.add(o);const l=new Zt(gi,_i,e,t);l.layers=this.layers,this.add(l);const c=new Zt(gi,_i,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,r,s,a,o,l]=t;for(const c of t)this.remove(c);if(e===un)i.up.set(0,1,0),i.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===$r)i.up.set(0,-1,0),i.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:i,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(),d=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const x=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,r),e.render(t,s),e.setRenderTarget(i,1,r),e.render(t,a),e.setRenderTarget(i,2,r),e.render(t,o),e.setRenderTarget(i,3,r),e.render(t,l),e.setRenderTarget(i,4,r),e.render(t,c),i.texture.generateMipmaps=x,e.setRenderTarget(i,5,r),e.render(t,h),e.setRenderTarget(f,d,m),e.xr.enabled=g,i.texture.needsPMREMUpdate=!0}}class Nc extends Pt{constructor(e=[],t=ei,i,r,s,a,o,l,c,h){super(e,t,i,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 Ic extends fn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];this.texture=new Nc(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:`
|
|
|
|
varying vec3 vWorldDirection;
|
|
|
|
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
|
|
|
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
|
|
|
}
|
|
|
|
void main() {
|
|
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
|
|
}
|
|
`,fragmentShader:`
|
|
|
|
uniform sampler2D tEquirect;
|
|
|
|
varying vec3 vWorldDirection;
|
|
|
|
#include <common>
|
|
|
|
void main() {
|
|
|
|
vec3 direction = normalize( vWorldDirection );
|
|
|
|
vec2 sampleUV = equirectUv( direction );
|
|
|
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
|
|
}
|
|
`},r=new sr(5,5,5),s=new mn({name:"CubemapFromEquirect",uniforms:Pi(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Vt,blending:An});s.uniforms.tEquirect.value=t;const a=new pn(r,s),o=t.minFilter;return t.minFilter===Zn&&(t.minFilter=Rt),new ad(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,i=!0,r=!0){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,r);e.setRenderTarget(s)}}class Cr extends Dt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const od={type:"move"};class Is{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Cr,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 Cr,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 Cr,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}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 i of e.hand.values())this._getHandJoint(t,i)}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,i){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 x of e.hand.values()){const p=t.getJointPose(x,i),u=this._getHandJoint(c,x);p!==null&&(u.matrix.fromArray(p.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,u.jointRadius=p.radius),u.visible=p!==null}const h=c.joints["index-finger-tip"],f=c.joints["thumb-tip"],d=h.position.distanceTo(f.position),m=.02,g=.005;c.inputState.pinching&&d>m+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=m-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),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));o!==null&&(r=t.getPose(e.targetRaySpace,i),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(od)))}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 i=new Cr;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}class ld extends Dt{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 Pn,this.environmentIntensity=1,this.environmentRotation=new Pn,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}}class cd extends Pt{constructor(e=null,t=1,i=1,r,s,a,o,l,c=bt,h=bt,f,d){super(null,a,o,l,c,h,r,s,f,d),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Us=new F,ud=new F,hd=new We;class On{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,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const r=Us.subVectors(i,t).cross(ud.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){const i=e.delta(Us),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(i,s)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<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 i=t||hd.getNormalMatrix(e),r=this.coplanarPoint(Us).applyMatrix4(e),s=this.normal.applyMatrix3(i).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 qn=new ir,fd=new Ge(.5,.5),Pr=new F;class Uc{constructor(e=new On,t=new On,i=new On,r=new On,s=new On,a=new On){this.planes=[e,t,i,r,s,a]}set(e,t,i,r,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(r),o[4].copy(s),o[5].copy(a),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=un,i=!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],d=s[6],m=s[7],g=s[8],x=s[9],p=s[10],u=s[11],y=s[12],v=s[13],M=s[14],b=s[15];if(r[0].setComponents(c-a,m-h,u-g,b-y).normalize(),r[1].setComponents(c+a,m+h,u+g,b+y).normalize(),r[2].setComponents(c+o,m+f,u+x,b+v).normalize(),r[3].setComponents(c-o,m-f,u-x,b-v).normalize(),i)r[4].setComponents(l,d,p,M).normalize(),r[5].setComponents(c-l,m-d,u-p,b-M).normalize();else if(r[4].setComponents(c-l,m-d,u-p,b-M).normalize(),t===un)r[5].setComponents(c+l,m+d,u+p,b+M).normalize();else if(t===$r)r[5].setComponents(l,d,p,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(),qn.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),qn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(qn)}intersectsSprite(e){qn.center.set(0,0,0);const t=fd.distanceTo(e.center);return qn.radius=.7071067811865476+t,qn.applyMatrix4(e.matrixWorld),this.intersectsSphere(qn)}intersectsSphere(e){const t=this.planes,i=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const r=t[i];if(Pr.x=r.normal.x>0?e.max.x:e.min.x,Pr.y=r.normal.y>0?e.max.y:e.min.y,Pr.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Pr)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Jr extends Di{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Qe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Qr=new F,es=new F,al=new ht,Gi=new rr,Dr=new ir,Fs=new F,ol=new F;class dd extends Dt{constructor(e=new Ct,t=new Jr){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let r=1,s=t.count;r<s;r++)Qr.fromBufferAttribute(t,r-1),es.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=Qr.distanceTo(es);e.setAttribute("lineDistance",new Ht(i,1))}else Be("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Dr.copy(i.boundingSphere),Dr.applyMatrix4(r),Dr.radius+=s,e.ray.intersectsSphere(Dr)===!1)return;al.copy(r).invert(),Gi.copy(e.ray).applyMatrix4(al);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=this.isLineSegments?2:1,h=i.index,d=i.attributes.position;if(h!==null){const m=Math.max(0,a.start),g=Math.min(h.count,a.start+a.count);for(let x=m,p=g-1;x<p;x+=c){const u=h.getX(x),y=h.getX(x+1),v=Lr(this,e,Gi,l,u,y,x);v&&t.push(v)}if(this.isLineLoop){const x=h.getX(g-1),p=h.getX(m),u=Lr(this,e,Gi,l,x,p,g-1);u&&t.push(u)}}else{const m=Math.max(0,a.start),g=Math.min(d.count,a.start+a.count);for(let x=m,p=g-1;x<p;x+=c){const u=Lr(this,e,Gi,l,x,x+1,x);u&&t.push(u)}if(this.isLineLoop){const x=Lr(this,e,Gi,l,g-1,m,g-1);x&&t.push(x)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const r=t[i[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 Lr(n,e,t,i,r,s,a){const o=n.geometry.attributes.position;if(Qr.fromBufferAttribute(o,r),es.fromBufferAttribute(o,s),t.distanceSqToSegment(Qr,es,Fs,ol)>i)return;Fs.applyMatrix4(n.matrixWorld);const c=e.ray.origin.distanceTo(Fs);if(!(c<e.near||c>e.far))return{distance:c,point:ol.clone().applyMatrix4(n.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:n}}const ll=new F,cl=new F;class Os extends dd{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let r=0,s=t.count;r<s;r+=2)ll.fromBufferAttribute(t,r),cl.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+ll.distanceTo(cl);e.setAttribute("lineDistance",new Ht(i,1))}else Be("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Fc extends Di{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Qe(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 ul=new ht,ka=new rr,Nr=new ir,Ir=new F;class pd extends Dt{constructor(e=new Ct,t=new Fc){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 i=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,a=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),Nr.copy(i.boundingSphere),Nr.applyMatrix4(r),Nr.radius+=s,e.ray.intersectsSphere(Nr)===!1)return;ul.copy(r).invert(),ka.copy(e.ray).applyMatrix4(ul);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=i.index,f=i.attributes.position;if(c!==null){const d=Math.max(0,a.start),m=Math.min(c.count,a.start+a.count);for(let g=d,x=m;g<x;g++){const p=c.getX(g);Ir.fromBufferAttribute(f,p),hl(Ir,p,l,r,e,t,this)}}else{const d=Math.max(0,a.start),m=Math.min(f.count,a.start+a.count);for(let g=d,x=m;g<x;g++)Ir.fromBufferAttribute(f,g),hl(Ir,g,l,r,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const r=t[i[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 hl(n,e,t,i,r,s,a){const o=ka.distanceSqToPoint(n);if(o<t){const l=new F;ka.closestPointToPoint(n,l),l.applyMatrix4(i);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 md extends Pt{constructor(e,t,i,r,s,a,o,l,c){super(e,t,i,r,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class er extends Pt{constructor(e,t,i=dn,r,s,a,o=bt,l=bt,c,h=Cn,f=1){if(h!==Cn&&h!==Jn)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:e,height:t,depth:f};super(d,r,s,a,o,l,h,i,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new io(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 gd extends er{constructor(e,t=dn,i=ei,r,s,a=bt,o=bt,l,c=Cn){const h={width:e,height:e,depth:1},f=[h,h,h,h,h,h];super(e,e,t,i,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 Oc extends Pt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class rs extends Ct{constructor(e=1,t=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};const s=e/2,a=t/2,o=Math.floor(i),l=Math.floor(r),c=o+1,h=l+1,f=e/o,d=t/l,m=[],g=[],x=[],p=[];for(let u=0;u<h;u++){const y=u*d-a;for(let v=0;v<c;v++){const M=v*f-s;g.push(M,-y,0),x.push(0,0,1),p.push(v/o),p.push(1-u/l)}}for(let u=0;u<l;u++)for(let y=0;y<o;y++){const v=y+c*u,M=y+c*(u+1),b=y+1+c*(u+1),w=y+1+c*u;m.push(v,M,w),m.push(M,b,w)}this.setIndex(m),this.setAttribute("position",new Ht(g,3)),this.setAttribute("normal",new Ht(x,3)),this.setAttribute("uv",new Ht(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new rs(e.width,e.height,e.widthSegments,e.heightSegments)}}class ao extends Ct{constructor(e=1,t=32,i=16,r=0,s=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:s,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));const l=Math.min(a+o,Math.PI);let c=0;const h=[],f=new F,d=new F,m=[],g=[],x=[],p=[];for(let u=0;u<=i;u++){const y=[],v=u/i;let M=0;u===0&&a===0?M=.5/t:u===i&&l===Math.PI&&(M=-.5/t);for(let b=0;b<=t;b++){const w=b/t;f.x=-e*Math.cos(r+w*s)*Math.sin(a+v*o),f.y=e*Math.cos(a+v*o),f.z=e*Math.sin(r+w*s)*Math.sin(a+v*o),g.push(f.x,f.y,f.z),d.copy(f).normalize(),x.push(d.x,d.y,d.z),p.push(w+M,1-v),y.push(c++)}h.push(y)}for(let u=0;u<i;u++)for(let y=0;y<t;y++){const v=h[u][y+1],M=h[u][y],b=h[u+1][y],w=h[u+1][y+1];(u!==0||a>0)&&m.push(v,M,w),(u!==i-1||l<Math.PI)&&m.push(M,b,w)}this.setIndex(m),this.setAttribute("position",new Ht(g,3)),this.setAttribute("normal",new Ht(x,3)),this.setAttribute("uv",new Ht(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ao(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class _d extends mn{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class xd extends Di{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Af,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 vd extends Di{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Md extends Jr{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}class Bc extends Lc{constructor(e=-1,t=1,i=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=i,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,i,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=i,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),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=i-e,a=i+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}}class Sd extends Zt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const fl=new ht;class yd{constructor(e,t,i=0,r=1/0){this.ray=new rr(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new ro,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.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):$e("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return fl.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(fl),this}intersectObject(e,t=!0,i=[]){return Va(e,this,i,t),i.sort(dl),i}intersectObjects(e,t=!0,i=[]){for(let r=0,s=e.length;r<s;r++)Va(e[r],this,i,t);return i.sort(dl),i}}function dl(n,e){return n.distance-e.distance}function Va(n,e,t,i){let r=!0;if(n.layers.test(e.layers)&&n.raycast(e,t)===!1&&(r=!1),r===!0&&i===!0){const s=n.children;for(let a=0,o=s.length;a<o;a++)Va(s[a],e,t,!0)}}class pl{constructor(e=1,t=0,i=0){this.radius=e,this.phi=t,this.theta=i}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Ye(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Ye(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class bd extends ni{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){Be("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function ml(n,e,t,i){const r=Ed(i);switch(t){case bc:return n*e;case Tc:return n*e/r.components*r.byteLength;case Ja:return n*e/r.components*r.byteLength;case Ri:return n*e*2/r.components*r.byteLength;case Qa:return n*e*2/r.components*r.byteLength;case Ec:return n*e*3/r.components*r.byteLength;case rn:return n*e*4/r.components*r.byteLength;case eo:return n*e*4/r.components*r.byteLength;case kr:case Vr:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Hr:case Gr:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case la:case ua:return Math.max(n,16)*Math.max(e,8)/4;case oa:case ca:return Math.max(n,8)*Math.max(e,8)/2;case ha:case fa:case pa:case ma:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case da:case ga:case _a:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case xa:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case va:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Ma:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case Sa:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case ya:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case ba:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case Ea:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case Ta:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case Aa:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case wa:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case Ra:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case Ca:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case Pa:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case Da:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case La:case Na:case Ia:return Math.ceil(n/4)*Math.ceil(e/4)*16;case Ua:case Fa:return Math.ceil(n/4)*Math.ceil(e/4)*8;case Oa:case Ba:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Ed(n){switch(n){case Jt:case vc:return{byteLength:1,components:1};case Zi:case Mc:case Rn:return{byteLength:2,components:1};case $a:case Za:return{byteLength:2,components:4};case dn:case Ka:case cn:return{byteLength:4,components:1};case Sc:case yc:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${n}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:ja}}));typeof window<"u"&&(window.__THREE__?Be("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=ja);/**
|
|
* @license
|
|
* Copyright 2010-2025 Three.js Authors
|
|
* SPDX-License-Identifier: MIT
|
|
*/function zc(){let n=null,e=!1,t=null,i=null;function r(s,a){t(s,a),i=n.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){n=s}}}function Td(n){const e=new WeakMap;function t(o,l){const c=o.array,h=o.usage,f=c.byteLength,d=n.createBuffer();n.bindBuffer(l,d),n.bufferData(l,c,h),o.onUploadCallback();let m;if(c instanceof Float32Array)m=n.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)m=n.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?m=n.HALF_FLOAT:m=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)m=n.SHORT;else if(c instanceof Uint32Array)m=n.UNSIGNED_INT;else if(c instanceof Int32Array)m=n.INT;else if(c instanceof Int8Array)m=n.BYTE;else if(c instanceof Uint8Array)m=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)m=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:m,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:f}}function i(o,l,c){const h=l.array,f=l.updateRanges;if(n.bindBuffer(c,o),f.length===0)n.bufferSubData(c,0,h);else{f.sort((m,g)=>m.start-g.start);let d=0;for(let m=1;m<f.length;m++){const g=f[d],x=f[m];x.start<=g.start+g.count+1?g.count=Math.max(g.count,x.start+x.count-g.start):(++d,f[d]=x)}f.length=d+1;for(let m=0,g=f.length;m<g;m++){const x=f[m];n.bufferSubData(c,x.start*h.BYTES_PER_ELEMENT,h,x.start,x.count)}l.clearUpdateRanges()}l.onUploadCallback()}function r(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function s(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=e.get(o);l&&(n.deleteBuffer(l.buffer),e.delete(o))}function a(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const h=e.get(o);(!h||h.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=e.get(o);if(c===void 0)e.set(o,t(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");i(c.buffer,o,l),c.version=o.version}}return{get:r,remove:s,update:a}}var Ad=`#ifdef USE_ALPHAHASH
|
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
#endif`,wd=`#ifdef USE_ALPHAHASH
|
|
const float ALPHA_HASH_SCALE = 0.05;
|
|
float hash2D( vec2 value ) {
|
|
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
|
|
}
|
|
float hash3D( vec3 value ) {
|
|
return hash2D( vec2( hash2D( value.xy ), value.z ) );
|
|
}
|
|
float getAlphaHashThreshold( vec3 position ) {
|
|
float maxDeriv = max(
|
|
length( dFdx( position.xyz ) ),
|
|
length( dFdy( position.xyz ) )
|
|
);
|
|
float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
|
|
vec2 pixScales = vec2(
|
|
exp2( floor( log2( pixScale ) ) ),
|
|
exp2( ceil( log2( pixScale ) ) )
|
|
);
|
|
vec2 alpha = vec2(
|
|
hash3D( floor( pixScales.x * position.xyz ) ),
|
|
hash3D( floor( pixScales.y * position.xyz ) )
|
|
);
|
|
float lerpFactor = fract( log2( pixScale ) );
|
|
float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
|
|
float a = min( lerpFactor, 1.0 - lerpFactor );
|
|
vec3 cases = vec3(
|
|
x * x / ( 2.0 * a * ( 1.0 - a ) ),
|
|
( x - 0.5 * a ) / ( 1.0 - a ),
|
|
1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
|
|
);
|
|
float threshold = ( x < ( 1.0 - a ) )
|
|
? ( ( x < a ) ? cases.x : cases.y )
|
|
: cases.z;
|
|
return clamp( threshold , 1.0e-6, 1.0 );
|
|
}
|
|
#endif`,Rd=`#ifdef USE_ALPHAMAP
|
|
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
|
#endif`,Cd=`#ifdef USE_ALPHAMAP
|
|
uniform sampler2D alphaMap;
|
|
#endif`,Pd=`#ifdef USE_ALPHATEST
|
|
#ifdef ALPHA_TO_COVERAGE
|
|
diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
|
|
if ( diffuseColor.a == 0.0 ) discard;
|
|
#else
|
|
if ( diffuseColor.a < alphaTest ) discard;
|
|
#endif
|
|
#endif`,Dd=`#ifdef USE_ALPHATEST
|
|
uniform float alphaTest;
|
|
#endif`,Ld=`#ifdef USE_AOMAP
|
|
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
|
|
reflectedLight.indirectDiffuse *= ambientOcclusion;
|
|
#if defined( USE_CLEARCOAT )
|
|
clearcoatSpecularIndirect *= ambientOcclusion;
|
|
#endif
|
|
#if defined( USE_SHEEN )
|
|
sheenSpecularIndirect *= ambientOcclusion;
|
|
#endif
|
|
#if defined( USE_ENVMAP ) && defined( STANDARD )
|
|
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
|
|
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
|
|
#endif
|
|
#endif`,Nd=`#ifdef USE_AOMAP
|
|
uniform sampler2D aoMap;
|
|
uniform float aoMapIntensity;
|
|
#endif`,Id=`#ifdef USE_BATCHING
|
|
#if ! defined( GL_ANGLE_multi_draw )
|
|
#define gl_DrawID _gl_DrawID
|
|
uniform int _gl_DrawID;
|
|
#endif
|
|
uniform highp sampler2D batchingTexture;
|
|
uniform highp usampler2D batchingIdTexture;
|
|
mat4 getBatchingMatrix( const in float i ) {
|
|
int size = textureSize( batchingTexture, 0 ).x;
|
|
int j = int( i ) * 4;
|
|
int x = j % size;
|
|
int y = j / size;
|
|
vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
|
|
vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
|
|
vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
|
|
vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
|
|
return mat4( v1, v2, v3, v4 );
|
|
}
|
|
float getIndirectIndex( const in int i ) {
|
|
int size = textureSize( batchingIdTexture, 0 ).x;
|
|
int x = i % size;
|
|
int y = i / size;
|
|
return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
|
|
}
|
|
#endif
|
|
#ifdef USE_BATCHING_COLOR
|
|
uniform sampler2D batchingColorTexture;
|
|
vec3 getBatchingColor( const in float i ) {
|
|
int size = textureSize( batchingColorTexture, 0 ).x;
|
|
int j = int( i );
|
|
int x = j % size;
|
|
int y = j / size;
|
|
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
|
|
}
|
|
#endif`,Ud=`#ifdef USE_BATCHING
|
|
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
|
#endif`,Fd=`vec3 transformed = vec3( position );
|
|
#ifdef USE_ALPHAHASH
|
|
vPosition = vec3( position );
|
|
#endif`,Od=`vec3 objectNormal = vec3( normal );
|
|
#ifdef USE_TANGENT
|
|
vec3 objectTangent = vec3( tangent.xyz );
|
|
#endif`,Bd=`float G_BlinnPhong_Implicit( ) {
|
|
return 0.25;
|
|
}
|
|
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
|
|
return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
|
|
}
|
|
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
|
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|
float dotNH = saturate( dot( normal, halfDir ) );
|
|
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|
vec3 F = F_Schlick( specularColor, 1.0, dotVH );
|
|
float G = G_BlinnPhong_Implicit( );
|
|
float D = D_BlinnPhong( shininess, dotNH );
|
|
return F * ( G * D );
|
|
} // validated`,zd=`#ifdef USE_IRIDESCENCE
|
|
const mat3 XYZ_TO_REC709 = mat3(
|
|
3.2404542, -0.9692660, 0.0556434,
|
|
-1.5371385, 1.8760108, -0.2040259,
|
|
-0.4985314, 0.0415560, 1.0572252
|
|
);
|
|
vec3 Fresnel0ToIor( vec3 fresnel0 ) {
|
|
vec3 sqrtF0 = sqrt( fresnel0 );
|
|
return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
|
|
}
|
|
vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
|
|
return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
|
|
}
|
|
float IorToFresnel0( float transmittedIor, float incidentIor ) {
|
|
return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
|
|
}
|
|
vec3 evalSensitivity( float OPD, vec3 shift ) {
|
|
float phase = 2.0 * PI * OPD * 1.0e-9;
|
|
vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
|
|
vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
|
|
vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
|
|
vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
|
|
xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
|
|
xyz /= 1.0685e-7;
|
|
vec3 rgb = XYZ_TO_REC709 * xyz;
|
|
return rgb;
|
|
}
|
|
vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
|
|
vec3 I;
|
|
float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
|
|
float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
|
|
float cosTheta2Sq = 1.0 - sinTheta2Sq;
|
|
if ( cosTheta2Sq < 0.0 ) {
|
|
return vec3( 1.0 );
|
|
}
|
|
float cosTheta2 = sqrt( cosTheta2Sq );
|
|
float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
|
|
float R12 = F_Schlick( R0, 1.0, cosTheta1 );
|
|
float T121 = 1.0 - R12;
|
|
float phi12 = 0.0;
|
|
if ( iridescenceIOR < outsideIOR ) phi12 = PI;
|
|
float phi21 = PI - phi12;
|
|
vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
|
|
vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
|
|
vec3 phi23 = vec3( 0.0 );
|
|
if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
|
|
if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
|
|
if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
|
|
float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
|
|
vec3 phi = vec3( phi21 ) + phi23;
|
|
vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
|
|
vec3 r123 = sqrt( R123 );
|
|
vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
|
|
vec3 C0 = R12 + Rs;
|
|
I = C0;
|
|
vec3 Cm = Rs - T121;
|
|
for ( int m = 1; m <= 2; ++ m ) {
|
|
Cm *= r123;
|
|
vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
|
|
I += Cm * Sm;
|
|
}
|
|
return max( I, vec3( 0.0 ) );
|
|
}
|
|
#endif`,kd=`#ifdef USE_BUMPMAP
|
|
uniform sampler2D bumpMap;
|
|
uniform float bumpScale;
|
|
vec2 dHdxy_fwd() {
|
|
vec2 dSTdx = dFdx( vBumpMapUv );
|
|
vec2 dSTdy = dFdy( vBumpMapUv );
|
|
float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
|
|
float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
|
|
float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
|
|
return vec2( dBx, dBy );
|
|
}
|
|
vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
|
|
vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
|
|
vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
|
|
vec3 vN = surf_norm;
|
|
vec3 R1 = cross( vSigmaY, vN );
|
|
vec3 R2 = cross( vN, vSigmaX );
|
|
float fDet = dot( vSigmaX, R1 ) * faceDirection;
|
|
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
|
return normalize( abs( fDet ) * surf_norm - vGrad );
|
|
}
|
|
#endif`,Vd=`#if NUM_CLIPPING_PLANES > 0
|
|
vec4 plane;
|
|
#ifdef ALPHA_TO_COVERAGE
|
|
float distanceToPlane, distanceGradient;
|
|
float clipOpacity = 1.0;
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
|
|
plane = clippingPlanes[ i ];
|
|
distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
|
|
distanceGradient = fwidth( distanceToPlane ) / 2.0;
|
|
clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
|
|
if ( clipOpacity == 0.0 ) discard;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
|
|
float unionClipOpacity = 1.0;
|
|
#pragma unroll_loop_start
|
|
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
|
|
plane = clippingPlanes[ i ];
|
|
distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
|
|
distanceGradient = fwidth( distanceToPlane ) / 2.0;
|
|
unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
|
|
}
|
|
#pragma unroll_loop_end
|
|
clipOpacity *= 1.0 - unionClipOpacity;
|
|
#endif
|
|
diffuseColor.a *= clipOpacity;
|
|
if ( diffuseColor.a == 0.0 ) discard;
|
|
#else
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
|
|
plane = clippingPlanes[ i ];
|
|
if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
|
|
bool clipped = true;
|
|
#pragma unroll_loop_start
|
|
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
|
|
plane = clippingPlanes[ i ];
|
|
clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
|
|
}
|
|
#pragma unroll_loop_end
|
|
if ( clipped ) discard;
|
|
#endif
|
|
#endif
|
|
#endif`,Hd=`#if NUM_CLIPPING_PLANES > 0
|
|
varying vec3 vClipPosition;
|
|
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
|
#endif`,Gd=`#if NUM_CLIPPING_PLANES > 0
|
|
varying vec3 vClipPosition;
|
|
#endif`,Wd=`#if NUM_CLIPPING_PLANES > 0
|
|
vClipPosition = - mvPosition.xyz;
|
|
#endif`,Xd=`#if defined( USE_COLOR_ALPHA )
|
|
diffuseColor *= vColor;
|
|
#elif defined( USE_COLOR )
|
|
diffuseColor.rgb *= vColor;
|
|
#endif`,qd=`#if defined( USE_COLOR_ALPHA )
|
|
varying vec4 vColor;
|
|
#elif defined( USE_COLOR )
|
|
varying vec3 vColor;
|
|
#endif`,Yd=`#if defined( USE_COLOR_ALPHA )
|
|
varying vec4 vColor;
|
|
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
varying vec3 vColor;
|
|
#endif`,jd=`#if defined( USE_COLOR_ALPHA )
|
|
vColor = vec4( 1.0 );
|
|
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
vColor = vec3( 1.0 );
|
|
#endif
|
|
#ifdef USE_COLOR
|
|
vColor *= color;
|
|
#endif
|
|
#ifdef USE_INSTANCING_COLOR
|
|
vColor.xyz *= instanceColor.xyz;
|
|
#endif
|
|
#ifdef USE_BATCHING_COLOR
|
|
vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
|
|
vColor.xyz *= batchingColor.xyz;
|
|
#endif`,Kd=`#define PI 3.141592653589793
|
|
#define PI2 6.283185307179586
|
|
#define PI_HALF 1.5707963267948966
|
|
#define RECIPROCAL_PI 0.3183098861837907
|
|
#define RECIPROCAL_PI2 0.15915494309189535
|
|
#define EPSILON 1e-6
|
|
#ifndef saturate
|
|
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|
#endif
|
|
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
|
|
float pow2( const in float x ) { return x*x; }
|
|
vec3 pow2( const in vec3 x ) { return x*x; }
|
|
float pow3( const in float x ) { return x*x*x; }
|
|
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
|
|
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
|
|
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
|
|
highp float rand( const in vec2 uv ) {
|
|
const highp float a = 12.9898, b = 78.233, c = 43758.5453;
|
|
highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
|
|
return fract( sin( sn ) * c );
|
|
}
|
|
#ifdef HIGH_PRECISION
|
|
float precisionSafeLength( vec3 v ) { return length( v ); }
|
|
#else
|
|
float precisionSafeLength( vec3 v ) {
|
|
float maxComponent = max3( abs( v ) );
|
|
return length( v / maxComponent ) * maxComponent;
|
|
}
|
|
#endif
|
|
struct IncidentLight {
|
|
vec3 color;
|
|
vec3 direction;
|
|
bool visible;
|
|
};
|
|
struct ReflectedLight {
|
|
vec3 directDiffuse;
|
|
vec3 directSpecular;
|
|
vec3 indirectDiffuse;
|
|
vec3 indirectSpecular;
|
|
};
|
|
#ifdef USE_ALPHAHASH
|
|
varying vec3 vPosition;
|
|
#endif
|
|
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
|
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
|
}
|
|
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
|
|
return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
|
|
}
|
|
bool isPerspectiveMatrix( mat4 m ) {
|
|
return m[ 2 ][ 3 ] == - 1.0;
|
|
}
|
|
vec2 equirectUv( in vec3 dir ) {
|
|
float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
|
|
float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
|
|
return vec2( u, v );
|
|
}
|
|
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
|
|
return RECIPROCAL_PI * diffuseColor;
|
|
}
|
|
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
|
|
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
|
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
|
}
|
|
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
|
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
|
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
|
} // validated`,$d=`#ifdef ENVMAP_TYPE_CUBE_UV
|
|
#define cubeUV_minMipLevel 4.0
|
|
#define cubeUV_minTileSize 16.0
|
|
float getFace( vec3 direction ) {
|
|
vec3 absDirection = abs( direction );
|
|
float face = - 1.0;
|
|
if ( absDirection.x > absDirection.z ) {
|
|
if ( absDirection.x > absDirection.y )
|
|
face = direction.x > 0.0 ? 0.0 : 3.0;
|
|
else
|
|
face = direction.y > 0.0 ? 1.0 : 4.0;
|
|
} else {
|
|
if ( absDirection.z > absDirection.y )
|
|
face = direction.z > 0.0 ? 2.0 : 5.0;
|
|
else
|
|
face = direction.y > 0.0 ? 1.0 : 4.0;
|
|
}
|
|
return face;
|
|
}
|
|
vec2 getUV( vec3 direction, float face ) {
|
|
vec2 uv;
|
|
if ( face == 0.0 ) {
|
|
uv = vec2( direction.z, direction.y ) / abs( direction.x );
|
|
} else if ( face == 1.0 ) {
|
|
uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
|
|
} else if ( face == 2.0 ) {
|
|
uv = vec2( - direction.x, direction.y ) / abs( direction.z );
|
|
} else if ( face == 3.0 ) {
|
|
uv = vec2( - direction.z, direction.y ) / abs( direction.x );
|
|
} else if ( face == 4.0 ) {
|
|
uv = vec2( - direction.x, direction.z ) / abs( direction.y );
|
|
} else {
|
|
uv = vec2( direction.x, direction.y ) / abs( direction.z );
|
|
}
|
|
return 0.5 * ( uv + 1.0 );
|
|
}
|
|
vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
|
|
float face = getFace( direction );
|
|
float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
|
|
mipInt = max( mipInt, cubeUV_minMipLevel );
|
|
float faceSize = exp2( mipInt );
|
|
highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
|
|
if ( face > 2.0 ) {
|
|
uv.y += faceSize;
|
|
face -= 3.0;
|
|
}
|
|
uv.x += face * faceSize;
|
|
uv.x += filterInt * 3.0 * cubeUV_minTileSize;
|
|
uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
|
|
uv.x *= CUBEUV_TEXEL_WIDTH;
|
|
uv.y *= CUBEUV_TEXEL_HEIGHT;
|
|
#ifdef texture2DGradEXT
|
|
return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
|
|
#else
|
|
return texture2D( envMap, uv ).rgb;
|
|
#endif
|
|
}
|
|
#define cubeUV_r0 1.0
|
|
#define cubeUV_m0 - 2.0
|
|
#define cubeUV_r1 0.8
|
|
#define cubeUV_m1 - 1.0
|
|
#define cubeUV_r4 0.4
|
|
#define cubeUV_m4 2.0
|
|
#define cubeUV_r5 0.305
|
|
#define cubeUV_m5 3.0
|
|
#define cubeUV_r6 0.21
|
|
#define cubeUV_m6 4.0
|
|
float roughnessToMip( float roughness ) {
|
|
float mip = 0.0;
|
|
if ( roughness >= cubeUV_r1 ) {
|
|
mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
|
|
} else if ( roughness >= cubeUV_r4 ) {
|
|
mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
|
|
} else if ( roughness >= cubeUV_r5 ) {
|
|
mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
|
|
} else if ( roughness >= cubeUV_r6 ) {
|
|
mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
|
|
} else {
|
|
mip = - 2.0 * log2( 1.16 * roughness ); }
|
|
return mip;
|
|
}
|
|
vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
|
|
float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
|
|
float mipF = fract( mip );
|
|
float mipInt = floor( mip );
|
|
vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
|
|
if ( mipF == 0.0 ) {
|
|
return vec4( color0, 1.0 );
|
|
} else {
|
|
vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
|
|
return vec4( mix( color0, color1, mipF ), 1.0 );
|
|
}
|
|
}
|
|
#endif`,Zd=`vec3 transformedNormal = objectNormal;
|
|
#ifdef USE_TANGENT
|
|
vec3 transformedTangent = objectTangent;
|
|
#endif
|
|
#ifdef USE_BATCHING
|
|
mat3 bm = mat3( batchingMatrix );
|
|
transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
|
|
transformedNormal = bm * transformedNormal;
|
|
#ifdef USE_TANGENT
|
|
transformedTangent = bm * transformedTangent;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_INSTANCING
|
|
mat3 im = mat3( instanceMatrix );
|
|
transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
|
|
transformedNormal = im * transformedNormal;
|
|
#ifdef USE_TANGENT
|
|
transformedTangent = im * transformedTangent;
|
|
#endif
|
|
#endif
|
|
transformedNormal = normalMatrix * transformedNormal;
|
|
#ifdef FLIP_SIDED
|
|
transformedNormal = - transformedNormal;
|
|
#endif
|
|
#ifdef USE_TANGENT
|
|
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
|
|
#ifdef FLIP_SIDED
|
|
transformedTangent = - transformedTangent;
|
|
#endif
|
|
#endif`,Jd=`#ifdef USE_DISPLACEMENTMAP
|
|
uniform sampler2D displacementMap;
|
|
uniform float displacementScale;
|
|
uniform float displacementBias;
|
|
#endif`,Qd=`#ifdef USE_DISPLACEMENTMAP
|
|
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
|
#endif`,ep=`#ifdef USE_EMISSIVEMAP
|
|
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
|
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
|
|
emissiveColor = sRGBTransferEOTF( emissiveColor );
|
|
#endif
|
|
totalEmissiveRadiance *= emissiveColor.rgb;
|
|
#endif`,tp=`#ifdef USE_EMISSIVEMAP
|
|
uniform sampler2D emissiveMap;
|
|
#endif`,np="gl_FragColor = linearToOutputTexel( gl_FragColor );",ip=`vec4 LinearTransferOETF( in vec4 value ) {
|
|
return value;
|
|
}
|
|
vec4 sRGBTransferEOTF( in vec4 value ) {
|
|
return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
|
|
}
|
|
vec4 sRGBTransferOETF( in vec4 value ) {
|
|
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 );
|
|
}`,rp=`#ifdef USE_ENVMAP
|
|
#ifdef ENV_WORLDPOS
|
|
vec3 cameraToFrag;
|
|
if ( isOrthographic ) {
|
|
cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
|
} else {
|
|
cameraToFrag = normalize( vWorldPosition - cameraPosition );
|
|
}
|
|
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
#ifdef ENVMAP_MODE_REFLECTION
|
|
vec3 reflectVec = reflect( cameraToFrag, worldNormal );
|
|
#else
|
|
vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
|
|
#endif
|
|
#else
|
|
vec3 reflectVec = vReflect;
|
|
#endif
|
|
#ifdef ENVMAP_TYPE_CUBE
|
|
vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
|
|
#else
|
|
vec4 envColor = vec4( 0.0 );
|
|
#endif
|
|
#ifdef ENVMAP_BLENDING_MULTIPLY
|
|
outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
|
|
#elif defined( ENVMAP_BLENDING_MIX )
|
|
outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
|
|
#elif defined( ENVMAP_BLENDING_ADD )
|
|
outgoingLight += envColor.xyz * specularStrength * reflectivity;
|
|
#endif
|
|
#endif`,sp=`#ifdef USE_ENVMAP
|
|
uniform float envMapIntensity;
|
|
uniform float flipEnvMap;
|
|
uniform mat3 envMapRotation;
|
|
#ifdef ENVMAP_TYPE_CUBE
|
|
uniform samplerCube envMap;
|
|
#else
|
|
uniform sampler2D envMap;
|
|
#endif
|
|
#endif`,ap=`#ifdef USE_ENVMAP
|
|
uniform float reflectivity;
|
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
#define ENV_WORLDPOS
|
|
#endif
|
|
#ifdef ENV_WORLDPOS
|
|
varying vec3 vWorldPosition;
|
|
uniform float refractionRatio;
|
|
#else
|
|
varying vec3 vReflect;
|
|
#endif
|
|
#endif`,op=`#ifdef USE_ENVMAP
|
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
#define ENV_WORLDPOS
|
|
#endif
|
|
#ifdef ENV_WORLDPOS
|
|
|
|
varying vec3 vWorldPosition;
|
|
#else
|
|
varying vec3 vReflect;
|
|
uniform float refractionRatio;
|
|
#endif
|
|
#endif`,lp=`#ifdef USE_ENVMAP
|
|
#ifdef ENV_WORLDPOS
|
|
vWorldPosition = worldPosition.xyz;
|
|
#else
|
|
vec3 cameraToVertex;
|
|
if ( isOrthographic ) {
|
|
cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
|
} else {
|
|
cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
|
|
}
|
|
vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
|
#ifdef ENVMAP_MODE_REFLECTION
|
|
vReflect = reflect( cameraToVertex, worldNormal );
|
|
#else
|
|
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
|
|
#endif
|
|
#endif
|
|
#endif`,cp=`#ifdef USE_FOG
|
|
vFogDepth = - mvPosition.z;
|
|
#endif`,up=`#ifdef USE_FOG
|
|
varying float vFogDepth;
|
|
#endif`,hp=`#ifdef USE_FOG
|
|
#ifdef FOG_EXP2
|
|
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
|
|
#else
|
|
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
|
|
#endif
|
|
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
|
|
#endif`,fp=`#ifdef USE_FOG
|
|
uniform vec3 fogColor;
|
|
varying float vFogDepth;
|
|
#ifdef FOG_EXP2
|
|
uniform float fogDensity;
|
|
#else
|
|
uniform float fogNear;
|
|
uniform float fogFar;
|
|
#endif
|
|
#endif`,dp=`#ifdef USE_GRADIENTMAP
|
|
uniform sampler2D gradientMap;
|
|
#endif
|
|
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
float dotNL = dot( normal, lightDirection );
|
|
vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
|
|
#ifdef USE_GRADIENTMAP
|
|
return vec3( texture2D( gradientMap, coord ).r );
|
|
#else
|
|
vec2 fw = fwidth( coord ) * 0.5;
|
|
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
|
|
#endif
|
|
}`,pp=`#ifdef USE_LIGHTMAP
|
|
uniform sampler2D lightMap;
|
|
uniform float lightMapIntensity;
|
|
#endif`,mp=`LambertMaterial material;
|
|
material.diffuseColor = diffuseColor.rgb;
|
|
material.specularStrength = specularStrength;`,gp=`varying vec3 vViewPosition;
|
|
struct LambertMaterial {
|
|
vec3 diffuseColor;
|
|
float specularStrength;
|
|
};
|
|
void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
|
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
|
vec3 irradiance = dotNL * directLight.color;
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
#define RE_Direct RE_Direct_Lambert
|
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,_p=`uniform bool receiveShadow;
|
|
uniform vec3 ambientLightColor;
|
|
#if defined( USE_LIGHT_PROBES )
|
|
uniform vec3 lightProbe[ 9 ];
|
|
#endif
|
|
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
|
|
float x = normal.x, y = normal.y, z = normal.z;
|
|
vec3 result = shCoefficients[ 0 ] * 0.886227;
|
|
result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
|
|
result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
|
|
result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
|
|
result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
|
|
result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
|
|
result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
|
|
result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
|
|
result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
|
|
return result;
|
|
}
|
|
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
|
|
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
|
|
return irradiance;
|
|
}
|
|
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
|
|
vec3 irradiance = ambientLightColor;
|
|
return irradiance;
|
|
}
|
|
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
|
|
float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
|
|
if ( cutoffDistance > 0.0 ) {
|
|
distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
|
|
}
|
|
return distanceFalloff;
|
|
}
|
|
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
|
|
return smoothstep( coneCosine, penumbraCosine, angleCosine );
|
|
}
|
|
#if NUM_DIR_LIGHTS > 0
|
|
struct DirectionalLight {
|
|
vec3 direction;
|
|
vec3 color;
|
|
};
|
|
uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
|
|
void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
|
|
light.color = directionalLight.color;
|
|
light.direction = directionalLight.direction;
|
|
light.visible = true;
|
|
}
|
|
#endif
|
|
#if NUM_POINT_LIGHTS > 0
|
|
struct PointLight {
|
|
vec3 position;
|
|
vec3 color;
|
|
float distance;
|
|
float decay;
|
|
};
|
|
uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
|
|
void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
|
|
vec3 lVector = pointLight.position - geometryPosition;
|
|
light.direction = normalize( lVector );
|
|
float lightDistance = length( lVector );
|
|
light.color = pointLight.color;
|
|
light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
|
|
light.visible = ( light.color != vec3( 0.0 ) );
|
|
}
|
|
#endif
|
|
#if NUM_SPOT_LIGHTS > 0
|
|
struct SpotLight {
|
|
vec3 position;
|
|
vec3 direction;
|
|
vec3 color;
|
|
float distance;
|
|
float decay;
|
|
float coneCos;
|
|
float penumbraCos;
|
|
};
|
|
uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
|
|
void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
|
|
vec3 lVector = spotLight.position - geometryPosition;
|
|
light.direction = normalize( lVector );
|
|
float angleCos = dot( light.direction, spotLight.direction );
|
|
float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
|
|
if ( spotAttenuation > 0.0 ) {
|
|
float lightDistance = length( lVector );
|
|
light.color = spotLight.color * spotAttenuation;
|
|
light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
|
|
light.visible = ( light.color != vec3( 0.0 ) );
|
|
} else {
|
|
light.color = vec3( 0.0 );
|
|
light.visible = false;
|
|
}
|
|
}
|
|
#endif
|
|
#if NUM_RECT_AREA_LIGHTS > 0
|
|
struct RectAreaLight {
|
|
vec3 color;
|
|
vec3 position;
|
|
vec3 halfWidth;
|
|
vec3 halfHeight;
|
|
};
|
|
uniform sampler2D ltc_1; uniform sampler2D ltc_2;
|
|
uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
|
|
#endif
|
|
#if NUM_HEMI_LIGHTS > 0
|
|
struct HemisphereLight {
|
|
vec3 direction;
|
|
vec3 skyColor;
|
|
vec3 groundColor;
|
|
};
|
|
uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
|
|
vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
|
|
float dotNL = dot( normal, hemiLight.direction );
|
|
float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
|
|
vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
|
|
return irradiance;
|
|
}
|
|
#endif`,xp=`#ifdef USE_ENVMAP
|
|
vec3 getIBLIrradiance( const in vec3 normal ) {
|
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
|
|
return PI * envMapColor.rgb * envMapIntensity;
|
|
#else
|
|
return vec3( 0.0 );
|
|
#endif
|
|
}
|
|
vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
|
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
vec3 reflectVec = reflect( - viewDir, normal );
|
|
reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
|
|
reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
|
|
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
|
|
return envMapColor.rgb * envMapIntensity;
|
|
#else
|
|
return vec3( 0.0 );
|
|
#endif
|
|
}
|
|
#ifdef USE_ANISOTROPY
|
|
vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
|
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
vec3 bentNormal = cross( bitangent, viewDir );
|
|
bentNormal = normalize( cross( bentNormal, bitangent ) );
|
|
bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
|
|
return getIBLRadiance( viewDir, bentNormal, roughness );
|
|
#else
|
|
return vec3( 0.0 );
|
|
#endif
|
|
}
|
|
#endif
|
|
#endif`,vp=`ToonMaterial material;
|
|
material.diffuseColor = diffuseColor.rgb;`,Mp=`varying vec3 vViewPosition;
|
|
struct ToonMaterial {
|
|
vec3 diffuseColor;
|
|
};
|
|
void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
|
|
vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
|
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
#define RE_Direct RE_Direct_Toon
|
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Sp=`BlinnPhongMaterial material;
|
|
material.diffuseColor = diffuseColor.rgb;
|
|
material.specularColor = specular;
|
|
material.specularShininess = shininess;
|
|
material.specularStrength = specularStrength;`,yp=`varying vec3 vViewPosition;
|
|
struct BlinnPhongMaterial {
|
|
vec3 diffuseColor;
|
|
vec3 specularColor;
|
|
float specularShininess;
|
|
float specularStrength;
|
|
};
|
|
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
|
|
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
|
vec3 irradiance = dotNL * directLight.color;
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
|
|
}
|
|
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
|
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
#define RE_Direct RE_Direct_BlinnPhong
|
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,bp=`PhysicalMaterial material;
|
|
material.diffuseColor = diffuseColor.rgb;
|
|
material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
|
material.metalness = metalnessFactor;
|
|
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
|
|
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
|
|
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
|
|
material.roughness = min( material.roughness, 1.0 );
|
|
#ifdef IOR
|
|
material.ior = ior;
|
|
#ifdef USE_SPECULAR
|
|
float specularIntensityFactor = specularIntensity;
|
|
vec3 specularColorFactor = specularColor;
|
|
#ifdef USE_SPECULAR_COLORMAP
|
|
specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
|
|
#endif
|
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
|
|
#endif
|
|
material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
|
|
#else
|
|
float specularIntensityFactor = 1.0;
|
|
vec3 specularColorFactor = vec3( 1.0 );
|
|
material.specularF90 = 1.0;
|
|
#endif
|
|
material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;
|
|
material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );
|
|
#else
|
|
material.specularColor = vec3( 0.04 );
|
|
material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );
|
|
material.specularF90 = 1.0;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
material.clearcoat = clearcoat;
|
|
material.clearcoatRoughness = clearcoatRoughness;
|
|
material.clearcoatF0 = vec3( 0.04 );
|
|
material.clearcoatF90 = 1.0;
|
|
#ifdef USE_CLEARCOATMAP
|
|
material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
|
|
#endif
|
|
material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
|
|
material.clearcoatRoughness += geometryRoughness;
|
|
material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
|
|
#endif
|
|
#ifdef USE_DISPERSION
|
|
material.dispersion = dispersion;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE
|
|
material.iridescence = iridescence;
|
|
material.iridescenceIOR = iridescenceIOR;
|
|
#ifdef USE_IRIDESCENCEMAP
|
|
material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
|
|
#else
|
|
material.iridescenceThickness = iridescenceThicknessMaximum;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
material.sheenColor = sheenColor;
|
|
#ifdef USE_SHEEN_COLORMAP
|
|
material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
|
|
#endif
|
|
material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );
|
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_ANISOTROPY
|
|
#ifdef USE_ANISOTROPYMAP
|
|
mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
|
|
vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
|
|
vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
|
|
#else
|
|
vec2 anisotropyV = anisotropyVector;
|
|
#endif
|
|
material.anisotropy = length( anisotropyV );
|
|
if( material.anisotropy == 0.0 ) {
|
|
anisotropyV = vec2( 1.0, 0.0 );
|
|
} else {
|
|
anisotropyV /= material.anisotropy;
|
|
material.anisotropy = saturate( material.anisotropy );
|
|
}
|
|
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
|
|
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
|
|
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
|
|
#endif`,Ep=`uniform sampler2D dfgLUT;
|
|
struct PhysicalMaterial {
|
|
vec3 diffuseColor;
|
|
vec3 diffuseContribution;
|
|
vec3 specularColor;
|
|
vec3 specularColorBlended;
|
|
float roughness;
|
|
float metalness;
|
|
float specularF90;
|
|
float dispersion;
|
|
#ifdef USE_CLEARCOAT
|
|
float clearcoat;
|
|
float clearcoatRoughness;
|
|
vec3 clearcoatF0;
|
|
float clearcoatF90;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE
|
|
float iridescence;
|
|
float iridescenceIOR;
|
|
float iridescenceThickness;
|
|
vec3 iridescenceFresnel;
|
|
vec3 iridescenceF0;
|
|
vec3 iridescenceFresnelDielectric;
|
|
vec3 iridescenceFresnelMetallic;
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
vec3 sheenColor;
|
|
float sheenRoughness;
|
|
#endif
|
|
#ifdef IOR
|
|
float ior;
|
|
#endif
|
|
#ifdef USE_TRANSMISSION
|
|
float transmission;
|
|
float transmissionAlpha;
|
|
float thickness;
|
|
float attenuationDistance;
|
|
vec3 attenuationColor;
|
|
#endif
|
|
#ifdef USE_ANISOTROPY
|
|
float anisotropy;
|
|
float alphaT;
|
|
vec3 anisotropyT;
|
|
vec3 anisotropyB;
|
|
#endif
|
|
};
|
|
vec3 clearcoatSpecularDirect = vec3( 0.0 );
|
|
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
|
|
vec3 sheenSpecularDirect = vec3( 0.0 );
|
|
vec3 sheenSpecularIndirect = vec3(0.0 );
|
|
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
|
|
float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
|
|
float x2 = x * x;
|
|
float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
|
|
return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
|
|
}
|
|
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
|
|
float a2 = pow2( alpha );
|
|
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
|
|
float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
|
|
return 0.5 / max( gv + gl, EPSILON );
|
|
}
|
|
float D_GGX( const in float alpha, const in float dotNH ) {
|
|
float a2 = pow2( alpha );
|
|
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
|
|
return RECIPROCAL_PI * a2 / pow2( denom );
|
|
}
|
|
#ifdef USE_ANISOTROPY
|
|
float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
|
|
float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
|
|
float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
|
|
float v = 0.5 / ( gv + gl );
|
|
return v;
|
|
}
|
|
float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
|
|
float a2 = alphaT * alphaB;
|
|
highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
|
|
highp float v2 = dot( v, v );
|
|
float w2 = a2 / v2;
|
|
return RECIPROCAL_PI * a2 * pow2 ( w2 );
|
|
}
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
|
|
vec3 f0 = material.clearcoatF0;
|
|
float f90 = material.clearcoatF90;
|
|
float roughness = material.clearcoatRoughness;
|
|
float alpha = pow2( roughness );
|
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|
float dotNL = saturate( dot( normal, lightDir ) );
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
float dotNH = saturate( dot( normal, halfDir ) );
|
|
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|
vec3 F = F_Schlick( f0, f90, dotVH );
|
|
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
|
float D = D_GGX( alpha, dotNH );
|
|
return F * ( V * D );
|
|
}
|
|
#endif
|
|
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
|
|
vec3 f0 = material.specularColorBlended;
|
|
float f90 = material.specularF90;
|
|
float roughness = material.roughness;
|
|
float alpha = pow2( roughness );
|
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|
float dotNL = saturate( dot( normal, lightDir ) );
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
float dotNH = saturate( dot( normal, halfDir ) );
|
|
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|
vec3 F = F_Schlick( f0, f90, dotVH );
|
|
#ifdef USE_IRIDESCENCE
|
|
F = mix( F, material.iridescenceFresnel, material.iridescence );
|
|
#endif
|
|
#ifdef USE_ANISOTROPY
|
|
float dotTL = dot( material.anisotropyT, lightDir );
|
|
float dotTV = dot( material.anisotropyT, viewDir );
|
|
float dotTH = dot( material.anisotropyT, halfDir );
|
|
float dotBL = dot( material.anisotropyB, lightDir );
|
|
float dotBV = dot( material.anisotropyB, viewDir );
|
|
float dotBH = dot( material.anisotropyB, halfDir );
|
|
float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
|
|
float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
|
|
#else
|
|
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
|
float D = D_GGX( alpha, dotNH );
|
|
#endif
|
|
return F * ( V * D );
|
|
}
|
|
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
|
|
const float LUT_SIZE = 64.0;
|
|
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
|
|
const float LUT_BIAS = 0.5 / LUT_SIZE;
|
|
float dotNV = saturate( dot( N, V ) );
|
|
vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
|
|
uv = uv * LUT_SCALE + LUT_BIAS;
|
|
return uv;
|
|
}
|
|
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
|
|
float l = length( f );
|
|
return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
|
|
}
|
|
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
|
|
float x = dot( v1, v2 );
|
|
float y = abs( x );
|
|
float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
|
|
float b = 3.4175940 + ( 4.1616724 + y ) * y;
|
|
float v = a / b;
|
|
float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
|
|
return cross( v1, v2 ) * theta_sintheta;
|
|
}
|
|
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
|
|
vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
|
|
vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
|
|
vec3 lightNormal = cross( v1, v2 );
|
|
if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
|
|
vec3 T1, T2;
|
|
T1 = normalize( V - N * dot( V, N ) );
|
|
T2 = - cross( N, T1 );
|
|
mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
|
|
vec3 coords[ 4 ];
|
|
coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
|
|
coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
|
|
coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
|
|
coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
|
|
coords[ 0 ] = normalize( coords[ 0 ] );
|
|
coords[ 1 ] = normalize( coords[ 1 ] );
|
|
coords[ 2 ] = normalize( coords[ 2 ] );
|
|
coords[ 3 ] = normalize( coords[ 3 ] );
|
|
vec3 vectorFormFactor = vec3( 0.0 );
|
|
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
|
|
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
|
|
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
|
|
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
|
|
float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
|
|
return vec3( result );
|
|
}
|
|
#if defined( USE_SHEEN )
|
|
float D_Charlie( float roughness, float dotNH ) {
|
|
float alpha = pow2( roughness );
|
|
float invAlpha = 1.0 / alpha;
|
|
float cos2h = dotNH * dotNH;
|
|
float sin2h = max( 1.0 - cos2h, 0.0078125 );
|
|
return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
|
|
}
|
|
float V_Neubelt( float dotNV, float dotNL ) {
|
|
return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
|
|
}
|
|
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
|
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|
float dotNL = saturate( dot( normal, lightDir ) );
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
float dotNH = saturate( dot( normal, halfDir ) );
|
|
float D = D_Charlie( sheenRoughness, dotNH );
|
|
float V = V_Neubelt( dotNV, dotNL );
|
|
return sheenColor * ( D * V );
|
|
}
|
|
#endif
|
|
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
float r2 = roughness * roughness;
|
|
float rInv = 1.0 / ( roughness + 0.1 );
|
|
float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;
|
|
float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;
|
|
float DG = exp( a * dotNV + b );
|
|
return saturate( DG );
|
|
}
|
|
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;
|
|
return specularColor * fab.x + specularF90 * fab.y;
|
|
}
|
|
#ifdef USE_IRIDESCENCE
|
|
void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
|
|
#else
|
|
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
|
|
#endif
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;
|
|
#ifdef USE_IRIDESCENCE
|
|
vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
|
|
#else
|
|
vec3 Fr = specularColor;
|
|
#endif
|
|
vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
|
|
float Ess = fab.x + fab.y;
|
|
float Ems = 1.0 - Ess;
|
|
vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
|
|
singleScatter += FssEss;
|
|
multiScatter += Fms * Ems;
|
|
}
|
|
vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
|
|
vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
|
|
float dotNL = saturate( dot( normal, lightDir ) );
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;
|
|
vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;
|
|
vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;
|
|
vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;
|
|
float Ess_V = dfgV.x + dfgV.y;
|
|
float Ess_L = dfgL.x + dfgL.y;
|
|
float Ems_V = 1.0 - Ess_V;
|
|
float Ems_L = 1.0 - Ess_L;
|
|
vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;
|
|
vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );
|
|
float compensationFactor = Ems_V * Ems_L;
|
|
vec3 multiScatter = Fms * compensationFactor;
|
|
return singleScatter + multiScatter;
|
|
}
|
|
#if NUM_RECT_AREA_LIGHTS > 0
|
|
void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
vec3 normal = geometryNormal;
|
|
vec3 viewDir = geometryViewDir;
|
|
vec3 position = geometryPosition;
|
|
vec3 lightPos = rectAreaLight.position;
|
|
vec3 halfWidth = rectAreaLight.halfWidth;
|
|
vec3 halfHeight = rectAreaLight.halfHeight;
|
|
vec3 lightColor = rectAreaLight.color;
|
|
float roughness = material.roughness;
|
|
vec3 rectCoords[ 4 ];
|
|
rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
|
|
rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
|
|
rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
|
|
vec2 uv = LTC_Uv( normal, viewDir, roughness );
|
|
vec4 t1 = texture2D( ltc_1, uv );
|
|
vec4 t2 = texture2D( ltc_2, uv );
|
|
mat3 mInv = mat3(
|
|
vec3( t1.x, 0, t1.y ),
|
|
vec3( 0, 1, 0 ),
|
|
vec3( t1.z, 0, t1.w )
|
|
);
|
|
vec3 fresnel = ( material.specularColorBlended * t2.x + ( vec3( 1.0 ) - material.specularColorBlended ) * t2.y );
|
|
reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
|
|
reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
|
|
}
|
|
#endif
|
|
void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
|
vec3 irradiance = dotNL * directLight.color;
|
|
#ifdef USE_CLEARCOAT
|
|
float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
|
|
vec3 ccIrradiance = dotNLcc * directLight.color;
|
|
clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
|
|
sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
|
|
|
|
float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
|
|
float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );
|
|
|
|
float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );
|
|
|
|
irradiance *= sheenEnergyComp;
|
|
|
|
#endif
|
|
reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );
|
|
}
|
|
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );
|
|
#ifdef USE_SHEEN
|
|
float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
|
|
float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;
|
|
diffuse *= sheenEnergyComp;
|
|
#endif
|
|
reflectedLight.indirectDiffuse += diffuse;
|
|
}
|
|
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
|
|
#ifdef USE_CLEARCOAT
|
|
clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;
|
|
#endif
|
|
vec3 singleScatteringDielectric = vec3( 0.0 );
|
|
vec3 multiScatteringDielectric = vec3( 0.0 );
|
|
vec3 singleScatteringMetallic = vec3( 0.0 );
|
|
vec3 multiScatteringMetallic = vec3( 0.0 );
|
|
#ifdef USE_IRIDESCENCE
|
|
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );
|
|
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );
|
|
#else
|
|
computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );
|
|
computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );
|
|
#endif
|
|
vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );
|
|
vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );
|
|
vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;
|
|
vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );
|
|
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
|
|
vec3 indirectSpecular = radiance * singleScattering;
|
|
indirectSpecular += multiScattering * cosineWeightedIrradiance;
|
|
vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;
|
|
#ifdef USE_SHEEN
|
|
float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
|
|
float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;
|
|
indirectSpecular *= sheenEnergyComp;
|
|
indirectDiffuse *= sheenEnergyComp;
|
|
#endif
|
|
reflectedLight.indirectSpecular += indirectSpecular;
|
|
reflectedLight.indirectDiffuse += indirectDiffuse;
|
|
}
|
|
#define RE_Direct RE_Direct_Physical
|
|
#define RE_Direct_RectArea RE_Direct_RectArea_Physical
|
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
|
|
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
|
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
|
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
|
}`,Tp=`
|
|
vec3 geometryPosition = - vViewPosition;
|
|
vec3 geometryNormal = normal;
|
|
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
vec3 geometryClearcoatNormal = vec3( 0.0 );
|
|
#ifdef USE_CLEARCOAT
|
|
geometryClearcoatNormal = clearcoatNormal;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE
|
|
float dotNVi = saturate( dot( normal, geometryViewDir ) );
|
|
if ( material.iridescenceThickness == 0.0 ) {
|
|
material.iridescence = 0.0;
|
|
} else {
|
|
material.iridescence = saturate( material.iridescence );
|
|
}
|
|
if ( material.iridescence > 0.0 ) {
|
|
material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
|
|
material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );
|
|
material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );
|
|
material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
|
|
}
|
|
#endif
|
|
IncidentLight directLight;
|
|
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
|
|
PointLight pointLight;
|
|
#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
|
|
PointLightShadow pointLightShadow;
|
|
#endif
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
|
|
pointLight = pointLights[ i ];
|
|
getPointLightInfo( pointLight, geometryPosition, directLight );
|
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )
|
|
pointLightShadow = pointLightShadows[ i ];
|
|
directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
|
|
#endif
|
|
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
|
|
SpotLight spotLight;
|
|
vec4 spotColor;
|
|
vec3 spotLightCoord;
|
|
bool inSpotLightMap;
|
|
#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
|
|
SpotLightShadow spotLightShadow;
|
|
#endif
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
|
|
spotLight = spotLights[ i ];
|
|
getSpotLightInfo( spotLight, geometryPosition, directLight );
|
|
#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
|
#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
|
|
#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
|
|
#else
|
|
#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
|
#endif
|
|
#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
|
|
spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
|
|
inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
|
|
spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
|
|
directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
|
|
#endif
|
|
#undef SPOT_LIGHT_MAP_INDEX
|
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
spotLightShadow = spotLightShadows[ i ];
|
|
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
|
#endif
|
|
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
|
|
DirectionalLight directionalLight;
|
|
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
|
|
DirectionalLightShadow directionalLightShadow;
|
|
#endif
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
|
|
directionalLight = directionalLights[ i ];
|
|
getDirectionalLightInfo( directionalLight, directLight );
|
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
|
|
directionalLightShadow = directionalLightShadows[ i ];
|
|
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
|
#endif
|
|
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
|
|
RectAreaLight rectAreaLight;
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
|
|
rectAreaLight = rectAreaLights[ i ];
|
|
RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if defined( RE_IndirectDiffuse )
|
|
vec3 iblIrradiance = vec3( 0.0 );
|
|
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
|
|
#if defined( USE_LIGHT_PROBES )
|
|
irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
|
|
#endif
|
|
#if ( NUM_HEMI_LIGHTS > 0 )
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
|
|
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#endif
|
|
#if defined( RE_IndirectSpecular )
|
|
vec3 radiance = vec3( 0.0 );
|
|
vec3 clearcoatRadiance = vec3( 0.0 );
|
|
#endif`,Ap=`#if defined( RE_IndirectDiffuse )
|
|
#ifdef USE_LIGHTMAP
|
|
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
|
irradiance += lightMapIrradiance;
|
|
#endif
|
|
#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
|
|
iblIrradiance += getIBLIrradiance( geometryNormal );
|
|
#endif
|
|
#endif
|
|
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
|
|
#ifdef USE_ANISOTROPY
|
|
radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
|
|
#else
|
|
radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
|
|
#endif
|
|
#endif`,wp=`#if defined( RE_IndirectDiffuse )
|
|
RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
#endif
|
|
#if defined( RE_IndirectSpecular )
|
|
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
#endif`,Rp=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
|
#endif`,Cp=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
uniform float logDepthBufFC;
|
|
varying float vFragDepth;
|
|
varying float vIsPerspective;
|
|
#endif`,Pp=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
varying float vFragDepth;
|
|
varying float vIsPerspective;
|
|
#endif`,Dp=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
vFragDepth = 1.0 + gl_Position.w;
|
|
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
#endif`,Lp=`#ifdef USE_MAP
|
|
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
|
#ifdef DECODE_VIDEO_TEXTURE
|
|
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
|
|
#endif
|
|
diffuseColor *= sampledDiffuseColor;
|
|
#endif`,Np=`#ifdef USE_MAP
|
|
uniform sampler2D map;
|
|
#endif`,Ip=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
#if defined( USE_POINTS_UV )
|
|
vec2 uv = vUv;
|
|
#else
|
|
vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_MAP
|
|
diffuseColor *= texture2D( map, uv );
|
|
#endif
|
|
#ifdef USE_ALPHAMAP
|
|
diffuseColor.a *= texture2D( alphaMap, uv ).g;
|
|
#endif`,Up=`#if defined( USE_POINTS_UV )
|
|
varying vec2 vUv;
|
|
#else
|
|
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
uniform mat3 uvTransform;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_MAP
|
|
uniform sampler2D map;
|
|
#endif
|
|
#ifdef USE_ALPHAMAP
|
|
uniform sampler2D alphaMap;
|
|
#endif`,Fp=`float metalnessFactor = metalness;
|
|
#ifdef USE_METALNESSMAP
|
|
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
|
metalnessFactor *= texelMetalness.b;
|
|
#endif`,Op=`#ifdef USE_METALNESSMAP
|
|
uniform sampler2D metalnessMap;
|
|
#endif`,Bp=`#ifdef USE_INSTANCING_MORPH
|
|
float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
|
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
|
|
}
|
|
#endif`,zp=`#if defined( USE_MORPHCOLORS )
|
|
vColor *= morphTargetBaseInfluence;
|
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
#if defined( USE_COLOR_ALPHA )
|
|
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
|
|
#elif defined( USE_COLOR )
|
|
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
|
|
#endif
|
|
}
|
|
#endif`,kp=`#ifdef USE_MORPHNORMALS
|
|
objectNormal *= morphTargetBaseInfluence;
|
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
|
|
}
|
|
#endif`,Vp=`#ifdef USE_MORPHTARGETS
|
|
#ifndef USE_INSTANCING_MORPH
|
|
uniform float morphTargetBaseInfluence;
|
|
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
#endif
|
|
uniform sampler2DArray morphTargetsTexture;
|
|
uniform ivec2 morphTargetsTextureSize;
|
|
vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
|
|
int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
|
|
int y = texelIndex / morphTargetsTextureSize.x;
|
|
int x = texelIndex - y * morphTargetsTextureSize.x;
|
|
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
|
|
return texelFetch( morphTargetsTexture, morphUV, 0 );
|
|
}
|
|
#endif`,Hp=`#ifdef USE_MORPHTARGETS
|
|
transformed *= morphTargetBaseInfluence;
|
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
|
|
}
|
|
#endif`,Gp=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
|
|
#ifdef FLAT_SHADED
|
|
vec3 fdx = dFdx( vViewPosition );
|
|
vec3 fdy = dFdy( vViewPosition );
|
|
vec3 normal = normalize( cross( fdx, fdy ) );
|
|
#else
|
|
vec3 normal = normalize( vNormal );
|
|
#ifdef DOUBLE_SIDED
|
|
normal *= faceDirection;
|
|
#endif
|
|
#endif
|
|
#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
|
|
#ifdef USE_TANGENT
|
|
mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
|
|
#else
|
|
mat3 tbn = getTangentFrame( - vViewPosition, normal,
|
|
#if defined( USE_NORMALMAP )
|
|
vNormalMapUv
|
|
#elif defined( USE_CLEARCOAT_NORMALMAP )
|
|
vClearcoatNormalMapUv
|
|
#else
|
|
vUv
|
|
#endif
|
|
);
|
|
#endif
|
|
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
|
|
tbn[0] *= faceDirection;
|
|
tbn[1] *= faceDirection;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
#ifdef USE_TANGENT
|
|
mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
|
|
#else
|
|
mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
|
|
#endif
|
|
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
|
|
tbn2[0] *= faceDirection;
|
|
tbn2[1] *= faceDirection;
|
|
#endif
|
|
#endif
|
|
vec3 nonPerturbedNormal = normal;`,Wp=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|
#ifdef FLIP_SIDED
|
|
normal = - normal;
|
|
#endif
|
|
#ifdef DOUBLE_SIDED
|
|
normal = normal * faceDirection;
|
|
#endif
|
|
normal = normalize( normalMatrix * normal );
|
|
#elif defined( USE_NORMALMAP_TANGENTSPACE )
|
|
vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|
mapN.xy *= normalScale;
|
|
normal = normalize( tbn * mapN );
|
|
#elif defined( USE_BUMPMAP )
|
|
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
|
|
#endif`,Xp=`#ifndef FLAT_SHADED
|
|
varying vec3 vNormal;
|
|
#ifdef USE_TANGENT
|
|
varying vec3 vTangent;
|
|
varying vec3 vBitangent;
|
|
#endif
|
|
#endif`,qp=`#ifndef FLAT_SHADED
|
|
varying vec3 vNormal;
|
|
#ifdef USE_TANGENT
|
|
varying vec3 vTangent;
|
|
varying vec3 vBitangent;
|
|
#endif
|
|
#endif`,Yp=`#ifndef FLAT_SHADED
|
|
vNormal = normalize( transformedNormal );
|
|
#ifdef USE_TANGENT
|
|
vTangent = normalize( transformedTangent );
|
|
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
|
|
#endif
|
|
#endif`,jp=`#ifdef USE_NORMALMAP
|
|
uniform sampler2D normalMap;
|
|
uniform vec2 normalScale;
|
|
#endif
|
|
#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
uniform mat3 normalMatrix;
|
|
#endif
|
|
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
|
|
mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
|
|
vec3 q0 = dFdx( eye_pos.xyz );
|
|
vec3 q1 = dFdy( eye_pos.xyz );
|
|
vec2 st0 = dFdx( uv.st );
|
|
vec2 st1 = dFdy( uv.st );
|
|
vec3 N = surf_norm;
|
|
vec3 q1perp = cross( q1, N );
|
|
vec3 q0perp = cross( N, q0 );
|
|
vec3 T = q1perp * st0.x + q0perp * st1.x;
|
|
vec3 B = q1perp * st0.y + q0perp * st1.y;
|
|
float det = max( dot( T, T ), dot( B, B ) );
|
|
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
|
|
return mat3( T * scale, B * scale, N );
|
|
}
|
|
#endif`,Kp=`#ifdef USE_CLEARCOAT
|
|
vec3 clearcoatNormal = nonPerturbedNormal;
|
|
#endif`,$p=`#ifdef USE_CLEARCOAT_NORMALMAP
|
|
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
|
clearcoatMapN.xy *= clearcoatNormalScale;
|
|
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
|
#endif`,Zp=`#ifdef USE_CLEARCOATMAP
|
|
uniform sampler2D clearcoatMap;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
uniform sampler2D clearcoatNormalMap;
|
|
uniform vec2 clearcoatNormalScale;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
uniform sampler2D clearcoatRoughnessMap;
|
|
#endif`,Jp=`#ifdef USE_IRIDESCENCEMAP
|
|
uniform sampler2D iridescenceMap;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
uniform sampler2D iridescenceThicknessMap;
|
|
#endif`,Qp=`#ifdef OPAQUE
|
|
diffuseColor.a = 1.0;
|
|
#endif
|
|
#ifdef USE_TRANSMISSION
|
|
diffuseColor.a *= material.transmissionAlpha;
|
|
#endif
|
|
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,em=`vec3 packNormalToRGB( const in vec3 normal ) {
|
|
return normalize( normal ) * 0.5 + 0.5;
|
|
}
|
|
vec3 unpackRGBToNormal( const in vec3 rgb ) {
|
|
return 2.0 * rgb.xyz - 1.0;
|
|
}
|
|
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
|
|
const float Inv255 = 1. / 255.;
|
|
const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
|
|
const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
|
|
const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
|
|
const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
|
|
vec4 packDepthToRGBA( const in float v ) {
|
|
if( v <= 0.0 )
|
|
return vec4( 0., 0., 0., 0. );
|
|
if( v >= 1.0 )
|
|
return vec4( 1., 1., 1., 1. );
|
|
float vuf;
|
|
float af = modf( v * PackFactors.a, vuf );
|
|
float bf = modf( vuf * ShiftRight8, vuf );
|
|
float gf = modf( vuf * ShiftRight8, vuf );
|
|
return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
|
|
}
|
|
vec3 packDepthToRGB( const in float v ) {
|
|
if( v <= 0.0 )
|
|
return vec3( 0., 0., 0. );
|
|
if( v >= 1.0 )
|
|
return vec3( 1., 1., 1. );
|
|
float vuf;
|
|
float bf = modf( v * PackFactors.b, vuf );
|
|
float gf = modf( vuf * ShiftRight8, vuf );
|
|
return vec3( vuf * Inv255, gf * PackUpscale, bf );
|
|
}
|
|
vec2 packDepthToRG( const in float v ) {
|
|
if( v <= 0.0 )
|
|
return vec2( 0., 0. );
|
|
if( v >= 1.0 )
|
|
return vec2( 1., 1. );
|
|
float vuf;
|
|
float gf = modf( v * 256., vuf );
|
|
return vec2( vuf * Inv255, gf );
|
|
}
|
|
float unpackRGBAToDepth( const in vec4 v ) {
|
|
return dot( v, UnpackFactors4 );
|
|
}
|
|
float unpackRGBToDepth( const in vec3 v ) {
|
|
return dot( v, UnpackFactors3 );
|
|
}
|
|
float unpackRGToDepth( const in vec2 v ) {
|
|
return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
|
|
}
|
|
vec4 pack2HalfToRGBA( const in vec2 v ) {
|
|
vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
|
|
return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
|
|
}
|
|
vec2 unpackRGBATo2Half( const in vec4 v ) {
|
|
return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
|
|
}
|
|
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
|
|
return ( viewZ + near ) / ( near - far );
|
|
}
|
|
float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
|
|
return depth * ( near - far ) - near;
|
|
}
|
|
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
|
|
return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
|
|
}
|
|
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
|
|
return ( near * far ) / ( ( far - near ) * depth - far );
|
|
}`,tm=`#ifdef PREMULTIPLIED_ALPHA
|
|
gl_FragColor.rgb *= gl_FragColor.a;
|
|
#endif`,nm=`vec4 mvPosition = vec4( transformed, 1.0 );
|
|
#ifdef USE_BATCHING
|
|
mvPosition = batchingMatrix * mvPosition;
|
|
#endif
|
|
#ifdef USE_INSTANCING
|
|
mvPosition = instanceMatrix * mvPosition;
|
|
#endif
|
|
mvPosition = modelViewMatrix * mvPosition;
|
|
gl_Position = projectionMatrix * mvPosition;`,im=`#ifdef DITHERING
|
|
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
|
#endif`,rm=`#ifdef DITHERING
|
|
vec3 dithering( vec3 color ) {
|
|
float grid_position = rand( gl_FragCoord.xy );
|
|
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
|
|
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
|
|
return color + dither_shift_RGB;
|
|
}
|
|
#endif`,sm=`float roughnessFactor = roughness;
|
|
#ifdef USE_ROUGHNESSMAP
|
|
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
|
roughnessFactor *= texelRoughness.g;
|
|
#endif`,am=`#ifdef USE_ROUGHNESSMAP
|
|
uniform sampler2D roughnessMap;
|
|
#endif`,om=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
#endif
|
|
#if NUM_SPOT_LIGHT_MAPS > 0
|
|
uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
|
|
#endif
|
|
#ifdef USE_SHADOWMAP
|
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
#if defined( SHADOWMAP_TYPE_PCF )
|
|
uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
|
|
#else
|
|
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
|
|
#endif
|
|
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
|
struct DirectionalLightShadow {
|
|
float shadowIntensity;
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
};
|
|
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
|
#endif
|
|
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
#if defined( SHADOWMAP_TYPE_PCF )
|
|
uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
#else
|
|
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
#endif
|
|
struct SpotLightShadow {
|
|
float shadowIntensity;
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
};
|
|
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
#endif
|
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
#if defined( SHADOWMAP_TYPE_PCF )
|
|
uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
|
|
#elif defined( SHADOWMAP_TYPE_BASIC )
|
|
uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
|
|
#endif
|
|
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
|
struct PointLightShadow {
|
|
float shadowIntensity;
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
float shadowCameraNear;
|
|
float shadowCameraFar;
|
|
};
|
|
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
#endif
|
|
#if defined( SHADOWMAP_TYPE_PCF )
|
|
float interleavedGradientNoise( vec2 position ) {
|
|
return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );
|
|
}
|
|
vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {
|
|
const float goldenAngle = 2.399963229728653;
|
|
float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );
|
|
float theta = float( sampleIndex ) * goldenAngle + phi;
|
|
return vec2( cos( theta ), sin( theta ) ) * r;
|
|
}
|
|
#endif
|
|
#if defined( SHADOWMAP_TYPE_PCF )
|
|
float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
|
|
float shadow = 1.0;
|
|
shadowCoord.xyz /= shadowCoord.w;
|
|
shadowCoord.z += shadowBias;
|
|
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
|
|
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
|
|
if ( frustumTest ) {
|
|
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
|
float radius = shadowRadius * texelSize.x;
|
|
float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;
|
|
shadow = (
|
|
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +
|
|
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +
|
|
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +
|
|
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +
|
|
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )
|
|
) * 0.2;
|
|
}
|
|
return mix( 1.0, shadow, shadowIntensity );
|
|
}
|
|
#elif defined( SHADOWMAP_TYPE_VSM )
|
|
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
|
|
float shadow = 1.0;
|
|
shadowCoord.xyz /= shadowCoord.w;
|
|
shadowCoord.z += shadowBias;
|
|
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
|
|
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
|
|
if ( frustumTest ) {
|
|
vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;
|
|
float mean = distribution.x;
|
|
float variance = distribution.y * distribution.y;
|
|
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
float hard_shadow = step( mean, shadowCoord.z );
|
|
#else
|
|
float hard_shadow = step( shadowCoord.z, mean );
|
|
#endif
|
|
if ( hard_shadow == 1.0 ) {
|
|
shadow = 1.0;
|
|
} else {
|
|
variance = max( variance, 0.0000001 );
|
|
float d = shadowCoord.z - mean;
|
|
float p_max = variance / ( variance + d * d );
|
|
p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );
|
|
shadow = max( hard_shadow, p_max );
|
|
}
|
|
}
|
|
return mix( 1.0, shadow, shadowIntensity );
|
|
}
|
|
#else
|
|
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
|
|
float shadow = 1.0;
|
|
shadowCoord.xyz /= shadowCoord.w;
|
|
shadowCoord.z += shadowBias;
|
|
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
|
|
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
|
|
if ( frustumTest ) {
|
|
float depth = texture2D( shadowMap, shadowCoord.xy ).r;
|
|
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
shadow = step( depth, shadowCoord.z );
|
|
#else
|
|
shadow = step( shadowCoord.z, depth );
|
|
#endif
|
|
}
|
|
return mix( 1.0, shadow, shadowIntensity );
|
|
}
|
|
#endif
|
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
#if defined( SHADOWMAP_TYPE_PCF )
|
|
float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
|
|
float shadow = 1.0;
|
|
vec3 lightToPosition = shadowCoord.xyz;
|
|
vec3 bd3D = normalize( lightToPosition );
|
|
vec3 absVec = abs( lightToPosition );
|
|
float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
|
|
if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
|
|
float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
|
|
dp += shadowBias;
|
|
float texelSize = shadowRadius / shadowMapSize.x;
|
|
vec3 absDir = abs( bd3D );
|
|
vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );
|
|
tangent = normalize( cross( bd3D, tangent ) );
|
|
vec3 bitangent = cross( bd3D, tangent );
|
|
float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;
|
|
shadow = (
|
|
texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 0, 5, phi ).x + bitangent * vogelDiskSample( 0, 5, phi ).y ) * texelSize, dp ) ) +
|
|
texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 1, 5, phi ).x + bitangent * vogelDiskSample( 1, 5, phi ).y ) * texelSize, dp ) ) +
|
|
texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 2, 5, phi ).x + bitangent * vogelDiskSample( 2, 5, phi ).y ) * texelSize, dp ) ) +
|
|
texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 3, 5, phi ).x + bitangent * vogelDiskSample( 3, 5, phi ).y ) * texelSize, dp ) ) +
|
|
texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 4, 5, phi ).x + bitangent * vogelDiskSample( 4, 5, phi ).y ) * texelSize, dp ) )
|
|
) * 0.2;
|
|
}
|
|
return mix( 1.0, shadow, shadowIntensity );
|
|
}
|
|
#elif defined( SHADOWMAP_TYPE_BASIC )
|
|
float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
|
|
float shadow = 1.0;
|
|
vec3 lightToPosition = shadowCoord.xyz;
|
|
vec3 bd3D = normalize( lightToPosition );
|
|
vec3 absVec = abs( lightToPosition );
|
|
float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
|
|
if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
|
|
float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
|
|
dp += shadowBias;
|
|
float depth = textureCube( shadowMap, bd3D ).r;
|
|
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
shadow = step( depth, dp );
|
|
#else
|
|
shadow = step( dp, depth );
|
|
#endif
|
|
}
|
|
return mix( 1.0, shadow, shadowIntensity );
|
|
}
|
|
#endif
|
|
#endif
|
|
#endif`,lm=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
|
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
#endif
|
|
#ifdef USE_SHADOWMAP
|
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
|
|
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
|
struct DirectionalLightShadow {
|
|
float shadowIntensity;
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
};
|
|
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
|
#endif
|
|
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
struct SpotLightShadow {
|
|
float shadowIntensity;
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
};
|
|
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
#endif
|
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
|
|
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
|
struct PointLightShadow {
|
|
float shadowIntensity;
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
float shadowCameraNear;
|
|
float shadowCameraFar;
|
|
};
|
|
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
#endif
|
|
#endif`,cm=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
|
|
vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
|
vec4 shadowWorldPosition;
|
|
#endif
|
|
#if defined( USE_SHADOWMAP )
|
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
|
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
|
|
vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
|
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
|
|
vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#endif
|
|
#if NUM_SPOT_LIGHT_COORDS > 0
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
|
|
shadowWorldPosition = worldPosition;
|
|
#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
|
|
#endif
|
|
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif`,um=`float getShadowMask() {
|
|
float shadow = 1.0;
|
|
#ifdef USE_SHADOWMAP
|
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
DirectionalLightShadow directionalLight;
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
|
directionalLight = directionalLightShadows[ i ];
|
|
shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
SpotLightShadow spotLight;
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
|
|
spotLight = spotLightShadows[ i ];
|
|
shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )
|
|
PointLightShadow pointLight;
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
|
pointLight = pointLightShadows[ i ];
|
|
shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#endif
|
|
return shadow;
|
|
}`,hm=`#ifdef USE_SKINNING
|
|
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
|
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
|
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
|
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
|
#endif`,fm=`#ifdef USE_SKINNING
|
|
uniform mat4 bindMatrix;
|
|
uniform mat4 bindMatrixInverse;
|
|
uniform highp sampler2D boneTexture;
|
|
mat4 getBoneMatrix( const in float i ) {
|
|
int size = textureSize( boneTexture, 0 ).x;
|
|
int j = int( i ) * 4;
|
|
int x = j % size;
|
|
int y = j / size;
|
|
vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
|
|
vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
|
|
vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
|
|
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
|
|
return mat4( v1, v2, v3, v4 );
|
|
}
|
|
#endif`,dm=`#ifdef USE_SKINNING
|
|
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
|
|
vec4 skinned = vec4( 0.0 );
|
|
skinned += boneMatX * skinVertex * skinWeight.x;
|
|
skinned += boneMatY * skinVertex * skinWeight.y;
|
|
skinned += boneMatZ * skinVertex * skinWeight.z;
|
|
skinned += boneMatW * skinVertex * skinWeight.w;
|
|
transformed = ( bindMatrixInverse * skinned ).xyz;
|
|
#endif`,pm=`#ifdef USE_SKINNING
|
|
mat4 skinMatrix = mat4( 0.0 );
|
|
skinMatrix += skinWeight.x * boneMatX;
|
|
skinMatrix += skinWeight.y * boneMatY;
|
|
skinMatrix += skinWeight.z * boneMatZ;
|
|
skinMatrix += skinWeight.w * boneMatW;
|
|
skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
|
|
objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
|
|
#ifdef USE_TANGENT
|
|
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
|
#endif
|
|
#endif`,mm=`float specularStrength;
|
|
#ifdef USE_SPECULARMAP
|
|
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
|
specularStrength = texelSpecular.r;
|
|
#else
|
|
specularStrength = 1.0;
|
|
#endif`,gm=`#ifdef USE_SPECULARMAP
|
|
uniform sampler2D specularMap;
|
|
#endif`,_m=`#if defined( TONE_MAPPING )
|
|
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
|
#endif`,xm=`#ifndef saturate
|
|
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|
#endif
|
|
uniform float toneMappingExposure;
|
|
vec3 LinearToneMapping( vec3 color ) {
|
|
return saturate( toneMappingExposure * color );
|
|
}
|
|
vec3 ReinhardToneMapping( vec3 color ) {
|
|
color *= toneMappingExposure;
|
|
return saturate( color / ( vec3( 1.0 ) + color ) );
|
|
}
|
|
vec3 CineonToneMapping( vec3 color ) {
|
|
color *= toneMappingExposure;
|
|
color = max( vec3( 0.0 ), color - 0.004 );
|
|
return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
|
|
}
|
|
vec3 RRTAndODTFit( vec3 v ) {
|
|
vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
|
|
vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
|
|
return a / b;
|
|
}
|
|
vec3 ACESFilmicToneMapping( vec3 color ) {
|
|
const mat3 ACESInputMat = mat3(
|
|
vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
|
|
vec3( 0.04823, 0.01566, 0.83777 )
|
|
);
|
|
const mat3 ACESOutputMat = mat3(
|
|
vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
|
|
vec3( -0.07367, -0.00605, 1.07602 )
|
|
);
|
|
color *= toneMappingExposure / 0.6;
|
|
color = ACESInputMat * color;
|
|
color = RRTAndODTFit( color );
|
|
color = ACESOutputMat * color;
|
|
return saturate( color );
|
|
}
|
|
const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
|
|
vec3( 1.6605, - 0.1246, - 0.0182 ),
|
|
vec3( - 0.5876, 1.1329, - 0.1006 ),
|
|
vec3( - 0.0728, - 0.0083, 1.1187 )
|
|
);
|
|
const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
|
|
vec3( 0.6274, 0.0691, 0.0164 ),
|
|
vec3( 0.3293, 0.9195, 0.0880 ),
|
|
vec3( 0.0433, 0.0113, 0.8956 )
|
|
);
|
|
vec3 agxDefaultContrastApprox( vec3 x ) {
|
|
vec3 x2 = x * x;
|
|
vec3 x4 = x2 * x2;
|
|
return + 15.5 * x4 * x2
|
|
- 40.14 * x4 * x
|
|
+ 31.96 * x4
|
|
- 6.868 * x2 * x
|
|
+ 0.4298 * x2
|
|
+ 0.1191 * x
|
|
- 0.00232;
|
|
}
|
|
vec3 AgXToneMapping( vec3 color ) {
|
|
const mat3 AgXInsetMatrix = mat3(
|
|
vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
|
|
vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
|
|
vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
|
|
);
|
|
const mat3 AgXOutsetMatrix = mat3(
|
|
vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
|
|
vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
|
|
vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
|
|
);
|
|
const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
|
|
color *= toneMappingExposure;
|
|
color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
|
|
color = AgXInsetMatrix * color;
|
|
color = max( color, 1e-10 ); color = log2( color );
|
|
color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
|
|
color = clamp( color, 0.0, 1.0 );
|
|
color = agxDefaultContrastApprox( color );
|
|
color = AgXOutsetMatrix * color;
|
|
color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
|
|
color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
|
|
color = clamp( color, 0.0, 1.0 );
|
|
return color;
|
|
}
|
|
vec3 NeutralToneMapping( vec3 color ) {
|
|
const float StartCompression = 0.8 - 0.04;
|
|
const float Desaturation = 0.15;
|
|
color *= toneMappingExposure;
|
|
float x = min( color.r, min( color.g, color.b ) );
|
|
float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
|
|
color -= offset;
|
|
float peak = max( color.r, max( color.g, color.b ) );
|
|
if ( peak < StartCompression ) return color;
|
|
float d = 1. - StartCompression;
|
|
float newPeak = 1. - d * d / ( peak + d - StartCompression );
|
|
color *= newPeak / peak;
|
|
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
|
|
return mix( color, vec3( newPeak ), g );
|
|
}
|
|
vec3 CustomToneMapping( vec3 color ) { return color; }`,vm=`#ifdef USE_TRANSMISSION
|
|
material.transmission = transmission;
|
|
material.transmissionAlpha = 1.0;
|
|
material.thickness = thickness;
|
|
material.attenuationDistance = attenuationDistance;
|
|
material.attenuationColor = attenuationColor;
|
|
#ifdef USE_TRANSMISSIONMAP
|
|
material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
|
|
#endif
|
|
#ifdef USE_THICKNESSMAP
|
|
material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
|
|
#endif
|
|
vec3 pos = vWorldPosition;
|
|
vec3 v = normalize( cameraPosition - pos );
|
|
vec3 n = inverseTransformDirection( normal, viewMatrix );
|
|
vec4 transmitted = getIBLVolumeRefraction(
|
|
n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,
|
|
pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
|
|
material.attenuationColor, material.attenuationDistance );
|
|
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
|
|
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
|
|
#endif`,Mm=`#ifdef USE_TRANSMISSION
|
|
uniform float transmission;
|
|
uniform float thickness;
|
|
uniform float attenuationDistance;
|
|
uniform vec3 attenuationColor;
|
|
#ifdef USE_TRANSMISSIONMAP
|
|
uniform sampler2D transmissionMap;
|
|
#endif
|
|
#ifdef USE_THICKNESSMAP
|
|
uniform sampler2D thicknessMap;
|
|
#endif
|
|
uniform vec2 transmissionSamplerSize;
|
|
uniform sampler2D transmissionSamplerMap;
|
|
uniform mat4 modelMatrix;
|
|
uniform mat4 projectionMatrix;
|
|
varying vec3 vWorldPosition;
|
|
float w0( float a ) {
|
|
return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
|
|
}
|
|
float w1( float a ) {
|
|
return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
|
|
}
|
|
float w2( float a ){
|
|
return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
|
|
}
|
|
float w3( float a ) {
|
|
return ( 1.0 / 6.0 ) * ( a * a * a );
|
|
}
|
|
float g0( float a ) {
|
|
return w0( a ) + w1( a );
|
|
}
|
|
float g1( float a ) {
|
|
return w2( a ) + w3( a );
|
|
}
|
|
float h0( float a ) {
|
|
return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
|
|
}
|
|
float h1( float a ) {
|
|
return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
|
|
}
|
|
vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
|
|
uv = uv * texelSize.zw + 0.5;
|
|
vec2 iuv = floor( uv );
|
|
vec2 fuv = fract( uv );
|
|
float g0x = g0( fuv.x );
|
|
float g1x = g1( fuv.x );
|
|
float h0x = h0( fuv.x );
|
|
float h1x = h1( fuv.x );
|
|
float h0y = h0( fuv.y );
|
|
float h1y = h1( fuv.y );
|
|
vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
|
|
vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
|
|
vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
|
|
vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
|
|
return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
|
|
g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
|
|
}
|
|
vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
|
|
vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
|
|
vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
|
|
vec2 fLodSizeInv = 1.0 / fLodSize;
|
|
vec2 cLodSizeInv = 1.0 / cLodSize;
|
|
vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
|
|
vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
|
|
return mix( fSample, cSample, fract( lod ) );
|
|
}
|
|
vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
|
|
vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
|
|
vec3 modelScale;
|
|
modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
|
|
modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
|
|
modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
|
|
return normalize( refractionVector ) * thickness * modelScale;
|
|
}
|
|
float applyIorToRoughness( const in float roughness, const in float ior ) {
|
|
return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
|
|
}
|
|
vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
|
|
float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
|
|
return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
|
|
}
|
|
vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
|
|
if ( isinf( attenuationDistance ) ) {
|
|
return vec3( 1.0 );
|
|
} else {
|
|
vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
|
|
vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
|
|
}
|
|
}
|
|
vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
|
|
const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
|
|
const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
|
|
const in vec3 attenuationColor, const in float attenuationDistance ) {
|
|
vec4 transmittedLight;
|
|
vec3 transmittance;
|
|
#ifdef USE_DISPERSION
|
|
float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
|
|
vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
|
|
for ( int i = 0; i < 3; i ++ ) {
|
|
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
|
|
vec3 refractedRayExit = position + transmissionRay;
|
|
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
|
|
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
|
|
refractionCoords += 1.0;
|
|
refractionCoords /= 2.0;
|
|
vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
|
|
transmittedLight[ i ] = transmissionSample[ i ];
|
|
transmittedLight.a += transmissionSample.a;
|
|
transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
|
|
}
|
|
transmittedLight.a /= 3.0;
|
|
#else
|
|
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
|
|
vec3 refractedRayExit = position + transmissionRay;
|
|
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
|
|
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
|
|
refractionCoords += 1.0;
|
|
refractionCoords /= 2.0;
|
|
transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
|
|
transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
|
|
#endif
|
|
vec3 attenuatedColor = transmittance * transmittedLight.rgb;
|
|
vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
|
|
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
|
|
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
|
|
}
|
|
#endif`,Sm=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
varying vec2 vUv;
|
|
#endif
|
|
#ifdef USE_MAP
|
|
varying vec2 vMapUv;
|
|
#endif
|
|
#ifdef USE_ALPHAMAP
|
|
varying vec2 vAlphaMapUv;
|
|
#endif
|
|
#ifdef USE_LIGHTMAP
|
|
varying vec2 vLightMapUv;
|
|
#endif
|
|
#ifdef USE_AOMAP
|
|
varying vec2 vAoMapUv;
|
|
#endif
|
|
#ifdef USE_BUMPMAP
|
|
varying vec2 vBumpMapUv;
|
|
#endif
|
|
#ifdef USE_NORMALMAP
|
|
varying vec2 vNormalMapUv;
|
|
#endif
|
|
#ifdef USE_EMISSIVEMAP
|
|
varying vec2 vEmissiveMapUv;
|
|
#endif
|
|
#ifdef USE_METALNESSMAP
|
|
varying vec2 vMetalnessMapUv;
|
|
#endif
|
|
#ifdef USE_ROUGHNESSMAP
|
|
varying vec2 vRoughnessMapUv;
|
|
#endif
|
|
#ifdef USE_ANISOTROPYMAP
|
|
varying vec2 vAnisotropyMapUv;
|
|
#endif
|
|
#ifdef USE_CLEARCOATMAP
|
|
varying vec2 vClearcoatMapUv;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
varying vec2 vClearcoatNormalMapUv;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
varying vec2 vClearcoatRoughnessMapUv;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCEMAP
|
|
varying vec2 vIridescenceMapUv;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
varying vec2 vIridescenceThicknessMapUv;
|
|
#endif
|
|
#ifdef USE_SHEEN_COLORMAP
|
|
varying vec2 vSheenColorMapUv;
|
|
#endif
|
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
varying vec2 vSheenRoughnessMapUv;
|
|
#endif
|
|
#ifdef USE_SPECULARMAP
|
|
varying vec2 vSpecularMapUv;
|
|
#endif
|
|
#ifdef USE_SPECULAR_COLORMAP
|
|
varying vec2 vSpecularColorMapUv;
|
|
#endif
|
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
varying vec2 vSpecularIntensityMapUv;
|
|
#endif
|
|
#ifdef USE_TRANSMISSIONMAP
|
|
uniform mat3 transmissionMapTransform;
|
|
varying vec2 vTransmissionMapUv;
|
|
#endif
|
|
#ifdef USE_THICKNESSMAP
|
|
uniform mat3 thicknessMapTransform;
|
|
varying vec2 vThicknessMapUv;
|
|
#endif`,ym=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
varying vec2 vUv;
|
|
#endif
|
|
#ifdef USE_MAP
|
|
uniform mat3 mapTransform;
|
|
varying vec2 vMapUv;
|
|
#endif
|
|
#ifdef USE_ALPHAMAP
|
|
uniform mat3 alphaMapTransform;
|
|
varying vec2 vAlphaMapUv;
|
|
#endif
|
|
#ifdef USE_LIGHTMAP
|
|
uniform mat3 lightMapTransform;
|
|
varying vec2 vLightMapUv;
|
|
#endif
|
|
#ifdef USE_AOMAP
|
|
uniform mat3 aoMapTransform;
|
|
varying vec2 vAoMapUv;
|
|
#endif
|
|
#ifdef USE_BUMPMAP
|
|
uniform mat3 bumpMapTransform;
|
|
varying vec2 vBumpMapUv;
|
|
#endif
|
|
#ifdef USE_NORMALMAP
|
|
uniform mat3 normalMapTransform;
|
|
varying vec2 vNormalMapUv;
|
|
#endif
|
|
#ifdef USE_DISPLACEMENTMAP
|
|
uniform mat3 displacementMapTransform;
|
|
varying vec2 vDisplacementMapUv;
|
|
#endif
|
|
#ifdef USE_EMISSIVEMAP
|
|
uniform mat3 emissiveMapTransform;
|
|
varying vec2 vEmissiveMapUv;
|
|
#endif
|
|
#ifdef USE_METALNESSMAP
|
|
uniform mat3 metalnessMapTransform;
|
|
varying vec2 vMetalnessMapUv;
|
|
#endif
|
|
#ifdef USE_ROUGHNESSMAP
|
|
uniform mat3 roughnessMapTransform;
|
|
varying vec2 vRoughnessMapUv;
|
|
#endif
|
|
#ifdef USE_ANISOTROPYMAP
|
|
uniform mat3 anisotropyMapTransform;
|
|
varying vec2 vAnisotropyMapUv;
|
|
#endif
|
|
#ifdef USE_CLEARCOATMAP
|
|
uniform mat3 clearcoatMapTransform;
|
|
varying vec2 vClearcoatMapUv;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
uniform mat3 clearcoatNormalMapTransform;
|
|
varying vec2 vClearcoatNormalMapUv;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
uniform mat3 clearcoatRoughnessMapTransform;
|
|
varying vec2 vClearcoatRoughnessMapUv;
|
|
#endif
|
|
#ifdef USE_SHEEN_COLORMAP
|
|
uniform mat3 sheenColorMapTransform;
|
|
varying vec2 vSheenColorMapUv;
|
|
#endif
|
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
uniform mat3 sheenRoughnessMapTransform;
|
|
varying vec2 vSheenRoughnessMapUv;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCEMAP
|
|
uniform mat3 iridescenceMapTransform;
|
|
varying vec2 vIridescenceMapUv;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
uniform mat3 iridescenceThicknessMapTransform;
|
|
varying vec2 vIridescenceThicknessMapUv;
|
|
#endif
|
|
#ifdef USE_SPECULARMAP
|
|
uniform mat3 specularMapTransform;
|
|
varying vec2 vSpecularMapUv;
|
|
#endif
|
|
#ifdef USE_SPECULAR_COLORMAP
|
|
uniform mat3 specularColorMapTransform;
|
|
varying vec2 vSpecularColorMapUv;
|
|
#endif
|
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
uniform mat3 specularIntensityMapTransform;
|
|
varying vec2 vSpecularIntensityMapUv;
|
|
#endif
|
|
#ifdef USE_TRANSMISSIONMAP
|
|
uniform mat3 transmissionMapTransform;
|
|
varying vec2 vTransmissionMapUv;
|
|
#endif
|
|
#ifdef USE_THICKNESSMAP
|
|
uniform mat3 thicknessMapTransform;
|
|
varying vec2 vThicknessMapUv;
|
|
#endif`,bm=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
vUv = vec3( uv, 1 ).xy;
|
|
#endif
|
|
#ifdef USE_MAP
|
|
vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_ALPHAMAP
|
|
vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_LIGHTMAP
|
|
vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_AOMAP
|
|
vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_BUMPMAP
|
|
vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_NORMALMAP
|
|
vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_DISPLACEMENTMAP
|
|
vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_EMISSIVEMAP
|
|
vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_METALNESSMAP
|
|
vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_ROUGHNESSMAP
|
|
vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_ANISOTROPYMAP
|
|
vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_CLEARCOATMAP
|
|
vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCEMAP
|
|
vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_SHEEN_COLORMAP
|
|
vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_SPECULARMAP
|
|
vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_SPECULAR_COLORMAP
|
|
vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_TRANSMISSIONMAP
|
|
vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_THICKNESSMAP
|
|
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
|
|
#endif`,Em=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
|
|
vec4 worldPosition = vec4( transformed, 1.0 );
|
|
#ifdef USE_BATCHING
|
|
worldPosition = batchingMatrix * worldPosition;
|
|
#endif
|
|
#ifdef USE_INSTANCING
|
|
worldPosition = instanceMatrix * worldPosition;
|
|
#endif
|
|
worldPosition = modelMatrix * worldPosition;
|
|
#endif`;const Tm=`varying vec2 vUv;
|
|
uniform mat3 uvTransform;
|
|
void main() {
|
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
|
}`,Am=`uniform sampler2D t2D;
|
|
uniform float backgroundIntensity;
|
|
varying vec2 vUv;
|
|
void main() {
|
|
vec4 texColor = texture2D( t2D, vUv );
|
|
#ifdef DECODE_VIDEO_TEXTURE
|
|
texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
|
|
#endif
|
|
texColor.rgb *= backgroundIntensity;
|
|
gl_FragColor = texColor;
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
}`,wm=`varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
gl_Position.z = gl_Position.w;
|
|
}`,Rm=`#ifdef ENVMAP_TYPE_CUBE
|
|
uniform samplerCube envMap;
|
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
uniform sampler2D envMap;
|
|
#endif
|
|
uniform float flipEnvMap;
|
|
uniform float backgroundBlurriness;
|
|
uniform float backgroundIntensity;
|
|
uniform mat3 backgroundRotation;
|
|
varying vec3 vWorldDirection;
|
|
#include <cube_uv_reflection_fragment>
|
|
void main() {
|
|
#ifdef ENVMAP_TYPE_CUBE
|
|
vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
|
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
|
|
#else
|
|
vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
|
|
#endif
|
|
texColor.rgb *= backgroundIntensity;
|
|
gl_FragColor = texColor;
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
}`,Cm=`varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
gl_Position.z = gl_Position.w;
|
|
}`,Pm=`uniform samplerCube tCube;
|
|
uniform float tFlip;
|
|
uniform float opacity;
|
|
varying vec3 vWorldDirection;
|
|
void main() {
|
|
vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
|
|
gl_FragColor = texColor;
|
|
gl_FragColor.a *= opacity;
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
}`,Dm=`#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
varying vec2 vHighPrecisionZW;
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <batching_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <morphinstance_vertex>
|
|
#ifdef USE_DISPLACEMENTMAP
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinnormal_vertex>
|
|
#endif
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vHighPrecisionZW = gl_Position.zw;
|
|
}`,Lm=`#if DEPTH_PACKING == 3200
|
|
uniform float opacity;
|
|
#endif
|
|
#include <common>
|
|
#include <packing>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
varying vec2 vHighPrecisionZW;
|
|
void main() {
|
|
vec4 diffuseColor = vec4( 1.0 );
|
|
#include <clipping_planes_fragment>
|
|
#if DEPTH_PACKING == 3200
|
|
diffuseColor.a = opacity;
|
|
#endif
|
|
#include <map_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <logdepthbuf_fragment>
|
|
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
|
|
#else
|
|
float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
|
|
#endif
|
|
#if DEPTH_PACKING == 3200
|
|
gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
|
|
#elif DEPTH_PACKING == 3201
|
|
gl_FragColor = packDepthToRGBA( fragCoordZ );
|
|
#elif DEPTH_PACKING == 3202
|
|
gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
|
|
#elif DEPTH_PACKING == 3203
|
|
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
|
|
#endif
|
|
}`,Nm=`#define DISTANCE
|
|
varying vec3 vWorldPosition;
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <batching_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <morphinstance_vertex>
|
|
#ifdef USE_DISPLACEMENTMAP
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinnormal_vertex>
|
|
#endif
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vWorldPosition = worldPosition.xyz;
|
|
}`,Im=`#define DISTANCE
|
|
uniform vec3 referencePosition;
|
|
uniform float nearDistance;
|
|
uniform float farDistance;
|
|
varying vec3 vWorldPosition;
|
|
#include <common>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main () {
|
|
vec4 diffuseColor = vec4( 1.0 );
|
|
#include <clipping_planes_fragment>
|
|
#include <map_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
float dist = length( vWorldPosition - referencePosition );
|
|
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
|
dist = saturate( dist );
|
|
gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
|
|
}`,Um=`varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
}`,Fm=`uniform sampler2D tEquirect;
|
|
varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vec3 direction = normalize( vWorldDirection );
|
|
vec2 sampleUV = equirectUv( direction );
|
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
}`,Om=`uniform float scale;
|
|
attribute float lineDistance;
|
|
varying float vLineDistance;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
vLineDistance = scale * lineDistance;
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <fog_vertex>
|
|
}`,Bm=`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
uniform float dashSize;
|
|
uniform float totalSize;
|
|
varying float vLineDistance;
|
|
#include <common>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
if ( mod( vLineDistance, totalSize ) > dashSize ) {
|
|
discard;
|
|
}
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
outgoingLight = diffuseColor.rgb;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
}`,zm=`#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <envmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#endif
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <envmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,km=`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
#ifndef FLAT_SHADED
|
|
varying vec3 vNormal;
|
|
#endif
|
|
#include <common>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <specularmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <specularmap_fragment>
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
#ifdef USE_LIGHTMAP
|
|
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
|
|
#else
|
|
reflectedLight.indirectDiffuse += vec3( 1.0 );
|
|
#endif
|
|
#include <aomap_fragment>
|
|
reflectedLight.indirectDiffuse *= diffuseColor.rgb;
|
|
vec3 outgoingLight = reflectedLight.indirectDiffuse;
|
|
#include <envmap_fragment>
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,Vm=`#define LAMBERT
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <envmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <envmap_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,Hm=`#define LAMBERT
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_lambert_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <specularmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <specularmap_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_lambert_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
|
#include <envmap_fragment>
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,Gm=`#define MATCAP
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <fog_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
}`,Wm=`#define MATCAP
|
|
uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
uniform sampler2D matcap;
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <normal_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
vec3 viewDir = normalize( vViewPosition );
|
|
vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
|
|
vec3 y = cross( viewDir, x );
|
|
vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
|
|
#ifdef USE_MATCAP
|
|
vec4 matcapColor = texture2D( matcap, uv );
|
|
#else
|
|
vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
|
|
#endif
|
|
vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,Xm=`#define NORMAL
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
varying vec3 vViewPosition;
|
|
#endif
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
vViewPosition = - mvPosition.xyz;
|
|
#endif
|
|
}`,qm=`#define NORMAL
|
|
uniform float opacity;
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
varying vec3 vViewPosition;
|
|
#endif
|
|
#include <uv_pars_fragment>
|
|
#include <normal_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
|
|
#include <clipping_planes_fragment>
|
|
#include <logdepthbuf_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );
|
|
#ifdef OPAQUE
|
|
gl_FragColor.a = 1.0;
|
|
#endif
|
|
}`,Ym=`#define PHONG
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <envmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <envmap_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,jm=`#define PHONG
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform vec3 specular;
|
|
uniform float shininess;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_phong_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <specularmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <specularmap_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_phong_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
|
|
#include <envmap_fragment>
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,Km=`#define STANDARD
|
|
varying vec3 vViewPosition;
|
|
#ifdef USE_TRANSMISSION
|
|
varying vec3 vWorldPosition;
|
|
#endif
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
#ifdef USE_TRANSMISSION
|
|
vWorldPosition = worldPosition.xyz;
|
|
#endif
|
|
}`,$m=`#define STANDARD
|
|
#ifdef PHYSICAL
|
|
#define IOR
|
|
#define USE_SPECULAR
|
|
#endif
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform float roughness;
|
|
uniform float metalness;
|
|
uniform float opacity;
|
|
#ifdef IOR
|
|
uniform float ior;
|
|
#endif
|
|
#ifdef USE_SPECULAR
|
|
uniform float specularIntensity;
|
|
uniform vec3 specularColor;
|
|
#ifdef USE_SPECULAR_COLORMAP
|
|
uniform sampler2D specularColorMap;
|
|
#endif
|
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
uniform sampler2D specularIntensityMap;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
uniform float clearcoat;
|
|
uniform float clearcoatRoughness;
|
|
#endif
|
|
#ifdef USE_DISPERSION
|
|
uniform float dispersion;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE
|
|
uniform float iridescence;
|
|
uniform float iridescenceIOR;
|
|
uniform float iridescenceThicknessMinimum;
|
|
uniform float iridescenceThicknessMaximum;
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
uniform vec3 sheenColor;
|
|
uniform float sheenRoughness;
|
|
#ifdef USE_SHEEN_COLORMAP
|
|
uniform sampler2D sheenColorMap;
|
|
#endif
|
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
uniform sampler2D sheenRoughnessMap;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_ANISOTROPY
|
|
uniform vec2 anisotropyVector;
|
|
#ifdef USE_ANISOTROPYMAP
|
|
uniform sampler2D anisotropyMap;
|
|
#endif
|
|
#endif
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <iridescence_fragment>
|
|
#include <cube_uv_reflection_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_physical_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_physical_pars_fragment>
|
|
#include <transmission_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <clearcoat_pars_fragment>
|
|
#include <iridescence_pars_fragment>
|
|
#include <roughnessmap_pars_fragment>
|
|
#include <metalnessmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <roughnessmap_fragment>
|
|
#include <metalnessmap_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <clearcoat_normal_fragment_begin>
|
|
#include <clearcoat_normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_physical_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
|
|
vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
|
|
#include <transmission_fragment>
|
|
vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
|
|
#ifdef USE_SHEEN
|
|
|
|
outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;
|
|
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
|
|
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
|
|
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
|
|
#endif
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,Zm=`#define TOON
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,Jm=`#define TOON
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <gradientmap_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_toon_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_toon_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,Qm=`uniform float size;
|
|
uniform float scale;
|
|
#include <common>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
#ifdef USE_POINTS_UV
|
|
varying vec2 vUv;
|
|
uniform mat3 uvTransform;
|
|
#endif
|
|
void main() {
|
|
#ifdef USE_POINTS_UV
|
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
#endif
|
|
#include <color_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <project_vertex>
|
|
gl_PointSize = size;
|
|
#ifdef USE_SIZEATTENUATION
|
|
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
|
if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
|
|
#endif
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <fog_vertex>
|
|
}`,eg=`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <color_pars_fragment>
|
|
#include <map_particle_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_particle_fragment>
|
|
#include <color_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
outgoingLight = diffuseColor.rgb;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
}`,tg=`#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
void main() {
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,ng=`uniform vec3 color;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <shadowmask_pars_fragment>
|
|
void main() {
|
|
#include <logdepthbuf_fragment>
|
|
gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
}`,ig=`uniform float rotation;
|
|
uniform vec2 center;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
vec4 mvPosition = modelViewMatrix[ 3 ];
|
|
vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
|
|
#ifndef USE_SIZEATTENUATION
|
|
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
|
if ( isPerspective ) scale *= - mvPosition.z;
|
|
#endif
|
|
vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
|
|
vec2 rotatedPosition;
|
|
rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
|
|
rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
|
|
mvPosition.xy += rotatedPosition;
|
|
gl_Position = projectionMatrix * mvPosition;
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <fog_vertex>
|
|
}`,rg=`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
outgoingLight = diffuseColor.rgb;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
}`,Xe={alphahash_fragment:Ad,alphahash_pars_fragment:wd,alphamap_fragment:Rd,alphamap_pars_fragment:Cd,alphatest_fragment:Pd,alphatest_pars_fragment:Dd,aomap_fragment:Ld,aomap_pars_fragment:Nd,batching_pars_vertex:Id,batching_vertex:Ud,begin_vertex:Fd,beginnormal_vertex:Od,bsdfs:Bd,iridescence_fragment:zd,bumpmap_pars_fragment:kd,clipping_planes_fragment:Vd,clipping_planes_pars_fragment:Hd,clipping_planes_pars_vertex:Gd,clipping_planes_vertex:Wd,color_fragment:Xd,color_pars_fragment:qd,color_pars_vertex:Yd,color_vertex:jd,common:Kd,cube_uv_reflection_fragment:$d,defaultnormal_vertex:Zd,displacementmap_pars_vertex:Jd,displacementmap_vertex:Qd,emissivemap_fragment:ep,emissivemap_pars_fragment:tp,colorspace_fragment:np,colorspace_pars_fragment:ip,envmap_fragment:rp,envmap_common_pars_fragment:sp,envmap_pars_fragment:ap,envmap_pars_vertex:op,envmap_physical_pars_fragment:xp,envmap_vertex:lp,fog_vertex:cp,fog_pars_vertex:up,fog_fragment:hp,fog_pars_fragment:fp,gradientmap_pars_fragment:dp,lightmap_pars_fragment:pp,lights_lambert_fragment:mp,lights_lambert_pars_fragment:gp,lights_pars_begin:_p,lights_toon_fragment:vp,lights_toon_pars_fragment:Mp,lights_phong_fragment:Sp,lights_phong_pars_fragment:yp,lights_physical_fragment:bp,lights_physical_pars_fragment:Ep,lights_fragment_begin:Tp,lights_fragment_maps:Ap,lights_fragment_end:wp,logdepthbuf_fragment:Rp,logdepthbuf_pars_fragment:Cp,logdepthbuf_pars_vertex:Pp,logdepthbuf_vertex:Dp,map_fragment:Lp,map_pars_fragment:Np,map_particle_fragment:Ip,map_particle_pars_fragment:Up,metalnessmap_fragment:Fp,metalnessmap_pars_fragment:Op,morphinstance_vertex:Bp,morphcolor_vertex:zp,morphnormal_vertex:kp,morphtarget_pars_vertex:Vp,morphtarget_vertex:Hp,normal_fragment_begin:Gp,normal_fragment_maps:Wp,normal_pars_fragment:Xp,normal_pars_vertex:qp,normal_vertex:Yp,normalmap_pars_fragment:jp,clearcoat_normal_fragment_begin:Kp,clearcoat_normal_fragment_maps:$p,clearcoat_pars_fragment:Zp,iridescence_pars_fragment:Jp,opaque_fragment:Qp,packing:em,premultiplied_alpha_fragment:tm,project_vertex:nm,dithering_fragment:im,dithering_pars_fragment:rm,roughnessmap_fragment:sm,roughnessmap_pars_fragment:am,shadowmap_pars_fragment:om,shadowmap_pars_vertex:lm,shadowmap_vertex:cm,shadowmask_pars_fragment:um,skinbase_vertex:hm,skinning_pars_vertex:fm,skinning_vertex:dm,skinnormal_vertex:pm,specularmap_fragment:mm,specularmap_pars_fragment:gm,tonemapping_fragment:_m,tonemapping_pars_fragment:xm,transmission_fragment:vm,transmission_pars_fragment:Mm,uv_pars_fragment:Sm,uv_pars_vertex:ym,uv_vertex:bm,worldpos_vertex:Em,background_vert:Tm,background_frag:Am,backgroundCube_vert:wm,backgroundCube_frag:Rm,cube_vert:Cm,cube_frag:Pm,depth_vert:Dm,depth_frag:Lm,distance_vert:Nm,distance_frag:Im,equirect_vert:Um,equirect_frag:Fm,linedashed_vert:Om,linedashed_frag:Bm,meshbasic_vert:zm,meshbasic_frag:km,meshlambert_vert:Vm,meshlambert_frag:Hm,meshmatcap_vert:Gm,meshmatcap_frag:Wm,meshnormal_vert:Xm,meshnormal_frag:qm,meshphong_vert:Ym,meshphong_frag:jm,meshphysical_vert:Km,meshphysical_frag:$m,meshtoon_vert:Zm,meshtoon_frag:Jm,points_vert:Qm,points_frag:eg,shadow_vert:tg,shadow_frag:ng,sprite_vert:ig,sprite_frag:rg},Me={common:{diffuse:{value:new Qe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new We},alphaMap:{value:null},alphaMapTransform:{value:new We},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new We}},envmap:{envMap:{value:null},envMapRotation:{value:new We},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new We}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new We}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new We},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new We},normalScale:{value:new Ge(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new We},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new We}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new We}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new We}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Qe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Qe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new We},alphaTest:{value:0},uvTransform:{value:new We}},sprite:{diffuse:{value:new Qe(16777215)},opacity:{value:1},center:{value:new Ge(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new We},alphaMap:{value:null},alphaMapTransform:{value:new We},alphaTest:{value:0}}},ln={basic:{uniforms:Nt([Me.common,Me.specularmap,Me.envmap,Me.aomap,Me.lightmap,Me.fog]),vertexShader:Xe.meshbasic_vert,fragmentShader:Xe.meshbasic_frag},lambert:{uniforms:Nt([Me.common,Me.specularmap,Me.envmap,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.fog,Me.lights,{emissive:{value:new Qe(0)}}]),vertexShader:Xe.meshlambert_vert,fragmentShader:Xe.meshlambert_frag},phong:{uniforms:Nt([Me.common,Me.specularmap,Me.envmap,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.fog,Me.lights,{emissive:{value:new Qe(0)},specular:{value:new Qe(1118481)},shininess:{value:30}}]),vertexShader:Xe.meshphong_vert,fragmentShader:Xe.meshphong_frag},standard:{uniforms:Nt([Me.common,Me.envmap,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.roughnessmap,Me.metalnessmap,Me.fog,Me.lights,{emissive:{value:new Qe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Xe.meshphysical_vert,fragmentShader:Xe.meshphysical_frag},toon:{uniforms:Nt([Me.common,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.gradientmap,Me.fog,Me.lights,{emissive:{value:new Qe(0)}}]),vertexShader:Xe.meshtoon_vert,fragmentShader:Xe.meshtoon_frag},matcap:{uniforms:Nt([Me.common,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.fog,{matcap:{value:null}}]),vertexShader:Xe.meshmatcap_vert,fragmentShader:Xe.meshmatcap_frag},points:{uniforms:Nt([Me.points,Me.fog]),vertexShader:Xe.points_vert,fragmentShader:Xe.points_frag},dashed:{uniforms:Nt([Me.common,Me.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Xe.linedashed_vert,fragmentShader:Xe.linedashed_frag},depth:{uniforms:Nt([Me.common,Me.displacementmap]),vertexShader:Xe.depth_vert,fragmentShader:Xe.depth_frag},normal:{uniforms:Nt([Me.common,Me.bumpmap,Me.normalmap,Me.displacementmap,{opacity:{value:1}}]),vertexShader:Xe.meshnormal_vert,fragmentShader:Xe.meshnormal_frag},sprite:{uniforms:Nt([Me.sprite,Me.fog]),vertexShader:Xe.sprite_vert,fragmentShader:Xe.sprite_frag},background:{uniforms:{uvTransform:{value:new We},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Xe.background_vert,fragmentShader:Xe.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new We}},vertexShader:Xe.backgroundCube_vert,fragmentShader:Xe.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Xe.cube_vert,fragmentShader:Xe.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Xe.equirect_vert,fragmentShader:Xe.equirect_frag},distance:{uniforms:Nt([Me.common,Me.displacementmap,{referencePosition:{value:new F},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Xe.distance_vert,fragmentShader:Xe.distance_frag},shadow:{uniforms:Nt([Me.lights,Me.fog,{color:{value:new Qe(0)},opacity:{value:1}}]),vertexShader:Xe.shadow_vert,fragmentShader:Xe.shadow_frag}};ln.physical={uniforms:Nt([ln.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new We},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new We},clearcoatNormalScale:{value:new Ge(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new We},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new We},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new We},sheen:{value:0},sheenColor:{value:new Qe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new We},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new We},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new We},transmissionSamplerSize:{value:new Ge},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new We},attenuationDistance:{value:0},attenuationColor:{value:new Qe(0)},specularColor:{value:new Qe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new We},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new We},anisotropyVector:{value:new Ge},anisotropyMap:{value:null},anisotropyMapTransform:{value:new We}}]),vertexShader:Xe.meshphysical_vert,fragmentShader:Xe.meshphysical_frag};const Ur={r:0,b:0,g:0},Yn=new Pn,sg=new ht;function ag(n,e,t,i,r,s,a){const o=new Qe(0);let l=s===!0?0:1,c,h,f=null,d=0,m=null;function g(v){let M=v.isScene===!0?v.background:null;return M&&M.isTexture&&(M=(v.backgroundBlurriness>0?t:e).get(M)),M}function x(v){let M=!1;const b=g(v);b===null?u(o,l):b&&b.isColor&&(u(b,1),M=!0);const w=n.xr.getEnvironmentBlendMode();w==="additive"?i.buffers.color.setClear(0,0,0,1,a):w==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,a),(n.autoClear||M)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function p(v,M){const b=g(M);b&&(b.isCubeTexture||b.mapping===is)?(h===void 0&&(h=new pn(new sr(1,1,1),new mn({name:"BackgroundCubeMaterial",uniforms:Pi(ln.backgroundCube.uniforms),vertexShader:ln.backgroundCube.vertexShader,fragmentShader:ln.backgroundCube.fragmentShader,side:Vt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(w,R,I){this.matrixWorld.copyPosition(I.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(h)),Yn.copy(M.backgroundRotation),Yn.x*=-1,Yn.y*=-1,Yn.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(Yn.y*=-1,Yn.z*=-1),h.material.uniforms.envMap.value=b,h.material.uniforms.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=M.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=M.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(sg.makeRotationFromEuler(Yn)),h.material.toneMapped=Ze.getTransfer(b.colorSpace)!==it,(f!==b||d!==b.version||m!==n.toneMapping)&&(h.material.needsUpdate=!0,f=b,d=b.version,m=n.toneMapping),h.layers.enableAll(),v.unshift(h,h.geometry,h.material,0,0,null)):b&&b.isTexture&&(c===void 0&&(c=new pn(new rs(2,2),new mn({name:"BackgroundMaterial",uniforms:Pi(ln.background.uniforms),vertexShader:ln.background.vertexShader,fragmentShader:ln.background.fragmentShader,side:kn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=b,c.material.uniforms.backgroundIntensity.value=M.backgroundIntensity,c.material.toneMapped=Ze.getTransfer(b.colorSpace)!==it,b.matrixAutoUpdate===!0&&b.updateMatrix(),c.material.uniforms.uvTransform.value.copy(b.matrix),(f!==b||d!==b.version||m!==n.toneMapping)&&(c.material.needsUpdate=!0,f=b,d=b.version,m=n.toneMapping),c.layers.enableAll(),v.unshift(c,c.geometry,c.material,0,0,null))}function u(v,M){v.getRGB(Ur,Dc(n)),i.buffers.color.setClear(Ur.r,Ur.g,Ur.b,M,a)}function y(){h!==void 0&&(h.geometry.dispose(),h.material.dispose(),h=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(v,M=1){o.set(v),l=M,u(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(v){l=v,u(o,l)},render:x,addToRenderList:p,dispose:y}}function og(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},r=d(null);let s=r,a=!1;function o(T,P,B,z,j){let K=!1;const L=f(z,B,P);s!==L&&(s=L,c(s.object)),K=m(T,z,B,j),K&&g(T,z,B,j),j!==null&&e.update(j,n.ELEMENT_ARRAY_BUFFER),(K||a)&&(a=!1,M(T,P,B,z),j!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(j).buffer))}function l(){return n.createVertexArray()}function c(T){return n.bindVertexArray(T)}function h(T){return n.deleteVertexArray(T)}function f(T,P,B){const z=B.wireframe===!0;let j=i[T.id];j===void 0&&(j={},i[T.id]=j);let K=j[P.id];K===void 0&&(K={},j[P.id]=K);let L=K[z];return L===void 0&&(L=d(l()),K[z]=L),L}function d(T){const P=[],B=[],z=[];for(let j=0;j<t;j++)P[j]=0,B[j]=0,z[j]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:P,enabledAttributes:B,attributeDivisors:z,object:T,attributes:{},index:null}}function m(T,P,B,z){const j=s.attributes,K=P.attributes;let L=0;const k=B.getAttributes();for(const Z in k)if(k[Z].location>=0){const V=j[Z];let W=K[Z];if(W===void 0&&(Z==="instanceMatrix"&&T.instanceMatrix&&(W=T.instanceMatrix),Z==="instanceColor"&&T.instanceColor&&(W=T.instanceColor)),V===void 0||V.attribute!==W||W&&V.data!==W.data)return!0;L++}return s.attributesNum!==L||s.index!==z}function g(T,P,B,z){const j={},K=P.attributes;let L=0;const k=B.getAttributes();for(const Z in k)if(k[Z].location>=0){let V=K[Z];V===void 0&&(Z==="instanceMatrix"&&T.instanceMatrix&&(V=T.instanceMatrix),Z==="instanceColor"&&T.instanceColor&&(V=T.instanceColor));const W={};W.attribute=V,V&&V.data&&(W.data=V.data),j[Z]=W,L++}s.attributes=j,s.attributesNum=L,s.index=z}function x(){const T=s.newAttributes;for(let P=0,B=T.length;P<B;P++)T[P]=0}function p(T){u(T,0)}function u(T,P){const B=s.newAttributes,z=s.enabledAttributes,j=s.attributeDivisors;B[T]=1,z[T]===0&&(n.enableVertexAttribArray(T),z[T]=1),j[T]!==P&&(n.vertexAttribDivisor(T,P),j[T]=P)}function y(){const T=s.newAttributes,P=s.enabledAttributes;for(let B=0,z=P.length;B<z;B++)P[B]!==T[B]&&(n.disableVertexAttribArray(B),P[B]=0)}function v(T,P,B,z,j,K,L){L===!0?n.vertexAttribIPointer(T,P,B,j,K):n.vertexAttribPointer(T,P,B,z,j,K)}function M(T,P,B,z){x();const j=z.attributes,K=B.getAttributes(),L=P.defaultAttributeValues;for(const k in K){const Z=K[k];if(Z.location>=0){let re=j[k];if(re===void 0&&(k==="instanceMatrix"&&T.instanceMatrix&&(re=T.instanceMatrix),k==="instanceColor"&&T.instanceColor&&(re=T.instanceColor)),re!==void 0){const V=re.normalized,W=re.itemSize,ce=e.get(re);if(ce===void 0)continue;const se=ce.buffer,we=ce.type,Se=ce.bytesPerElement,Y=we===n.INT||we===n.UNSIGNED_INT||re.gpuType===Ka;if(re.isInterleavedBufferAttribute){const Q=re.data,ge=Q.stride,Ce=re.offset;if(Q.isInstancedInterleavedBuffer){for(let le=0;le<Z.locationSize;le++)u(Z.location+le,Q.meshPerAttribute);T.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=Q.meshPerAttribute*Q.count)}else for(let le=0;le<Z.locationSize;le++)p(Z.location+le);n.bindBuffer(n.ARRAY_BUFFER,se);for(let le=0;le<Z.locationSize;le++)v(Z.location+le,W/Z.locationSize,we,V,ge*Se,(Ce+W/Z.locationSize*le)*Se,Y)}else{if(re.isInstancedBufferAttribute){for(let Q=0;Q<Z.locationSize;Q++)u(Z.location+Q,re.meshPerAttribute);T.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=re.meshPerAttribute*re.count)}else for(let Q=0;Q<Z.locationSize;Q++)p(Z.location+Q);n.bindBuffer(n.ARRAY_BUFFER,se);for(let Q=0;Q<Z.locationSize;Q++)v(Z.location+Q,W/Z.locationSize,we,V,W*Se,W/Z.locationSize*Q*Se,Y)}}else if(L!==void 0){const V=L[k];if(V!==void 0)switch(V.length){case 2:n.vertexAttrib2fv(Z.location,V);break;case 3:n.vertexAttrib3fv(Z.location,V);break;case 4:n.vertexAttrib4fv(Z.location,V);break;default:n.vertexAttrib1fv(Z.location,V)}}}}y()}function b(){I();for(const T in i){const P=i[T];for(const B in P){const z=P[B];for(const j in z)h(z[j].object),delete z[j];delete P[B]}delete i[T]}}function w(T){if(i[T.id]===void 0)return;const P=i[T.id];for(const B in P){const z=P[B];for(const j in z)h(z[j].object),delete z[j];delete P[B]}delete i[T.id]}function R(T){for(const P in i){const B=i[P];if(B[T.id]===void 0)continue;const z=B[T.id];for(const j in z)h(z[j].object),delete z[j];delete B[T.id]}}function I(){S(),a=!0,s!==r&&(s=r,c(s.object))}function S(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:o,reset:I,resetDefaultState:S,dispose:b,releaseStatesOfGeometry:w,releaseStatesOfProgram:R,initAttributes:x,enableAttribute:p,disableUnusedAttributes:y}}function lg(n,e,t){let i;function r(c){i=c}function s(c,h){n.drawArrays(i,c,h),t.update(h,i,1)}function a(c,h,f){f!==0&&(n.drawArraysInstanced(i,c,h,f),t.update(h,i,f))}function o(c,h,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,h,0,f);let m=0;for(let g=0;g<f;g++)m+=h[g];t.update(m,i,1)}function l(c,h,f,d){if(f===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let g=0;g<c.length;g++)a(c[g],h[g],d[g]);else{m.multiDrawArraysInstancedWEBGL(i,c,0,h,0,d,0,f);let g=0;for(let x=0;x<f;x++)g+=h[x]*d[x];t.update(g,i,1)}}this.setMode=r,this.render=s,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function cg(n,e,t,i){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=n.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(R){return!(R!==rn&&i.convert(R)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(R){const I=R===Rn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(R!==Jt&&i.convert(R)!==n.getParameter(n.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==cn&&!I)}function l(R){if(R==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const h=l(c);h!==c&&(Be("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const f=t.logarithmicDepthBuffer===!0,d=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),m=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),g=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=n.getParameter(n.MAX_TEXTURE_SIZE),p=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),u=n.getParameter(n.MAX_VERTEX_ATTRIBS),y=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),v=n.getParameter(n.MAX_VARYING_VECTORS),M=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),b=n.getParameter(n.MAX_SAMPLES),w=n.getParameter(n.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:f,reversedDepthBuffer:d,maxTextures:m,maxVertexTextures:g,maxTextureSize:x,maxCubemapSize:p,maxAttributes:u,maxVertexUniforms:y,maxVaryings:v,maxFragmentUniforms:M,maxSamples:b,samples:w}}function ug(n){const e=this;let t=null,i=0,r=!1,s=!1;const a=new On,o=new We,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(f,d){const m=f.length!==0||d||i!==0||r;return r=d,i=f.length,m},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,d){t=h(f,d,0)},this.setState=function(f,d,m){const g=f.clippingPlanes,x=f.clipIntersection,p=f.clipShadows,u=n.get(f);if(!r||g===null||g.length===0||s&&!p)s?h(null):c();else{const y=s?0:i,v=y*4;let M=u.clippingState||null;l.value=M,M=h(g,d,v,m);for(let b=0;b!==v;++b)M[b]=t[b];u.clippingState=M,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=y}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function h(f,d,m,g){const x=f!==null?f.length:0;let p=null;if(x!==0){if(p=l.value,g!==!0||p===null){const u=m+x*4,y=d.matrixWorldInverse;o.getNormalMatrix(y),(p===null||p.length<u)&&(p=new Float32Array(u));for(let v=0,M=m;v!==x;++v,M+=4)a.copy(f[v]).applyMatrix4(y,o),a.normal.toArray(p,M),p[M+3]=a.constant}l.value=p,l.needsUpdate=!0}return e.numPlanes=x,e.numIntersection=0,p}}function hg(n){let e=new WeakMap;function t(a,o){return o===ia?a.mapping=ei:o===ra&&(a.mapping=wi),a}function i(a){if(a&&a.isTexture){const o=a.mapping;if(o===ia||o===ra)if(e.has(a)){const l=e.get(a).texture;return t(l,a.mapping)}else{const l=a.image;if(l&&l.height>0){const c=new Ic(l.height);return c.fromEquirectangularTexture(n,a),e.set(a,c),a.addEventListener("dispose",r),t(c.texture,a.mapping)}else return null}}return a}function r(a){const o=a.target;o.removeEventListener("dispose",r);const l=e.get(o);l!==void 0&&(e.delete(o),l.dispose())}function s(){e=new WeakMap}return{get:i,dispose:s}}const zn=4,gl=[.125,.215,.35,.446,.526,.582],$n=20,fg=256,Wi=new Bc,_l=new Qe;let Bs=null,zs=0,ks=0,Vs=!1;const dg=new F;class xl{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,i=.1,r=100,s={}){const{size:a=256,position:o=dg}=s;Bs=this._renderer.getRenderTarget(),zs=this._renderer.getActiveCubeFace(),ks=this._renderer.getActiveMipmapLevel(),Vs=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,i,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=Sl(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Ml(),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(Bs,zs,ks),this._renderer.xr.enabled=Vs,e.scissorTest=!1,xi(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===ei||e.mapping===wi?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Bs=this._renderer.getRenderTarget(),zs=this._renderer.getActiveCubeFace(),ks=this._renderer.getActiveMipmapLevel(),Vs=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:Rt,minFilter:Rt,generateMipmaps:!1,type:Rn,format:rn,colorSpace:Ci,depthBuffer:!1},r=vl(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=vl(e,t,i);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=pg(s)),this._blurMaterial=gg(s,e,t),this._ggxMaterial=mg(s,e,t)}return r}_compileMaterial(e){const t=new pn(new Ct,e);this._renderer.compile(t,Wi)}_sceneToCubeUV(e,t,i,r,s){const l=new Zt(90,1,t,i),c=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],f=this._renderer,d=f.autoClear,m=f.toneMapping;f.getClearColor(_l),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 pn(new sr,new so({name:"PMREM.Background",side:Vt,depthWrite:!1,depthTest:!1})));const x=this._backgroundBox,p=x.material;let u=!1;const y=e.background;y?y.isColor&&(p.color.copy(y),e.background=null,u=!0):(p.color.copy(_l),u=!0);for(let v=0;v<6;v++){const M=v%3;M===0?(l.up.set(0,c[v],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x+h[v],s.y,s.z)):M===1?(l.up.set(0,0,c[v]),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y+h[v],s.z)):(l.up.set(0,c[v],0),l.position.set(s.x,s.y,s.z),l.lookAt(s.x,s.y,s.z+h[v]));const b=this._cubeSize;xi(r,M*b,v>2?b:0,b,b),f.setRenderTarget(r),u&&f.render(x,l),f.render(e,l)}f.toneMapping=m,f.autoClear=d,e.background=y}_textureToCubeUV(e,t){const i=this._renderer,r=e.mapping===ei||e.mapping===wi;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=Sl()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Ml());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;xi(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(a,Wi)}_applyPMREM(e){const t=this._renderer,i=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=i}_applyGGXFilter(e,t,i){const r=this._renderer,s=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[i];o.material=a;const l=a.uniforms,c=i/(this._lodMeshes.length-1),h=t/(this._lodMeshes.length-1),f=Math.sqrt(c*c-h*h),d=0+c*1.25,m=f*d,{_lodMax:g}=this,x=this._sizeLods[i],p=3*x*(i>g-zn?i-g+zn:0),u=4*(this._cubeSize-x);l.envMap.value=e.texture,l.roughness.value=m,l.mipInt.value=g-t,xi(s,p,u,3*x,2*x),r.setRenderTarget(s),r.render(o,Wi),l.envMap.value=s.texture,l.roughness.value=0,l.mipInt.value=g-i,xi(e,p,u,3*x,2*x),r.setRenderTarget(e),r.render(o,Wi)}_blur(e,t,i,r,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,r,"latitudinal",s),this._halfBlur(a,e,i,i,r,"longitudinal",s)}_halfBlur(e,t,i,r,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&$e("blur direction must be either latitudinal or longitudinal!");const h=3,f=this._lodMeshes[r];f.material=c;const d=c.uniforms,m=this._sizeLods[i]-1,g=isFinite(s)?Math.PI/(2*m):2*Math.PI/(2*$n-1),x=s/g,p=isFinite(s)?1+Math.floor(h*x):$n;p>$n&&Be(`sigmaRadians, ${s}, is too large and will clip, as it requested ${p} samples when the maximum is set to ${$n}`);const u=[];let y=0;for(let R=0;R<$n;++R){const I=R/x,S=Math.exp(-I*I/2);u.push(S),R===0?y+=S:R<p&&(y+=2*S)}for(let R=0;R<u.length;R++)u[R]=u[R]/y;d.envMap.value=e.texture,d.samples.value=p,d.weights.value=u,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:v}=this;d.dTheta.value=g,d.mipInt.value=v-i;const M=this._sizeLods[r],b=3*M*(r>v-zn?r-v+zn:0),w=4*(this._cubeSize-M);xi(t,b,w,3*M,2*M),l.setRenderTarget(t),l.render(f,Wi)}}function pg(n){const e=[],t=[],i=[];let r=n;const s=n-zn+1+gl.length;for(let a=0;a<s;a++){const o=Math.pow(2,r);e.push(o);let l=1/o;a>n-zn?l=gl[a-n+zn-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),h=-c,f=1+c,d=[h,h,f,h,f,f,h,h,f,f,h,f],m=6,g=6,x=3,p=2,u=1,y=new Float32Array(x*g*m),v=new Float32Array(p*g*m),M=new Float32Array(u*g*m);for(let w=0;w<m;w++){const R=w%3*2/3-1,I=w>2?0:-1,S=[R,I,0,R+2/3,I,0,R+2/3,I+1,0,R,I,0,R+2/3,I+1,0,R,I+1,0];y.set(S,x*g*w),v.set(d,p*g*w);const T=[w,w,w,w,w,w];M.set(T,u*g*w)}const b=new Ct;b.setAttribute("position",new Ut(y,x)),b.setAttribute("uv",new Ut(v,p)),b.setAttribute("faceIndex",new Ut(M,u)),i.push(new pn(b,null)),r>zn&&r--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function vl(n,e,t){const i=new fn(n,e,t);return i.texture.mapping=is,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function xi(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function mg(n,e,t){return new mn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:fg,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:ss(),fragmentShader:`
|
|
|
|
precision highp float;
|
|
precision highp int;
|
|
|
|
varying vec3 vOutputDirection;
|
|
|
|
uniform sampler2D envMap;
|
|
uniform float roughness;
|
|
uniform float mipInt;
|
|
|
|
#define ENVMAP_TYPE_CUBE_UV
|
|
#include <cube_uv_reflection_fragment>
|
|
|
|
#define PI 3.14159265359
|
|
|
|
// Van der Corput radical inverse
|
|
float radicalInverse_VdC(uint bits) {
|
|
bits = (bits << 16u) | (bits >> 16u);
|
|
bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
|
|
bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
|
|
bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
|
|
bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
|
|
return float(bits) * 2.3283064365386963e-10; // / 0x100000000
|
|
}
|
|
|
|
// Hammersley sequence
|
|
vec2 hammersley(uint i, uint N) {
|
|
return vec2(float(i) / float(N), radicalInverse_VdC(i));
|
|
}
|
|
|
|
// GGX VNDF importance sampling (Eric Heitz 2018)
|
|
// "Sampling the GGX Distribution of Visible Normals"
|
|
// https://jcgt.org/published/0007/04/01/
|
|
vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
|
|
float alpha = roughness * roughness;
|
|
|
|
// Section 3.2: Transform view direction to hemisphere configuration
|
|
vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
|
|
|
|
// Section 4.1: Orthonormal basis
|
|
float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
|
|
vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
|
|
vec3 T2 = cross(Vh, T1);
|
|
|
|
// Section 4.2: Parameterization of projected area
|
|
float r = sqrt(Xi.x);
|
|
float phi = 2.0 * PI * Xi.y;
|
|
float t1 = r * cos(phi);
|
|
float t2 = r * sin(phi);
|
|
float s = 0.5 * (1.0 + Vh.z);
|
|
t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
|
|
|
|
// Section 4.3: Reprojection onto hemisphere
|
|
vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
|
|
|
|
// Section 3.4: Transform back to ellipsoid configuration
|
|
return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
|
|
}
|
|
|
|
void main() {
|
|
vec3 N = normalize(vOutputDirection);
|
|
vec3 V = N; // Assume view direction equals normal for pre-filtering
|
|
|
|
vec3 prefilteredColor = vec3(0.0);
|
|
float totalWeight = 0.0;
|
|
|
|
// For very low roughness, just sample the environment directly
|
|
if (roughness < 0.001) {
|
|
gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
|
|
return;
|
|
}
|
|
|
|
// Tangent space basis for VNDF sampling
|
|
vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
|
|
vec3 tangent = normalize(cross(up, N));
|
|
vec3 bitangent = cross(N, tangent);
|
|
|
|
for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
|
|
vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
|
|
|
|
// For PMREM, V = N, so in tangent space V is always (0, 0, 1)
|
|
vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
|
|
|
|
// Transform H back to world space
|
|
vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
|
|
vec3 L = normalize(2.0 * dot(V, H) * H - V);
|
|
|
|
float NdotL = max(dot(N, L), 0.0);
|
|
|
|
if(NdotL > 0.0) {
|
|
// Sample environment at fixed mip level
|
|
// VNDF importance sampling handles the distribution filtering
|
|
vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
|
|
|
|
// Weight by NdotL for the split-sum approximation
|
|
// VNDF PDF naturally accounts for the visible microfacet distribution
|
|
prefilteredColor += sampleColor * NdotL;
|
|
totalWeight += NdotL;
|
|
}
|
|
}
|
|
|
|
if (totalWeight > 0.0) {
|
|
prefilteredColor = prefilteredColor / totalWeight;
|
|
}
|
|
|
|
gl_FragColor = vec4(prefilteredColor, 1.0);
|
|
}
|
|
`,blending:An,depthTest:!1,depthWrite:!1})}function gg(n,e,t){const i=new Float32Array($n),r=new F(0,1,0);return new mn({name:"SphericalGaussianBlur",defines:{n:$n,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:ss(),fragmentShader:`
|
|
|
|
precision mediump float;
|
|
precision mediump int;
|
|
|
|
varying vec3 vOutputDirection;
|
|
|
|
uniform sampler2D envMap;
|
|
uniform int samples;
|
|
uniform float weights[ n ];
|
|
uniform bool latitudinal;
|
|
uniform float dTheta;
|
|
uniform float mipInt;
|
|
uniform vec3 poleAxis;
|
|
|
|
#define ENVMAP_TYPE_CUBE_UV
|
|
#include <cube_uv_reflection_fragment>
|
|
|
|
vec3 getSample( float theta, vec3 axis ) {
|
|
|
|
float cosTheta = cos( theta );
|
|
// Rodrigues' axis-angle rotation
|
|
vec3 sampleDirection = vOutputDirection * cosTheta
|
|
+ cross( axis, vOutputDirection ) * sin( theta )
|
|
+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
|
|
|
|
return bilinearCubeUV( envMap, sampleDirection, mipInt );
|
|
|
|
}
|
|
|
|
void main() {
|
|
|
|
vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
|
|
|
|
if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
|
|
|
|
axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
|
|
|
|
}
|
|
|
|
axis = normalize( axis );
|
|
|
|
gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
|
|
gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
|
|
|
|
for ( int i = 1; i < n; i++ ) {
|
|
|
|
if ( i >= samples ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
float theta = dTheta * float( i );
|
|
gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
|
|
gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
|
|
|
|
}
|
|
|
|
}
|
|
`,blending:An,depthTest:!1,depthWrite:!1})}function Ml(){return new mn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ss(),fragmentShader:`
|
|
|
|
precision mediump float;
|
|
precision mediump int;
|
|
|
|
varying vec3 vOutputDirection;
|
|
|
|
uniform sampler2D envMap;
|
|
|
|
#include <common>
|
|
|
|
void main() {
|
|
|
|
vec3 outputDirection = normalize( vOutputDirection );
|
|
vec2 uv = equirectUv( outputDirection );
|
|
|
|
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
|
|
|
|
}
|
|
`,blending:An,depthTest:!1,depthWrite:!1})}function Sl(){return new mn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ss(),fragmentShader:`
|
|
|
|
precision mediump float;
|
|
precision mediump int;
|
|
|
|
uniform float flipEnvMap;
|
|
|
|
varying vec3 vOutputDirection;
|
|
|
|
uniform samplerCube envMap;
|
|
|
|
void main() {
|
|
|
|
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
|
|
|
|
}
|
|
`,blending:An,depthTest:!1,depthWrite:!1})}function ss(){return`
|
|
|
|
precision mediump float;
|
|
precision mediump int;
|
|
|
|
attribute float faceIndex;
|
|
|
|
varying vec3 vOutputDirection;
|
|
|
|
// RH coordinate system; PMREM face-indexing convention
|
|
vec3 getDirection( vec2 uv, float face ) {
|
|
|
|
uv = 2.0 * uv - 1.0;
|
|
|
|
vec3 direction = vec3( uv, 1.0 );
|
|
|
|
if ( face == 0.0 ) {
|
|
|
|
direction = direction.zyx; // ( 1, v, u ) pos x
|
|
|
|
} else if ( face == 1.0 ) {
|
|
|
|
direction = direction.xzy;
|
|
direction.xz *= -1.0; // ( -u, 1, -v ) pos y
|
|
|
|
} else if ( face == 2.0 ) {
|
|
|
|
direction.x *= -1.0; // ( -u, v, 1 ) pos z
|
|
|
|
} else if ( face == 3.0 ) {
|
|
|
|
direction = direction.zyx;
|
|
direction.xz *= -1.0; // ( -1, v, -u ) neg x
|
|
|
|
} else if ( face == 4.0 ) {
|
|
|
|
direction = direction.xzy;
|
|
direction.xy *= -1.0; // ( -u, -1, v ) neg y
|
|
|
|
} else if ( face == 5.0 ) {
|
|
|
|
direction.z *= -1.0; // ( u, v, -1 ) neg z
|
|
|
|
}
|
|
|
|
return direction;
|
|
|
|
}
|
|
|
|
void main() {
|
|
|
|
vOutputDirection = getDirection( uv, faceIndex );
|
|
gl_Position = vec4( position, 1.0 );
|
|
|
|
}
|
|
`}function _g(n){let e=new WeakMap,t=null;function i(o){if(o&&o.isTexture){const l=o.mapping,c=l===ia||l===ra,h=l===ei||l===wi;if(c||h){let f=e.get(o);const d=f!==void 0?f.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return t===null&&(t=new xl(n)),f=c?t.fromEquirectangular(o,f):t.fromCubemap(o,f),f.texture.pmremVersion=o.pmremVersion,e.set(o,f),f.texture;if(f!==void 0)return f.texture;{const m=o.image;return c&&m&&m.height>0||h&&m&&r(m)?(t===null&&(t=new xl(n)),f=c?t.fromEquirectangular(o):t.fromCubemap(o),f.texture.pmremVersion=o.pmremVersion,e.set(o,f),o.addEventListener("dispose",s),f.texture):null}}}return o}function r(o){let l=0;const c=6;for(let h=0;h<c;h++)o[h]!==void 0&&l++;return l===c}function s(o){const l=o.target;l.removeEventListener("dispose",s);const c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:a}}function xg(n){const e={};function t(i){if(e[i]!==void 0)return e[i];const r=n.getExtension(i);return e[i]=r,r}return{has:function(i){return t(i)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(i){const r=t(i);return r===null&&Qi("WebGLRenderer: "+i+" extension not supported."),r}}}function vg(n,e,t,i){const r={},s=new WeakMap;function a(f){const d=f.target;d.index!==null&&e.remove(d.index);for(const g in d.attributes)e.remove(d.attributes[g]);d.removeEventListener("dispose",a),delete r[d.id];const m=s.get(d);m&&(e.remove(m),s.delete(d)),i.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function o(f,d){return r[d.id]===!0||(d.addEventListener("dispose",a),r[d.id]=!0,t.memory.geometries++),d}function l(f){const d=f.attributes;for(const m in d)e.update(d[m],n.ARRAY_BUFFER)}function c(f){const d=[],m=f.index,g=f.attributes.position;let x=0;if(m!==null){const y=m.array;x=m.version;for(let v=0,M=y.length;v<M;v+=3){const b=y[v+0],w=y[v+1],R=y[v+2];d.push(b,w,w,R,R,b)}}else if(g!==void 0){const y=g.array;x=g.version;for(let v=0,M=y.length/3-1;v<M;v+=3){const b=v+0,w=v+1,R=v+2;d.push(b,w,w,R,R,b)}}else return;const p=new(Ac(d)?Pc:Cc)(d,1);p.version=x;const u=s.get(f);u&&e.remove(u),s.set(f,p)}function h(f){const d=s.get(f);if(d){const m=f.index;m!==null&&d.version<m.version&&c(f)}else c(f);return s.get(f)}return{get:o,update:l,getWireframeAttribute:h}}function Mg(n,e,t){let i;function r(d){i=d}let s,a;function o(d){s=d.type,a=d.bytesPerElement}function l(d,m){n.drawElements(i,m,s,d*a),t.update(m,i,1)}function c(d,m,g){g!==0&&(n.drawElementsInstanced(i,m,s,d*a,g),t.update(m,i,g))}function h(d,m,g){if(g===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,m,0,s,d,0,g);let p=0;for(let u=0;u<g;u++)p+=m[u];t.update(p,i,1)}function f(d,m,g,x){if(g===0)return;const p=e.get("WEBGL_multi_draw");if(p===null)for(let u=0;u<d.length;u++)c(d[u]/a,m[u],x[u]);else{p.multiDrawElementsInstancedWEBGL(i,m,0,s,d,0,x,0,g);let u=0;for(let y=0;y<g;y++)u+=m[y]*x[y];t.update(u,i,1)}}this.setMode=r,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=h,this.renderMultiDrawInstances=f}function Sg(n){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,a,o){switch(t.calls++,a){case n.TRIANGLES:t.triangles+=o*(s/3);break;case n.LINES:t.lines+=o*(s/2);break;case n.LINE_STRIP:t.lines+=o*(s-1);break;case n.LINE_LOOP:t.lines+=o*s;break;case n.POINTS:t.points+=o*s;break;default:$e("WebGLInfo: Unknown draw mode:",a);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:i}}function yg(n,e,t){const i=new WeakMap,r=new mt;function s(a,o,l){const c=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,f=h!==void 0?h.length:0;let d=i.get(o);if(d===void 0||d.count!==f){let S=function(){R.dispose(),i.delete(o),o.removeEventListener("dispose",S)};d!==void 0&&d.texture.dispose();const m=o.morphAttributes.position!==void 0,g=o.morphAttributes.normal!==void 0,x=o.morphAttributes.color!==void 0,p=o.morphAttributes.position||[],u=o.morphAttributes.normal||[],y=o.morphAttributes.color||[];let v=0;m===!0&&(v=1),g===!0&&(v=2),x===!0&&(v=3);let M=o.attributes.position.count*v,b=1;M>e.maxTextureSize&&(b=Math.ceil(M/e.maxTextureSize),M=e.maxTextureSize);const w=new Float32Array(M*b*4*f),R=new wc(w,M,b,f);R.type=cn,R.needsUpdate=!0;const I=v*4;for(let T=0;T<f;T++){const P=p[T],B=u[T],z=y[T],j=M*b*4*T;for(let K=0;K<P.count;K++){const L=K*I;m===!0&&(r.fromBufferAttribute(P,K),w[j+L+0]=r.x,w[j+L+1]=r.y,w[j+L+2]=r.z,w[j+L+3]=0),g===!0&&(r.fromBufferAttribute(B,K),w[j+L+4]=r.x,w[j+L+5]=r.y,w[j+L+6]=r.z,w[j+L+7]=0),x===!0&&(r.fromBufferAttribute(z,K),w[j+L+8]=r.x,w[j+L+9]=r.y,w[j+L+10]=r.z,w[j+L+11]=z.itemSize===4?r.w:1)}}d={count:f,texture:R,size:new Ge(M,b)},i.set(o,d),o.addEventListener("dispose",S)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)l.getUniforms().setValue(n,"morphTexture",a.morphTexture,t);else{let m=0;for(let x=0;x<c.length;x++)m+=c[x];const g=o.morphTargetsRelative?1:1-m;l.getUniforms().setValue(n,"morphTargetBaseInfluence",g),l.getUniforms().setValue(n,"morphTargetInfluences",c)}l.getUniforms().setValue(n,"morphTargetsTexture",d.texture,t),l.getUniforms().setValue(n,"morphTargetsTextureSize",d.size)}return{update:s}}function bg(n,e,t,i){let r=new WeakMap;function s(l){const c=i.render.frame,h=l.geometry,f=e.get(l,h);if(r.get(f)!==c&&(e.update(f),r.set(f,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),r.get(l)!==c&&(t.update(l.instanceMatrix,n.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,n.ARRAY_BUFFER),r.set(l,c))),l.isSkinnedMesh){const d=l.skeleton;r.get(d)!==c&&(d.update(),r.set(d,c))}return f}function a(){r=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:s,dispose:a}}const Eg={[hc]:"LINEAR_TONE_MAPPING",[fc]:"REINHARD_TONE_MAPPING",[dc]:"CINEON_TONE_MAPPING",[pc]:"ACES_FILMIC_TONE_MAPPING",[gc]:"AGX_TONE_MAPPING",[_c]:"NEUTRAL_TONE_MAPPING",[mc]:"CUSTOM_TONE_MAPPING"};function Tg(n,e,t,i,r){const s=new fn(e,t,{type:n,depthBuffer:i,stencilBuffer:r}),a=new fn(e,t,{type:Rn,depthBuffer:!1,stencilBuffer:!1}),o=new Ct;o.setAttribute("position",new Ht([-1,3,0,-1,-1,0,3,-1,0],3)),o.setAttribute("uv",new Ht([0,2,0,0,2,0],2));const l=new _d({uniforms:{tDiffuse:{value:null}},vertexShader:`
|
|
precision highp float;
|
|
|
|
uniform mat4 modelViewMatrix;
|
|
uniform mat4 projectionMatrix;
|
|
|
|
attribute vec3 position;
|
|
attribute vec2 uv;
|
|
|
|
varying vec2 vUv;
|
|
|
|
void main() {
|
|
vUv = uv;
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
}`,fragmentShader:`
|
|
precision highp float;
|
|
|
|
uniform sampler2D tDiffuse;
|
|
|
|
varying vec2 vUv;
|
|
|
|
#include <tonemapping_pars_fragment>
|
|
#include <colorspace_pars_fragment>
|
|
|
|
void main() {
|
|
gl_FragColor = texture2D( tDiffuse, vUv );
|
|
|
|
#ifdef LINEAR_TONE_MAPPING
|
|
gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
|
|
#elif defined( REINHARD_TONE_MAPPING )
|
|
gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
|
|
#elif defined( CINEON_TONE_MAPPING )
|
|
gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
|
|
#elif defined( ACES_FILMIC_TONE_MAPPING )
|
|
gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
|
|
#elif defined( AGX_TONE_MAPPING )
|
|
gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
|
|
#elif defined( NEUTRAL_TONE_MAPPING )
|
|
gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
|
|
#elif defined( CUSTOM_TONE_MAPPING )
|
|
gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
|
|
#endif
|
|
|
|
#ifdef SRGB_TRANSFER
|
|
gl_FragColor = sRGBTransferOETF( gl_FragColor );
|
|
#endif
|
|
}`,depthTest:!1,depthWrite:!1}),c=new pn(o,l),h=new Bc(-1,1,1,-1,0,1);let f=null,d=null,m=!1,g,x=null,p=[],u=!1;this.setSize=function(y,v){s.setSize(y,v),a.setSize(y,v);for(let M=0;M<p.length;M++){const b=p[M];b.setSize&&b.setSize(y,v)}},this.setEffects=function(y){p=y,u=p.length>0&&p[0].isRenderPass===!0;const v=s.width,M=s.height;for(let b=0;b<p.length;b++){const w=p[b];w.setSize&&w.setSize(v,M)}},this.begin=function(y,v){if(m||y.toneMapping===hn&&p.length===0)return!1;if(x=v,v!==null){const M=v.width,b=v.height;(s.width!==M||s.height!==b)&&this.setSize(M,b)}return u===!1&&y.setRenderTarget(s),g=y.toneMapping,y.toneMapping=hn,!0},this.hasRenderPass=function(){return u},this.end=function(y,v){y.toneMapping=g,m=!0;let M=s,b=a;for(let w=0;w<p.length;w++){const R=p[w];if(R.enabled!==!1&&(R.render(y,b,M,v),R.needsSwap!==!1)){const I=M;M=b,b=I}}if(f!==y.outputColorSpace||d!==y.toneMapping){f=y.outputColorSpace,d=y.toneMapping,l.defines={},Ze.getTransfer(f)===it&&(l.defines.SRGB_TRANSFER="");const w=Eg[d];w&&(l.defines[w]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=M.texture,y.setRenderTarget(x),y.render(c,h),x=null,m=!1},this.isCompositing=function(){return m},this.dispose=function(){s.dispose(),a.dispose(),o.dispose(),l.dispose()}}const kc=new Pt,Ha=new er(1,1),Vc=new wc,Hc=new Wf,Gc=new Nc,yl=[],bl=[],El=new Float32Array(16),Tl=new Float32Array(9),Al=new Float32Array(4);function Li(n,e,t){const i=n[0];if(i<=0||i>0)return n;const r=e*t;let s=yl[r];if(s===void 0&&(s=new Float32Array(r),yl[r]=s),e!==0){i.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,n[a].toArray(s,o)}return s}function vt(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function Mt(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function as(n,e){let t=bl[e];t===void 0&&(t=new Int32Array(e),bl[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function Ag(n,e){const t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function wg(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(vt(t,e))return;n.uniform2fv(this.addr,e),Mt(t,e)}}function Rg(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(vt(t,e))return;n.uniform3fv(this.addr,e),Mt(t,e)}}function Cg(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(vt(t,e))return;n.uniform4fv(this.addr,e),Mt(t,e)}}function Pg(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(vt(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),Mt(t,e)}else{if(vt(t,i))return;Al.set(i),n.uniformMatrix2fv(this.addr,!1,Al),Mt(t,i)}}function Dg(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(vt(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),Mt(t,e)}else{if(vt(t,i))return;Tl.set(i),n.uniformMatrix3fv(this.addr,!1,Tl),Mt(t,i)}}function Lg(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(vt(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),Mt(t,e)}else{if(vt(t,i))return;El.set(i),n.uniformMatrix4fv(this.addr,!1,El),Mt(t,i)}}function Ng(n,e){const t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function Ig(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(vt(t,e))return;n.uniform2iv(this.addr,e),Mt(t,e)}}function Ug(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(vt(t,e))return;n.uniform3iv(this.addr,e),Mt(t,e)}}function Fg(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(vt(t,e))return;n.uniform4iv(this.addr,e),Mt(t,e)}}function Og(n,e){const t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function Bg(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(vt(t,e))return;n.uniform2uiv(this.addr,e),Mt(t,e)}}function zg(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(vt(t,e))return;n.uniform3uiv(this.addr,e),Mt(t,e)}}function kg(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(n.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(vt(t,e))return;n.uniform4uiv(this.addr,e),Mt(t,e)}}function Vg(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r);let s;this.type===n.SAMPLER_2D_SHADOW?(Ha.compareFunction=t.isReversedDepthBuffer()?no:to,s=Ha):s=kc,t.setTexture2D(e||s,r)}function Hg(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture3D(e||Hc,r)}function Gg(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||Gc,r)}function Wg(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||Vc,r)}function Xg(n){switch(n){case 5126:return Ag;case 35664:return wg;case 35665:return Rg;case 35666:return Cg;case 35674:return Pg;case 35675:return Dg;case 35676:return Lg;case 5124:case 35670:return Ng;case 35667:case 35671:return Ig;case 35668:case 35672:return Ug;case 35669:case 35673:return Fg;case 5125:return Og;case 36294:return Bg;case 36295:return zg;case 36296:return kg;case 35678:case 36198:case 36298:case 36306:case 35682:return Vg;case 35679:case 36299:case 36307:return Hg;case 35680:case 36300:case 36308:case 36293:return Gg;case 36289:case 36303:case 36311:case 36292:return Wg}}function qg(n,e){n.uniform1fv(this.addr,e)}function Yg(n,e){const t=Li(e,this.size,2);n.uniform2fv(this.addr,t)}function jg(n,e){const t=Li(e,this.size,3);n.uniform3fv(this.addr,t)}function Kg(n,e){const t=Li(e,this.size,4);n.uniform4fv(this.addr,t)}function $g(n,e){const t=Li(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function Zg(n,e){const t=Li(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function Jg(n,e){const t=Li(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function Qg(n,e){n.uniform1iv(this.addr,e)}function e_(n,e){n.uniform2iv(this.addr,e)}function t_(n,e){n.uniform3iv(this.addr,e)}function n_(n,e){n.uniform4iv(this.addr,e)}function i_(n,e){n.uniform1uiv(this.addr,e)}function r_(n,e){n.uniform2uiv(this.addr,e)}function s_(n,e){n.uniform3uiv(this.addr,e)}function a_(n,e){n.uniform4uiv(this.addr,e)}function o_(n,e,t){const i=this.cache,r=e.length,s=as(t,r);vt(i,s)||(n.uniform1iv(this.addr,s),Mt(i,s));let a;this.type===n.SAMPLER_2D_SHADOW?a=Ha:a=kc;for(let o=0;o!==r;++o)t.setTexture2D(e[o]||a,s[o])}function l_(n,e,t){const i=this.cache,r=e.length,s=as(t,r);vt(i,s)||(n.uniform1iv(this.addr,s),Mt(i,s));for(let a=0;a!==r;++a)t.setTexture3D(e[a]||Hc,s[a])}function c_(n,e,t){const i=this.cache,r=e.length,s=as(t,r);vt(i,s)||(n.uniform1iv(this.addr,s),Mt(i,s));for(let a=0;a!==r;++a)t.setTextureCube(e[a]||Gc,s[a])}function u_(n,e,t){const i=this.cache,r=e.length,s=as(t,r);vt(i,s)||(n.uniform1iv(this.addr,s),Mt(i,s));for(let a=0;a!==r;++a)t.setTexture2DArray(e[a]||Vc,s[a])}function h_(n){switch(n){case 5126:return qg;case 35664:return Yg;case 35665:return jg;case 35666:return Kg;case 35674:return $g;case 35675:return Zg;case 35676:return Jg;case 5124:case 35670:return Qg;case 35667:case 35671:return e_;case 35668:case 35672:return t_;case 35669:case 35673:return n_;case 5125:return i_;case 36294:return r_;case 36295:return s_;case 36296:return a_;case 35678:case 36198:case 36298:case 36306:case 35682:return o_;case 35679:case 36299:case 36307:return l_;case 35680:case 36300:case 36308:case 36293:return c_;case 36289:case 36303:case 36311:case 36292:return u_}}class f_{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=Xg(t.type)}}class d_{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=h_(t.type)}}class p_{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const r=this.seq;for(let s=0,a=r.length;s!==a;++s){const o=r[s];o.setValue(e,t[o.id],i)}}}const Hs=/(\w+)(\])?(\[|\.)?/g;function wl(n,e){n.seq.push(e),n.map[e.id]=e}function m_(n,e,t){const i=n.name,r=i.length;for(Hs.lastIndex=0;;){const s=Hs.exec(i),a=Hs.lastIndex;let o=s[1];const l=s[2]==="]",c=s[3];if(l&&(o=o|0),c===void 0||c==="["&&a+2===r){wl(t,c===void 0?new f_(o,n,e):new d_(o,n,e));break}else{let f=t.map[o];f===void 0&&(f=new p_(o),wl(t,f)),t=f}}}class Xr{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let a=0;a<i;++a){const o=e.getActiveUniform(t,a),l=e.getUniformLocation(t,o.name);m_(o,l,this)}const r=[],s=[];for(const a of this.seq)a.type===e.SAMPLER_2D_SHADOW||a.type===e.SAMPLER_CUBE_SHADOW||a.type===e.SAMPLER_2D_ARRAY_SHADOW?r.push(a):s.push(a);r.length>0&&(this.seq=r.concat(s))}setValue(e,t,i,r){const s=this.map[t];s!==void 0&&s.setValue(e,i,r)}setOptional(e,t,i){const r=t[i];r!==void 0&&this.setValue(e,i,r)}static upload(e,t,i,r){for(let s=0,a=t.length;s!==a;++s){const o=t[s],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,r)}}static seqWithValue(e,t){const i=[];for(let r=0,s=e.length;r!==s;++r){const a=e[r];a.id in t&&i.push(a)}return i}}function Rl(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const g_=37297;let __=0;function x_(n,e){const t=n.split(`
|
|
`),i=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let a=r;a<s;a++){const o=a+1;i.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return i.join(`
|
|
`)}const Cl=new We;function v_(n){Ze._getMatrix(Cl,Ze.workingColorSpace,n);const e=`mat3( ${Cl.elements.map(t=>t.toFixed(4))} )`;switch(Ze.getTransfer(n)){case Kr:return[e,"LinearTransferOETF"];case it:return[e,"sRGBTransferOETF"];default:return Be("WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function Pl(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),s=(n.getShaderInfoLog(e)||"").trim();if(i&&s==="")return"";const a=/ERROR: 0:(\d+)/.exec(s);if(a){const o=parseInt(a[1]);return t.toUpperCase()+`
|
|
|
|
`+s+`
|
|
|
|
`+x_(n.getShaderSource(e),o)}else return s}function M_(n,e){const t=v_(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
|
|
`)}const S_={[hc]:"Linear",[fc]:"Reinhard",[dc]:"Cineon",[pc]:"ACESFilmic",[gc]:"AgX",[_c]:"Neutral",[mc]:"Custom"};function y_(n,e){const t=S_[e];return t===void 0?(Be("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+n+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Fr=new F;function b_(){Ze.getLuminanceCoefficients(Fr);const n=Fr.x.toFixed(4),e=Fr.y.toFixed(4),t=Fr.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
|
|
`)}function E_(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Ki).join(`
|
|
`)}function T_(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
|
|
`)}function A_(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const s=n.getActiveAttrib(e,r),a=s.name;let o=1;s.type===n.FLOAT_MAT2&&(o=2),s.type===n.FLOAT_MAT3&&(o=3),s.type===n.FLOAT_MAT4&&(o=4),t[a]={type:s.type,location:n.getAttribLocation(e,a),locationSize:o}}return t}function Ki(n){return n!==""}function Dl(n,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return n.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Ll(n,e){return n.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const w_=/^[ \t]*#include +<([\w\d./]+)>/gm;function Ga(n){return n.replace(w_,C_)}const R_=new Map;function C_(n,e){let t=Xe[e];if(t===void 0){const i=R_.get(e);if(i!==void 0)t=Xe[i],Be('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return Ga(t)}const P_=/#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 Nl(n){return n.replace(P_,D_)}function D_(n,e,t,i){let r="";for(let s=parseInt(e);s<parseInt(t);s++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function Il(n){let e=`precision ${n.precision} float;
|
|
precision ${n.precision} int;
|
|
precision ${n.precision} sampler2D;
|
|
precision ${n.precision} samplerCube;
|
|
precision ${n.precision} sampler3D;
|
|
precision ${n.precision} sampler2DArray;
|
|
precision ${n.precision} sampler2DShadow;
|
|
precision ${n.precision} samplerCubeShadow;
|
|
precision ${n.precision} sampler2DArrayShadow;
|
|
precision ${n.precision} isampler2D;
|
|
precision ${n.precision} isampler3D;
|
|
precision ${n.precision} isamplerCube;
|
|
precision ${n.precision} isampler2DArray;
|
|
precision ${n.precision} usampler2D;
|
|
precision ${n.precision} usampler3D;
|
|
precision ${n.precision} usamplerCube;
|
|
precision ${n.precision} usampler2DArray;
|
|
`;return n.precision==="highp"?e+=`
|
|
#define HIGH_PRECISION`:n.precision==="mediump"?e+=`
|
|
#define MEDIUM_PRECISION`:n.precision==="lowp"&&(e+=`
|
|
#define LOW_PRECISION`),e}const L_={[zr]:"SHADOWMAP_TYPE_PCF",[ji]:"SHADOWMAP_TYPE_VSM"};function N_(n){return L_[n.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const I_={[ei]:"ENVMAP_TYPE_CUBE",[wi]:"ENVMAP_TYPE_CUBE",[is]:"ENVMAP_TYPE_CUBE_UV"};function U_(n){return n.envMap===!1?"ENVMAP_TYPE_CUBE":I_[n.envMapMode]||"ENVMAP_TYPE_CUBE"}const F_={[wi]:"ENVMAP_MODE_REFRACTION"};function O_(n){return n.envMap===!1?"ENVMAP_MODE_REFLECTION":F_[n.envMapMode]||"ENVMAP_MODE_REFLECTION"}const B_={[uc]:"ENVMAP_BLENDING_MULTIPLY",[bf]:"ENVMAP_BLENDING_MIX",[Ef]:"ENVMAP_BLENDING_ADD"};function z_(n){return n.envMap===!1?"ENVMAP_BLENDING_NONE":B_[n.combine]||"ENVMAP_BLENDING_NONE"}function k_(n){const e=n.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:i,maxMip:t}}function V_(n,e,t,i){const r=n.getContext(),s=t.defines;let a=t.vertexShader,o=t.fragmentShader;const l=N_(t),c=U_(t),h=O_(t),f=z_(t),d=k_(t),m=E_(t),g=T_(s),x=r.createProgram();let p,u,y=t.glslVersion?"#version "+t.glslVersion+`
|
|
`:"";t.isRawShaderMaterial?(p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Ki).join(`
|
|
`),p.length>0&&(p+=`
|
|
`),u=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(Ki).join(`
|
|
`),u.length>0&&(u+=`
|
|
`)):(p=[Il(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
|
|
`].filter(Ki).join(`
|
|
`),u=[Il(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+h:"",t.envMap?"#define "+f:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==hn?"#define TONE_MAPPING":"",t.toneMapping!==hn?Xe.tonemapping_pars_fragment:"",t.toneMapping!==hn?y_("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Xe.colorspace_pars_fragment,M_("linearToOutputTexel",t.outputColorSpace),b_(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
|
`].filter(Ki).join(`
|
|
`)),a=Ga(a),a=Dl(a,t),a=Ll(a,t),o=Ga(o),o=Dl(o,t),o=Ll(o,t),a=Nl(a),o=Nl(o),t.isRawShaderMaterial!==!0&&(y=`#version 300 es
|
|
`,p=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
`)+`
|
|
`+p,u=["#define varying in",t.glslVersion===Vo?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Vo?"":"#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(`
|
|
`)+`
|
|
`+u);const v=y+p+a,M=y+u+o,b=Rl(r,r.VERTEX_SHADER,v),w=Rl(r,r.FRAGMENT_SHADER,M);r.attachShader(x,b),r.attachShader(x,w),t.index0AttributeName!==void 0?r.bindAttribLocation(x,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(x,0,"position"),r.linkProgram(x);function R(P){if(n.debug.checkShaderErrors){const B=r.getProgramInfoLog(x)||"",z=r.getShaderInfoLog(b)||"",j=r.getShaderInfoLog(w)||"",K=B.trim(),L=z.trim(),k=j.trim();let Z=!0,re=!0;if(r.getProgramParameter(x,r.LINK_STATUS)===!1)if(Z=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(r,x,b,w);else{const V=Pl(r,b,"vertex"),W=Pl(r,w,"fragment");$e("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(x,r.VALIDATE_STATUS)+`
|
|
|
|
Material Name: `+P.name+`
|
|
Material Type: `+P.type+`
|
|
|
|
Program Info Log: `+K+`
|
|
`+V+`
|
|
`+W)}else K!==""?Be("WebGLProgram: Program Info Log:",K):(L===""||k==="")&&(re=!1);re&&(P.diagnostics={runnable:Z,programLog:K,vertexShader:{log:L,prefix:p},fragmentShader:{log:k,prefix:u}})}r.deleteShader(b),r.deleteShader(w),I=new Xr(r,x),S=A_(r,x)}let I;this.getUniforms=function(){return I===void 0&&R(this),I};let S;this.getAttributes=function(){return S===void 0&&R(this),S};let T=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return T===!1&&(T=r.getProgramParameter(x,g_)),T},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(x),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=__++,this.cacheKey=e,this.usedTimes=1,this.program=x,this.vertexShader=b,this.fragmentShader=w,this}let H_=0;class G_{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(i),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new W_(e),t.set(e,i)),i}}class W_{constructor(e){this.id=H_++,this.code=e,this.usedTimes=0}}function X_(n,e,t,i,r,s,a){const o=new ro,l=new G_,c=new Set,h=[],f=new Map,d=r.logarithmicDepthBuffer;let m=r.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(S){return c.add(S),S===0?"uv":`uv${S}`}function p(S,T,P,B,z){const j=B.fog,K=z.geometry,L=S.isMeshStandardMaterial?B.environment:null,k=(S.isMeshStandardMaterial?t:e).get(S.envMap||L),Z=k&&k.mapping===is?k.image.height:null,re=g[S.type];S.precision!==null&&(m=r.getMaxPrecision(S.precision),m!==S.precision&&Be("WebGLProgram.getParameters:",S.precision,"not supported, using",m,"instead."));const V=K.morphAttributes.position||K.morphAttributes.normal||K.morphAttributes.color,W=V!==void 0?V.length:0;let ce=0;K.morphAttributes.position!==void 0&&(ce=1),K.morphAttributes.normal!==void 0&&(ce=2),K.morphAttributes.color!==void 0&&(ce=3);let se,we,Se,Y;if(re){const tt=ln[re];se=tt.vertexShader,we=tt.fragmentShader}else se=S.vertexShader,we=S.fragmentShader,l.update(S),Se=l.getVertexShaderID(S),Y=l.getFragmentShaderID(S);const Q=n.getRenderTarget(),ge=n.state.buffers.depth.getReversed(),Ce=z.isInstancedMesh===!0,le=z.isBatchedMesh===!0,De=!!S.map,Ve=!!S.matcap,Ne=!!k,Fe=!!S.aoMap,je=!!S.lightMap,ze=!!S.bumpMap,lt=!!S.normalMap,C=!!S.displacementMap,et=!!S.emissiveMap,Ke=!!S.metalnessMap,xe=!!S.roughnessMap,ne=S.anisotropy>0,A=S.clearcoat>0,_=S.dispersion>0,D=S.iridescence>0,G=S.sheen>0,$=S.transmission>0,H=ne&&!!S.anisotropyMap,pe=A&&!!S.clearcoatMap,te=A&&!!S.clearcoatNormalMap,fe=A&&!!S.clearcoatRoughnessMap,Pe=D&&!!S.iridescenceMap,ie=D&&!!S.iridescenceThicknessMap,oe=G&&!!S.sheenColorMap,Ee=G&&!!S.sheenRoughnessMap,Re=!!S.specularMap,de=!!S.specularColorMap,He=!!S.specularIntensityMap,N=$&&!!S.transmissionMap,ve=$&&!!S.thicknessMap,ue=!!S.gradientMap,be=!!S.alphaMap,ae=S.alphaTest>0,ee=!!S.alphaHash,me=!!S.extensions;let ke=hn;S.toneMapped&&(Q===null||Q.isXRRenderTarget===!0)&&(ke=n.toneMapping);const ct={shaderID:re,shaderType:S.type,shaderName:S.name,vertexShader:se,fragmentShader:we,defines:S.defines,customVertexShaderID:Se,customFragmentShaderID:Y,isRawShaderMaterial:S.isRawShaderMaterial===!0,glslVersion:S.glslVersion,precision:m,batching:le,batchingColor:le&&z._colorsTexture!==null,instancing:Ce,instancingColor:Ce&&z.instanceColor!==null,instancingMorph:Ce&&z.morphTexture!==null,outputColorSpace:Q===null?n.outputColorSpace:Q.isXRRenderTarget===!0?Q.texture.colorSpace:Ci,alphaToCoverage:!!S.alphaToCoverage,map:De,matcap:Ve,envMap:Ne,envMapMode:Ne&&k.mapping,envMapCubeUVHeight:Z,aoMap:Fe,lightMap:je,bumpMap:ze,normalMap:lt,displacementMap:C,emissiveMap:et,normalMapObjectSpace:lt&&S.normalMapType===Rf,normalMapTangentSpace:lt&&S.normalMapType===wf,metalnessMap:Ke,roughnessMap:xe,anisotropy:ne,anisotropyMap:H,clearcoat:A,clearcoatMap:pe,clearcoatNormalMap:te,clearcoatRoughnessMap:fe,dispersion:_,iridescence:D,iridescenceMap:Pe,iridescenceThicknessMap:ie,sheen:G,sheenColorMap:oe,sheenRoughnessMap:Ee,specularMap:Re,specularColorMap:de,specularIntensityMap:He,transmission:$,transmissionMap:N,thicknessMap:ve,gradientMap:ue,opaque:S.transparent===!1&&S.blending===yi&&S.alphaToCoverage===!1,alphaMap:be,alphaTest:ae,alphaHash:ee,combine:S.combine,mapUv:De&&x(S.map.channel),aoMapUv:Fe&&x(S.aoMap.channel),lightMapUv:je&&x(S.lightMap.channel),bumpMapUv:ze&&x(S.bumpMap.channel),normalMapUv:lt&&x(S.normalMap.channel),displacementMapUv:C&&x(S.displacementMap.channel),emissiveMapUv:et&&x(S.emissiveMap.channel),metalnessMapUv:Ke&&x(S.metalnessMap.channel),roughnessMapUv:xe&&x(S.roughnessMap.channel),anisotropyMapUv:H&&x(S.anisotropyMap.channel),clearcoatMapUv:pe&&x(S.clearcoatMap.channel),clearcoatNormalMapUv:te&&x(S.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:fe&&x(S.clearcoatRoughnessMap.channel),iridescenceMapUv:Pe&&x(S.iridescenceMap.channel),iridescenceThicknessMapUv:ie&&x(S.iridescenceThicknessMap.channel),sheenColorMapUv:oe&&x(S.sheenColorMap.channel),sheenRoughnessMapUv:Ee&&x(S.sheenRoughnessMap.channel),specularMapUv:Re&&x(S.specularMap.channel),specularColorMapUv:de&&x(S.specularColorMap.channel),specularIntensityMapUv:He&&x(S.specularIntensityMap.channel),transmissionMapUv:N&&x(S.transmissionMap.channel),thicknessMapUv:ve&&x(S.thicknessMap.channel),alphaMapUv:be&&x(S.alphaMap.channel),vertexTangents:!!K.attributes.tangent&&(lt||ne),vertexColors:S.vertexColors,vertexAlphas:S.vertexColors===!0&&!!K.attributes.color&&K.attributes.color.itemSize===4,pointsUvs:z.isPoints===!0&&!!K.attributes.uv&&(De||be),fog:!!j,useFog:S.fog===!0,fogExp2:!!j&&j.isFogExp2,flatShading:S.flatShading===!0&&S.wireframe===!1,sizeAttenuation:S.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:ge,skinning:z.isSkinnedMesh===!0,morphTargets:K.morphAttributes.position!==void 0,morphNormals:K.morphAttributes.normal!==void 0,morphColors:K.morphAttributes.color!==void 0,morphTargetsCount:W,morphTextureStride:ce,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,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:S.dithering,shadowMapEnabled:n.shadowMap.enabled&&P.length>0,shadowMapType:n.shadowMap.type,toneMapping:ke,decodeVideoTexture:De&&S.map.isVideoTexture===!0&&Ze.getTransfer(S.map.colorSpace)===it,decodeVideoTextureEmissive:et&&S.emissiveMap.isVideoTexture===!0&&Ze.getTransfer(S.emissiveMap.colorSpace)===it,premultipliedAlpha:S.premultipliedAlpha,doubleSided:S.side===bn,flipSided:S.side===Vt,useDepthPacking:S.depthPacking>=0,depthPacking:S.depthPacking||0,index0AttributeName:S.index0AttributeName,extensionClipCullDistance:me&&S.extensions.clipCullDistance===!0&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(me&&S.extensions.multiDraw===!0||le)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:S.customProgramCacheKey()};return ct.vertexUv1s=c.has(1),ct.vertexUv2s=c.has(2),ct.vertexUv3s=c.has(3),c.clear(),ct}function u(S){const T=[];if(S.shaderID?T.push(S.shaderID):(T.push(S.customVertexShaderID),T.push(S.customFragmentShaderID)),S.defines!==void 0)for(const P in S.defines)T.push(P),T.push(S.defines[P]);return S.isRawShaderMaterial===!1&&(y(T,S),v(T,S),T.push(n.outputColorSpace)),T.push(S.customProgramCacheKey),T.join()}function y(S,T){S.push(T.precision),S.push(T.outputColorSpace),S.push(T.envMapMode),S.push(T.envMapCubeUVHeight),S.push(T.mapUv),S.push(T.alphaMapUv),S.push(T.lightMapUv),S.push(T.aoMapUv),S.push(T.bumpMapUv),S.push(T.normalMapUv),S.push(T.displacementMapUv),S.push(T.emissiveMapUv),S.push(T.metalnessMapUv),S.push(T.roughnessMapUv),S.push(T.anisotropyMapUv),S.push(T.clearcoatMapUv),S.push(T.clearcoatNormalMapUv),S.push(T.clearcoatRoughnessMapUv),S.push(T.iridescenceMapUv),S.push(T.iridescenceThicknessMapUv),S.push(T.sheenColorMapUv),S.push(T.sheenRoughnessMapUv),S.push(T.specularMapUv),S.push(T.specularColorMapUv),S.push(T.specularIntensityMapUv),S.push(T.transmissionMapUv),S.push(T.thicknessMapUv),S.push(T.combine),S.push(T.fogExp2),S.push(T.sizeAttenuation),S.push(T.morphTargetsCount),S.push(T.morphAttributeCount),S.push(T.numDirLights),S.push(T.numPointLights),S.push(T.numSpotLights),S.push(T.numSpotLightMaps),S.push(T.numHemiLights),S.push(T.numRectAreaLights),S.push(T.numDirLightShadows),S.push(T.numPointLightShadows),S.push(T.numSpotLightShadows),S.push(T.numSpotLightShadowsWithMaps),S.push(T.numLightProbes),S.push(T.shadowMapType),S.push(T.toneMapping),S.push(T.numClippingPlanes),S.push(T.numClipIntersection),S.push(T.depthPacking)}function v(S,T){o.disableAll(),T.instancing&&o.enable(0),T.instancingColor&&o.enable(1),T.instancingMorph&&o.enable(2),T.matcap&&o.enable(3),T.envMap&&o.enable(4),T.normalMapObjectSpace&&o.enable(5),T.normalMapTangentSpace&&o.enable(6),T.clearcoat&&o.enable(7),T.iridescence&&o.enable(8),T.alphaTest&&o.enable(9),T.vertexColors&&o.enable(10),T.vertexAlphas&&o.enable(11),T.vertexUv1s&&o.enable(12),T.vertexUv2s&&o.enable(13),T.vertexUv3s&&o.enable(14),T.vertexTangents&&o.enable(15),T.anisotropy&&o.enable(16),T.alphaHash&&o.enable(17),T.batching&&o.enable(18),T.dispersion&&o.enable(19),T.batchingColor&&o.enable(20),T.gradientMap&&o.enable(21),S.push(o.mask),o.disableAll(),T.fog&&o.enable(0),T.useFog&&o.enable(1),T.flatShading&&o.enable(2),T.logarithmicDepthBuffer&&o.enable(3),T.reversedDepthBuffer&&o.enable(4),T.skinning&&o.enable(5),T.morphTargets&&o.enable(6),T.morphNormals&&o.enable(7),T.morphColors&&o.enable(8),T.premultipliedAlpha&&o.enable(9),T.shadowMapEnabled&&o.enable(10),T.doubleSided&&o.enable(11),T.flipSided&&o.enable(12),T.useDepthPacking&&o.enable(13),T.dithering&&o.enable(14),T.transmission&&o.enable(15),T.sheen&&o.enable(16),T.opaque&&o.enable(17),T.pointsUvs&&o.enable(18),T.decodeVideoTexture&&o.enable(19),T.decodeVideoTextureEmissive&&o.enable(20),T.alphaToCoverage&&o.enable(21),S.push(o.mask)}function M(S){const T=g[S.type];let P;if(T){const B=ln[T];P=id.clone(B.uniforms)}else P=S.uniforms;return P}function b(S,T){let P=f.get(T);return P!==void 0?++P.usedTimes:(P=new V_(n,T,S,s),h.push(P),f.set(T,P)),P}function w(S){if(--S.usedTimes===0){const T=h.indexOf(S);h[T]=h[h.length-1],h.pop(),f.delete(S.cacheKey),S.destroy()}}function R(S){l.remove(S)}function I(){l.dispose()}return{getParameters:p,getProgramCacheKey:u,getUniforms:M,acquireProgram:b,releaseProgram:w,releaseShaderCache:R,programs:h,dispose:I}}function q_(){let n=new WeakMap;function e(a){return n.has(a)}function t(a){let o=n.get(a);return o===void 0&&(o={},n.set(a,o)),o}function i(a){n.delete(a)}function r(a,o,l){n.get(a)[o]=l}function s(){n=new WeakMap}return{has:e,get:t,remove:i,update:r,dispose:s}}function Y_(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.z!==e.z?n.z-e.z:n.id-e.id}function Ul(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function Fl(){const n=[];let e=0;const t=[],i=[],r=[];function s(){e=0,t.length=0,i.length=0,r.length=0}function a(f,d,m,g,x,p){let u=n[e];return u===void 0?(u={id:f.id,object:f,geometry:d,material:m,groupOrder:g,renderOrder:f.renderOrder,z:x,group:p},n[e]=u):(u.id=f.id,u.object=f,u.geometry=d,u.material=m,u.groupOrder=g,u.renderOrder=f.renderOrder,u.z=x,u.group=p),e++,u}function o(f,d,m,g,x,p){const u=a(f,d,m,g,x,p);m.transmission>0?i.push(u):m.transparent===!0?r.push(u):t.push(u)}function l(f,d,m,g,x,p){const u=a(f,d,m,g,x,p);m.transmission>0?i.unshift(u):m.transparent===!0?r.unshift(u):t.unshift(u)}function c(f,d){t.length>1&&t.sort(f||Y_),i.length>1&&i.sort(d||Ul),r.length>1&&r.sort(d||Ul)}function h(){for(let f=e,d=n.length;f<d;f++){const m=n[f];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:t,transmissive:i,transparent:r,init:s,push:o,unshift:l,finish:h,sort:c}}function j_(){let n=new WeakMap;function e(i,r){const s=n.get(i);let a;return s===void 0?(a=new Fl,n.set(i,[a])):r>=s.length?(a=new Fl,s.push(a)):a=s[r],a}function t(){n=new WeakMap}return{get:e,dispose:t}}function K_(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new F,color:new Qe};break;case"SpotLight":t={position:new F,direction:new F,color:new Qe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new F,color:new Qe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new F,skyColor:new Qe,groundColor:new Qe};break;case"RectAreaLight":t={color:new Qe,position:new F,halfWidth:new F,halfHeight:new F};break}return n[e.id]=t,t}}}function $_(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ge};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ge};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ge,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let Z_=0;function J_(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function Q_(n){const e=new K_,t=$_(),i={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++)i.probe.push(new F);const r=new F,s=new ht,a=new ht;function o(c){let h=0,f=0,d=0;for(let S=0;S<9;S++)i.probe[S].set(0,0,0);let m=0,g=0,x=0,p=0,u=0,y=0,v=0,M=0,b=0,w=0,R=0;c.sort(J_);for(let S=0,T=c.length;S<T;S++){const P=c[S],B=P.color,z=P.intensity,j=P.distance;let K=null;if(P.shadow&&P.shadow.map&&(P.shadow.map.texture.format===Ri?K=P.shadow.map.texture:K=P.shadow.map.depthTexture||P.shadow.map.texture),P.isAmbientLight)h+=B.r*z,f+=B.g*z,d+=B.b*z;else if(P.isLightProbe){for(let L=0;L<9;L++)i.probe[L].addScaledVector(P.sh.coefficients[L],z);R++}else if(P.isDirectionalLight){const L=e.get(P);if(L.color.copy(P.color).multiplyScalar(P.intensity),P.castShadow){const k=P.shadow,Z=t.get(P);Z.shadowIntensity=k.intensity,Z.shadowBias=k.bias,Z.shadowNormalBias=k.normalBias,Z.shadowRadius=k.radius,Z.shadowMapSize=k.mapSize,i.directionalShadow[m]=Z,i.directionalShadowMap[m]=K,i.directionalShadowMatrix[m]=P.shadow.matrix,y++}i.directional[m]=L,m++}else if(P.isSpotLight){const L=e.get(P);L.position.setFromMatrixPosition(P.matrixWorld),L.color.copy(B).multiplyScalar(z),L.distance=j,L.coneCos=Math.cos(P.angle),L.penumbraCos=Math.cos(P.angle*(1-P.penumbra)),L.decay=P.decay,i.spot[x]=L;const k=P.shadow;if(P.map&&(i.spotLightMap[b]=P.map,b++,k.updateMatrices(P),P.castShadow&&w++),i.spotLightMatrix[x]=k.matrix,P.castShadow){const Z=t.get(P);Z.shadowIntensity=k.intensity,Z.shadowBias=k.bias,Z.shadowNormalBias=k.normalBias,Z.shadowRadius=k.radius,Z.shadowMapSize=k.mapSize,i.spotShadow[x]=Z,i.spotShadowMap[x]=K,M++}x++}else if(P.isRectAreaLight){const L=e.get(P);L.color.copy(B).multiplyScalar(z),L.halfWidth.set(P.width*.5,0,0),L.halfHeight.set(0,P.height*.5,0),i.rectArea[p]=L,p++}else if(P.isPointLight){const L=e.get(P);if(L.color.copy(P.color).multiplyScalar(P.intensity),L.distance=P.distance,L.decay=P.decay,P.castShadow){const k=P.shadow,Z=t.get(P);Z.shadowIntensity=k.intensity,Z.shadowBias=k.bias,Z.shadowNormalBias=k.normalBias,Z.shadowRadius=k.radius,Z.shadowMapSize=k.mapSize,Z.shadowCameraNear=k.camera.near,Z.shadowCameraFar=k.camera.far,i.pointShadow[g]=Z,i.pointShadowMap[g]=K,i.pointShadowMatrix[g]=P.shadow.matrix,v++}i.point[g]=L,g++}else if(P.isHemisphereLight){const L=e.get(P);L.skyColor.copy(P.color).multiplyScalar(z),L.groundColor.copy(P.groundColor).multiplyScalar(z),i.hemi[u]=L,u++}}p>0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Me.LTC_FLOAT_1,i.rectAreaLTC2=Me.LTC_FLOAT_2):(i.rectAreaLTC1=Me.LTC_HALF_1,i.rectAreaLTC2=Me.LTC_HALF_2)),i.ambient[0]=h,i.ambient[1]=f,i.ambient[2]=d;const I=i.hash;(I.directionalLength!==m||I.pointLength!==g||I.spotLength!==x||I.rectAreaLength!==p||I.hemiLength!==u||I.numDirectionalShadows!==y||I.numPointShadows!==v||I.numSpotShadows!==M||I.numSpotMaps!==b||I.numLightProbes!==R)&&(i.directional.length=m,i.spot.length=x,i.rectArea.length=p,i.point.length=g,i.hemi.length=u,i.directionalShadow.length=y,i.directionalShadowMap.length=y,i.pointShadow.length=v,i.pointShadowMap.length=v,i.spotShadow.length=M,i.spotShadowMap.length=M,i.directionalShadowMatrix.length=y,i.pointShadowMatrix.length=v,i.spotLightMatrix.length=M+b-w,i.spotLightMap.length=b,i.numSpotLightShadowsWithMaps=w,i.numLightProbes=R,I.directionalLength=m,I.pointLength=g,I.spotLength=x,I.rectAreaLength=p,I.hemiLength=u,I.numDirectionalShadows=y,I.numPointShadows=v,I.numSpotShadows=M,I.numSpotMaps=b,I.numLightProbes=R,i.version=Z_++)}function l(c,h){let f=0,d=0,m=0,g=0,x=0;const p=h.matrixWorldInverse;for(let u=0,y=c.length;u<y;u++){const v=c[u];if(v.isDirectionalLight){const M=i.directional[f];M.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(p),f++}else if(v.isSpotLight){const M=i.spot[m];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(p),M.direction.setFromMatrixPosition(v.matrixWorld),r.setFromMatrixPosition(v.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(p),m++}else if(v.isRectAreaLight){const M=i.rectArea[g];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(p),a.identity(),s.copy(v.matrixWorld),s.premultiply(p),a.extractRotation(s),M.halfWidth.set(v.width*.5,0,0),M.halfHeight.set(0,v.height*.5,0),M.halfWidth.applyMatrix4(a),M.halfHeight.applyMatrix4(a),g++}else if(v.isPointLight){const M=i.point[d];M.position.setFromMatrixPosition(v.matrixWorld),M.position.applyMatrix4(p),d++}else if(v.isHemisphereLight){const M=i.hemi[x];M.direction.setFromMatrixPosition(v.matrixWorld),M.direction.transformDirection(p),x++}}}return{setup:o,setupView:l,state:i}}function Ol(n){const e=new Q_(n),t=[],i=[];function r(h){c.camera=h,t.length=0,i.length=0}function s(h){t.push(h)}function a(h){i.push(h)}function o(){e.setup(t)}function l(h){e.setupView(t,h)}const c={lightsArray:t,shadowsArray:i,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:c,setupLights:o,setupLightsView:l,pushLight:s,pushShadow:a}}function e0(n){let e=new WeakMap;function t(r,s=0){const a=e.get(r);let o;return a===void 0?(o=new Ol(n),e.set(r,[o])):s>=a.length?(o=new Ol(n),a.push(o)):o=a[s],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const t0=`void main() {
|
|
gl_Position = vec4( position, 1.0 );
|
|
}`,n0=`uniform sampler2D shadow_pass;
|
|
uniform vec2 resolution;
|
|
uniform float radius;
|
|
void main() {
|
|
const float samples = float( VSM_SAMPLES );
|
|
float mean = 0.0;
|
|
float squared_mean = 0.0;
|
|
float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
|
|
float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
|
|
for ( float i = 0.0; i < samples; i ++ ) {
|
|
float uvOffset = uvStart + i * uvStride;
|
|
#ifdef HORIZONTAL_PASS
|
|
vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;
|
|
mean += distribution.x;
|
|
squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
|
|
#else
|
|
float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;
|
|
mean += depth;
|
|
squared_mean += depth * depth;
|
|
#endif
|
|
}
|
|
mean = mean / samples;
|
|
squared_mean = squared_mean / samples;
|
|
float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
|
|
gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
|
|
}`,i0=[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)],r0=[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)],Bl=new ht,Xi=new F,Gs=new F;function s0(n,e,t){let i=new Uc;const r=new Ge,s=new Ge,a=new mt,o=new xd,l=new vd,c={},h=t.maxTextureSize,f={[kn]:Vt,[Vt]:kn,[bn]:bn},d=new mn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ge},radius:{value:4}},vertexShader:t0,fragmentShader:n0}),m=d.clone();m.defines.HORIZONTAL_PASS=1;const g=new Ct;g.setAttribute("position",new Ut(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const x=new pn(g,d),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=zr;let u=this.type;this.render=function(w,R,I){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||w.length===0)return;w.type===rf&&(Be("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),w.type=zr);const S=n.getRenderTarget(),T=n.getActiveCubeFace(),P=n.getActiveMipmapLevel(),B=n.state;B.setBlending(An),B.buffers.depth.getReversed()===!0?B.buffers.color.setClear(0,0,0,0):B.buffers.color.setClear(1,1,1,1),B.buffers.depth.setTest(!0),B.setScissorTest(!1);const z=u!==this.type;z&&R.traverse(function(j){j.material&&(Array.isArray(j.material)?j.material.forEach(K=>K.needsUpdate=!0):j.material.needsUpdate=!0)});for(let j=0,K=w.length;j<K;j++){const L=w[j],k=L.shadow;if(k===void 0){Be("WebGLShadowMap:",L,"has no shadow.");continue}if(k.autoUpdate===!1&&k.needsUpdate===!1)continue;r.copy(k.mapSize);const Z=k.getFrameExtents();if(r.multiply(Z),s.copy(k.mapSize),(r.x>h||r.y>h)&&(r.x>h&&(s.x=Math.floor(h/Z.x),r.x=s.x*Z.x,k.mapSize.x=s.x),r.y>h&&(s.y=Math.floor(h/Z.y),r.y=s.y*Z.y,k.mapSize.y=s.y)),k.map===null||z===!0){if(k.map!==null&&(k.map.depthTexture!==null&&(k.map.depthTexture.dispose(),k.map.depthTexture=null),k.map.dispose()),this.type===ji){if(L.isPointLight){Be("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}k.map=new fn(r.x,r.y,{format:Ri,type:Rn,minFilter:Rt,magFilter:Rt,generateMipmaps:!1}),k.map.texture.name=L.name+".shadowMap",k.map.depthTexture=new er(r.x,r.y,cn),k.map.depthTexture.name=L.name+".shadowMapDepth",k.map.depthTexture.format=Cn,k.map.depthTexture.compareFunction=null,k.map.depthTexture.minFilter=bt,k.map.depthTexture.magFilter=bt}else{L.isPointLight?(k.map=new Ic(r.x),k.map.depthTexture=new gd(r.x,dn)):(k.map=new fn(r.x,r.y),k.map.depthTexture=new er(r.x,r.y,dn)),k.map.depthTexture.name=L.name+".shadowMap",k.map.depthTexture.format=Cn;const V=n.state.buffers.depth.getReversed();this.type===zr?(k.map.depthTexture.compareFunction=V?no:to,k.map.depthTexture.minFilter=Rt,k.map.depthTexture.magFilter=Rt):(k.map.depthTexture.compareFunction=null,k.map.depthTexture.minFilter=bt,k.map.depthTexture.magFilter=bt)}k.camera.updateProjectionMatrix()}const re=k.map.isWebGLCubeRenderTarget?6:1;for(let V=0;V<re;V++){if(k.map.isWebGLCubeRenderTarget)n.setRenderTarget(k.map,V),n.clear();else{V===0&&(n.setRenderTarget(k.map),n.clear());const W=k.getViewport(V);a.set(s.x*W.x,s.y*W.y,s.x*W.z,s.y*W.w),B.viewport(a)}if(L.isPointLight){const W=k.camera,ce=k.matrix,se=L.distance||W.far;se!==W.far&&(W.far=se,W.updateProjectionMatrix()),Xi.setFromMatrixPosition(L.matrixWorld),W.position.copy(Xi),Gs.copy(W.position),Gs.add(i0[V]),W.up.copy(r0[V]),W.lookAt(Gs),W.updateMatrixWorld(),ce.makeTranslation(-Xi.x,-Xi.y,-Xi.z),Bl.multiplyMatrices(W.projectionMatrix,W.matrixWorldInverse),k._frustum.setFromProjectionMatrix(Bl,W.coordinateSystem,W.reversedDepth)}else k.updateMatrices(L);i=k.getFrustum(),M(R,I,k.camera,L,this.type)}k.isPointLightShadow!==!0&&this.type===ji&&y(k,I),k.needsUpdate=!1}u=this.type,p.needsUpdate=!1,n.setRenderTarget(S,T,P)};function y(w,R){const I=e.update(x);d.defines.VSM_SAMPLES!==w.blurSamples&&(d.defines.VSM_SAMPLES=w.blurSamples,m.defines.VSM_SAMPLES=w.blurSamples,d.needsUpdate=!0,m.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new fn(r.x,r.y,{format:Ri,type:Rn})),d.uniforms.shadow_pass.value=w.map.depthTexture,d.uniforms.resolution.value=w.mapSize,d.uniforms.radius.value=w.radius,n.setRenderTarget(w.mapPass),n.clear(),n.renderBufferDirect(R,null,I,d,x,null),m.uniforms.shadow_pass.value=w.mapPass.texture,m.uniforms.resolution.value=w.mapSize,m.uniforms.radius.value=w.radius,n.setRenderTarget(w.map),n.clear(),n.renderBufferDirect(R,null,I,m,x,null)}function v(w,R,I,S){let T=null;const P=I.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(P!==void 0)T=P;else if(T=I.isPointLight===!0?l:o,n.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 B=T.uuid,z=R.uuid;let j=c[B];j===void 0&&(j={},c[B]=j);let K=j[z];K===void 0&&(K=T.clone(),j[z]=K,R.addEventListener("dispose",b)),T=K}if(T.visible=R.visible,T.wireframe=R.wireframe,S===ji?T.side=R.shadowSide!==null?R.shadowSide:R.side:T.side=R.shadowSide!==null?R.shadowSide:f[R.side],T.alphaMap=R.alphaMap,T.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,T.map=R.map,T.clipShadows=R.clipShadows,T.clippingPlanes=R.clippingPlanes,T.clipIntersection=R.clipIntersection,T.displacementMap=R.displacementMap,T.displacementScale=R.displacementScale,T.displacementBias=R.displacementBias,T.wireframeLinewidth=R.wireframeLinewidth,T.linewidth=R.linewidth,I.isPointLight===!0&&T.isMeshDistanceMaterial===!0){const B=n.properties.get(T);B.light=I}return T}function M(w,R,I,S,T){if(w.visible===!1)return;if(w.layers.test(R.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&T===ji)&&(!w.frustumCulled||i.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(I.matrixWorldInverse,w.matrixWorld);const z=e.update(w),j=w.material;if(Array.isArray(j)){const K=z.groups;for(let L=0,k=K.length;L<k;L++){const Z=K[L],re=j[Z.materialIndex];if(re&&re.visible){const V=v(w,re,S,T);w.onBeforeShadow(n,w,R,I,z,V,Z),n.renderBufferDirect(I,null,z,V,w,Z),w.onAfterShadow(n,w,R,I,z,V,Z)}}}else if(j.visible){const K=v(w,j,S,T);w.onBeforeShadow(n,w,R,I,z,K,null),n.renderBufferDirect(I,null,z,K,w,null),w.onAfterShadow(n,w,R,I,z,K,null)}}const B=w.children;for(let z=0,j=B.length;z<j;z++)M(B[z],R,I,S,T)}function b(w){w.target.removeEventListener("dispose",b);for(const I in c){const S=c[I],T=w.target.uuid;T in S&&(S[T].dispose(),delete S[T])}}}const a0={[$s]:Zs,[Js]:ta,[Qs]:na,[Ai]:ea,[Zs]:$s,[ta]:Js,[na]:Qs,[ea]:Ai};function o0(n,e){function t(){let N=!1;const ve=new mt;let ue=null;const be=new mt(0,0,0,0);return{setMask:function(ae){ue!==ae&&!N&&(n.colorMask(ae,ae,ae,ae),ue=ae)},setLocked:function(ae){N=ae},setClear:function(ae,ee,me,ke,ct){ct===!0&&(ae*=ke,ee*=ke,me*=ke),ve.set(ae,ee,me,ke),be.equals(ve)===!1&&(n.clearColor(ae,ee,me,ke),be.copy(ve))},reset:function(){N=!1,ue=null,be.set(-1,0,0,0)}}}function i(){let N=!1,ve=!1,ue=null,be=null,ae=null;return{setReversed:function(ee){if(ve!==ee){const me=e.get("EXT_clip_control");ee?me.clipControlEXT(me.LOWER_LEFT_EXT,me.ZERO_TO_ONE_EXT):me.clipControlEXT(me.LOWER_LEFT_EXT,me.NEGATIVE_ONE_TO_ONE_EXT),ve=ee;const ke=ae;ae=null,this.setClear(ke)}},getReversed:function(){return ve},setTest:function(ee){ee?Q(n.DEPTH_TEST):ge(n.DEPTH_TEST)},setMask:function(ee){ue!==ee&&!N&&(n.depthMask(ee),ue=ee)},setFunc:function(ee){if(ve&&(ee=a0[ee]),be!==ee){switch(ee){case $s:n.depthFunc(n.NEVER);break;case Zs:n.depthFunc(n.ALWAYS);break;case Js:n.depthFunc(n.LESS);break;case Ai:n.depthFunc(n.LEQUAL);break;case Qs:n.depthFunc(n.EQUAL);break;case ea:n.depthFunc(n.GEQUAL);break;case ta:n.depthFunc(n.GREATER);break;case na:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}be=ee}},setLocked:function(ee){N=ee},setClear:function(ee){ae!==ee&&(ve&&(ee=1-ee),n.clearDepth(ee),ae=ee)},reset:function(){N=!1,ue=null,be=null,ae=null,ve=!1}}}function r(){let N=!1,ve=null,ue=null,be=null,ae=null,ee=null,me=null,ke=null,ct=null;return{setTest:function(tt){N||(tt?Q(n.STENCIL_TEST):ge(n.STENCIL_TEST))},setMask:function(tt){ve!==tt&&!N&&(n.stencilMask(tt),ve=tt)},setFunc:function(tt,sn,gn){(ue!==tt||be!==sn||ae!==gn)&&(n.stencilFunc(tt,sn,gn),ue=tt,be=sn,ae=gn)},setOp:function(tt,sn,gn){(ee!==tt||me!==sn||ke!==gn)&&(n.stencilOp(tt,sn,gn),ee=tt,me=sn,ke=gn)},setLocked:function(tt){N=tt},setClear:function(tt){ct!==tt&&(n.clearStencil(tt),ct=tt)},reset:function(){N=!1,ve=null,ue=null,be=null,ae=null,ee=null,me=null,ke=null,ct=null}}}const s=new t,a=new i,o=new r,l=new WeakMap,c=new WeakMap;let h={},f={},d=new WeakMap,m=[],g=null,x=!1,p=null,u=null,y=null,v=null,M=null,b=null,w=null,R=new Qe(0,0,0),I=0,S=!1,T=null,P=null,B=null,z=null,j=null;const K=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let L=!1,k=0;const Z=n.getParameter(n.VERSION);Z.indexOf("WebGL")!==-1?(k=parseFloat(/^WebGL (\d)/.exec(Z)[1]),L=k>=1):Z.indexOf("OpenGL ES")!==-1&&(k=parseFloat(/^OpenGL ES (\d)/.exec(Z)[1]),L=k>=2);let re=null,V={};const W=n.getParameter(n.SCISSOR_BOX),ce=n.getParameter(n.VIEWPORT),se=new mt().fromArray(W),we=new mt().fromArray(ce);function Se(N,ve,ue,be){const ae=new Uint8Array(4),ee=n.createTexture();n.bindTexture(N,ee),n.texParameteri(N,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(N,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let me=0;me<ue;me++)N===n.TEXTURE_3D||N===n.TEXTURE_2D_ARRAY?n.texImage3D(ve,0,n.RGBA,1,1,be,0,n.RGBA,n.UNSIGNED_BYTE,ae):n.texImage2D(ve+me,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,ae);return ee}const Y={};Y[n.TEXTURE_2D]=Se(n.TEXTURE_2D,n.TEXTURE_2D,1),Y[n.TEXTURE_CUBE_MAP]=Se(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),Y[n.TEXTURE_2D_ARRAY]=Se(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),Y[n.TEXTURE_3D]=Se(n.TEXTURE_3D,n.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),o.setClear(0),Q(n.DEPTH_TEST),a.setFunc(Ai),ze(!1),lt(Uo),Q(n.CULL_FACE),Fe(An);function Q(N){h[N]!==!0&&(n.enable(N),h[N]=!0)}function ge(N){h[N]!==!1&&(n.disable(N),h[N]=!1)}function Ce(N,ve){return f[N]!==ve?(n.bindFramebuffer(N,ve),f[N]=ve,N===n.DRAW_FRAMEBUFFER&&(f[n.FRAMEBUFFER]=ve),N===n.FRAMEBUFFER&&(f[n.DRAW_FRAMEBUFFER]=ve),!0):!1}function le(N,ve){let ue=m,be=!1;if(N){ue=d.get(ve),ue===void 0&&(ue=[],d.set(ve,ue));const ae=N.textures;if(ue.length!==ae.length||ue[0]!==n.COLOR_ATTACHMENT0){for(let ee=0,me=ae.length;ee<me;ee++)ue[ee]=n.COLOR_ATTACHMENT0+ee;ue.length=ae.length,be=!0}}else ue[0]!==n.BACK&&(ue[0]=n.BACK,be=!0);be&&n.drawBuffers(ue)}function De(N){return g!==N?(n.useProgram(N),g=N,!0):!1}const Ve={[Kn]:n.FUNC_ADD,[af]:n.FUNC_SUBTRACT,[of]:n.FUNC_REVERSE_SUBTRACT};Ve[lf]=n.MIN,Ve[cf]=n.MAX;const Ne={[uf]:n.ZERO,[hf]:n.ONE,[ff]:n.SRC_COLOR,[js]:n.SRC_ALPHA,[xf]:n.SRC_ALPHA_SATURATE,[gf]:n.DST_COLOR,[pf]:n.DST_ALPHA,[df]:n.ONE_MINUS_SRC_COLOR,[Ks]:n.ONE_MINUS_SRC_ALPHA,[_f]:n.ONE_MINUS_DST_COLOR,[mf]:n.ONE_MINUS_DST_ALPHA,[vf]:n.CONSTANT_COLOR,[Mf]:n.ONE_MINUS_CONSTANT_COLOR,[Sf]:n.CONSTANT_ALPHA,[yf]:n.ONE_MINUS_CONSTANT_ALPHA};function Fe(N,ve,ue,be,ae,ee,me,ke,ct,tt){if(N===An){x===!0&&(ge(n.BLEND),x=!1);return}if(x===!1&&(Q(n.BLEND),x=!0),N!==sf){if(N!==p||tt!==S){if((u!==Kn||M!==Kn)&&(n.blendEquation(n.FUNC_ADD),u=Kn,M=Kn),tt)switch(N){case yi:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Fo:n.blendFunc(n.ONE,n.ONE);break;case Oo:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case Bo:n.blendFuncSeparate(n.DST_COLOR,n.ONE_MINUS_SRC_ALPHA,n.ZERO,n.ONE);break;default:$e("WebGLState: Invalid blending: ",N);break}else switch(N){case yi:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Fo:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE,n.ONE,n.ONE);break;case Oo:$e("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Bo:$e("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:$e("WebGLState: Invalid blending: ",N);break}y=null,v=null,b=null,w=null,R.set(0,0,0),I=0,p=N,S=tt}return}ae=ae||ve,ee=ee||ue,me=me||be,(ve!==u||ae!==M)&&(n.blendEquationSeparate(Ve[ve],Ve[ae]),u=ve,M=ae),(ue!==y||be!==v||ee!==b||me!==w)&&(n.blendFuncSeparate(Ne[ue],Ne[be],Ne[ee],Ne[me]),y=ue,v=be,b=ee,w=me),(ke.equals(R)===!1||ct!==I)&&(n.blendColor(ke.r,ke.g,ke.b,ct),R.copy(ke),I=ct),p=N,S=!1}function je(N,ve){N.side===bn?ge(n.CULL_FACE):Q(n.CULL_FACE);let ue=N.side===Vt;ve&&(ue=!ue),ze(ue),N.blending===yi&&N.transparent===!1?Fe(An):Fe(N.blending,N.blendEquation,N.blendSrc,N.blendDst,N.blendEquationAlpha,N.blendSrcAlpha,N.blendDstAlpha,N.blendColor,N.blendAlpha,N.premultipliedAlpha),a.setFunc(N.depthFunc),a.setTest(N.depthTest),a.setMask(N.depthWrite),s.setMask(N.colorWrite);const be=N.stencilWrite;o.setTest(be),be&&(o.setMask(N.stencilWriteMask),o.setFunc(N.stencilFunc,N.stencilRef,N.stencilFuncMask),o.setOp(N.stencilFail,N.stencilZFail,N.stencilZPass)),et(N.polygonOffset,N.polygonOffsetFactor,N.polygonOffsetUnits),N.alphaToCoverage===!0?Q(n.SAMPLE_ALPHA_TO_COVERAGE):ge(n.SAMPLE_ALPHA_TO_COVERAGE)}function ze(N){T!==N&&(N?n.frontFace(n.CW):n.frontFace(n.CCW),T=N)}function lt(N){N!==tf?(Q(n.CULL_FACE),N!==P&&(N===Uo?n.cullFace(n.BACK):N===nf?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):ge(n.CULL_FACE),P=N}function C(N){N!==B&&(L&&n.lineWidth(N),B=N)}function et(N,ve,ue){N?(Q(n.POLYGON_OFFSET_FILL),(z!==ve||j!==ue)&&(n.polygonOffset(ve,ue),z=ve,j=ue)):ge(n.POLYGON_OFFSET_FILL)}function Ke(N){N?Q(n.SCISSOR_TEST):ge(n.SCISSOR_TEST)}function xe(N){N===void 0&&(N=n.TEXTURE0+K-1),re!==N&&(n.activeTexture(N),re=N)}function ne(N,ve,ue){ue===void 0&&(re===null?ue=n.TEXTURE0+K-1:ue=re);let be=V[ue];be===void 0&&(be={type:void 0,texture:void 0},V[ue]=be),(be.type!==N||be.texture!==ve)&&(re!==ue&&(n.activeTexture(ue),re=ue),n.bindTexture(N,ve||Y[N]),be.type=N,be.texture=ve)}function A(){const N=V[re];N!==void 0&&N.type!==void 0&&(n.bindTexture(N.type,null),N.type=void 0,N.texture=void 0)}function _(){try{n.compressedTexImage2D(...arguments)}catch(N){$e("WebGLState:",N)}}function D(){try{n.compressedTexImage3D(...arguments)}catch(N){$e("WebGLState:",N)}}function G(){try{n.texSubImage2D(...arguments)}catch(N){$e("WebGLState:",N)}}function $(){try{n.texSubImage3D(...arguments)}catch(N){$e("WebGLState:",N)}}function H(){try{n.compressedTexSubImage2D(...arguments)}catch(N){$e("WebGLState:",N)}}function pe(){try{n.compressedTexSubImage3D(...arguments)}catch(N){$e("WebGLState:",N)}}function te(){try{n.texStorage2D(...arguments)}catch(N){$e("WebGLState:",N)}}function fe(){try{n.texStorage3D(...arguments)}catch(N){$e("WebGLState:",N)}}function Pe(){try{n.texImage2D(...arguments)}catch(N){$e("WebGLState:",N)}}function ie(){try{n.texImage3D(...arguments)}catch(N){$e("WebGLState:",N)}}function oe(N){se.equals(N)===!1&&(n.scissor(N.x,N.y,N.z,N.w),se.copy(N))}function Ee(N){we.equals(N)===!1&&(n.viewport(N.x,N.y,N.z,N.w),we.copy(N))}function Re(N,ve){let ue=c.get(ve);ue===void 0&&(ue=new WeakMap,c.set(ve,ue));let be=ue.get(N);be===void 0&&(be=n.getUniformBlockIndex(ve,N.name),ue.set(N,be))}function de(N,ve){const be=c.get(ve).get(N);l.get(ve)!==be&&(n.uniformBlockBinding(ve,be,N.__bindingPointIndex),l.set(ve,be))}function He(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),a.setReversed(!1),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),h={},re=null,V={},f={},d=new WeakMap,m=[],g=null,x=!1,p=null,u=null,y=null,v=null,M=null,b=null,w=null,R=new Qe(0,0,0),I=0,S=!1,T=null,P=null,B=null,z=null,j=null,se.set(0,0,n.canvas.width,n.canvas.height),we.set(0,0,n.canvas.width,n.canvas.height),s.reset(),a.reset(),o.reset()}return{buffers:{color:s,depth:a,stencil:o},enable:Q,disable:ge,bindFramebuffer:Ce,drawBuffers:le,useProgram:De,setBlending:Fe,setMaterial:je,setFlipSided:ze,setCullFace:lt,setLineWidth:C,setPolygonOffset:et,setScissorTest:Ke,activeTexture:xe,bindTexture:ne,unbindTexture:A,compressedTexImage2D:_,compressedTexImage3D:D,texImage2D:Pe,texImage3D:ie,updateUBOMapping:Re,uniformBlockBinding:de,texStorage2D:te,texStorage3D:fe,texSubImage2D:G,texSubImage3D:$,compressedTexSubImage2D:H,compressedTexSubImage3D:pe,scissor:oe,viewport:Ee,reset:He}}function l0(n,e,t,i,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 Ge,h=new WeakMap;let f;const d=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(A,_){return m?new OffscreenCanvas(A,_):Zr("canvas")}function x(A,_,D){let G=1;const $=ne(A);if(($.width>D||$.height>D)&&(G=D/Math.max($.width,$.height)),G<1)if(typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&A instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&A instanceof ImageBitmap||typeof VideoFrame<"u"&&A instanceof VideoFrame){const H=Math.floor(G*$.width),pe=Math.floor(G*$.height);f===void 0&&(f=g(H,pe));const te=_?g(H,pe):f;return te.width=H,te.height=pe,te.getContext("2d").drawImage(A,0,0,H,pe),Be("WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+H+"x"+pe+")."),te}else return"data"in A&&Be("WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),A;return A}function p(A){return A.generateMipmaps}function u(A){n.generateMipmap(A)}function y(A){return A.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:A.isWebGL3DRenderTarget?n.TEXTURE_3D:A.isWebGLArrayRenderTarget||A.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function v(A,_,D,G,$=!1){if(A!==null){if(n[A]!==void 0)return n[A];Be("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+A+"'")}let H=_;if(_===n.RED&&(D===n.FLOAT&&(H=n.R32F),D===n.HALF_FLOAT&&(H=n.R16F),D===n.UNSIGNED_BYTE&&(H=n.R8)),_===n.RED_INTEGER&&(D===n.UNSIGNED_BYTE&&(H=n.R8UI),D===n.UNSIGNED_SHORT&&(H=n.R16UI),D===n.UNSIGNED_INT&&(H=n.R32UI),D===n.BYTE&&(H=n.R8I),D===n.SHORT&&(H=n.R16I),D===n.INT&&(H=n.R32I)),_===n.RG&&(D===n.FLOAT&&(H=n.RG32F),D===n.HALF_FLOAT&&(H=n.RG16F),D===n.UNSIGNED_BYTE&&(H=n.RG8)),_===n.RG_INTEGER&&(D===n.UNSIGNED_BYTE&&(H=n.RG8UI),D===n.UNSIGNED_SHORT&&(H=n.RG16UI),D===n.UNSIGNED_INT&&(H=n.RG32UI),D===n.BYTE&&(H=n.RG8I),D===n.SHORT&&(H=n.RG16I),D===n.INT&&(H=n.RG32I)),_===n.RGB_INTEGER&&(D===n.UNSIGNED_BYTE&&(H=n.RGB8UI),D===n.UNSIGNED_SHORT&&(H=n.RGB16UI),D===n.UNSIGNED_INT&&(H=n.RGB32UI),D===n.BYTE&&(H=n.RGB8I),D===n.SHORT&&(H=n.RGB16I),D===n.INT&&(H=n.RGB32I)),_===n.RGBA_INTEGER&&(D===n.UNSIGNED_BYTE&&(H=n.RGBA8UI),D===n.UNSIGNED_SHORT&&(H=n.RGBA16UI),D===n.UNSIGNED_INT&&(H=n.RGBA32UI),D===n.BYTE&&(H=n.RGBA8I),D===n.SHORT&&(H=n.RGBA16I),D===n.INT&&(H=n.RGBA32I)),_===n.RGB&&(D===n.UNSIGNED_INT_5_9_9_9_REV&&(H=n.RGB9_E5),D===n.UNSIGNED_INT_10F_11F_11F_REV&&(H=n.R11F_G11F_B10F)),_===n.RGBA){const pe=$?Kr:Ze.getTransfer(G);D===n.FLOAT&&(H=n.RGBA32F),D===n.HALF_FLOAT&&(H=n.RGBA16F),D===n.UNSIGNED_BYTE&&(H=pe===it?n.SRGB8_ALPHA8:n.RGBA8),D===n.UNSIGNED_SHORT_4_4_4_4&&(H=n.RGBA4),D===n.UNSIGNED_SHORT_5_5_5_1&&(H=n.RGB5_A1)}return(H===n.R16F||H===n.R32F||H===n.RG16F||H===n.RG32F||H===n.RGBA16F||H===n.RGBA32F)&&e.get("EXT_color_buffer_float"),H}function M(A,_){let D;return A?_===null||_===dn||_===Ji?D=n.DEPTH24_STENCIL8:_===cn?D=n.DEPTH32F_STENCIL8:_===Zi&&(D=n.DEPTH24_STENCIL8,Be("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):_===null||_===dn||_===Ji?D=n.DEPTH_COMPONENT24:_===cn?D=n.DEPTH_COMPONENT32F:_===Zi&&(D=n.DEPTH_COMPONENT16),D}function b(A,_){return p(A)===!0||A.isFramebufferTexture&&A.minFilter!==bt&&A.minFilter!==Rt?Math.log2(Math.max(_.width,_.height))+1:A.mipmaps!==void 0&&A.mipmaps.length>0?A.mipmaps.length:A.isCompressedTexture&&Array.isArray(A.image)?_.mipmaps.length:1}function w(A){const _=A.target;_.removeEventListener("dispose",w),I(_),_.isVideoTexture&&h.delete(_)}function R(A){const _=A.target;_.removeEventListener("dispose",R),T(_)}function I(A){const _=i.get(A);if(_.__webglInit===void 0)return;const D=A.source,G=d.get(D);if(G){const $=G[_.__cacheKey];$.usedTimes--,$.usedTimes===0&&S(A),Object.keys(G).length===0&&d.delete(D)}i.remove(A)}function S(A){const _=i.get(A);n.deleteTexture(_.__webglTexture);const D=A.source,G=d.get(D);delete G[_.__cacheKey],a.memory.textures--}function T(A){const _=i.get(A);if(A.depthTexture&&(A.depthTexture.dispose(),i.remove(A.depthTexture)),A.isWebGLCubeRenderTarget)for(let G=0;G<6;G++){if(Array.isArray(_.__webglFramebuffer[G]))for(let $=0;$<_.__webglFramebuffer[G].length;$++)n.deleteFramebuffer(_.__webglFramebuffer[G][$]);else n.deleteFramebuffer(_.__webglFramebuffer[G]);_.__webglDepthbuffer&&n.deleteRenderbuffer(_.__webglDepthbuffer[G])}else{if(Array.isArray(_.__webglFramebuffer))for(let G=0;G<_.__webglFramebuffer.length;G++)n.deleteFramebuffer(_.__webglFramebuffer[G]);else n.deleteFramebuffer(_.__webglFramebuffer);if(_.__webglDepthbuffer&&n.deleteRenderbuffer(_.__webglDepthbuffer),_.__webglMultisampledFramebuffer&&n.deleteFramebuffer(_.__webglMultisampledFramebuffer),_.__webglColorRenderbuffer)for(let G=0;G<_.__webglColorRenderbuffer.length;G++)_.__webglColorRenderbuffer[G]&&n.deleteRenderbuffer(_.__webglColorRenderbuffer[G]);_.__webglDepthRenderbuffer&&n.deleteRenderbuffer(_.__webglDepthRenderbuffer)}const D=A.textures;for(let G=0,$=D.length;G<$;G++){const H=i.get(D[G]);H.__webglTexture&&(n.deleteTexture(H.__webglTexture),a.memory.textures--),i.remove(D[G])}i.remove(A)}let P=0;function B(){P=0}function z(){const A=P;return A>=r.maxTextures&&Be("WebGLTextures: Trying to use "+A+" texture units while this GPU supports only "+r.maxTextures),P+=1,A}function j(A){const _=[];return _.push(A.wrapS),_.push(A.wrapT),_.push(A.wrapR||0),_.push(A.magFilter),_.push(A.minFilter),_.push(A.anisotropy),_.push(A.internalFormat),_.push(A.format),_.push(A.type),_.push(A.generateMipmaps),_.push(A.premultiplyAlpha),_.push(A.flipY),_.push(A.unpackAlignment),_.push(A.colorSpace),_.join()}function K(A,_){const D=i.get(A);if(A.isVideoTexture&&Ke(A),A.isRenderTargetTexture===!1&&A.isExternalTexture!==!0&&A.version>0&&D.__version!==A.version){const G=A.image;if(G===null)Be("WebGLRenderer: Texture marked for update but no image data found.");else if(G.complete===!1)Be("WebGLRenderer: Texture marked for update but image is incomplete");else{Y(D,A,_);return}}else A.isExternalTexture&&(D.__webglTexture=A.sourceTexture?A.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,D.__webglTexture,n.TEXTURE0+_)}function L(A,_){const D=i.get(A);if(A.isRenderTargetTexture===!1&&A.version>0&&D.__version!==A.version){Y(D,A,_);return}else A.isExternalTexture&&(D.__webglTexture=A.sourceTexture?A.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,D.__webglTexture,n.TEXTURE0+_)}function k(A,_){const D=i.get(A);if(A.isRenderTargetTexture===!1&&A.version>0&&D.__version!==A.version){Y(D,A,_);return}t.bindTexture(n.TEXTURE_3D,D.__webglTexture,n.TEXTURE0+_)}function Z(A,_){const D=i.get(A);if(A.isCubeDepthTexture!==!0&&A.version>0&&D.__version!==A.version){Q(D,A,_);return}t.bindTexture(n.TEXTURE_CUBE_MAP,D.__webglTexture,n.TEXTURE0+_)}const re={[sa]:n.REPEAT,[En]:n.CLAMP_TO_EDGE,[aa]:n.MIRRORED_REPEAT},V={[bt]:n.NEAREST,[Tf]:n.NEAREST_MIPMAP_NEAREST,[fr]:n.NEAREST_MIPMAP_LINEAR,[Rt]:n.LINEAR,[fs]:n.LINEAR_MIPMAP_NEAREST,[Zn]:n.LINEAR_MIPMAP_LINEAR},W={[Cf]:n.NEVER,[If]:n.ALWAYS,[Pf]:n.LESS,[to]:n.LEQUAL,[Df]:n.EQUAL,[no]:n.GEQUAL,[Lf]:n.GREATER,[Nf]:n.NOTEQUAL};function ce(A,_){if(_.type===cn&&e.has("OES_texture_float_linear")===!1&&(_.magFilter===Rt||_.magFilter===fs||_.magFilter===fr||_.magFilter===Zn||_.minFilter===Rt||_.minFilter===fs||_.minFilter===fr||_.minFilter===Zn)&&Be("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(A,n.TEXTURE_WRAP_S,re[_.wrapS]),n.texParameteri(A,n.TEXTURE_WRAP_T,re[_.wrapT]),(A===n.TEXTURE_3D||A===n.TEXTURE_2D_ARRAY)&&n.texParameteri(A,n.TEXTURE_WRAP_R,re[_.wrapR]),n.texParameteri(A,n.TEXTURE_MAG_FILTER,V[_.magFilter]),n.texParameteri(A,n.TEXTURE_MIN_FILTER,V[_.minFilter]),_.compareFunction&&(n.texParameteri(A,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(A,n.TEXTURE_COMPARE_FUNC,W[_.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(_.magFilter===bt||_.minFilter!==fr&&_.minFilter!==Zn||_.type===cn&&e.has("OES_texture_float_linear")===!1)return;if(_.anisotropy>1||i.get(_).__currentAnisotropy){const D=e.get("EXT_texture_filter_anisotropic");n.texParameterf(A,D.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(_.anisotropy,r.getMaxAnisotropy())),i.get(_).__currentAnisotropy=_.anisotropy}}}function se(A,_){let D=!1;A.__webglInit===void 0&&(A.__webglInit=!0,_.addEventListener("dispose",w));const G=_.source;let $=d.get(G);$===void 0&&($={},d.set(G,$));const H=j(_);if(H!==A.__cacheKey){$[H]===void 0&&($[H]={texture:n.createTexture(),usedTimes:0},a.memory.textures++,D=!0),$[H].usedTimes++;const pe=$[A.__cacheKey];pe!==void 0&&($[A.__cacheKey].usedTimes--,pe.usedTimes===0&&S(_)),A.__cacheKey=H,A.__webglTexture=$[H].texture}return D}function we(A,_,D){return Math.floor(Math.floor(A/D)/_)}function Se(A,_,D,G){const H=A.updateRanges;if(H.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,_.width,_.height,D,G,_.data);else{H.sort((ie,oe)=>ie.start-oe.start);let pe=0;for(let ie=1;ie<H.length;ie++){const oe=H[pe],Ee=H[ie],Re=oe.start+oe.count,de=we(Ee.start,_.width,4),He=we(oe.start,_.width,4);Ee.start<=Re+1&&de===He&&we(Ee.start+Ee.count-1,_.width,4)===de?oe.count=Math.max(oe.count,Ee.start+Ee.count-oe.start):(++pe,H[pe]=Ee)}H.length=pe+1;const te=n.getParameter(n.UNPACK_ROW_LENGTH),fe=n.getParameter(n.UNPACK_SKIP_PIXELS),Pe=n.getParameter(n.UNPACK_SKIP_ROWS);n.pixelStorei(n.UNPACK_ROW_LENGTH,_.width);for(let ie=0,oe=H.length;ie<oe;ie++){const Ee=H[ie],Re=Math.floor(Ee.start/4),de=Math.ceil(Ee.count/4),He=Re%_.width,N=Math.floor(Re/_.width),ve=de,ue=1;n.pixelStorei(n.UNPACK_SKIP_PIXELS,He),n.pixelStorei(n.UNPACK_SKIP_ROWS,N),t.texSubImage2D(n.TEXTURE_2D,0,He,N,ve,ue,D,G,_.data)}A.clearUpdateRanges(),n.pixelStorei(n.UNPACK_ROW_LENGTH,te),n.pixelStorei(n.UNPACK_SKIP_PIXELS,fe),n.pixelStorei(n.UNPACK_SKIP_ROWS,Pe)}}function Y(A,_,D){let G=n.TEXTURE_2D;(_.isDataArrayTexture||_.isCompressedArrayTexture)&&(G=n.TEXTURE_2D_ARRAY),_.isData3DTexture&&(G=n.TEXTURE_3D);const $=se(A,_),H=_.source;t.bindTexture(G,A.__webglTexture,n.TEXTURE0+D);const pe=i.get(H);if(H.version!==pe.__version||$===!0){t.activeTexture(n.TEXTURE0+D);const te=Ze.getPrimaries(Ze.workingColorSpace),fe=_.colorSpace===Bn?null:Ze.getPrimaries(_.colorSpace),Pe=_.colorSpace===Bn||te===fe?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,_.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,_.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Pe);let ie=x(_.image,!1,r.maxTextureSize);ie=xe(_,ie);const oe=s.convert(_.format,_.colorSpace),Ee=s.convert(_.type);let Re=v(_.internalFormat,oe,Ee,_.colorSpace,_.isVideoTexture);ce(G,_);let de;const He=_.mipmaps,N=_.isVideoTexture!==!0,ve=pe.__version===void 0||$===!0,ue=H.dataReady,be=b(_,ie);if(_.isDepthTexture)Re=M(_.format===Jn,_.type),ve&&(N?t.texStorage2D(n.TEXTURE_2D,1,Re,ie.width,ie.height):t.texImage2D(n.TEXTURE_2D,0,Re,ie.width,ie.height,0,oe,Ee,null));else if(_.isDataTexture)if(He.length>0){N&&ve&&t.texStorage2D(n.TEXTURE_2D,be,Re,He[0].width,He[0].height);for(let ae=0,ee=He.length;ae<ee;ae++)de=He[ae],N?ue&&t.texSubImage2D(n.TEXTURE_2D,ae,0,0,de.width,de.height,oe,Ee,de.data):t.texImage2D(n.TEXTURE_2D,ae,Re,de.width,de.height,0,oe,Ee,de.data);_.generateMipmaps=!1}else N?(ve&&t.texStorage2D(n.TEXTURE_2D,be,Re,ie.width,ie.height),ue&&Se(_,ie,oe,Ee)):t.texImage2D(n.TEXTURE_2D,0,Re,ie.width,ie.height,0,oe,Ee,ie.data);else if(_.isCompressedTexture)if(_.isCompressedArrayTexture){N&&ve&&t.texStorage3D(n.TEXTURE_2D_ARRAY,be,Re,He[0].width,He[0].height,ie.depth);for(let ae=0,ee=He.length;ae<ee;ae++)if(de=He[ae],_.format!==rn)if(oe!==null)if(N){if(ue)if(_.layerUpdates.size>0){const me=ml(de.width,de.height,_.format,_.type);for(const ke of _.layerUpdates){const ct=de.data.subarray(ke*me/de.data.BYTES_PER_ELEMENT,(ke+1)*me/de.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ae,0,0,ke,de.width,de.height,1,oe,ct)}_.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ae,0,0,0,de.width,de.height,ie.depth,oe,de.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,ae,Re,de.width,de.height,ie.depth,0,de.data,0,0);else Be("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else N?ue&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,ae,0,0,0,de.width,de.height,ie.depth,oe,Ee,de.data):t.texImage3D(n.TEXTURE_2D_ARRAY,ae,Re,de.width,de.height,ie.depth,0,oe,Ee,de.data)}else{N&&ve&&t.texStorage2D(n.TEXTURE_2D,be,Re,He[0].width,He[0].height);for(let ae=0,ee=He.length;ae<ee;ae++)de=He[ae],_.format!==rn?oe!==null?N?ue&&t.compressedTexSubImage2D(n.TEXTURE_2D,ae,0,0,de.width,de.height,oe,de.data):t.compressedTexImage2D(n.TEXTURE_2D,ae,Re,de.width,de.height,0,de.data):Be("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):N?ue&&t.texSubImage2D(n.TEXTURE_2D,ae,0,0,de.width,de.height,oe,Ee,de.data):t.texImage2D(n.TEXTURE_2D,ae,Re,de.width,de.height,0,oe,Ee,de.data)}else if(_.isDataArrayTexture)if(N){if(ve&&t.texStorage3D(n.TEXTURE_2D_ARRAY,be,Re,ie.width,ie.height,ie.depth),ue)if(_.layerUpdates.size>0){const ae=ml(ie.width,ie.height,_.format,_.type);for(const ee of _.layerUpdates){const me=ie.data.subarray(ee*ae/ie.data.BYTES_PER_ELEMENT,(ee+1)*ae/ie.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,ee,ie.width,ie.height,1,oe,Ee,me)}_.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,ie.width,ie.height,ie.depth,oe,Ee,ie.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,Re,ie.width,ie.height,ie.depth,0,oe,Ee,ie.data);else if(_.isData3DTexture)N?(ve&&t.texStorage3D(n.TEXTURE_3D,be,Re,ie.width,ie.height,ie.depth),ue&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,ie.width,ie.height,ie.depth,oe,Ee,ie.data)):t.texImage3D(n.TEXTURE_3D,0,Re,ie.width,ie.height,ie.depth,0,oe,Ee,ie.data);else if(_.isFramebufferTexture){if(ve)if(N)t.texStorage2D(n.TEXTURE_2D,be,Re,ie.width,ie.height);else{let ae=ie.width,ee=ie.height;for(let me=0;me<be;me++)t.texImage2D(n.TEXTURE_2D,me,Re,ae,ee,0,oe,Ee,null),ae>>=1,ee>>=1}}else if(He.length>0){if(N&&ve){const ae=ne(He[0]);t.texStorage2D(n.TEXTURE_2D,be,Re,ae.width,ae.height)}for(let ae=0,ee=He.length;ae<ee;ae++)de=He[ae],N?ue&&t.texSubImage2D(n.TEXTURE_2D,ae,0,0,oe,Ee,de):t.texImage2D(n.TEXTURE_2D,ae,Re,oe,Ee,de);_.generateMipmaps=!1}else if(N){if(ve){const ae=ne(ie);t.texStorage2D(n.TEXTURE_2D,be,Re,ae.width,ae.height)}ue&&t.texSubImage2D(n.TEXTURE_2D,0,0,0,oe,Ee,ie)}else t.texImage2D(n.TEXTURE_2D,0,Re,oe,Ee,ie);p(_)&&u(G),pe.__version=H.version,_.onUpdate&&_.onUpdate(_)}A.__version=_.version}function Q(A,_,D){if(_.image.length!==6)return;const G=se(A,_),$=_.source;t.bindTexture(n.TEXTURE_CUBE_MAP,A.__webglTexture,n.TEXTURE0+D);const H=i.get($);if($.version!==H.__version||G===!0){t.activeTexture(n.TEXTURE0+D);const pe=Ze.getPrimaries(Ze.workingColorSpace),te=_.colorSpace===Bn?null:Ze.getPrimaries(_.colorSpace),fe=_.colorSpace===Bn||pe===te?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,_.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,_.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,_.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,fe);const Pe=_.isCompressedTexture||_.image[0].isCompressedTexture,ie=_.image[0]&&_.image[0].isDataTexture,oe=[];for(let ee=0;ee<6;ee++)!Pe&&!ie?oe[ee]=x(_.image[ee],!0,r.maxCubemapSize):oe[ee]=ie?_.image[ee].image:_.image[ee],oe[ee]=xe(_,oe[ee]);const Ee=oe[0],Re=s.convert(_.format,_.colorSpace),de=s.convert(_.type),He=v(_.internalFormat,Re,de,_.colorSpace),N=_.isVideoTexture!==!0,ve=H.__version===void 0||G===!0,ue=$.dataReady;let be=b(_,Ee);ce(n.TEXTURE_CUBE_MAP,_);let ae;if(Pe){N&&ve&&t.texStorage2D(n.TEXTURE_CUBE_MAP,be,He,Ee.width,Ee.height);for(let ee=0;ee<6;ee++){ae=oe[ee].mipmaps;for(let me=0;me<ae.length;me++){const ke=ae[me];_.format!==rn?Re!==null?N?ue&&t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,me,0,0,ke.width,ke.height,Re,ke.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,me,He,ke.width,ke.height,0,ke.data):Be("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):N?ue&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,me,0,0,ke.width,ke.height,Re,de,ke.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,me,He,ke.width,ke.height,0,Re,de,ke.data)}}}else{if(ae=_.mipmaps,N&&ve){ae.length>0&&be++;const ee=ne(oe[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,be,He,ee.width,ee.height)}for(let ee=0;ee<6;ee++)if(ie){N?ue&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,oe[ee].width,oe[ee].height,Re,de,oe[ee].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,He,oe[ee].width,oe[ee].height,0,Re,de,oe[ee].data);for(let me=0;me<ae.length;me++){const ct=ae[me].image[ee].image;N?ue&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,me+1,0,0,ct.width,ct.height,Re,de,ct.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,me+1,He,ct.width,ct.height,0,Re,de,ct.data)}}else{N?ue&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,0,0,Re,de,oe[ee]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,0,He,Re,de,oe[ee]);for(let me=0;me<ae.length;me++){const ke=ae[me];N?ue&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,me+1,0,0,Re,de,ke.image[ee]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+ee,me+1,He,Re,de,ke.image[ee])}}}p(_)&&u(n.TEXTURE_CUBE_MAP),H.__version=$.version,_.onUpdate&&_.onUpdate(_)}A.__version=_.version}function ge(A,_,D,G,$,H){const pe=s.convert(D.format,D.colorSpace),te=s.convert(D.type),fe=v(D.internalFormat,pe,te,D.colorSpace),Pe=i.get(_),ie=i.get(D);if(ie.__renderTarget=_,!Pe.__hasExternalTextures){const oe=Math.max(1,_.width>>H),Ee=Math.max(1,_.height>>H);$===n.TEXTURE_3D||$===n.TEXTURE_2D_ARRAY?t.texImage3D($,H,fe,oe,Ee,_.depth,0,pe,te,null):t.texImage2D($,H,fe,oe,Ee,0,pe,te,null)}t.bindFramebuffer(n.FRAMEBUFFER,A),et(_)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,G,$,ie.__webglTexture,0,C(_)):($===n.TEXTURE_2D||$>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,G,$,ie.__webglTexture,H),t.bindFramebuffer(n.FRAMEBUFFER,null)}function Ce(A,_,D){if(n.bindRenderbuffer(n.RENDERBUFFER,A),_.depthBuffer){const G=_.depthTexture,$=G&&G.isDepthTexture?G.type:null,H=M(_.stencilBuffer,$),pe=_.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;et(_)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,C(_),H,_.width,_.height):D?n.renderbufferStorageMultisample(n.RENDERBUFFER,C(_),H,_.width,_.height):n.renderbufferStorage(n.RENDERBUFFER,H,_.width,_.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,pe,n.RENDERBUFFER,A)}else{const G=_.textures;for(let $=0;$<G.length;$++){const H=G[$],pe=s.convert(H.format,H.colorSpace),te=s.convert(H.type),fe=v(H.internalFormat,pe,te,H.colorSpace);et(_)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,C(_),fe,_.width,_.height):D?n.renderbufferStorageMultisample(n.RENDERBUFFER,C(_),fe,_.width,_.height):n.renderbufferStorage(n.RENDERBUFFER,fe,_.width,_.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function le(A,_,D){const G=_.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(n.FRAMEBUFFER,A),!(_.depthTexture&&_.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const $=i.get(_.depthTexture);if($.__renderTarget=_,(!$.__webglTexture||_.depthTexture.image.width!==_.width||_.depthTexture.image.height!==_.height)&&(_.depthTexture.image.width=_.width,_.depthTexture.image.height=_.height,_.depthTexture.needsUpdate=!0),G){if($.__webglInit===void 0&&($.__webglInit=!0,_.depthTexture.addEventListener("dispose",w)),$.__webglTexture===void 0){$.__webglTexture=n.createTexture(),t.bindTexture(n.TEXTURE_CUBE_MAP,$.__webglTexture),ce(n.TEXTURE_CUBE_MAP,_.depthTexture);const Pe=s.convert(_.depthTexture.format),ie=s.convert(_.depthTexture.type);let oe;_.depthTexture.format===Cn?oe=n.DEPTH_COMPONENT24:_.depthTexture.format===Jn&&(oe=n.DEPTH24_STENCIL8);for(let Ee=0;Ee<6;Ee++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ee,0,oe,_.width,_.height,0,Pe,ie,null)}}else K(_.depthTexture,0);const H=$.__webglTexture,pe=C(_),te=G?n.TEXTURE_CUBE_MAP_POSITIVE_X+D:n.TEXTURE_2D,fe=_.depthTexture.format===Jn?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;if(_.depthTexture.format===Cn)et(_)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,fe,te,H,0,pe):n.framebufferTexture2D(n.FRAMEBUFFER,fe,te,H,0);else if(_.depthTexture.format===Jn)et(_)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,fe,te,H,0,pe):n.framebufferTexture2D(n.FRAMEBUFFER,fe,te,H,0);else throw new Error("Unknown depthTexture format")}function De(A){const _=i.get(A),D=A.isWebGLCubeRenderTarget===!0;if(_.__boundDepthTexture!==A.depthTexture){const G=A.depthTexture;if(_.__depthDisposeCallback&&_.__depthDisposeCallback(),G){const $=()=>{delete _.__boundDepthTexture,delete _.__depthDisposeCallback,G.removeEventListener("dispose",$)};G.addEventListener("dispose",$),_.__depthDisposeCallback=$}_.__boundDepthTexture=G}if(A.depthTexture&&!_.__autoAllocateDepthBuffer)if(D)for(let G=0;G<6;G++)le(_.__webglFramebuffer[G],A,G);else{const G=A.texture.mipmaps;G&&G.length>0?le(_.__webglFramebuffer[0],A,0):le(_.__webglFramebuffer,A,0)}else if(D){_.__webglDepthbuffer=[];for(let G=0;G<6;G++)if(t.bindFramebuffer(n.FRAMEBUFFER,_.__webglFramebuffer[G]),_.__webglDepthbuffer[G]===void 0)_.__webglDepthbuffer[G]=n.createRenderbuffer(),Ce(_.__webglDepthbuffer[G],A,!1);else{const $=A.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,H=_.__webglDepthbuffer[G];n.bindRenderbuffer(n.RENDERBUFFER,H),n.framebufferRenderbuffer(n.FRAMEBUFFER,$,n.RENDERBUFFER,H)}}else{const G=A.texture.mipmaps;if(G&&G.length>0?t.bindFramebuffer(n.FRAMEBUFFER,_.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,_.__webglFramebuffer),_.__webglDepthbuffer===void 0)_.__webglDepthbuffer=n.createRenderbuffer(),Ce(_.__webglDepthbuffer,A,!1);else{const $=A.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,H=_.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,H),n.framebufferRenderbuffer(n.FRAMEBUFFER,$,n.RENDERBUFFER,H)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function Ve(A,_,D){const G=i.get(A);_!==void 0&&ge(G.__webglFramebuffer,A,A.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),D!==void 0&&De(A)}function Ne(A){const _=A.texture,D=i.get(A),G=i.get(_);A.addEventListener("dispose",R);const $=A.textures,H=A.isWebGLCubeRenderTarget===!0,pe=$.length>1;if(pe||(G.__webglTexture===void 0&&(G.__webglTexture=n.createTexture()),G.__version=_.version,a.memory.textures++),H){D.__webglFramebuffer=[];for(let te=0;te<6;te++)if(_.mipmaps&&_.mipmaps.length>0){D.__webglFramebuffer[te]=[];for(let fe=0;fe<_.mipmaps.length;fe++)D.__webglFramebuffer[te][fe]=n.createFramebuffer()}else D.__webglFramebuffer[te]=n.createFramebuffer()}else{if(_.mipmaps&&_.mipmaps.length>0){D.__webglFramebuffer=[];for(let te=0;te<_.mipmaps.length;te++)D.__webglFramebuffer[te]=n.createFramebuffer()}else D.__webglFramebuffer=n.createFramebuffer();if(pe)for(let te=0,fe=$.length;te<fe;te++){const Pe=i.get($[te]);Pe.__webglTexture===void 0&&(Pe.__webglTexture=n.createTexture(),a.memory.textures++)}if(A.samples>0&&et(A)===!1){D.__webglMultisampledFramebuffer=n.createFramebuffer(),D.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,D.__webglMultisampledFramebuffer);for(let te=0;te<$.length;te++){const fe=$[te];D.__webglColorRenderbuffer[te]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,D.__webglColorRenderbuffer[te]);const Pe=s.convert(fe.format,fe.colorSpace),ie=s.convert(fe.type),oe=v(fe.internalFormat,Pe,ie,fe.colorSpace,A.isXRRenderTarget===!0),Ee=C(A);n.renderbufferStorageMultisample(n.RENDERBUFFER,Ee,oe,A.width,A.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+te,n.RENDERBUFFER,D.__webglColorRenderbuffer[te])}n.bindRenderbuffer(n.RENDERBUFFER,null),A.depthBuffer&&(D.__webglDepthRenderbuffer=n.createRenderbuffer(),Ce(D.__webglDepthRenderbuffer,A,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(H){t.bindTexture(n.TEXTURE_CUBE_MAP,G.__webglTexture),ce(n.TEXTURE_CUBE_MAP,_);for(let te=0;te<6;te++)if(_.mipmaps&&_.mipmaps.length>0)for(let fe=0;fe<_.mipmaps.length;fe++)ge(D.__webglFramebuffer[te][fe],A,_,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+te,fe);else ge(D.__webglFramebuffer[te],A,_,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+te,0);p(_)&&u(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(pe){for(let te=0,fe=$.length;te<fe;te++){const Pe=$[te],ie=i.get(Pe);let oe=n.TEXTURE_2D;(A.isWebGL3DRenderTarget||A.isWebGLArrayRenderTarget)&&(oe=A.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(oe,ie.__webglTexture),ce(oe,Pe),ge(D.__webglFramebuffer,A,Pe,n.COLOR_ATTACHMENT0+te,oe,0),p(Pe)&&u(oe)}t.unbindTexture()}else{let te=n.TEXTURE_2D;if((A.isWebGL3DRenderTarget||A.isWebGLArrayRenderTarget)&&(te=A.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY),t.bindTexture(te,G.__webglTexture),ce(te,_),_.mipmaps&&_.mipmaps.length>0)for(let fe=0;fe<_.mipmaps.length;fe++)ge(D.__webglFramebuffer[fe],A,_,n.COLOR_ATTACHMENT0,te,fe);else ge(D.__webglFramebuffer,A,_,n.COLOR_ATTACHMENT0,te,0);p(_)&&u(te),t.unbindTexture()}A.depthBuffer&&De(A)}function Fe(A){const _=A.textures;for(let D=0,G=_.length;D<G;D++){const $=_[D];if(p($)){const H=y(A),pe=i.get($).__webglTexture;t.bindTexture(H,pe),u(H),t.unbindTexture()}}}const je=[],ze=[];function lt(A){if(A.samples>0){if(et(A)===!1){const _=A.textures,D=A.width,G=A.height;let $=n.COLOR_BUFFER_BIT;const H=A.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,pe=i.get(A),te=_.length>1;if(te)for(let Pe=0;Pe<_.length;Pe++)t.bindFramebuffer(n.FRAMEBUFFER,pe.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Pe,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,pe.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Pe,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,pe.__webglMultisampledFramebuffer);const fe=A.texture.mipmaps;fe&&fe.length>0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,pe.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,pe.__webglFramebuffer);for(let Pe=0;Pe<_.length;Pe++){if(A.resolveDepthBuffer&&(A.depthBuffer&&($|=n.DEPTH_BUFFER_BIT),A.stencilBuffer&&A.resolveStencilBuffer&&($|=n.STENCIL_BUFFER_BIT)),te){n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,pe.__webglColorRenderbuffer[Pe]);const ie=i.get(_[Pe]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,ie,0)}n.blitFramebuffer(0,0,D,G,0,0,D,G,$,n.NEAREST),l===!0&&(je.length=0,ze.length=0,je.push(n.COLOR_ATTACHMENT0+Pe),A.depthBuffer&&A.resolveDepthBuffer===!1&&(je.push(H),ze.push(H),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,ze)),n.invalidateFramebuffer(n.READ_FRAMEBUFFER,je))}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),te)for(let Pe=0;Pe<_.length;Pe++){t.bindFramebuffer(n.FRAMEBUFFER,pe.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Pe,n.RENDERBUFFER,pe.__webglColorRenderbuffer[Pe]);const ie=i.get(_[Pe]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,pe.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Pe,n.TEXTURE_2D,ie,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,pe.__webglMultisampledFramebuffer)}else if(A.depthBuffer&&A.resolveDepthBuffer===!1&&l){const _=A.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[_])}}}function C(A){return Math.min(r.maxSamples,A.samples)}function et(A){const _=i.get(A);return A.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&_.__useRenderToTexture!==!1}function Ke(A){const _=a.render.frame;h.get(A)!==_&&(h.set(A,_),A.update())}function xe(A,_){const D=A.colorSpace,G=A.format,$=A.type;return A.isCompressedTexture===!0||A.isVideoTexture===!0||D!==Ci&&D!==Bn&&(Ze.getTransfer(D)===it?(G!==rn||$!==Jt)&&Be("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):$e("WebGLTextures: Unsupported texture color space:",D)),_}function ne(A){return typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement?(c.width=A.naturalWidth||A.width,c.height=A.naturalHeight||A.height):typeof VideoFrame<"u"&&A instanceof VideoFrame?(c.width=A.displayWidth,c.height=A.displayHeight):(c.width=A.width,c.height=A.height),c}this.allocateTextureUnit=z,this.resetTextureUnits=B,this.setTexture2D=K,this.setTexture2DArray=L,this.setTexture3D=k,this.setTextureCube=Z,this.rebindTextures=Ve,this.setupRenderTarget=Ne,this.updateRenderTargetMipmap=Fe,this.updateMultisampleRenderTarget=lt,this.setupDepthRenderbuffer=De,this.setupFrameBufferTexture=ge,this.useMultisampledRTT=et,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function c0(n,e){function t(i,r=Bn){let s;const a=Ze.getTransfer(r);if(i===Jt)return n.UNSIGNED_BYTE;if(i===$a)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Za)return n.UNSIGNED_SHORT_5_5_5_1;if(i===Sc)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===yc)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===vc)return n.BYTE;if(i===Mc)return n.SHORT;if(i===Zi)return n.UNSIGNED_SHORT;if(i===Ka)return n.INT;if(i===dn)return n.UNSIGNED_INT;if(i===cn)return n.FLOAT;if(i===Rn)return n.HALF_FLOAT;if(i===bc)return n.ALPHA;if(i===Ec)return n.RGB;if(i===rn)return n.RGBA;if(i===Cn)return n.DEPTH_COMPONENT;if(i===Jn)return n.DEPTH_STENCIL;if(i===Tc)return n.RED;if(i===Ja)return n.RED_INTEGER;if(i===Ri)return n.RG;if(i===Qa)return n.RG_INTEGER;if(i===eo)return n.RGBA_INTEGER;if(i===kr||i===Vr||i===Hr||i===Gr)if(a===it)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===kr)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Vr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Hr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Gr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===kr)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Vr)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Hr)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Gr)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===oa||i===la||i===ca||i===ua)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===oa)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===la)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===ca)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===ua)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===ha||i===fa||i===da||i===pa||i===ma||i===ga||i===_a)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(i===ha||i===fa)return a===it?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===da)return a===it?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===pa)return s.COMPRESSED_R11_EAC;if(i===ma)return s.COMPRESSED_SIGNED_R11_EAC;if(i===ga)return s.COMPRESSED_RG11_EAC;if(i===_a)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===xa||i===va||i===Ma||i===Sa||i===ya||i===ba||i===Ea||i===Ta||i===Aa||i===wa||i===Ra||i===Ca||i===Pa||i===Da)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(i===xa)return a===it?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===va)return a===it?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Ma)return a===it?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Sa)return a===it?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===ya)return a===it?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===ba)return a===it?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Ea)return a===it?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Ta)return a===it?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Aa)return a===it?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===wa)return a===it?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Ra)return a===it?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===Ca)return a===it?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===Pa)return a===it?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Da)return a===it?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===La||i===Na||i===Ia)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(i===La)return a===it?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Na)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Ia)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Ua||i===Fa||i===Oa||i===Ba)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(i===Ua)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Fa)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Oa)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===Ba)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Ji?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}const u0=`
|
|
void main() {
|
|
|
|
gl_Position = vec4( position, 1.0 );
|
|
|
|
}`,h0=`
|
|
uniform sampler2DArray depthColor;
|
|
uniform float depthWidth;
|
|
uniform float depthHeight;
|
|
|
|
void main() {
|
|
|
|
vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
|
|
|
|
if ( coord.x >= 1.0 ) {
|
|
|
|
gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
|
|
|
|
} else {
|
|
|
|
gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
|
|
|
|
}
|
|
|
|
}`;class f0{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new Oc(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new mn({vertexShader:u0,fragmentShader:h0,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new pn(new rs(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class d0 extends ni{constructor(e,t){super();const i=this;let r=null,s=1,a=null,o="local-floor",l=1,c=null,h=null,f=null,d=null,m=null,g=null;const x=typeof XRWebGLBinding<"u",p=new f0,u={},y=t.getContextAttributes();let v=null,M=null;const b=[],w=[],R=new Ge;let I=null;const S=new Zt;S.viewport=new mt;const T=new Zt;T.viewport=new mt;const P=[S,T],B=new Sd;let z=null,j=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let Q=b[Y];return Q===void 0&&(Q=new Is,b[Y]=Q),Q.getTargetRaySpace()},this.getControllerGrip=function(Y){let Q=b[Y];return Q===void 0&&(Q=new Is,b[Y]=Q),Q.getGripSpace()},this.getHand=function(Y){let Q=b[Y];return Q===void 0&&(Q=new Is,b[Y]=Q),Q.getHandSpace()};function K(Y){const Q=w.indexOf(Y.inputSource);if(Q===-1)return;const ge=b[Q];ge!==void 0&&(ge.update(Y.inputSource,Y.frame,c||a),ge.dispatchEvent({type:Y.type,data:Y.inputSource}))}function L(){r.removeEventListener("select",K),r.removeEventListener("selectstart",K),r.removeEventListener("selectend",K),r.removeEventListener("squeeze",K),r.removeEventListener("squeezestart",K),r.removeEventListener("squeezeend",K),r.removeEventListener("end",L),r.removeEventListener("inputsourceschange",k);for(let Y=0;Y<b.length;Y++){const Q=w[Y];Q!==null&&(w[Y]=null,b[Y].disconnect(Q))}z=null,j=null,p.reset();for(const Y in u)delete u[Y];e.setRenderTarget(v),m=null,d=null,f=null,r=null,M=null,Se.stop(),i.isPresenting=!1,e.setPixelRatio(I),e.setSize(R.width,R.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){s=Y,i.isPresenting===!0&&Be("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){o=Y,i.isPresenting===!0&&Be("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(Y){c=Y},this.getBaseLayer=function(){return d!==null?d:m},this.getBinding=function(){return f===null&&x&&(f=new XRWebGLBinding(r,t)),f},this.getFrame=function(){return g},this.getSession=function(){return r},this.setSession=async function(Y){if(r=Y,r!==null){if(v=e.getRenderTarget(),r.addEventListener("select",K),r.addEventListener("selectstart",K),r.addEventListener("selectend",K),r.addEventListener("squeeze",K),r.addEventListener("squeezestart",K),r.addEventListener("squeezeend",K),r.addEventListener("end",L),r.addEventListener("inputsourceschange",k),y.xrCompatible!==!0&&await t.makeXRCompatible(),I=e.getPixelRatio(),e.getSize(R),x&&"createProjectionLayer"in XRWebGLBinding.prototype){let ge=null,Ce=null,le=null;y.depth&&(le=y.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ge=y.stencil?Jn:Cn,Ce=y.stencil?Ji:dn);const De={colorFormat:t.RGBA8,depthFormat:le,scaleFactor:s};f=this.getBinding(),d=f.createProjectionLayer(De),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),M=new fn(d.textureWidth,d.textureHeight,{format:rn,type:Jt,depthTexture:new er(d.textureWidth,d.textureHeight,Ce,void 0,void 0,void 0,void 0,void 0,void 0,ge),stencilBuffer:y.stencil,colorSpace:e.outputColorSpace,samples:y.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const ge={antialias:y.antialias,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:s};m=new XRWebGLLayer(r,t,ge),r.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),M=new fn(m.framebufferWidth,m.framebufferHeight,{format:rn,type:Jt,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}M.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await r.requestReferenceSpace(o),Se.setContext(r),Se.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return p.getDepthTexture()};function k(Y){for(let Q=0;Q<Y.removed.length;Q++){const ge=Y.removed[Q],Ce=w.indexOf(ge);Ce>=0&&(w[Ce]=null,b[Ce].disconnect(ge))}for(let Q=0;Q<Y.added.length;Q++){const ge=Y.added[Q];let Ce=w.indexOf(ge);if(Ce===-1){for(let De=0;De<b.length;De++)if(De>=w.length){w.push(ge),Ce=De;break}else if(w[De]===null){w[De]=ge,Ce=De;break}if(Ce===-1)break}const le=b[Ce];le&&le.connect(ge)}}const Z=new F,re=new F;function V(Y,Q,ge){Z.setFromMatrixPosition(Q.matrixWorld),re.setFromMatrixPosition(ge.matrixWorld);const Ce=Z.distanceTo(re),le=Q.projectionMatrix.elements,De=ge.projectionMatrix.elements,Ve=le[14]/(le[10]-1),Ne=le[14]/(le[10]+1),Fe=(le[9]+1)/le[5],je=(le[9]-1)/le[5],ze=(le[8]-1)/le[0],lt=(De[8]+1)/De[0],C=Ve*ze,et=Ve*lt,Ke=Ce/(-ze+lt),xe=Ke*-ze;if(Q.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(xe),Y.translateZ(Ke),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),le[10]===-1)Y.projectionMatrix.copy(Q.projectionMatrix),Y.projectionMatrixInverse.copy(Q.projectionMatrixInverse);else{const ne=Ve+Ke,A=Ne+Ke,_=C-xe,D=et+(Ce-xe),G=Fe*Ne/A*ne,$=je*Ne/A*ne;Y.projectionMatrix.makePerspective(_,D,G,$,ne,A),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert()}}function W(Y,Q){Q===null?Y.matrixWorld.copy(Y.matrix):Y.matrixWorld.multiplyMatrices(Q.matrixWorld,Y.matrix),Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(r===null)return;let Q=Y.near,ge=Y.far;p.texture!==null&&(p.depthNear>0&&(Q=p.depthNear),p.depthFar>0&&(ge=p.depthFar)),B.near=T.near=S.near=Q,B.far=T.far=S.far=ge,(z!==B.near||j!==B.far)&&(r.updateRenderState({depthNear:B.near,depthFar:B.far}),z=B.near,j=B.far),B.layers.mask=Y.layers.mask|6,S.layers.mask=B.layers.mask&3,T.layers.mask=B.layers.mask&5;const Ce=Y.parent,le=B.cameras;W(B,Ce);for(let De=0;De<le.length;De++)W(le[De],Ce);le.length===2?V(B,S,T):B.projectionMatrix.copy(S.projectionMatrix),ce(Y,B,Ce)};function ce(Y,Q,ge){ge===null?Y.matrix.copy(Q.matrixWorld):(Y.matrix.copy(ge.matrixWorld),Y.matrix.invert(),Y.matrix.multiply(Q.matrixWorld)),Y.matrix.decompose(Y.position,Y.quaternion,Y.scale),Y.updateMatrixWorld(!0),Y.projectionMatrix.copy(Q.projectionMatrix),Y.projectionMatrixInverse.copy(Q.projectionMatrixInverse),Y.isPerspectiveCamera&&(Y.fov=za*2*Math.atan(1/Y.projectionMatrix.elements[5]),Y.zoom=1)}this.getCamera=function(){return B},this.getFoveation=function(){if(!(d===null&&m===null))return l},this.setFoveation=function(Y){l=Y,d!==null&&(d.fixedFoveation=Y),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=Y)},this.hasDepthSensing=function(){return p.texture!==null},this.getDepthSensingMesh=function(){return p.getMesh(B)},this.getCameraTexture=function(Y){return u[Y]};let se=null;function we(Y,Q){if(h=Q.getViewerPose(c||a),g=Q,h!==null){const ge=h.views;m!==null&&(e.setRenderTargetFramebuffer(M,m.framebuffer),e.setRenderTarget(M));let Ce=!1;ge.length!==B.cameras.length&&(B.cameras.length=0,Ce=!0);for(let Ne=0;Ne<ge.length;Ne++){const Fe=ge[Ne];let je=null;if(m!==null)je=m.getViewport(Fe);else{const lt=f.getViewSubImage(d,Fe);je=lt.viewport,Ne===0&&(e.setRenderTargetTextures(M,lt.colorTexture,lt.depthStencilTexture),e.setRenderTarget(M))}let ze=P[Ne];ze===void 0&&(ze=new Zt,ze.layers.enable(Ne),ze.viewport=new mt,P[Ne]=ze),ze.matrix.fromArray(Fe.transform.matrix),ze.matrix.decompose(ze.position,ze.quaternion,ze.scale),ze.projectionMatrix.fromArray(Fe.projectionMatrix),ze.projectionMatrixInverse.copy(ze.projectionMatrix).invert(),ze.viewport.set(je.x,je.y,je.width,je.height),Ne===0&&(B.matrix.copy(ze.matrix),B.matrix.decompose(B.position,B.quaternion,B.scale)),Ce===!0&&B.cameras.push(ze)}const le=r.enabledFeatures;if(le&&le.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&x){f=i.getBinding();const Ne=f.getDepthInformation(ge[0]);Ne&&Ne.isValid&&Ne.texture&&p.init(Ne,r.renderState)}if(le&&le.includes("camera-access")&&x){e.state.unbindTexture(),f=i.getBinding();for(let Ne=0;Ne<ge.length;Ne++){const Fe=ge[Ne].camera;if(Fe){let je=u[Fe];je||(je=new Oc,u[Fe]=je);const ze=f.getCameraImage(Fe);je.sourceTexture=ze}}}}for(let ge=0;ge<b.length;ge++){const Ce=w[ge],le=b[ge];Ce!==null&&le!==void 0&&le.update(Ce,Q,c||a)}se&&se(Y,Q),Q.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:Q}),g=null}const Se=new zc;Se.setAnimationLoop(we),this.setAnimationLoop=function(Y){se=Y},this.dispose=function(){}}}const jn=new Pn,p0=new ht;function m0(n,e){function t(p,u){p.matrixAutoUpdate===!0&&p.updateMatrix(),u.value.copy(p.matrix)}function i(p,u){u.color.getRGB(p.fogColor.value,Dc(n)),u.isFog?(p.fogNear.value=u.near,p.fogFar.value=u.far):u.isFogExp2&&(p.fogDensity.value=u.density)}function r(p,u,y,v,M){u.isMeshBasicMaterial||u.isMeshLambertMaterial?s(p,u):u.isMeshToonMaterial?(s(p,u),f(p,u)):u.isMeshPhongMaterial?(s(p,u),h(p,u)):u.isMeshStandardMaterial?(s(p,u),d(p,u),u.isMeshPhysicalMaterial&&m(p,u,M)):u.isMeshMatcapMaterial?(s(p,u),g(p,u)):u.isMeshDepthMaterial?s(p,u):u.isMeshDistanceMaterial?(s(p,u),x(p,u)):u.isMeshNormalMaterial?s(p,u):u.isLineBasicMaterial?(a(p,u),u.isLineDashedMaterial&&o(p,u)):u.isPointsMaterial?l(p,u,y,v):u.isSpriteMaterial?c(p,u):u.isShadowMaterial?(p.color.value.copy(u.color),p.opacity.value=u.opacity):u.isShaderMaterial&&(u.uniformsNeedUpdate=!1)}function s(p,u){p.opacity.value=u.opacity,u.color&&p.diffuse.value.copy(u.color),u.emissive&&p.emissive.value.copy(u.emissive).multiplyScalar(u.emissiveIntensity),u.map&&(p.map.value=u.map,t(u.map,p.mapTransform)),u.alphaMap&&(p.alphaMap.value=u.alphaMap,t(u.alphaMap,p.alphaMapTransform)),u.bumpMap&&(p.bumpMap.value=u.bumpMap,t(u.bumpMap,p.bumpMapTransform),p.bumpScale.value=u.bumpScale,u.side===Vt&&(p.bumpScale.value*=-1)),u.normalMap&&(p.normalMap.value=u.normalMap,t(u.normalMap,p.normalMapTransform),p.normalScale.value.copy(u.normalScale),u.side===Vt&&p.normalScale.value.negate()),u.displacementMap&&(p.displacementMap.value=u.displacementMap,t(u.displacementMap,p.displacementMapTransform),p.displacementScale.value=u.displacementScale,p.displacementBias.value=u.displacementBias),u.emissiveMap&&(p.emissiveMap.value=u.emissiveMap,t(u.emissiveMap,p.emissiveMapTransform)),u.specularMap&&(p.specularMap.value=u.specularMap,t(u.specularMap,p.specularMapTransform)),u.alphaTest>0&&(p.alphaTest.value=u.alphaTest);const y=e.get(u),v=y.envMap,M=y.envMapRotation;v&&(p.envMap.value=v,jn.copy(M),jn.x*=-1,jn.y*=-1,jn.z*=-1,v.isCubeTexture&&v.isRenderTargetTexture===!1&&(jn.y*=-1,jn.z*=-1),p.envMapRotation.value.setFromMatrix4(p0.makeRotationFromEuler(jn)),p.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=u.reflectivity,p.ior.value=u.ior,p.refractionRatio.value=u.refractionRatio),u.lightMap&&(p.lightMap.value=u.lightMap,p.lightMapIntensity.value=u.lightMapIntensity,t(u.lightMap,p.lightMapTransform)),u.aoMap&&(p.aoMap.value=u.aoMap,p.aoMapIntensity.value=u.aoMapIntensity,t(u.aoMap,p.aoMapTransform))}function a(p,u){p.diffuse.value.copy(u.color),p.opacity.value=u.opacity,u.map&&(p.map.value=u.map,t(u.map,p.mapTransform))}function o(p,u){p.dashSize.value=u.dashSize,p.totalSize.value=u.dashSize+u.gapSize,p.scale.value=u.scale}function l(p,u,y,v){p.diffuse.value.copy(u.color),p.opacity.value=u.opacity,p.size.value=u.size*y,p.scale.value=v*.5,u.map&&(p.map.value=u.map,t(u.map,p.uvTransform)),u.alphaMap&&(p.alphaMap.value=u.alphaMap,t(u.alphaMap,p.alphaMapTransform)),u.alphaTest>0&&(p.alphaTest.value=u.alphaTest)}function c(p,u){p.diffuse.value.copy(u.color),p.opacity.value=u.opacity,p.rotation.value=u.rotation,u.map&&(p.map.value=u.map,t(u.map,p.mapTransform)),u.alphaMap&&(p.alphaMap.value=u.alphaMap,t(u.alphaMap,p.alphaMapTransform)),u.alphaTest>0&&(p.alphaTest.value=u.alphaTest)}function h(p,u){p.specular.value.copy(u.specular),p.shininess.value=Math.max(u.shininess,1e-4)}function f(p,u){u.gradientMap&&(p.gradientMap.value=u.gradientMap)}function d(p,u){p.metalness.value=u.metalness,u.metalnessMap&&(p.metalnessMap.value=u.metalnessMap,t(u.metalnessMap,p.metalnessMapTransform)),p.roughness.value=u.roughness,u.roughnessMap&&(p.roughnessMap.value=u.roughnessMap,t(u.roughnessMap,p.roughnessMapTransform)),u.envMap&&(p.envMapIntensity.value=u.envMapIntensity)}function m(p,u,y){p.ior.value=u.ior,u.sheen>0&&(p.sheenColor.value.copy(u.sheenColor).multiplyScalar(u.sheen),p.sheenRoughness.value=u.sheenRoughness,u.sheenColorMap&&(p.sheenColorMap.value=u.sheenColorMap,t(u.sheenColorMap,p.sheenColorMapTransform)),u.sheenRoughnessMap&&(p.sheenRoughnessMap.value=u.sheenRoughnessMap,t(u.sheenRoughnessMap,p.sheenRoughnessMapTransform))),u.clearcoat>0&&(p.clearcoat.value=u.clearcoat,p.clearcoatRoughness.value=u.clearcoatRoughness,u.clearcoatMap&&(p.clearcoatMap.value=u.clearcoatMap,t(u.clearcoatMap,p.clearcoatMapTransform)),u.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=u.clearcoatRoughnessMap,t(u.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),u.clearcoatNormalMap&&(p.clearcoatNormalMap.value=u.clearcoatNormalMap,t(u.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(u.clearcoatNormalScale),u.side===Vt&&p.clearcoatNormalScale.value.negate())),u.dispersion>0&&(p.dispersion.value=u.dispersion),u.iridescence>0&&(p.iridescence.value=u.iridescence,p.iridescenceIOR.value=u.iridescenceIOR,p.iridescenceThicknessMinimum.value=u.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=u.iridescenceThicknessRange[1],u.iridescenceMap&&(p.iridescenceMap.value=u.iridescenceMap,t(u.iridescenceMap,p.iridescenceMapTransform)),u.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=u.iridescenceThicknessMap,t(u.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),u.transmission>0&&(p.transmission.value=u.transmission,p.transmissionSamplerMap.value=y.texture,p.transmissionSamplerSize.value.set(y.width,y.height),u.transmissionMap&&(p.transmissionMap.value=u.transmissionMap,t(u.transmissionMap,p.transmissionMapTransform)),p.thickness.value=u.thickness,u.thicknessMap&&(p.thicknessMap.value=u.thicknessMap,t(u.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=u.attenuationDistance,p.attenuationColor.value.copy(u.attenuationColor)),u.anisotropy>0&&(p.anisotropyVector.value.set(u.anisotropy*Math.cos(u.anisotropyRotation),u.anisotropy*Math.sin(u.anisotropyRotation)),u.anisotropyMap&&(p.anisotropyMap.value=u.anisotropyMap,t(u.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=u.specularIntensity,p.specularColor.value.copy(u.specularColor),u.specularColorMap&&(p.specularColorMap.value=u.specularColorMap,t(u.specularColorMap,p.specularColorMapTransform)),u.specularIntensityMap&&(p.specularIntensityMap.value=u.specularIntensityMap,t(u.specularIntensityMap,p.specularIntensityMapTransform))}function g(p,u){u.matcap&&(p.matcap.value=u.matcap)}function x(p,u){const y=e.get(u).light;p.referencePosition.value.setFromMatrixPosition(y.matrixWorld),p.nearDistance.value=y.shadow.camera.near,p.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function g0(n,e,t,i){let r={},s={},a=[];const o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,v){const M=v.program;i.uniformBlockBinding(y,M)}function c(y,v){let M=r[y.id];M===void 0&&(g(y),M=h(y),r[y.id]=M,y.addEventListener("dispose",p));const b=v.program;i.updateUBOMapping(y,b);const w=e.render.frame;s[y.id]!==w&&(d(y),s[y.id]=w)}function h(y){const v=f();y.__bindingPointIndex=v;const M=n.createBuffer(),b=y.__size,w=y.usage;return n.bindBuffer(n.UNIFORM_BUFFER,M),n.bufferData(n.UNIFORM_BUFFER,b,w),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,v,M),M}function f(){for(let y=0;y<o;y++)if(a.indexOf(y)===-1)return a.push(y),y;return $e("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(y){const v=r[y.id],M=y.uniforms,b=y.__cache;n.bindBuffer(n.UNIFORM_BUFFER,v);for(let w=0,R=M.length;w<R;w++){const I=Array.isArray(M[w])?M[w]:[M[w]];for(let S=0,T=I.length;S<T;S++){const P=I[S];if(m(P,w,S,b)===!0){const B=P.__offset,z=Array.isArray(P.value)?P.value:[P.value];let j=0;for(let K=0;K<z.length;K++){const L=z[K],k=x(L);typeof L=="number"||typeof L=="boolean"?(P.__data[0]=L,n.bufferSubData(n.UNIFORM_BUFFER,B+j,P.__data)):L.isMatrix3?(P.__data[0]=L.elements[0],P.__data[1]=L.elements[1],P.__data[2]=L.elements[2],P.__data[3]=0,P.__data[4]=L.elements[3],P.__data[5]=L.elements[4],P.__data[6]=L.elements[5],P.__data[7]=0,P.__data[8]=L.elements[6],P.__data[9]=L.elements[7],P.__data[10]=L.elements[8],P.__data[11]=0):(L.toArray(P.__data,j),j+=k.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,B,P.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function m(y,v,M,b){const w=y.value,R=v+"_"+M;if(b[R]===void 0)return typeof w=="number"||typeof w=="boolean"?b[R]=w:b[R]=w.clone(),!0;{const I=b[R];if(typeof w=="number"||typeof w=="boolean"){if(I!==w)return b[R]=w,!0}else if(I.equals(w)===!1)return I.copy(w),!0}return!1}function g(y){const v=y.uniforms;let M=0;const b=16;for(let R=0,I=v.length;R<I;R++){const S=Array.isArray(v[R])?v[R]:[v[R]];for(let T=0,P=S.length;T<P;T++){const B=S[T],z=Array.isArray(B.value)?B.value:[B.value];for(let j=0,K=z.length;j<K;j++){const L=z[j],k=x(L),Z=M%b,re=Z%k.boundary,V=Z+re;M+=re,V!==0&&b-V<k.storage&&(M+=b-V),B.__data=new Float32Array(k.storage/Float32Array.BYTES_PER_ELEMENT),B.__offset=M,M+=k.storage}}}const w=M%b;return w>0&&(M+=b-w),y.__size=M,y.__cache={},this}function x(y){const v={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(v.boundary=4,v.storage=4):y.isVector2?(v.boundary=8,v.storage=8):y.isVector3||y.isColor?(v.boundary=16,v.storage=12):y.isVector4?(v.boundary=16,v.storage=16):y.isMatrix3?(v.boundary=48,v.storage=48):y.isMatrix4?(v.boundary=64,v.storage=64):y.isTexture?Be("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Be("WebGLRenderer: Unsupported uniform value type.",y),v}function p(y){const v=y.target;v.removeEventListener("dispose",p);const M=a.indexOf(v.__bindingPointIndex);a.splice(M,1),n.deleteBuffer(r[v.id]),delete r[v.id],delete s[v.id]}function u(){for(const y in r)n.deleteBuffer(r[y]);a=[],r={},s={}}return{bind:l,update:c,dispose:u}}const _0=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 on=null;function x0(){return on===null&&(on=new cd(_0,16,16,Ri,Rn),on.name="DFG_LUT",on.minFilter=Rt,on.magFilter=Rt,on.wrapS=En,on.wrapT=En,on.generateMipmaps=!1,on.needsUpdate=!0),on}class v0{constructor(e={}){const{canvas:t=Uf(),context:i=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:d=!1,outputBufferType:m=Jt}=e;this.isWebGLRenderer=!0;let g;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=i.getContextAttributes().alpha}else g=a;const x=m,p=new Set([eo,Qa,Ja]),u=new Set([Jt,dn,Zi,Ji,$a,Za]),y=new Uint32Array(4),v=new Int32Array(4);let M=null,b=null;const w=[],R=[];let I=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 S=this;let T=!1;this._outputColorSpace=$t;let P=0,B=0,z=null,j=-1,K=null;const L=new mt,k=new mt;let Z=null;const re=new Qe(0);let V=0,W=t.width,ce=t.height,se=1,we=null,Se=null;const Y=new mt(0,0,W,ce),Q=new mt(0,0,W,ce);let ge=!1;const Ce=new Uc;let le=!1,De=!1;const Ve=new ht,Ne=new F,Fe=new mt,je={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ze=!1;function lt(){return z===null?se:1}let C=i;function et(E,U){return t.getContext(E,U)}try{const E={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${ja}`),t.addEventListener("webglcontextlost",ke,!1),t.addEventListener("webglcontextrestored",ct,!1),t.addEventListener("webglcontextcreationerror",tt,!1),C===null){const U="webgl2";if(C=et(U,E),C===null)throw et(U)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(E){throw $e("WebGLRenderer: "+E.message),E}let Ke,xe,ne,A,_,D,G,$,H,pe,te,fe,Pe,ie,oe,Ee,Re,de,He,N,ve,ue,be,ae;function ee(){Ke=new xg(C),Ke.init(),ue=new c0(C,Ke),xe=new cg(C,Ke,e,ue),ne=new o0(C,Ke),xe.reversedDepthBuffer&&d&&ne.buffers.depth.setReversed(!0),A=new Sg(C),_=new q_,D=new l0(C,Ke,ne,_,xe,ue,A),G=new hg(S),$=new _g(S),H=new Td(C),be=new og(C,H),pe=new vg(C,H,A,be),te=new bg(C,pe,H,A),He=new yg(C,xe,D),Ee=new ug(_),fe=new X_(S,G,$,Ke,xe,be,Ee),Pe=new m0(S,_),ie=new j_,oe=new e0(Ke),de=new ag(S,G,$,ne,te,g,l),Re=new s0(S,te,xe),ae=new g0(C,A,xe,ne),N=new lg(C,Ke,A),ve=new Mg(C,Ke,A),A.programs=fe.programs,S.capabilities=xe,S.extensions=Ke,S.properties=_,S.renderLists=ie,S.shadowMap=Re,S.state=ne,S.info=A}ee(),x!==Jt&&(I=new Tg(x,t.width,t.height,r,s));const me=new d0(S,C);this.xr=me,this.getContext=function(){return C},this.getContextAttributes=function(){return C.getContextAttributes()},this.forceContextLoss=function(){const E=Ke.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){const E=Ke.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return se},this.setPixelRatio=function(E){E!==void 0&&(se=E,this.setSize(W,ce,!1))},this.getSize=function(E){return E.set(W,ce)},this.setSize=function(E,U,q=!0){if(me.isPresenting){Be("WebGLRenderer: Can't change size while VR device is presenting.");return}W=E,ce=U,t.width=Math.floor(E*se),t.height=Math.floor(U*se),q===!0&&(t.style.width=E+"px",t.style.height=U+"px"),I!==null&&I.setSize(t.width,t.height),this.setViewport(0,0,E,U)},this.getDrawingBufferSize=function(E){return E.set(W*se,ce*se).floor()},this.setDrawingBufferSize=function(E,U,q){W=E,ce=U,se=q,t.width=Math.floor(E*q),t.height=Math.floor(U*q),this.setViewport(0,0,E,U)},this.setEffects=function(E){if(x===Jt){console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(E){for(let U=0;U<E.length;U++)if(E[U].isOutputPass===!0){console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}I.setEffects(E||[])},this.getCurrentViewport=function(E){return E.copy(L)},this.getViewport=function(E){return E.copy(Y)},this.setViewport=function(E,U,q,X){E.isVector4?Y.set(E.x,E.y,E.z,E.w):Y.set(E,U,q,X),ne.viewport(L.copy(Y).multiplyScalar(se).round())},this.getScissor=function(E){return E.copy(Q)},this.setScissor=function(E,U,q,X){E.isVector4?Q.set(E.x,E.y,E.z,E.w):Q.set(E,U,q,X),ne.scissor(k.copy(Q).multiplyScalar(se).round())},this.getScissorTest=function(){return ge},this.setScissorTest=function(E){ne.setScissorTest(ge=E)},this.setOpaqueSort=function(E){we=E},this.setTransparentSort=function(E){Se=E},this.getClearColor=function(E){return E.copy(de.getClearColor())},this.setClearColor=function(){de.setClearColor(...arguments)},this.getClearAlpha=function(){return de.getClearAlpha()},this.setClearAlpha=function(){de.setClearAlpha(...arguments)},this.clear=function(E=!0,U=!0,q=!0){let X=0;if(E){let O=!1;if(z!==null){const _e=z.texture.format;O=p.has(_e)}if(O){const _e=z.texture.type,Te=u.has(_e),ye=de.getClearColor(),Ae=de.getClearAlpha(),Le=ye.r,Oe=ye.g,Ie=ye.b;Te?(y[0]=Le,y[1]=Oe,y[2]=Ie,y[3]=Ae,C.clearBufferuiv(C.COLOR,0,y)):(v[0]=Le,v[1]=Oe,v[2]=Ie,v[3]=Ae,C.clearBufferiv(C.COLOR,0,v))}else X|=C.COLOR_BUFFER_BIT}U&&(X|=C.DEPTH_BUFFER_BIT),q&&(X|=C.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),C.clear(X)},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.dispose=function(){t.removeEventListener("webglcontextlost",ke,!1),t.removeEventListener("webglcontextrestored",ct,!1),t.removeEventListener("webglcontextcreationerror",tt,!1),de.dispose(),ie.dispose(),oe.dispose(),_.dispose(),G.dispose(),$.dispose(),te.dispose(),be.dispose(),ae.dispose(),fe.dispose(),me.dispose(),me.removeEventListener("sessionstart",co),me.removeEventListener("sessionend",uo),Vn.stop()};function ke(E){E.preventDefault(),Go("WebGLRenderer: Context Lost."),T=!0}function ct(){Go("WebGLRenderer: Context Restored."),T=!1;const E=A.autoReset,U=Re.enabled,q=Re.autoUpdate,X=Re.needsUpdate,O=Re.type;ee(),A.autoReset=E,Re.enabled=U,Re.autoUpdate=q,Re.needsUpdate=X,Re.type=O}function tt(E){$e("WebGLRenderer: A WebGL context could not be created. Reason: ",E.statusMessage)}function sn(E){const U=E.target;U.removeEventListener("dispose",sn),gn(U)}function gn(E){Xc(E),_.remove(E)}function Xc(E){const U=_.get(E).programs;U!==void 0&&(U.forEach(function(q){fe.releaseProgram(q)}),E.isShaderMaterial&&fe.releaseShaderCache(E))}this.renderBufferDirect=function(E,U,q,X,O,_e){U===null&&(U=je);const Te=O.isMesh&&O.matrixWorld.determinant()<0,ye=Yc(E,U,q,X,O);ne.setMaterial(X,Te);let Ae=q.index,Le=1;if(X.wireframe===!0){if(Ae=pe.getWireframeAttribute(q),Ae===void 0)return;Le=2}const Oe=q.drawRange,Ie=q.attributes.position;let qe=Oe.start*Le,rt=(Oe.start+Oe.count)*Le;_e!==null&&(qe=Math.max(qe,_e.start*Le),rt=Math.min(rt,(_e.start+_e.count)*Le)),Ae!==null?(qe=Math.max(qe,0),rt=Math.min(rt,Ae.count)):Ie!=null&&(qe=Math.max(qe,0),rt=Math.min(rt,Ie.count));const dt=rt-qe;if(dt<0||dt===1/0)return;be.setup(O,X,ye,q,Ae);let pt,at=N;if(Ae!==null&&(pt=H.get(Ae),at=ve,at.setIndex(pt)),O.isMesh)X.wireframe===!0?(ne.setLineWidth(X.wireframeLinewidth*lt()),at.setMode(C.LINES)):at.setMode(C.TRIANGLES);else if(O.isLine){let Ue=X.linewidth;Ue===void 0&&(Ue=1),ne.setLineWidth(Ue*lt()),O.isLineSegments?at.setMode(C.LINES):O.isLineLoop?at.setMode(C.LINE_LOOP):at.setMode(C.LINE_STRIP)}else O.isPoints?at.setMode(C.POINTS):O.isSprite&&at.setMode(C.TRIANGLES);if(O.isBatchedMesh)if(O._multiDrawInstances!==null)Qi("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),at.renderMultiDrawInstances(O._multiDrawStarts,O._multiDrawCounts,O._multiDrawCount,O._multiDrawInstances);else if(Ke.get("WEBGL_multi_draw"))at.renderMultiDraw(O._multiDrawStarts,O._multiDrawCounts,O._multiDrawCount);else{const Ue=O._multiDrawStarts,nt=O._multiDrawCounts,Je=O._multiDrawCount,Wt=Ae?H.get(Ae).bytesPerElement:1,ii=_.get(X).currentProgram.getUniforms();for(let Xt=0;Xt<Je;Xt++)ii.setValue(C,"_gl_DrawID",Xt),at.render(Ue[Xt]/Wt,nt[Xt])}else if(O.isInstancedMesh)at.renderInstances(qe,dt,O.count);else if(q.isInstancedBufferGeometry){const Ue=q._maxInstanceCount!==void 0?q._maxInstanceCount:1/0,nt=Math.min(q.instanceCount,Ue);at.renderInstances(qe,dt,nt)}else at.render(qe,dt)};function lo(E,U,q){E.transparent===!0&&E.side===bn&&E.forceSinglePass===!1?(E.side=Vt,E.needsUpdate=!0,or(E,U,q),E.side=kn,E.needsUpdate=!0,or(E,U,q),E.side=bn):or(E,U,q)}this.compile=function(E,U,q=null){q===null&&(q=E),b=oe.get(q),b.init(U),R.push(b),q.traverseVisible(function(O){O.isLight&&O.layers.test(U.layers)&&(b.pushLight(O),O.castShadow&&b.pushShadow(O))}),E!==q&&E.traverseVisible(function(O){O.isLight&&O.layers.test(U.layers)&&(b.pushLight(O),O.castShadow&&b.pushShadow(O))}),b.setupLights();const X=new Set;return E.traverse(function(O){if(!(O.isMesh||O.isPoints||O.isLine||O.isSprite))return;const _e=O.material;if(_e)if(Array.isArray(_e))for(let Te=0;Te<_e.length;Te++){const ye=_e[Te];lo(ye,q,O),X.add(ye)}else lo(_e,q,O),X.add(_e)}),b=R.pop(),X},this.compileAsync=function(E,U,q=null){const X=this.compile(E,U,q);return new Promise(O=>{function _e(){if(X.forEach(function(Te){_.get(Te).currentProgram.isReady()&&X.delete(Te)}),X.size===0){O(E);return}setTimeout(_e,10)}Ke.get("KHR_parallel_shader_compile")!==null?_e():setTimeout(_e,10)})};let os=null;function qc(E){os&&os(E)}function co(){Vn.stop()}function uo(){Vn.start()}const Vn=new zc;Vn.setAnimationLoop(qc),typeof self<"u"&&Vn.setContext(self),this.setAnimationLoop=function(E){os=E,me.setAnimationLoop(E),E===null?Vn.stop():Vn.start()},me.addEventListener("sessionstart",co),me.addEventListener("sessionend",uo),this.render=function(E,U){if(U!==void 0&&U.isCamera!==!0){$e("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(T===!0)return;const q=me.enabled===!0&&me.isPresenting===!0,X=I!==null&&(z===null||q)&&I.begin(S,z);if(E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),me.enabled===!0&&me.isPresenting===!0&&(I===null||I.isCompositing()===!1)&&(me.cameraAutoUpdate===!0&&me.updateCamera(U),U=me.getCamera()),E.isScene===!0&&E.onBeforeRender(S,E,U,z),b=oe.get(E,R.length),b.init(U),R.push(b),Ve.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),Ce.setFromProjectionMatrix(Ve,un,U.reversedDepth),De=this.localClippingEnabled,le=Ee.init(this.clippingPlanes,De),M=ie.get(E,w.length),M.init(),w.push(M),me.enabled===!0&&me.isPresenting===!0){const Te=S.xr.getDepthSensingMesh();Te!==null&&ls(Te,U,-1/0,S.sortObjects)}ls(E,U,0,S.sortObjects),M.finish(),S.sortObjects===!0&&M.sort(we,Se),ze=me.enabled===!1||me.isPresenting===!1||me.hasDepthSensing()===!1,ze&&de.addToRenderList(M,E),this.info.render.frame++,le===!0&&Ee.beginShadows();const O=b.state.shadowsArray;if(Re.render(O,E,U),le===!0&&Ee.endShadows(),this.info.autoReset===!0&&this.info.reset(),(X&&I.hasRenderPass())===!1){const Te=M.opaque,ye=M.transmissive;if(b.setupLights(),U.isArrayCamera){const Ae=U.cameras;if(ye.length>0)for(let Le=0,Oe=Ae.length;Le<Oe;Le++){const Ie=Ae[Le];fo(Te,ye,E,Ie)}ze&&de.render(E);for(let Le=0,Oe=Ae.length;Le<Oe;Le++){const Ie=Ae[Le];ho(M,E,Ie,Ie.viewport)}}else ye.length>0&&fo(Te,ye,E,U),ze&&de.render(E),ho(M,E,U)}z!==null&&B===0&&(D.updateMultisampleRenderTarget(z),D.updateRenderTargetMipmap(z)),X&&I.end(S),E.isScene===!0&&E.onAfterRender(S,E,U),be.resetDefaultState(),j=-1,K=null,R.pop(),R.length>0?(b=R[R.length-1],le===!0&&Ee.setGlobalState(S.clippingPlanes,b.state.camera)):b=null,w.pop(),w.length>0?M=w[w.length-1]:M=null};function ls(E,U,q,X){if(E.visible===!1)return;if(E.layers.test(U.layers)){if(E.isGroup)q=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(U);else if(E.isLight)b.pushLight(E),E.castShadow&&b.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||Ce.intersectsSprite(E)){X&&Fe.setFromMatrixPosition(E.matrixWorld).applyMatrix4(Ve);const Te=te.update(E),ye=E.material;ye.visible&&M.push(E,Te,ye,q,Fe.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||Ce.intersectsObject(E))){const Te=te.update(E),ye=E.material;if(X&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),Fe.copy(E.boundingSphere.center)):(Te.boundingSphere===null&&Te.computeBoundingSphere(),Fe.copy(Te.boundingSphere.center)),Fe.applyMatrix4(E.matrixWorld).applyMatrix4(Ve)),Array.isArray(ye)){const Ae=Te.groups;for(let Le=0,Oe=Ae.length;Le<Oe;Le++){const Ie=Ae[Le],qe=ye[Ie.materialIndex];qe&&qe.visible&&M.push(E,Te,qe,q,Fe.z,Ie)}}else ye.visible&&M.push(E,Te,ye,q,Fe.z,null)}}const _e=E.children;for(let Te=0,ye=_e.length;Te<ye;Te++)ls(_e[Te],U,q,X)}function ho(E,U,q,X){const{opaque:O,transmissive:_e,transparent:Te}=E;b.setupLightsView(q),le===!0&&Ee.setGlobalState(S.clippingPlanes,q),X&&ne.viewport(L.copy(X)),O.length>0&&ar(O,U,q),_e.length>0&&ar(_e,U,q),Te.length>0&&ar(Te,U,q),ne.buffers.depth.setTest(!0),ne.buffers.depth.setMask(!0),ne.buffers.color.setMask(!0),ne.setPolygonOffset(!1)}function fo(E,U,q,X){if((q.isScene===!0?q.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[X.id]===void 0){const qe=Ke.has("EXT_color_buffer_half_float")||Ke.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[X.id]=new fn(1,1,{generateMipmaps:!0,type:qe?Rn:Jt,minFilter:Zn,samples:xe.samples,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ze.workingColorSpace})}const _e=b.state.transmissionRenderTarget[X.id],Te=X.viewport||L;_e.setSize(Te.z*S.transmissionResolutionScale,Te.w*S.transmissionResolutionScale);const ye=S.getRenderTarget(),Ae=S.getActiveCubeFace(),Le=S.getActiveMipmapLevel();S.setRenderTarget(_e),S.getClearColor(re),V=S.getClearAlpha(),V<1&&S.setClearColor(16777215,.5),S.clear(),ze&&de.render(q);const Oe=S.toneMapping;S.toneMapping=hn;const Ie=X.viewport;if(X.viewport!==void 0&&(X.viewport=void 0),b.setupLightsView(X),le===!0&&Ee.setGlobalState(S.clippingPlanes,X),ar(E,q,X),D.updateMultisampleRenderTarget(_e),D.updateRenderTargetMipmap(_e),Ke.has("WEBGL_multisampled_render_to_texture")===!1){let qe=!1;for(let rt=0,dt=U.length;rt<dt;rt++){const pt=U[rt],{object:at,geometry:Ue,material:nt,group:Je}=pt;if(nt.side===bn&&at.layers.test(X.layers)){const Wt=nt.side;nt.side=Vt,nt.needsUpdate=!0,po(at,q,X,Ue,nt,Je),nt.side=Wt,nt.needsUpdate=!0,qe=!0}}qe===!0&&(D.updateMultisampleRenderTarget(_e),D.updateRenderTargetMipmap(_e))}S.setRenderTarget(ye,Ae,Le),S.setClearColor(re,V),Ie!==void 0&&(X.viewport=Ie),S.toneMapping=Oe}function ar(E,U,q){const X=U.isScene===!0?U.overrideMaterial:null;for(let O=0,_e=E.length;O<_e;O++){const Te=E[O],{object:ye,geometry:Ae,group:Le}=Te;let Oe=Te.material;Oe.allowOverride===!0&&X!==null&&(Oe=X),ye.layers.test(q.layers)&&po(ye,U,q,Ae,Oe,Le)}}function po(E,U,q,X,O,_e){E.onBeforeRender(S,U,q,X,O,_e),E.modelViewMatrix.multiplyMatrices(q.matrixWorldInverse,E.matrixWorld),E.normalMatrix.getNormalMatrix(E.modelViewMatrix),O.onBeforeRender(S,U,q,X,E,_e),O.transparent===!0&&O.side===bn&&O.forceSinglePass===!1?(O.side=Vt,O.needsUpdate=!0,S.renderBufferDirect(q,U,X,O,E,_e),O.side=kn,O.needsUpdate=!0,S.renderBufferDirect(q,U,X,O,E,_e),O.side=bn):S.renderBufferDirect(q,U,X,O,E,_e),E.onAfterRender(S,U,q,X,O,_e)}function or(E,U,q){U.isScene!==!0&&(U=je);const X=_.get(E),O=b.state.lights,_e=b.state.shadowsArray,Te=O.state.version,ye=fe.getParameters(E,O.state,_e,U,q),Ae=fe.getProgramCacheKey(ye);let Le=X.programs;X.environment=E.isMeshStandardMaterial?U.environment:null,X.fog=U.fog,X.envMap=(E.isMeshStandardMaterial?$:G).get(E.envMap||X.environment),X.envMapRotation=X.environment!==null&&E.envMap===null?U.environmentRotation:E.envMapRotation,Le===void 0&&(E.addEventListener("dispose",sn),Le=new Map,X.programs=Le);let Oe=Le.get(Ae);if(Oe!==void 0){if(X.currentProgram===Oe&&X.lightsStateVersion===Te)return go(E,ye),Oe}else ye.uniforms=fe.getUniforms(E),E.onBeforeCompile(ye,S),Oe=fe.acquireProgram(ye,Ae),Le.set(Ae,Oe),X.uniforms=ye.uniforms;const Ie=X.uniforms;return(!E.isShaderMaterial&&!E.isRawShaderMaterial||E.clipping===!0)&&(Ie.clippingPlanes=Ee.uniform),go(E,ye),X.needsLights=Kc(E),X.lightsStateVersion=Te,X.needsLights&&(Ie.ambientLightColor.value=O.state.ambient,Ie.lightProbe.value=O.state.probe,Ie.directionalLights.value=O.state.directional,Ie.directionalLightShadows.value=O.state.directionalShadow,Ie.spotLights.value=O.state.spot,Ie.spotLightShadows.value=O.state.spotShadow,Ie.rectAreaLights.value=O.state.rectArea,Ie.ltc_1.value=O.state.rectAreaLTC1,Ie.ltc_2.value=O.state.rectAreaLTC2,Ie.pointLights.value=O.state.point,Ie.pointLightShadows.value=O.state.pointShadow,Ie.hemisphereLights.value=O.state.hemi,Ie.directionalShadowMap.value=O.state.directionalShadowMap,Ie.directionalShadowMatrix.value=O.state.directionalShadowMatrix,Ie.spotShadowMap.value=O.state.spotShadowMap,Ie.spotLightMatrix.value=O.state.spotLightMatrix,Ie.spotLightMap.value=O.state.spotLightMap,Ie.pointShadowMap.value=O.state.pointShadowMap,Ie.pointShadowMatrix.value=O.state.pointShadowMatrix),X.currentProgram=Oe,X.uniformsList=null,Oe}function mo(E){if(E.uniformsList===null){const U=E.currentProgram.getUniforms();E.uniformsList=Xr.seqWithValue(U.seq,E.uniforms)}return E.uniformsList}function go(E,U){const q=_.get(E);q.outputColorSpace=U.outputColorSpace,q.batching=U.batching,q.batchingColor=U.batchingColor,q.instancing=U.instancing,q.instancingColor=U.instancingColor,q.instancingMorph=U.instancingMorph,q.skinning=U.skinning,q.morphTargets=U.morphTargets,q.morphNormals=U.morphNormals,q.morphColors=U.morphColors,q.morphTargetsCount=U.morphTargetsCount,q.numClippingPlanes=U.numClippingPlanes,q.numIntersection=U.numClipIntersection,q.vertexAlphas=U.vertexAlphas,q.vertexTangents=U.vertexTangents,q.toneMapping=U.toneMapping}function Yc(E,U,q,X,O){U.isScene!==!0&&(U=je),D.resetTextureUnits();const _e=U.fog,Te=X.isMeshStandardMaterial?U.environment:null,ye=z===null?S.outputColorSpace:z.isXRRenderTarget===!0?z.texture.colorSpace:Ci,Ae=(X.isMeshStandardMaterial?$:G).get(X.envMap||Te),Le=X.vertexColors===!0&&!!q.attributes.color&&q.attributes.color.itemSize===4,Oe=!!q.attributes.tangent&&(!!X.normalMap||X.anisotropy>0),Ie=!!q.morphAttributes.position,qe=!!q.morphAttributes.normal,rt=!!q.morphAttributes.color;let dt=hn;X.toneMapped&&(z===null||z.isXRRenderTarget===!0)&&(dt=S.toneMapping);const pt=q.morphAttributes.position||q.morphAttributes.normal||q.morphAttributes.color,at=pt!==void 0?pt.length:0,Ue=_.get(X),nt=b.state.lights;if(le===!0&&(De===!0||E!==K)){const Lt=E===K&&X.id===j;Ee.setState(X,E,Lt)}let Je=!1;X.version===Ue.__version?(Ue.needsLights&&Ue.lightsStateVersion!==nt.state.version||Ue.outputColorSpace!==ye||O.isBatchedMesh&&Ue.batching===!1||!O.isBatchedMesh&&Ue.batching===!0||O.isBatchedMesh&&Ue.batchingColor===!0&&O.colorTexture===null||O.isBatchedMesh&&Ue.batchingColor===!1&&O.colorTexture!==null||O.isInstancedMesh&&Ue.instancing===!1||!O.isInstancedMesh&&Ue.instancing===!0||O.isSkinnedMesh&&Ue.skinning===!1||!O.isSkinnedMesh&&Ue.skinning===!0||O.isInstancedMesh&&Ue.instancingColor===!0&&O.instanceColor===null||O.isInstancedMesh&&Ue.instancingColor===!1&&O.instanceColor!==null||O.isInstancedMesh&&Ue.instancingMorph===!0&&O.morphTexture===null||O.isInstancedMesh&&Ue.instancingMorph===!1&&O.morphTexture!==null||Ue.envMap!==Ae||X.fog===!0&&Ue.fog!==_e||Ue.numClippingPlanes!==void 0&&(Ue.numClippingPlanes!==Ee.numPlanes||Ue.numIntersection!==Ee.numIntersection)||Ue.vertexAlphas!==Le||Ue.vertexTangents!==Oe||Ue.morphTargets!==Ie||Ue.morphNormals!==qe||Ue.morphColors!==rt||Ue.toneMapping!==dt||Ue.morphTargetsCount!==at)&&(Je=!0):(Je=!0,Ue.__version=X.version);let Wt=Ue.currentProgram;Je===!0&&(Wt=or(X,U,O));let ii=!1,Xt=!1,Ni=!1;const ut=Wt.getUniforms(),Ot=Ue.uniforms;if(ne.useProgram(Wt.program)&&(ii=!0,Xt=!0,Ni=!0),X.id!==j&&(j=X.id,Xt=!0),ii||K!==E){ne.buffers.depth.getReversed()&&E.reversedDepth!==!0&&(E._reversedDepth=!0,E.updateProjectionMatrix()),ut.setValue(C,"projectionMatrix",E.projectionMatrix),ut.setValue(C,"viewMatrix",E.matrixWorldInverse);const Bt=ut.map.cameraPosition;Bt!==void 0&&Bt.setValue(C,Ne.setFromMatrixPosition(E.matrixWorld)),xe.logarithmicDepthBuffer&&ut.setValue(C,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),(X.isMeshPhongMaterial||X.isMeshToonMaterial||X.isMeshLambertMaterial||X.isMeshBasicMaterial||X.isMeshStandardMaterial||X.isShaderMaterial)&&ut.setValue(C,"isOrthographic",E.isOrthographicCamera===!0),K!==E&&(K=E,Xt=!0,Ni=!0)}if(Ue.needsLights&&(nt.state.directionalShadowMap.length>0&&ut.setValue(C,"directionalShadowMap",nt.state.directionalShadowMap,D),nt.state.spotShadowMap.length>0&&ut.setValue(C,"spotShadowMap",nt.state.spotShadowMap,D),nt.state.pointShadowMap.length>0&&ut.setValue(C,"pointShadowMap",nt.state.pointShadowMap,D)),O.isSkinnedMesh){ut.setOptional(C,O,"bindMatrix"),ut.setOptional(C,O,"bindMatrixInverse");const Lt=O.skeleton;Lt&&(Lt.boneTexture===null&&Lt.computeBoneTexture(),ut.setValue(C,"boneTexture",Lt.boneTexture,D))}O.isBatchedMesh&&(ut.setOptional(C,O,"batchingTexture"),ut.setValue(C,"batchingTexture",O._matricesTexture,D),ut.setOptional(C,O,"batchingIdTexture"),ut.setValue(C,"batchingIdTexture",O._indirectTexture,D),ut.setOptional(C,O,"batchingColorTexture"),O._colorsTexture!==null&&ut.setValue(C,"batchingColorTexture",O._colorsTexture,D));const jt=q.morphAttributes;if((jt.position!==void 0||jt.normal!==void 0||jt.color!==void 0)&&He.update(O,q,Wt),(Xt||Ue.receiveShadow!==O.receiveShadow)&&(Ue.receiveShadow=O.receiveShadow,ut.setValue(C,"receiveShadow",O.receiveShadow)),X.isMeshGouraudMaterial&&X.envMap!==null&&(Ot.envMap.value=Ae,Ot.flipEnvMap.value=Ae.isCubeTexture&&Ae.isRenderTargetTexture===!1?-1:1),X.isMeshStandardMaterial&&X.envMap===null&&U.environment!==null&&(Ot.envMapIntensity.value=U.environmentIntensity),Ot.dfgLUT!==void 0&&(Ot.dfgLUT.value=x0()),Xt&&(ut.setValue(C,"toneMappingExposure",S.toneMappingExposure),Ue.needsLights&&jc(Ot,Ni),_e&&X.fog===!0&&Pe.refreshFogUniforms(Ot,_e),Pe.refreshMaterialUniforms(Ot,X,se,ce,b.state.transmissionRenderTarget[E.id]),Xr.upload(C,mo(Ue),Ot,D)),X.isShaderMaterial&&X.uniformsNeedUpdate===!0&&(Xr.upload(C,mo(Ue),Ot,D),X.uniformsNeedUpdate=!1),X.isSpriteMaterial&&ut.setValue(C,"center",O.center),ut.setValue(C,"modelViewMatrix",O.modelViewMatrix),ut.setValue(C,"normalMatrix",O.normalMatrix),ut.setValue(C,"modelMatrix",O.matrixWorld),X.isShaderMaterial||X.isRawShaderMaterial){const Lt=X.uniformsGroups;for(let Bt=0,cs=Lt.length;Bt<cs;Bt++){const Hn=Lt[Bt];ae.update(Hn,Wt),ae.bind(Hn,Wt)}}return Wt}function jc(E,U){E.ambientLightColor.needsUpdate=U,E.lightProbe.needsUpdate=U,E.directionalLights.needsUpdate=U,E.directionalLightShadows.needsUpdate=U,E.pointLights.needsUpdate=U,E.pointLightShadows.needsUpdate=U,E.spotLights.needsUpdate=U,E.spotLightShadows.needsUpdate=U,E.rectAreaLights.needsUpdate=U,E.hemisphereLights.needsUpdate=U}function Kc(E){return E.isMeshLambertMaterial||E.isMeshToonMaterial||E.isMeshPhongMaterial||E.isMeshStandardMaterial||E.isShadowMaterial||E.isShaderMaterial&&E.lights===!0}this.getActiveCubeFace=function(){return P},this.getActiveMipmapLevel=function(){return B},this.getRenderTarget=function(){return z},this.setRenderTargetTextures=function(E,U,q){const X=_.get(E);X.__autoAllocateDepthBuffer=E.resolveDepthBuffer===!1,X.__autoAllocateDepthBuffer===!1&&(X.__useRenderToTexture=!1),_.get(E.texture).__webglTexture=U,_.get(E.depthTexture).__webglTexture=X.__autoAllocateDepthBuffer?void 0:q,X.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(E,U){const q=_.get(E);q.__webglFramebuffer=U,q.__useDefaultFramebuffer=U===void 0};const $c=C.createFramebuffer();this.setRenderTarget=function(E,U=0,q=0){z=E,P=U,B=q;let X=null,O=!1,_e=!1;if(E){const ye=_.get(E);if(ye.__useDefaultFramebuffer!==void 0){ne.bindFramebuffer(C.FRAMEBUFFER,ye.__webglFramebuffer),L.copy(E.viewport),k.copy(E.scissor),Z=E.scissorTest,ne.viewport(L),ne.scissor(k),ne.setScissorTest(Z),j=-1;return}else if(ye.__webglFramebuffer===void 0)D.setupRenderTarget(E);else if(ye.__hasExternalTextures)D.rebindTextures(E,_.get(E.texture).__webglTexture,_.get(E.depthTexture).__webglTexture);else if(E.depthBuffer){const Oe=E.depthTexture;if(ye.__boundDepthTexture!==Oe){if(Oe!==null&&_.has(Oe)&&(E.width!==Oe.image.width||E.height!==Oe.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");D.setupDepthRenderbuffer(E)}}const Ae=E.texture;(Ae.isData3DTexture||Ae.isDataArrayTexture||Ae.isCompressedArrayTexture)&&(_e=!0);const Le=_.get(E).__webglFramebuffer;E.isWebGLCubeRenderTarget?(Array.isArray(Le[U])?X=Le[U][q]:X=Le[U],O=!0):E.samples>0&&D.useMultisampledRTT(E)===!1?X=_.get(E).__webglMultisampledFramebuffer:Array.isArray(Le)?X=Le[q]:X=Le,L.copy(E.viewport),k.copy(E.scissor),Z=E.scissorTest}else L.copy(Y).multiplyScalar(se).floor(),k.copy(Q).multiplyScalar(se).floor(),Z=ge;if(q!==0&&(X=$c),ne.bindFramebuffer(C.FRAMEBUFFER,X)&&ne.drawBuffers(E,X),ne.viewport(L),ne.scissor(k),ne.setScissorTest(Z),O){const ye=_.get(E.texture);C.framebufferTexture2D(C.FRAMEBUFFER,C.COLOR_ATTACHMENT0,C.TEXTURE_CUBE_MAP_POSITIVE_X+U,ye.__webglTexture,q)}else if(_e){const ye=U;for(let Ae=0;Ae<E.textures.length;Ae++){const Le=_.get(E.textures[Ae]);C.framebufferTextureLayer(C.FRAMEBUFFER,C.COLOR_ATTACHMENT0+Ae,Le.__webglTexture,q,ye)}}else if(E!==null&&q!==0){const ye=_.get(E.texture);C.framebufferTexture2D(C.FRAMEBUFFER,C.COLOR_ATTACHMENT0,C.TEXTURE_2D,ye.__webglTexture,q)}j=-1},this.readRenderTargetPixels=function(E,U,q,X,O,_e,Te,ye=0){if(!(E&&E.isWebGLRenderTarget)){$e("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ae=_.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&Te!==void 0&&(Ae=Ae[Te]),Ae){ne.bindFramebuffer(C.FRAMEBUFFER,Ae);try{const Le=E.textures[ye],Oe=Le.format,Ie=Le.type;if(!xe.textureFormatReadable(Oe)){$e("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!xe.textureTypeReadable(Ie)){$e("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=E.width-X&&q>=0&&q<=E.height-O&&(E.textures.length>1&&C.readBuffer(C.COLOR_ATTACHMENT0+ye),C.readPixels(U,q,X,O,ue.convert(Oe),ue.convert(Ie),_e))}finally{const Le=z!==null?_.get(z).__webglFramebuffer:null;ne.bindFramebuffer(C.FRAMEBUFFER,Le)}}},this.readRenderTargetPixelsAsync=async function(E,U,q,X,O,_e,Te,ye=0){if(!(E&&E.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ae=_.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&Te!==void 0&&(Ae=Ae[Te]),Ae)if(U>=0&&U<=E.width-X&&q>=0&&q<=E.height-O){ne.bindFramebuffer(C.FRAMEBUFFER,Ae);const Le=E.textures[ye],Oe=Le.format,Ie=Le.type;if(!xe.textureFormatReadable(Oe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!xe.textureTypeReadable(Ie))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const qe=C.createBuffer();C.bindBuffer(C.PIXEL_PACK_BUFFER,qe),C.bufferData(C.PIXEL_PACK_BUFFER,_e.byteLength,C.STREAM_READ),E.textures.length>1&&C.readBuffer(C.COLOR_ATTACHMENT0+ye),C.readPixels(U,q,X,O,ue.convert(Oe),ue.convert(Ie),0);const rt=z!==null?_.get(z).__webglFramebuffer:null;ne.bindFramebuffer(C.FRAMEBUFFER,rt);const dt=C.fenceSync(C.SYNC_GPU_COMMANDS_COMPLETE,0);return C.flush(),await Ff(C,dt,4),C.bindBuffer(C.PIXEL_PACK_BUFFER,qe),C.getBufferSubData(C.PIXEL_PACK_BUFFER,0,_e),C.deleteBuffer(qe),C.deleteSync(dt),_e}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(E,U=null,q=0){const X=Math.pow(2,-q),O=Math.floor(E.image.width*X),_e=Math.floor(E.image.height*X),Te=U!==null?U.x:0,ye=U!==null?U.y:0;D.setTexture2D(E,0),C.copyTexSubImage2D(C.TEXTURE_2D,q,0,0,Te,ye,O,_e),ne.unbindTexture()};const Zc=C.createFramebuffer(),Jc=C.createFramebuffer();this.copyTextureToTexture=function(E,U,q=null,X=null,O=0,_e=null){_e===null&&(O!==0?(Qi("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),_e=O,O=0):_e=0);let Te,ye,Ae,Le,Oe,Ie,qe,rt,dt;const pt=E.isCompressedTexture?E.mipmaps[_e]:E.image;if(q!==null)Te=q.max.x-q.min.x,ye=q.max.y-q.min.y,Ae=q.isBox3?q.max.z-q.min.z:1,Le=q.min.x,Oe=q.min.y,Ie=q.isBox3?q.min.z:0;else{const jt=Math.pow(2,-O);Te=Math.floor(pt.width*jt),ye=Math.floor(pt.height*jt),E.isDataArrayTexture?Ae=pt.depth:E.isData3DTexture?Ae=Math.floor(pt.depth*jt):Ae=1,Le=0,Oe=0,Ie=0}X!==null?(qe=X.x,rt=X.y,dt=X.z):(qe=0,rt=0,dt=0);const at=ue.convert(U.format),Ue=ue.convert(U.type);let nt;U.isData3DTexture?(D.setTexture3D(U,0),nt=C.TEXTURE_3D):U.isDataArrayTexture||U.isCompressedArrayTexture?(D.setTexture2DArray(U,0),nt=C.TEXTURE_2D_ARRAY):(D.setTexture2D(U,0),nt=C.TEXTURE_2D),C.pixelStorei(C.UNPACK_FLIP_Y_WEBGL,U.flipY),C.pixelStorei(C.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),C.pixelStorei(C.UNPACK_ALIGNMENT,U.unpackAlignment);const Je=C.getParameter(C.UNPACK_ROW_LENGTH),Wt=C.getParameter(C.UNPACK_IMAGE_HEIGHT),ii=C.getParameter(C.UNPACK_SKIP_PIXELS),Xt=C.getParameter(C.UNPACK_SKIP_ROWS),Ni=C.getParameter(C.UNPACK_SKIP_IMAGES);C.pixelStorei(C.UNPACK_ROW_LENGTH,pt.width),C.pixelStorei(C.UNPACK_IMAGE_HEIGHT,pt.height),C.pixelStorei(C.UNPACK_SKIP_PIXELS,Le),C.pixelStorei(C.UNPACK_SKIP_ROWS,Oe),C.pixelStorei(C.UNPACK_SKIP_IMAGES,Ie);const ut=E.isDataArrayTexture||E.isData3DTexture,Ot=U.isDataArrayTexture||U.isData3DTexture;if(E.isDepthTexture){const jt=_.get(E),Lt=_.get(U),Bt=_.get(jt.__renderTarget),cs=_.get(Lt.__renderTarget);ne.bindFramebuffer(C.READ_FRAMEBUFFER,Bt.__webglFramebuffer),ne.bindFramebuffer(C.DRAW_FRAMEBUFFER,cs.__webglFramebuffer);for(let Hn=0;Hn<Ae;Hn++)ut&&(C.framebufferTextureLayer(C.READ_FRAMEBUFFER,C.COLOR_ATTACHMENT0,_.get(E).__webglTexture,O,Ie+Hn),C.framebufferTextureLayer(C.DRAW_FRAMEBUFFER,C.COLOR_ATTACHMENT0,_.get(U).__webglTexture,_e,dt+Hn)),C.blitFramebuffer(Le,Oe,Te,ye,qe,rt,Te,ye,C.DEPTH_BUFFER_BIT,C.NEAREST);ne.bindFramebuffer(C.READ_FRAMEBUFFER,null),ne.bindFramebuffer(C.DRAW_FRAMEBUFFER,null)}else if(O!==0||E.isRenderTargetTexture||_.has(E)){const jt=_.get(E),Lt=_.get(U);ne.bindFramebuffer(C.READ_FRAMEBUFFER,Zc),ne.bindFramebuffer(C.DRAW_FRAMEBUFFER,Jc);for(let Bt=0;Bt<Ae;Bt++)ut?C.framebufferTextureLayer(C.READ_FRAMEBUFFER,C.COLOR_ATTACHMENT0,jt.__webglTexture,O,Ie+Bt):C.framebufferTexture2D(C.READ_FRAMEBUFFER,C.COLOR_ATTACHMENT0,C.TEXTURE_2D,jt.__webglTexture,O),Ot?C.framebufferTextureLayer(C.DRAW_FRAMEBUFFER,C.COLOR_ATTACHMENT0,Lt.__webglTexture,_e,dt+Bt):C.framebufferTexture2D(C.DRAW_FRAMEBUFFER,C.COLOR_ATTACHMENT0,C.TEXTURE_2D,Lt.__webglTexture,_e),O!==0?C.blitFramebuffer(Le,Oe,Te,ye,qe,rt,Te,ye,C.COLOR_BUFFER_BIT,C.NEAREST):Ot?C.copyTexSubImage3D(nt,_e,qe,rt,dt+Bt,Le,Oe,Te,ye):C.copyTexSubImage2D(nt,_e,qe,rt,Le,Oe,Te,ye);ne.bindFramebuffer(C.READ_FRAMEBUFFER,null),ne.bindFramebuffer(C.DRAW_FRAMEBUFFER,null)}else Ot?E.isDataTexture||E.isData3DTexture?C.texSubImage3D(nt,_e,qe,rt,dt,Te,ye,Ae,at,Ue,pt.data):U.isCompressedArrayTexture?C.compressedTexSubImage3D(nt,_e,qe,rt,dt,Te,ye,Ae,at,pt.data):C.texSubImage3D(nt,_e,qe,rt,dt,Te,ye,Ae,at,Ue,pt):E.isDataTexture?C.texSubImage2D(C.TEXTURE_2D,_e,qe,rt,Te,ye,at,Ue,pt.data):E.isCompressedTexture?C.compressedTexSubImage2D(C.TEXTURE_2D,_e,qe,rt,pt.width,pt.height,at,pt.data):C.texSubImage2D(C.TEXTURE_2D,_e,qe,rt,Te,ye,at,Ue,pt);C.pixelStorei(C.UNPACK_ROW_LENGTH,Je),C.pixelStorei(C.UNPACK_IMAGE_HEIGHT,Wt),C.pixelStorei(C.UNPACK_SKIP_PIXELS,ii),C.pixelStorei(C.UNPACK_SKIP_ROWS,Xt),C.pixelStorei(C.UNPACK_SKIP_IMAGES,Ni),_e===0&&U.generateMipmaps&&C.generateMipmap(nt),ne.unbindTexture()},this.initRenderTarget=function(E){_.get(E).__webglFramebuffer===void 0&&D.setupRenderTarget(E)},this.initTexture=function(E){E.isCubeTexture?D.setTextureCube(E,0):E.isData3DTexture?D.setTexture3D(E,0):E.isDataArrayTexture||E.isCompressedArrayTexture?D.setTexture2DArray(E,0):D.setTexture2D(E,0),ne.unbindTexture()},this.resetState=function(){P=0,B=0,z=null,ne.reset(),be.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=Ze._getDrawingBufferColorSpace(e),t.unpackColorSpace=Ze._getUnpackColorSpace()}}const zl={type:"change"},oo={type:"start"},Wc={type:"end"},Or=new rr,kl=new On,M0=Math.cos(70*Bf.DEG2RAD),xt=new F,kt=2*Math.PI,st={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Ws=1e-6;class S0 extends bd{constructor(e,t=null){super(e,t),this.state=st.NONE,this.target=new F,this.cursor=new F,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Si.ROTATE,MIDDLE:Si.DOLLY,RIGHT:Si.PAN},this.touches={ONE:Mi.ROTATE,TWO:Mi.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new F,this._lastQuaternion=new ti,this._lastTargetPosition=new F,this._quat=new ti().setFromUnitVectors(e.up,new F(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new pl,this._sphericalDelta=new pl,this._scale=1,this._panOffset=new F,this._rotateStart=new Ge,this._rotateEnd=new Ge,this._rotateDelta=new Ge,this._panStart=new Ge,this._panEnd=new Ge,this._panDelta=new Ge,this._dollyStart=new Ge,this._dollyEnd=new Ge,this._dollyDelta=new Ge,this._dollyDirection=new F,this._mouse=new Ge,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=b0.bind(this),this._onPointerDown=y0.bind(this),this._onPointerUp=E0.bind(this),this._onContextMenu=D0.bind(this),this._onMouseWheel=w0.bind(this),this._onKeyDown=R0.bind(this),this._onTouchStart=C0.bind(this),this._onTouchMove=P0.bind(this),this._onMouseDown=T0.bind(this),this._onMouseMove=A0.bind(this),this._interceptControlDown=L0.bind(this),this._interceptControlUp=N0.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(zl),this.update(),this.state=st.NONE}update(e=null){const t=this.object.position;xt.copy(t).sub(this.target),xt.applyQuaternion(this._quat),this._spherical.setFromVector3(xt),this.autoRotate&&this.state===st.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let i=this.minAzimuthAngle,r=this.maxAzimuthAngle;isFinite(i)&&isFinite(r)&&(i<-Math.PI?i+=kt:i>Math.PI&&(i-=kt),r<-Math.PI?r+=kt:r>Math.PI&&(r-=kt),i<=r?this._spherical.theta=Math.max(i,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+r)/2?Math.max(i,this._spherical.theta):Math.min(r,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=a!=this._spherical.radius}if(xt.setFromSpherical(this._spherical),xt.applyQuaternion(this._quatInverse),t.copy(this.target).add(xt),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=xt.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),s=!!l}else if(this.object.isOrthographicCamera){const o=new F(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=l!==this.object.zoom;const c=new F(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=xt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Or.origin.copy(this.object.position),Or.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Or.direction))<M0?this.object.lookAt(this.target):(kl.setFromNormalAndCoplanarPoint(this.object.up,this.target),Or.intersectPlane(kl,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>Ws||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Ws||this._lastTargetPosition.distanceToSquared(this.target)>Ws?(this.dispatchEvent(zl),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?kt/60*this.autoRotateSpeed*e:kt/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){xt.setFromMatrixColumn(t,0),xt.multiplyScalar(-e),this._panOffset.add(xt)}_panUp(e,t){this.screenSpacePanning===!0?xt.setFromMatrixColumn(t,1):(xt.setFromMatrixColumn(t,0),xt.crossVectors(this.object.up,xt)),xt.multiplyScalar(e),this._panOffset.add(xt)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const r=this.object.position;xt.copy(r).sub(this.target);let s=xt.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/i.clientHeight,this.object.matrix),this._panUp(2*t*s/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),r=e-i.left,s=t-i.top,a=i.width,o=i.height;this._mouse.x=r/a*2-1,this._mouse.y=-(s/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(kt*this._rotateDelta.x/t.clientHeight),this._rotateUp(kt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(kt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-kt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(kt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-kt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(i,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(i,r)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(i*i+r*r);this._dollyStart.set(0,s)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),r=.5*(e.pageX+i.x),s=.5*(e.pageY+i.y);this._rotateEnd.set(r,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(kt*this._rotateDelta.x/t.clientHeight),this._rotateUp(kt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(i,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(i*i+r*r);this._dollyEnd.set(0,s),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new Ge,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,i={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:i.deltaY*=16;break;case 2:i.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(i.deltaY*=10),i}}function y0(n){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(n.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(n)&&(this._addPointer(n),n.pointerType==="touch"?this._onTouchStart(n):this._onMouseDown(n)))}function b0(n){this.enabled!==!1&&(n.pointerType==="touch"?this._onTouchMove(n):this._onMouseMove(n))}function E0(n){switch(this._removePointer(n),this._pointers.length){case 0:this.domElement.releasePointerCapture(n.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Wc),this.state=st.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function T0(n){let e;switch(n.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case Si.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(n),this.state=st.DOLLY;break;case Si.ROTATE:if(n.ctrlKey||n.metaKey||n.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(n),this.state=st.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(n),this.state=st.ROTATE}break;case Si.PAN:if(n.ctrlKey||n.metaKey||n.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(n),this.state=st.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(n),this.state=st.PAN}break;default:this.state=st.NONE}this.state!==st.NONE&&this.dispatchEvent(oo)}function A0(n){switch(this.state){case st.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(n);break;case st.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(n);break;case st.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(n);break}}function w0(n){this.enabled===!1||this.enableZoom===!1||this.state!==st.NONE||(n.preventDefault(),this.dispatchEvent(oo),this._handleMouseWheel(this._customWheelEvent(n)),this.dispatchEvent(Wc))}function R0(n){this.enabled!==!1&&this._handleKeyDown(n)}function C0(n){switch(this._trackPointer(n),this._pointers.length){case 1:switch(this.touches.ONE){case Mi.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(n),this.state=st.TOUCH_ROTATE;break;case Mi.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(n),this.state=st.TOUCH_PAN;break;default:this.state=st.NONE}break;case 2:switch(this.touches.TWO){case Mi.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(n),this.state=st.TOUCH_DOLLY_PAN;break;case Mi.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(n),this.state=st.TOUCH_DOLLY_ROTATE;break;default:this.state=st.NONE}break;default:this.state=st.NONE}this.state!==st.NONE&&this.dispatchEvent(oo)}function P0(n){switch(this._trackPointer(n),this.state){case st.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(n),this.update();break;case st.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(n),this.update();break;case st.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(n),this.update();break;case st.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(n),this.update();break;default:this.state=st.NONE}}function D0(n){this.enabled!==!1&&n.preventDefault()}function L0(n){n.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function N0(n){n.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class I0 extends Dt{constructor(e=document.createElement("div")){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.center=new Ge(.5,.5),this.addEventListener("removed",function(){this.traverse(function(t){t.element&&t.element instanceof t.element.ownerDocument.defaultView.Element&&t.element.parentNode!==null&&t.element.remove()})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this}}const vi=new F,Vl=new ht,Hl=new ht,Gl=new F,Wl=new F;class U0{constructor(e={}){const t=this;let i,r,s,a;const o={objects:new WeakMap},l=e.element!==void 0?e.element:document.createElement("div");l.style.overflow="hidden",this.domElement=l,this.sortObjects=!0,this.getSize=function(){return{width:i,height:r}},this.render=function(g,x){g.matrixWorldAutoUpdate===!0&&g.updateMatrixWorld(),x.parent===null&&x.matrixWorldAutoUpdate===!0&&x.updateMatrixWorld(),Vl.copy(x.matrixWorldInverse),Hl.multiplyMatrices(x.projectionMatrix,Vl),h(g,g,x),this.sortObjects&&m(g)},this.setSize=function(g,x){i=g,r=x,s=i/2,a=r/2,l.style.width=g+"px",l.style.height=x+"px"};function c(g){g.isCSS2DObject&&(g.element.style.display="none");for(let x=0,p=g.children.length;x<p;x++)c(g.children[x])}function h(g,x,p){if(g.visible===!1){c(g);return}if(g.isCSS2DObject){vi.setFromMatrixPosition(g.matrixWorld),vi.applyMatrix4(Hl);const u=vi.z>=-1&&vi.z<=1&&g.layers.test(p.layers)===!0,y=g.element;y.style.display=u===!0?"":"none",u===!0&&(g.onBeforeRender(t,x,p),y.style.transform="translate("+-100*g.center.x+"%,"+-100*g.center.y+"%)translate("+(vi.x*s+s)+"px,"+(-vi.y*a+a)+"px)",y.parentNode!==l&&l.appendChild(y),g.onAfterRender(t,x,p));const v={distanceToCameraSquared:f(p,g)};o.objects.set(g,v)}for(let u=0,y=g.children.length;u<y;u++)h(g.children[u],x,p)}function f(g,x){return Gl.setFromMatrixPosition(g.matrixWorld),Wl.setFromMatrixPosition(x.matrixWorld),Gl.distanceToSquared(Wl)}function d(g){const x=[];return g.traverseVisible(function(p){p.isCSS2DObject&&x.push(p)}),x}function m(g){const x=d(g).sort(function(u,y){if(u.renderOrder!==y.renderOrder)return y.renderOrder-u.renderOrder;const v=o.objects.get(u).distanceToCameraSquared,M=o.objects.get(y).distanceToCameraSquared;return v-M}),p=x.length;for(let u=0,y=x.length;u<y;u++)x[u].element.style.zIndex=p-u}}}function F0({containerRef:n,data:e,autoOrbit:t}){const i=he.useRef(null),r=he.useRef(null),s=he.useRef(null),a=he.useRef(null),o=he.useRef(null),l=he.useRef(new Map),c=he.useRef([]),h=he.useRef(null),f=he.useRef(null),d=he.useRef(null),m=he.useRef(null),g=he.useRef(null),x=he.useRef(new Float32Array(0)),p=he.useRef(new Float32Array(0)),u=he.useRef(new Float32Array(0)),y=he.useRef(new Float32Array(0)),v=he.useRef(new Float32Array(0)),M=he.useRef(new yd),b=he.useRef(new Ge),w=he.useRef(e),[R,I]=he.useState(null),S=he.useRef(null),[T,P]=he.useState([]),B=he.useRef([]),z=he.useRef(null),[j,K]=he.useState(null);return he.useEffect(()=>{w.current=e},[e]),he.useEffect(()=>{const L=n.current;if(!L)return;const k=new ld;k.background=new Qe(_t.background),s.current=k;const Z=new Zt(60,1,1,5e3);Z.position.set(0,0,400),a.current=Z;const re=new v0({antialias:!0});re.setPixelRatio(window.devicePixelRatio),L.appendChild(re.domElement),i.current=re;const V=64,W=document.createElement("canvas");W.width=V,W.height=V;const ce=W.getContext("2d");if(!ce){re.dispose(),re.domElement.parentNode&&re.domElement.parentNode.removeChild(re.domElement);return}const se=ce.createRadialGradient(V/2,V/2,0,V/2,V/2,V/2);se.addColorStop(0,"rgba(255,255,255,1)"),se.addColorStop(.5,"rgba(255,255,255,0.8)"),se.addColorStop(1,"rgba(255,255,255,0)"),ce.fillStyle=se,ce.fillRect(0,0,V,V);const we=new md(W);g.current=we;const Se=new U0;Se.domElement.style.position="absolute",Se.domElement.style.top="0",Se.domElement.style.left="0",Se.domElement.style.pointerEvents="none",Se.domElement.style.zIndex="1",L.appendChild(Se.domElement),r.current=Se;const Y=new S0(Z,re.domElement);Y.enableDamping=!0,Y.dampingFactor=.1,Y.minDistance=50,Y.maxDistance=2e3,o.current=Y;const Q=new Ct,ge=new Jr({color:_t.link,transparent:!0,opacity:.6}),Ce=new Os(Q,ge);Ce.visible=!1,k.add(Ce),h.current=Ce;const le=new Ct,De=new Md({color:9741240,transparent:!0,opacity:.85,dashSize:16,gapSize:10}),Ve=new Os(le,De);Ve.visible=!1,k.add(Ve),f.current=Ve;const Ne=new Ct,Fe=new Jr({color:16766720,transparent:!0,opacity:1,linewidth:2}),je=new Os(Ne,Fe);je.visible=!1,k.add(je),d.current=je;const ze=new Ct,lt=new Fc({size:20,map:we,vertexColors:!0,sizeAttenuation:!0,transparent:!0,opacity:.9,depthWrite:!1}),C=new pd(ze,lt);C.visible=!1,k.add(C),m.current=C;const et=L.getBoundingClientRect();re.setSize(et.width,et.height),Se.setSize(et.width,et.height),Z.aspect=et.width/et.height,Z.updateProjectionMatrix();const Ke=new ResizeObserver(ne=>{for(const A of ne){const{width:_,height:D}=A.contentRect;_===0||D===0||(re.setSize(_,D),Se.setSize(_,D),Z.aspect=_/D,Z.updateProjectionMatrix())}});Ke.observe(L);const xe=l.current;return()=>{Ke.disconnect(),Y.dispose(),re.dispose(),re.domElement.parentNode&&re.domElement.parentNode.removeChild(re.domElement),Se.domElement.parentNode&&Se.domElement.parentNode.removeChild(Se.domElement);for(const ne of xe.values())ne.mesh.remove(ne.label),ne.labelDiv.remove(),k.remove(ne.mesh),ne.mesh.geometry.dispose(),ne.mesh.material.dispose();xe.clear(),c.current=[],h.current&&(k.remove(h.current),h.current.geometry.dispose(),h.current.material.dispose(),h.current=null),f.current&&(k.remove(f.current),f.current.geometry.dispose(),f.current.material.dispose(),f.current=null),d.current&&(k.remove(d.current),d.current.geometry.dispose(),d.current.material.dispose(),d.current=null),m.current&&(k.remove(m.current),m.current.geometry.dispose(),m.current.material.dispose(),m.current=null),we.dispose(),g.current=null,x.current=new Float32Array(0),p.current=new Float32Array(0),u.current=new Float32Array(0),y.current=new Float32Array(0),v.current=new Float32Array(0),s.current=null,a.current=null,i.current=null,r.current=null,o.current=null}},[n]),he.useEffect(()=>{const L=o.current;L&&(L.autoRotate=t,L.autoRotateSpeed=-.5)},[t]),he.useEffect(()=>{const L=i.current,k=a.current;if(!L||!k)return;const Z=ce=>{const se=L.domElement.getBoundingClientRect();b.current.x=(ce.clientX-se.left)/se.width*2-1,b.current.y=-((ce.clientY-se.top)/se.height)*2+1};let re={x:0,y:0};const V=ce=>{re={x:ce.clientX,y:ce.clientY}},W=ce=>{var De,Ve;const se=ce.clientX-re.x,we=ce.clientY-re.y;if(se*se+we*we>25)return;const Se=L.domElement.getBoundingClientRect(),Y=new Ge((ce.clientX-Se.left)/Se.width*2-1,-((ce.clientY-Se.top)/Se.height)*2+1),Q=M.current;Q.setFromCamera(Y,k);const Ce=(De=Q.intersectObjects(c.current,!1)[0])==null?void 0:De.object,le=((Ve=Ce==null?void 0:Ce.userData)==null?void 0:Ve.nodeId)??null;le===z.current?(z.current=null,K(null)):le?(z.current=le,K(le)):(z.current=null,K(null))};return L.domElement.addEventListener("mousemove",Z),L.domElement.addEventListener("mousedown",V),L.domElement.addEventListener("mouseup",W),()=>{L.domElement.removeEventListener("mousemove",Z),L.domElement.removeEventListener("mousedown",V),L.domElement.removeEventListener("mouseup",W)}},[]),he.useEffect(()=>{const L=s.current,k=a.current,Z=i.current,re=r.current,V=o.current;if(!L||!k||!Z||!re||!V)return;let W=!0;const ce=()=>{var et,Ke;if(!W)return;requestAnimationFrame(ce),V.update();const{nodes:se,links:we,particles:Se}=w.current,Y=new Set;for(const xe of se.values()){Y.add(xe.id);let ne=l.current.get(xe.id);if(!ne){const G=xe.type==="self"?12:6,$=new ao(G,16,12),H=new so({color:Eo(xe)}),pe=new pn($,H);pe.userData.nodeId=xe.id,L.add(pe);const te=document.createElement("div");te.style.color=xe.isAmbiguous?_t.ambiguous:"#e5e7eb",te.style.fontSize="11px",te.style.fontFamily="sans-serif",te.style.textAlign="center",te.style.whiteSpace="nowrap",te.style.textShadow="0 0 4px #000, 0 0 2px #000";const fe=new I0(te);fe.position.set(0,-(G+6),0),pe.add(fe),ne={mesh:pe,label:fe,labelDiv:te},l.current.set(xe.id,ne),c.current.push(pe)}ne.mesh.position.set(xe.x??0,xe.y??0,xe.z??0);const A=xe.isAmbiguous?_t.ambiguous:"#e5e7eb";ne.labelDiv.style.color!==A&&(ne.labelDiv.style.color=A);const _=Su(xe);ne.labelDiv.textContent!==_&&(ne.labelDiv.textContent=_)}for(const[xe,ne]of l.current)if(!Y.has(xe)){ne.mesh.remove(ne.label),ne.labelDiv.remove(),L.remove(ne.mesh),ne.mesh.geometry.dispose(),ne.mesh.material.dispose();const A=c.current.indexOf(ne.mesh);A>=0&&c.current.splice(A,1),l.current.delete(xe)}M.current.setFromCamera(b.current,k);const ge=(et=M.current.intersectObjects(c.current,!1)[0])==null?void 0:et.object,Ce=((Ke=ge==null?void 0:ge.userData)==null?void 0:Ke.nodeId)??null;Ce!==S.current&&(S.current=Ce,I(Ce));const le=z.current??S.current,De=[],Ve=[];for(const xe of we.values()){const{sourceId:ne,targetId:A}=lr(xe);Y.has(ne)&&Y.has(A)&&(xe.hasDirectObservation||!xe.hasHiddenIntermediate?De.push(xe):Ve.push(xe))}const Ne=le?new Set([le]):null,Fe=h.current;if(Fe){const xe=Fe.geometry,ne=De.length*6,A=(De.length+Ve.length)*6;x.current.length<ne&&(x.current=Ii(x.current,ne),xe.setAttribute("position",new Ut(x.current,3).setUsage(Oi)));const _=d.current;_&&u.current.length<A&&(u.current=Ii(u.current,A),_.geometry.setAttribute("position",new Ut(u.current,3).setUsage(Oi)));const D=x.current,G=u.current;let $=0,H=0;for(const te of De){const{sourceId:fe,targetId:Pe}=lr(te),ie=se.get(fe),oe=se.get(Pe);if(!ie||!oe)continue;const Ee=ie.x??0,Re=ie.y??0,de=ie.z??0,He=oe.x??0,N=oe.y??0,ve=oe.z??0;D[$++]=Ee,D[$++]=Re,D[$++]=de,D[$++]=He,D[$++]=N,D[$++]=ve,le&&(fe===le||Pe===le)&&(Ne==null||Ne.add(fe===le?Pe:fe),G[H++]=Ee,G[H++]=Re,G[H++]=de,G[H++]=He,G[H++]=N,G[H++]=ve)}for(const te of Ve){const{sourceId:fe,targetId:Pe}=lr(te);if(le&&(fe===le||Pe===le)){const ie=se.get(fe),oe=se.get(Pe);if(!ie||!oe)continue;Ne==null||Ne.add(fe===le?Pe:fe),G[H++]=ie.x??0,G[H++]=ie.y??0,G[H++]=ie.z??0,G[H++]=oe.x??0,G[H++]=oe.y??0,G[H++]=oe.z??0}}const pe=xe.getAttribute("position");if(pe&&(pe.needsUpdate=!0),xe.setDrawRange(0,$/3),Fe.visible=$>0,_){const te=_.geometry,fe=te.getAttribute("position");fe&&(fe.needsUpdate=!0),te.setDrawRange(0,H/3),_.visible=H>0}}const je=f.current;if(je){const xe=je.geometry,ne=Ve.length*6;p.current.length<ne&&(p.current=Ii(p.current,ne),xe.setAttribute("position",new Ut(p.current,3).setUsage(Oi)));const A=p.current;let _=0;for(const G of Ve){const{sourceId:$,targetId:H}=lr(G),pe=se.get($),te=se.get(H);!pe||!te||(A[_++]=pe.x??0,A[_++]=pe.y??0,A[_++]=pe.z??0,A[_++]=te.x??0,A[_++]=te.y??0,A[_++]=te.z??0)}const D=xe.getAttribute("position");D&&(D.needsUpdate=!0),xe.setDrawRange(0,_/3),je.visible=_>0,_>0&&D&&je.computeLineDistances()}let ze=0;for(let xe=0;xe<Se.length;xe++){const ne=Se[xe];ne.progress+=ne.speed,ne.progress<=1&&(Se[ze++]=ne)}Se.length=ze;const lt=m.current;if(lt){const xe=lt.geometry,ne=Se.length*3;y.current.length<ne&&(y.current=Ii(y.current,ne),xe.setAttribute("position",new Ut(y.current,3).setUsage(Oi))),v.current.length<ne&&(v.current=Ii(v.current,ne),xe.setAttribute("color",new Ut(v.current,3).setUsage(Oi)));const A=y.current,_=v.current,D=new Qe;let G=0;for(const pe of Se){if(pe.progress<0||!Y.has(pe.fromNodeId)||!Y.has(pe.toNodeId))continue;const te=se.get(pe.fromNodeId),fe=se.get(pe.toNodeId);if(!te||!fe)continue;const Pe=pe.progress,ie=(te.x??0)+((fe.x??0)-(te.x??0))*Pe,oe=(te.y??0)+((fe.y??0)-(te.y??0))*Pe,Ee=(te.z??0)+((fe.z??0)-(te.z??0))*Pe;A[G*3]=ie,A[G*3+1]=oe,A[G*3+2]=Ee,D.set(pe.color),_[G*3]=D.r,_[G*3+1]=D.g,_[G*3+2]=D.b,G++}const $=xe.getAttribute("position"),H=xe.getAttribute("color");$&&($.needsUpdate=!0),H&&(H.needsUpdate=!0),xe.setDrawRange(0,G),lt.visible=G>0}const C=Ne?Array.from(Ne).filter(xe=>xe!==le).sort():[];vu(B.current,C)||(B.current=C,P(C));for(const[xe,ne]of l.current){const A=se.get(xe);if(!A)continue;const _=ne.mesh.material;xe===le?_.color.set(16766720):Ne!=null&&Ne.has(xe)?_.color.set(16773299):_.color.set(Eo(A))}Z.render(L,k),re.render(L,k)};return ce(),()=>{W=!1}},[]),{hoveredNodeId:R,hoveredNeighborIds:T,pinnedNodeId:j}}function Xl({packets:n,contacts:e,config:t,fullScreen:i,onFullScreenChange:r}){const s=he.useRef(null),[a]=he.useState(qr),[o,l]=he.useState(a.showAmbiguousPaths),[c,h]=he.useState(a.showAmbiguousNodes),[f,d]=he.useState(a.useAdvertPathHints),[m,g]=he.useState(a.collapseLikelyKnownSiblingRepeaters),[x,p]=he.useState(a.splitAmbiguousByTraffic),[u,y]=he.useState(a.chargeStrength),[v,M]=he.useState(a.observationWindowSec),[b,w]=he.useState(a.letEmDrift),[R,I]=he.useState(a.particleSpeedMultiplier),[S,T]=he.useState(a.showControls),[P,B]=he.useState(a.autoOrbit),[z,j]=he.useState(a.pruneStaleNodes),[K,L]=he.useState(a.pruneStaleMinutes),[k,Z]=he.useState([]);he.useEffect(()=>{jl({...qr(),showAmbiguousPaths:o,showAmbiguousNodes:c,useAdvertPathHints:f,collapseLikelyKnownSiblingRepeaters:m,splitAmbiguousByTraffic:x,chargeStrength:u,observationWindowSec:v,letEmDrift:b,particleSpeedMultiplier:R,pruneStaleNodes:z,pruneStaleMinutes:K,autoOrbit:P,showControls:S})},[o,c,f,m,x,u,v,b,R,z,K,P,S]),he.useEffect(()=>{let se=!1;async function we(){try{const Se=await tu.getRepeaterAdvertPaths(10);se||Z(Se)}catch(Se){se||(console.debug("Failed to load repeater advert path hints",Se),Z([]))}}return we(),()=>{se=!0}},[e.length]);const re=ef({packets:n,contacts:e,config:t,repeaterAdvertPaths:k,showAmbiguousPaths:o,showAmbiguousNodes:c,useAdvertPathHints:f,collapseLikelyKnownSiblingRepeaters:m,splitAmbiguousByTraffic:x,chargeStrength:u,letEmDrift:b,particleSpeedMultiplier:R,observationWindowSec:v,pruneStaleNodes:z,pruneStaleMinutes:K}),{hoveredNodeId:V,pinnedNodeId:W}=F0({containerRef:s,data:re,autoOrbit:P}),ce=W??V;return J.jsxs("div",{ref:s,className:"w-full h-full bg-background relative overflow-hidden",role:"img","aria-label":"3D mesh network visualizer showing radio nodes as colored spheres and packet transmissions as animated arcs between them",children:[J.jsx(bu,{showControls:S,setShowControls:T,fullScreen:i,onFullScreenChange:r,showAmbiguousPaths:o,setShowAmbiguousPaths:l,showAmbiguousNodes:c,setShowAmbiguousNodes:h,useAdvertPathHints:f,setUseAdvertPathHints:d,collapseLikelyKnownSiblingRepeaters:m,setCollapseLikelyKnownSiblingRepeaters:g,splitAmbiguousByTraffic:x,setSplitAmbiguousByTraffic:p,observationWindowSec:v,setObservationWindowSec:M,pruneStaleNodes:z,setPruneStaleNodes:j,pruneStaleMinutes:K,setPruneStaleMinutes:L,letEmDrift:b,setLetEmDrift:w,autoOrbit:P,setAutoOrbit:B,chargeStrength:u,setChargeStrength:y,particleSpeedMultiplier:R,setParticleSpeedMultiplier:I,nodeCount:re.stats.nodes,linkCount:re.stats.links,onExpandContract:re.expandContract,onClearAndReset:re.clearAndReset}),J.jsx(Eu,{activeNodeId:ce,canonicalNodes:re.canonicalNodes,canonicalNeighborIds:re.canonicalNeighborIds,renderedNodeIds:re.renderedNodeIds})]})}function B0({packets:n,contacts:e,config:t}){const[i,r]=he.useState(()=>qr().hidePacketFeed),[s,a]=he.useState(!1),o=he.useRef(null);he.useEffect(()=>{const c=qr();c.hidePacketFeed!==i&&jl({...c,hidePacketFeed:i})},[i]),he.useEffect(()=>{const c=()=>{document.fullscreenElement||a(!1)};return document.addEventListener("fullscreenchange",c),()=>document.removeEventListener("fullscreenchange",c)},[]);const l=he.useCallback(()=>{var c;document.fullscreenElement?document.exitFullscreen():((c=o.current)==null||c.requestFullscreen(),a(!0))},[]);return J.jsxs("div",{ref:o,className:"flex flex-col h-full bg-background",children:[J.jsxs("div",{className:"flex justify-between items-center px-4 py-3 border-b border-border font-medium text-lg",children:[J.jsx("span",{children:s?"RemoteTerm MeshCore Visualizer":"Mesh Visualizer"}),J.jsx("button",{className:"hidden md:inline-flex items-center justify-center rounded-md p-1.5 text-muted-foreground hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:l,title:s?"Exit fullscreen":"Fullscreen","aria-label":s?"Exit fullscreen":"Enter fullscreen",children:s?J.jsx(ou,{size:18}):J.jsx(su,{size:18})})]}),J.jsx("div",{className:"flex-1 overflow-hidden md:hidden",children:J.jsxs(nu,{defaultValue:"visualizer",className:"h-full flex flex-col",children:[J.jsxs(iu,{className:"mx-4 mt-2 grid grid-cols-2",children:[J.jsx(_o,{value:"visualizer",children:"Visualizer"}),J.jsx(_o,{value:"packets",children:"Packet Feed"})]}),J.jsx(xo,{value:"visualizer",className:"flex-1 m-0 overflow-hidden",children:J.jsx(Xl,{packets:n,contacts:e,config:t})}),J.jsx(xo,{value:"packets",className:"flex-1 m-0 overflow-hidden",children:J.jsx(vo,{packets:n})})]})}),J.jsxs("div",{className:"hidden md:flex flex-1 overflow-hidden",children:[J.jsx("div",{className:Mo("overflow-hidden transition-all duration-200",i?"flex-1":"flex-1 border-r border-border"),children:J.jsx(Xl,{packets:n,contacts:e,config:t,fullScreen:i,onFullScreenChange:r})}),J.jsx("div",{className:Mo("overflow-hidden transition-all duration-200",i?"w-0":"w-[31rem] lg:w-[38rem]"),children:J.jsxs("div",{className:"h-full flex flex-col",children:[J.jsx("div",{className:"px-3 py-2 border-b border-border text-sm font-medium text-muted-foreground",children:"Packet Feed"}),J.jsx("div",{className:"flex-1 overflow-hidden",children:J.jsx(vo,{packets:n})})]})})]})]})}export{B0 as VisualizerView};
|
|
//# sourceMappingURL=VisualizerView-BswMOFbt.js.map
|