miro0o_miniWorldMap/main.js
2026-06-24 15:27:43 +02:00

4371 lines
775 KiB
JavaScript

/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
"use strict";var sc=Object.defineProperty;var gm=Object.getOwnPropertyDescriptor;var xm=Object.getOwnPropertyNames;var vm=Object.prototype.hasOwnProperty;var _m=(i,t)=>{for(var e in t)sc(i,e,{get:t[e],enumerable:!0})},ym=(i,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of xm(t))!vm.call(i,s)&&s!==e&&sc(i,s,{get:()=>t[s],enumerable:!(n=gm(t,s))||n.enumerable});return i};var bm=i=>ym(sc({},"__esModule",{value:!0}),i);var hM={};_m(hM,{default:()=>ec});module.exports=bm(hM);var we=require("obsidian");var qn="mini-world-map-view";var ss=2.2,rc=ss*6;var Qr={strength:.6,radius:.4,threshold:.18};var Fn={angularSpeed:.022,elevationDeg:8,elevationPeriodS:90,radiusBreath:.04,radiusPeriodS:60,resumeDelayMs:1e4,rampUpMs:2e3},Yn={distancePerRadius:12,minDistance:40,maxDistance:140,azimuthOffsetRad:15*Math.PI/180,minMs:800,maxMs:1800,msPerWorldUnit:.45},oc=8e-4;var Vs=[["none","None"],["note-links","Note links"],["hierarchy-parents","Hierarchy parents"],["hierarchy-direct-children","Hierarchy direct children"],["hierarchy-descendants","Hierarchy all children"],["hierarchy-parents-direct","Hierarchy parents + direct"],["hierarchy-all","Hierarchy parents + all children"]],to=[["auto","Auto"],["hover","Hover only"]],Hs=[["nodes","Nodes"],["links","Links"],["both","Nodes + links"]],ac=[["root","legend.root","legend.root.desc","mwm-legend-root"],["folder","legend.folder","legend.folder.desc","mwm-legend-folder"],["folder-meta","legend.folderMeta","legend.folderMeta.desc","mwm-legend-meta"],["file","legend.note","legend.note.desc","mwm-legend-note"],["outside","legend.outsideGroup","legend.outsideGroup.desc","mwm-legend-external"],["outside-file","legend.outsideNote","legend.outsideNote.desc","mwm-legend-outside-file"],["missing","legend.unresolvedNote","legend.unresolvedNote.desc","mwm-legend-unresolved"],["tree","legend.hierarchy","legend.hierarchy.desc","mwm-legend-tree"],["link","legend.noteLinks","legend.noteLinks.desc","mwm-legend-link"],["outside-link","legend.outsideLinks","legend.outsideLinks.desc","mwm-legend-link-external"],["dashed-link","legend.unresolvedLinks","legend.unresolvedLinks.desc","mwm-legend-link-unresolved"]],ke={atlasDepth:6,focusSiblingLimit:160,linkLimit:1200,renderNodeLimit:4200,externalLinkAnchorLimit:700,adaptiveDetail:!0,includeUnresolvedLinks:!0,showLinkOverlay:!0,showExternalLinks:!0,externalDetailMode:"grouped",colorScheme:"auto",labelVisibility:"auto",hoverHighlightMode:"hierarchy-all",hoverTargetMode:"nodes",swirlStrength:0,showRingGuides:!1,hiddenLegendItems:[],ignoreFolders:[".git",".obsidian"]},xn={bloom:{strength:.35,radius:.35,threshold:.22},physics:{repel:200,linkDistance:70,linkStrength:1,centerPull:.04,flatten:.3},look:{nodeSize:1,linkOpacity:.14,twinkle:.5,sizeBy:"degree"},cruise:!0,cruiseSpeed:1,showUnresolved:!1,showOrphans:!0,colorTheme:"imported",qualityOverride:"auto",preset:"adaptive",colorGroups:[],positionCache:{}},xu={language:"en",viewMode:"radial2d",radial:ke,galaxy3d:xn};function lc(i){let t=kn(i)?i:{},e=kn(t.radial),n=e?t.radial:t,s=kn(t.galaxy3d)?t.galaxy3d:t,r=Mm(n);return!e&&t.showLinkOverlay===!1&&(r.showLinkOverlay=ke.showLinkOverlay),{language:rs(t.language??t.locale??t.lang),viewMode:eo(t.viewMode),radial:r,galaxy3d:Sm(s)}}function Mm(i){let t=kn(i)?i:{},e=ke,n=new Set(ac.map(([r])=>r)),s=t.hoverHighlightMode??(t.enableLinkHover===!0?"note-links":e.hoverHighlightMode);return{atlasDepth:Ae(t.atlasDepth,1,80,e.atlasDepth),focusSiblingLimit:Ae(t.focusSiblingLimit,10,1e3,e.focusSiblingLimit),linkLimit:Ae(t.linkLimit,0,3e4,e.linkLimit),renderNodeLimit:Ae(t.renderNodeLimit,200,2e4,e.renderNodeLimit),externalLinkAnchorLimit:Ae(t.externalLinkAnchorLimit,0,2e4,e.externalLinkAnchorLimit),adaptiveDetail:typeof t.adaptiveDetail=="boolean"?t.adaptiveDetail:e.adaptiveDetail,includeUnresolvedLinks:typeof t.includeUnresolvedLinks=="boolean"?t.includeUnresolvedLinks:e.includeUnresolvedLinks,showLinkOverlay:typeof t.showLinkOverlay=="boolean"?t.showLinkOverlay:e.showLinkOverlay,showExternalLinks:typeof t.showExternalLinks=="boolean"?t.showExternalLinks:e.showExternalLinks,externalDetailMode:cc(t.externalDetailMode),colorScheme:no(t.colorScheme),labelVisibility:Xs(t.labelVisibility),hoverHighlightMode:fi(s),hoverTargetMode:os(t.hoverTargetMode),swirlStrength:Ae(t.swirlStrength,0,100,e.swirlStrength),showRingGuides:typeof t.showRingGuides=="boolean"?t.showRingGuides:e.showRingGuides,hiddenLegendItems:Array.isArray(t.hiddenLegendItems)?t.hiddenLegendItems.filter(r=>typeof r=="string"&&n.has(r)):e.hiddenLegendItems.slice(),ignoreFolders:Array.isArray(t.ignoreFolders)?t.ignoreFolders.filter(r=>typeof r=="string"&&r.trim().length>0):e.ignoreFolders.slice()}}function Sm(i){let t=kn(i)?i:{},e=xn,n=kn(t.bloom)?t.bloom:{},s=kn(t.physics)?t.physics:{},r=kn(t.look)?t.look:{};return{bloom:{strength:rn(n.strength,e.bloom.strength),radius:rn(n.radius,e.bloom.radius),threshold:rn(n.threshold,e.bloom.threshold)},physics:{repel:rn(s.repel,e.physics.repel),linkDistance:rn(s.linkDistance,e.physics.linkDistance),linkStrength:rn(s.linkStrength,e.physics.linkStrength),centerPull:rn(s.centerPull,e.physics.centerPull),flatten:rn(s.flatten,e.physics.flatten)},look:{nodeSize:rn(r.nodeSize,e.look.nodeSize),linkOpacity:rn(r.linkOpacity,e.look.linkOpacity),twinkle:rn(r.twinkle,e.look.twinkle),sizeBy:["degree","fileSize","uniform"].includes(r.sizeBy)?r.sizeBy:e.look.sizeBy},cruise:typeof t.cruise=="boolean"?t.cruise:e.cruise,cruiseSpeed:rn(t.cruiseSpeed,e.cruiseSpeed),showUnresolved:typeof t.showUnresolved=="boolean"?t.showUnresolved:typeof t.includeUnresolvedLinks=="boolean"?t.includeUnresolvedLinks:e.showUnresolved,showOrphans:typeof t.showOrphans=="boolean"?t.showOrphans:e.showOrphans,colorTheme:typeof t.colorTheme=="string"?t.colorTheme:e.colorTheme,qualityOverride:["auto","high","low","mobile"].includes(t.qualityOverride)?t.qualityOverride:e.qualityOverride,preset:t.preset==="deep-space"?"deep-space":"adaptive",colorGroups:Array.isArray(t.colorGroups)?t.colorGroups.filter(o=>kn(o)&&typeof o.query=="string"&&typeof o.color=="string"):[],positionCache:kn(t.positionCache)&&!Array.isArray(t.positionCache)?t.positionCache:{}}}function Ws(i){return{charge:-i.repel,linkDistance:i.linkDistance,linkStrength:i.linkStrength,centerPull:i.centerPull,flatten:i.flatten,velocityDecay:.6}}function eo(i){return i==="map3d"||i==="radial2d"?i:xu.viewMode}function rs(i){return i==="zh"?"zh":xu.language}function no(i){return i==="auto"||i==="day"||i==="night"?i:ke.colorScheme}function Xs(i){return i==="hover"?"hover":ke.labelVisibility}function fi(i){return Vs.some(([t])=>t===i)?i:ke.hoverHighlightMode}function os(i){return Hs.some(([t])=>t===i)?i:ke.hoverTargetMode}function qs(i){return fi(i)==="note-links"}function cc(i){return i==="selected"||i==="exact"||i==="grouped"?i:ke.externalDetailMode}function Ae(i,t,e,n){let s=rn(i,n);return Math.min(Math.max(s,t),e)}function rn(i,t){return typeof i=="number"&&Number.isFinite(i)?i:Number.parseFloat(String(i))||t}function kn(i){return typeof i=="object"&&i!==null}var wm=[["en","English"],["zh","\u4E2D\u6587"]],vu={language:{en:"Language",zh:"\u8BED\u8A00"},"language.en":{en:"English",zh:"English"},"language.zh":{en:"Chinese",zh:"\u4E2D\u6587"},"mode.radial2d":{en:"2D",zh:"2D"},"mode.map3d":{en:"3D",zh:"3D"},"stats.counts":{en:"{nodes} nodes / {links} links",zh:"{nodes} \u4E2A\u8282\u70B9 / {links} \u6761\u94FE\u63A5"},"stats.3d":{en:"{fps} fps \xB7 {calls} calls \xB7 {nodes}n/{links}l \xB7 {state}",zh:"{fps} fps \xB7 {calls} calls \xB7 {nodes} \u8282\u70B9/{links} \u94FE\u63A5 \xB7 {state}"},"state.settled":{en:"settled",zh:"\u5DF2\u6C89\u964D"},"state.layout":{en:"layout",zh:"\u5E03\u5C40\u4E2D"},"tab.inspect":{en:"Inspect",zh:"\u68C0\u67E5"},"tab.pins":{en:"Pins",zh:"\u56FA\u5B9A"},"tab.view":{en:"View",zh:"\u89C6\u56FE"},"tab.controls":{en:"Controls",zh:"\u63A7\u5236"},"tab.defaults":{en:"Defaults",zh:"\u9ED8\u8BA4"},"tab.appearance":{en:"Appearance",zh:"\u5916\u89C2"},"tab.physics":{en:"Physics",zh:"\u529B\u5B66"},"tab.motion":{en:"Motion",zh:"\u8FD0\u52A8"},"tab.advanced":{en:"Advanced",zh:"\u9AD8\u7EA7"},"common.search":{en:"Search",zh:"\u641C\u7D22"},"common.recenter":{en:"Center",zh:"\u56DE\u4E2D\u5FC3"},"common.fit":{en:"Fit",zh:"\u9002\u914D"},"common.rebuild":{en:"Rebuild",zh:"\u91CD\u5EFA"},"common.pin":{en:"Pin",zh:"\u56FA\u5B9A"},"common.pinCurrent":{en:"Pin current",zh:"\u56FA\u5B9A\u5F53\u524D"},"common.clear":{en:"Clear",zh:"\u6E05\u7A7A"},"common.group":{en:"Group",zh:"\u5206\u7EC4"},"common.ungroup":{en:"Ungroup",zh:"\u53D6\u6D88\u5206\u7EC4"},"common.inspect":{en:"Inspect",zh:"\u68C0\u67E5"},"common.open":{en:"Open",zh:"\u6253\u5F00"},"common.focus":{en:"Focus",zh:"\u805A\u7126"},"common.root":{en:"Root",zh:"\u6839\u8282\u70B9"},"common.source":{en:"Source",zh:"\u6765\u6E90"},"common.target":{en:"Target",zh:"\u76EE\u6807"},"common.none":{en:"None",zh:"\u65E0"},"common.default":{en:"Default",zh:"\u9ED8\u8BA4"},"common.resetDefaults":{en:"Reset defaults",zh:"\u91CD\u7F6E\u9ED8\u8BA4"},"view.atlas":{en:"Atlas",zh:"\u56FE\u8C31"},"view.focus":{en:"Focus",zh:"\u805A\u7126"},"view.vaultRoot":{en:"Vault root",zh:"\u5E93\u6839\u76EE\u5F55"},"view.mode":{en:"Map mode",zh:"\u5730\u56FE\u6A21\u5F0F"},"view.theme":{en:"Theme",zh:"\u4E3B\u9898"},"theme.auto":{en:"System",zh:"\u8DDF\u968F\u7CFB\u7EDF"},"theme.radialAuto":{en:"System",zh:"\u8DDF\u968F\u7CFB\u7EDF"},"theme.day":{en:"Light",zh:"\u6D45\u8272"},"theme.night":{en:"Dark",zh:"\u6DF1\u8272"},"theme.deep":{en:"Deep space",zh:"\u6DF1\u7A7A"},"inspect.type":{en:"Type",zh:"\u7C7B\u578B"},"inspect.depth":{en:"Depth",zh:"\u6DF1\u5EA6"},"inspect.notes":{en:"Notes",zh:"\u7B14\u8BB0"},"inspect.out":{en:"Out",zh:"\u51FA\u94FE"},"inspect.in":{en:"In",zh:"\u5165\u94FE"},"inspect.linkOverlay":{en:"Note link",zh:"\u7B14\u8BB0\u94FE\u63A5"},"inspect.weight":{en:"Weight",zh:"\u6743\u91CD"},"inspect.raw":{en:"Raw",zh:"\u539F\u59CB"},"inspect.unresolved":{en:"Unresolved",zh:"\u672A\u89E3\u6790"},"inspect.external":{en:"Outside",zh:"\u5916\u90E8"},"inspect.outgoing":{en:"Outgoing ({count})",zh:"\u51FA\u94FE\uFF08{count}\uFF09"},"inspect.backlinks":{en:"Backlinks ({count})",zh:"\u53CD\u5411\u94FE\u63A5\uFF08{count}\uFF09"},"inspect.parentRoot":{en:"Parent of root",zh:"\u5F53\u524D\u6839\u7684\u7236\u6587\u4EF6\u5939"},"pins.groupName":{en:"Group name",zh:"\u5206\u7EC4\u540D\u79F0"},"pins.empty":{en:"No pinned paths.",zh:"\u6682\u65E0\u56FA\u5B9A\u8DEF\u5F84\u3002"},"pins.already":{en:"That path is already pinned.",zh:"\u8FD9\u6761\u8DEF\u5F84\u5DF2\u7ECF\u56FA\u5B9A\u3002"},"pins.selectFirst":{en:"Select pinned paths to group.",zh:"\u5148\u9009\u62E9\u8981\u5206\u7EC4\u7684\u56FA\u5B9A\u8DEF\u5F84\u3002"},"pins.selectBeforePin":{en:"Select or hover a path before pinning.",zh:"\u5148\u9009\u62E9\u6216\u60AC\u505C\u4E00\u6761\u8DEF\u5F84\u518D\u56FA\u5B9A\u3002"},"pins.ungrouped":{en:"Ungrouped",zh:"\u672A\u5206\u7EC4"},"pins.selectForGroup":{en:"Select for grouping",zh:"\u9009\u62E9\u7528\u4E8E\u5206\u7EC4"},"pins.hideHighlight":{en:"Hide route",zh:"\u9690\u85CF\u8DEF\u7EBF"},"pins.showHighlight":{en:"Show route",zh:"\u663E\u793A\u8DEF\u7EBF"},"control.depth":{en:"Depth",zh:"\u6DF1\u5EA6"},"control.nodes":{en:"Nodes",zh:"\u8282\u70B9"},"control.noteLinks":{en:"Note links",zh:"\u7B14\u8BB0\u94FE\u63A5"},"control.showNoteLinks":{en:"Show note links",zh:"\u663E\u793A\u7B14\u8BB0\u94FE\u63A5"},"control.hover":{en:"Hover",zh:"\u60AC\u505C"},"control.hoverTargets":{en:"Hover targets",zh:"\u60AC\u505C\u5BF9\u8C61"},"control.labels":{en:"Labels",zh:"\u6807\u7B7E"},"control.spin":{en:"Ring spin",zh:"\u73AF\u5F62\u65CB\u8F6C"},"control.ringGuides":{en:"Ring guides",zh:"\u73AF\u5F62\u53C2\u8003\u7EBF"},"control.outsideLinks":{en:"Outside links",zh:"\u5916\u90E8\u94FE\u63A5"},"control.outsideDetail":{en:"Outside detail",zh:"\u5916\u90E8\u7EC6\u8282"},"control.exactOutsideFiles":{en:"Exact outside notes",zh:"\u7CBE\u786E\u5916\u90E8\u7B14\u8BB0"},"control.legend":{en:"Legend",zh:"\u56FE\u4F8B"},"control.defaultDepth":{en:"Default depth",zh:"\u9ED8\u8BA4\u6DF1\u5EA6"},"control.defaultNodes":{en:"Default nodes",zh:"\u9ED8\u8BA4\u8282\u70B9\u6570"},"control.defaultNoteLinks":{en:"Default note links",zh:"\u9ED8\u8BA4\u7B14\u8BB0\u94FE\u63A5"},"control.unresolvedLinks":{en:"Unresolved links",zh:"\u672A\u89E3\u6790\u94FE\u63A5"},"control.ignoredFolders":{en:"Ignored folders",zh:"\u5FFD\u7565\u6587\u4EF6\u5939"},"hover.none":{en:"None",zh:"\u65E0"},"hover.note-links":{en:"Note links",zh:"\u7B14\u8BB0\u94FE\u63A5"},"hover.hierarchy-parents":{en:"Parents",zh:"\u7236\u7EA7"},"hover.hierarchy-direct-children":{en:"Direct children",zh:"\u76F4\u63A5\u5B50\u7EA7"},"hover.hierarchy-descendants":{en:"All children",zh:"\u5168\u90E8\u5B50\u7EA7"},"hover.hierarchy-parents-direct":{en:"Parents + direct children",zh:"\u7236\u7EA7 + \u76F4\u63A5\u5B50\u7EA7"},"hover.hierarchy-all":{en:"Parents + all children",zh:"\u7236\u7EA7 + \u5168\u90E8\u5B50\u7EA7"},"hoverTarget.nodes":{en:"Nodes only",zh:"\u4EC5\u8282\u70B9"},"hoverTarget.links":{en:"Links only",zh:"\u4EC5\u94FE\u63A5"},"hoverTarget.both":{en:"Nodes + links",zh:"\u8282\u70B9 + \u94FE\u63A5"},"labels.auto":{en:"Auto",zh:"\u81EA\u52A8"},"labels.hover":{en:"Hover only",zh:"\u4EC5\u60AC\u505C"},"outside.grouped":{en:"Groups",zh:"\u5206\u7EC4"},"outside.selected":{en:"Selected",zh:"\u9009\u4E2D"},"outside.exact":{en:"Exact",zh:"\u7CBE\u786E"},"legend.root":{en:"Root",zh:"\u6839\u8282\u70B9"},"legend.root.desc":{en:"Current atlas root",zh:"\u5F53\u524D\u56FE\u8C31\u6839\u8282\u70B9"},"legend.folder":{en:"Folders",zh:"\u6587\u4EF6\u5939"},"legend.folder.desc":{en:"Folders without a same-name child note",zh:"\u6CA1\u6709\u540C\u540D\u5B50\u7B14\u8BB0\u7684\u6587\u4EF6\u5939"},"legend.folderMeta":{en:"Folder notes",zh:"\u6587\u4EF6\u5939\u7B14\u8BB0"},"legend.folderMeta.desc":{en:"Folder merged with its same-name child note",zh:"\u4E0E\u540C\u540D\u5B50\u7B14\u8BB0\u5408\u5E76\u7684\u6587\u4EF6\u5939"},"legend.note":{en:"Notes",zh:"\u7B14\u8BB0"},"legend.note.desc":{en:"Markdown notes",zh:"Markdown \u7B14\u8BB0"},"legend.outsideGroup":{en:"Outside groups",zh:"\u5916\u90E8\u5206\u7EC4"},"legend.outsideGroup.desc":{en:"Grouped branches outside the root",zh:"\u6839\u8282\u70B9\u5916\u7684\u5206\u7EC4\u5206\u652F"},"legend.outsideNote":{en:"Outside notes",zh:"\u5916\u90E8\u7B14\u8BB0"},"legend.outsideNote.desc":{en:"Exact linked notes outside the root",zh:"\u6839\u8282\u70B9\u5916\u7684\u7CBE\u786E\u94FE\u63A5\u7B14\u8BB0"},"legend.unresolvedNote":{en:"Unresolved notes",zh:"\u672A\u89E3\u6790\u7B14\u8BB0"},"legend.unresolvedNote.desc":{en:"Unresolved internal link targets",zh:"\u672A\u89E3\u6790\u7684\u5185\u90E8\u94FE\u63A5\u76EE\u6807"},"legend.hierarchy":{en:"Hierarchy",zh:"\u5C42\u7EA7"},"legend.hierarchy.desc":{en:"Parent-child hierarchy edges",zh:"\u7236\u5B50\u5C42\u7EA7\u8FB9"},"legend.noteLinks":{en:"Note links",zh:"\u7B14\u8BB0\u94FE\u63A5"},"legend.noteLinks.desc":{en:"Internal markdown links",zh:"\u5185\u90E8 Markdown \u94FE\u63A5"},"legend.outsideLinks":{en:"Outside links",zh:"\u5916\u90E8\u94FE\u63A5"},"legend.outsideLinks.desc":{en:"Links crossing the current root",zh:"\u8DE8\u51FA\u5F53\u524D\u6839\u8282\u70B9\u7684\u94FE\u63A5"},"legend.unresolvedLinks":{en:"Unresolved links",zh:"\u672A\u89E3\u6790\u94FE\u63A5"},"legend.unresolvedLinks.desc":{en:"Links involving unresolved targets",zh:"\u5305\u542B\u672A\u89E3\u6790\u76EE\u6807\u7684\u94FE\u63A5"},"loading.radial":{en:"Building map\u2026",zh:"\u6784\u5EFA\u5730\u56FE\u2026"},"loading.3d":{en:"Building map\u2026",zh:"\u6784\u5EFA\u5730\u56FE\u2026"},"context.openNote":{en:"Open note",zh:"\u6253\u5F00\u7B14\u8BB0"},"context.focusNote":{en:"Focus note",zh:"\u805A\u7126\u7B14\u8BB0"},"context.useAsRoot":{en:"Use as atlas root",zh:"\u8BBE\u4E3A\u56FE\u8C31\u6839\u8282\u70B9"},"context.openRepresentative":{en:"Open representative note",zh:"\u6253\u5F00\u4EE3\u8868\u7B14\u8BB0"},"context.pinPath":{en:"Pin highlighted path",zh:"\u56FA\u5B9A\u9AD8\u4EAE\u8DEF\u5F84"},"3d.cruiseOn":{en:"Cruise: on",zh:"\u5DE1\u822A\uFF1A\u5F00"},"3d.cruiseOff":{en:"Cruise: off",zh:"\u5DE1\u822A\uFF1A\u5173"},"3d.reveal":{en:"Reveal",zh:"\u521B\u4E16\u52A8\u753B"},"3d.glow":{en:"Glow",zh:"\u8F89\u5149"},"3d.glowStrength":{en:"Strength",zh:"\u5F3A\u5EA6"},"3d.glowRadius":{en:"Radius",zh:"\u6269\u6563"},"3d.glowThreshold":{en:"Threshold",zh:"\u9608\u503C"},"3d.repel":{en:"Repel",zh:"\u65A5\u529B"},"3d.linkDistance":{en:"Link distance",zh:"\u94FE\u63A5\u8DDD\u79BB"},"3d.linkStrength":{en:"Link strength",zh:"\u94FE\u63A5\u5F3A\u5EA6"},"3d.centerPull":{en:"Center pull",zh:"\u5411\u5FC3\u529B"},"3d.flatten":{en:"Flatten",zh:"\u6241\u5E73\u5EA6"},"3d.nodeSize":{en:"Node size",zh:"\u8282\u70B9\u5927\u5C0F"},"3d.linkOpacity":{en:"Link opacity",zh:"\u94FE\u63A5\u900F\u660E\u5EA6"},"3d.twinkle":{en:"Twinkle",zh:"\u661F\u661F\u7728\u773C"},"3d.twinkleOff":{en:"Off",zh:"\u5173"},"3d.size.degree":{en:"Size: links",zh:"\u5927\u5C0F\uFF1A\u94FE\u63A5\u6570"},"3d.size.fileSize":{en:"Size: file size",zh:"\u5927\u5C0F\uFF1A\u6587\u6863\u91CF"},"3d.size.uniform":{en:"Size: uniform",zh:"\u5927\u5C0F\uFF1A\u4E00\u81F4"},"3d.colorTheme":{en:"Color theme\u2026",zh:"\u914D\u8272\u4E3B\u9898\u2026"},"3d.importColors":{en:"Import 2D colors",zh:"\u5BFC\u5165\u4E8C\u7EF4\u914D\u8272"},"3d.shuffleColors":{en:"Shuffle colors",zh:"\u914D\u8272\u6D17\u724C"},"3d.speed":{en:"Speed",zh:"\u901F\u5EA6"},"3d.unresolvedShow":{en:"Unresolved: show",zh:"\u672A\u89E3\u6790\uFF1A\u663E\u793A"},"3d.unresolvedHide":{en:"Unresolved: hide",zh:"\u672A\u89E3\u6790\uFF1A\u9690\u85CF"},"3d.orphansShow":{en:"Orphans: show",zh:"\u5B64\u513F\uFF1A\u663E\u793A"},"3d.orphansHide":{en:"Orphans: hide",zh:"\u5B64\u513F\uFF1A\u9690\u85CF"},"3d.quality.auto":{en:"Quality: auto",zh:"\u753B\u8D28\uFF1A\u81EA\u52A8"},"3d.quality.high":{en:"Quality: high",zh:"\u753B\u8D28\uFF1A\u9AD8"},"3d.quality.low":{en:"Quality: low",zh:"\u753B\u8D28\uFF1A\u4F4E"},"3d.quality.mobile":{en:"Quality: mobile",zh:"\u753B\u8D28\uFF1A\u79FB\u52A8\u6A21\u62DF"},"3d.help.drag":{en:"Left drag = orbit \xB7 wheel = zoom",zh:"\u5DE6\u952E\u62D6 = \u73AF\u7ED5 \xB7 \u6EDA\u8F6E = \u7F29\u653E"},"3d.help.pan":{en:"Right drag / Cmd or Shift + left drag = pan",zh:"\u53F3\u952E\u62D6 / \u2318\u6216\u21E7+\u5DE6\u952E\u62D6 = \u5E73\u79FB"},"3d.help.mac":{en:"macOS treats Ctrl+click as right-click",zh:"macOS \u7684 Ctrl+\u70B9\u51FB\u4F1A\u88AB\u7CFB\u7EDF\u5F53\u53F3\u952E"},"3d.help.fly":{en:"WASD = fly \xB7 Q/E = rise/fall \xB7 Shift = fast",zh:"WASD = \u5E73\u98DE \xB7 Q/E = \u5347\u964D \xB7 Shift = \u52A0\u901F"},"3d.help.pick":{en:"Click node = select and fly \xB7 ESC = clear",zh:"\u70B9\u51FB\u8282\u70B9 = \u9009\u4E2D\u98DE\u884C \xB7 ESC = \u53D6\u6D88"},"3d.help.keys":{en:"F = fly to selected \xB7 R = overview",zh:"F = \u98DE\u5411\u9009\u4E2D \xB7 R = \u56DE\u603B\u89C8"},"3d.help.slider":{en:"Double-click a slider to reset it",zh:"\u53CC\u51FB\u6ED1\u6746 = \u56DE\u9ED8\u8BA4\u503C"},"3d.revealWait":{en:"The map is still settling. Try reveal after it settles.",zh:"\u661F\u7CFB\u8FD8\u5728\u6210\u5F62\u4E2D\uFF0C\u6C89\u964D\u540E\u518D\u8BD5\u3002"},"3d.workerFallback":{en:"Mini World Map 3D: background layout worker is unavailable; using the main thread.",zh:"Mini World Map 3D\uFF1A\u540E\u53F0\u7EBF\u7A0B\u4E0D\u53EF\u7528\uFF0C\u5DF2\u56DE\u9000\u4E3B\u7EBF\u7A0B\u5E03\u5C40\u3002"},"3d.mobileCap":{en:"Mobile quality: showing the top {cap} linked nodes out of {total}.",zh:"\u79FB\u52A8\u6863\uFF1A\u5DF2\u663E\u793A\u94FE\u63A5\u6700\u591A\u7684\u524D {cap} \u4E2A\u8282\u70B9\uFF08\u5171 {total}\uFF09\u3002"},"3d.performanceMode":{en:"Mini World Map 3D switched to performance mode. Change quality in Advanced.",zh:"Mini World Map 3D\uFF1A\u5DF2\u81EA\u52A8\u5207\u6362\u5230\u6027\u80FD\u6A21\u5F0F\uFF0C\u53EF\u5728\u9AD8\u7EA7\u9875\u6539\u56DE\u3002"},"3d.importMissing":{en:"No 2D graph color groups found in graph.json.",zh:"\u672A\u627E\u5230\u81EA\u5E26\u56FE\u8C31\u7684\u989C\u8272\u5206\u7EC4\uFF08graph.json\uFF09\u3002"},"3d.importDone":{en:"Imported {count} 2D color groups.",zh:"\u5DF2\u5BFC\u5165 {count} \u7EC4 2D \u56FE\u8C31\u914D\u8272\u3002"},"3d.shuffleMissing":{en:"Import 2D colors before shuffling.",zh:"\u5148\u5BFC\u5165\u4E8C\u7EF4\u56FE\u8C31\u914D\u8272\uFF0C\u624D\u80FD\u6D17\u724C\u3002"},"3d.contextLost":{en:"Rendering context lost. Click to rebuild.",zh:"\u6E32\u67D3\u4E0A\u4E0B\u6587\u4E22\u5931\uFF0C\u70B9\u51FB\u91CD\u5EFA\u3002"},"3d.searchPlaceholder":{en:"Search notes, press Enter to fly\u2026",zh:"\u641C\u7D22\u7B14\u8BB0\uFF0C\u56DE\u8F66\u98DE\u8FC7\u53BB\u2026"},"3d.searchUnresolved":{en:"Unresolved",zh:"\u672A\u89E3\u6790"},"3d.searchLinks":{en:"{count} links",zh:"{count} \u94FE\u63A5"},"3d.card.unresolved":{en:"Unresolved link (note does not exist)",zh:"\u672A\u89E3\u6790\u94FE\u63A5\uFF08\u7B14\u8BB0\u5C1A\u4E0D\u5B58\u5728\uFF09"},"3d.card.root":{en:"Vault root",zh:"\u6839\u76EE\u5F55"},"3d.card.stats":{en:"\u21A9 {in} backlinks \xB7 \u2192 {out} outgoing",zh:"\u21A9 {in} \u53CD\u94FE \xB7 \u2192 {out} \u51FA\u94FE"},"3d.card.modified":{en:" \xB7 modified {date}",zh:" \xB7 \u6539\u4E8E {date}"},"3d.card.empty":{en:"(empty note)",zh:"\uFF08\u7A7A\u7B14\u8BB0\uFF09"},"3d.bench.wait":{en:"{scenario}: waiting for layout to settle\u2026",zh:"{scenario}\uFF1A\u7B49\u5F85\u5E03\u5C40\u6C89\u964D\u2026"},"3d.bench.orbit":{en:"{scenario}: 20s orbit FPS run\u2026",zh:"{scenario}\uFF1A20s \u73AF\u7ED5\u6D4B\u5E27\u7387\u2026"},"3d.bench.done":{en:"{scenario} done: avg {fps} fps \xB7 {calls} calls",zh:"{scenario} \u5B8C\u6210\uFF1Aavg {fps} fps \xB7 {calls} calls"},"3d.bench.s2Start":{en:"S2: cold layout started. The interface should remain responsive.",zh:"S2\uFF1A\u51B7\u5E03\u5C40\u5F00\u59CB\uFF08\u9884\u7B97\u5316 tick\uFF0C\u671F\u95F4\u754C\u9762\u5E94\u4FDD\u6301\u53EF\u7528\uFF09\u2026"},"3d.bench.s2Done":{en:"S2 done: settled in {seconds}s / {ticks} ticks, longest block {longest}ms",zh:"S2 \u5B8C\u6210\uFF1A\u6C89\u964D {seconds}s / {ticks} ticks\uFF0C\u6700\u957F\u963B\u585E {longest}ms"},"style.galaxy":{en:"Galaxy",zh:"\u94F6\u6CB3"},"style.nebula":{en:"Nebula",zh:"\u661F\u4E91"},"style.minimal":{en:"Minimal",zh:"\u6781\u7B80"},"style.fireworks":{en:"Fireworks",zh:"\u70DF\u706B"},"color.hubble":{en:"Hubble deep field",zh:"\u54C8\u52C3\u6DF1\u7A7A"},"color.tiktok":{en:"Neon pop",zh:"\u6296\u97F3\u9713\u8679"},"color.sunset":{en:"Sunset film",zh:"\u843D\u65E5\u80F6\u7247"},"color.cyber":{en:"Cyber city",zh:"\u8D5B\u535A\u90FD\u5E02"},"color.matrix":{en:"Matrix",zh:"\u9ED1\u5BA2\u5E1D\u56FD"},"color.aurora":{en:"Aurora",zh:"\u6781\u5149"},"settings.title":{en:"Mini World Map",zh:"Mini World Map"},"settings.defaultMode":{en:"Default render mode",zh:"\u9ED8\u8BA4\u6E32\u67D3\u6A21\u5F0F"},"settings.defaultModeDesc":{en:"2D radial rings is the hierarchy-first map. 3D map uses the Galaxy renderer.",zh:"2D \u73AF\u5F62\u56FE\u4EE5\u5C42\u7EA7\u4E3A\u4E3B\uFF1B3D \u5730\u56FE\u4F7F\u7528 Galaxy \u6E32\u67D3\u5668\u3002"},"settings.languageDesc":{en:"Language used by both 2D and 3D panels.",zh:"2D \u4E0E 3D \u9762\u677F\u5171\u540C\u4F7F\u7528\u7684\u8BED\u8A00\u3002"},"settings.depthDesc":{en:"How many hierarchy levels to render before deeper nodes are summarized by budgets.",zh:"\u6E32\u67D3\u591A\u5C11\u5C42\u7EA7\u540E\u7531\u9884\u7B97\u6C47\u603B\u66F4\u6DF1\u8282\u70B9\u3002"},"settings.nodeLimitDesc":{en:"Maximum visible nodes in the 2D radial map.",zh:"2D \u73AF\u5F62\u56FE\u6700\u591A\u663E\u793A\u7684\u8282\u70B9\u6570\u3002"},"settings.linkLimitDesc":{en:"Maximum aggregated note links to draw in 2D.",zh:"2D \u4E2D\u6700\u591A\u7ED8\u5236\u7684\u805A\u5408\u7B14\u8BB0\u94FE\u63A5\u6570\u3002"},"settings.showLinksDesc":{en:"Keeps note-link roads visible. Hover/link pinning still works when this is off.",zh:"\u4FDD\u6301\u7B14\u8BB0\u94FE\u63A5\u53EF\u89C1\uFF1B\u5173\u95ED\u540E\u60AC\u505C\u4E0E\u94FE\u63A5\u56FA\u5B9A\u4ECD\u53EF\u7528\u3002"},"settings.hoverDesc":{en:"Choose what 2D hover highlights.",zh:"\u9009\u62E9 2D \u60AC\u505C\u9AD8\u4EAE\u7684\u5185\u5BB9\u3002"},"settings.hoverTargetsDesc":{en:"Choose whether nodes, note-link roads, or both react to hover and click.",zh:"\u9009\u62E9\u8282\u70B9\u3001\u7B14\u8BB0\u94FE\u63A5\u9053\u8DEF\u6216\u4E24\u8005\u662F\u5426\u54CD\u5E94\u60AC\u505C\u548C\u70B9\u51FB\u3002"},"settings.labelsDesc":{en:"Auto shows important names by zoom; hover only keeps the map quieter.",zh:"\u81EA\u52A8\u6309\u7F29\u653E\u663E\u793A\u91CD\u8981\u540D\u79F0\uFF1B\u4EC5\u60AC\u505C\u4F1A\u66F4\u5B89\u9759\u3002"},"settings.spinDesc":{en:"Optional radial ring motion in the 2D map.",zh:"2D \u73AF\u5F62\u56FE\u4E2D\u7684\u53EF\u9009\u73AF\u5F62\u8FD0\u52A8\u3002"},"settings.unresolvedDesc":{en:"Represent unresolved internal links as temporary nodes.",zh:"\u5C06\u672A\u89E3\u6790\u5185\u90E8\u94FE\u63A5\u663E\u793A\u4E3A\u4E34\u65F6\u8282\u70B9\u3002"},"settings.ignoredDesc":{en:"One folder path per line.",zh:"\u6BCF\u884C\u4E00\u4E2A\u6587\u4EF6\u5939\u8DEF\u5F84\u3002"},"notice.rebuilt":{en:"Mini World Map rebuilt",zh:"Mini World Map \u5DF2\u91CD\u5EFA"},"notice.openToBuild":{en:"Open Mini World Map to build the index",zh:"\u6253\u5F00 Mini World Map \u540E\u624D\u80FD\u6784\u5EFA\u7D22\u5F15"},"notice.switchTo3d":{en:"Switch to 3D map to use fly-to search.",zh:"\u5207\u6362\u5230 3D \u5730\u56FE\u540E\u53EF\u4F7F\u7528\u98DE\u884C\u641C\u7D22\u3002"}};function Rt(i,t,e={}){return(vu[t]?.[i]??vu[t]?.en??t).replace(/\{(\w+)\}/g,(s,r)=>String(e[r]??`{${r}}`))}function pi(i,t){return Rt(i,`mode.${t}`)}function _u(i){return[["auto",Rt(i,"theme.radialAuto")],["day",Rt(i,"theme.day")],["night",Rt(i,"theme.night")]]}function as(i){return wm.map(([t])=>[t,Rt(i,`language.${t}`)])}function io(i,t){return t.map(([e])=>[e,Rt(i,`hover.${e}`)])}function so(i,t){return t.map(([e])=>[e,Rt(i,`hoverTarget.${e}`)])}function ro(i,t){return t.map(([e])=>[e,Rt(i,`labels.${e}`)])}function yu(i){return[["grouped",Rt(i,"outside.grouped")],["selected",Rt(i,"outside.selected")],["exact",Rt(i,"outside.exact")]]}var tc=require("obsidian");var _e=require("obsidian");var pa="184",Cn={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Ii={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},qu=0,Gc=1,Yu=2;var xr=1,Zu=2,Cs=3,ei=0,$e=1,Vn=2,yn=0,Yi=1,vr=2,Vc=3,Hc=4,$u=5;var Mi=100,Ku=101,Ju=102,ju=103,Qu=104,td=200,ed=201,nd=202,id=203,Lo=204,Do=205,sd=206,rd=207,od=208,ad=209,ld=210,cd=211,hd=212,ud=213,dd=214,No=0,Fo=1,ko=2,Zi=3,Oo=4,Uo=5,Bo=6,zo=7,Wc=0,fd=1,pd=2,dn=0,_r=1,yr=2,br=3,Li=4,Mr=5,Sr=6,wr=7;var Xc=300,Di=301,Ki=302,ma=303,ga=304,Er=306,Go=1e3,Un=1001,Vo=1002,De=1003,md=1004;var Tr=1005;var Ue=1006,xa=1007;var Ni=1008;var fn=1009,qc=1010,Yc=1011,Rs=1012,va=1013,Rn=1014,Pn=1015,qe=1016,_a=1017,ya=1018,Ps=1020,Zc=35902,$c=35899,Kc=1021,Jc=1022,bn=1023,Bn=1026,Fi=1027,jc=1028,ba=1029,ki=1030,Ma=1031;var Sa=1033,Ar=33776,Cr=33777,Rr=33778,Pr=33779,wa=35840,Ea=35841,Ta=35842,Aa=35843,Ca=36196,Ra=37492,Pa=37496,Ia=37488,La=37489,Ir=37490,Da=37491,Na=37808,Fa=37809,ka=37810,Oa=37811,Ua=37812,Ba=37813,za=37814,Ga=37815,Va=37816,Ha=37817,Wa=37818,Xa=37819,qa=37820,Ya=37821,Za=36492,$a=36494,Ka=36495,Ja=36283,ja=36284,Lr=36285,Qa=36286;var tr=2300,Ho=2301,Io=2302,Lc=2303,Dc=2400,Nc=2401,Fc=2402;var gd=3200;var Qc=0,xd=1,ai="",ln="srgb",er="srgb-linear",nr="linear",Jt="srgb";var qi=7680;var kc=519,vd=512,_d=513,yd=514,tl=515,bd=516,Md=517,el=518,Sd=519,Oc=35044;var th="300 es",Tn=2e3,ir=2001;function Em(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function Tm(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function sr(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function wd(){let i=sr("canvas");return i.style.display="block",i}var bu={},Ms=null;function eh(...i){let t="THREE."+i.shift();Ms?Ms("log",t,...i):console.log(t,...i)}function Ed(i){let t=i[0];if(typeof t=="string"&&t.startsWith("TSL:")){let e=i[1];e&&e.isStackTrace?i[0]+=" "+e.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function At(...i){i=Ed(i);let t="THREE."+i.shift();if(Ms)Ms("warn",t,...i);else{let e=i[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...i)}}function Pt(...i){i=Ed(i);let t="THREE."+i.shift();if(Ms)Ms("error",t,...i);else{let e=i[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...i)}}function Wo(...i){let t=i.join(" ");t in bu||(bu[t]=!0,At(...i))}function Td(i,t,e){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(t,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,e);break;default:n()}}setTimeout(r,e)})}var Ad={[No]:Fo,[ko]:Bo,[Oo]:zo,[Zi]:Uo,[Fo]:No,[Bo]:ko,[zo]:Oo,[Uo]:Zi},An=class{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){let n=this._listeners;return n===void 0?!1:n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){let n=this._listeners;if(n===void 0)return;let s=n[t];if(s!==void 0){let r=s.indexOf(e);r!==-1&&s.splice(r,1)}}dispatchEvent(t){let e=this._listeners;if(e===void 0)return;let n=e[t.type];if(n!==void 0){t.target=this;let s=n.slice(0);for(let r=0,o=s.length;r<o;r++)s[r].call(this,t);t.target=null}}},Ve=["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"],Mu=1234567,js=Math.PI/180,Ss=180/Math.PI;function Is(){let i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Ve[i&255]+Ve[i>>8&255]+Ve[i>>16&255]+Ve[i>>24&255]+"-"+Ve[t&255]+Ve[t>>8&255]+"-"+Ve[t>>16&15|64]+Ve[t>>24&255]+"-"+Ve[e&63|128]+Ve[e>>8&255]+"-"+Ve[e>>16&255]+Ve[e>>24&255]+Ve[n&255]+Ve[n>>8&255]+Ve[n>>16&255]+Ve[n>>24&255]).toLowerCase()}function Ht(i,t,e){return Math.max(t,Math.min(e,i))}function nh(i,t){return(i%t+t)%t}function Am(i,t,e,n,s){return n+(i-t)*(s-n)/(e-t)}function Cm(i,t,e){return i!==t?(e-i)/(t-i):0}function Qs(i,t,e){return(1-e)*i+e*t}function Rm(i,t,e,n){return Qs(i,t,1-Math.exp(-e*n))}function Pm(i,t=1){return t-Math.abs(nh(i,t*2)-t)}function Im(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function Lm(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function Dm(i,t){return i+Math.floor(Math.random()*(t-i+1))}function Nm(i,t){return i+Math.random()*(t-i)}function Fm(i){return i*(.5-Math.random())}function km(i){i!==void 0&&(Mu=i);let t=Mu+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Om(i){return i*js}function Um(i){return i*Ss}function Bm(i){return(i&i-1)===0&&i!==0}function zm(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Gm(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Vm(i,t,e,n,s){let r=Math.cos,o=Math.sin,a=r(e/2),l=o(e/2),c=r((t+n)/2),u=o((t+n)/2),d=r((t-n)/2),h=o((t-n)/2),f=r((n-t)/2),m=o((n-t)/2);switch(s){case"XYX":i.set(a*u,l*d,l*h,a*c);break;case"YZY":i.set(l*h,a*u,l*d,a*c);break;case"ZXZ":i.set(l*d,l*h,a*u,a*c);break;case"XZX":i.set(a*u,l*m,l*f,a*c);break;case"YXY":i.set(l*f,a*u,l*m,a*c);break;case"ZYZ":i.set(l*m,l*f,a*u,a*c);break;default:At("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function ys(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function Ze(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}var ih={DEG2RAD:js,RAD2DEG:Ss,generateUUID:Is,clamp:Ht,euclideanModulo:nh,mapLinear:Am,inverseLerp:Cm,lerp:Qs,damp:Rm,pingpong:Pm,smoothstep:Im,smootherstep:Lm,randInt:Dm,randFloat:Nm,randFloatSpread:Fm,seededRandom:km,degToRad:Om,radToDeg:Um,isPowerOfTwo:Bm,ceilPowerOfTwo:zm,floorPowerOfTwo:Gm,setQuaternionFromProperEuler:Vm,normalize:Ze,denormalize:ys},lh=class lh{constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,n=this.y,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6],this.y=s[1]*e+s[4]*n+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Ht(this.x,t.x,e.x),this.y=Ht(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Ht(this.x,t,e),this.y=Ht(this.y,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ht(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(Ht(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let n=Math.cos(e),s=Math.sin(e),r=this.x-t.x,o=this.y-t.y;return this.x=r*n-o*s+t.x,this.y=r*s+o*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};lh.prototype.isVector2=!0;var Tt=lh,cn=class{constructor(t=0,e=0,n=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=s}static slerpFlat(t,e,n,s,r,o,a){let l=n[s+0],c=n[s+1],u=n[s+2],d=n[s+3],h=r[o+0],f=r[o+1],m=r[o+2],x=r[o+3];if(d!==x||l!==h||c!==f||u!==m){let g=l*h+c*f+u*m+d*x;g<0&&(h=-h,f=-f,m=-m,x=-x,g=-g);let p=1-a;if(g<.9995){let v=Math.acos(g),M=Math.sin(v);p=Math.sin(p*v)/M,a=Math.sin(a*v)/M,l=l*p+h*a,c=c*p+f*a,u=u*p+m*a,d=d*p+x*a}else{l=l*p+h*a,c=c*p+f*a,u=u*p+m*a,d=d*p+x*a;let v=1/Math.sqrt(l*l+c*c+u*u+d*d);l*=v,c*=v,u*=v,d*=v}}t[e]=l,t[e+1]=c,t[e+2]=u,t[e+3]=d}static multiplyQuaternionsFlat(t,e,n,s,r,o){let a=n[s],l=n[s+1],c=n[s+2],u=n[s+3],d=r[o],h=r[o+1],f=r[o+2],m=r[o+3];return t[e]=a*m+u*d+l*f-c*h,t[e+1]=l*m+u*h+c*d-a*f,t[e+2]=c*m+u*f+a*h-l*d,t[e+3]=u*m-a*d-l*h-c*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,s){return this._x=t,this._y=e,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){let n=t._x,s=t._y,r=t._z,o=t._order,a=Math.cos,l=Math.sin,c=a(n/2),u=a(s/2),d=a(r/2),h=l(n/2),f=l(s/2),m=l(r/2);switch(o){case"XYZ":this._x=h*u*d+c*f*m,this._y=c*f*d-h*u*m,this._z=c*u*m+h*f*d,this._w=c*u*d-h*f*m;break;case"YXZ":this._x=h*u*d+c*f*m,this._y=c*f*d-h*u*m,this._z=c*u*m-h*f*d,this._w=c*u*d+h*f*m;break;case"ZXY":this._x=h*u*d-c*f*m,this._y=c*f*d+h*u*m,this._z=c*u*m+h*f*d,this._w=c*u*d-h*f*m;break;case"ZYX":this._x=h*u*d-c*f*m,this._y=c*f*d+h*u*m,this._z=c*u*m-h*f*d,this._w=c*u*d+h*f*m;break;case"YZX":this._x=h*u*d+c*f*m,this._y=c*f*d+h*u*m,this._z=c*u*m-h*f*d,this._w=c*u*d-h*f*m;break;case"XZY":this._x=h*u*d-c*f*m,this._y=c*f*d-h*u*m,this._z=c*u*m+h*f*d,this._w=c*u*d+h*f*m;break;default:At("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let n=e/2,s=Math.sin(n);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,n=e[0],s=e[4],r=e[8],o=e[1],a=e[5],l=e[9],c=e[2],u=e[6],d=e[10],h=n+a+d;if(h>0){let f=.5/Math.sqrt(h+1);this._w=.25/f,this._x=(u-l)*f,this._y=(r-c)*f,this._z=(o-s)*f}else if(n>a&&n>d){let f=2*Math.sqrt(1+n-a-d);this._w=(u-l)/f,this._x=.25*f,this._y=(s+o)/f,this._z=(r+c)/f}else if(a>d){let f=2*Math.sqrt(1+a-n-d);this._w=(r-c)/f,this._x=(s+o)/f,this._y=.25*f,this._z=(l+u)/f}else{let f=2*Math.sqrt(1+d-n-a);this._w=(o-s)/f,this._x=(r+c)/f,this._y=(l+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Ht(this.dot(t),-1,1)))}rotateTowards(t,e){let n=this.angleTo(t);if(n===0)return this;let s=Math.min(1,e/n);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){let n=t._x,s=t._y,r=t._z,o=t._w,a=e._x,l=e._y,c=e._z,u=e._w;return this._x=n*u+o*a+s*c-r*l,this._y=s*u+o*l+r*a-n*c,this._z=r*u+o*c+n*l-s*a,this._w=o*u-n*a-s*l-r*c,this._onChangeCallback(),this}slerp(t,e){let n=t._x,s=t._y,r=t._z,o=t._w,a=this.dot(t);a<0&&(n=-n,s=-s,r=-r,o=-o,a=-a);let l=1-e;if(a<.9995){let c=Math.acos(a),u=Math.sin(c);l=Math.sin(l*c)/u,e=Math.sin(e*c)/u,this._x=this._x*l+n*e,this._y=this._y*l+s*e,this._z=this._z*l+r*e,this._w=this._w*l+o*e,this._onChangeCallback()}else this._x=this._x*l+n*e,this._y=this._y*l+s*e,this._z=this._z*l+r*e,this._w=this._w*l+o*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){let t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(t),s*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},ch=class ch{constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Su.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Su.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*s,this.y=r[1]*e+r[4]*n+r[7]*s,this.z=r[2]*e+r[5]*n+r[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,n=this.y,s=this.z,r=t.elements,o=1/(r[3]*e+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*s+r[12])*o,this.y=(r[1]*e+r[5]*n+r[9]*s+r[13])*o,this.z=(r[2]*e+r[6]*n+r[10]*s+r[14])*o,this}applyQuaternion(t){let e=this.x,n=this.y,s=this.z,r=t.x,o=t.y,a=t.z,l=t.w,c=2*(o*s-a*n),u=2*(a*e-r*s),d=2*(r*n-o*e);return this.x=e+l*c+o*d-a*u,this.y=n+l*u+a*c-r*d,this.z=s+l*d+r*u-o*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*s,this.y=r[1]*e+r[5]*n+r[9]*s,this.z=r[2]*e+r[6]*n+r[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Ht(this.x,t.x,e.x),this.y=Ht(this.y,t.y,e.y),this.z=Ht(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Ht(this.x,t,e),this.y=Ht(this.y,t,e),this.z=Ht(this.z,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ht(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let n=t.x,s=t.y,r=t.z,o=e.x,a=e.y,l=e.z;return this.x=s*l-r*a,this.y=r*o-n*l,this.z=n*a-s*o,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return hc.copy(this).projectOnVector(t),this.sub(hc)}reflect(t){return this.sub(hc.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(Ht(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y,s=this.z-t.z;return e*e+n*n+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){let s=Math.sin(e)*t;return this.x=s*Math.sin(n),this.y=Math.cos(e)*t,this.z=s*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};ch.prototype.isVector3=!0;var L=ch,hc=new L,Su=new cn,hh=class hh{constructor(t,e,n,s,r,o,a,l,c){this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,o,a,l,c)}set(t,e,n,s,r,o,a,l,c){let u=this.elements;return u[0]=t,u[1]=s,u[2]=a,u[3]=e,u[4]=r,u[5]=l,u[6]=n,u[7]=o,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,s=e.elements,r=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],u=n[4],d=n[7],h=n[2],f=n[5],m=n[8],x=s[0],g=s[3],p=s[6],v=s[1],M=s[4],b=s[7],E=s[2],w=s[5],C=s[8];return r[0]=o*x+a*v+l*E,r[3]=o*g+a*M+l*w,r[6]=o*p+a*b+l*C,r[1]=c*x+u*v+d*E,r[4]=c*g+u*M+d*w,r[7]=c*p+u*b+d*C,r[2]=h*x+f*v+m*E,r[5]=h*g+f*M+m*w,r[8]=h*p+f*b+m*C,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8];return e*o*u-e*a*c-n*r*u+n*a*l+s*r*c-s*o*l}invert(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8],d=u*o-a*c,h=a*l-u*r,f=c*r-o*l,m=e*d+n*h+s*f;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);let x=1/m;return t[0]=d*x,t[1]=(s*c-u*n)*x,t[2]=(a*n-s*o)*x,t[3]=h*x,t[4]=(u*e-s*l)*x,t[5]=(s*r-a*e)*x,t[6]=f*x,t[7]=(n*l-c*e)*x,t[8]=(o*e-n*r)*x,this}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,s,r,o,a){let l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*o+c*a)+o+t,-s*c,s*l,-s*(-c*o+l*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(uc.makeScale(t,e)),this}rotate(t){return this.premultiply(uc.makeRotation(-t)),this}translate(t,e){return this.premultiply(uc.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,n=t.elements;for(let s=0;s<9;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}};hh.prototype.isMatrix3=!0;var Dt=hh,uc=new Dt,wu=new Dt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Eu=new Dt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Hm(){let i={enabled:!0,workingColorSpace:er,spaces:{},convert:function(s,r,o){return this.enabled===!1||r===o||!r||!o||(this.spaces[r].transfer===Jt&&(s.r=ti(s.r),s.g=ti(s.g),s.b=ti(s.b)),this.spaces[r].primaries!==this.spaces[o].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===Jt&&(s.r=bs(s.r),s.g=bs(s.g),s.b=bs(s.b))),s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===ai?nr:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,o){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return Wo("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Wo("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(s,r)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[er]:{primaries:t,whitePoint:n,transfer:nr,toXYZ:wu,fromXYZ:Eu,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:ln},outputColorSpaceConfig:{drawingBufferColorSpace:ln}},[ln]:{primaries:t,whitePoint:n,transfer:Jt,toXYZ:wu,fromXYZ:Eu,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:ln}}}),i}var Vt=Hm();function ti(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function bs(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var ls,Xo=class{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{ls===void 0&&(ls=sr("canvas")),ls.width=t.width,ls.height=t.height;let s=ls.getContext("2d");t instanceof ImageData?s.putImageData(t,0,0):s.drawImage(t,0,0,t.width,t.height),n=ls}return n.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){let e=sr("canvas");e.width=t.width,e.height=t.height;let n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);let s=n.getImageData(0,0,t.width,t.height),r=s.data;for(let o=0;o<r.length;o++)r[o]=ti(r[o]/255)*255;return n.putImageData(s,0,0),e}else if(t.data){let e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(ti(e[n]/255)*255):e[n]=ti(e[n]);return{data:e,width:t.width,height:t.height}}else return At("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}},Wm=0,ws=class{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Wm++}),this.uuid=Is(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){let e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):typeof VideoFrame<"u"&&e instanceof VideoFrame?t.set(e.displayWidth,e.displayHeight,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];let n={uuid:this.uuid,url:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let o=0,a=s.length;o<a;o++)s[o].isDataTexture?r.push(dc(s[o].image)):r.push(dc(s[o]))}else r=dc(s);n.url=r}return e||(t.images[this.uuid]=n),n}};function dc(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?Xo.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(At("Texture: Unable to serialize Texture."),{})}var Xm=0,fc=new L,je=class i extends An{constructor(t=i.DEFAULT_IMAGE,e=i.DEFAULT_MAPPING,n=Un,s=Un,r=Ue,o=Ni,a=bn,l=fn,c=i.DEFAULT_ANISOTROPY,u=ai){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Xm++}),this.uuid=Is(),this.name="",this.source=new ws(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new Tt(0,0),this.repeat=new Tt(1,1),this.center=new Tt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Dt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(fc).x}get height(){return this.source.getSize(fc).y}get depth(){return this.source.getSize(fc).z}get image(){return this.source.data}set image(t){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.normalized=t.normalized,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(let e in t){let n=t[e];if(n===void 0){At(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}let s=this[e];if(s===void 0){At(`Texture.setValues(): property '${e}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Xc)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Go:t.x=t.x-Math.floor(t.x);break;case Un:t.x=t.x<0?0:1;break;case Vo:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Go:t.y=t.y-Math.floor(t.y);break;case Un:t.y=t.y<0?0:1;break;case Vo:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}};je.DEFAULT_IMAGE=null;je.DEFAULT_MAPPING=Xc;je.DEFAULT_ANISOTROPY=1;var uh=class uh{constructor(t=0,e=0,n=0,s=1){this.x=t,this.y=e,this.z=n,this.w=s}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,s){return this.x=t,this.y=e,this.z=n,this.w=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,n=this.y,s=this.z,r=this.w,o=t.elements;return this.x=o[0]*e+o[4]*n+o[8]*s+o[12]*r,this.y=o[1]*e+o[5]*n+o[9]*s+o[13]*r,this.z=o[2]*e+o[6]*n+o[10]*s+o[14]*r,this.w=o[3]*e+o[7]*n+o[11]*s+o[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,s,r,l=t.elements,c=l[0],u=l[4],d=l[8],h=l[1],f=l[5],m=l[9],x=l[2],g=l[6],p=l[10];if(Math.abs(u-h)<.01&&Math.abs(d-x)<.01&&Math.abs(m-g)<.01){if(Math.abs(u+h)<.1&&Math.abs(d+x)<.1&&Math.abs(m+g)<.1&&Math.abs(c+f+p-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let M=(c+1)/2,b=(f+1)/2,E=(p+1)/2,w=(u+h)/4,C=(d+x)/4,_=(m+g)/4;return M>b&&M>E?M<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(M),s=w/n,r=C/n):b>E?b<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(b),n=w/s,r=_/s):E<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(E),n=C/r,s=_/r),this.set(n,s,r,e),this}let v=Math.sqrt((g-m)*(g-m)+(d-x)*(d-x)+(h-u)*(h-u));return Math.abs(v)<.001&&(v=1),this.x=(g-m)/v,this.y=(d-x)/v,this.z=(h-u)/v,this.w=Math.acos((c+f+p-1)/2),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Ht(this.x,t.x,e.x),this.y=Ht(this.y,t.y,e.y),this.z=Ht(this.z,t.z,e.z),this.w=Ht(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Ht(this.x,t,e),this.y=Ht(this.y,t,e),this.z=Ht(this.z,t,e),this.w=Ht(this.w,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ht(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};uh.prototype.isVector4=!0;var xe=uh,qo=class extends An{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ue,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=n.depth,this.scissor=new xe(0,0,t,e),this.scissorTest=!1,this.viewport=new xe(0,0,t,e),this.textures=[];let s={width:t,height:e,depth:n.depth},r=new je(s),o=n.count;for(let a=0;a<o;a++)this.textures[a]=r.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(t={}){let e={minFilter:Ue,generateMipmaps:!1,flipY:!1,internalFormat:null};t.mapping!==void 0&&(e.mapping=t.mapping),t.wrapS!==void 0&&(e.wrapS=t.wrapS),t.wrapT!==void 0&&(e.wrapT=t.wrapT),t.wrapR!==void 0&&(e.wrapR=t.wrapR),t.magFilter!==void 0&&(e.magFilter=t.magFilter),t.minFilter!==void 0&&(e.minFilter=t.minFilter),t.format!==void 0&&(e.format=t.format),t.type!==void 0&&(e.type=t.type),t.anisotropy!==void 0&&(e.anisotropy=t.anisotropy),t.colorSpace!==void 0&&(e.colorSpace=t.colorSpace),t.flipY!==void 0&&(e.flipY=t.flipY),t.generateMipmaps!==void 0&&(e.generateMipmaps=t.generateMipmaps),t.internalFormat!==void 0&&(e.internalFormat=t.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(e)}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),t!==null&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=t,this.textures[s].image.height=e,this.textures[s].image.depth=n,this.textures[s].isData3DTexture!==!0&&(this.textures[s].isArrayTexture=this.textures[s].image.depth>1);this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,n=t.textures.length;e<n;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;let s=Object.assign({},t.textures[e].image);this.textures[e].source=new ws(s)}return this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this.multiview=t.multiview,this}dispose(){this.dispatchEvent({type:"dispose"})}},Ce=class extends qo{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}},rr=class extends je{constructor(t=null,e=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=De,this.minFilter=De,this.wrapR=Un,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}};var Yo=class extends je{constructor(t=null,e=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=De,this.minFilter=De,this.wrapR=Un,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var fa=class fa{constructor(t,e,n,s,r,o,a,l,c,u,d,h,f,m,x,g){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,o,a,l,c,u,d,h,f,m,x,g)}set(t,e,n,s,r,o,a,l,c,u,d,h,f,m,x,g){let p=this.elements;return p[0]=t,p[4]=e,p[8]=n,p[12]=s,p[1]=r,p[5]=o,p[9]=a,p[13]=l,p[2]=c,p[6]=u,p[10]=d,p[14]=h,p[3]=f,p[7]=m,p[11]=x,p[15]=g,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 fa().fromArray(this.elements)}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){let e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){let e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return this.determinant()===0?(t.set(1,0,0),e.set(0,1,0),n.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){if(t.determinant()===0)return this.identity();let e=this.elements,n=t.elements,s=1/cs.setFromMatrixColumn(t,0).length(),r=1/cs.setFromMatrixColumn(t,1).length(),o=1/cs.setFromMatrixColumn(t,2).length();return e[0]=n[0]*s,e[1]=n[1]*s,e[2]=n[2]*s,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*o,e[9]=n[9]*o,e[10]=n[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,n=t.x,s=t.y,r=t.z,o=Math.cos(n),a=Math.sin(n),l=Math.cos(s),c=Math.sin(s),u=Math.cos(r),d=Math.sin(r);if(t.order==="XYZ"){let h=o*u,f=o*d,m=a*u,x=a*d;e[0]=l*u,e[4]=-l*d,e[8]=c,e[1]=f+m*c,e[5]=h-x*c,e[9]=-a*l,e[2]=x-h*c,e[6]=m+f*c,e[10]=o*l}else if(t.order==="YXZ"){let h=l*u,f=l*d,m=c*u,x=c*d;e[0]=h+x*a,e[4]=m*a-f,e[8]=o*c,e[1]=o*d,e[5]=o*u,e[9]=-a,e[2]=f*a-m,e[6]=x+h*a,e[10]=o*l}else if(t.order==="ZXY"){let h=l*u,f=l*d,m=c*u,x=c*d;e[0]=h-x*a,e[4]=-o*d,e[8]=m+f*a,e[1]=f+m*a,e[5]=o*u,e[9]=x-h*a,e[2]=-o*c,e[6]=a,e[10]=o*l}else if(t.order==="ZYX"){let h=o*u,f=o*d,m=a*u,x=a*d;e[0]=l*u,e[4]=m*c-f,e[8]=h*c+x,e[1]=l*d,e[5]=x*c+h,e[9]=f*c-m,e[2]=-c,e[6]=a*l,e[10]=o*l}else if(t.order==="YZX"){let h=o*l,f=o*c,m=a*l,x=a*c;e[0]=l*u,e[4]=x-h*d,e[8]=m*d+f,e[1]=d,e[5]=o*u,e[9]=-a*u,e[2]=-c*u,e[6]=f*d+m,e[10]=h-x*d}else if(t.order==="XZY"){let h=o*l,f=o*c,m=a*l,x=a*c;e[0]=l*u,e[4]=-d,e[8]=c*u,e[1]=h*d+x,e[5]=o*u,e[9]=f*d-m,e[2]=m*d-f,e[6]=a*u,e[10]=x*d+h}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(qm,t,Ym)}lookAt(t,e,n){let s=this.elements;return on.subVectors(t,e),on.lengthSq()===0&&(on.z=1),on.normalize(),mi.crossVectors(n,on),mi.lengthSq()===0&&(Math.abs(n.z)===1?on.x+=1e-4:on.z+=1e-4,on.normalize(),mi.crossVectors(n,on)),mi.normalize(),oo.crossVectors(on,mi),s[0]=mi.x,s[4]=oo.x,s[8]=on.x,s[1]=mi.y,s[5]=oo.y,s[9]=on.y,s[2]=mi.z,s[6]=oo.z,s[10]=on.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,s=e.elements,r=this.elements,o=n[0],a=n[4],l=n[8],c=n[12],u=n[1],d=n[5],h=n[9],f=n[13],m=n[2],x=n[6],g=n[10],p=n[14],v=n[3],M=n[7],b=n[11],E=n[15],w=s[0],C=s[4],_=s[8],A=s[12],P=s[1],R=s[5],D=s[9],W=s[13],H=s[2],k=s[6],B=s[10],U=s[14],j=s[3],Q=s[7],ct=s[11],_t=s[15];return r[0]=o*w+a*P+l*H+c*j,r[4]=o*C+a*R+l*k+c*Q,r[8]=o*_+a*D+l*B+c*ct,r[12]=o*A+a*W+l*U+c*_t,r[1]=u*w+d*P+h*H+f*j,r[5]=u*C+d*R+h*k+f*Q,r[9]=u*_+d*D+h*B+f*ct,r[13]=u*A+d*W+h*U+f*_t,r[2]=m*w+x*P+g*H+p*j,r[6]=m*C+x*R+g*k+p*Q,r[10]=m*_+x*D+g*B+p*ct,r[14]=m*A+x*W+g*U+p*_t,r[3]=v*w+M*P+b*H+E*j,r[7]=v*C+M*R+b*k+E*Q,r[11]=v*_+M*D+b*B+E*ct,r[15]=v*A+M*W+b*U+E*_t,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[4],s=t[8],r=t[12],o=t[1],a=t[5],l=t[9],c=t[13],u=t[2],d=t[6],h=t[10],f=t[14],m=t[3],x=t[7],g=t[11],p=t[15],v=l*f-c*h,M=a*f-c*d,b=a*h-l*d,E=o*f-c*u,w=o*h-l*u,C=o*d-a*u;return e*(x*v-g*M+p*b)-n*(m*v-g*E+p*w)+s*(m*M-x*E+p*C)-r*(m*b-x*w+g*C)}transpose(){let t=this.elements,e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){let s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=n),this}invert(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8],d=t[9],h=t[10],f=t[11],m=t[12],x=t[13],g=t[14],p=t[15],v=e*a-n*o,M=e*l-s*o,b=e*c-r*o,E=n*l-s*a,w=n*c-r*a,C=s*c-r*l,_=u*x-d*m,A=u*g-h*m,P=u*p-f*m,R=d*g-h*x,D=d*p-f*x,W=h*p-f*g,H=v*W-M*D+b*R+E*P-w*A+C*_;if(H===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let k=1/H;return t[0]=(a*W-l*D+c*R)*k,t[1]=(s*D-n*W-r*R)*k,t[2]=(x*C-g*w+p*E)*k,t[3]=(h*w-d*C-f*E)*k,t[4]=(l*P-o*W-c*A)*k,t[5]=(e*W-s*P+r*A)*k,t[6]=(g*b-m*C-p*M)*k,t[7]=(u*C-h*b+f*M)*k,t[8]=(o*D-a*P+c*_)*k,t[9]=(n*P-e*D-r*_)*k,t[10]=(m*w-x*b+p*v)*k,t[11]=(d*b-u*w-f*v)*k,t[12]=(a*A-o*R-l*_)*k,t[13]=(e*R-n*A+s*_)*k,t[14]=(x*M-m*E-g*v)*k,t[15]=(u*E-d*M+h*v)*k,this}scale(t){let e=this.elements,n=t.x,s=t.y,r=t.z;return e[0]*=n,e[4]*=s,e[8]*=r,e[1]*=n,e[5]*=s,e[9]*=r,e[2]*=n,e[6]*=s,e[10]*=r,e[3]*=n,e[7]*=s,e[11]*=r,this}getMaxScaleOnAxis(){let t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,s))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){let e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let n=Math.cos(e),s=Math.sin(e),r=1-n,o=t.x,a=t.y,l=t.z,c=r*o,u=r*a;return this.set(c*o+n,c*a-s*l,c*l+s*a,0,c*a+s*l,u*a+n,u*l-s*o,0,c*l-s*a,u*l+s*o,r*l*l+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,s,r,o){return this.set(1,n,r,0,t,1,o,0,e,s,1,0,0,0,0,1),this}compose(t,e,n){let s=this.elements,r=e._x,o=e._y,a=e._z,l=e._w,c=r+r,u=o+o,d=a+a,h=r*c,f=r*u,m=r*d,x=o*u,g=o*d,p=a*d,v=l*c,M=l*u,b=l*d,E=n.x,w=n.y,C=n.z;return s[0]=(1-(x+p))*E,s[1]=(f+b)*E,s[2]=(m-M)*E,s[3]=0,s[4]=(f-b)*w,s[5]=(1-(h+p))*w,s[6]=(g+v)*w,s[7]=0,s[8]=(m+M)*C,s[9]=(g-v)*C,s[10]=(1-(h+x))*C,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,n){let s=this.elements;t.x=s[12],t.y=s[13],t.z=s[14];let r=this.determinant();if(r===0)return n.set(1,1,1),e.identity(),this;let o=cs.set(s[0],s[1],s[2]).length(),a=cs.set(s[4],s[5],s[6]).length(),l=cs.set(s[8],s[9],s[10]).length();r<0&&(o=-o),Sn.copy(this);let c=1/o,u=1/a,d=1/l;return Sn.elements[0]*=c,Sn.elements[1]*=c,Sn.elements[2]*=c,Sn.elements[4]*=u,Sn.elements[5]*=u,Sn.elements[6]*=u,Sn.elements[8]*=d,Sn.elements[9]*=d,Sn.elements[10]*=d,e.setFromRotationMatrix(Sn),n.x=o,n.y=a,n.z=l,this}makePerspective(t,e,n,s,r,o,a=Tn,l=!1){let c=this.elements,u=2*r/(e-t),d=2*r/(n-s),h=(e+t)/(e-t),f=(n+s)/(n-s),m,x;if(l)m=r/(o-r),x=o*r/(o-r);else if(a===Tn)m=-(o+r)/(o-r),x=-2*o*r/(o-r);else if(a===ir)m=-o/(o-r),x=-o*r/(o-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=u,c[4]=0,c[8]=h,c[12]=0,c[1]=0,c[5]=d,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,n,s,r,o,a=Tn,l=!1){let c=this.elements,u=2/(e-t),d=2/(n-s),h=-(e+t)/(e-t),f=-(n+s)/(n-s),m,x;if(l)m=1/(o-r),x=o/(o-r);else if(a===Tn)m=-2/(o-r),x=-(o+r)/(o-r);else if(a===ir)m=-1/(o-r),x=-r/(o-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=u,c[4]=0,c[8]=0,c[12]=h,c[1]=0,c[5]=d,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=m,c[14]=x,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){let e=this.elements,n=t.elements;for(let s=0;s<16;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}};fa.prototype.isMatrix4=!0;var ge=fa,cs=new L,Sn=new ge,qm=new L(0,0,0),Ym=new L(1,1,1),mi=new L,oo=new L,on=new L,Tu=new ge,Au=new cn,Si=class i{constructor(t=0,e=0,n=0,s=i.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,s=this._order){return this._x=t,this._y=e,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){let s=t.elements,r=s[0],o=s[4],a=s[8],l=s[1],c=s[5],u=s[9],d=s[2],h=s[6],f=s[10];switch(e){case"XYZ":this._y=Math.asin(Ht(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(h,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Ht(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-d,r),this._z=0);break;case"ZXY":this._x=Math.asin(Ht(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-d,f),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-Ht(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(h,f),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(Ht(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-d,r)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-Ht(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(h,c),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-u,f),this._y=0);break;default:At("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Tu.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Tu,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Au.setFromEuler(this),this.setFromQuaternion(Au,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Si.DEFAULT_ORDER="XYZ";var or=class{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}},Zm=0,Cu=new L,hs=new cn,Zn=new ge,ao=new L,Ys=new L,$m=new L,Km=new cn,Ru=new L(1,0,0),Pu=new L(0,1,0),Iu=new L(0,0,1),Lu={type:"added"},Jm={type:"removed"},us={type:"childadded",child:null},pc={type:"childremoved",child:null},Qe=class i extends An{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Zm++}),this.uuid=Is(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=i.DEFAULT_UP.clone();let t=new L,e=new Si,n=new cn,s=new L(1,1,1);function r(){n.setFromEuler(e,!1)}function o(){e.setFromQuaternion(n,void 0,!1)}e._onChange(r),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new ge},normalMatrix:{value:new Dt}}),this.matrix=new ge,this.matrixWorld=new ge,this.matrixAutoUpdate=i.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=i.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new or,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return hs.setFromAxisAngle(t,e),this.quaternion.multiply(hs),this}rotateOnWorldAxis(t,e){return hs.setFromAxisAngle(t,e),this.quaternion.premultiply(hs),this}rotateX(t){return this.rotateOnAxis(Ru,t)}rotateY(t){return this.rotateOnAxis(Pu,t)}rotateZ(t){return this.rotateOnAxis(Iu,t)}translateOnAxis(t,e){return Cu.copy(t).applyQuaternion(this.quaternion),this.position.add(Cu.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Ru,t)}translateY(t){return this.translateOnAxis(Pu,t)}translateZ(t){return this.translateOnAxis(Iu,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Zn.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?ao.copy(t):ao.set(t,e,n);let s=this.parent;this.updateWorldMatrix(!0,!1),Ys.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Zn.lookAt(Ys,ao,this.up):Zn.lookAt(ao,Ys,this.up),this.quaternion.setFromRotationMatrix(Zn),s&&(Zn.extractRotation(s.matrixWorld),hs.setFromRotationMatrix(Zn),this.quaternion.premultiply(hs.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(Pt("Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Lu),us.child=t,this.dispatchEvent(us),us.child=null):Pt("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Jm),pc.child=t,this.dispatchEvent(pc),pc.child=null),this}removeFromParent(){let t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),Zn.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Zn.multiply(t.parent.matrixWorld)),t.applyMatrix4(Zn),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Lu),us.child=t,this.dispatchEvent(us),us.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,s=this.children.length;n<s;n++){let o=this.children[n].getObjectByProperty(t,e);if(o!==void 0)return o}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);let s=this.children;for(let r=0,o=s.length;r<o;r++)s[r].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ys,t,$m),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ys,Km,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);let e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);let e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverseVisible(t)}traverseAncestors(t){let e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let t=this.pivot;if(t!==null){let e=t.x,n=t.y,s=t.z,r=this.matrix.elements;r[12]+=e-r[0]*e-r[4]*n-r[8]*s,r[13]+=n-r[1]*e-r[5]*n-r[9]*s,r[14]+=s-r[2]*e-r[6]*n-r[10]*s}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);let e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e){let n=this.parent;if(t===!0&&n!==null&&n.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)),e===!0){let s=this.children;for(let r=0,o=s.length;r<o;r++)s[r].updateWorldMatrix(!1,!0)}}toJSON(t){let e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});let s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),this.static!==!1&&(s.static=this.static),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.pivot!==null&&(s.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(a=>({...a})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(t),s.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(t.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let l=a.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c<u;c++){let d=l[c];r(t.shapes,d)}else r(t.shapes,l)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(t.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(r(t.materials,this.material[l]));s.material=a}else s.material=r(t.materials,this.material);if(this.children.length>0){s.children=[];for(let a=0;a<this.children.length;a++)s.children.push(this.children[a].toJSON(t).object)}if(this.animations.length>0){s.animations=[];for(let a=0;a<this.animations.length;a++){let l=this.animations[a];s.animations.push(r(t.animations,l))}}if(e){let a=o(t.geometries),l=o(t.materials),c=o(t.textures),u=o(t.images),d=o(t.shapes),h=o(t.skeletons),f=o(t.animations),m=o(t.nodes);a.length>0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),u.length>0&&(n.images=u),d.length>0&&(n.shapes=d),h.length>0&&(n.skeletons=h),f.length>0&&(n.animations=f),m.length>0&&(n.nodes=m)}return n.object=s,n;function o(a){let l=[];for(let c in a){let u=a[c];delete u.metadata,l.push(u)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.pivot=t.pivot!==null?t.pivot.clone():null,this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){let s=t.children[n];this.add(s.clone())}return this}};Qe.DEFAULT_UP=new L(0,1,0);Qe.DEFAULT_MATRIX_AUTO_UPDATE=!0;Qe.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Qn=class extends Qe{constructor(){super(),this.isGroup=!0,this.type="Group"}},jm={type:"move"},Es=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Qn,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 Qn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new L,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new L),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Qn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new L,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new L,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let s=null,r=null,o=null,a=this._targetRay,l=this._grip,c=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(c&&t.hand){o=!0;for(let x of t.hand.values()){let g=e.getJointPose(x,n),p=this._getHandJoint(c,x);g!==null&&(p.matrix.fromArray(g.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=g.radius),p.visible=g!==null}let u=c.joints["index-finger-tip"],d=c.joints["thumb-tip"],h=u.position.distanceTo(d.position),f=.02,m=.005;c.inputState.pinching&&h>f+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&h<=f-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:t,target:this})));a!==null&&(s=e.getPose(t.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(a.matrix.fromArray(s.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,s.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(s.linearVelocity)):a.hasLinearVelocity=!1,s.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(s.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(jm)))}return a!==null&&(a.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let n=new Qn;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}},Cd={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},gi={h:0,s:0,l:0},lo={h:0,s:0,l:0};function mc(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+(t-i)*6*e:e<1/2?t:e<2/3?i+(t-i)*6*(2/3-e):i}var mt=class{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){let s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=ln){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Vt.colorSpaceToWorking(this,e),this}setRGB(t,e,n,s=Vt.workingColorSpace){return this.r=t,this.g=e,this.b=n,Vt.colorSpaceToWorking(this,s),this}setHSL(t,e,n,s=Vt.workingColorSpace){if(t=nh(t,1),e=Ht(e,0,1),n=Ht(n,0,1),e===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+e):n+e-n*e,o=2*n-r;this.r=mc(o,r,t+1/3),this.g=mc(o,r,t),this.b=mc(o,r,t-1/3)}return Vt.colorSpaceToWorking(this,s),this}setStyle(t,e=ln){function n(r){r!==void 0&&parseFloat(r)<1&&At("Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){let r,o=s[1],a=s[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:At("Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){let r=s[1],o=r.length;if(o===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,e);if(o===6)return this.setHex(parseInt(r,16),e);At("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=ln){let n=Cd[t.toLowerCase()];return n!==void 0?this.setHex(n,e):At("Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=ti(t.r),this.g=ti(t.g),this.b=ti(t.b),this}copyLinearToSRGB(t){return this.r=bs(t.r),this.g=bs(t.g),this.b=bs(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=ln){return Vt.workingToColorSpace(He.copy(this),t),Math.round(Ht(He.r*255,0,255))*65536+Math.round(Ht(He.g*255,0,255))*256+Math.round(Ht(He.b*255,0,255))}getHexString(t=ln){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Vt.workingColorSpace){Vt.workingToColorSpace(He.copy(this),e);let n=He.r,s=He.g,r=He.b,o=Math.max(n,s,r),a=Math.min(n,s,r),l,c,u=(a+o)/2;if(a===o)l=0,c=0;else{let d=o-a;switch(c=u<=.5?d/(o+a):d/(2-o-a),o){case n:l=(s-r)/d+(s<r?6:0);break;case s:l=(r-n)/d+2;break;case r:l=(n-s)/d+4;break}l/=6}return t.h=l,t.s=c,t.l=u,t}getRGB(t,e=Vt.workingColorSpace){return Vt.workingToColorSpace(He.copy(this),e),t.r=He.r,t.g=He.g,t.b=He.b,t}getStyle(t=ln){Vt.workingToColorSpace(He.copy(this),t);let e=He.r,n=He.g,s=He.b;return t!==ln?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(t,e,n){return this.getHSL(gi),this.setHSL(gi.h+t,gi.s+e,gi.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(gi),t.getHSL(lo);let n=Qs(gi.h,lo.h,e),s=Qs(gi.s,lo.s,e),r=Qs(gi.l,lo.l,e);return this.setHSL(n,s,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){let e=this.r,n=this.g,s=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*s,this.g=r[1]*e+r[4]*n+r[7]*s,this.b=r[2]*e+r[5]*n+r[8]*s,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},He=new mt;mt.NAMES=Cd;var $i=class extends Qe{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 Si,this.environmentIntensity=1,this.environmentRotation=new Si,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}},wn=new L,$n=new L,gc=new L,Kn=new L,ds=new L,fs=new L,Du=new L,xc=new L,vc=new L,_c=new L,yc=new xe,bc=new xe,Mc=new xe,bi=class i{constructor(t=new L,e=new L,n=new L){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,s){s.subVectors(n,e),wn.subVectors(t,e),s.cross(wn);let r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(t,e,n,s,r){wn.subVectors(s,e),$n.subVectors(n,e),gc.subVectors(t,e);let o=wn.dot(wn),a=wn.dot($n),l=wn.dot(gc),c=$n.dot($n),u=$n.dot(gc),d=o*c-a*a;if(d===0)return r.set(0,0,0),null;let h=1/d,f=(c*l-a*u)*h,m=(o*u-a*l)*h;return r.set(1-f-m,m,f)}static containsPoint(t,e,n,s){return this.getBarycoord(t,e,n,s,Kn)===null?!1:Kn.x>=0&&Kn.y>=0&&Kn.x+Kn.y<=1}static getInterpolation(t,e,n,s,r,o,a,l){return this.getBarycoord(t,e,n,s,Kn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,Kn.x),l.addScaledVector(o,Kn.y),l.addScaledVector(a,Kn.z),l)}static getInterpolatedAttribute(t,e,n,s,r,o){return yc.setScalar(0),bc.setScalar(0),Mc.setScalar(0),yc.fromBufferAttribute(t,e),bc.fromBufferAttribute(t,n),Mc.fromBufferAttribute(t,s),o.setScalar(0),o.addScaledVector(yc,r.x),o.addScaledVector(bc,r.y),o.addScaledVector(Mc,r.z),o}static isFrontFacing(t,e,n,s){return wn.subVectors(n,e),$n.subVectors(t,e),wn.cross($n).dot(s)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,s){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,n,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,s),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return wn.subVectors(this.c,this.b),$n.subVectors(this.a,this.b),wn.cross($n).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return i.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return i.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,s,r){return i.getInterpolation(t,this.a,this.b,this.c,e,n,s,r)}containsPoint(t){return i.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return i.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let n=this.a,s=this.b,r=this.c,o,a;ds.subVectors(s,n),fs.subVectors(r,n),xc.subVectors(t,n);let l=ds.dot(xc),c=fs.dot(xc);if(l<=0&&c<=0)return e.copy(n);vc.subVectors(t,s);let u=ds.dot(vc),d=fs.dot(vc);if(u>=0&&d<=u)return e.copy(s);let h=l*d-u*c;if(h<=0&&l>=0&&u<=0)return o=l/(l-u),e.copy(n).addScaledVector(ds,o);_c.subVectors(t,r);let f=ds.dot(_c),m=fs.dot(_c);if(m>=0&&f<=m)return e.copy(r);let x=f*c-l*m;if(x<=0&&c>=0&&m<=0)return a=c/(c-m),e.copy(n).addScaledVector(fs,a);let g=u*m-f*d;if(g<=0&&d-u>=0&&f-m>=0)return Du.subVectors(r,s),a=(d-u)/(d-u+(f-m)),e.copy(s).addScaledVector(Du,a);let p=1/(g+x+h);return o=x*p,a=h*p,e.copy(n).addScaledVector(ds,o).addScaledVector(fs,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},wi=class{constructor(t=new L(1/0,1/0,1/0),e=new L(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(En.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(En.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let n=En.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);let n=t.geometry;if(n!==void 0){let r=n.getAttribute("position");if(e===!0&&r!==void 0&&t.isInstancedMesh!==!0)for(let o=0,a=r.count;o<a;o++)t.isMesh===!0?t.getVertexPosition(o,En):En.fromBufferAttribute(r,o),En.applyMatrix4(t.matrixWorld),this.expandByPoint(En);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),co.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),co.copy(n.boundingBox)),co.applyMatrix4(t.matrixWorld),this.union(co)}let s=t.children;for(let r=0,o=s.length;r<o;r++)this.expandByObject(s[r],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,En),En.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Zs),ho.subVectors(this.max,Zs),ps.subVectors(t.a,Zs),ms.subVectors(t.b,Zs),gs.subVectors(t.c,Zs),xi.subVectors(ms,ps),vi.subVectors(gs,ms),Vi.subVectors(ps,gs);let e=[0,-xi.z,xi.y,0,-vi.z,vi.y,0,-Vi.z,Vi.y,xi.z,0,-xi.x,vi.z,0,-vi.x,Vi.z,0,-Vi.x,-xi.y,xi.x,0,-vi.y,vi.x,0,-Vi.y,Vi.x,0];return!Sc(e,ps,ms,gs,ho)||(e=[1,0,0,0,1,0,0,0,1],!Sc(e,ps,ms,gs,ho))?!1:(uo.crossVectors(xi,vi),e=[uo.x,uo.y,uo.z],Sc(e,ps,ms,gs,ho))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,En).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(En).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Jn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Jn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Jn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Jn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Jn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Jn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Jn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Jn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Jn),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}},Jn=[new L,new L,new L,new L,new L,new L,new L,new L],En=new L,co=new wi,ps=new L,ms=new L,gs=new L,xi=new L,vi=new L,Vi=new L,Zs=new L,ho=new L,uo=new L,Hi=new L;function Sc(i,t,e,n,s){for(let r=0,o=i.length-3;r<=o;r+=3){Hi.fromArray(i,r);let a=s.x*Math.abs(Hi.x)+s.y*Math.abs(Hi.y)+s.z*Math.abs(Hi.z),l=t.dot(Hi),c=e.dot(Hi),u=n.dot(Hi);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>a)return!1}return!0}var Se=new L,fo=new Tt,Qm=0,Yt=class extends An{constructor(t,e,n=!1){if(super(),Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Qm++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=Oc,this.updateRanges=[],this.gpuType=Pn,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[t+s]=e.array[n+s];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)fo.fromBufferAttribute(this,e),fo.applyMatrix3(t),this.setXY(e,fo.x,fo.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)Se.fromBufferAttribute(this,e),Se.applyMatrix3(t),this.setXYZ(e,Se.x,Se.y,Se.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)Se.fromBufferAttribute(this,e),Se.applyMatrix4(t),this.setXYZ(e,Se.x,Se.y,Se.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Se.fromBufferAttribute(this,e),Se.applyNormalMatrix(t),this.setXYZ(e,Se.x,Se.y,Se.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Se.fromBufferAttribute(this,e),Se.transformDirection(t),this.setXYZ(e,Se.x,Se.y,Se.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=ys(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=Ze(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=ys(e,this.array)),e}setX(t,e){return this.normalized&&(e=Ze(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=ys(e,this.array)),e}setY(t,e){return this.normalized&&(e=Ze(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=ys(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Ze(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=ys(e,this.array)),e}setW(t,e){return this.normalized&&(e=Ze(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=Ze(e,this.array),n=Ze(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,s){return t*=this.itemSize,this.normalized&&(e=Ze(e,this.array),n=Ze(n,this.array),s=Ze(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=s,this}setXYZW(t,e,n,s,r){return t*=this.itemSize,this.normalized&&(e=Ze(e,this.array),n=Ze(n,this.array),s=Ze(s,this.array),r=Ze(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=s,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==Oc&&(t.usage=this.usage),t}dispose(){this.dispatchEvent({type:"dispose"})}};var ar=class extends Yt{constructor(t,e,n){super(new Uint16Array(t),e,n)}};var lr=class extends Yt{constructor(t,e,n){super(new Uint32Array(t),e,n)}};var Oe=class extends Yt{constructor(t,e,n){super(new Float32Array(t),e,n)}},tg=new wi,$s=new L,wc=new L,Ei=class{constructor(t=new L,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){let n=this.center;e!==void 0?n.copy(e):tg.setFromPoints(t).getCenter(n);let s=0;for(let r=0,o=t.length;r<o;r++)s=Math.max(s,n.distanceToSquared(t[r]));return this.radius=Math.sqrt(s),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){let e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){let n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;$s.subVectors(t,this.center);let e=$s.lengthSq();if(e>this.radius*this.radius){let n=Math.sqrt(e),s=(n-this.radius)*.5;this.center.addScaledVector($s,s/n),this.radius+=s}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(wc.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint($s.copy(t.center).add(wc)),this.expandByPoint($s.copy(t.center).sub(wc))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}},eg=0,vn=new ge,Ec=new Qe,xs=new L,an=new wi,Ks=new wi,Le=new L,he=class i extends An{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:eg++}),this.uuid=Is(),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(t){return Array.isArray(t)?this.index=new(Em(t)?lr:ar)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){let e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let r=new Dt().getNormalMatrix(t);n.applyNormalMatrix(r),n.needsUpdate=!0}let s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(t),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return vn.makeRotationFromQuaternion(t),this.applyMatrix4(vn),this}rotateX(t){return vn.makeRotationX(t),this.applyMatrix4(vn),this}rotateY(t){return vn.makeRotationY(t),this.applyMatrix4(vn),this}rotateZ(t){return vn.makeRotationZ(t),this.applyMatrix4(vn),this}translate(t,e,n){return vn.makeTranslation(t,e,n),this.applyMatrix4(vn),this}scale(t,e,n){return vn.makeScale(t,e,n),this.applyMatrix4(vn),this}lookAt(t){return Ec.lookAt(t),Ec.updateMatrix(),this.applyMatrix4(Ec.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(xs).negate(),this.translate(xs.x,xs.y,xs.z),this}setFromPoints(t){let e=this.getAttribute("position");if(e===void 0){let n=[];for(let s=0,r=t.length;s<r;s++){let o=t[s];n.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Oe(n,3))}else{let n=Math.min(t.length,e.count);for(let s=0;s<n;s++){let r=t[s];e.setXYZ(s,r.x,r.y,r.z||0)}t.length>e.count&&At("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new wi);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Pt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new L(-1/0,-1/0,-1/0),new L(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,s=e.length;n<s;n++){let r=e[n];an.setFromBufferAttribute(r),this.morphTargetsRelative?(Le.addVectors(this.boundingBox.min,an.min),this.boundingBox.expandByPoint(Le),Le.addVectors(this.boundingBox.max,an.max),this.boundingBox.expandByPoint(Le)):(this.boundingBox.expandByPoint(an.min),this.boundingBox.expandByPoint(an.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Pt('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 Ei);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Pt("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new L,1/0);return}if(t){let n=this.boundingSphere.center;if(an.setFromBufferAttribute(t),e)for(let r=0,o=e.length;r<o;r++){let a=e[r];Ks.setFromBufferAttribute(a),this.morphTargetsRelative?(Le.addVectors(an.min,Ks.min),an.expandByPoint(Le),Le.addVectors(an.max,Ks.max),an.expandByPoint(Le)):(an.expandByPoint(Ks.min),an.expandByPoint(Ks.max))}an.getCenter(n);let s=0;for(let r=0,o=t.count;r<o;r++)Le.fromBufferAttribute(t,r),s=Math.max(s,n.distanceToSquared(Le));if(e)for(let r=0,o=e.length;r<o;r++){let a=e[r],l=this.morphTargetsRelative;for(let c=0,u=a.count;c<u;c++)Le.fromBufferAttribute(a,c),l&&(xs.fromBufferAttribute(t,c),Le.add(xs)),s=Math.max(s,n.distanceToSquared(Le))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&Pt('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){Pt("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=e.position,s=e.normal,r=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Yt(new Float32Array(4*n.count),4));let o=this.getAttribute("tangent"),a=[],l=[];for(let _=0;_<n.count;_++)a[_]=new L,l[_]=new L;let c=new L,u=new L,d=new L,h=new Tt,f=new Tt,m=new Tt,x=new L,g=new L;function p(_,A,P){c.fromBufferAttribute(n,_),u.fromBufferAttribute(n,A),d.fromBufferAttribute(n,P),h.fromBufferAttribute(r,_),f.fromBufferAttribute(r,A),m.fromBufferAttribute(r,P),u.sub(c),d.sub(c),f.sub(h),m.sub(h);let R=1/(f.x*m.y-m.x*f.y);isFinite(R)&&(x.copy(u).multiplyScalar(m.y).addScaledVector(d,-f.y).multiplyScalar(R),g.copy(d).multiplyScalar(f.x).addScaledVector(u,-m.x).multiplyScalar(R),a[_].add(x),a[A].add(x),a[P].add(x),l[_].add(g),l[A].add(g),l[P].add(g))}let v=this.groups;v.length===0&&(v=[{start:0,count:t.count}]);for(let _=0,A=v.length;_<A;++_){let P=v[_],R=P.start,D=P.count;for(let W=R,H=R+D;W<H;W+=3)p(t.getX(W+0),t.getX(W+1),t.getX(W+2))}let M=new L,b=new L,E=new L,w=new L;function C(_){E.fromBufferAttribute(s,_),w.copy(E);let A=a[_];M.copy(A),M.sub(E.multiplyScalar(E.dot(A))).normalize(),b.crossVectors(w,A);let R=b.dot(l[_])<0?-1:1;o.setXYZW(_,M.x,M.y,M.z,R)}for(let _=0,A=v.length;_<A;++_){let P=v[_],R=P.start,D=P.count;for(let W=R,H=R+D;W<H;W+=3)C(t.getX(W+0)),C(t.getX(W+1)),C(t.getX(W+2))}}computeVertexNormals(){let t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new Yt(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let h=0,f=n.count;h<f;h++)n.setXYZ(h,0,0,0);let s=new L,r=new L,o=new L,a=new L,l=new L,c=new L,u=new L,d=new L;if(t)for(let h=0,f=t.count;h<f;h+=3){let m=t.getX(h+0),x=t.getX(h+1),g=t.getX(h+2);s.fromBufferAttribute(e,m),r.fromBufferAttribute(e,x),o.fromBufferAttribute(e,g),u.subVectors(o,r),d.subVectors(s,r),u.cross(d),a.fromBufferAttribute(n,m),l.fromBufferAttribute(n,x),c.fromBufferAttribute(n,g),a.add(u),l.add(u),c.add(u),n.setXYZ(m,a.x,a.y,a.z),n.setXYZ(x,l.x,l.y,l.z),n.setXYZ(g,c.x,c.y,c.z)}else for(let h=0,f=e.count;h<f;h+=3)s.fromBufferAttribute(e,h+0),r.fromBufferAttribute(e,h+1),o.fromBufferAttribute(e,h+2),u.subVectors(o,r),d.subVectors(s,r),u.cross(d),n.setXYZ(h+0,u.x,u.y,u.z),n.setXYZ(h+1,u.x,u.y,u.z),n.setXYZ(h+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)Le.fromBufferAttribute(t,e),Le.normalize(),t.setXYZ(e,Le.x,Le.y,Le.z)}toNonIndexed(){function t(a,l){let c=a.array,u=a.itemSize,d=a.normalized,h=new c.constructor(l.length*u),f=0,m=0;for(let x=0,g=l.length;x<g;x++){a.isInterleavedBufferAttribute?f=l[x]*a.data.stride+a.offset:f=l[x]*u;for(let p=0;p<u;p++)h[m++]=c[f++]}return new Yt(h,u,d)}if(this.index===null)return At("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let e=new i,n=this.index.array,s=this.attributes;for(let a in s){let l=s[a],c=t(l,n);e.setAttribute(a,c)}let r=this.morphAttributes;for(let a in r){let l=[],c=r[a];for(let u=0,d=c.length;u<d;u++){let h=c[u],f=t(h,n);l.push(f)}e.morphAttributes[a]=l}e.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,l=o.length;a<l;a++){let c=o[a];e.addGroup(c.start,c.count,c.materialIndex)}return e}toJSON(){let t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){let l=this.parameters;for(let c in l)l[c]!==void 0&&(t[c]=l[c]);return t}t.data={attributes:{}};let e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});let n=this.attributes;for(let l in n){let c=n[l];t.data.attributes[l]=c.toJSON(t.data)}let s={},r=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],u=[];for(let d=0,h=c.length;d<h;d++){let f=c[d];u.push(f.toJSON(t.data))}u.length>0&&(s[l]=u,r=!0)}r&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(t.data.boundingSphere=a.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let e={};this.name=t.name;let n=t.index;n!==null&&this.setIndex(n.clone());let s=t.attributes;for(let c in s){let u=s[c];this.setAttribute(c,u.clone(e))}let r=t.morphAttributes;for(let c in r){let u=[],d=r[c];for(let h=0,f=d.length;h<f;h++)u.push(d[h].clone(e));this.morphAttributes[c]=u}this.morphTargetsRelative=t.morphTargetsRelative;let o=t.groups;for(let c=0,u=o.length;c<u;c++){let d=o[c];this.addGroup(d.start,d.count,d.materialIndex)}let a=t.boundingBox;a!==null&&(this.boundingBox=a.clone());let l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}};var ng=0,ni=class extends An{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ng++}),this.uuid=Is(),this.name="",this.type="Material",this.blending=Yi,this.side=ei,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Lo,this.blendDst=Do,this.blendEquation=Mi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new mt(0,0,0),this.blendAlpha=0,this.depthFunc=Zi,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=kc,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=qi,this.stencilZFail=qi,this.stencilZPass=qi,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(let e in t){let n=t[e];if(n===void 0){At(`Material: parameter '${e}' has value of undefined.`);continue}let s=this[e];if(s===void 0){At(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Yi&&(n.blending=this.blending),this.side!==ei&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Lo&&(n.blendSrc=this.blendSrc),this.blendDst!==Do&&(n.blendDst=this.blendDst),this.blendEquation!==Mi&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Zi&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==kc&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==qi&&(n.stencilFail=this.stencilFail),this.stencilZFail!==qi&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==qi&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){let o=[];for(let a in r){let l=r[a];delete l.metadata,o.push(l)}return o}if(e){let r=s(t.textures),o=s(t.images);r.length>0&&(n.textures=r),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;let e=t.clippingPlanes,n=null;if(e!==null){let s=e.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}};var jn=new L,Tc=new L,po=new L,_i=new L,Ac=new L,mo=new L,Cc=new L,Ti=class{constructor(t=new L,e=new L(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,jn)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);let n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){let e=jn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(jn.copy(this.origin).addScaledVector(this.direction,e),jn.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){Tc.copy(t).add(e).multiplyScalar(.5),po.copy(e).sub(t).normalize(),_i.copy(this.origin).sub(Tc);let r=t.distanceTo(e)*.5,o=-this.direction.dot(po),a=_i.dot(this.direction),l=-_i.dot(po),c=_i.lengthSq(),u=Math.abs(1-o*o),d,h,f,m;if(u>0)if(d=o*l-a,h=o*a-l,m=r*u,d>=0)if(h>=-m)if(h<=m){let x=1/u;d*=x,h*=x,f=d*(d+o*h+2*a)+h*(o*d+h+2*l)+c}else h=r,d=Math.max(0,-(o*h+a)),f=-d*d+h*(h+2*l)+c;else h=-r,d=Math.max(0,-(o*h+a)),f=-d*d+h*(h+2*l)+c;else h<=-m?(d=Math.max(0,-(-o*r+a)),h=d>0?-r:Math.min(Math.max(-r,-l),r),f=-d*d+h*(h+2*l)+c):h<=m?(d=0,h=Math.min(Math.max(-r,-l),r),f=h*(h+2*l)+c):(d=Math.max(0,-(o*r+a)),h=d>0?r:Math.min(Math.max(-r,-l),r),f=-d*d+h*(h+2*l)+c);else h=o>0?-r:r,d=Math.max(0,-(o*h+a)),f=-d*d+h*(h+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(Tc).addScaledVector(po,h),f}intersectSphere(t,e){jn.subVectors(t.center,this.origin);let n=jn.dot(this.direction),s=jn.dot(jn)-n*n,r=t.radius*t.radius;if(s>r)return null;let o=Math.sqrt(r-s),a=n-o,l=n+o;return l<0?null:a<0?this.at(l,e):this.at(a,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){let e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){let n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){let e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,s,r,o,a,l,c=1/this.direction.x,u=1/this.direction.y,d=1/this.direction.z,h=this.origin;return c>=0?(n=(t.min.x-h.x)*c,s=(t.max.x-h.x)*c):(n=(t.max.x-h.x)*c,s=(t.min.x-h.x)*c),u>=0?(r=(t.min.y-h.y)*u,o=(t.max.y-h.y)*u):(r=(t.max.y-h.y)*u,o=(t.min.y-h.y)*u),n>o||r>s||((r>n||isNaN(n))&&(n=r),(o<s||isNaN(s))&&(s=o),d>=0?(a=(t.min.z-h.z)*d,l=(t.max.z-h.z)*d):(a=(t.max.z-h.z)*d,l=(t.min.z-h.z)*d),n>l||a>s)||((a>n||n!==n)&&(n=a),(l<s||s!==s)&&(s=l),s<0)?null:this.at(n>=0?n:s,e)}intersectsBox(t){return this.intersectBox(t,jn)!==null}intersectTriangle(t,e,n,s,r){Ac.subVectors(e,t),mo.subVectors(n,t),Cc.crossVectors(Ac,mo);let o=this.direction.dot(Cc),a;if(o>0){if(s)return null;a=1}else if(o<0)a=-1,o=-o;else return null;_i.subVectors(this.origin,t);let l=a*this.direction.dot(mo.crossVectors(_i,mo));if(l<0)return null;let c=a*this.direction.dot(Ac.cross(_i));if(c<0||l+c>o)return null;let u=-a*_i.dot(Cc);return u<0?null:this.at(u/o,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},ii=class extends ni{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new mt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Si,this.combine=Wc,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}},Nu=new ge,Wi=new Ti,go=new Ei,Fu=new L,xo=new L,vo=new L,_o=new L,Rc=new L,yo=new L,ku=new L,bo=new L,Xe=class extends Qe{constructor(t=new he,e=new ii){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;r<o;r++){let a=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(t,e){let n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,o=n.morphTargetsRelative;e.fromBufferAttribute(s,t);let a=this.morphTargetInfluences;if(r&&a){yo.set(0,0,0);for(let l=0,c=r.length;l<c;l++){let u=a[l],d=r[l];u!==0&&(Rc.fromBufferAttribute(d,t),o?yo.addScaledVector(Rc,u):yo.addScaledVector(Rc.sub(e),u))}e.add(yo)}return e}raycast(t,e){let n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),go.copy(n.boundingSphere),go.applyMatrix4(r),Wi.copy(t.ray).recast(t.near),!(go.containsPoint(Wi.origin)===!1&&(Wi.intersectSphere(go,Fu)===null||Wi.origin.distanceToSquared(Fu)>(t.far-t.near)**2))&&(Nu.copy(r).invert(),Wi.copy(t.ray).applyMatrix4(Nu),!(n.boundingBox!==null&&Wi.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,Wi)))}_computeIntersections(t,e,n){let s,r=this.geometry,o=this.material,a=r.index,l=r.attributes.position,c=r.attributes.uv,u=r.attributes.uv1,d=r.attributes.normal,h=r.groups,f=r.drawRange;if(a!==null)if(Array.isArray(o))for(let m=0,x=h.length;m<x;m++){let g=h[m],p=o[g.materialIndex],v=Math.max(g.start,f.start),M=Math.min(a.count,Math.min(g.start+g.count,f.start+f.count));for(let b=v,E=M;b<E;b+=3){let w=a.getX(b),C=a.getX(b+1),_=a.getX(b+2);s=Mo(this,p,t,n,c,u,d,w,C,_),s&&(s.faceIndex=Math.floor(b/3),s.face.materialIndex=g.materialIndex,e.push(s))}}else{let m=Math.max(0,f.start),x=Math.min(a.count,f.start+f.count);for(let g=m,p=x;g<p;g+=3){let v=a.getX(g),M=a.getX(g+1),b=a.getX(g+2);s=Mo(this,o,t,n,c,u,d,v,M,b),s&&(s.faceIndex=Math.floor(g/3),e.push(s))}}else if(l!==void 0)if(Array.isArray(o))for(let m=0,x=h.length;m<x;m++){let g=h[m],p=o[g.materialIndex],v=Math.max(g.start,f.start),M=Math.min(l.count,Math.min(g.start+g.count,f.start+f.count));for(let b=v,E=M;b<E;b+=3){let w=b,C=b+1,_=b+2;s=Mo(this,p,t,n,c,u,d,w,C,_),s&&(s.faceIndex=Math.floor(b/3),s.face.materialIndex=g.materialIndex,e.push(s))}}else{let m=Math.max(0,f.start),x=Math.min(l.count,f.start+f.count);for(let g=m,p=x;g<p;g+=3){let v=g,M=g+1,b=g+2;s=Mo(this,o,t,n,c,u,d,v,M,b),s&&(s.faceIndex=Math.floor(g/3),e.push(s))}}}};function ig(i,t,e,n,s,r,o,a){let l;if(t.side===$e?l=n.intersectTriangle(o,r,s,!0,a):l=n.intersectTriangle(s,r,o,t.side===ei,a),l===null)return null;bo.copy(a),bo.applyMatrix4(i.matrixWorld);let c=e.ray.origin.distanceTo(bo);return c<e.near||c>e.far?null:{distance:c,point:bo.clone(),object:i}}function Mo(i,t,e,n,s,r,o,a,l,c){i.getVertexPosition(a,xo),i.getVertexPosition(l,vo),i.getVertexPosition(c,_o);let u=ig(i,t,e,n,xo,vo,_o,ku);if(u){let d=new L;bi.getBarycoord(ku,xo,vo,_o,d),s&&(u.uv=bi.getInterpolatedAttribute(s,a,l,c,d,new Tt)),r&&(u.uv1=bi.getInterpolatedAttribute(r,a,l,c,d,new Tt)),o&&(u.normal=bi.getInterpolatedAttribute(o,a,l,c,d,new L),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));let h={a,b:l,c,normal:new L,materialIndex:0};bi.getNormal(xo,vo,_o,h.normal),u.face=h,u.barycoord=d}return u}var Zo=class extends je{constructor(t=null,e=1,n=1,s,r,o,a,l,c=De,u=De,d,h){super(null,o,a,l,c,u,s,r,d,h),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Pc=new L,sg=new L,rg=new Dt,_n=class{constructor(t=new L(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,s){return this.normal.set(t,e,n),this.constant=s,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){let s=Pc.subVectors(n,e).cross(sg.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(s,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){let t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e,n=!0){let s=t.delta(Pc),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;let o=-(t.start.dot(this.normal)+this.constant)/r;return n===!0&&(o<0||o>1)?null:e.copy(t.start).addScaledVector(s,o)}intersectsLine(t){let e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){let n=e||rg.getNormalMatrix(t),s=this.coplanarPoint(Pc).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}},Xi=new Ei,og=new Tt(.5,.5),So=new L,cr=class{constructor(t=new _n,e=new _n,n=new _n,s=new _n,r=new _n,o=new _n){this.planes=[t,e,n,s,r,o]}set(t,e,n,s,r,o){let a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(s),a[4].copy(r),a[5].copy(o),this}copy(t){let e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=Tn,n=!1){let s=this.planes,r=t.elements,o=r[0],a=r[1],l=r[2],c=r[3],u=r[4],d=r[5],h=r[6],f=r[7],m=r[8],x=r[9],g=r[10],p=r[11],v=r[12],M=r[13],b=r[14],E=r[15];if(s[0].setComponents(c-o,f-u,p-m,E-v).normalize(),s[1].setComponents(c+o,f+u,p+m,E+v).normalize(),s[2].setComponents(c+a,f+d,p+x,E+M).normalize(),s[3].setComponents(c-a,f-d,p-x,E-M).normalize(),n)s[4].setComponents(l,h,g,b).normalize(),s[5].setComponents(c-l,f-h,p-g,E-b).normalize();else if(s[4].setComponents(c-l,f-h,p-g,E-b).normalize(),e===Tn)s[5].setComponents(c+l,f+h,p+g,E+b).normalize();else if(e===ir)s[5].setComponents(l,h,g,b).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),Xi.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{let e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Xi.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Xi)}intersectsSprite(t){Xi.center.set(0,0,0);let e=og.distanceTo(t.center);return Xi.radius=.7071067811865476+e,Xi.applyMatrix4(t.matrixWorld),this.intersectsSphere(Xi)}intersectsSphere(t){let e=this.planes,n=t.center,s=-t.radius;for(let r=0;r<6;r++)if(e[r].distanceToPoint(n)<s)return!1;return!0}intersectsBox(t){let e=this.planes;for(let n=0;n<6;n++){let s=e[n];if(So.x=s.normal.x>0?t.max.x:t.min.x,So.y=s.normal.y>0?t.max.y:t.min.y,So.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(So)<0)return!1}return!0}containsPoint(t){let e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};var zn=class extends ni{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new mt(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}},$o=new L,Ko=new L,Ou=new ge,Js=new Ti,wo=new Ei,Ic=new L,Uu=new L,Jo=class extends Qe{constructor(t=new he,e=new zn){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[0];for(let s=1,r=e.count;s<r;s++)$o.fromBufferAttribute(e,s-1),Ko.fromBufferAttribute(e,s),n[s]=n[s-1],n[s]+=$o.distanceTo(Ko);t.setAttribute("lineDistance",new Oe(n,1))}else At("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){let n=this.geometry,s=this.matrixWorld,r=t.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),wo.copy(n.boundingSphere),wo.applyMatrix4(s),wo.radius+=r,t.ray.intersectsSphere(wo)===!1)return;Ou.copy(s).invert(),Js.copy(t.ray).applyMatrix4(Ou);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=this.isLineSegments?2:1,u=n.index,h=n.attributes.position;if(u!==null){let f=Math.max(0,o.start),m=Math.min(u.count,o.start+o.count);for(let x=f,g=m-1;x<g;x+=c){let p=u.getX(x),v=u.getX(x+1),M=Eo(this,t,Js,l,p,v,x);M&&e.push(M)}if(this.isLineLoop){let x=u.getX(m-1),g=u.getX(f),p=Eo(this,t,Js,l,x,g,m-1);p&&e.push(p)}}else{let f=Math.max(0,o.start),m=Math.min(h.count,o.start+o.count);for(let x=f,g=m-1;x<g;x+=c){let p=Eo(this,t,Js,l,x,x+1,x);p&&e.push(p)}if(this.isLineLoop){let x=Eo(this,t,Js,l,m-1,f,m-1);x&&e.push(x)}}}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;r<o;r++){let a=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};function Eo(i,t,e,n,s,r,o){let a=i.geometry.attributes.position;if($o.fromBufferAttribute(a,s),Ko.fromBufferAttribute(a,r),e.distanceSqToSegment($o,Ko,Ic,Uu)>n)return;Ic.applyMatrix4(i.matrixWorld);let c=t.ray.origin.distanceTo(Ic);if(!(c<t.near||c>t.far))return{distance:c,point:Uu.clone().applyMatrix4(i.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:i}}var Bu=new L,zu=new L,si=class extends Jo{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[];for(let s=0,r=e.count;s<r;s+=2)Bu.fromBufferAttribute(e,s),zu.fromBufferAttribute(e,s+1),n[s]=s===0?0:n[s-1],n[s+1]=n[s]+Bu.distanceTo(zu);t.setAttribute("lineDistance",new Oe(n,1))}else At("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var Ai=class extends ni{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new mt(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}},Gu=new ge,Uc=new Ti,To=new Ei,Ao=new L,Gn=class extends Qe{constructor(t=new he,e=new Ai){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){let n=this.geometry,s=this.matrixWorld,r=t.params.Points.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),To.copy(n.boundingSphere),To.applyMatrix4(s),To.radius+=r,t.ray.intersectsSphere(To)===!1)return;Gu.copy(s).invert(),Uc.copy(t.ray).applyMatrix4(Gu);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=n.index,d=n.attributes.position;if(c!==null){let h=Math.max(0,o.start),f=Math.min(c.count,o.start+o.count);for(let m=h,x=f;m<x;m++){let g=c.getX(m);Ao.fromBufferAttribute(d,g),Vu(Ao,g,l,s,t,e,this)}}else{let h=Math.max(0,o.start),f=Math.min(d.count,o.start+o.count);for(let m=h,x=f;m<x;m++)Ao.fromBufferAttribute(d,m),Vu(Ao,m,l,s,t,e,this)}}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;r<o;r++){let a=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};function Vu(i,t,e,n,s,r,o){let a=Uc.distanceSqToPoint(i);if(a<e){let l=new L;Uc.closestPointToPoint(i,l),l.applyMatrix4(n);let c=s.ray.origin.distanceTo(l);if(c<s.near||c>s.far)return;r.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}var hr=class extends je{constructor(t=[],e=Di,n,s,r,o,a,l,c,u){super(t,e,n,s,r,o,a,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}};var ri=class extends je{constructor(t,e,n=Rn,s,r,o,a=De,l=De,c,u=Bn,d=1){if(u!==Bn&&u!==Fi)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let h={width:t,height:e,depth:d};super(h,s,r,o,a,l,u,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new ws(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){let e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}},jo=class extends ri{constructor(t,e=Rn,n=Di,s,r,o=De,a=De,l,c=Bn){let u={width:t,height:t,depth:1},d=[u,u,u,u,u,u];super(t,t,e,n,s,r,o,a,l,c),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}},ur=class extends je{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}},Ts=class i extends he{constructor(t=1,e=1,n=1,s=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:s,heightSegments:r,depthSegments:o};let a=this;s=Math.floor(s),r=Math.floor(r),o=Math.floor(o);let l=[],c=[],u=[],d=[],h=0,f=0;m("z","y","x",-1,-1,n,e,t,o,r,0),m("z","y","x",1,-1,n,e,-t,o,r,1),m("x","z","y",1,1,t,n,e,s,o,2),m("x","z","y",1,-1,t,n,-e,s,o,3),m("x","y","z",1,-1,t,e,n,s,r,4),m("x","y","z",-1,-1,t,e,-n,s,r,5),this.setIndex(l),this.setAttribute("position",new Oe(c,3)),this.setAttribute("normal",new Oe(u,3)),this.setAttribute("uv",new Oe(d,2));function m(x,g,p,v,M,b,E,w,C,_,A){let P=b/C,R=E/_,D=b/2,W=E/2,H=w/2,k=C+1,B=_+1,U=0,j=0,Q=new L;for(let ct=0;ct<B;ct++){let _t=ct*R-W;for(let wt=0;wt<k;wt++){let Zt=wt*P-D;Q[x]=Zt*v,Q[g]=_t*M,Q[p]=H,c.push(Q.x,Q.y,Q.z),Q[x]=0,Q[g]=0,Q[p]=w>0?1:-1,u.push(Q.x,Q.y,Q.z),d.push(wt/C),d.push(1-ct/_),U+=1}}for(let ct=0;ct<_;ct++)for(let _t=0;_t<C;_t++){let wt=h+_t+k*ct,Zt=h+_t+k*(ct+1),Qt=h+(_t+1)+k*(ct+1),Ut=h+(_t+1)+k*ct;l.push(wt,Zt,Ut),l.push(Zt,Qt,Ut),j+=6}a.addGroup(f,j,A),f+=j,h+=U}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new i(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}};var dr=class i extends he{constructor(t=1,e=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:s};let r=t/2,o=e/2,a=Math.floor(n),l=Math.floor(s),c=a+1,u=l+1,d=t/a,h=e/l,f=[],m=[],x=[],g=[];for(let p=0;p<u;p++){let v=p*h-o;for(let M=0;M<c;M++){let b=M*d-r;m.push(b,-v,0),x.push(0,0,1),g.push(M/a),g.push(1-p/l)}}for(let p=0;p<l;p++)for(let v=0;v<a;v++){let M=v+c*p,b=v+c*(p+1),E=v+1+c*(p+1),w=v+1+c*p;f.push(M,b,w),f.push(b,E,w)}this.setIndex(f),this.setAttribute("position",new Oe(m,3)),this.setAttribute("normal",new Oe(x,3)),this.setAttribute("uv",new Oe(g,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new i(t.width,t.height,t.widthSegments,t.heightSegments)}};function Ji(i){let t={};for(let e in i){t[e]={};for(let n in i[e]){let s=i[e][n];if(Hu(s))s.isRenderTargetTexture?(At("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=s.clone();else if(Array.isArray(s))if(Hu(s[0])){let r=[];for(let o=0,a=s.length;o<a;o++)r[o]=s[o].clone();t[e][n]=r}else t[e][n]=s.slice();else t[e][n]=s}}return t}function Ye(i){let t={};for(let e=0;e<i.length;e++){let n=Ji(i[e]);for(let s in n)t[s]=n[s]}return t}function Hu(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function ag(i){let t=[];for(let e=0;e<i.length;e++)t.push(i[e].clone());return t}function sh(i){let t=i.getRenderTarget();return t===null?i.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:Vt.workingColorSpace}var li={clone:Ji,merge:Ye},lg=`void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,cg=`void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`,ue=class extends ni{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=lg,this.fragmentShader=cg,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Ji(t.uniforms),this.uniformsGroups=ag(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this.defaultAttributeValues=Object.assign({},t.defaultAttributeValues),this.index0AttributeName=t.index0AttributeName,this.uniformsNeedUpdate=t.uniformsNeedUpdate,this}toJSON(t){let e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(let s in this.uniforms){let o=this.uniforms[s].value;o&&o.isTexture?e.uniforms[s]={type:"t",value:o.toJSON(t).uuid}:o&&o.isColor?e.uniforms[s]={type:"c",value:o.getHex()}:o&&o.isVector2?e.uniforms[s]={type:"v2",value:o.toArray()}:o&&o.isVector3?e.uniforms[s]={type:"v3",value:o.toArray()}:o&&o.isVector4?e.uniforms[s]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?e.uniforms[s]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?e.uniforms[s]={type:"m4",value:o.toArray()}:e.uniforms[s]={value:o}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}},As=class extends ue{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};var Qo=class extends ni{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=gd,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}},ta=class extends ni{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}};function Co(i,t){return!i||i.constructor===t?i:typeof t.BYTES_PER_ELEMENT=="number"?new t(i):Array.prototype.slice.call(i)}var Ci=class{constructor(t,e,n,s){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,s=e[n],r=e[n-1];n:{t:{let o;e:{i:if(!(t<s)){for(let a=n+2;;){if(s===void 0){if(t<r)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(r=s,s=e[++n],t<s)break t}o=e.length;break e}if(!(t>=r)){let a=e[1];t<a&&(n=2,r=a);for(let l=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(s=r,r=e[--n-1],t>=r)break t}o=n,n=0;break e}break n}for(;n<o;){let a=n+o>>>1;t<e[a]?o=a:n=a+1}if(s=e[n],r=e[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(s===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,s)}return this.interpolate_(n,r,t,s)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=t*s;for(let o=0;o!==s;++o)e[o]=n[r+o];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},ea=class extends Ci{constructor(t,e,n,s){super(t,e,n,s),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Dc,endingEnd:Dc}}intervalChanged_(t,e,n){let s=this.parameterPositions,r=t-2,o=t+1,a=s[r],l=s[o];if(a===void 0)switch(this.getSettings_().endingStart){case Nc:r=t,a=2*e-n;break;case Fc:r=s.length-2,a=e+s[r]-s[r+1];break;default:r=t,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case Nc:o=t,l=2*n-e;break;case Fc:o=1,l=n+s[1]-s[0];break;default:o=t-1,l=e}let c=(n-e)*.5,u=this.valueSize;this._weightPrev=c/(e-a),this._weightNext=c/(l-n),this._offsetPrev=r*u,this._offsetNext=o*u}interpolate_(t,e,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,c=l-a,u=this._offsetPrev,d=this._offsetNext,h=this._weightPrev,f=this._weightNext,m=(n-e)/(s-e),x=m*m,g=x*m,p=-h*g+2*h*x-h*m,v=(1+h)*g+(-1.5-2*h)*x+(-.5+h)*m+1,M=(-1-f)*g+(1.5+f)*x+.5*m,b=f*g-f*x;for(let E=0;E!==a;++E)r[E]=p*o[u+E]+v*o[c+E]+M*o[l+E]+b*o[d+E];return r}},na=class extends Ci{constructor(t,e,n,s){super(t,e,n,s)}interpolate_(t,e,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,c=l-a,u=(n-e)/(s-e),d=1-u;for(let h=0;h!==a;++h)r[h]=o[c+h]*d+o[l+h]*u;return r}},ia=class extends Ci{constructor(t,e,n,s){super(t,e,n,s)}interpolate_(t){return this.copySampleValue_(t-1)}},sa=class extends Ci{interpolate_(t,e,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a,c=l-a,u=this.settings||this.DefaultSettings_,d=u.inTangents,h=u.outTangents;if(!d||!h){let x=(n-e)/(s-e),g=1-x;for(let p=0;p!==a;++p)r[p]=o[c+p]*g+o[l+p]*x;return r}let f=a*2,m=t-1;for(let x=0;x!==a;++x){let g=o[c+x],p=o[l+x],v=m*f+x*2,M=h[v],b=h[v+1],E=t*f+x*2,w=d[E],C=d[E+1],_=(n-e)/(s-e),A,P,R,D,W;for(let H=0;H<8;H++){A=_*_,P=A*_,R=1-_,D=R*R,W=D*R;let B=W*e+3*D*_*M+3*R*A*w+P*s-n;if(Math.abs(B)<1e-10)break;let U=3*D*(M-e)+6*R*_*(w-M)+3*A*(s-w);if(Math.abs(U)<1e-10)break;_=_-B/U,_=Math.max(0,Math.min(1,_))}r[x]=W*g+3*D*_*b+3*R*A*C+P*p}return r}},hn=class{constructor(t,e,n,s){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Co(e,this.TimeBufferType),this.values=Co(n,this.ValueBufferType),this.setInterpolation(s||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:Co(t.times,Array),values:Co(t.values,Array)};let s=t.getInterpolation();s!==t.DefaultInterpolation&&(n.interpolation=s)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new ia(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new na(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new ea(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodBezier(t){let e=new sa(this.times,this.values,this.getValueSize(),t);return this.settings&&(e.settings=this.settings),e}setInterpolation(t){let e;switch(t){case tr:e=this.InterpolantFactoryMethodDiscrete;break;case Ho:e=this.InterpolantFactoryMethodLinear;break;case Io:e=this.InterpolantFactoryMethodSmooth;break;case Lc:e=this.InterpolantFactoryMethodBezier;break}if(e===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return At("KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return tr;case this.InterpolantFactoryMethodLinear:return Ho;case this.InterpolantFactoryMethodSmooth:return Io;case this.InterpolantFactoryMethodBezier:return Lc}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let n=0,s=e.length;n!==s;++n)e[n]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let n=0,s=e.length;n!==s;++n)e[n]*=t}return this}trim(t,e){let n=this.times,s=n.length,r=0,o=s-1;for(;r!==s&&n[r]<t;)++r;for(;o!==-1&&n[o]>e;)--o;if(++o,r!==0||o!==s){r>=o&&(o=Math.max(o,1),r=o-1);let a=this.getValueSize();this.times=n.slice(r,o),this.values=this.values.slice(r*a,o*a)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(Pt("KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,s=this.values,r=n.length;r===0&&(Pt("KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let a=0;a!==r;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){Pt("KeyframeTrack: Time is not a valid number.",this,a,l),t=!1;break}if(o!==null&&o>l){Pt("KeyframeTrack: Out of order keys.",this,a,l,o),t=!1;break}o=l}if(s!==void 0&&Tm(s))for(let a=0,l=s.length;a!==l;++a){let c=s[a];if(isNaN(c)){Pt("KeyframeTrack: Value is not a valid number.",this,a,c),t=!1;break}}return t}optimize(){let t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===Io,r=t.length-1,o=1;for(let a=1;a<r;++a){let l=!1,c=t[a],u=t[a+1];if(c!==u&&(a!==1||c!==t[0]))if(s)l=!0;else{let d=a*n,h=d-n,f=d+n;for(let m=0;m!==n;++m){let x=e[d+m];if(x!==e[h+m]||x!==e[f+m]){l=!0;break}}}if(l){if(a!==o){t[o]=t[a];let d=a*n,h=o*n;for(let f=0;f!==n;++f)e[h+f]=e[d+f]}++o}}if(r>0){t[o]=t[r];for(let a=r*n,l=o*n,c=0;c!==n;++c)e[l+c]=e[a+c];++o}return o!==t.length?(this.times=t.slice(0,o),this.values=e.slice(0,o*n)):(this.times=t,this.values=e),this}clone(){let t=this.times.slice(),e=this.values.slice(),n=this.constructor,s=new n(this.name,t,e);return s.createInterpolant=this.createInterpolant,s}};hn.prototype.ValueTypeName="";hn.prototype.TimeBufferType=Float32Array;hn.prototype.ValueBufferType=Float32Array;hn.prototype.DefaultInterpolation=Ho;var Ri=class extends hn{constructor(t,e,n){super(t,e,n)}};Ri.prototype.ValueTypeName="bool";Ri.prototype.ValueBufferType=Array;Ri.prototype.DefaultInterpolation=tr;Ri.prototype.InterpolantFactoryMethodLinear=void 0;Ri.prototype.InterpolantFactoryMethodSmooth=void 0;var ra=class extends hn{constructor(t,e,n,s){super(t,e,n,s)}};ra.prototype.ValueTypeName="color";var oa=class extends hn{constructor(t,e,n,s){super(t,e,n,s)}};oa.prototype.ValueTypeName="number";var aa=class extends Ci{constructor(t,e,n,s){super(t,e,n,s)}interpolate_(t,e,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-e)/(s-e),c=t*a;for(let u=c+a;c!==u;c+=4)cn.slerpFlat(r,0,o,c-a,o,c,l);return r}},fr=class extends hn{constructor(t,e,n,s){super(t,e,n,s)}InterpolantFactoryMethodLinear(t){return new aa(this.times,this.values,this.getValueSize(),t)}};fr.prototype.ValueTypeName="quaternion";fr.prototype.InterpolantFactoryMethodSmooth=void 0;var Pi=class extends hn{constructor(t,e,n){super(t,e,n)}};Pi.prototype.ValueTypeName="string";Pi.prototype.ValueBufferType=Array;Pi.prototype.DefaultInterpolation=tr;Pi.prototype.InterpolantFactoryMethodLinear=void 0;Pi.prototype.InterpolantFactoryMethodSmooth=void 0;var la=class extends hn{constructor(t,e,n,s){super(t,e,n,s)}};la.prototype.ValueTypeName="vector";var ca=class{constructor(t,e,n){let s=this,r=!1,o=0,a=0,l,c=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this._abortController=null,this.itemStart=function(u){a++,r===!1&&s.onStart!==void 0&&s.onStart(u,o,a),r=!0},this.itemEnd=function(u){o++,s.onProgress!==void 0&&s.onProgress(u,o,a),o===a&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(u){s.onError!==void 0&&s.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,d){return c.push(u,d),this},this.removeHandler=function(u){let d=c.indexOf(u);return d!==-1&&c.splice(d,2),this},this.getHandler=function(u){for(let d=0,h=c.length;d<h;d+=2){let f=c[d],m=c[d+1];if(f.global&&(f.lastIndex=0),f.test(u))return m}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}},Rd=new ca,ha=class{constructor(t){this.manager=t!==void 0?t:Rd,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(t,e){let n=this;return new Promise(function(s,r){n.load(t,s,e,r)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}abort(){return this}};ha.DEFAULT_MATERIAL_NAME="__DEFAULT";var Ro=new L,Po=new cn,On=new L,pr=class extends Qe{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ge,this.projectionMatrix=new ge,this.projectionMatrixInverse=new ge,this.coordinateSystem=Tn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorld.decompose(Ro,Po,On),On.x===1&&On.y===1&&On.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Ro,Po,On.set(1,1,1)).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorld.decompose(Ro,Po,On),On.x===1&&On.y===1&&On.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Ro,Po,On.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}},yi=new L,Wu=new Tt,Xu=new Tt,We=class extends pr{constructor(t=50,e=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){let e=.5*this.getFilmHeight()/t;this.fov=Ss*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){let t=Math.tan(js*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return Ss*2*Math.atan(Math.tan(js*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){yi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(yi.x,yi.y).multiplyScalar(-t/yi.z),yi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(yi.x,yi.y).multiplyScalar(-t/yi.z)}getViewSize(t,e){return this.getViewBounds(t,Wu,Xu),e.subVectors(Xu,Wu)}setViewOffset(t,e,n,s,r,o){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=this.near,e=t*Math.tan(js*.5*this.fov)/this.zoom,n=2*e,s=this.aspect*n,r=-.5*s,o=this.view;if(this.view!==null&&this.view.enabled){let l=o.fullWidth,c=o.fullHeight;r+=o.offsetX*s/l,e-=o.offsetY*n/c,s*=o.width/l,n*=o.height/c}let a=this.filmOffset;a!==0&&(r+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,e,e-n,t,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}};var oi=class extends pr{constructor(t=-1,e=1,n=1,s=-1,r=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=s,this.near=r,this.far=o,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,s,r,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2,r=n-t,o=n+t,a=s+e,l=s-e;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,o=r+c*this.view.width,a-=u*this.view.offsetY,l=a-u*this.view.height}this.projectionMatrix.makeOrthographic(r,o,a,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}};var vs=-90,_s=1,ua=class extends Qe{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let s=new We(vs,_s,t,e);s.layers=this.layers,this.add(s);let r=new We(vs,_s,t,e);r.layers=this.layers,this.add(r);let o=new We(vs,_s,t,e);o.layers=this.layers,this.add(o);let a=new We(vs,_s,t,e);a.layers=this.layers,this.add(a);let l=new We(vs,_s,t,e);l.layers=this.layers,this.add(l);let c=new We(vs,_s,t,e);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let t=this.coordinateSystem,e=this.children.concat(),[n,s,r,o,a,l]=e;for(let c of e)this.remove(c);if(t===Tn)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(t===ir)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(let c of e)this.add(c),c.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());let[r,o,a,l,c,u]=this.children,d=t.getRenderTarget(),h=t.getActiveCubeFace(),f=t.getActiveMipmapLevel(),m=t.xr.enabled;t.xr.enabled=!1;let x=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let g=!1;t.isWebGLRenderer===!0?g=t.state.buffers.depth.getReversed():g=t.reversedDepthBuffer,t.setRenderTarget(n,0,s),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,r),t.setRenderTarget(n,1,s),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,o),t.setRenderTarget(n,2,s),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,a),t.setRenderTarget(n,3,s),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,l),t.setRenderTarget(n,4,s),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,c),n.texture.generateMipmaps=x,t.setRenderTarget(n,5,s),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,u),t.setRenderTarget(d,h,f),t.xr.enabled=m,n.texture.needsPMREMUpdate=!0}},da=class extends We{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}},mr=class{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(t){this._document=t,t.hidden!==void 0&&(this._pageVisibilityHandler=hg.bind(this),t.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){this._pageVisibilityHandler!==null&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(t){return this._timescale=t,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(t){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(t!==void 0?t:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}};function hg(){this._document.hidden===!1&&this.reset()}var rh="\\[\\]\\.:\\/",ug=new RegExp("["+rh+"]","g"),oh="[^"+rh+"]",dg="[^"+rh.replace("\\.","")+"]",fg=/((?:WC+[\/:])*)/.source.replace("WC",oh),pg=/(WCOD+)?/.source.replace("WCOD",dg),mg=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",oh),gg=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",oh),xg=new RegExp("^"+fg+pg+mg+gg+"$"),vg=["material","materials","bones","map"],Bc=class{constructor(t,e,n){let s=n||ce.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,s)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,s=this._bindings[n];s!==void 0&&s.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let s=this._targetGroup.nCachedObjects_,r=n.length;s!==r;++s)n[s].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},ce=class i{constructor(t,e,n){this.path=e,this.parsedPath=n||i.parseTrackName(e),this.node=i.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new i.Composite(t,e,n):new i(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(ug,"")}static parseTrackName(t){let e=xg.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},s=n.nodeName&&n.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){let r=n.nodeName.substring(s+1);vg.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,s),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=function(r){for(let o=0;o<r.length;o++){let a=r[o];if(a.name===e||a.uuid===e)return a;let l=n(a.children);if(l)return l}return null},s=n(t.children);if(s)return s}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)t[e++]=n[s]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,n=e.objectName,s=e.propertyName,r=e.propertyIndex;if(t||(t=i.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){At("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=e.objectIndex;switch(n){case"materials":if(!t.material){Pt("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){Pt("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){Pt("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let u=0;u<t.length;u++)if(t[u].name===c){c=u;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){Pt("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){Pt("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){Pt("PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(c!==void 0){if(t[c]===void 0){Pt("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[c]}}let o=t[s];if(o===void 0){let c=e.nodeName;Pt("PropertyBinding: Trying to update property for track: "+c+"."+s+" but it wasn't found.",t);return}let a=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?a=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(r!==void 0){if(s==="morphTargetInfluences"){if(!t.geometry){Pt("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){Pt("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[r]!==void 0&&(r=t.morphTargetDictionary[r])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=r}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=s;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};ce.Composite=Bc;ce.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ce.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ce.prototype.GetterByBindingType=[ce.prototype._getValue_direct,ce.prototype._getValue_array,ce.prototype._getValue_arrayElement,ce.prototype._getValue_toArray];ce.prototype.SetterByBindingTypeAndVersioning=[[ce.prototype._setValue_direct,ce.prototype._setValue_direct_setNeedsUpdate,ce.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ce.prototype._setValue_array,ce.prototype._setValue_array_setNeedsUpdate,ce.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ce.prototype._setValue_arrayElement,ce.prototype._setValue_arrayElement_setNeedsUpdate,ce.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ce.prototype._setValue_fromArray,ce.prototype._setValue_fromArray_setNeedsUpdate,ce.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var mM=new Float32Array(1);var un=class{constructor(t=1,e=0,n=0){this.radius=t,this.phi=e,this.theta=n}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Ht(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(Ht(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var dh=class dh{constructor(t,e,n,s){this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,n,s)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,s){let r=this.elements;return r[0]=t,r[2]=e,r[1]=n,r[3]=s,this}};dh.prototype.isMatrix2=!0;var zc=dh;var gr=class extends An{constructor(t,e=null){super(),this.object=t,this.domElement=e,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(t){if(t===void 0){At("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=t}disconnect(){}dispose(){}update(){}};function ah(i,t,e,n){let s=_g(n);switch(e){case Kc:return i*t;case jc:return i*t/s.components*s.byteLength;case ba:return i*t/s.components*s.byteLength;case ki:return i*t*2/s.components*s.byteLength;case Ma:return i*t*2/s.components*s.byteLength;case Jc:return i*t*3/s.components*s.byteLength;case bn:return i*t*4/s.components*s.byteLength;case Sa:return i*t*4/s.components*s.byteLength;case Ar:case Cr:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case Rr:case Pr:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case Ea:case Aa:return Math.max(i,16)*Math.max(t,8)/4;case wa:case Ta:return Math.max(i,8)*Math.max(t,8)/2;case Ca:case Ra:case Ia:case La:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case Pa:case Ir:case Da:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case Na:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case Fa:return Math.floor((i+4)/5)*Math.floor((t+3)/4)*16;case ka:return Math.floor((i+4)/5)*Math.floor((t+4)/5)*16;case Oa:return Math.floor((i+5)/6)*Math.floor((t+4)/5)*16;case Ua:return Math.floor((i+5)/6)*Math.floor((t+5)/6)*16;case Ba:return Math.floor((i+7)/8)*Math.floor((t+4)/5)*16;case za:return Math.floor((i+7)/8)*Math.floor((t+5)/6)*16;case Ga:return Math.floor((i+7)/8)*Math.floor((t+7)/8)*16;case Va:return Math.floor((i+9)/10)*Math.floor((t+4)/5)*16;case Ha:return Math.floor((i+9)/10)*Math.floor((t+5)/6)*16;case Wa:return Math.floor((i+9)/10)*Math.floor((t+7)/8)*16;case Xa:return Math.floor((i+9)/10)*Math.floor((t+9)/10)*16;case qa:return Math.floor((i+11)/12)*Math.floor((t+9)/10)*16;case Ya:return Math.floor((i+11)/12)*Math.floor((t+11)/12)*16;case Za:case $a:case Ka:return Math.ceil(i/4)*Math.ceil(t/4)*16;case Ja:case ja:return Math.ceil(i/4)*Math.ceil(t/4)*8;case Lr:case Qa:return Math.ceil(i/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function _g(i){switch(i){case fn:case qc:return{byteLength:1,components:1};case Rs:case Yc:case qe:return{byteLength:2,components:1};case _a:case ya:return{byteLength:2,components:4};case Rn:case va:case Pn:return{byteLength:4,components:1};case Zc:case $c:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:pa}}));typeof window<"u"&&(window.__THREE__?At("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=pa);function jd(){let i=null,t=!1,e=null,n=null;function s(r,o){e(r,o),n=i.requestAnimationFrame(s)}return{start:function(){t!==!0&&e!==null&&i!==null&&(n=i.requestAnimationFrame(s),t=!0)},stop:function(){i!==null&&i.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(r){e=r},setContext:function(r){i=r}}}function yg(i){let t=new WeakMap;function e(a,l){let c=a.array,u=a.usage,d=c.byteLength,h=i.createBuffer();i.bindBuffer(l,h),i.bufferData(l,c,u),a.onUploadCallback();let f;if(c instanceof Float32Array)f=i.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)f=i.HALF_FLOAT;else if(c instanceof Uint16Array)a.isFloat16BufferAttribute?f=i.HALF_FLOAT:f=i.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=i.SHORT;else if(c instanceof Uint32Array)f=i.UNSIGNED_INT;else if(c instanceof Int32Array)f=i.INT;else if(c instanceof Int8Array)f=i.BYTE;else if(c instanceof Uint8Array)f=i.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:h,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:a.version,size:d}}function n(a,l,c){let u=l.array,d=l.updateRanges;if(i.bindBuffer(c,a),d.length===0)i.bufferSubData(c,0,u);else{d.sort((f,m)=>f.start-m.start);let h=0;for(let f=1;f<d.length;f++){let m=d[h],x=d[f];x.start<=m.start+m.count+1?m.count=Math.max(m.count,x.start+x.count-m.start):(++h,d[h]=x)}d.length=h+1;for(let f=0,m=d.length;f<m;f++){let x=d[f];i.bufferSubData(c,x.start*u.BYTES_PER_ELEMENT,u,x.start,x.count)}l.clearUpdateRanges()}l.onUploadCallback()}function s(a){return a.isInterleavedBufferAttribute&&(a=a.data),t.get(a)}function r(a){a.isInterleavedBufferAttribute&&(a=a.data);let l=t.get(a);l&&(i.deleteBuffer(l.buffer),t.delete(a))}function o(a,l){if(a.isInterleavedBufferAttribute&&(a=a.data),a.isGLBufferAttribute){let u=t.get(a);(!u||u.version<a.version)&&t.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let c=t.get(a);if(c===void 0)t.set(a,e(a,l));else if(c.version<a.version){if(c.size!==a.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(c.buffer,a,l),c.version=a.version}}return{get:s,remove:r,update:o}}var bg=`#ifdef USE_ALPHAHASH
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
#endif`,Mg=`#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`,Sg=`#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
#endif`,wg=`#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
#endif`,Eg=`#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`,Tg=`#ifdef USE_ALPHATEST
uniform float alphaTest;
#endif`,Ag=`#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`,Cg=`#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
#endif`,Rg=`#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;
vec4 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 );
}
#endif`,Pg=`#ifdef USE_BATCHING
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
#endif`,Ig=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
vPosition = vec3( position );
#endif`,Lg=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
#endif`,Dg=`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`,Ng=`#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`,Fg=`#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`,kg=`#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`,Og=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`,Ug=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
#endif`,Bg=`#if NUM_CLIPPING_PLANES > 0
vClipPosition = - mvPosition.xyz;
#endif`,zg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
diffuseColor *= vColor;
#endif`,Gg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#endif`,Vg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
varying vec4 vColor;
#endif`,Hg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
vColor = vec4( 1.0 );
#endif
#ifdef USE_COLOR_ALPHA
vColor *= color;
#elif defined( USE_COLOR )
vColor.rgb *= color;
#endif
#ifdef USE_INSTANCING_COLOR
vColor.rgb *= instanceColor.rgb;
#endif
#ifdef USE_BATCHING_COLOR
vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
#endif`,Wg=`#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`,Xg=`#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`,qg=`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`,Yg=`#ifdef USE_DISPLACEMENTMAP
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
#endif`,Zg=`#ifdef USE_DISPLACEMENTMAP
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
#endif`,$g=`#ifdef USE_EMISSIVEMAP
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
emissiveColor = sRGBTransferEOTF( emissiveColor );
#endif
totalEmissiveRadiance *= emissiveColor.rgb;
#endif`,Kg=`#ifdef USE_EMISSIVEMAP
uniform sampler2D emissiveMap;
#endif`,Jg="gl_FragColor = linearToOutputTexel( gl_FragColor );",jg=`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 );
}`,Qg=`#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 * reflectVec );
#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
#endif`,t0=`#ifdef USE_ENVMAP
uniform float envMapIntensity;
uniform mat3 envMapRotation;
#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#else
uniform sampler2D envMap;
#endif
#endif`,e0=`#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`,n0=`#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`,i0=`#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`,s0=`#ifdef USE_FOG
vFogDepth = - mvPosition.z;
#endif`,r0=`#ifdef USE_FOG
varying float vFogDepth;
#endif`,o0=`#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`,a0=`#ifdef USE_FOG
uniform vec3 fogColor;
varying float vFogDepth;
#ifdef FOG_EXP2
uniform float fogDensity;
#else
uniform float fogNear;
uniform float fogFar;
#endif
#endif`,l0=`#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
}`,c0=`#ifdef USE_LIGHTMAP
uniform sampler2D lightMap;
uniform float lightMapIntensity;
#endif`,h0=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`,u0=`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`,d0=`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
#include <lightprobes_pars_fragment>`,f0=`#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`,p0=`ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`,m0=`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`,g0=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`,x0=`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`,v0=`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`,_0=`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 ) );
return 0.5 / max( gv + gl, EPSILON );
}
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 + ( material.specularF90 - 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 );
#ifdef USE_CLEARCOAT
vec3 Ncc = geometryClearcoatNormal;
vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );
vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );
vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );
mat3 mInvClearcoat = mat3(
vec3( t1Clearcoat.x, 0, t1Clearcoat.y ),
vec3( 0, 1, 0 ),
vec3( t1Clearcoat.z, 0, t1Clearcoat.w )
);
vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;
clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );
#endif
}
#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 );
}`,y0=`
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
#ifdef USE_LIGHT_PROBES_GRID
vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz;
vec3 probeWorldNormal = inverseTransformDirection( geometryNormal, viewMatrix );
irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal );
#endif
#endif
#if defined( RE_IndirectSpecular )
vec3 radiance = vec3( 0.0 );
vec3 clearcoatRadiance = vec3( 0.0 );
#endif`,b0=`#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( ENVMAP_TYPE_CUBE_UV )
#if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG )
iblIrradiance += getIBLIrradiance( geometryNormal );
#endif
#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`,M0=`#if defined( RE_IndirectDiffuse )
#if defined( LAMBERT ) || defined( PHONG )
irradiance += iblIrradiance;
#endif
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`,S0=`#ifdef USE_LIGHT_PROBES_GRID
uniform highp sampler3D probesSH;
uniform vec3 probesMin;
uniform vec3 probesMax;
uniform vec3 probesResolution;
vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
vec3 res = probesResolution;
vec3 gridRange = probesMax - probesMin;
vec3 resMinusOne = res - 1.0;
vec3 probeSpacing = gridRange / resMinusOne;
vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5;
vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 );
uvw = uvw * resMinusOne / res + 0.5 / res;
float nz = res.z;
float paddedSlices = nz + 2.0;
float atlasDepth = 7.0 * paddedSlices;
float uvZBase = uvw.z * nz + 1.0;
vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) );
vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) );
vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) );
vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) );
vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) );
vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) );
vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) );
vec3 c0 = s0.xyz;
vec3 c1 = vec3( s0.w, s1.xy );
vec3 c2 = vec3( s1.zw, s2.x );
vec3 c3 = s2.yzw;
vec3 c4 = s3.xyz;
vec3 c5 = vec3( s3.w, s4.xy );
vec3 c6 = vec3( s4.zw, s5.x );
vec3 c7 = s5.yzw;
vec3 c8 = s6.xyz;
float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z;
vec3 result = c0 * 0.886227;
result += c1 * 2.0 * 0.511664 * y;
result += c2 * 2.0 * 0.511664 * z;
result += c3 * 2.0 * 0.511664 * x;
result += c4 * 2.0 * 0.429043 * x * y;
result += c5 * 2.0 * 0.429043 * y * z;
result += c6 * ( 0.743125 * z * z - 0.247708 );
result += c7 * 2.0 * 0.429043 * x * z;
result += c8 * 0.429043 * ( x * x - y * y );
return max( result, vec3( 0.0 ) );
}
#endif`,w0=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`,E0=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
#endif`,T0=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
varying float vFragDepth;
varying float vIsPerspective;
#endif`,A0=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
vFragDepth = 1.0 + gl_Position.w;
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#endif`,C0=`#ifdef USE_MAP
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
#ifdef DECODE_VIDEO_TEXTURE
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
#endif
diffuseColor *= sampledDiffuseColor;
#endif`,R0=`#ifdef USE_MAP
uniform sampler2D map;
#endif`,P0=`#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`,I0=`#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`,L0=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
metalnessFactor *= texelMetalness.b;
#endif`,D0=`#ifdef USE_METALNESSMAP
uniform sampler2D metalnessMap;
#endif`,N0=`#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`,F0=`#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`,k0=`#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`,O0=`#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`,U0=`#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`,B0=`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;`,z0=`#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;
#if defined( USE_PACKED_NORMALMAP )
mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) );
#endif
mapN.xy *= normalScale;
normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
#endif`,G0=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,V0=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,H0=`#ifndef FLAT_SHADED
vNormal = normalize( transformedNormal );
#ifdef USE_TANGENT
vTangent = normalize( transformedTangent );
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
#endif
#endif`,W0=`#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`,X0=`#ifdef USE_CLEARCOAT
vec3 clearcoatNormal = nonPerturbedNormal;
#endif`,q0=`#ifdef USE_CLEARCOAT_NORMALMAP
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
clearcoatMapN.xy *= clearcoatNormalScale;
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
#endif`,Y0=`#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`,Z0=`#ifdef USE_IRIDESCENCEMAP
uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform sampler2D iridescenceThicknessMap;
#endif`,$0=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,K0=`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 ) {
#ifdef USE_REVERSED_DEPTH_BUFFER
return depth * ( far - near ) - far;
#else
return depth * ( near - far ) - near;
#endif
}
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 ) {
#ifdef USE_REVERSED_DEPTH_BUFFER
return ( near * far ) / ( ( near - far ) * depth - near );
#else
return ( near * far ) / ( ( far - near ) * depth - far );
#endif
}`,J0=`#ifdef PREMULTIPLIED_ALPHA
gl_FragColor.rgb *= gl_FragColor.a;
#endif`,j0=`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;`,Q0=`#ifdef DITHERING
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`,tx=`#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`,ex=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
roughnessFactor *= texelRoughness.g;
#endif`,nx=`#ifdef USE_ROUGHNESSMAP
uniform sampler2D roughnessMap;
#endif`,ix=`#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 ) * PI2;
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;
#ifdef USE_REVERSED_DEPTH_BUFFER
shadowCoord.z -= shadowBias;
#else
shadowCoord.z += shadowBias;
#endif
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;
#ifdef USE_REVERSED_DEPTH_BUFFER
shadowCoord.z -= shadowBias;
#else
shadowCoord.z += shadowBias;
#endif
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 ) {
#ifdef USE_REVERSED_DEPTH_BUFFER
float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
dp -= shadowBias;
#else
float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
dp += shadowBias;
#endif
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 ) * PI2;
vec2 sample0 = vogelDiskSample( 0, 5, phi );
vec2 sample1 = vogelDiskSample( 1, 5, phi );
vec2 sample2 = vogelDiskSample( 2, 5, phi );
vec2 sample3 = vogelDiskSample( 3, 5, phi );
vec2 sample4 = vogelDiskSample( 4, 5, phi );
shadow = (
texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) +
texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) +
texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) +
texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) +
texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.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 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;
vec3 bd3D = normalize( lightToPosition );
float depth = textureCube( shadowMap, bd3D ).r;
#ifdef USE_REVERSED_DEPTH_BUFFER
depth = 1.0 - depth;
#endif
shadow = step( dp, depth );
}
return mix( 1.0, shadow, shadowIntensity );
}
#endif
#endif
#endif`,sx=`#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`,rx=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
#ifdef HAS_NORMAL
vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
#else
vec3 shadowWorldNormal = vec3( 0.0 );
#endif
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`,ox=`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;
}`,ax=`#ifdef USE_SKINNING
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`,lx=`#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`,cx=`#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`,hx=`#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`,ux=`float specularStrength;
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
#endif`,dx=`#ifdef USE_SPECULARMAP
uniform sampler2D specularMap;
#endif`,fx=`#if defined( TONE_MAPPING )
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`,px=`#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; }`,mx=`#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`,gx=`#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`,xx=`#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`,vx=`#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`,_x=`#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`,yx=`#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`,bx=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
gl_Position = vec4( position.xy, 1.0, 1.0 );
}`,Mx=`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>
}`,Sx=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,wx=`#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
uniform sampler2D envMap;
#endif
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 * vWorldDirection );
#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>
}`,Ex=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,Tx=`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>
}`,Ax=`#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;
}`,Cx=`#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
}`,Rx=`#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;
}`,Px=`#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 );
}`,Ix=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
}`,Lx=`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>
}`,Dx=`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>
}`,Nx=`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>
}`,Fx=`#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>
}`,kx=`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>
}`,Ox=`#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>
}`,Ux=`#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 <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <envmap_physical_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>
}`,Bx=`#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;
}`,zx=`#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>
}`,Gx=`#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
}`,Vx=`#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
}`,Hx=`#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>
}`,Wx=`#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 <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <envmap_physical_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>
}`,Xx=`#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
}`,qx=`#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>
}`,Yx=`#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>
}`,Zx=`#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>
}`,$x=`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>
}`,Kx=`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>
}`,Jx=`#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>
}`,jx=`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>
#include <premultiplied_alpha_fragment>
}`,Qx=`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>
}`,tv=`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>
}`,zt={alphahash_fragment:bg,alphahash_pars_fragment:Mg,alphamap_fragment:Sg,alphamap_pars_fragment:wg,alphatest_fragment:Eg,alphatest_pars_fragment:Tg,aomap_fragment:Ag,aomap_pars_fragment:Cg,batching_pars_vertex:Rg,batching_vertex:Pg,begin_vertex:Ig,beginnormal_vertex:Lg,bsdfs:Dg,iridescence_fragment:Ng,bumpmap_pars_fragment:Fg,clipping_planes_fragment:kg,clipping_planes_pars_fragment:Og,clipping_planes_pars_vertex:Ug,clipping_planes_vertex:Bg,color_fragment:zg,color_pars_fragment:Gg,color_pars_vertex:Vg,color_vertex:Hg,common:Wg,cube_uv_reflection_fragment:Xg,defaultnormal_vertex:qg,displacementmap_pars_vertex:Yg,displacementmap_vertex:Zg,emissivemap_fragment:$g,emissivemap_pars_fragment:Kg,colorspace_fragment:Jg,colorspace_pars_fragment:jg,envmap_fragment:Qg,envmap_common_pars_fragment:t0,envmap_pars_fragment:e0,envmap_pars_vertex:n0,envmap_physical_pars_fragment:f0,envmap_vertex:i0,fog_vertex:s0,fog_pars_vertex:r0,fog_fragment:o0,fog_pars_fragment:a0,gradientmap_pars_fragment:l0,lightmap_pars_fragment:c0,lights_lambert_fragment:h0,lights_lambert_pars_fragment:u0,lights_pars_begin:d0,lights_toon_fragment:p0,lights_toon_pars_fragment:m0,lights_phong_fragment:g0,lights_phong_pars_fragment:x0,lights_physical_fragment:v0,lights_physical_pars_fragment:_0,lights_fragment_begin:y0,lights_fragment_maps:b0,lights_fragment_end:M0,lightprobes_pars_fragment:S0,logdepthbuf_fragment:w0,logdepthbuf_pars_fragment:E0,logdepthbuf_pars_vertex:T0,logdepthbuf_vertex:A0,map_fragment:C0,map_pars_fragment:R0,map_particle_fragment:P0,map_particle_pars_fragment:I0,metalnessmap_fragment:L0,metalnessmap_pars_fragment:D0,morphinstance_vertex:N0,morphcolor_vertex:F0,morphnormal_vertex:k0,morphtarget_pars_vertex:O0,morphtarget_vertex:U0,normal_fragment_begin:B0,normal_fragment_maps:z0,normal_pars_fragment:G0,normal_pars_vertex:V0,normal_vertex:H0,normalmap_pars_fragment:W0,clearcoat_normal_fragment_begin:X0,clearcoat_normal_fragment_maps:q0,clearcoat_pars_fragment:Y0,iridescence_pars_fragment:Z0,opaque_fragment:$0,packing:K0,premultiplied_alpha_fragment:J0,project_vertex:j0,dithering_fragment:Q0,dithering_pars_fragment:tx,roughnessmap_fragment:ex,roughnessmap_pars_fragment:nx,shadowmap_pars_fragment:ix,shadowmap_pars_vertex:sx,shadowmap_vertex:rx,shadowmask_pars_fragment:ox,skinbase_vertex:ax,skinning_pars_vertex:lx,skinning_vertex:cx,skinnormal_vertex:hx,specularmap_fragment:ux,specularmap_pars_fragment:dx,tonemapping_fragment:fx,tonemapping_pars_fragment:px,transmission_fragment:mx,transmission_pars_fragment:gx,uv_pars_fragment:xx,uv_pars_vertex:vx,uv_vertex:_x,worldpos_vertex:yx,background_vert:bx,background_frag:Mx,backgroundCube_vert:Sx,backgroundCube_frag:wx,cube_vert:Ex,cube_frag:Tx,depth_vert:Ax,depth_frag:Cx,distance_vert:Rx,distance_frag:Px,equirect_vert:Ix,equirect_frag:Lx,linedashed_vert:Dx,linedashed_frag:Nx,meshbasic_vert:Fx,meshbasic_frag:kx,meshlambert_vert:Ox,meshlambert_frag:Ux,meshmatcap_vert:Bx,meshmatcap_frag:zx,meshnormal_vert:Gx,meshnormal_frag:Vx,meshphong_vert:Hx,meshphong_frag:Wx,meshphysical_vert:Xx,meshphysical_frag:qx,meshtoon_vert:Yx,meshtoon_frag:Zx,points_vert:$x,points_frag:Kx,shadow_vert:Jx,shadow_frag:jx,sprite_vert:Qx,sprite_frag:tv},lt={common:{diffuse:{value:new mt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Dt},alphaMap:{value:null},alphaMapTransform:{value:new Dt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Dt}},envmap:{envMap:{value:null},envMapRotation:{value:new Dt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Dt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Dt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Dt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Dt},normalScale:{value:new Tt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Dt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Dt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Dt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Dt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new mt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new L},probesMax:{value:new L},probesResolution:{value:new L}},points:{diffuse:{value:new mt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Dt},alphaTest:{value:0},uvTransform:{value:new Dt}},sprite:{diffuse:{value:new mt(16777215)},opacity:{value:1},center:{value:new Tt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Dt},alphaMap:{value:null},alphaMapTransform:{value:new Dt},alphaTest:{value:0}}},Wn={basic:{uniforms:Ye([lt.common,lt.specularmap,lt.envmap,lt.aomap,lt.lightmap,lt.fog]),vertexShader:zt.meshbasic_vert,fragmentShader:zt.meshbasic_frag},lambert:{uniforms:Ye([lt.common,lt.specularmap,lt.envmap,lt.aomap,lt.lightmap,lt.emissivemap,lt.bumpmap,lt.normalmap,lt.displacementmap,lt.fog,lt.lights,{emissive:{value:new mt(0)},envMapIntensity:{value:1}}]),vertexShader:zt.meshlambert_vert,fragmentShader:zt.meshlambert_frag},phong:{uniforms:Ye([lt.common,lt.specularmap,lt.envmap,lt.aomap,lt.lightmap,lt.emissivemap,lt.bumpmap,lt.normalmap,lt.displacementmap,lt.fog,lt.lights,{emissive:{value:new mt(0)},specular:{value:new mt(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:zt.meshphong_vert,fragmentShader:zt.meshphong_frag},standard:{uniforms:Ye([lt.common,lt.envmap,lt.aomap,lt.lightmap,lt.emissivemap,lt.bumpmap,lt.normalmap,lt.displacementmap,lt.roughnessmap,lt.metalnessmap,lt.fog,lt.lights,{emissive:{value:new mt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:zt.meshphysical_vert,fragmentShader:zt.meshphysical_frag},toon:{uniforms:Ye([lt.common,lt.aomap,lt.lightmap,lt.emissivemap,lt.bumpmap,lt.normalmap,lt.displacementmap,lt.gradientmap,lt.fog,lt.lights,{emissive:{value:new mt(0)}}]),vertexShader:zt.meshtoon_vert,fragmentShader:zt.meshtoon_frag},matcap:{uniforms:Ye([lt.common,lt.bumpmap,lt.normalmap,lt.displacementmap,lt.fog,{matcap:{value:null}}]),vertexShader:zt.meshmatcap_vert,fragmentShader:zt.meshmatcap_frag},points:{uniforms:Ye([lt.points,lt.fog]),vertexShader:zt.points_vert,fragmentShader:zt.points_frag},dashed:{uniforms:Ye([lt.common,lt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:zt.linedashed_vert,fragmentShader:zt.linedashed_frag},depth:{uniforms:Ye([lt.common,lt.displacementmap]),vertexShader:zt.depth_vert,fragmentShader:zt.depth_frag},normal:{uniforms:Ye([lt.common,lt.bumpmap,lt.normalmap,lt.displacementmap,{opacity:{value:1}}]),vertexShader:zt.meshnormal_vert,fragmentShader:zt.meshnormal_frag},sprite:{uniforms:Ye([lt.sprite,lt.fog]),vertexShader:zt.sprite_vert,fragmentShader:zt.sprite_frag},background:{uniforms:{uvTransform:{value:new Dt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:zt.background_vert,fragmentShader:zt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Dt}},vertexShader:zt.backgroundCube_vert,fragmentShader:zt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:zt.cube_vert,fragmentShader:zt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:zt.equirect_vert,fragmentShader:zt.equirect_frag},distance:{uniforms:Ye([lt.common,lt.displacementmap,{referencePosition:{value:new L},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:zt.distance_vert,fragmentShader:zt.distance_frag},shadow:{uniforms:Ye([lt.lights,lt.fog,{color:{value:new mt(0)},opacity:{value:1}}]),vertexShader:zt.shadow_vert,fragmentShader:zt.shadow_frag}};Wn.physical={uniforms:Ye([Wn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Dt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Dt},clearcoatNormalScale:{value:new Tt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Dt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Dt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Dt},sheen:{value:0},sheenColor:{value:new mt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Dt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Dt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Dt},transmissionSamplerSize:{value:new Tt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Dt},attenuationDistance:{value:0},attenuationColor:{value:new mt(0)},specularColor:{value:new mt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Dt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Dt},anisotropyVector:{value:new Tt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Dt}}]),vertexShader:zt.meshphysical_vert,fragmentShader:zt.meshphysical_frag};var nl={r:0,b:0,g:0},ev=new ge,Qd=new Dt;Qd.set(-1,0,0,0,1,0,0,0,1);function nv(i,t,e,n,s,r){let o=new mt(0),a=s===!0?0:1,l,c,u=null,d=0,h=null;function f(v){let M=v.isScene===!0?v.background:null;if(M&&M.isTexture){let b=v.backgroundBlurriness>0;M=t.get(M,b)}return M}function m(v){let M=!1,b=f(v);b===null?g(o,a):b&&b.isColor&&(g(b,1),M=!0);let E=i.xr.getEnvironmentBlendMode();E==="additive"?e.buffers.color.setClear(0,0,0,1,r):E==="alpha-blend"&&e.buffers.color.setClear(0,0,0,0,r),(i.autoClear||M)&&(e.buffers.depth.setTest(!0),e.buffers.depth.setMask(!0),e.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function x(v,M){let b=f(M);b&&(b.isCubeTexture||b.mapping===Er)?(c===void 0&&(c=new Xe(new Ts(1,1,1),new ue({name:"BackgroundCubeMaterial",uniforms:Ji(Wn.backgroundCube.uniforms),vertexShader:Wn.backgroundCube.vertexShader,fragmentShader:Wn.backgroundCube.fragmentShader,side:$e,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(E,w,C){this.matrixWorld.copyPosition(C.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=b,c.material.uniforms.backgroundBlurriness.value=M.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=M.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(ev.makeRotationFromEuler(M.backgroundRotation)).transpose(),b.isCubeTexture&&b.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(Qd),c.material.toneMapped=Vt.getTransfer(b.colorSpace)!==Jt,(u!==b||d!==b.version||h!==i.toneMapping)&&(c.material.needsUpdate=!0,u=b,d=b.version,h=i.toneMapping),c.layers.enableAll(),v.unshift(c,c.geometry,c.material,0,0,null)):b&&b.isTexture&&(l===void 0&&(l=new Xe(new dr(2,2),new ue({name:"BackgroundMaterial",uniforms:Ji(Wn.background.uniforms),vertexShader:Wn.background.vertexShader,fragmentShader:Wn.background.fragmentShader,side:ei,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=b,l.material.uniforms.backgroundIntensity.value=M.backgroundIntensity,l.material.toneMapped=Vt.getTransfer(b.colorSpace)!==Jt,b.matrixAutoUpdate===!0&&b.updateMatrix(),l.material.uniforms.uvTransform.value.copy(b.matrix),(u!==b||d!==b.version||h!==i.toneMapping)&&(l.material.needsUpdate=!0,u=b,d=b.version,h=i.toneMapping),l.layers.enableAll(),v.unshift(l,l.geometry,l.material,0,0,null))}function g(v,M){v.getRGB(nl,sh(i)),e.buffers.color.setClear(nl.r,nl.g,nl.b,M,r)}function p(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return o},setClearColor:function(v,M=1){o.set(v),a=M,g(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(v){a=v,g(o,a)},render:m,addToRenderList:x,dispose:p}}function iv(i,t){let e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=h(null),r=s,o=!1;function a(R,D,W,H,k){let B=!1,U=d(R,H,W,D);r!==U&&(r=U,c(r.object)),B=f(R,H,W,k),B&&m(R,H,W,k),k!==null&&t.update(k,i.ELEMENT_ARRAY_BUFFER),(B||o)&&(o=!1,b(R,D,W,H),k!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get(k).buffer))}function l(){return i.createVertexArray()}function c(R){return i.bindVertexArray(R)}function u(R){return i.deleteVertexArray(R)}function d(R,D,W,H){let k=H.wireframe===!0,B=n[D.id];B===void 0&&(B={},n[D.id]=B);let U=R.isInstancedMesh===!0?R.id:0,j=B[U];j===void 0&&(j={},B[U]=j);let Q=j[W.id];Q===void 0&&(Q={},j[W.id]=Q);let ct=Q[k];return ct===void 0&&(ct=h(l()),Q[k]=ct),ct}function h(R){let D=[],W=[],H=[];for(let k=0;k<e;k++)D[k]=0,W[k]=0,H[k]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:D,enabledAttributes:W,attributeDivisors:H,object:R,attributes:{},index:null}}function f(R,D,W,H){let k=r.attributes,B=D.attributes,U=0,j=W.getAttributes();for(let Q in j)if(j[Q].location>=0){let _t=k[Q],wt=B[Q];if(wt===void 0&&(Q==="instanceMatrix"&&R.instanceMatrix&&(wt=R.instanceMatrix),Q==="instanceColor"&&R.instanceColor&&(wt=R.instanceColor)),_t===void 0||_t.attribute!==wt||wt&&_t.data!==wt.data)return!0;U++}return r.attributesNum!==U||r.index!==H}function m(R,D,W,H){let k={},B=D.attributes,U=0,j=W.getAttributes();for(let Q in j)if(j[Q].location>=0){let _t=B[Q];_t===void 0&&(Q==="instanceMatrix"&&R.instanceMatrix&&(_t=R.instanceMatrix),Q==="instanceColor"&&R.instanceColor&&(_t=R.instanceColor));let wt={};wt.attribute=_t,_t&&_t.data&&(wt.data=_t.data),k[Q]=wt,U++}r.attributes=k,r.attributesNum=U,r.index=H}function x(){let R=r.newAttributes;for(let D=0,W=R.length;D<W;D++)R[D]=0}function g(R){p(R,0)}function p(R,D){let W=r.newAttributes,H=r.enabledAttributes,k=r.attributeDivisors;W[R]=1,H[R]===0&&(i.enableVertexAttribArray(R),H[R]=1),k[R]!==D&&(i.vertexAttribDivisor(R,D),k[R]=D)}function v(){let R=r.newAttributes,D=r.enabledAttributes;for(let W=0,H=D.length;W<H;W++)D[W]!==R[W]&&(i.disableVertexAttribArray(W),D[W]=0)}function M(R,D,W,H,k,B,U){U===!0?i.vertexAttribIPointer(R,D,W,k,B):i.vertexAttribPointer(R,D,W,H,k,B)}function b(R,D,W,H){x();let k=H.attributes,B=W.getAttributes(),U=D.defaultAttributeValues;for(let j in B){let Q=B[j];if(Q.location>=0){let ct=k[j];if(ct===void 0&&(j==="instanceMatrix"&&R.instanceMatrix&&(ct=R.instanceMatrix),j==="instanceColor"&&R.instanceColor&&(ct=R.instanceColor)),ct!==void 0){let _t=ct.normalized,wt=ct.itemSize,Zt=t.get(ct);if(Zt===void 0)continue;let Qt=Zt.buffer,Ut=Zt.type,$=Zt.bytesPerElement,dt=Ut===i.INT||Ut===i.UNSIGNED_INT||ct.gpuType===va;if(ct.isInterleavedBufferAttribute){let it=ct.data,Ct=it.stride,Nt=ct.offset;if(it.isInstancedInterleavedBuffer){for(let It=0;It<Q.locationSize;It++)p(Q.location+It,it.meshPerAttribute);R.isInstancedMesh!==!0&&H._maxInstanceCount===void 0&&(H._maxInstanceCount=it.meshPerAttribute*it.count)}else for(let It=0;It<Q.locationSize;It++)g(Q.location+It);i.bindBuffer(i.ARRAY_BUFFER,Qt);for(let It=0;It<Q.locationSize;It++)M(Q.location+It,wt/Q.locationSize,Ut,_t,Ct*$,(Nt+wt/Q.locationSize*It)*$,dt)}else{if(ct.isInstancedBufferAttribute){for(let it=0;it<Q.locationSize;it++)p(Q.location+it,ct.meshPerAttribute);R.isInstancedMesh!==!0&&H._maxInstanceCount===void 0&&(H._maxInstanceCount=ct.meshPerAttribute*ct.count)}else for(let it=0;it<Q.locationSize;it++)g(Q.location+it);i.bindBuffer(i.ARRAY_BUFFER,Qt);for(let it=0;it<Q.locationSize;it++)M(Q.location+it,wt/Q.locationSize,Ut,_t,wt*$,wt/Q.locationSize*it*$,dt)}}else if(U!==void 0){let _t=U[j];if(_t!==void 0)switch(_t.length){case 2:i.vertexAttrib2fv(Q.location,_t);break;case 3:i.vertexAttrib3fv(Q.location,_t);break;case 4:i.vertexAttrib4fv(Q.location,_t);break;default:i.vertexAttrib1fv(Q.location,_t)}}}}v()}function E(){A();for(let R in n){let D=n[R];for(let W in D){let H=D[W];for(let k in H){let B=H[k];for(let U in B)u(B[U].object),delete B[U];delete H[k]}}delete n[R]}}function w(R){if(n[R.id]===void 0)return;let D=n[R.id];for(let W in D){let H=D[W];for(let k in H){let B=H[k];for(let U in B)u(B[U].object),delete B[U];delete H[k]}}delete n[R.id]}function C(R){for(let D in n){let W=n[D];for(let H in W){let k=W[H];if(k[R.id]===void 0)continue;let B=k[R.id];for(let U in B)u(B[U].object),delete B[U];delete k[R.id]}}}function _(R){for(let D in n){let W=n[D],H=R.isInstancedMesh===!0?R.id:0,k=W[H];if(k!==void 0){for(let B in k){let U=k[B];for(let j in U)u(U[j].object),delete U[j];delete k[B]}delete W[H],Object.keys(W).length===0&&delete n[D]}}}function A(){P(),o=!0,r!==s&&(r=s,c(r.object))}function P(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:a,reset:A,resetDefaultState:P,dispose:E,releaseStatesOfGeometry:w,releaseStatesOfObject:_,releaseStatesOfProgram:C,initAttributes:x,enableAttribute:g,disableUnusedAttributes:v}}function sv(i,t,e){let n;function s(l){n=l}function r(l,c){i.drawArrays(n,l,c),e.update(c,n,1)}function o(l,c,u){u!==0&&(i.drawArraysInstanced(n,l,c,u),e.update(c,n,u))}function a(l,c,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,c,0,u);let h=0;for(let f=0;f<u;f++)h+=c[f];e.update(h,n,1)}this.setMode=s,this.render=r,this.renderInstances=o,this.renderMultiDraw=a}function rv(i,t,e,n){let s;function r(){if(s!==void 0)return s;if(t.has("EXT_texture_filter_anisotropic")===!0){let C=t.get("EXT_texture_filter_anisotropic");s=i.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function o(C){return!(C!==bn&&n.convert(C)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(C){let _=C===qe&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(C!==fn&&n.convert(C)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&C!==Pn&&!_)}function l(C){if(C==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=e.precision!==void 0?e.precision:"highp",u=l(c);u!==c&&(At("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);let d=e.logarithmicDepthBuffer===!0,h=e.reversedDepthBuffer===!0&&t.has("EXT_clip_control");e.reversedDepthBuffer===!0&&h===!1&&At("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let f=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),m=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=i.getParameter(i.MAX_TEXTURE_SIZE),g=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),p=i.getParameter(i.MAX_VERTEX_ATTRIBS),v=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),M=i.getParameter(i.MAX_VARYING_VECTORS),b=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),E=i.getParameter(i.MAX_SAMPLES),w=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:h,maxTextures:f,maxVertexTextures:m,maxTextureSize:x,maxCubemapSize:g,maxAttributes:p,maxVertexUniforms:v,maxVaryings:M,maxFragmentUniforms:b,maxSamples:E,samples:w}}function ov(i){let t=this,e=null,n=0,s=!1,r=!1,o=new _n,a=new Dt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){let f=d.length!==0||h||n!==0||s;return s=h,n=d.length,f},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,h){e=u(d,h,0)},this.setState=function(d,h,f){let m=d.clippingPlanes,x=d.clipIntersection,g=d.clipShadows,p=i.get(d);if(!s||m===null||m.length===0||r&&!g)r?u(null):c();else{let v=r?0:n,M=v*4,b=p.clippingState||null;l.value=b,b=u(m,h,M,f);for(let E=0;E!==M;++E)b[E]=e[E];p.clippingState=b,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=v}};function c(){l.value!==e&&(l.value=e,l.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function u(d,h,f,m){let x=d!==null?d.length:0,g=null;if(x!==0){if(g=l.value,m!==!0||g===null){let p=f+x*4,v=h.matrixWorldInverse;a.getNormalMatrix(v),(g===null||g.length<p)&&(g=new Float32Array(p));for(let M=0,b=f;M!==x;++M,b+=4)o.copy(d[M]).applyMatrix4(v,a),o.normal.toArray(g,b),g[b+3]=o.constant}l.value=g,l.needsUpdate=!0}return t.numPlanes=x,t.numIntersection=0,g}}var Oi=4,Pd=[.125,.215,.35,.446,.526,.582],ji=20,av=256,Dr=new oi,Id=new mt,fh=null,ph=0,mh=0,gh=!1,lv=new L,sl=class{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(t,e=0,n=.1,s=100,r={}){let{size:o=256,position:a=lv}=r;fh=this._renderer.getRenderTarget(),ph=this._renderer.getActiveCubeFace(),mh=this._renderer.getActiveMipmapLevel(),gh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(o);let l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(t,n,s,l,a),e>0&&this._blur(l,0,0,e),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Nd(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Dd(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodMeshes.length;t++)this._lodMeshes[t].geometry.dispose()}_cleanup(t){this._renderer.setRenderTarget(fh,ph,mh),this._renderer.xr.enabled=gh,t.scissorTest=!1,Ls(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===Di||t.mapping===Ki?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),fh=this._renderer.getRenderTarget(),ph=this._renderer.getActiveCubeFace(),mh=this._renderer.getActiveMipmapLevel(),gh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:Ue,minFilter:Ue,generateMipmaps:!1,type:qe,format:bn,colorSpace:er,depthBuffer:!1},s=Ld(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Ld(t,e,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=cv(r)),this._blurMaterial=uv(r,t,e),this._ggxMaterial=hv(r,t,e)}return s}_compileMaterial(t){let e=new Xe(new he,t);this._renderer.compile(e,Dr)}_sceneToCubeUV(t,e,n,s,r){let l=new We(90,1,e,n),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],d=this._renderer,h=d.autoClear,f=d.toneMapping;d.getClearColor(Id),d.toneMapping=dn,d.autoClear=!1,d.state.buffers.depth.getReversed()&&(d.setRenderTarget(s),d.clearDepth(),d.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Xe(new Ts,new ii({name:"PMREM.Background",side:$e,depthWrite:!1,depthTest:!1})));let x=this._backgroundBox,g=x.material,p=!1,v=t.background;v?v.isColor&&(g.color.copy(v),t.background=null,p=!0):(g.color.copy(Id),p=!0);for(let M=0;M<6;M++){let b=M%3;b===0?(l.up.set(0,c[M],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x+u[M],r.y,r.z)):b===1?(l.up.set(0,0,c[M]),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y+u[M],r.z)):(l.up.set(0,c[M],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y,r.z+u[M]));let E=this._cubeSize;Ls(s,b*E,M>2?E:0,E,E),d.setRenderTarget(s),p&&d.render(x,l),d.render(t,l)}d.toneMapping=f,d.autoClear=h,t.background=v}_textureToCubeUV(t,e){let n=this._renderer,s=t.mapping===Di||t.mapping===Ki;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Nd()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Dd());let r=s?this._cubemapMaterial:this._equirectMaterial,o=this._lodMeshes[0];o.material=r;let a=r.uniforms;a.envMap.value=t;let l=this._cubeSize;Ls(e,0,0,3*l,2*l),n.setRenderTarget(e),n.render(o,Dr)}_applyPMREM(t){let e=this._renderer,n=e.autoClear;e.autoClear=!1;let s=this._lodMeshes.length;for(let r=1;r<s;r++)this._applyGGXFilter(t,r-1,r);e.autoClear=n}_applyGGXFilter(t,e,n){let s=this._renderer,r=this._pingPongRenderTarget,o=this._ggxMaterial,a=this._lodMeshes[n];a.material=o;let l=o.uniforms,c=n/(this._lodMeshes.length-1),u=e/(this._lodMeshes.length-1),d=Math.sqrt(c*c-u*u),h=0+c*1.25,f=d*h,{_lodMax:m}=this,x=this._sizeLods[n],g=3*x*(n>m-Oi?n-m+Oi:0),p=4*(this._cubeSize-x);l.envMap.value=t.texture,l.roughness.value=f,l.mipInt.value=m-e,Ls(r,g,p,3*x,2*x),s.setRenderTarget(r),s.render(a,Dr),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=m-n,Ls(t,g,p,3*x,2*x),s.setRenderTarget(t),s.render(a,Dr)}_blur(t,e,n,s,r){let o=this._pingPongRenderTarget;this._halfBlur(t,o,e,n,s,"latitudinal",r),this._halfBlur(o,t,n,n,s,"longitudinal",r)}_halfBlur(t,e,n,s,r,o,a){let l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&Pt("blur direction must be either latitudinal or longitudinal!");let u=3,d=this._lodMeshes[s];d.material=c;let h=c.uniforms,f=this._sizeLods[n]-1,m=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*ji-1),x=r/m,g=isFinite(r)?1+Math.floor(u*x):ji;g>ji&&At(`sigmaRadians, ${r}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${ji}`);let p=[],v=0;for(let C=0;C<ji;++C){let _=C/x,A=Math.exp(-_*_/2);p.push(A),C===0?v+=A:C<g&&(v+=2*A)}for(let C=0;C<p.length;C++)p[C]=p[C]/v;h.envMap.value=t.texture,h.samples.value=g,h.weights.value=p,h.latitudinal.value=o==="latitudinal",a&&(h.poleAxis.value=a);let{_lodMax:M}=this;h.dTheta.value=m,h.mipInt.value=M-n;let b=this._sizeLods[s],E=3*b*(s>M-Oi?s-M+Oi:0),w=4*(this._cubeSize-b);Ls(e,E,w,3*b,2*b),l.setRenderTarget(e),l.render(d,Dr)}};function cv(i){let t=[],e=[],n=[],s=i,r=i-Oi+1+Pd.length;for(let o=0;o<r;o++){let a=Math.pow(2,s);t.push(a);let l=1/a;o>i-Oi?l=Pd[o-i+Oi-1]:o===0&&(l=0),e.push(l);let c=1/(a-2),u=-c,d=1+c,h=[u,u,d,u,d,d,u,u,d,d,u,d],f=6,m=6,x=3,g=2,p=1,v=new Float32Array(x*m*f),M=new Float32Array(g*m*f),b=new Float32Array(p*m*f);for(let w=0;w<f;w++){let C=w%3*2/3-1,_=w>2?0:-1,A=[C,_,0,C+2/3,_,0,C+2/3,_+1,0,C,_,0,C+2/3,_+1,0,C,_+1,0];v.set(A,x*m*w),M.set(h,g*m*w);let P=[w,w,w,w,w,w];b.set(P,p*m*w)}let E=new he;E.setAttribute("position",new Yt(v,x)),E.setAttribute("uv",new Yt(M,g)),E.setAttribute("faceIndex",new Yt(b,p)),n.push(new Xe(E,null)),s>Oi&&s--}return{lodMeshes:n,sizeLods:t,sigmas:e}}function Ld(i,t,e){let n=new Ce(i,t,e);return n.texture.mapping=Er,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Ls(i,t,e,n,s){i.viewport.set(t,e,n,s),i.scissor.set(t,e,n,s)}function hv(i,t,e){return new ue({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:av,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:ol(),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 4.1: Orthonormal basis
vec3 T1 = vec3(1.0, 0.0, 0.0);
vec3 T2 = cross(V, 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 + V.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)) * V;
// 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:yn,depthTest:!1,depthWrite:!1})}function uv(i,t,e){let n=new Float32Array(ji),s=new L(0,1,0);return new ue({name:"SphericalGaussianBlur",defines:{n:ji,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:ol(),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:yn,depthTest:!1,depthWrite:!1})}function Dd(){return new ue({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ol(),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:yn,depthTest:!1,depthWrite:!1})}function Nd(){return new ue({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ol(),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:yn,depthTest:!1,depthWrite:!1})}function ol(){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 );
}
`}var rl=class extends Ce{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;let n={width:t,height:t,depth:1},s=[n,n,n,n,n,n];this.texture=new hr(s),this._setTextureOptions(e),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;let n={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 );
}
`},s=new Ts(5,5,5),r=new ue({name:"CubemapFromEquirect",uniforms:Ji(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:$e,blending:yn});r.uniforms.tEquirect.value=e;let o=new Xe(s,r),a=e.minFilter;return e.minFilter===Ni&&(e.minFilter=Ue),new ua(1,10,this).update(t,o),e.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(t,e=!0,n=!0,s=!0){let r=t.getRenderTarget();for(let o=0;o<6;o++)t.setRenderTarget(this,o),t.clear(e,n,s);t.setRenderTarget(r)}};function dv(i){let t=new WeakMap,e=new WeakMap,n=null;function s(h,f=!1){return h==null?null:f?o(h):r(h)}function r(h){if(h&&h.isTexture){let f=h.mapping;if(f===ma||f===ga)if(t.has(h)){let m=t.get(h).texture;return a(m,h.mapping)}else{let m=h.image;if(m&&m.height>0){let x=new rl(m.height);return x.fromEquirectangularTexture(i,h),t.set(h,x),h.addEventListener("dispose",c),a(x.texture,h.mapping)}else return null}}return h}function o(h){if(h&&h.isTexture){let f=h.mapping,m=f===ma||f===ga,x=f===Di||f===Ki;if(m||x){let g=e.get(h),p=g!==void 0?g.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==p)return n===null&&(n=new sl(i)),g=m?n.fromEquirectangular(h,g):n.fromCubemap(h,g),g.texture.pmremVersion=h.pmremVersion,e.set(h,g),g.texture;if(g!==void 0)return g.texture;{let v=h.image;return m&&v&&v.height>0||x&&v&&l(v)?(n===null&&(n=new sl(i)),g=m?n.fromEquirectangular(h):n.fromCubemap(h),g.texture.pmremVersion=h.pmremVersion,e.set(h,g),h.addEventListener("dispose",u),g.texture):null}}}return h}function a(h,f){return f===ma?h.mapping=Di:f===ga&&(h.mapping=Ki),h}function l(h){let f=0,m=6;for(let x=0;x<m;x++)h[x]!==void 0&&f++;return f===m}function c(h){let f=h.target;f.removeEventListener("dispose",c);let m=t.get(f);m!==void 0&&(t.delete(f),m.dispose())}function u(h){let f=h.target;f.removeEventListener("dispose",u);let m=e.get(f);m!==void 0&&(e.delete(f),m.dispose())}function d(){t=new WeakMap,e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:s,dispose:d}}function fv(i){let t={};function e(n){if(t[n]!==void 0)return t[n];let s=i.getExtension(n);return t[n]=s,s}return{has:function(n){return e(n)!==null},init:function(){e("EXT_color_buffer_float"),e("WEBGL_clip_cull_distance"),e("OES_texture_float_linear"),e("EXT_color_buffer_half_float"),e("WEBGL_multisampled_render_to_texture"),e("WEBGL_render_shared_exponent")},get:function(n){let s=e(n);return s===null&&Wo("WebGLRenderer: "+n+" extension not supported."),s}}}function pv(i,t,e,n){let s={},r=new WeakMap;function o(d){let h=d.target;h.index!==null&&t.remove(h.index);for(let m in h.attributes)t.remove(h.attributes[m]);h.removeEventListener("dispose",o),delete s[h.id];let f=r.get(h);f&&(t.remove(f),r.delete(h)),n.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0&&delete h._maxInstanceCount,e.memory.geometries--}function a(d,h){return s[h.id]===!0||(h.addEventListener("dispose",o),s[h.id]=!0,e.memory.geometries++),h}function l(d){let h=d.attributes;for(let f in h)t.update(h[f],i.ARRAY_BUFFER)}function c(d){let h=[],f=d.index,m=d.attributes.position,x=0;if(m===void 0)return;if(f!==null){let v=f.array;x=f.version;for(let M=0,b=v.length;M<b;M+=3){let E=v[M+0],w=v[M+1],C=v[M+2];h.push(E,w,w,C,C,E)}}else{let v=m.array;x=m.version;for(let M=0,b=v.length/3-1;M<b;M+=3){let E=M+0,w=M+1,C=M+2;h.push(E,w,w,C,C,E)}}let g=new(m.count>=65535?lr:ar)(h,1);g.version=x;let p=r.get(d);p&&t.remove(p),r.set(d,g)}function u(d){let h=r.get(d);if(h){let f=d.index;f!==null&&h.version<f.version&&c(d)}else c(d);return r.get(d)}return{get:a,update:l,getWireframeAttribute:u}}function mv(i,t,e){let n;function s(d){n=d}let r,o;function a(d){r=d.type,o=d.bytesPerElement}function l(d,h){i.drawElements(n,h,r,d*o),e.update(h,n,1)}function c(d,h,f){f!==0&&(i.drawElementsInstanced(n,h,r,d*o,f),e.update(h,n,f))}function u(d,h,f){if(f===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,h,0,r,d,0,f);let x=0;for(let g=0;g<f;g++)x+=h[g];e.update(x,n,1)}this.setMode=s,this.setIndex=a,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function gv(i){let t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,o,a){switch(e.calls++,o){case i.TRIANGLES:e.triangles+=a*(r/3);break;case i.LINES:e.lines+=a*(r/2);break;case i.LINE_STRIP:e.lines+=a*(r-1);break;case i.LINE_LOOP:e.lines+=a*r;break;case i.POINTS:e.points+=a*r;break;default:Pt("WebGLInfo: Unknown draw mode:",o);break}}function s(){e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:s,update:n}}function xv(i,t,e){let n=new WeakMap,s=new xe;function r(o,a,l){let c=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,d=u!==void 0?u.length:0,h=n.get(a);if(h===void 0||h.count!==d){let A=function(){C.dispose(),n.delete(a),a.removeEventListener("dispose",A)};h!==void 0&&h.texture.dispose();let f=a.morphAttributes.position!==void 0,m=a.morphAttributes.normal!==void 0,x=a.morphAttributes.color!==void 0,g=a.morphAttributes.position||[],p=a.morphAttributes.normal||[],v=a.morphAttributes.color||[],M=0;f===!0&&(M=1),m===!0&&(M=2),x===!0&&(M=3);let b=a.attributes.position.count*M,E=1;b>t.maxTextureSize&&(E=Math.ceil(b/t.maxTextureSize),b=t.maxTextureSize);let w=new Float32Array(b*E*4*d),C=new rr(w,b,E,d);C.type=Pn,C.needsUpdate=!0;let _=M*4;for(let P=0;P<d;P++){let R=g[P],D=p[P],W=v[P],H=b*E*4*P;for(let k=0;k<R.count;k++){let B=k*_;f===!0&&(s.fromBufferAttribute(R,k),w[H+B+0]=s.x,w[H+B+1]=s.y,w[H+B+2]=s.z,w[H+B+3]=0),m===!0&&(s.fromBufferAttribute(D,k),w[H+B+4]=s.x,w[H+B+5]=s.y,w[H+B+6]=s.z,w[H+B+7]=0),x===!0&&(s.fromBufferAttribute(W,k),w[H+B+8]=s.x,w[H+B+9]=s.y,w[H+B+10]=s.z,w[H+B+11]=W.itemSize===4?s.w:1)}}h={count:d,texture:C,size:new Tt(b,E)},n.set(a,h),a.addEventListener("dispose",A)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)l.getUniforms().setValue(i,"morphTexture",o.morphTexture,e);else{let f=0;for(let x=0;x<c.length;x++)f+=c[x];let m=a.morphTargetsRelative?1:1-f;l.getUniforms().setValue(i,"morphTargetBaseInfluence",m),l.getUniforms().setValue(i,"morphTargetInfluences",c)}l.getUniforms().setValue(i,"morphTargetsTexture",h.texture,e),l.getUniforms().setValue(i,"morphTargetsTextureSize",h.size)}return{update:r}}function vv(i,t,e,n,s){let r=new WeakMap;function o(c){let u=s.render.frame,d=c.geometry,h=t.get(c,d);if(r.get(h)!==u&&(t.update(h),r.set(h,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),r.get(c)!==u&&(e.update(c.instanceMatrix,i.ARRAY_BUFFER),c.instanceColor!==null&&e.update(c.instanceColor,i.ARRAY_BUFFER),r.set(c,u))),c.isSkinnedMesh){let f=c.skeleton;r.get(f)!==u&&(f.update(),r.set(f,u))}return h}function a(){r=new WeakMap}function l(c){let u=c.target;u.removeEventListener("dispose",l),n.releaseStatesOfObject(u),e.remove(u.instanceMatrix),u.instanceColor!==null&&e.remove(u.instanceColor)}return{update:o,dispose:a}}var _v={[_r]:"LINEAR_TONE_MAPPING",[yr]:"REINHARD_TONE_MAPPING",[br]:"CINEON_TONE_MAPPING",[Li]:"ACES_FILMIC_TONE_MAPPING",[Sr]:"AGX_TONE_MAPPING",[wr]:"NEUTRAL_TONE_MAPPING",[Mr]:"CUSTOM_TONE_MAPPING"};function yv(i,t,e,n,s){let r=new Ce(t,e,{type:i,depthBuffer:n,stencilBuffer:s,depthTexture:n?new ri(t,e):void 0}),o=new Ce(t,e,{type:qe,depthBuffer:!1,stencilBuffer:!1}),a=new he;a.setAttribute("position",new Oe([-1,3,0,-1,-1,0,3,-1,0],3)),a.setAttribute("uv",new Oe([0,2,0,0,2,0],2));let l=new As({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 Xe(a,l),u=new oi(-1,1,1,-1,0,1),d=null,h=null,f=!1,m,x=null,g=[],p=!1;this.setSize=function(v,M){r.setSize(v,M),o.setSize(v,M);for(let b=0;b<g.length;b++){let E=g[b];E.setSize&&E.setSize(v,M)}},this.setEffects=function(v){g=v,p=g.length>0&&g[0].isRenderPass===!0;let M=r.width,b=r.height;for(let E=0;E<g.length;E++){let w=g[E];w.setSize&&w.setSize(M,b)}},this.begin=function(v,M){if(f||v.toneMapping===dn&&g.length===0)return!1;if(x=M,M!==null){let b=M.width,E=M.height;(r.width!==b||r.height!==E)&&this.setSize(b,E)}return p===!1&&v.setRenderTarget(r),m=v.toneMapping,v.toneMapping=dn,!0},this.hasRenderPass=function(){return p},this.end=function(v,M){v.toneMapping=m,f=!0;let b=r,E=o;for(let w=0;w<g.length;w++){let C=g[w];if(C.enabled!==!1&&(C.render(v,E,b,M),C.needsSwap!==!1)){let _=b;b=E,E=_}}if(d!==v.outputColorSpace||h!==v.toneMapping){d=v.outputColorSpace,h=v.toneMapping,l.defines={},Vt.getTransfer(d)===Jt&&(l.defines.SRGB_TRANSFER="");let w=_v[h];w&&(l.defines[w]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=b.texture,v.setRenderTarget(x),v.render(c,u),x=null,f=!1},this.isCompositing=function(){return f},this.dispose=function(){r.depthTexture&&r.depthTexture.dispose(),r.dispose(),o.dispose(),a.dispose(),l.dispose()}}var tf=new je,_h=new ri(1,1),ef=new rr,nf=new Yo,sf=new hr,Fd=[],kd=[],Od=new Float32Array(16),Ud=new Float32Array(9),Bd=new Float32Array(4);function Fs(i,t,e){let n=i[0];if(n<=0||n>0)return i;let s=t*e,r=Fd[s];if(r===void 0&&(r=new Float32Array(s),Fd[s]=r),t!==0){n.toArray(r,0);for(let o=1,a=0;o!==t;++o)a+=e,i[o].toArray(r,a)}return r}function Re(i,t){if(i.length!==t.length)return!1;for(let e=0,n=i.length;e<n;e++)if(i[e]!==t[e])return!1;return!0}function Pe(i,t){for(let e=0,n=t.length;e<n;e++)i[e]=t[e]}function al(i,t){let e=kd[t];e===void 0&&(e=new Int32Array(t),kd[t]=e);for(let n=0;n!==t;++n)e[n]=i.allocateTextureUnit();return e}function bv(i,t){let e=this.cache;e[0]!==t&&(i.uniform1f(this.addr,t),e[0]=t)}function Mv(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Re(e,t))return;i.uniform2fv(this.addr,t),Pe(e,t)}}function Sv(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(i.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(Re(e,t))return;i.uniform3fv(this.addr,t),Pe(e,t)}}function wv(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Re(e,t))return;i.uniform4fv(this.addr,t),Pe(e,t)}}function Ev(i,t){let e=this.cache,n=t.elements;if(n===void 0){if(Re(e,t))return;i.uniformMatrix2fv(this.addr,!1,t),Pe(e,t)}else{if(Re(e,n))return;Bd.set(n),i.uniformMatrix2fv(this.addr,!1,Bd),Pe(e,n)}}function Tv(i,t){let e=this.cache,n=t.elements;if(n===void 0){if(Re(e,t))return;i.uniformMatrix3fv(this.addr,!1,t),Pe(e,t)}else{if(Re(e,n))return;Ud.set(n),i.uniformMatrix3fv(this.addr,!1,Ud),Pe(e,n)}}function Av(i,t){let e=this.cache,n=t.elements;if(n===void 0){if(Re(e,t))return;i.uniformMatrix4fv(this.addr,!1,t),Pe(e,t)}else{if(Re(e,n))return;Od.set(n),i.uniformMatrix4fv(this.addr,!1,Od),Pe(e,n)}}function Cv(i,t){let e=this.cache;e[0]!==t&&(i.uniform1i(this.addr,t),e[0]=t)}function Rv(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Re(e,t))return;i.uniform2iv(this.addr,t),Pe(e,t)}}function Pv(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(Re(e,t))return;i.uniform3iv(this.addr,t),Pe(e,t)}}function Iv(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4i(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Re(e,t))return;i.uniform4iv(this.addr,t),Pe(e,t)}}function Lv(i,t){let e=this.cache;e[0]!==t&&(i.uniform1ui(this.addr,t),e[0]=t)}function Dv(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Re(e,t))return;i.uniform2uiv(this.addr,t),Pe(e,t)}}function Nv(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(Re(e,t))return;i.uniform3uiv(this.addr,t),Pe(e,t)}}function Fv(i,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4ui(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Re(e,t))return;i.uniform4uiv(this.addr,t),Pe(e,t)}}function kv(i,t,e){let n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let r;this.type===i.SAMPLER_2D_SHADOW?(_h.compareFunction=e.isReversedDepthBuffer()?el:tl,r=_h):r=tf,e.setTexture2D(t||r,s)}function Ov(i,t,e){let n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture3D(t||nf,s)}function Uv(i,t,e){let n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTextureCube(t||sf,s)}function Bv(i,t,e){let n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture2DArray(t||ef,s)}function zv(i){switch(i){case 5126:return bv;case 35664:return Mv;case 35665:return Sv;case 35666:return wv;case 35674:return Ev;case 35675:return Tv;case 35676:return Av;case 5124:case 35670:return Cv;case 35667:case 35671:return Rv;case 35668:case 35672:return Pv;case 35669:case 35673:return Iv;case 5125:return Lv;case 36294:return Dv;case 36295:return Nv;case 36296:return Fv;case 35678:case 36198:case 36298:case 36306:case 35682:return kv;case 35679:case 36299:case 36307:return Ov;case 35680:case 36300:case 36308:case 36293:return Uv;case 36289:case 36303:case 36311:case 36292:return Bv}}function Gv(i,t){i.uniform1fv(this.addr,t)}function Vv(i,t){let e=Fs(t,this.size,2);i.uniform2fv(this.addr,e)}function Hv(i,t){let e=Fs(t,this.size,3);i.uniform3fv(this.addr,e)}function Wv(i,t){let e=Fs(t,this.size,4);i.uniform4fv(this.addr,e)}function Xv(i,t){let e=Fs(t,this.size,4);i.uniformMatrix2fv(this.addr,!1,e)}function qv(i,t){let e=Fs(t,this.size,9);i.uniformMatrix3fv(this.addr,!1,e)}function Yv(i,t){let e=Fs(t,this.size,16);i.uniformMatrix4fv(this.addr,!1,e)}function Zv(i,t){i.uniform1iv(this.addr,t)}function $v(i,t){i.uniform2iv(this.addr,t)}function Kv(i,t){i.uniform3iv(this.addr,t)}function Jv(i,t){i.uniform4iv(this.addr,t)}function jv(i,t){i.uniform1uiv(this.addr,t)}function Qv(i,t){i.uniform2uiv(this.addr,t)}function t_(i,t){i.uniform3uiv(this.addr,t)}function e_(i,t){i.uniform4uiv(this.addr,t)}function n_(i,t,e){let n=this.cache,s=t.length,r=al(e,s);Re(n,r)||(i.uniform1iv(this.addr,r),Pe(n,r));let o;this.type===i.SAMPLER_2D_SHADOW?o=_h:o=tf;for(let a=0;a!==s;++a)e.setTexture2D(t[a]||o,r[a])}function i_(i,t,e){let n=this.cache,s=t.length,r=al(e,s);Re(n,r)||(i.uniform1iv(this.addr,r),Pe(n,r));for(let o=0;o!==s;++o)e.setTexture3D(t[o]||nf,r[o])}function s_(i,t,e){let n=this.cache,s=t.length,r=al(e,s);Re(n,r)||(i.uniform1iv(this.addr,r),Pe(n,r));for(let o=0;o!==s;++o)e.setTextureCube(t[o]||sf,r[o])}function r_(i,t,e){let n=this.cache,s=t.length,r=al(e,s);Re(n,r)||(i.uniform1iv(this.addr,r),Pe(n,r));for(let o=0;o!==s;++o)e.setTexture2DArray(t[o]||ef,r[o])}function o_(i){switch(i){case 5126:return Gv;case 35664:return Vv;case 35665:return Hv;case 35666:return Wv;case 35674:return Xv;case 35675:return qv;case 35676:return Yv;case 5124:case 35670:return Zv;case 35667:case 35671:return $v;case 35668:case 35672:return Kv;case 35669:case 35673:return Jv;case 5125:return jv;case 36294:return Qv;case 36295:return t_;case 36296:return e_;case 35678:case 36198:case 36298:case 36306:case 35682:return n_;case 35679:case 36299:case 36307:return i_;case 35680:case 36300:case 36308:case 36293:return s_;case 36289:case 36303:case 36311:case 36292:return r_}}var yh=class{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=zv(e.type)}},bh=class{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=o_(e.type)}},Mh=class{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){let s=this.seq;for(let r=0,o=s.length;r!==o;++r){let a=s[r];a.setValue(t,e[a.id],n)}}},xh=/(\w+)(\])?(\[|\.)?/g;function zd(i,t){i.seq.push(t),i.map[t.id]=t}function a_(i,t,e){let n=i.name,s=n.length;for(xh.lastIndex=0;;){let r=xh.exec(n),o=xh.lastIndex,a=r[1],l=r[2]==="]",c=r[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===s){zd(e,c===void 0?new yh(a,i,t):new bh(a,i,t));break}else{let d=e.map[a];d===void 0&&(d=new Mh(a),zd(e,d)),e=d}}}var Ds=class{constructor(t,e){this.seq=[],this.map={};let n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let o=0;o<n;++o){let a=t.getActiveUniform(e,o),l=t.getUniformLocation(e,a.name);a_(a,l,this)}let s=[],r=[];for(let o of this.seq)o.type===t.SAMPLER_2D_SHADOW||o.type===t.SAMPLER_CUBE_SHADOW||o.type===t.SAMPLER_2D_ARRAY_SHADOW?s.push(o):r.push(o);s.length>0&&(this.seq=s.concat(r))}setValue(t,e,n,s){let r=this.map[e];r!==void 0&&r.setValue(t,n,s)}setOptional(t,e,n){let s=e[n];s!==void 0&&this.setValue(t,n,s)}static upload(t,e,n,s){for(let r=0,o=e.length;r!==o;++r){let a=e[r],l=n[a.id];l.needsUpdate!==!1&&a.setValue(t,l.value,s)}}static seqWithValue(t,e){let n=[];for(let s=0,r=t.length;s!==r;++s){let o=t[s];o.id in e&&n.push(o)}return n}};function Gd(i,t,e){let n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}var l_=37297,c_=0;function h_(i,t){let e=i.split(`
`),n=[],s=Math.max(t-6,0),r=Math.min(t+6,e.length);for(let o=s;o<r;o++){let a=o+1;n.push(`${a===t?">":" "} ${a}: ${e[o]}`)}return n.join(`
`)}var Vd=new Dt;function u_(i){Vt._getMatrix(Vd,Vt.workingColorSpace,i);let t=`mat3( ${Vd.elements.map(e=>e.toFixed(4))} )`;switch(Vt.getTransfer(i)){case nr:return[t,"LinearTransferOETF"];case Jt:return[t,"sRGBTransferOETF"];default:return At("WebGLProgram: Unsupported color space: ",i),[t,"LinearTransferOETF"]}}function Hd(i,t,e){let n=i.getShaderParameter(t,i.COMPILE_STATUS),r=(i.getShaderInfoLog(t)||"").trim();if(n&&r==="")return"";let o=/ERROR: 0:(\d+)/.exec(r);if(o){let a=parseInt(o[1]);return e.toUpperCase()+`
`+r+`
`+h_(i.getShaderSource(t),a)}else return r}function d_(i,t){let e=u_(t);return[`vec4 ${i}( vec4 value ) {`,` return ${e[1]}( vec4( value.rgb * ${e[0]}, value.a ) );`,"}"].join(`
`)}var f_={[_r]:"Linear",[yr]:"Reinhard",[br]:"Cineon",[Li]:"ACESFilmic",[Sr]:"AgX",[wr]:"Neutral",[Mr]:"Custom"};function p_(i,t){let e=f_[t];return e===void 0?(At("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}var il=new L;function m_(){Vt.getLuminanceCoefficients(il);let i=il.x.toFixed(4),t=il.y.toFixed(4),e=il.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${t}, ${e} );`," return dot( weights, rgb );","}"].join(`
`)}function g_(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Fr).join(`
`)}function x_(i){let t=[];for(let e in i){let n=i[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(`
`)}function v_(i,t){let e={},n=i.getProgramParameter(t,i.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){let r=i.getActiveAttrib(t,s),o=r.name,a=1;r.type===i.FLOAT_MAT2&&(a=2),r.type===i.FLOAT_MAT3&&(a=3),r.type===i.FLOAT_MAT4&&(a=4),e[o]={type:r.type,location:i.getAttribLocation(t,o),locationSize:a}}return e}function Fr(i){return i!==""}function Wd(i,t){let e=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,e).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Xd(i,t){return i.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var __=/^[ \t]*#include +<([\w\d./]+)>/gm;function Sh(i){return i.replace(__,b_)}var y_=new Map;function b_(i,t){let e=zt[t];if(e===void 0){let n=y_.get(t);if(n!==void 0)e=zt[n],At('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("Can not resolve #include <"+t+">")}return Sh(e)}var M_=/#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 qd(i){return i.replace(M_,S_)}function S_(i,t,e,n){let s="";for(let r=parseInt(t);r<parseInt(e);r++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function Yd(i){let t=`precision ${i.precision} float;
precision ${i.precision} int;
precision ${i.precision} sampler2D;
precision ${i.precision} samplerCube;
precision ${i.precision} sampler3D;
precision ${i.precision} sampler2DArray;
precision ${i.precision} sampler2DShadow;
precision ${i.precision} samplerCubeShadow;
precision ${i.precision} sampler2DArrayShadow;
precision ${i.precision} isampler2D;
precision ${i.precision} isampler3D;
precision ${i.precision} isamplerCube;
precision ${i.precision} isampler2DArray;
precision ${i.precision} usampler2D;
precision ${i.precision} usampler3D;
precision ${i.precision} usamplerCube;
precision ${i.precision} usampler2DArray;
`;return i.precision==="highp"?t+=`
#define HIGH_PRECISION`:i.precision==="mediump"?t+=`
#define MEDIUM_PRECISION`:i.precision==="lowp"&&(t+=`
#define LOW_PRECISION`),t}var w_={[xr]:"SHADOWMAP_TYPE_PCF",[Cs]:"SHADOWMAP_TYPE_VSM"};function E_(i){return w_[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var T_={[Di]:"ENVMAP_TYPE_CUBE",[Ki]:"ENVMAP_TYPE_CUBE",[Er]:"ENVMAP_TYPE_CUBE_UV"};function A_(i){return i.envMap===!1?"ENVMAP_TYPE_CUBE":T_[i.envMapMode]||"ENVMAP_TYPE_CUBE"}var C_={[Ki]:"ENVMAP_MODE_REFRACTION"};function R_(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":C_[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}var P_={[Wc]:"ENVMAP_BLENDING_MULTIPLY",[fd]:"ENVMAP_BLENDING_MIX",[pd]:"ENVMAP_BLENDING_ADD"};function I_(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":P_[i.combine]||"ENVMAP_BLENDING_NONE"}function L_(i){let t=i.envMapCubeUVHeight;if(t===null)return null;let e=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),7*16)),texelHeight:n,maxMip:e}}function D_(i,t,e,n){let s=i.getContext(),r=e.defines,o=e.vertexShader,a=e.fragmentShader,l=E_(e),c=A_(e),u=R_(e),d=I_(e),h=L_(e),f=g_(e),m=x_(r),x=s.createProgram(),g,p,v=e.glslVersion?"#version "+e.glslVersion+`
`:"";e.isRawShaderMaterial?(g=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m].filter(Fr).join(`
`),g.length>0&&(g+=`
`),p=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m].filter(Fr).join(`
`),p.length>0&&(p+=`
`)):(g=[Yd(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m,e.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",e.batching?"#define USE_BATCHING":"",e.batchingColor?"#define USE_BATCHING_COLOR":"",e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.instancingMorph?"#define USE_INSTANCING_MORPH":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+u:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.displacementMap?"#define USE_DISPLACEMENTMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.mapUv?"#define MAP_UV "+e.mapUv:"",e.alphaMapUv?"#define ALPHAMAP_UV "+e.alphaMapUv:"",e.lightMapUv?"#define LIGHTMAP_UV "+e.lightMapUv:"",e.aoMapUv?"#define AOMAP_UV "+e.aoMapUv:"",e.emissiveMapUv?"#define EMISSIVEMAP_UV "+e.emissiveMapUv:"",e.bumpMapUv?"#define BUMPMAP_UV "+e.bumpMapUv:"",e.normalMapUv?"#define NORMALMAP_UV "+e.normalMapUv:"",e.displacementMapUv?"#define DISPLACEMENTMAP_UV "+e.displacementMapUv:"",e.metalnessMapUv?"#define METALNESSMAP_UV "+e.metalnessMapUv:"",e.roughnessMapUv?"#define ROUGHNESSMAP_UV "+e.roughnessMapUv:"",e.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+e.anisotropyMapUv:"",e.clearcoatMapUv?"#define CLEARCOATMAP_UV "+e.clearcoatMapUv:"",e.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+e.clearcoatNormalMapUv:"",e.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+e.clearcoatRoughnessMapUv:"",e.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+e.iridescenceMapUv:"",e.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+e.iridescenceThicknessMapUv:"",e.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+e.sheenColorMapUv:"",e.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+e.sheenRoughnessMapUv:"",e.specularMapUv?"#define SPECULARMAP_UV "+e.specularMapUv:"",e.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+e.specularColorMapUv:"",e.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+e.specularIntensityMapUv:"",e.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+e.transmissionMapUv:"",e.thicknessMapUv?"#define THICKNESSMAP_UV "+e.thicknessMapUv:"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexNormals?"#define HAS_NORMAL":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
`].filter(Fr).join(`
`),p=[Yd(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+c:"",e.envMap?"#define "+u:"",e.envMap?"#define "+d:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.dispersion?"#define USE_DISPERSION":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor?"#define USE_COLOR":"",e.vertexAlphas||e.batchingColor?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==dn?"#define TONE_MAPPING":"",e.toneMapping!==dn?zt.tonemapping_pars_fragment:"",e.toneMapping!==dn?p_("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",zt.colorspace_pars_fragment,d_("linearToOutputTexel",e.outputColorSpace),m_(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`
`].filter(Fr).join(`
`)),o=Sh(o),o=Wd(o,e),o=Xd(o,e),a=Sh(a),a=Wd(a,e),a=Xd(a,e),o=qd(o),a=qd(a),e.isRawShaderMaterial!==!0&&(v=`#version 300 es
`,g=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
`+g,p=["#define varying in",e.glslVersion===th?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===th?"":"#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(`
`)+`
`+p);let M=v+g+o,b=v+p+a,E=Gd(s,s.VERTEX_SHADER,M),w=Gd(s,s.FRAGMENT_SHADER,b);s.attachShader(x,E),s.attachShader(x,w),e.index0AttributeName!==void 0?s.bindAttribLocation(x,0,e.index0AttributeName):e.morphTargets===!0&&s.bindAttribLocation(x,0,"position"),s.linkProgram(x);function C(R){if(i.debug.checkShaderErrors){let D=s.getProgramInfoLog(x)||"",W=s.getShaderInfoLog(E)||"",H=s.getShaderInfoLog(w)||"",k=D.trim(),B=W.trim(),U=H.trim(),j=!0,Q=!0;if(s.getProgramParameter(x,s.LINK_STATUS)===!1)if(j=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,x,E,w);else{let ct=Hd(s,E,"vertex"),_t=Hd(s,w,"fragment");Pt("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(x,s.VALIDATE_STATUS)+`
Material Name: `+R.name+`
Material Type: `+R.type+`
Program Info Log: `+k+`
`+ct+`
`+_t)}else k!==""?At("WebGLProgram: Program Info Log:",k):(B===""||U==="")&&(Q=!1);Q&&(R.diagnostics={runnable:j,programLog:k,vertexShader:{log:B,prefix:g},fragmentShader:{log:U,prefix:p}})}s.deleteShader(E),s.deleteShader(w),_=new Ds(s,x),A=v_(s,x)}let _;this.getUniforms=function(){return _===void 0&&C(this),_};let A;this.getAttributes=function(){return A===void 0&&C(this),A};let P=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return P===!1&&(P=s.getProgramParameter(x,l_)),P},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(x),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=c_++,this.cacheKey=t,this.usedTimes=1,this.program=x,this.vertexShader=E,this.fragmentShader=w,this}var N_=0,wh=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){let e=t.vertexShader,n=t.fragmentShader,s=this._getShaderStage(e),r=this._getShaderStage(n),o=this._getShaderCacheForMaterial(t);return o.has(s)===!1&&(o.add(s),s.usedTimes++),o.has(r)===!1&&(o.add(r),r.usedTimes++),this}remove(t){let e=this.materialCache.get(t);for(let n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){let e=this.materialCache,n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){let e=this.shaderCache,n=e.get(t);return n===void 0&&(n=new Eh(t),e.set(t,n)),n}},Eh=class{constructor(t){this.id=N_++,this.code=t,this.usedTimes=0}};function F_(i){return i===ki||i===Ir||i===Lr}function k_(i,t,e,n,s,r){let o=new or,a=new wh,l=new Set,c=[],u=new Map,d=n.logarithmicDepthBuffer,h=n.precision,f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(_){return l.add(_),_===0?"uv":`uv${_}`}function x(_,A,P,R,D,W){let H=R.fog,k=D.geometry,B=_.isMeshStandardMaterial||_.isMeshLambertMaterial||_.isMeshPhongMaterial?R.environment:null,U=_.isMeshStandardMaterial||_.isMeshLambertMaterial&&!_.envMap||_.isMeshPhongMaterial&&!_.envMap,j=t.get(_.envMap||B,U),Q=j&&j.mapping===Er?j.image.height:null,ct=f[_.type];_.precision!==null&&(h=n.getMaxPrecision(_.precision),h!==_.precision&&At("WebGLProgram.getParameters:",_.precision,"not supported, using",h,"instead."));let _t=k.morphAttributes.position||k.morphAttributes.normal||k.morphAttributes.color,wt=_t!==void 0?_t.length:0,Zt=0;k.morphAttributes.position!==void 0&&(Zt=1),k.morphAttributes.normal!==void 0&&(Zt=2),k.morphAttributes.color!==void 0&&(Zt=3);let Qt,Ut,$,dt;if(ct){let kt=Wn[ct];Qt=kt.vertexShader,Ut=kt.fragmentShader}else Qt=_.vertexShader,Ut=_.fragmentShader,a.update(_),$=a.getVertexShaderID(_),dt=a.getFragmentShaderID(_);let it=i.getRenderTarget(),Ct=i.state.buffers.depth.getReversed(),Nt=D.isInstancedMesh===!0,It=D.isBatchedMesh===!0,de=!!_.map,Xt=!!_.matcap,te=!!j,le=!!_.aoMap,Wt=!!_.lightMap,Ee=!!_.bumpMap,fe=!!_.normalMap,nn=!!_.displacementMap,N=!!_.emissiveMap,Te=!!_.metalnessMap,qt=!!_.roughnessMap,oe=_.anisotropy>0,at=_.clearcoat>0,pe=_.dispersion>0,T=_.iridescence>0,y=_.sheen>0,O=_.transmission>0,Y=oe&&!!_.anisotropyMap,J=at&&!!_.clearcoatMap,tt=at&&!!_.clearcoatNormalMap,ot=at&&!!_.clearcoatRoughnessMap,X=T&&!!_.iridescenceMap,Z=T&&!!_.iridescenceThicknessMap,ft=y&&!!_.sheenColorMap,xt=y&&!!_.sheenRoughnessMap,st=!!_.specularMap,et=!!_.specularColorMap,Lt=!!_.specularIntensityMap,Bt=O&&!!_.transmissionMap,Kt=O&&!!_.thicknessMap,I=!!_.gradientMap,nt=!!_.alphaMap,q=_.alphaTest>0,pt=!!_.alphaHash,rt=!!_.extensions,K=dn;_.toneMapped&&(it===null||it.isXRRenderTarget===!0)&&(K=i.toneMapping);let Mt={shaderID:ct,shaderType:_.type,shaderName:_.name,vertexShader:Qt,fragmentShader:Ut,defines:_.defines,customVertexShaderID:$,customFragmentShaderID:dt,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:h,batching:It,batchingColor:It&&D._colorsTexture!==null,instancing:Nt,instancingColor:Nt&&D.instanceColor!==null,instancingMorph:Nt&&D.morphTexture!==null,outputColorSpace:it===null?i.outputColorSpace:it.isXRRenderTarget===!0?it.texture.colorSpace:Vt.workingColorSpace,alphaToCoverage:!!_.alphaToCoverage,map:de,matcap:Xt,envMap:te,envMapMode:te&&j.mapping,envMapCubeUVHeight:Q,aoMap:le,lightMap:Wt,bumpMap:Ee,normalMap:fe,displacementMap:nn,emissiveMap:N,normalMapObjectSpace:fe&&_.normalMapType===xd,normalMapTangentSpace:fe&&_.normalMapType===Qc,packedNormalMap:fe&&_.normalMapType===Qc&&F_(_.normalMap.format),metalnessMap:Te,roughnessMap:qt,anisotropy:oe,anisotropyMap:Y,clearcoat:at,clearcoatMap:J,clearcoatNormalMap:tt,clearcoatRoughnessMap:ot,dispersion:pe,iridescence:T,iridescenceMap:X,iridescenceThicknessMap:Z,sheen:y,sheenColorMap:ft,sheenRoughnessMap:xt,specularMap:st,specularColorMap:et,specularIntensityMap:Lt,transmission:O,transmissionMap:Bt,thicknessMap:Kt,gradientMap:I,opaque:_.transparent===!1&&_.blending===Yi&&_.alphaToCoverage===!1,alphaMap:nt,alphaTest:q,alphaHash:pt,combine:_.combine,mapUv:de&&m(_.map.channel),aoMapUv:le&&m(_.aoMap.channel),lightMapUv:Wt&&m(_.lightMap.channel),bumpMapUv:Ee&&m(_.bumpMap.channel),normalMapUv:fe&&m(_.normalMap.channel),displacementMapUv:nn&&m(_.displacementMap.channel),emissiveMapUv:N&&m(_.emissiveMap.channel),metalnessMapUv:Te&&m(_.metalnessMap.channel),roughnessMapUv:qt&&m(_.roughnessMap.channel),anisotropyMapUv:Y&&m(_.anisotropyMap.channel),clearcoatMapUv:J&&m(_.clearcoatMap.channel),clearcoatNormalMapUv:tt&&m(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ot&&m(_.clearcoatRoughnessMap.channel),iridescenceMapUv:X&&m(_.iridescenceMap.channel),iridescenceThicknessMapUv:Z&&m(_.iridescenceThicknessMap.channel),sheenColorMapUv:ft&&m(_.sheenColorMap.channel),sheenRoughnessMapUv:xt&&m(_.sheenRoughnessMap.channel),specularMapUv:st&&m(_.specularMap.channel),specularColorMapUv:et&&m(_.specularColorMap.channel),specularIntensityMapUv:Lt&&m(_.specularIntensityMap.channel),transmissionMapUv:Bt&&m(_.transmissionMap.channel),thicknessMapUv:Kt&&m(_.thicknessMap.channel),alphaMapUv:nt&&m(_.alphaMap.channel),vertexTangents:!!k.attributes.tangent&&(fe||oe),vertexNormals:!!k.attributes.normal,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!k.attributes.color&&k.attributes.color.itemSize===4,pointsUvs:D.isPoints===!0&&!!k.attributes.uv&&(de||nt),fog:!!H,useFog:_.fog===!0,fogExp2:!!H&&H.isFogExp2,flatShading:_.wireframe===!1&&(_.flatShading===!0||k.attributes.normal===void 0&&fe===!1&&(_.isMeshLambertMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isMeshPhysicalMaterial)),sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:Ct,skinning:D.isSkinnedMesh===!0,morphTargets:k.morphAttributes.position!==void 0,morphNormals:k.morphAttributes.normal!==void 0,morphColors:k.morphAttributes.color!==void 0,morphTargetsCount:wt,morphTextureStride:Zt,numDirLights:A.directional.length,numPointLights:A.point.length,numSpotLights:A.spot.length,numSpotLightMaps:A.spotLightMap.length,numRectAreaLights:A.rectArea.length,numHemiLights:A.hemi.length,numDirLightShadows:A.directionalShadowMap.length,numPointLightShadows:A.pointShadowMap.length,numSpotLightShadows:A.spotShadowMap.length,numSpotLightShadowsWithMaps:A.numSpotLightShadowsWithMaps,numLightProbes:A.numLightProbes,numLightProbeGrids:W.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:_.dithering,shadowMapEnabled:i.shadowMap.enabled&&P.length>0,shadowMapType:i.shadowMap.type,toneMapping:K,decodeVideoTexture:de&&_.map.isVideoTexture===!0&&Vt.getTransfer(_.map.colorSpace)===Jt,decodeVideoTextureEmissive:N&&_.emissiveMap.isVideoTexture===!0&&Vt.getTransfer(_.emissiveMap.colorSpace)===Jt,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===Vn,flipSided:_.side===$e,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:rt&&_.extensions.clipCullDistance===!0&&e.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(rt&&_.extensions.multiDraw===!0||It)&&e.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:e.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return Mt.vertexUv1s=l.has(1),Mt.vertexUv2s=l.has(2),Mt.vertexUv3s=l.has(3),l.clear(),Mt}function g(_){let A=[];if(_.shaderID?A.push(_.shaderID):(A.push(_.customVertexShaderID),A.push(_.customFragmentShaderID)),_.defines!==void 0)for(let P in _.defines)A.push(P),A.push(_.defines[P]);return _.isRawShaderMaterial===!1&&(p(A,_),v(A,_),A.push(i.outputColorSpace)),A.push(_.customProgramCacheKey),A.join()}function p(_,A){_.push(A.precision),_.push(A.outputColorSpace),_.push(A.envMapMode),_.push(A.envMapCubeUVHeight),_.push(A.mapUv),_.push(A.alphaMapUv),_.push(A.lightMapUv),_.push(A.aoMapUv),_.push(A.bumpMapUv),_.push(A.normalMapUv),_.push(A.displacementMapUv),_.push(A.emissiveMapUv),_.push(A.metalnessMapUv),_.push(A.roughnessMapUv),_.push(A.anisotropyMapUv),_.push(A.clearcoatMapUv),_.push(A.clearcoatNormalMapUv),_.push(A.clearcoatRoughnessMapUv),_.push(A.iridescenceMapUv),_.push(A.iridescenceThicknessMapUv),_.push(A.sheenColorMapUv),_.push(A.sheenRoughnessMapUv),_.push(A.specularMapUv),_.push(A.specularColorMapUv),_.push(A.specularIntensityMapUv),_.push(A.transmissionMapUv),_.push(A.thicknessMapUv),_.push(A.combine),_.push(A.fogExp2),_.push(A.sizeAttenuation),_.push(A.morphTargetsCount),_.push(A.morphAttributeCount),_.push(A.numDirLights),_.push(A.numPointLights),_.push(A.numSpotLights),_.push(A.numSpotLightMaps),_.push(A.numHemiLights),_.push(A.numRectAreaLights),_.push(A.numDirLightShadows),_.push(A.numPointLightShadows),_.push(A.numSpotLightShadows),_.push(A.numSpotLightShadowsWithMaps),_.push(A.numLightProbes),_.push(A.shadowMapType),_.push(A.toneMapping),_.push(A.numClippingPlanes),_.push(A.numClipIntersection),_.push(A.depthPacking)}function v(_,A){o.disableAll(),A.instancing&&o.enable(0),A.instancingColor&&o.enable(1),A.instancingMorph&&o.enable(2),A.matcap&&o.enable(3),A.envMap&&o.enable(4),A.normalMapObjectSpace&&o.enable(5),A.normalMapTangentSpace&&o.enable(6),A.clearcoat&&o.enable(7),A.iridescence&&o.enable(8),A.alphaTest&&o.enable(9),A.vertexColors&&o.enable(10),A.vertexAlphas&&o.enable(11),A.vertexUv1s&&o.enable(12),A.vertexUv2s&&o.enable(13),A.vertexUv3s&&o.enable(14),A.vertexTangents&&o.enable(15),A.anisotropy&&o.enable(16),A.alphaHash&&o.enable(17),A.batching&&o.enable(18),A.dispersion&&o.enable(19),A.batchingColor&&o.enable(20),A.gradientMap&&o.enable(21),A.packedNormalMap&&o.enable(22),A.vertexNormals&&o.enable(23),_.push(o.mask),o.disableAll(),A.fog&&o.enable(0),A.useFog&&o.enable(1),A.flatShading&&o.enable(2),A.logarithmicDepthBuffer&&o.enable(3),A.reversedDepthBuffer&&o.enable(4),A.skinning&&o.enable(5),A.morphTargets&&o.enable(6),A.morphNormals&&o.enable(7),A.morphColors&&o.enable(8),A.premultipliedAlpha&&o.enable(9),A.shadowMapEnabled&&o.enable(10),A.doubleSided&&o.enable(11),A.flipSided&&o.enable(12),A.useDepthPacking&&o.enable(13),A.dithering&&o.enable(14),A.transmission&&o.enable(15),A.sheen&&o.enable(16),A.opaque&&o.enable(17),A.pointsUvs&&o.enable(18),A.decodeVideoTexture&&o.enable(19),A.decodeVideoTextureEmissive&&o.enable(20),A.alphaToCoverage&&o.enable(21),A.numLightProbeGrids>0&&o.enable(22),_.push(o.mask)}function M(_){let A=f[_.type],P;if(A){let R=Wn[A];P=li.clone(R.uniforms)}else P=_.uniforms;return P}function b(_,A){let P=u.get(A);return P!==void 0?++P.usedTimes:(P=new D_(i,A,_,s),c.push(P),u.set(A,P)),P}function E(_){if(--_.usedTimes===0){let A=c.indexOf(_);c[A]=c[c.length-1],c.pop(),u.delete(_.cacheKey),_.destroy()}}function w(_){a.remove(_)}function C(){a.dispose()}return{getParameters:x,getProgramCacheKey:g,getUniforms:M,acquireProgram:b,releaseProgram:E,releaseShaderCache:w,programs:c,dispose:C}}function O_(){let i=new WeakMap;function t(o){return i.has(o)}function e(o){let a=i.get(o);return a===void 0&&(a={},i.set(o,a)),a}function n(o){i.delete(o)}function s(o,a,l){i.get(o)[a]=l}function r(){i=new WeakMap}return{has:t,get:e,remove:n,update:s,dispose:r}}function U_(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.material.id!==t.material.id?i.material.id-t.material.id:i.materialVariant!==t.materialVariant?i.materialVariant-t.materialVariant:i.z!==t.z?i.z-t.z:i.id-t.id}function Zd(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.z!==t.z?t.z-i.z:i.id-t.id}function $d(){let i=[],t=0,e=[],n=[],s=[];function r(){t=0,e.length=0,n.length=0,s.length=0}function o(h){let f=0;return h.isInstancedMesh&&(f+=2),h.isSkinnedMesh&&(f+=1),f}function a(h,f,m,x,g,p){let v=i[t];return v===void 0?(v={id:h.id,object:h,geometry:f,material:m,materialVariant:o(h),groupOrder:x,renderOrder:h.renderOrder,z:g,group:p},i[t]=v):(v.id=h.id,v.object=h,v.geometry=f,v.material=m,v.materialVariant=o(h),v.groupOrder=x,v.renderOrder=h.renderOrder,v.z=g,v.group=p),t++,v}function l(h,f,m,x,g,p){let v=a(h,f,m,x,g,p);m.transmission>0?n.push(v):m.transparent===!0?s.push(v):e.push(v)}function c(h,f,m,x,g,p){let v=a(h,f,m,x,g,p);m.transmission>0?n.unshift(v):m.transparent===!0?s.unshift(v):e.unshift(v)}function u(h,f){e.length>1&&e.sort(h||U_),n.length>1&&n.sort(f||Zd),s.length>1&&s.sort(f||Zd)}function d(){for(let h=t,f=i.length;h<f;h++){let m=i[h];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:e,transmissive:n,transparent:s,init:r,push:l,unshift:c,finish:d,sort:u}}function B_(){let i=new WeakMap;function t(n,s){let r=i.get(n),o;return r===void 0?(o=new $d,i.set(n,[o])):s>=r.length?(o=new $d,r.push(o)):o=r[s],o}function e(){i=new WeakMap}return{get:t,dispose:e}}function z_(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new L,color:new mt};break;case"SpotLight":e={position:new L,direction:new L,color:new mt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new L,color:new mt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new L,skyColor:new mt,groundColor:new mt};break;case"RectAreaLight":e={color:new mt,position:new L,halfWidth:new L,halfHeight:new L};break}return i[t.id]=e,e}}}function G_(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Tt};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Tt};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Tt,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}var V_=0;function H_(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function W_(i){let t=new z_,e=G_(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new L);let s=new L,r=new ge,o=new ge;function a(c){let u=0,d=0,h=0;for(let A=0;A<9;A++)n.probe[A].set(0,0,0);let f=0,m=0,x=0,g=0,p=0,v=0,M=0,b=0,E=0,w=0,C=0;c.sort(H_);for(let A=0,P=c.length;A<P;A++){let R=c[A],D=R.color,W=R.intensity,H=R.distance,k=null;if(R.shadow&&R.shadow.map&&(R.shadow.map.texture.format===ki?k=R.shadow.map.texture:k=R.shadow.map.depthTexture||R.shadow.map.texture),R.isAmbientLight)u+=D.r*W,d+=D.g*W,h+=D.b*W;else if(R.isLightProbe){for(let B=0;B<9;B++)n.probe[B].addScaledVector(R.sh.coefficients[B],W);C++}else if(R.isDirectionalLight){let B=t.get(R);if(B.color.copy(R.color).multiplyScalar(R.intensity),R.castShadow){let U=R.shadow,j=e.get(R);j.shadowIntensity=U.intensity,j.shadowBias=U.bias,j.shadowNormalBias=U.normalBias,j.shadowRadius=U.radius,j.shadowMapSize=U.mapSize,n.directionalShadow[f]=j,n.directionalShadowMap[f]=k,n.directionalShadowMatrix[f]=R.shadow.matrix,v++}n.directional[f]=B,f++}else if(R.isSpotLight){let B=t.get(R);B.position.setFromMatrixPosition(R.matrixWorld),B.color.copy(D).multiplyScalar(W),B.distance=H,B.coneCos=Math.cos(R.angle),B.penumbraCos=Math.cos(R.angle*(1-R.penumbra)),B.decay=R.decay,n.spot[x]=B;let U=R.shadow;if(R.map&&(n.spotLightMap[E]=R.map,E++,U.updateMatrices(R),R.castShadow&&w++),n.spotLightMatrix[x]=U.matrix,R.castShadow){let j=e.get(R);j.shadowIntensity=U.intensity,j.shadowBias=U.bias,j.shadowNormalBias=U.normalBias,j.shadowRadius=U.radius,j.shadowMapSize=U.mapSize,n.spotShadow[x]=j,n.spotShadowMap[x]=k,b++}x++}else if(R.isRectAreaLight){let B=t.get(R);B.color.copy(D).multiplyScalar(W),B.halfWidth.set(R.width*.5,0,0),B.halfHeight.set(0,R.height*.5,0),n.rectArea[g]=B,g++}else if(R.isPointLight){let B=t.get(R);if(B.color.copy(R.color).multiplyScalar(R.intensity),B.distance=R.distance,B.decay=R.decay,R.castShadow){let U=R.shadow,j=e.get(R);j.shadowIntensity=U.intensity,j.shadowBias=U.bias,j.shadowNormalBias=U.normalBias,j.shadowRadius=U.radius,j.shadowMapSize=U.mapSize,j.shadowCameraNear=U.camera.near,j.shadowCameraFar=U.camera.far,n.pointShadow[m]=j,n.pointShadowMap[m]=k,n.pointShadowMatrix[m]=R.shadow.matrix,M++}n.point[m]=B,m++}else if(R.isHemisphereLight){let B=t.get(R);B.skyColor.copy(R.color).multiplyScalar(W),B.groundColor.copy(R.groundColor).multiplyScalar(W),n.hemi[p]=B,p++}}g>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=lt.LTC_FLOAT_1,n.rectAreaLTC2=lt.LTC_FLOAT_2):(n.rectAreaLTC1=lt.LTC_HALF_1,n.rectAreaLTC2=lt.LTC_HALF_2)),n.ambient[0]=u,n.ambient[1]=d,n.ambient[2]=h;let _=n.hash;(_.directionalLength!==f||_.pointLength!==m||_.spotLength!==x||_.rectAreaLength!==g||_.hemiLength!==p||_.numDirectionalShadows!==v||_.numPointShadows!==M||_.numSpotShadows!==b||_.numSpotMaps!==E||_.numLightProbes!==C)&&(n.directional.length=f,n.spot.length=x,n.rectArea.length=g,n.point.length=m,n.hemi.length=p,n.directionalShadow.length=v,n.directionalShadowMap.length=v,n.pointShadow.length=M,n.pointShadowMap.length=M,n.spotShadow.length=b,n.spotShadowMap.length=b,n.directionalShadowMatrix.length=v,n.pointShadowMatrix.length=M,n.spotLightMatrix.length=b+E-w,n.spotLightMap.length=E,n.numSpotLightShadowsWithMaps=w,n.numLightProbes=C,_.directionalLength=f,_.pointLength=m,_.spotLength=x,_.rectAreaLength=g,_.hemiLength=p,_.numDirectionalShadows=v,_.numPointShadows=M,_.numSpotShadows=b,_.numSpotMaps=E,_.numLightProbes=C,n.version=V_++)}function l(c,u){let d=0,h=0,f=0,m=0,x=0,g=u.matrixWorldInverse;for(let p=0,v=c.length;p<v;p++){let M=c[p];if(M.isDirectionalLight){let b=n.directional[d];b.direction.setFromMatrixPosition(M.matrixWorld),s.setFromMatrixPosition(M.target.matrixWorld),b.direction.sub(s),b.direction.transformDirection(g),d++}else if(M.isSpotLight){let b=n.spot[f];b.position.setFromMatrixPosition(M.matrixWorld),b.position.applyMatrix4(g),b.direction.setFromMatrixPosition(M.matrixWorld),s.setFromMatrixPosition(M.target.matrixWorld),b.direction.sub(s),b.direction.transformDirection(g),f++}else if(M.isRectAreaLight){let b=n.rectArea[m];b.position.setFromMatrixPosition(M.matrixWorld),b.position.applyMatrix4(g),o.identity(),r.copy(M.matrixWorld),r.premultiply(g),o.extractRotation(r),b.halfWidth.set(M.width*.5,0,0),b.halfHeight.set(0,M.height*.5,0),b.halfWidth.applyMatrix4(o),b.halfHeight.applyMatrix4(o),m++}else if(M.isPointLight){let b=n.point[h];b.position.setFromMatrixPosition(M.matrixWorld),b.position.applyMatrix4(g),h++}else if(M.isHemisphereLight){let b=n.hemi[x];b.direction.setFromMatrixPosition(M.matrixWorld),b.direction.transformDirection(g),x++}}}return{setup:a,setupView:l,state:n}}function Kd(i){let t=new W_(i),e=[],n=[],s=[];function r(h){d.camera=h,e.length=0,n.length=0,s.length=0}function o(h){e.push(h)}function a(h){n.push(h)}function l(h){s.push(h)}function c(){t.setup(e)}function u(h){t.setupView(e,h)}let d={lightsArray:e,shadowsArray:n,lightProbeGridArray:s,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:d,setupLights:c,setupLightsView:u,pushLight:o,pushShadow:a,pushLightProbeGrid:l}}function X_(i){let t=new WeakMap;function e(s,r=0){let o=t.get(s),a;return o===void 0?(a=new Kd(i),t.set(s,[a])):r>=o.length?(a=new Kd(i),o.push(a)):a=o[r],a}function n(){t=new WeakMap}return{get:e,dispose:n}}var q_=`void main() {
gl_Position = vec4( position, 1.0 );
}`,Y_=`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 );
}`,Z_=[new L(1,0,0),new L(-1,0,0),new L(0,1,0),new L(0,-1,0),new L(0,0,1),new L(0,0,-1)],$_=[new L(0,-1,0),new L(0,-1,0),new L(0,0,1),new L(0,0,-1),new L(0,-1,0),new L(0,-1,0)],Jd=new ge,Nr=new L,vh=new L;function K_(i,t,e){let n=new cr,s=new Tt,r=new Tt,o=new xe,a=new Qo,l=new ta,c={},u=e.maxTextureSize,d={[ei]:$e,[$e]:ei,[Vn]:Vn},h=new ue({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Tt},radius:{value:4}},vertexShader:q_,fragmentShader:Y_}),f=h.clone();f.defines.HORIZONTAL_PASS=1;let m=new he;m.setAttribute("position",new Yt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let x=new Xe(m,h),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=xr;let p=this.type;this.render=function(w,C,_){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||w.length===0)return;this.type===Zu&&(At("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=xr);let A=i.getRenderTarget(),P=i.getActiveCubeFace(),R=i.getActiveMipmapLevel(),D=i.state;D.setBlending(yn),D.buffers.depth.getReversed()===!0?D.buffers.color.setClear(0,0,0,0):D.buffers.color.setClear(1,1,1,1),D.buffers.depth.setTest(!0),D.setScissorTest(!1);let W=p!==this.type;W&&C.traverse(function(H){H.material&&(Array.isArray(H.material)?H.material.forEach(k=>k.needsUpdate=!0):H.material.needsUpdate=!0)});for(let H=0,k=w.length;H<k;H++){let B=w[H],U=B.shadow;if(U===void 0){At("WebGLShadowMap:",B,"has no shadow.");continue}if(U.autoUpdate===!1&&U.needsUpdate===!1)continue;s.copy(U.mapSize);let j=U.getFrameExtents();s.multiply(j),r.copy(U.mapSize),(s.x>u||s.y>u)&&(s.x>u&&(r.x=Math.floor(u/j.x),s.x=r.x*j.x,U.mapSize.x=r.x),s.y>u&&(r.y=Math.floor(u/j.y),s.y=r.y*j.y,U.mapSize.y=r.y));let Q=i.state.buffers.depth.getReversed();if(U.camera._reversedDepth=Q,U.map===null||W===!0){if(U.map!==null&&(U.map.depthTexture!==null&&(U.map.depthTexture.dispose(),U.map.depthTexture=null),U.map.dispose()),this.type===Cs){if(B.isPointLight){At("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}U.map=new Ce(s.x,s.y,{format:ki,type:qe,minFilter:Ue,magFilter:Ue,generateMipmaps:!1}),U.map.texture.name=B.name+".shadowMap",U.map.depthTexture=new ri(s.x,s.y,Pn),U.map.depthTexture.name=B.name+".shadowMapDepth",U.map.depthTexture.format=Bn,U.map.depthTexture.compareFunction=null,U.map.depthTexture.minFilter=De,U.map.depthTexture.magFilter=De}else B.isPointLight?(U.map=new rl(s.x),U.map.depthTexture=new jo(s.x,Rn)):(U.map=new Ce(s.x,s.y),U.map.depthTexture=new ri(s.x,s.y,Rn)),U.map.depthTexture.name=B.name+".shadowMap",U.map.depthTexture.format=Bn,this.type===xr?(U.map.depthTexture.compareFunction=Q?el:tl,U.map.depthTexture.minFilter=Ue,U.map.depthTexture.magFilter=Ue):(U.map.depthTexture.compareFunction=null,U.map.depthTexture.minFilter=De,U.map.depthTexture.magFilter=De);U.camera.updateProjectionMatrix()}let ct=U.map.isWebGLCubeRenderTarget?6:1;for(let _t=0;_t<ct;_t++){if(U.map.isWebGLCubeRenderTarget)i.setRenderTarget(U.map,_t),i.clear();else{_t===0&&(i.setRenderTarget(U.map),i.clear());let wt=U.getViewport(_t);o.set(r.x*wt.x,r.y*wt.y,r.x*wt.z,r.y*wt.w),D.viewport(o)}if(B.isPointLight){let wt=U.camera,Zt=U.matrix,Qt=B.distance||wt.far;Qt!==wt.far&&(wt.far=Qt,wt.updateProjectionMatrix()),Nr.setFromMatrixPosition(B.matrixWorld),wt.position.copy(Nr),vh.copy(wt.position),vh.add(Z_[_t]),wt.up.copy($_[_t]),wt.lookAt(vh),wt.updateMatrixWorld(),Zt.makeTranslation(-Nr.x,-Nr.y,-Nr.z),Jd.multiplyMatrices(wt.projectionMatrix,wt.matrixWorldInverse),U._frustum.setFromProjectionMatrix(Jd,wt.coordinateSystem,wt.reversedDepth)}else U.updateMatrices(B);n=U.getFrustum(),b(C,_,U.camera,B,this.type)}U.isPointLightShadow!==!0&&this.type===Cs&&v(U,_),U.needsUpdate=!1}p=this.type,g.needsUpdate=!1,i.setRenderTarget(A,P,R)};function v(w,C){let _=t.update(x);h.defines.VSM_SAMPLES!==w.blurSamples&&(h.defines.VSM_SAMPLES=w.blurSamples,f.defines.VSM_SAMPLES=w.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new Ce(s.x,s.y,{format:ki,type:qe})),h.uniforms.shadow_pass.value=w.map.depthTexture,h.uniforms.resolution.value=w.mapSize,h.uniforms.radius.value=w.radius,i.setRenderTarget(w.mapPass),i.clear(),i.renderBufferDirect(C,null,_,h,x,null),f.uniforms.shadow_pass.value=w.mapPass.texture,f.uniforms.resolution.value=w.mapSize,f.uniforms.radius.value=w.radius,i.setRenderTarget(w.map),i.clear(),i.renderBufferDirect(C,null,_,f,x,null)}function M(w,C,_,A){let P=null,R=_.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(R!==void 0)P=R;else if(P=_.isPointLight===!0?l:a,i.localClippingEnabled&&C.clipShadows===!0&&Array.isArray(C.clippingPlanes)&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0||C.map&&C.alphaTest>0||C.alphaToCoverage===!0){let D=P.uuid,W=C.uuid,H=c[D];H===void 0&&(H={},c[D]=H);let k=H[W];k===void 0&&(k=P.clone(),H[W]=k,C.addEventListener("dispose",E)),P=k}if(P.visible=C.visible,P.wireframe=C.wireframe,A===Cs?P.side=C.shadowSide!==null?C.shadowSide:C.side:P.side=C.shadowSide!==null?C.shadowSide:d[C.side],P.alphaMap=C.alphaMap,P.alphaTest=C.alphaToCoverage===!0?.5:C.alphaTest,P.map=C.map,P.clipShadows=C.clipShadows,P.clippingPlanes=C.clippingPlanes,P.clipIntersection=C.clipIntersection,P.displacementMap=C.displacementMap,P.displacementScale=C.displacementScale,P.displacementBias=C.displacementBias,P.wireframeLinewidth=C.wireframeLinewidth,P.linewidth=C.linewidth,_.isPointLight===!0&&P.isMeshDistanceMaterial===!0){let D=i.properties.get(P);D.light=_}return P}function b(w,C,_,A,P){if(w.visible===!1)return;if(w.layers.test(C.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&P===Cs)&&(!w.frustumCulled||n.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,w.matrixWorld);let W=t.update(w),H=w.material;if(Array.isArray(H)){let k=W.groups;for(let B=0,U=k.length;B<U;B++){let j=k[B],Q=H[j.materialIndex];if(Q&&Q.visible){let ct=M(w,Q,A,P);w.onBeforeShadow(i,w,C,_,W,ct,j),i.renderBufferDirect(_,null,W,ct,w,j),w.onAfterShadow(i,w,C,_,W,ct,j)}}}else if(H.visible){let k=M(w,H,A,P);w.onBeforeShadow(i,w,C,_,W,k,null),i.renderBufferDirect(_,null,W,k,w,null),w.onAfterShadow(i,w,C,_,W,k,null)}}let D=w.children;for(let W=0,H=D.length;W<H;W++)b(D[W],C,_,A,P)}function E(w){w.target.removeEventListener("dispose",E);for(let _ in c){let A=c[_],P=w.target.uuid;P in A&&(A[P].dispose(),delete A[P])}}}function J_(i,t){function e(){let I=!1,nt=new xe,q=null,pt=new xe(0,0,0,0);return{setMask:function(rt){q!==rt&&!I&&(i.colorMask(rt,rt,rt,rt),q=rt)},setLocked:function(rt){I=rt},setClear:function(rt,K,Mt,kt,ye){ye===!0&&(rt*=kt,K*=kt,Mt*=kt),nt.set(rt,K,Mt,kt),pt.equals(nt)===!1&&(i.clearColor(rt,K,Mt,kt),pt.copy(nt))},reset:function(){I=!1,q=null,pt.set(-1,0,0,0)}}}function n(){let I=!1,nt=!1,q=null,pt=null,rt=null;return{setReversed:function(K){if(nt!==K){let Mt=t.get("EXT_clip_control");K?Mt.clipControlEXT(Mt.LOWER_LEFT_EXT,Mt.ZERO_TO_ONE_EXT):Mt.clipControlEXT(Mt.LOWER_LEFT_EXT,Mt.NEGATIVE_ONE_TO_ONE_EXT),nt=K;let kt=rt;rt=null,this.setClear(kt)}},getReversed:function(){return nt},setTest:function(K){K?it(i.DEPTH_TEST):Ct(i.DEPTH_TEST)},setMask:function(K){q!==K&&!I&&(i.depthMask(K),q=K)},setFunc:function(K){if(nt&&(K=Ad[K]),pt!==K){switch(K){case No:i.depthFunc(i.NEVER);break;case Fo:i.depthFunc(i.ALWAYS);break;case ko:i.depthFunc(i.LESS);break;case Zi:i.depthFunc(i.LEQUAL);break;case Oo:i.depthFunc(i.EQUAL);break;case Uo:i.depthFunc(i.GEQUAL);break;case Bo:i.depthFunc(i.GREATER);break;case zo:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}pt=K}},setLocked:function(K){I=K},setClear:function(K){rt!==K&&(rt=K,nt&&(K=1-K),i.clearDepth(K))},reset:function(){I=!1,q=null,pt=null,rt=null,nt=!1}}}function s(){let I=!1,nt=null,q=null,pt=null,rt=null,K=null,Mt=null,kt=null,ye=null;return{setTest:function(ee){I||(ee?it(i.STENCIL_TEST):Ct(i.STENCIL_TEST))},setMask:function(ee){nt!==ee&&!I&&(i.stencilMask(ee),nt=ee)},setFunc:function(ee,Xn,Dn){(q!==ee||pt!==Xn||rt!==Dn)&&(i.stencilFunc(ee,Xn,Dn),q=ee,pt=Xn,rt=Dn)},setOp:function(ee,Xn,Dn){(K!==ee||Mt!==Xn||kt!==Dn)&&(i.stencilOp(ee,Xn,Dn),K=ee,Mt=Xn,kt=Dn)},setLocked:function(ee){I=ee},setClear:function(ee){ye!==ee&&(i.clearStencil(ee),ye=ee)},reset:function(){I=!1,nt=null,q=null,pt=null,rt=null,K=null,Mt=null,kt=null,ye=null}}}let r=new e,o=new n,a=new s,l=new WeakMap,c=new WeakMap,u={},d={},h={},f=new WeakMap,m=[],x=null,g=!1,p=null,v=null,M=null,b=null,E=null,w=null,C=null,_=new mt(0,0,0),A=0,P=!1,R=null,D=null,W=null,H=null,k=null,B=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS),U=!1,j=0,Q=i.getParameter(i.VERSION);Q.indexOf("WebGL")!==-1?(j=parseFloat(/^WebGL (\d)/.exec(Q)[1]),U=j>=1):Q.indexOf("OpenGL ES")!==-1&&(j=parseFloat(/^OpenGL ES (\d)/.exec(Q)[1]),U=j>=2);let ct=null,_t={},wt=i.getParameter(i.SCISSOR_BOX),Zt=i.getParameter(i.VIEWPORT),Qt=new xe().fromArray(wt),Ut=new xe().fromArray(Zt);function $(I,nt,q,pt){let rt=new Uint8Array(4),K=i.createTexture();i.bindTexture(I,K),i.texParameteri(I,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(I,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Mt=0;Mt<q;Mt++)I===i.TEXTURE_3D||I===i.TEXTURE_2D_ARRAY?i.texImage3D(nt,0,i.RGBA,1,1,pt,0,i.RGBA,i.UNSIGNED_BYTE,rt):i.texImage2D(nt+Mt,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,rt);return K}let dt={};dt[i.TEXTURE_2D]=$(i.TEXTURE_2D,i.TEXTURE_2D,1),dt[i.TEXTURE_CUBE_MAP]=$(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),dt[i.TEXTURE_2D_ARRAY]=$(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),dt[i.TEXTURE_3D]=$(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),o.setClear(1),a.setClear(0),it(i.DEPTH_TEST),o.setFunc(Zi),Ee(!1),fe(Gc),it(i.CULL_FACE),le(yn);function it(I){u[I]!==!0&&(i.enable(I),u[I]=!0)}function Ct(I){u[I]!==!1&&(i.disable(I),u[I]=!1)}function Nt(I,nt){return h[I]!==nt?(i.bindFramebuffer(I,nt),h[I]=nt,I===i.DRAW_FRAMEBUFFER&&(h[i.FRAMEBUFFER]=nt),I===i.FRAMEBUFFER&&(h[i.DRAW_FRAMEBUFFER]=nt),!0):!1}function It(I,nt){let q=m,pt=!1;if(I){q=f.get(nt),q===void 0&&(q=[],f.set(nt,q));let rt=I.textures;if(q.length!==rt.length||q[0]!==i.COLOR_ATTACHMENT0){for(let K=0,Mt=rt.length;K<Mt;K++)q[K]=i.COLOR_ATTACHMENT0+K;q.length=rt.length,pt=!0}}else q[0]!==i.BACK&&(q[0]=i.BACK,pt=!0);pt&&i.drawBuffers(q)}function de(I){return x!==I?(i.useProgram(I),x=I,!0):!1}let Xt={[Mi]:i.FUNC_ADD,[Ku]:i.FUNC_SUBTRACT,[Ju]:i.FUNC_REVERSE_SUBTRACT};Xt[ju]=i.MIN,Xt[Qu]=i.MAX;let te={[td]:i.ZERO,[ed]:i.ONE,[nd]:i.SRC_COLOR,[Lo]:i.SRC_ALPHA,[ld]:i.SRC_ALPHA_SATURATE,[od]:i.DST_COLOR,[sd]:i.DST_ALPHA,[id]:i.ONE_MINUS_SRC_COLOR,[Do]:i.ONE_MINUS_SRC_ALPHA,[ad]:i.ONE_MINUS_DST_COLOR,[rd]:i.ONE_MINUS_DST_ALPHA,[cd]:i.CONSTANT_COLOR,[hd]:i.ONE_MINUS_CONSTANT_COLOR,[ud]:i.CONSTANT_ALPHA,[dd]:i.ONE_MINUS_CONSTANT_ALPHA};function le(I,nt,q,pt,rt,K,Mt,kt,ye,ee){if(I===yn){g===!0&&(Ct(i.BLEND),g=!1);return}if(g===!1&&(it(i.BLEND),g=!0),I!==$u){if(I!==p||ee!==P){if((v!==Mi||E!==Mi)&&(i.blendEquation(i.FUNC_ADD),v=Mi,E=Mi),ee)switch(I){case Yi:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case vr:i.blendFunc(i.ONE,i.ONE);break;case Vc:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Hc:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:Pt("WebGLState: Invalid blending: ",I);break}else switch(I){case Yi:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case vr:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case Vc:Pt("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Hc:Pt("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Pt("WebGLState: Invalid blending: ",I);break}M=null,b=null,w=null,C=null,_.set(0,0,0),A=0,p=I,P=ee}return}rt=rt||nt,K=K||q,Mt=Mt||pt,(nt!==v||rt!==E)&&(i.blendEquationSeparate(Xt[nt],Xt[rt]),v=nt,E=rt),(q!==M||pt!==b||K!==w||Mt!==C)&&(i.blendFuncSeparate(te[q],te[pt],te[K],te[Mt]),M=q,b=pt,w=K,C=Mt),(kt.equals(_)===!1||ye!==A)&&(i.blendColor(kt.r,kt.g,kt.b,ye),_.copy(kt),A=ye),p=I,P=!1}function Wt(I,nt){I.side===Vn?Ct(i.CULL_FACE):it(i.CULL_FACE);let q=I.side===$e;nt&&(q=!q),Ee(q),I.blending===Yi&&I.transparent===!1?le(yn):le(I.blending,I.blendEquation,I.blendSrc,I.blendDst,I.blendEquationAlpha,I.blendSrcAlpha,I.blendDstAlpha,I.blendColor,I.blendAlpha,I.premultipliedAlpha),o.setFunc(I.depthFunc),o.setTest(I.depthTest),o.setMask(I.depthWrite),r.setMask(I.colorWrite);let pt=I.stencilWrite;a.setTest(pt),pt&&(a.setMask(I.stencilWriteMask),a.setFunc(I.stencilFunc,I.stencilRef,I.stencilFuncMask),a.setOp(I.stencilFail,I.stencilZFail,I.stencilZPass)),N(I.polygonOffset,I.polygonOffsetFactor,I.polygonOffsetUnits),I.alphaToCoverage===!0?it(i.SAMPLE_ALPHA_TO_COVERAGE):Ct(i.SAMPLE_ALPHA_TO_COVERAGE)}function Ee(I){R!==I&&(I?i.frontFace(i.CW):i.frontFace(i.CCW),R=I)}function fe(I){I!==qu?(it(i.CULL_FACE),I!==D&&(I===Gc?i.cullFace(i.BACK):I===Yu?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):Ct(i.CULL_FACE),D=I}function nn(I){I!==W&&(U&&i.lineWidth(I),W=I)}function N(I,nt,q){I?(it(i.POLYGON_OFFSET_FILL),(H!==nt||k!==q)&&(H=nt,k=q,o.getReversed()&&(nt=-nt),i.polygonOffset(nt,q))):Ct(i.POLYGON_OFFSET_FILL)}function Te(I){I?it(i.SCISSOR_TEST):Ct(i.SCISSOR_TEST)}function qt(I){I===void 0&&(I=i.TEXTURE0+B-1),ct!==I&&(i.activeTexture(I),ct=I)}function oe(I,nt,q){q===void 0&&(ct===null?q=i.TEXTURE0+B-1:q=ct);let pt=_t[q];pt===void 0&&(pt={type:void 0,texture:void 0},_t[q]=pt),(pt.type!==I||pt.texture!==nt)&&(ct!==q&&(i.activeTexture(q),ct=q),i.bindTexture(I,nt||dt[I]),pt.type=I,pt.texture=nt)}function at(){let I=_t[ct];I!==void 0&&I.type!==void 0&&(i.bindTexture(I.type,null),I.type=void 0,I.texture=void 0)}function pe(){try{i.compressedTexImage2D(...arguments)}catch(I){Pt("WebGLState:",I)}}function T(){try{i.compressedTexImage3D(...arguments)}catch(I){Pt("WebGLState:",I)}}function y(){try{i.texSubImage2D(...arguments)}catch(I){Pt("WebGLState:",I)}}function O(){try{i.texSubImage3D(...arguments)}catch(I){Pt("WebGLState:",I)}}function Y(){try{i.compressedTexSubImage2D(...arguments)}catch(I){Pt("WebGLState:",I)}}function J(){try{i.compressedTexSubImage3D(...arguments)}catch(I){Pt("WebGLState:",I)}}function tt(){try{i.texStorage2D(...arguments)}catch(I){Pt("WebGLState:",I)}}function ot(){try{i.texStorage3D(...arguments)}catch(I){Pt("WebGLState:",I)}}function X(){try{i.texImage2D(...arguments)}catch(I){Pt("WebGLState:",I)}}function Z(){try{i.texImage3D(...arguments)}catch(I){Pt("WebGLState:",I)}}function ft(I){return d[I]!==void 0?d[I]:i.getParameter(I)}function xt(I,nt){d[I]!==nt&&(i.pixelStorei(I,nt),d[I]=nt)}function st(I){Qt.equals(I)===!1&&(i.scissor(I.x,I.y,I.z,I.w),Qt.copy(I))}function et(I){Ut.equals(I)===!1&&(i.viewport(I.x,I.y,I.z,I.w),Ut.copy(I))}function Lt(I,nt){let q=c.get(nt);q===void 0&&(q=new WeakMap,c.set(nt,q));let pt=q.get(I);pt===void 0&&(pt=i.getUniformBlockIndex(nt,I.name),q.set(I,pt))}function Bt(I,nt){let pt=c.get(nt).get(I);l.get(nt)!==pt&&(i.uniformBlockBinding(nt,pt,I.__bindingPointIndex),l.set(nt,pt))}function Kt(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),o.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),i.pixelStorei(i.PACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.BROWSER_DEFAULT_WEBGL),i.pixelStorei(i.PACK_ROW_LENGTH,0),i.pixelStorei(i.PACK_SKIP_PIXELS,0),i.pixelStorei(i.PACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_ROW_LENGTH,0),i.pixelStorei(i.UNPACK_IMAGE_HEIGHT,0),i.pixelStorei(i.UNPACK_SKIP_PIXELS,0),i.pixelStorei(i.UNPACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_SKIP_IMAGES,0),u={},d={},ct=null,_t={},h={},f=new WeakMap,m=[],x=null,g=!1,p=null,v=null,M=null,b=null,E=null,w=null,C=null,_=new mt(0,0,0),A=0,P=!1,R=null,D=null,W=null,H=null,k=null,Qt.set(0,0,i.canvas.width,i.canvas.height),Ut.set(0,0,i.canvas.width,i.canvas.height),r.reset(),o.reset(),a.reset()}return{buffers:{color:r,depth:o,stencil:a},enable:it,disable:Ct,bindFramebuffer:Nt,drawBuffers:It,useProgram:de,setBlending:le,setMaterial:Wt,setFlipSided:Ee,setCullFace:fe,setLineWidth:nn,setPolygonOffset:N,setScissorTest:Te,activeTexture:qt,bindTexture:oe,unbindTexture:at,compressedTexImage2D:pe,compressedTexImage3D:T,texImage2D:X,texImage3D:Z,pixelStorei:xt,getParameter:ft,updateUBOMapping:Lt,uniformBlockBinding:Bt,texStorage2D:tt,texStorage3D:ot,texSubImage2D:y,texSubImage3D:O,compressedTexSubImage2D:Y,compressedTexSubImage3D:J,scissor:st,viewport:et,reset:Kt}}function j_(i,t,e,n,s,r,o){let a=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Tt,u=new WeakMap,d=new Set,h,f=new WeakMap,m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(T,y){return m?new OffscreenCanvas(T,y):sr("canvas")}function g(T,y,O){let Y=1,J=pe(T);if((J.width>O||J.height>O)&&(Y=O/Math.max(J.width,J.height)),Y<1)if(typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&T instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&T instanceof ImageBitmap||typeof VideoFrame<"u"&&T instanceof VideoFrame){let tt=Math.floor(Y*J.width),ot=Math.floor(Y*J.height);h===void 0&&(h=x(tt,ot));let X=y?x(tt,ot):h;return X.width=tt,X.height=ot,X.getContext("2d").drawImage(T,0,0,tt,ot),At("WebGLRenderer: Texture has been resized from ("+J.width+"x"+J.height+") to ("+tt+"x"+ot+")."),X}else return"data"in T&&At("WebGLRenderer: Image in DataTexture is too big ("+J.width+"x"+J.height+")."),T;return T}function p(T){return T.generateMipmaps}function v(T){i.generateMipmap(T)}function M(T){return T.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:T.isWebGL3DRenderTarget?i.TEXTURE_3D:T.isWebGLArrayRenderTarget||T.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function b(T,y,O,Y,J,tt=!1){if(T!==null){if(i[T]!==void 0)return i[T];At("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let ot;Y&&(ot=t.get("EXT_texture_norm16"),ot||At("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let X=y;if(y===i.RED&&(O===i.FLOAT&&(X=i.R32F),O===i.HALF_FLOAT&&(X=i.R16F),O===i.UNSIGNED_BYTE&&(X=i.R8),O===i.UNSIGNED_SHORT&&ot&&(X=ot.R16_EXT),O===i.SHORT&&ot&&(X=ot.R16_SNORM_EXT)),y===i.RED_INTEGER&&(O===i.UNSIGNED_BYTE&&(X=i.R8UI),O===i.UNSIGNED_SHORT&&(X=i.R16UI),O===i.UNSIGNED_INT&&(X=i.R32UI),O===i.BYTE&&(X=i.R8I),O===i.SHORT&&(X=i.R16I),O===i.INT&&(X=i.R32I)),y===i.RG&&(O===i.FLOAT&&(X=i.RG32F),O===i.HALF_FLOAT&&(X=i.RG16F),O===i.UNSIGNED_BYTE&&(X=i.RG8),O===i.UNSIGNED_SHORT&&ot&&(X=ot.RG16_EXT),O===i.SHORT&&ot&&(X=ot.RG16_SNORM_EXT)),y===i.RG_INTEGER&&(O===i.UNSIGNED_BYTE&&(X=i.RG8UI),O===i.UNSIGNED_SHORT&&(X=i.RG16UI),O===i.UNSIGNED_INT&&(X=i.RG32UI),O===i.BYTE&&(X=i.RG8I),O===i.SHORT&&(X=i.RG16I),O===i.INT&&(X=i.RG32I)),y===i.RGB_INTEGER&&(O===i.UNSIGNED_BYTE&&(X=i.RGB8UI),O===i.UNSIGNED_SHORT&&(X=i.RGB16UI),O===i.UNSIGNED_INT&&(X=i.RGB32UI),O===i.BYTE&&(X=i.RGB8I),O===i.SHORT&&(X=i.RGB16I),O===i.INT&&(X=i.RGB32I)),y===i.RGBA_INTEGER&&(O===i.UNSIGNED_BYTE&&(X=i.RGBA8UI),O===i.UNSIGNED_SHORT&&(X=i.RGBA16UI),O===i.UNSIGNED_INT&&(X=i.RGBA32UI),O===i.BYTE&&(X=i.RGBA8I),O===i.SHORT&&(X=i.RGBA16I),O===i.INT&&(X=i.RGBA32I)),y===i.RGB&&(O===i.UNSIGNED_SHORT&&ot&&(X=ot.RGB16_EXT),O===i.SHORT&&ot&&(X=ot.RGB16_SNORM_EXT),O===i.UNSIGNED_INT_5_9_9_9_REV&&(X=i.RGB9_E5),O===i.UNSIGNED_INT_10F_11F_11F_REV&&(X=i.R11F_G11F_B10F)),y===i.RGBA){let Z=tt?nr:Vt.getTransfer(J);O===i.FLOAT&&(X=i.RGBA32F),O===i.HALF_FLOAT&&(X=i.RGBA16F),O===i.UNSIGNED_BYTE&&(X=Z===Jt?i.SRGB8_ALPHA8:i.RGBA8),O===i.UNSIGNED_SHORT&&ot&&(X=ot.RGBA16_EXT),O===i.SHORT&&ot&&(X=ot.RGBA16_SNORM_EXT),O===i.UNSIGNED_SHORT_4_4_4_4&&(X=i.RGBA4),O===i.UNSIGNED_SHORT_5_5_5_1&&(X=i.RGB5_A1)}return(X===i.R16F||X===i.R32F||X===i.RG16F||X===i.RG32F||X===i.RGBA16F||X===i.RGBA32F)&&t.get("EXT_color_buffer_float"),X}function E(T,y){let O;return T?y===null||y===Rn||y===Ps?O=i.DEPTH24_STENCIL8:y===Pn?O=i.DEPTH32F_STENCIL8:y===Rs&&(O=i.DEPTH24_STENCIL8,At("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):y===null||y===Rn||y===Ps?O=i.DEPTH_COMPONENT24:y===Pn?O=i.DEPTH_COMPONENT32F:y===Rs&&(O=i.DEPTH_COMPONENT16),O}function w(T,y){return p(T)===!0||T.isFramebufferTexture&&T.minFilter!==De&&T.minFilter!==Ue?Math.log2(Math.max(y.width,y.height))+1:T.mipmaps!==void 0&&T.mipmaps.length>0?T.mipmaps.length:T.isCompressedTexture&&Array.isArray(T.image)?y.mipmaps.length:1}function C(T){let y=T.target;y.removeEventListener("dispose",C),A(y),y.isVideoTexture&&u.delete(y),y.isHTMLTexture&&d.delete(y)}function _(T){let y=T.target;y.removeEventListener("dispose",_),R(y)}function A(T){let y=n.get(T);if(y.__webglInit===void 0)return;let O=T.source,Y=f.get(O);if(Y){let J=Y[y.__cacheKey];J.usedTimes--,J.usedTimes===0&&P(T),Object.keys(Y).length===0&&f.delete(O)}n.remove(T)}function P(T){let y=n.get(T);i.deleteTexture(y.__webglTexture);let O=T.source,Y=f.get(O);delete Y[y.__cacheKey],o.memory.textures--}function R(T){let y=n.get(T);if(T.depthTexture&&(T.depthTexture.dispose(),n.remove(T.depthTexture)),T.isWebGLCubeRenderTarget)for(let Y=0;Y<6;Y++){if(Array.isArray(y.__webglFramebuffer[Y]))for(let J=0;J<y.__webglFramebuffer[Y].length;J++)i.deleteFramebuffer(y.__webglFramebuffer[Y][J]);else i.deleteFramebuffer(y.__webglFramebuffer[Y]);y.__webglDepthbuffer&&i.deleteRenderbuffer(y.__webglDepthbuffer[Y])}else{if(Array.isArray(y.__webglFramebuffer))for(let Y=0;Y<y.__webglFramebuffer.length;Y++)i.deleteFramebuffer(y.__webglFramebuffer[Y]);else i.deleteFramebuffer(y.__webglFramebuffer);if(y.__webglDepthbuffer&&i.deleteRenderbuffer(y.__webglDepthbuffer),y.__webglMultisampledFramebuffer&&i.deleteFramebuffer(y.__webglMultisampledFramebuffer),y.__webglColorRenderbuffer)for(let Y=0;Y<y.__webglColorRenderbuffer.length;Y++)y.__webglColorRenderbuffer[Y]&&i.deleteRenderbuffer(y.__webglColorRenderbuffer[Y]);y.__webglDepthRenderbuffer&&i.deleteRenderbuffer(y.__webglDepthRenderbuffer)}let O=T.textures;for(let Y=0,J=O.length;Y<J;Y++){let tt=n.get(O[Y]);tt.__webglTexture&&(i.deleteTexture(tt.__webglTexture),o.memory.textures--),n.remove(O[Y])}n.remove(T)}let D=0;function W(){D=0}function H(){return D}function k(T){D=T}function B(){let T=D;return T>=s.maxTextures&&At("WebGLTextures: Trying to use "+T+" texture units while this GPU supports only "+s.maxTextures),D+=1,T}function U(T){let y=[];return y.push(T.wrapS),y.push(T.wrapT),y.push(T.wrapR||0),y.push(T.magFilter),y.push(T.minFilter),y.push(T.anisotropy),y.push(T.internalFormat),y.push(T.format),y.push(T.type),y.push(T.generateMipmaps),y.push(T.premultiplyAlpha),y.push(T.flipY),y.push(T.unpackAlignment),y.push(T.colorSpace),y.join()}function j(T,y){let O=n.get(T);if(T.isVideoTexture&&oe(T),T.isRenderTargetTexture===!1&&T.isExternalTexture!==!0&&T.version>0&&O.__version!==T.version){let Y=T.image;if(Y===null)At("WebGLRenderer: Texture marked for update but no image data found.");else if(Y.complete===!1)At("WebGLRenderer: Texture marked for update but image is incomplete");else{Ct(O,T,y);return}}else T.isExternalTexture&&(O.__webglTexture=T.sourceTexture?T.sourceTexture:null);e.bindTexture(i.TEXTURE_2D,O.__webglTexture,i.TEXTURE0+y)}function Q(T,y){let O=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&O.__version!==T.version){Ct(O,T,y);return}else T.isExternalTexture&&(O.__webglTexture=T.sourceTexture?T.sourceTexture:null);e.bindTexture(i.TEXTURE_2D_ARRAY,O.__webglTexture,i.TEXTURE0+y)}function ct(T,y){let O=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&O.__version!==T.version){Ct(O,T,y);return}e.bindTexture(i.TEXTURE_3D,O.__webglTexture,i.TEXTURE0+y)}function _t(T,y){let O=n.get(T);if(T.isCubeDepthTexture!==!0&&T.version>0&&O.__version!==T.version){Nt(O,T,y);return}e.bindTexture(i.TEXTURE_CUBE_MAP,O.__webglTexture,i.TEXTURE0+y)}let wt={[Go]:i.REPEAT,[Un]:i.CLAMP_TO_EDGE,[Vo]:i.MIRRORED_REPEAT},Zt={[De]:i.NEAREST,[md]:i.NEAREST_MIPMAP_NEAREST,[Tr]:i.NEAREST_MIPMAP_LINEAR,[Ue]:i.LINEAR,[xa]:i.LINEAR_MIPMAP_NEAREST,[Ni]:i.LINEAR_MIPMAP_LINEAR},Qt={[vd]:i.NEVER,[Sd]:i.ALWAYS,[_d]:i.LESS,[tl]:i.LEQUAL,[yd]:i.EQUAL,[el]:i.GEQUAL,[bd]:i.GREATER,[Md]:i.NOTEQUAL};function Ut(T,y){if(y.type===Pn&&t.has("OES_texture_float_linear")===!1&&(y.magFilter===Ue||y.magFilter===xa||y.magFilter===Tr||y.magFilter===Ni||y.minFilter===Ue||y.minFilter===xa||y.minFilter===Tr||y.minFilter===Ni)&&At("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(T,i.TEXTURE_WRAP_S,wt[y.wrapS]),i.texParameteri(T,i.TEXTURE_WRAP_T,wt[y.wrapT]),(T===i.TEXTURE_3D||T===i.TEXTURE_2D_ARRAY)&&i.texParameteri(T,i.TEXTURE_WRAP_R,wt[y.wrapR]),i.texParameteri(T,i.TEXTURE_MAG_FILTER,Zt[y.magFilter]),i.texParameteri(T,i.TEXTURE_MIN_FILTER,Zt[y.minFilter]),y.compareFunction&&(i.texParameteri(T,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(T,i.TEXTURE_COMPARE_FUNC,Qt[y.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(y.magFilter===De||y.minFilter!==Tr&&y.minFilter!==Ni||y.type===Pn&&t.has("OES_texture_float_linear")===!1)return;if(y.anisotropy>1||n.get(y).__currentAnisotropy){let O=t.get("EXT_texture_filter_anisotropic");i.texParameterf(T,O.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(y.anisotropy,s.getMaxAnisotropy())),n.get(y).__currentAnisotropy=y.anisotropy}}}function $(T,y){let O=!1;T.__webglInit===void 0&&(T.__webglInit=!0,y.addEventListener("dispose",C));let Y=y.source,J=f.get(Y);J===void 0&&(J={},f.set(Y,J));let tt=U(y);if(tt!==T.__cacheKey){J[tt]===void 0&&(J[tt]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,O=!0),J[tt].usedTimes++;let ot=J[T.__cacheKey];ot!==void 0&&(J[T.__cacheKey].usedTimes--,ot.usedTimes===0&&P(y)),T.__cacheKey=tt,T.__webglTexture=J[tt].texture}return O}function dt(T,y,O){return Math.floor(Math.floor(T/O)/y)}function it(T,y,O,Y){let tt=T.updateRanges;if(tt.length===0)e.texSubImage2D(i.TEXTURE_2D,0,0,0,y.width,y.height,O,Y,y.data);else{tt.sort((xt,st)=>xt.start-st.start);let ot=0;for(let xt=1;xt<tt.length;xt++){let st=tt[ot],et=tt[xt],Lt=st.start+st.count,Bt=dt(et.start,y.width,4),Kt=dt(st.start,y.width,4);et.start<=Lt+1&&Bt===Kt&&dt(et.start+et.count-1,y.width,4)===Bt?st.count=Math.max(st.count,et.start+et.count-st.start):(++ot,tt[ot]=et)}tt.length=ot+1;let X=e.getParameter(i.UNPACK_ROW_LENGTH),Z=e.getParameter(i.UNPACK_SKIP_PIXELS),ft=e.getParameter(i.UNPACK_SKIP_ROWS);e.pixelStorei(i.UNPACK_ROW_LENGTH,y.width);for(let xt=0,st=tt.length;xt<st;xt++){let et=tt[xt],Lt=Math.floor(et.start/4),Bt=Math.ceil(et.count/4),Kt=Lt%y.width,I=Math.floor(Lt/y.width),nt=Bt,q=1;e.pixelStorei(i.UNPACK_SKIP_PIXELS,Kt),e.pixelStorei(i.UNPACK_SKIP_ROWS,I),e.texSubImage2D(i.TEXTURE_2D,0,Kt,I,nt,q,O,Y,y.data)}T.clearUpdateRanges(),e.pixelStorei(i.UNPACK_ROW_LENGTH,X),e.pixelStorei(i.UNPACK_SKIP_PIXELS,Z),e.pixelStorei(i.UNPACK_SKIP_ROWS,ft)}}function Ct(T,y,O){let Y=i.TEXTURE_2D;(y.isDataArrayTexture||y.isCompressedArrayTexture)&&(Y=i.TEXTURE_2D_ARRAY),y.isData3DTexture&&(Y=i.TEXTURE_3D);let J=$(T,y),tt=y.source;e.bindTexture(Y,T.__webglTexture,i.TEXTURE0+O);let ot=n.get(tt);if(tt.version!==ot.__version||J===!0){if(e.activeTexture(i.TEXTURE0+O),(typeof ImageBitmap<"u"&&y.image instanceof ImageBitmap)===!1){let q=Vt.getPrimaries(Vt.workingColorSpace),pt=y.colorSpace===ai?null:Vt.getPrimaries(y.colorSpace),rt=y.colorSpace===ai||q===pt?i.NONE:i.BROWSER_DEFAULT_WEBGL;e.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,y.flipY),e.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),e.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,rt)}e.pixelStorei(i.UNPACK_ALIGNMENT,y.unpackAlignment);let Z=g(y.image,!1,s.maxTextureSize);Z=at(y,Z);let ft=r.convert(y.format,y.colorSpace),xt=r.convert(y.type),st=b(y.internalFormat,ft,xt,y.normalized,y.colorSpace,y.isVideoTexture);Ut(Y,y);let et,Lt=y.mipmaps,Bt=y.isVideoTexture!==!0,Kt=ot.__version===void 0||J===!0,I=tt.dataReady,nt=w(y,Z);if(y.isDepthTexture)st=E(y.format===Fi,y.type),Kt&&(Bt?e.texStorage2D(i.TEXTURE_2D,1,st,Z.width,Z.height):e.texImage2D(i.TEXTURE_2D,0,st,Z.width,Z.height,0,ft,xt,null));else if(y.isDataTexture)if(Lt.length>0){Bt&&Kt&&e.texStorage2D(i.TEXTURE_2D,nt,st,Lt[0].width,Lt[0].height);for(let q=0,pt=Lt.length;q<pt;q++)et=Lt[q],Bt?I&&e.texSubImage2D(i.TEXTURE_2D,q,0,0,et.width,et.height,ft,xt,et.data):e.texImage2D(i.TEXTURE_2D,q,st,et.width,et.height,0,ft,xt,et.data);y.generateMipmaps=!1}else Bt?(Kt&&e.texStorage2D(i.TEXTURE_2D,nt,st,Z.width,Z.height),I&&it(y,Z,ft,xt)):e.texImage2D(i.TEXTURE_2D,0,st,Z.width,Z.height,0,ft,xt,Z.data);else if(y.isCompressedTexture)if(y.isCompressedArrayTexture){Bt&&Kt&&e.texStorage3D(i.TEXTURE_2D_ARRAY,nt,st,Lt[0].width,Lt[0].height,Z.depth);for(let q=0,pt=Lt.length;q<pt;q++)if(et=Lt[q],y.format!==bn)if(ft!==null)if(Bt){if(I)if(y.layerUpdates.size>0){let rt=ah(et.width,et.height,y.format,y.type);for(let K of y.layerUpdates){let Mt=et.data.subarray(K*rt/et.data.BYTES_PER_ELEMENT,(K+1)*rt/et.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,q,0,0,K,et.width,et.height,1,ft,Mt)}y.clearLayerUpdates()}else e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,q,0,0,0,et.width,et.height,Z.depth,ft,et.data)}else e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,q,st,et.width,et.height,Z.depth,0,et.data,0,0);else At("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Bt?I&&e.texSubImage3D(i.TEXTURE_2D_ARRAY,q,0,0,0,et.width,et.height,Z.depth,ft,xt,et.data):e.texImage3D(i.TEXTURE_2D_ARRAY,q,st,et.width,et.height,Z.depth,0,ft,xt,et.data)}else{Bt&&Kt&&e.texStorage2D(i.TEXTURE_2D,nt,st,Lt[0].width,Lt[0].height);for(let q=0,pt=Lt.length;q<pt;q++)et=Lt[q],y.format!==bn?ft!==null?Bt?I&&e.compressedTexSubImage2D(i.TEXTURE_2D,q,0,0,et.width,et.height,ft,et.data):e.compressedTexImage2D(i.TEXTURE_2D,q,st,et.width,et.height,0,et.data):At("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Bt?I&&e.texSubImage2D(i.TEXTURE_2D,q,0,0,et.width,et.height,ft,xt,et.data):e.texImage2D(i.TEXTURE_2D,q,st,et.width,et.height,0,ft,xt,et.data)}else if(y.isDataArrayTexture)if(Bt){if(Kt&&e.texStorage3D(i.TEXTURE_2D_ARRAY,nt,st,Z.width,Z.height,Z.depth),I)if(y.layerUpdates.size>0){let q=ah(Z.width,Z.height,y.format,y.type);for(let pt of y.layerUpdates){let rt=Z.data.subarray(pt*q/Z.data.BYTES_PER_ELEMENT,(pt+1)*q/Z.data.BYTES_PER_ELEMENT);e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,pt,Z.width,Z.height,1,ft,xt,rt)}y.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,Z.width,Z.height,Z.depth,ft,xt,Z.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,st,Z.width,Z.height,Z.depth,0,ft,xt,Z.data);else if(y.isData3DTexture)Bt?(Kt&&e.texStorage3D(i.TEXTURE_3D,nt,st,Z.width,Z.height,Z.depth),I&&e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,Z.width,Z.height,Z.depth,ft,xt,Z.data)):e.texImage3D(i.TEXTURE_3D,0,st,Z.width,Z.height,Z.depth,0,ft,xt,Z.data);else if(y.isFramebufferTexture){if(Kt)if(Bt)e.texStorage2D(i.TEXTURE_2D,nt,st,Z.width,Z.height);else{let q=Z.width,pt=Z.height;for(let rt=0;rt<nt;rt++)e.texImage2D(i.TEXTURE_2D,rt,st,q,pt,0,ft,xt,null),q>>=1,pt>>=1}}else if(y.isHTMLTexture){if("texElementImage2D"in i){let q=i.canvas;if(q.hasAttribute("layoutsubtree")||q.setAttribute("layoutsubtree","true"),Z.parentNode!==q){q.appendChild(Z),d.add(y),q.onpaint=kt=>{let ye=kt.changedElements;for(let ee of d)ye.includes(ee.image)&&(ee.needsUpdate=!0)},q.requestPaint();return}let pt=0,rt=i.RGBA,K=i.RGBA,Mt=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,pt,rt,K,Mt,Z),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)}}else if(Lt.length>0){if(Bt&&Kt){let q=pe(Lt[0]);e.texStorage2D(i.TEXTURE_2D,nt,st,q.width,q.height)}for(let q=0,pt=Lt.length;q<pt;q++)et=Lt[q],Bt?I&&e.texSubImage2D(i.TEXTURE_2D,q,0,0,ft,xt,et):e.texImage2D(i.TEXTURE_2D,q,st,ft,xt,et);y.generateMipmaps=!1}else if(Bt){if(Kt){let q=pe(Z);e.texStorage2D(i.TEXTURE_2D,nt,st,q.width,q.height)}I&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,ft,xt,Z)}else e.texImage2D(i.TEXTURE_2D,0,st,ft,xt,Z);p(y)&&v(Y),ot.__version=tt.version,y.onUpdate&&y.onUpdate(y)}T.__version=y.version}function Nt(T,y,O){if(y.image.length!==6)return;let Y=$(T,y),J=y.source;e.bindTexture(i.TEXTURE_CUBE_MAP,T.__webglTexture,i.TEXTURE0+O);let tt=n.get(J);if(J.version!==tt.__version||Y===!0){e.activeTexture(i.TEXTURE0+O);let ot=Vt.getPrimaries(Vt.workingColorSpace),X=y.colorSpace===ai?null:Vt.getPrimaries(y.colorSpace),Z=y.colorSpace===ai||ot===X?i.NONE:i.BROWSER_DEFAULT_WEBGL;e.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,y.flipY),e.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),e.pixelStorei(i.UNPACK_ALIGNMENT,y.unpackAlignment),e.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Z);let ft=y.isCompressedTexture||y.image[0].isCompressedTexture,xt=y.image[0]&&y.image[0].isDataTexture,st=[];for(let K=0;K<6;K++)!ft&&!xt?st[K]=g(y.image[K],!0,s.maxCubemapSize):st[K]=xt?y.image[K].image:y.image[K],st[K]=at(y,st[K]);let et=st[0],Lt=r.convert(y.format,y.colorSpace),Bt=r.convert(y.type),Kt=b(y.internalFormat,Lt,Bt,y.normalized,y.colorSpace),I=y.isVideoTexture!==!0,nt=tt.__version===void 0||Y===!0,q=J.dataReady,pt=w(y,et);Ut(i.TEXTURE_CUBE_MAP,y);let rt;if(ft){I&&nt&&e.texStorage2D(i.TEXTURE_CUBE_MAP,pt,Kt,et.width,et.height);for(let K=0;K<6;K++){rt=st[K].mipmaps;for(let Mt=0;Mt<rt.length;Mt++){let kt=rt[Mt];y.format!==bn?Lt!==null?I?q&&e.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,Mt,0,0,kt.width,kt.height,Lt,kt.data):e.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,Mt,Kt,kt.width,kt.height,0,kt.data):At("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):I?q&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,Mt,0,0,kt.width,kt.height,Lt,Bt,kt.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,Mt,Kt,kt.width,kt.height,0,Lt,Bt,kt.data)}}}else{if(rt=y.mipmaps,I&&nt){rt.length>0&&pt++;let K=pe(st[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,pt,Kt,K.width,K.height)}for(let K=0;K<6;K++)if(xt){I?q&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,0,0,0,st[K].width,st[K].height,Lt,Bt,st[K].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,0,Kt,st[K].width,st[K].height,0,Lt,Bt,st[K].data);for(let Mt=0;Mt<rt.length;Mt++){let ye=rt[Mt].image[K].image;I?q&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,Mt+1,0,0,ye.width,ye.height,Lt,Bt,ye.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,Mt+1,Kt,ye.width,ye.height,0,Lt,Bt,ye.data)}}else{I?q&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,0,0,0,Lt,Bt,st[K]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,0,Kt,Lt,Bt,st[K]);for(let Mt=0;Mt<rt.length;Mt++){let kt=rt[Mt];I?q&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,Mt+1,0,0,Lt,Bt,kt.image[K]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+K,Mt+1,Kt,Lt,Bt,kt.image[K])}}}p(y)&&v(i.TEXTURE_CUBE_MAP),tt.__version=J.version,y.onUpdate&&y.onUpdate(y)}T.__version=y.version}function It(T,y,O,Y,J,tt){let ot=r.convert(O.format,O.colorSpace),X=r.convert(O.type),Z=b(O.internalFormat,ot,X,O.normalized,O.colorSpace),ft=n.get(y),xt=n.get(O);if(xt.__renderTarget=y,!ft.__hasExternalTextures){let st=Math.max(1,y.width>>tt),et=Math.max(1,y.height>>tt);J===i.TEXTURE_3D||J===i.TEXTURE_2D_ARRAY?e.texImage3D(J,tt,Z,st,et,y.depth,0,ot,X,null):e.texImage2D(J,tt,Z,st,et,0,ot,X,null)}e.bindFramebuffer(i.FRAMEBUFFER,T),qt(y)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Y,J,xt.__webglTexture,0,Te(y)):(J===i.TEXTURE_2D||J>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&J<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,Y,J,xt.__webglTexture,tt),e.bindFramebuffer(i.FRAMEBUFFER,null)}function de(T,y,O){if(i.bindRenderbuffer(i.RENDERBUFFER,T),y.depthBuffer){let Y=y.depthTexture,J=Y&&Y.isDepthTexture?Y.type:null,tt=E(y.stencilBuffer,J),ot=y.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;qt(y)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Te(y),tt,y.width,y.height):O?i.renderbufferStorageMultisample(i.RENDERBUFFER,Te(y),tt,y.width,y.height):i.renderbufferStorage(i.RENDERBUFFER,tt,y.width,y.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,ot,i.RENDERBUFFER,T)}else{let Y=y.textures;for(let J=0;J<Y.length;J++){let tt=Y[J],ot=r.convert(tt.format,tt.colorSpace),X=r.convert(tt.type),Z=b(tt.internalFormat,ot,X,tt.normalized,tt.colorSpace);qt(y)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Te(y),Z,y.width,y.height):O?i.renderbufferStorageMultisample(i.RENDERBUFFER,Te(y),Z,y.width,y.height):i.renderbufferStorage(i.RENDERBUFFER,Z,y.width,y.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Xt(T,y,O){let Y=y.isWebGLCubeRenderTarget===!0;if(e.bindFramebuffer(i.FRAMEBUFFER,T),!(y.depthTexture&&y.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");let J=n.get(y.depthTexture);if(J.__renderTarget=y,(!J.__webglTexture||y.depthTexture.image.width!==y.width||y.depthTexture.image.height!==y.height)&&(y.depthTexture.image.width=y.width,y.depthTexture.image.height=y.height,y.depthTexture.needsUpdate=!0),Y){if(J.__webglInit===void 0&&(J.__webglInit=!0,y.depthTexture.addEventListener("dispose",C)),J.__webglTexture===void 0){J.__webglTexture=i.createTexture(),e.bindTexture(i.TEXTURE_CUBE_MAP,J.__webglTexture),Ut(i.TEXTURE_CUBE_MAP,y.depthTexture);let ft=r.convert(y.depthTexture.format),xt=r.convert(y.depthTexture.type),st;y.depthTexture.format===Bn?st=i.DEPTH_COMPONENT24:y.depthTexture.format===Fi&&(st=i.DEPTH24_STENCIL8);for(let et=0;et<6;et++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+et,0,st,y.width,y.height,0,ft,xt,null)}}else j(y.depthTexture,0);let tt=J.__webglTexture,ot=Te(y),X=Y?i.TEXTURE_CUBE_MAP_POSITIVE_X+O:i.TEXTURE_2D,Z=y.depthTexture.format===Fi?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(y.depthTexture.format===Bn)qt(y)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Z,X,tt,0,ot):i.framebufferTexture2D(i.FRAMEBUFFER,Z,X,tt,0);else if(y.depthTexture.format===Fi)qt(y)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Z,X,tt,0,ot):i.framebufferTexture2D(i.FRAMEBUFFER,Z,X,tt,0);else throw new Error("Unknown depthTexture format")}function te(T){let y=n.get(T),O=T.isWebGLCubeRenderTarget===!0;if(y.__boundDepthTexture!==T.depthTexture){let Y=T.depthTexture;if(y.__depthDisposeCallback&&y.__depthDisposeCallback(),Y){let J=()=>{delete y.__boundDepthTexture,delete y.__depthDisposeCallback,Y.removeEventListener("dispose",J)};Y.addEventListener("dispose",J),y.__depthDisposeCallback=J}y.__boundDepthTexture=Y}if(T.depthTexture&&!y.__autoAllocateDepthBuffer)if(O)for(let Y=0;Y<6;Y++)Xt(y.__webglFramebuffer[Y],T,Y);else{let Y=T.texture.mipmaps;Y&&Y.length>0?Xt(y.__webglFramebuffer[0],T,0):Xt(y.__webglFramebuffer,T,0)}else if(O){y.__webglDepthbuffer=[];for(let Y=0;Y<6;Y++)if(e.bindFramebuffer(i.FRAMEBUFFER,y.__webglFramebuffer[Y]),y.__webglDepthbuffer[Y]===void 0)y.__webglDepthbuffer[Y]=i.createRenderbuffer(),de(y.__webglDepthbuffer[Y],T,!1);else{let J=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,tt=y.__webglDepthbuffer[Y];i.bindRenderbuffer(i.RENDERBUFFER,tt),i.framebufferRenderbuffer(i.FRAMEBUFFER,J,i.RENDERBUFFER,tt)}}else{let Y=T.texture.mipmaps;if(Y&&Y.length>0?e.bindFramebuffer(i.FRAMEBUFFER,y.__webglFramebuffer[0]):e.bindFramebuffer(i.FRAMEBUFFER,y.__webglFramebuffer),y.__webglDepthbuffer===void 0)y.__webglDepthbuffer=i.createRenderbuffer(),de(y.__webglDepthbuffer,T,!1);else{let J=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,tt=y.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,tt),i.framebufferRenderbuffer(i.FRAMEBUFFER,J,i.RENDERBUFFER,tt)}}e.bindFramebuffer(i.FRAMEBUFFER,null)}function le(T,y,O){let Y=n.get(T);y!==void 0&&It(Y.__webglFramebuffer,T,T.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),O!==void 0&&te(T)}function Wt(T){let y=T.texture,O=n.get(T),Y=n.get(y);T.addEventListener("dispose",_);let J=T.textures,tt=T.isWebGLCubeRenderTarget===!0,ot=J.length>1;if(ot||(Y.__webglTexture===void 0&&(Y.__webglTexture=i.createTexture()),Y.__version=y.version,o.memory.textures++),tt){O.__webglFramebuffer=[];for(let X=0;X<6;X++)if(y.mipmaps&&y.mipmaps.length>0){O.__webglFramebuffer[X]=[];for(let Z=0;Z<y.mipmaps.length;Z++)O.__webglFramebuffer[X][Z]=i.createFramebuffer()}else O.__webglFramebuffer[X]=i.createFramebuffer()}else{if(y.mipmaps&&y.mipmaps.length>0){O.__webglFramebuffer=[];for(let X=0;X<y.mipmaps.length;X++)O.__webglFramebuffer[X]=i.createFramebuffer()}else O.__webglFramebuffer=i.createFramebuffer();if(ot)for(let X=0,Z=J.length;X<Z;X++){let ft=n.get(J[X]);ft.__webglTexture===void 0&&(ft.__webglTexture=i.createTexture(),o.memory.textures++)}if(T.samples>0&&qt(T)===!1){O.__webglMultisampledFramebuffer=i.createFramebuffer(),O.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,O.__webglMultisampledFramebuffer);for(let X=0;X<J.length;X++){let Z=J[X];O.__webglColorRenderbuffer[X]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,O.__webglColorRenderbuffer[X]);let ft=r.convert(Z.format,Z.colorSpace),xt=r.convert(Z.type),st=b(Z.internalFormat,ft,xt,Z.normalized,Z.colorSpace,T.isXRRenderTarget===!0),et=Te(T);i.renderbufferStorageMultisample(i.RENDERBUFFER,et,st,T.width,T.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+X,i.RENDERBUFFER,O.__webglColorRenderbuffer[X])}i.bindRenderbuffer(i.RENDERBUFFER,null),T.depthBuffer&&(O.__webglDepthRenderbuffer=i.createRenderbuffer(),de(O.__webglDepthRenderbuffer,T,!0)),e.bindFramebuffer(i.FRAMEBUFFER,null)}}if(tt){e.bindTexture(i.TEXTURE_CUBE_MAP,Y.__webglTexture),Ut(i.TEXTURE_CUBE_MAP,y);for(let X=0;X<6;X++)if(y.mipmaps&&y.mipmaps.length>0)for(let Z=0;Z<y.mipmaps.length;Z++)It(O.__webglFramebuffer[X][Z],T,y,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+X,Z);else It(O.__webglFramebuffer[X],T,y,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+X,0);p(y)&&v(i.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(ot){for(let X=0,Z=J.length;X<Z;X++){let ft=J[X],xt=n.get(ft),st=i.TEXTURE_2D;(T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(st=T.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(st,xt.__webglTexture),Ut(st,ft),It(O.__webglFramebuffer,T,ft,i.COLOR_ATTACHMENT0+X,st,0),p(ft)&&v(st)}e.unbindTexture()}else{let X=i.TEXTURE_2D;if((T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(X=T.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(X,Y.__webglTexture),Ut(X,y),y.mipmaps&&y.mipmaps.length>0)for(let Z=0;Z<y.mipmaps.length;Z++)It(O.__webglFramebuffer[Z],T,y,i.COLOR_ATTACHMENT0,X,Z);else It(O.__webglFramebuffer,T,y,i.COLOR_ATTACHMENT0,X,0);p(y)&&v(X),e.unbindTexture()}T.depthBuffer&&te(T)}function Ee(T){let y=T.textures;for(let O=0,Y=y.length;O<Y;O++){let J=y[O];if(p(J)){let tt=M(T),ot=n.get(J).__webglTexture;e.bindTexture(tt,ot),v(tt),e.unbindTexture()}}}let fe=[],nn=[];function N(T){if(T.samples>0){if(qt(T)===!1){let y=T.textures,O=T.width,Y=T.height,J=i.COLOR_BUFFER_BIT,tt=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ot=n.get(T),X=y.length>1;if(X)for(let ft=0;ft<y.length;ft++)e.bindFramebuffer(i.FRAMEBUFFER,ot.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ft,i.RENDERBUFFER,null),e.bindFramebuffer(i.FRAMEBUFFER,ot.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ft,i.TEXTURE_2D,null,0);e.bindFramebuffer(i.READ_FRAMEBUFFER,ot.__webglMultisampledFramebuffer);let Z=T.texture.mipmaps;Z&&Z.length>0?e.bindFramebuffer(i.DRAW_FRAMEBUFFER,ot.__webglFramebuffer[0]):e.bindFramebuffer(i.DRAW_FRAMEBUFFER,ot.__webglFramebuffer);for(let ft=0;ft<y.length;ft++){if(T.resolveDepthBuffer&&(T.depthBuffer&&(J|=i.DEPTH_BUFFER_BIT),T.stencilBuffer&&T.resolveStencilBuffer&&(J|=i.STENCIL_BUFFER_BIT)),X){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,ot.__webglColorRenderbuffer[ft]);let xt=n.get(y[ft]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,xt,0)}i.blitFramebuffer(0,0,O,Y,0,0,O,Y,J,i.NEAREST),l===!0&&(fe.length=0,nn.length=0,fe.push(i.COLOR_ATTACHMENT0+ft),T.depthBuffer&&T.resolveDepthBuffer===!1&&(fe.push(tt),nn.push(tt),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,nn)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,fe))}if(e.bindFramebuffer(i.READ_FRAMEBUFFER,null),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),X)for(let ft=0;ft<y.length;ft++){e.bindFramebuffer(i.FRAMEBUFFER,ot.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ft,i.RENDERBUFFER,ot.__webglColorRenderbuffer[ft]);let xt=n.get(y[ft]).__webglTexture;e.bindFramebuffer(i.FRAMEBUFFER,ot.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ft,i.TEXTURE_2D,xt,0)}e.bindFramebuffer(i.DRAW_FRAMEBUFFER,ot.__webglMultisampledFramebuffer)}else if(T.depthBuffer&&T.resolveDepthBuffer===!1&&l){let y=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[y])}}}function Te(T){return Math.min(s.maxSamples,T.samples)}function qt(T){let y=n.get(T);return T.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&y.__useRenderToTexture!==!1}function oe(T){let y=o.render.frame;u.get(T)!==y&&(u.set(T,y),T.update())}function at(T,y){let O=T.colorSpace,Y=T.format,J=T.type;return T.isCompressedTexture===!0||T.isVideoTexture===!0||O!==er&&O!==ai&&(Vt.getTransfer(O)===Jt?(Y!==bn||J!==fn)&&At("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Pt("WebGLTextures: Unsupported texture color space:",O)),y}function pe(T){return typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement?(c.width=T.naturalWidth||T.width,c.height=T.naturalHeight||T.height):typeof VideoFrame<"u"&&T instanceof VideoFrame?(c.width=T.displayWidth,c.height=T.displayHeight):(c.width=T.width,c.height=T.height),c}this.allocateTextureUnit=B,this.resetTextureUnits=W,this.getTextureUnits=H,this.setTextureUnits=k,this.setTexture2D=j,this.setTexture2DArray=Q,this.setTexture3D=ct,this.setTextureCube=_t,this.rebindTextures=le,this.setupRenderTarget=Wt,this.updateRenderTargetMipmap=Ee,this.updateMultisampleRenderTarget=N,this.setupDepthRenderbuffer=te,this.setupFrameBufferTexture=It,this.useMultisampledRTT=qt,this.isReversedDepthBuffer=function(){return e.buffers.depth.getReversed()}}function Q_(i,t){function e(n,s=ai){let r,o=Vt.getTransfer(s);if(n===fn)return i.UNSIGNED_BYTE;if(n===_a)return i.UNSIGNED_SHORT_4_4_4_4;if(n===ya)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Zc)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===$c)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===qc)return i.BYTE;if(n===Yc)return i.SHORT;if(n===Rs)return i.UNSIGNED_SHORT;if(n===va)return i.INT;if(n===Rn)return i.UNSIGNED_INT;if(n===Pn)return i.FLOAT;if(n===qe)return i.HALF_FLOAT;if(n===Kc)return i.ALPHA;if(n===Jc)return i.RGB;if(n===bn)return i.RGBA;if(n===Bn)return i.DEPTH_COMPONENT;if(n===Fi)return i.DEPTH_STENCIL;if(n===jc)return i.RED;if(n===ba)return i.RED_INTEGER;if(n===ki)return i.RG;if(n===Ma)return i.RG_INTEGER;if(n===Sa)return i.RGBA_INTEGER;if(n===Ar||n===Cr||n===Rr||n===Pr)if(o===Jt)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Ar)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Cr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Rr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Pr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Ar)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Cr)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Rr)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Pr)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===wa||n===Ea||n===Ta||n===Aa)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===wa)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Ea)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Ta)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Aa)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Ca||n===Ra||n===Pa||n===Ia||n===La||n===Ir||n===Da)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Ca||n===Ra)return o===Jt?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Pa)return o===Jt?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===Ia)return r.COMPRESSED_R11_EAC;if(n===La)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Ir)return r.COMPRESSED_RG11_EAC;if(n===Da)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Na||n===Fa||n===ka||n===Oa||n===Ua||n===Ba||n===za||n===Ga||n===Va||n===Ha||n===Wa||n===Xa||n===qa||n===Ya)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Na)return o===Jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Fa)return o===Jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===ka)return o===Jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Oa)return o===Jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Ua)return o===Jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Ba)return o===Jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===za)return o===Jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Ga)return o===Jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Va)return o===Jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Ha)return o===Jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Wa)return o===Jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Xa)return o===Jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===qa)return o===Jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Ya)return o===Jt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Za||n===$a||n===Ka)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===Za)return o===Jt?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===$a)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Ka)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Ja||n===ja||n===Lr||n===Qa)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===Ja)return r.COMPRESSED_RED_RGTC1_EXT;if(n===ja)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Lr)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Qa)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ps?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:e}}var ty=`
void main() {
gl_Position = vec4( position, 1.0 );
}`,ey=`
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;
}
}`,Th=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){let n=new ur(t.texture);(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=n}}getMesh(t){if(this.texture!==null&&this.mesh===null){let e=t.cameras[0].viewport,n=new ue({vertexShader:ty,fragmentShader:ey,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new Xe(new dr(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Ah=class extends An{constructor(t,e){super();let n=this,s=null,r=1,o=null,a="local-floor",l=1,c=null,u=null,d=null,h=null,f=null,m=null,x=typeof XRWebGLBinding<"u",g=new Th,p={},v=e.getContextAttributes(),M=null,b=null,E=[],w=[],C=new Tt,_=null,A=new We;A.viewport=new xe;let P=new We;P.viewport=new xe;let R=[A,P],D=new da,W=null,H=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function($){let dt=E[$];return dt===void 0&&(dt=new Es,E[$]=dt),dt.getTargetRaySpace()},this.getControllerGrip=function($){let dt=E[$];return dt===void 0&&(dt=new Es,E[$]=dt),dt.getGripSpace()},this.getHand=function($){let dt=E[$];return dt===void 0&&(dt=new Es,E[$]=dt),dt.getHandSpace()};function k($){let dt=w.indexOf($.inputSource);if(dt===-1)return;let it=E[dt];it!==void 0&&(it.update($.inputSource,$.frame,c||o),it.dispatchEvent({type:$.type,data:$.inputSource}))}function B(){s.removeEventListener("select",k),s.removeEventListener("selectstart",k),s.removeEventListener("selectend",k),s.removeEventListener("squeeze",k),s.removeEventListener("squeezestart",k),s.removeEventListener("squeezeend",k),s.removeEventListener("end",B),s.removeEventListener("inputsourceschange",U);for(let $=0;$<E.length;$++){let dt=w[$];dt!==null&&(w[$]=null,E[$].disconnect(dt))}W=null,H=null,g.reset();for(let $ in p)delete p[$];t.setRenderTarget(M),f=null,h=null,d=null,s=null,b=null,Ut.stop(),n.isPresenting=!1,t.setPixelRatio(_),t.setSize(C.width,C.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function($){r=$,n.isPresenting===!0&&At("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function($){a=$,n.isPresenting===!0&&At("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function($){c=$},this.getBaseLayer=function(){return h!==null?h:f},this.getBinding=function(){return d===null&&x&&(d=new XRWebGLBinding(s,e)),d},this.getFrame=function(){return m},this.getSession=function(){return s},this.setSession=async function($){if(s=$,s!==null){if(M=t.getRenderTarget(),s.addEventListener("select",k),s.addEventListener("selectstart",k),s.addEventListener("selectend",k),s.addEventListener("squeeze",k),s.addEventListener("squeezestart",k),s.addEventListener("squeezeend",k),s.addEventListener("end",B),s.addEventListener("inputsourceschange",U),v.xrCompatible!==!0&&await e.makeXRCompatible(),_=t.getPixelRatio(),t.getSize(C),x&&"createProjectionLayer"in XRWebGLBinding.prototype){let it=null,Ct=null,Nt=null;v.depth&&(Nt=v.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,it=v.stencil?Fi:Bn,Ct=v.stencil?Ps:Rn);let It={colorFormat:e.RGBA8,depthFormat:Nt,scaleFactor:r};d=this.getBinding(),h=d.createProjectionLayer(It),s.updateRenderState({layers:[h]}),t.setPixelRatio(1),t.setSize(h.textureWidth,h.textureHeight,!1),b=new Ce(h.textureWidth,h.textureHeight,{format:bn,type:fn,depthTexture:new ri(h.textureWidth,h.textureHeight,Ct,void 0,void 0,void 0,void 0,void 0,void 0,it),stencilBuffer:v.stencil,colorSpace:t.outputColorSpace,samples:v.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1})}else{let it={antialias:v.antialias,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(s,e,it),s.updateRenderState({baseLayer:f}),t.setPixelRatio(1),t.setSize(f.framebufferWidth,f.framebufferHeight,!1),b=new Ce(f.framebufferWidth,f.framebufferHeight,{format:bn,type:fn,colorSpace:t.outputColorSpace,stencilBuffer:v.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}b.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await s.requestReferenceSpace(a),Ut.setContext(s),Ut.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};function U($){for(let dt=0;dt<$.removed.length;dt++){let it=$.removed[dt],Ct=w.indexOf(it);Ct>=0&&(w[Ct]=null,E[Ct].disconnect(it))}for(let dt=0;dt<$.added.length;dt++){let it=$.added[dt],Ct=w.indexOf(it);if(Ct===-1){for(let It=0;It<E.length;It++)if(It>=w.length){w.push(it),Ct=It;break}else if(w[It]===null){w[It]=it,Ct=It;break}if(Ct===-1)break}let Nt=E[Ct];Nt&&Nt.connect(it)}}let j=new L,Q=new L;function ct($,dt,it){j.setFromMatrixPosition(dt.matrixWorld),Q.setFromMatrixPosition(it.matrixWorld);let Ct=j.distanceTo(Q),Nt=dt.projectionMatrix.elements,It=it.projectionMatrix.elements,de=Nt[14]/(Nt[10]-1),Xt=Nt[14]/(Nt[10]+1),te=(Nt[9]+1)/Nt[5],le=(Nt[9]-1)/Nt[5],Wt=(Nt[8]-1)/Nt[0],Ee=(It[8]+1)/It[0],fe=de*Wt,nn=de*Ee,N=Ct/(-Wt+Ee),Te=N*-Wt;if(dt.matrixWorld.decompose($.position,$.quaternion,$.scale),$.translateX(Te),$.translateZ(N),$.matrixWorld.compose($.position,$.quaternion,$.scale),$.matrixWorldInverse.copy($.matrixWorld).invert(),Nt[10]===-1)$.projectionMatrix.copy(dt.projectionMatrix),$.projectionMatrixInverse.copy(dt.projectionMatrixInverse);else{let qt=de+N,oe=Xt+N,at=fe-Te,pe=nn+(Ct-Te),T=te*Xt/oe*qt,y=le*Xt/oe*qt;$.projectionMatrix.makePerspective(at,pe,T,y,qt,oe),$.projectionMatrixInverse.copy($.projectionMatrix).invert()}}function _t($,dt){dt===null?$.matrixWorld.copy($.matrix):$.matrixWorld.multiplyMatrices(dt.matrixWorld,$.matrix),$.matrixWorldInverse.copy($.matrixWorld).invert()}this.updateCamera=function($){if(s===null)return;let dt=$.near,it=$.far;g.texture!==null&&(g.depthNear>0&&(dt=g.depthNear),g.depthFar>0&&(it=g.depthFar)),D.near=P.near=A.near=dt,D.far=P.far=A.far=it,(W!==D.near||H!==D.far)&&(s.updateRenderState({depthNear:D.near,depthFar:D.far}),W=D.near,H=D.far),D.layers.mask=$.layers.mask|6,A.layers.mask=D.layers.mask&-5,P.layers.mask=D.layers.mask&-3;let Ct=$.parent,Nt=D.cameras;_t(D,Ct);for(let It=0;It<Nt.length;It++)_t(Nt[It],Ct);Nt.length===2?ct(D,A,P):D.projectionMatrix.copy(A.projectionMatrix),wt($,D,Ct)};function wt($,dt,it){it===null?$.matrix.copy(dt.matrixWorld):($.matrix.copy(it.matrixWorld),$.matrix.invert(),$.matrix.multiply(dt.matrixWorld)),$.matrix.decompose($.position,$.quaternion,$.scale),$.updateMatrixWorld(!0),$.projectionMatrix.copy(dt.projectionMatrix),$.projectionMatrixInverse.copy(dt.projectionMatrixInverse),$.isPerspectiveCamera&&($.fov=Ss*2*Math.atan(1/$.projectionMatrix.elements[5]),$.zoom=1)}this.getCamera=function(){return D},this.getFoveation=function(){if(!(h===null&&f===null))return l},this.setFoveation=function($){l=$,h!==null&&(h.fixedFoveation=$),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=$)},this.hasDepthSensing=function(){return g.texture!==null},this.getDepthSensingMesh=function(){return g.getMesh(D)},this.getCameraTexture=function($){return p[$]};let Zt=null;function Qt($,dt){if(u=dt.getViewerPose(c||o),m=dt,u!==null){let it=u.views;f!==null&&(t.setRenderTargetFramebuffer(b,f.framebuffer),t.setRenderTarget(b));let Ct=!1;it.length!==D.cameras.length&&(D.cameras.length=0,Ct=!0);for(let Xt=0;Xt<it.length;Xt++){let te=it[Xt],le=null;if(f!==null)le=f.getViewport(te);else{let Ee=d.getViewSubImage(h,te);le=Ee.viewport,Xt===0&&(t.setRenderTargetTextures(b,Ee.colorTexture,Ee.depthStencilTexture),t.setRenderTarget(b))}let Wt=R[Xt];Wt===void 0&&(Wt=new We,Wt.layers.enable(Xt),Wt.viewport=new xe,R[Xt]=Wt),Wt.matrix.fromArray(te.transform.matrix),Wt.matrix.decompose(Wt.position,Wt.quaternion,Wt.scale),Wt.projectionMatrix.fromArray(te.projectionMatrix),Wt.projectionMatrixInverse.copy(Wt.projectionMatrix).invert(),Wt.viewport.set(le.x,le.y,le.width,le.height),Xt===0&&(D.matrix.copy(Wt.matrix),D.matrix.decompose(D.position,D.quaternion,D.scale)),Ct===!0&&D.cameras.push(Wt)}let Nt=s.enabledFeatures;if(Nt&&Nt.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&x){d=n.getBinding();let Xt=d.getDepthInformation(it[0]);Xt&&Xt.isValid&&Xt.texture&&g.init(Xt,s.renderState)}if(Nt&&Nt.includes("camera-access")&&x){t.state.unbindTexture(),d=n.getBinding();for(let Xt=0;Xt<it.length;Xt++){let te=it[Xt].camera;if(te){let le=p[te];le||(le=new ur,p[te]=le);let Wt=d.getCameraImage(te);le.sourceTexture=Wt}}}}for(let it=0;it<E.length;it++){let Ct=w[it],Nt=E[it];Ct!==null&&Nt!==void 0&&Nt.update(Ct,dt,c||o)}Zt&&Zt($,dt),dt.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:dt}),m=null}let Ut=new jd;Ut.setAnimationLoop(Qt),this.setAnimationLoop=function($){Zt=$},this.dispose=function(){}}},ny=new ge,rf=new Dt;rf.set(-1,0,0,0,1,0,0,0,1);function iy(i,t){function e(g,p){g.matrixAutoUpdate===!0&&g.updateMatrix(),p.value.copy(g.matrix)}function n(g,p){p.color.getRGB(g.fogColor.value,sh(i)),p.isFog?(g.fogNear.value=p.near,g.fogFar.value=p.far):p.isFogExp2&&(g.fogDensity.value=p.density)}function s(g,p,v,M,b){p.isNodeMaterial?p.uniformsNeedUpdate=!1:p.isMeshBasicMaterial?r(g,p):p.isMeshLambertMaterial?(r(g,p),p.envMap&&(g.envMapIntensity.value=p.envMapIntensity)):p.isMeshToonMaterial?(r(g,p),d(g,p)):p.isMeshPhongMaterial?(r(g,p),u(g,p),p.envMap&&(g.envMapIntensity.value=p.envMapIntensity)):p.isMeshStandardMaterial?(r(g,p),h(g,p),p.isMeshPhysicalMaterial&&f(g,p,b)):p.isMeshMatcapMaterial?(r(g,p),m(g,p)):p.isMeshDepthMaterial?r(g,p):p.isMeshDistanceMaterial?(r(g,p),x(g,p)):p.isMeshNormalMaterial?r(g,p):p.isLineBasicMaterial?(o(g,p),p.isLineDashedMaterial&&a(g,p)):p.isPointsMaterial?l(g,p,v,M):p.isSpriteMaterial?c(g,p):p.isShadowMaterial?(g.color.value.copy(p.color),g.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function r(g,p){g.opacity.value=p.opacity,p.color&&g.diffuse.value.copy(p.color),p.emissive&&g.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(g.map.value=p.map,e(p.map,g.mapTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,e(p.alphaMap,g.alphaMapTransform)),p.bumpMap&&(g.bumpMap.value=p.bumpMap,e(p.bumpMap,g.bumpMapTransform),g.bumpScale.value=p.bumpScale,p.side===$e&&(g.bumpScale.value*=-1)),p.normalMap&&(g.normalMap.value=p.normalMap,e(p.normalMap,g.normalMapTransform),g.normalScale.value.copy(p.normalScale),p.side===$e&&g.normalScale.value.negate()),p.displacementMap&&(g.displacementMap.value=p.displacementMap,e(p.displacementMap,g.displacementMapTransform),g.displacementScale.value=p.displacementScale,g.displacementBias.value=p.displacementBias),p.emissiveMap&&(g.emissiveMap.value=p.emissiveMap,e(p.emissiveMap,g.emissiveMapTransform)),p.specularMap&&(g.specularMap.value=p.specularMap,e(p.specularMap,g.specularMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest);let v=t.get(p),M=v.envMap,b=v.envMapRotation;M&&(g.envMap.value=M,g.envMapRotation.value.setFromMatrix4(ny.makeRotationFromEuler(b)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&g.envMapRotation.value.premultiply(rf),g.reflectivity.value=p.reflectivity,g.ior.value=p.ior,g.refractionRatio.value=p.refractionRatio),p.lightMap&&(g.lightMap.value=p.lightMap,g.lightMapIntensity.value=p.lightMapIntensity,e(p.lightMap,g.lightMapTransform)),p.aoMap&&(g.aoMap.value=p.aoMap,g.aoMapIntensity.value=p.aoMapIntensity,e(p.aoMap,g.aoMapTransform))}function o(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,p.map&&(g.map.value=p.map,e(p.map,g.mapTransform))}function a(g,p){g.dashSize.value=p.dashSize,g.totalSize.value=p.dashSize+p.gapSize,g.scale.value=p.scale}function l(g,p,v,M){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.size.value=p.size*v,g.scale.value=M*.5,p.map&&(g.map.value=p.map,e(p.map,g.uvTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,e(p.alphaMap,g.alphaMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest)}function c(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.rotation.value=p.rotation,p.map&&(g.map.value=p.map,e(p.map,g.mapTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,e(p.alphaMap,g.alphaMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest)}function u(g,p){g.specular.value.copy(p.specular),g.shininess.value=Math.max(p.shininess,1e-4)}function d(g,p){p.gradientMap&&(g.gradientMap.value=p.gradientMap)}function h(g,p){g.metalness.value=p.metalness,p.metalnessMap&&(g.metalnessMap.value=p.metalnessMap,e(p.metalnessMap,g.metalnessMapTransform)),g.roughness.value=p.roughness,p.roughnessMap&&(g.roughnessMap.value=p.roughnessMap,e(p.roughnessMap,g.roughnessMapTransform)),p.envMap&&(g.envMapIntensity.value=p.envMapIntensity)}function f(g,p,v){g.ior.value=p.ior,p.sheen>0&&(g.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),g.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(g.sheenColorMap.value=p.sheenColorMap,e(p.sheenColorMap,g.sheenColorMapTransform)),p.sheenRoughnessMap&&(g.sheenRoughnessMap.value=p.sheenRoughnessMap,e(p.sheenRoughnessMap,g.sheenRoughnessMapTransform))),p.clearcoat>0&&(g.clearcoat.value=p.clearcoat,g.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(g.clearcoatMap.value=p.clearcoatMap,e(p.clearcoatMap,g.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,e(p.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(g.clearcoatNormalMap.value=p.clearcoatNormalMap,e(p.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===$e&&g.clearcoatNormalScale.value.negate())),p.dispersion>0&&(g.dispersion.value=p.dispersion),p.iridescence>0&&(g.iridescence.value=p.iridescence,g.iridescenceIOR.value=p.iridescenceIOR,g.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(g.iridescenceMap.value=p.iridescenceMap,e(p.iridescenceMap,g.iridescenceMapTransform)),p.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=p.iridescenceThicknessMap,e(p.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),p.transmission>0&&(g.transmission.value=p.transmission,g.transmissionSamplerMap.value=v.texture,g.transmissionSamplerSize.value.set(v.width,v.height),p.transmissionMap&&(g.transmissionMap.value=p.transmissionMap,e(p.transmissionMap,g.transmissionMapTransform)),g.thickness.value=p.thickness,p.thicknessMap&&(g.thicknessMap.value=p.thicknessMap,e(p.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=p.attenuationDistance,g.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(g.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(g.anisotropyMap.value=p.anisotropyMap,e(p.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=p.specularIntensity,g.specularColor.value.copy(p.specularColor),p.specularColorMap&&(g.specularColorMap.value=p.specularColorMap,e(p.specularColorMap,g.specularColorMapTransform)),p.specularIntensityMap&&(g.specularIntensityMap.value=p.specularIntensityMap,e(p.specularIntensityMap,g.specularIntensityMapTransform))}function m(g,p){p.matcap&&(g.matcap.value=p.matcap)}function x(g,p){let v=t.get(p).light;g.referencePosition.value.setFromMatrixPosition(v.matrixWorld),g.nearDistance.value=v.shadow.camera.near,g.farDistance.value=v.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function sy(i,t,e,n){let s={},r={},o=[],a=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(v,M){let b=M.program;n.uniformBlockBinding(v,b)}function c(v,M){let b=s[v.id];b===void 0&&(m(v),b=u(v),s[v.id]=b,v.addEventListener("dispose",g));let E=M.program;n.updateUBOMapping(v,E);let w=t.render.frame;r[v.id]!==w&&(h(v),r[v.id]=w)}function u(v){let M=d();v.__bindingPointIndex=M;let b=i.createBuffer(),E=v.__size,w=v.usage;return i.bindBuffer(i.UNIFORM_BUFFER,b),i.bufferData(i.UNIFORM_BUFFER,E,w),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,M,b),b}function d(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return Pt("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(v){let M=s[v.id],b=v.uniforms,E=v.__cache;i.bindBuffer(i.UNIFORM_BUFFER,M);for(let w=0,C=b.length;w<C;w++){let _=Array.isArray(b[w])?b[w]:[b[w]];for(let A=0,P=_.length;A<P;A++){let R=_[A];if(f(R,w,A,E)===!0){let D=R.__offset,W=Array.isArray(R.value)?R.value:[R.value],H=0;for(let k=0;k<W.length;k++){let B=W[k],U=x(B);typeof B=="number"||typeof B=="boolean"?(R.__data[0]=B,i.bufferSubData(i.UNIFORM_BUFFER,D+H,R.__data)):B.isMatrix3?(R.__data[0]=B.elements[0],R.__data[1]=B.elements[1],R.__data[2]=B.elements[2],R.__data[3]=0,R.__data[4]=B.elements[3],R.__data[5]=B.elements[4],R.__data[6]=B.elements[5],R.__data[7]=0,R.__data[8]=B.elements[6],R.__data[9]=B.elements[7],R.__data[10]=B.elements[8],R.__data[11]=0):ArrayBuffer.isView(B)?R.__data.set(new B.constructor(B.buffer,B.byteOffset,R.__data.length)):(B.toArray(R.__data,H),H+=U.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,D,R.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function f(v,M,b,E){let w=v.value,C=M+"_"+b;if(E[C]===void 0)return typeof w=="number"||typeof w=="boolean"?E[C]=w:ArrayBuffer.isView(w)?E[C]=w.slice():E[C]=w.clone(),!0;{let _=E[C];if(typeof w=="number"||typeof w=="boolean"){if(_!==w)return E[C]=w,!0}else{if(ArrayBuffer.isView(w))return!0;if(_.equals(w)===!1)return _.copy(w),!0}}return!1}function m(v){let M=v.uniforms,b=0,E=16;for(let C=0,_=M.length;C<_;C++){let A=Array.isArray(M[C])?M[C]:[M[C]];for(let P=0,R=A.length;P<R;P++){let D=A[P],W=Array.isArray(D.value)?D.value:[D.value];for(let H=0,k=W.length;H<k;H++){let B=W[H],U=x(B),j=b%E,Q=j%U.boundary,ct=j+Q;b+=Q,ct!==0&&E-ct<U.storage&&(b+=E-ct),D.__data=new Float32Array(U.storage/Float32Array.BYTES_PER_ELEMENT),D.__offset=b,b+=U.storage}}}let w=b%E;return w>0&&(b+=E-w),v.__size=b,v.__cache={},this}function x(v){let M={boundary:0,storage:0};return typeof v=="number"||typeof v=="boolean"?(M.boundary=4,M.storage=4):v.isVector2?(M.boundary=8,M.storage=8):v.isVector3||v.isColor?(M.boundary=16,M.storage=12):v.isVector4?(M.boundary=16,M.storage=16):v.isMatrix3?(M.boundary=48,M.storage=48):v.isMatrix4?(M.boundary=64,M.storage=64):v.isTexture?At("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(v)?(M.boundary=16,M.storage=v.byteLength):At("WebGLRenderer: Unsupported uniform value type.",v),M}function g(v){let M=v.target;M.removeEventListener("dispose",g);let b=o.indexOf(M.__bindingPointIndex);o.splice(b,1),i.deleteBuffer(s[M.id]),delete s[M.id],delete r[M.id]}function p(){for(let v in s)i.deleteBuffer(s[v]);o=[],s={},r={}}return{bind:l,update:c,dispose:p}}var ry=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]),Hn=null;function oy(){return Hn===null&&(Hn=new Zo(ry,16,16,ki,qe),Hn.name="DFG_LUT",Hn.minFilter=Ue,Hn.magFilter=Ue,Hn.wrapS=Un,Hn.wrapT=Un,Hn.generateMipmaps=!1,Hn.needsUpdate=!0),Hn}var Ns=class{constructor(t={}){let{canvas:e=wd(),context:n=null,depth:s=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:h=!1,outputBufferType:f=fn}=t;this.isWebGLRenderer=!0;let m;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=n.getContextAttributes().alpha}else m=o;let x=f,g=new Set([Sa,Ma,ba]),p=new Set([fn,Rn,Rs,Ps,_a,ya]),v=new Uint32Array(4),M=new Int32Array(4),b=new L,E=null,w=null,C=[],_=[],A=null;this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=dn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let P=this,R=!1,D=null;this._outputColorSpace=ln;let W=0,H=0,k=null,B=-1,U=null,j=new xe,Q=new xe,ct=null,_t=new mt(0),wt=0,Zt=e.width,Qt=e.height,Ut=1,$=null,dt=null,it=new xe(0,0,Zt,Qt),Ct=new xe(0,0,Zt,Qt),Nt=!1,It=new cr,de=!1,Xt=!1,te=new ge,le=new L,Wt=new xe,Ee={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},fe=!1;function nn(){return k===null?Ut:1}let N=n;function Te(S,F){return e.getContext(S,F)}try{let S={alpha:!0,depth:s,stencil:r,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:d};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${pa}`),e.addEventListener("webglcontextlost",K,!1),e.addEventListener("webglcontextrestored",Mt,!1),e.addEventListener("webglcontextcreationerror",kt,!1),N===null){let F="webgl2";if(N=Te(F,S),N===null)throw Te(F)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(S){throw Pt("WebGLRenderer: "+S.message),S}let qt,oe,at,pe,T,y,O,Y,J,tt,ot,X,Z,ft,xt,st,et,Lt,Bt,Kt,I,nt,q;function pt(){qt=new fv(N),qt.init(),I=new Q_(N,qt),oe=new rv(N,qt,t,I),at=new J_(N,qt),oe.reversedDepthBuffer&&h&&at.buffers.depth.setReversed(!0),pe=new gv(N),T=new O_,y=new j_(N,qt,at,T,oe,I,pe),O=new dv(P),Y=new yg(N),nt=new iv(N,Y),J=new pv(N,Y,pe,nt),tt=new vv(N,J,Y,nt,pe),Lt=new xv(N,oe,y),xt=new ov(T),ot=new k_(P,O,qt,oe,nt,xt),X=new iy(P,T),Z=new B_,ft=new X_(qt),et=new nv(P,O,at,tt,m,l),st=new K_(P,tt,oe),q=new sy(N,pe,oe,at),Bt=new sv(N,qt,pe),Kt=new mv(N,qt,pe),pe.programs=ot.programs,P.capabilities=oe,P.extensions=qt,P.properties=T,P.renderLists=Z,P.shadowMap=st,P.state=at,P.info=pe}pt(),x!==fn&&(A=new yv(x,e.width,e.height,s,r));let rt=new Ah(P,N);this.xr=rt,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){let S=qt.get("WEBGL_lose_context");S&&S.loseContext()},this.forceContextRestore=function(){let S=qt.get("WEBGL_lose_context");S&&S.restoreContext()},this.getPixelRatio=function(){return Ut},this.setPixelRatio=function(S){S!==void 0&&(Ut=S,this.setSize(Zt,Qt,!1))},this.getSize=function(S){return S.set(Zt,Qt)},this.setSize=function(S,F,V=!0){if(rt.isPresenting){At("WebGLRenderer: Can't change size while VR device is presenting.");return}Zt=S,Qt=F,e.width=Math.floor(S*Ut),e.height=Math.floor(F*Ut),V===!0&&(e.style.width=S+"px",e.style.height=F+"px"),A!==null&&A.setSize(e.width,e.height),this.setViewport(0,0,S,F)},this.getDrawingBufferSize=function(S){return S.set(Zt*Ut,Qt*Ut).floor()},this.setDrawingBufferSize=function(S,F,V){Zt=S,Qt=F,Ut=V,e.width=Math.floor(S*V),e.height=Math.floor(F*V),this.setViewport(0,0,S,F)},this.setEffects=function(S){if(x===fn){Pt("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(S){for(let F=0;F<S.length;F++)if(S[F].isOutputPass===!0){At("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}A.setEffects(S||[])},this.getCurrentViewport=function(S){return S.copy(j)},this.getViewport=function(S){return S.copy(it)},this.setViewport=function(S,F,V,z){S.isVector4?it.set(S.x,S.y,S.z,S.w):it.set(S,F,V,z),at.viewport(j.copy(it).multiplyScalar(Ut).round())},this.getScissor=function(S){return S.copy(Ct)},this.setScissor=function(S,F,V,z){S.isVector4?Ct.set(S.x,S.y,S.z,S.w):Ct.set(S,F,V,z),at.scissor(Q.copy(Ct).multiplyScalar(Ut).round())},this.getScissorTest=function(){return Nt},this.setScissorTest=function(S){at.setScissorTest(Nt=S)},this.setOpaqueSort=function(S){$=S},this.setTransparentSort=function(S){dt=S},this.getClearColor=function(S){return S.copy(et.getClearColor())},this.setClearColor=function(){et.setClearColor(...arguments)},this.getClearAlpha=function(){return et.getClearAlpha()},this.setClearAlpha=function(){et.setClearAlpha(...arguments)},this.clear=function(S=!0,F=!0,V=!0){let z=0;if(S){let G=!1;if(k!==null){let ut=k.texture.format;G=g.has(ut)}if(G){let ut=k.texture.type,vt=p.has(ut),ht=et.getClearColor(),yt=et.getClearAlpha(),St=ht.r,Ot=ht.g,Gt=ht.b;vt?(v[0]=St,v[1]=Ot,v[2]=Gt,v[3]=yt,N.clearBufferuiv(N.COLOR,0,v)):(M[0]=St,M[1]=Ot,M[2]=Gt,M[3]=yt,N.clearBufferiv(N.COLOR,0,M))}else z|=N.COLOR_BUFFER_BIT}F&&(z|=N.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),V&&(z|=N.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),z!==0&&N.clear(z)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(S){S.setRenderer(this),D=S},this.dispose=function(){e.removeEventListener("webglcontextlost",K,!1),e.removeEventListener("webglcontextrestored",Mt,!1),e.removeEventListener("webglcontextcreationerror",kt,!1),et.dispose(),Z.dispose(),ft.dispose(),T.dispose(),O.dispose(),tt.dispose(),nt.dispose(),q.dispose(),ot.dispose(),rt.dispose(),rt.removeEventListener("sessionstart",cu),rt.removeEventListener("sessionend",hu),Gi.stop()};function K(S){S.preventDefault(),eh("WebGLRenderer: Context Lost."),R=!0}function Mt(){eh("WebGLRenderer: Context Restored."),R=!1;let S=pe.autoReset,F=st.enabled,V=st.autoUpdate,z=st.needsUpdate,G=st.type;pt(),pe.autoReset=S,st.enabled=F,st.autoUpdate=V,st.needsUpdate=z,st.type=G}function kt(S){Pt("WebGLRenderer: A WebGL context could not be created. Reason: ",S.statusMessage)}function ye(S){let F=S.target;F.removeEventListener("dispose",ye),ee(F)}function ee(S){Xn(S),T.remove(S)}function Xn(S){let F=T.get(S).programs;F!==void 0&&(F.forEach(function(V){ot.releaseProgram(V)}),S.isShaderMaterial&&ot.releaseShaderCache(S))}this.renderBufferDirect=function(S,F,V,z,G,ut){F===null&&(F=Ee);let vt=G.isMesh&&G.matrixWorld.determinant()<0,ht=hm(S,F,V,z,G);at.setMaterial(z,vt);let yt=V.index,St=1;if(z.wireframe===!0){if(yt=J.getWireframeAttribute(V),yt===void 0)return;St=2}let Ot=V.drawRange,Gt=V.attributes.position,Et=Ot.start*St,ne=(Ot.start+Ot.count)*St;ut!==null&&(Et=Math.max(Et,ut.start*St),ne=Math.min(ne,(ut.start+ut.count)*St)),yt!==null?(Et=Math.max(Et,0),ne=Math.min(ne,yt.count)):Gt!=null&&(Et=Math.max(Et,0),ne=Math.min(ne,Gt.count));let be=ne-Et;if(be<0||be===1/0)return;nt.setup(G,z,ht,V,yt);let me,se=Bt;if(yt!==null&&(me=Y.get(yt),se=Kt,se.setIndex(me)),G.isMesh)z.wireframe===!0?(at.setLineWidth(z.wireframeLinewidth*nn()),se.setMode(N.LINES)):se.setMode(N.TRIANGLES);else if(G.isLine){let Ge=z.linewidth;Ge===void 0&&(Ge=1),at.setLineWidth(Ge*nn()),G.isLineSegments?se.setMode(N.LINES):G.isLineLoop?se.setMode(N.LINE_LOOP):se.setMode(N.LINE_STRIP)}else G.isPoints?se.setMode(N.POINTS):G.isSprite&&se.setMode(N.TRIANGLES);if(G.isBatchedMesh)if(qt.get("WEBGL_multi_draw"))se.renderMultiDraw(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount);else{let Ge=G._multiDrawStarts,gt=G._multiDrawCounts,sn=G._multiDrawCount,$t=yt?Y.get(yt).bytesPerElement:1,gn=T.get(z).currentProgram.getUniforms();for(let Nn=0;Nn<sn;Nn++)gn.setValue(N,"_gl_DrawID",Nn),se.render(Ge[Nn]/$t,gt[Nn])}else if(G.isInstancedMesh)se.renderInstances(Et,be,G.count);else if(V.isInstancedBufferGeometry){let Ge=V._maxInstanceCount!==void 0?V._maxInstanceCount:1/0,gt=Math.min(V.instanceCount,Ge);se.renderInstances(Et,be,gt)}else se.render(Et,be)};function Dn(S,F,V){S.transparent===!0&&S.side===Vn&&S.forceSinglePass===!1?(S.side=$e,S.needsUpdate=!0,jr(S,F,V),S.side=ei,S.needsUpdate=!0,jr(S,F,V),S.side=Vn):jr(S,F,V)}this.compile=function(S,F,V=null){V===null&&(V=S),w=ft.get(V),w.init(F),_.push(w),V.traverseVisible(function(G){G.isLight&&G.layers.test(F.layers)&&(w.pushLight(G),G.castShadow&&w.pushShadow(G))}),S!==V&&S.traverseVisible(function(G){G.isLight&&G.layers.test(F.layers)&&(w.pushLight(G),G.castShadow&&w.pushShadow(G))}),w.setupLights();let z=new Set;return S.traverse(function(G){if(!(G.isMesh||G.isPoints||G.isLine||G.isSprite))return;let ut=G.material;if(ut)if(Array.isArray(ut))for(let vt=0;vt<ut.length;vt++){let ht=ut[vt];Dn(ht,V,G),z.add(ht)}else Dn(ut,V,G),z.add(ut)}),w=_.pop(),z},this.compileAsync=function(S,F,V=null){let z=this.compile(S,F,V);return new Promise(G=>{function ut(){if(z.forEach(function(vt){T.get(vt).currentProgram.isReady()&&z.delete(vt)}),z.size===0){G(S);return}setTimeout(ut,10)}qt.get("KHR_parallel_shader_compile")!==null?ut():setTimeout(ut,10)})};let nc=null;function lm(S){nc&&nc(S)}function cu(){Gi.stop()}function hu(){Gi.start()}let Gi=new jd;Gi.setAnimationLoop(lm),typeof self<"u"&&Gi.setContext(self),this.setAnimationLoop=function(S){nc=S,rt.setAnimationLoop(S),S===null?Gi.stop():Gi.start()},rt.addEventListener("sessionstart",cu),rt.addEventListener("sessionend",hu),this.render=function(S,F){if(F!==void 0&&F.isCamera!==!0){Pt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(R===!0)return;D!==null&&D.renderStart(S,F);let V=rt.enabled===!0&&rt.isPresenting===!0,z=A!==null&&(k===null||V)&&A.begin(P,k);if(S.matrixWorldAutoUpdate===!0&&S.updateMatrixWorld(),F.parent===null&&F.matrixWorldAutoUpdate===!0&&F.updateMatrixWorld(),rt.enabled===!0&&rt.isPresenting===!0&&(A===null||A.isCompositing()===!1)&&(rt.cameraAutoUpdate===!0&&rt.updateCamera(F),F=rt.getCamera()),S.isScene===!0&&S.onBeforeRender(P,S,F,k),w=ft.get(S,_.length),w.init(F),w.state.textureUnits=y.getTextureUnits(),_.push(w),te.multiplyMatrices(F.projectionMatrix,F.matrixWorldInverse),It.setFromProjectionMatrix(te,Tn,F.reversedDepth),Xt=this.localClippingEnabled,de=xt.init(this.clippingPlanes,Xt),E=Z.get(S,C.length),E.init(),C.push(E),rt.enabled===!0&&rt.isPresenting===!0){let vt=P.xr.getDepthSensingMesh();vt!==null&&ic(vt,F,-1/0,P.sortObjects)}ic(S,F,0,P.sortObjects),E.finish(),P.sortObjects===!0&&E.sort($,dt),fe=rt.enabled===!1||rt.isPresenting===!1||rt.hasDepthSensing()===!1,fe&&et.addToRenderList(E,S),this.info.render.frame++,de===!0&&xt.beginShadows();let G=w.state.shadowsArray;if(st.render(G,S,F),de===!0&&xt.endShadows(),this.info.autoReset===!0&&this.info.reset(),(z&&A.hasRenderPass())===!1){let vt=E.opaque,ht=E.transmissive;if(w.setupLights(),F.isArrayCamera){let yt=F.cameras;if(ht.length>0)for(let St=0,Ot=yt.length;St<Ot;St++){let Gt=yt[St];du(vt,ht,S,Gt)}fe&&et.render(S);for(let St=0,Ot=yt.length;St<Ot;St++){let Gt=yt[St];uu(E,S,Gt,Gt.viewport)}}else ht.length>0&&du(vt,ht,S,F),fe&&et.render(S),uu(E,S,F)}k!==null&&H===0&&(y.updateMultisampleRenderTarget(k),y.updateRenderTargetMipmap(k)),z&&A.end(P),S.isScene===!0&&S.onAfterRender(P,S,F),nt.resetDefaultState(),B=-1,U=null,_.pop(),_.length>0?(w=_[_.length-1],y.setTextureUnits(w.state.textureUnits),de===!0&&xt.setGlobalState(P.clippingPlanes,w.state.camera)):w=null,C.pop(),C.length>0?E=C[C.length-1]:E=null,D!==null&&D.renderEnd()};function ic(S,F,V,z){if(S.visible===!1)return;if(S.layers.test(F.layers)){if(S.isGroup)V=S.renderOrder;else if(S.isLOD)S.autoUpdate===!0&&S.update(F);else if(S.isLightProbeGrid)w.pushLightProbeGrid(S);else if(S.isLight)w.pushLight(S),S.castShadow&&w.pushShadow(S);else if(S.isSprite){if(!S.frustumCulled||It.intersectsSprite(S)){z&&Wt.setFromMatrixPosition(S.matrixWorld).applyMatrix4(te);let vt=tt.update(S),ht=S.material;ht.visible&&E.push(S,vt,ht,V,Wt.z,null)}}else if((S.isMesh||S.isLine||S.isPoints)&&(!S.frustumCulled||It.intersectsObject(S))){let vt=tt.update(S),ht=S.material;if(z&&(S.boundingSphere!==void 0?(S.boundingSphere===null&&S.computeBoundingSphere(),Wt.copy(S.boundingSphere.center)):(vt.boundingSphere===null&&vt.computeBoundingSphere(),Wt.copy(vt.boundingSphere.center)),Wt.applyMatrix4(S.matrixWorld).applyMatrix4(te)),Array.isArray(ht)){let yt=vt.groups;for(let St=0,Ot=yt.length;St<Ot;St++){let Gt=yt[St],Et=ht[Gt.materialIndex];Et&&Et.visible&&E.push(S,vt,Et,V,Wt.z,Gt)}}else ht.visible&&E.push(S,vt,ht,V,Wt.z,null)}}let ut=S.children;for(let vt=0,ht=ut.length;vt<ht;vt++)ic(ut[vt],F,V,z)}function uu(S,F,V,z){let{opaque:G,transmissive:ut,transparent:vt}=S;w.setupLightsView(V),de===!0&&xt.setGlobalState(P.clippingPlanes,V),z&&at.viewport(j.copy(z)),G.length>0&&Jr(G,F,V),ut.length>0&&Jr(ut,F,V),vt.length>0&&Jr(vt,F,V),at.buffers.depth.setTest(!0),at.buffers.depth.setMask(!0),at.buffers.color.setMask(!0),at.setPolygonOffset(!1)}function du(S,F,V,z){if((V.isScene===!0?V.overrideMaterial:null)!==null)return;if(w.state.transmissionRenderTarget[z.id]===void 0){let Et=qt.has("EXT_color_buffer_half_float")||qt.has("EXT_color_buffer_float");w.state.transmissionRenderTarget[z.id]=new Ce(1,1,{generateMipmaps:!0,type:Et?qe:fn,minFilter:Ni,samples:Math.max(4,oe.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Vt.workingColorSpace})}let ut=w.state.transmissionRenderTarget[z.id],vt=z.viewport||j;ut.setSize(vt.z*P.transmissionResolutionScale,vt.w*P.transmissionResolutionScale);let ht=P.getRenderTarget(),yt=P.getActiveCubeFace(),St=P.getActiveMipmapLevel();P.setRenderTarget(ut),P.getClearColor(_t),wt=P.getClearAlpha(),wt<1&&P.setClearColor(16777215,.5),P.clear(),fe&&et.render(V);let Ot=P.toneMapping;P.toneMapping=dn;let Gt=z.viewport;if(z.viewport!==void 0&&(z.viewport=void 0),w.setupLightsView(z),de===!0&&xt.setGlobalState(P.clippingPlanes,z),Jr(S,V,z),y.updateMultisampleRenderTarget(ut),y.updateRenderTargetMipmap(ut),qt.has("WEBGL_multisampled_render_to_texture")===!1){let Et=!1;for(let ne=0,be=F.length;ne<be;ne++){let me=F[ne],{object:se,geometry:Ge,material:gt,group:sn}=me;if(gt.side===Vn&&se.layers.test(z.layers)){let $t=gt.side;gt.side=$e,gt.needsUpdate=!0,fu(se,V,z,Ge,gt,sn),gt.side=$t,gt.needsUpdate=!0,Et=!0}}Et===!0&&(y.updateMultisampleRenderTarget(ut),y.updateRenderTargetMipmap(ut))}P.setRenderTarget(ht,yt,St),P.setClearColor(_t,wt),Gt!==void 0&&(z.viewport=Gt),P.toneMapping=Ot}function Jr(S,F,V){let z=F.isScene===!0?F.overrideMaterial:null;for(let G=0,ut=S.length;G<ut;G++){let vt=S[G],{object:ht,geometry:yt,group:St}=vt,Ot=vt.material;Ot.allowOverride===!0&&z!==null&&(Ot=z),ht.layers.test(V.layers)&&fu(ht,F,V,yt,Ot,St)}}function fu(S,F,V,z,G,ut){S.onBeforeRender(P,F,V,z,G,ut),S.modelViewMatrix.multiplyMatrices(V.matrixWorldInverse,S.matrixWorld),S.normalMatrix.getNormalMatrix(S.modelViewMatrix),G.onBeforeRender(P,F,V,z,S,ut),G.transparent===!0&&G.side===Vn&&G.forceSinglePass===!1?(G.side=$e,G.needsUpdate=!0,P.renderBufferDirect(V,F,z,G,S,ut),G.side=ei,G.needsUpdate=!0,P.renderBufferDirect(V,F,z,G,S,ut),G.side=Vn):P.renderBufferDirect(V,F,z,G,S,ut),S.onAfterRender(P,F,V,z,G,ut)}function jr(S,F,V){F.isScene!==!0&&(F=Ee);let z=T.get(S),G=w.state.lights,ut=w.state.shadowsArray,vt=G.state.version,ht=ot.getParameters(S,G.state,ut,F,V,w.state.lightProbeGridArray),yt=ot.getProgramCacheKey(ht),St=z.programs;z.environment=S.isMeshStandardMaterial||S.isMeshLambertMaterial||S.isMeshPhongMaterial?F.environment:null,z.fog=F.fog;let Ot=S.isMeshStandardMaterial||S.isMeshLambertMaterial&&!S.envMap||S.isMeshPhongMaterial&&!S.envMap;z.envMap=O.get(S.envMap||z.environment,Ot),z.envMapRotation=z.environment!==null&&S.envMap===null?F.environmentRotation:S.envMapRotation,St===void 0&&(S.addEventListener("dispose",ye),St=new Map,z.programs=St);let Gt=St.get(yt);if(Gt!==void 0){if(z.currentProgram===Gt&&z.lightsStateVersion===vt)return mu(S,ht),Gt}else ht.uniforms=ot.getUniforms(S),D!==null&&S.isNodeMaterial&&D.build(S,V,ht),S.onBeforeCompile(ht,P),Gt=ot.acquireProgram(ht,yt),St.set(yt,Gt),z.uniforms=ht.uniforms;let Et=z.uniforms;return(!S.isShaderMaterial&&!S.isRawShaderMaterial||S.clipping===!0)&&(Et.clippingPlanes=xt.uniform),mu(S,ht),z.needsLights=dm(S),z.lightsStateVersion=vt,z.needsLights&&(Et.ambientLightColor.value=G.state.ambient,Et.lightProbe.value=G.state.probe,Et.directionalLights.value=G.state.directional,Et.directionalLightShadows.value=G.state.directionalShadow,Et.spotLights.value=G.state.spot,Et.spotLightShadows.value=G.state.spotShadow,Et.rectAreaLights.value=G.state.rectArea,Et.ltc_1.value=G.state.rectAreaLTC1,Et.ltc_2.value=G.state.rectAreaLTC2,Et.pointLights.value=G.state.point,Et.pointLightShadows.value=G.state.pointShadow,Et.hemisphereLights.value=G.state.hemi,Et.directionalShadowMatrix.value=G.state.directionalShadowMatrix,Et.spotLightMatrix.value=G.state.spotLightMatrix,Et.spotLightMap.value=G.state.spotLightMap,Et.pointShadowMatrix.value=G.state.pointShadowMatrix),z.lightProbeGrid=w.state.lightProbeGridArray.length>0,z.currentProgram=Gt,z.uniformsList=null,Gt}function pu(S){if(S.uniformsList===null){let F=S.currentProgram.getUniforms();S.uniformsList=Ds.seqWithValue(F.seq,S.uniforms)}return S.uniformsList}function mu(S,F){let V=T.get(S);V.outputColorSpace=F.outputColorSpace,V.batching=F.batching,V.batchingColor=F.batchingColor,V.instancing=F.instancing,V.instancingColor=F.instancingColor,V.instancingMorph=F.instancingMorph,V.skinning=F.skinning,V.morphTargets=F.morphTargets,V.morphNormals=F.morphNormals,V.morphColors=F.morphColors,V.morphTargetsCount=F.morphTargetsCount,V.numClippingPlanes=F.numClippingPlanes,V.numIntersection=F.numClipIntersection,V.vertexAlphas=F.vertexAlphas,V.vertexTangents=F.vertexTangents,V.toneMapping=F.toneMapping}function cm(S,F){if(S.length===0)return null;if(S.length===1)return S[0].texture!==null?S[0]:null;b.setFromMatrixPosition(F.matrixWorld);for(let V=0,z=S.length;V<z;V++){let G=S[V];if(G.texture!==null&&G.boundingBox.containsPoint(b))return G}return null}function hm(S,F,V,z,G){F.isScene!==!0&&(F=Ee),y.resetTextureUnits();let ut=F.fog,vt=z.isMeshStandardMaterial||z.isMeshLambertMaterial||z.isMeshPhongMaterial?F.environment:null,ht=k===null?P.outputColorSpace:k.isXRRenderTarget===!0?k.texture.colorSpace:Vt.workingColorSpace,yt=z.isMeshStandardMaterial||z.isMeshLambertMaterial&&!z.envMap||z.isMeshPhongMaterial&&!z.envMap,St=O.get(z.envMap||vt,yt),Ot=z.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,Gt=!!V.attributes.tangent&&(!!z.normalMap||z.anisotropy>0),Et=!!V.morphAttributes.position,ne=!!V.morphAttributes.normal,be=!!V.morphAttributes.color,me=dn;z.toneMapped&&(k===null||k.isXRRenderTarget===!0)&&(me=P.toneMapping);let se=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,Ge=se!==void 0?se.length:0,gt=T.get(z),sn=w.state.lights;if(de===!0&&(Xt===!0||S!==U)){let ae=S===U&&z.id===B;xt.setState(z,S,ae)}let $t=!1;z.version===gt.__version?(gt.needsLights&&gt.lightsStateVersion!==sn.state.version||gt.outputColorSpace!==ht||G.isBatchedMesh&&gt.batching===!1||!G.isBatchedMesh&&gt.batching===!0||G.isBatchedMesh&&gt.batchingColor===!0&&G.colorTexture===null||G.isBatchedMesh&&gt.batchingColor===!1&&G.colorTexture!==null||G.isInstancedMesh&&gt.instancing===!1||!G.isInstancedMesh&&gt.instancing===!0||G.isSkinnedMesh&&gt.skinning===!1||!G.isSkinnedMesh&&gt.skinning===!0||G.isInstancedMesh&&gt.instancingColor===!0&&G.instanceColor===null||G.isInstancedMesh&&gt.instancingColor===!1&&G.instanceColor!==null||G.isInstancedMesh&&gt.instancingMorph===!0&&G.morphTexture===null||G.isInstancedMesh&&gt.instancingMorph===!1&&G.morphTexture!==null||gt.envMap!==St||z.fog===!0&&gt.fog!==ut||gt.numClippingPlanes!==void 0&&(gt.numClippingPlanes!==xt.numPlanes||gt.numIntersection!==xt.numIntersection)||gt.vertexAlphas!==Ot||gt.vertexTangents!==Gt||gt.morphTargets!==Et||gt.morphNormals!==ne||gt.morphColors!==be||gt.toneMapping!==me||gt.morphTargetsCount!==Ge||!!gt.lightProbeGrid!=w.state.lightProbeGridArray.length>0)&&($t=!0):($t=!0,gt.__version=z.version);let gn=gt.currentProgram;$t===!0&&(gn=jr(z,F,G),D&&z.isNodeMaterial&&D.onUpdateProgram(z,gn,gt));let Nn=!1,hi=!1,ns=!1,re=gn.getUniforms(),Me=gt.uniforms;if(at.useProgram(gn.program)&&(Nn=!0,hi=!0,ns=!0),z.id!==B&&(B=z.id,hi=!0),gt.needsLights){let ae=cm(w.state.lightProbeGridArray,G);gt.lightProbeGrid!==ae&&(gt.lightProbeGrid=ae,hi=!0)}if(Nn||U!==S){at.buffers.depth.getReversed()&&S.reversedDepth!==!0&&(S._reversedDepth=!0,S.updateProjectionMatrix()),re.setValue(N,"projectionMatrix",S.projectionMatrix),re.setValue(N,"viewMatrix",S.matrixWorldInverse);let di=re.map.cameraPosition;di!==void 0&&di.setValue(N,le.setFromMatrixPosition(S.matrixWorld)),oe.logarithmicDepthBuffer&&re.setValue(N,"logDepthBufFC",2/(Math.log(S.far+1)/Math.LN2)),(z.isMeshPhongMaterial||z.isMeshToonMaterial||z.isMeshLambertMaterial||z.isMeshBasicMaterial||z.isMeshStandardMaterial||z.isShaderMaterial)&&re.setValue(N,"isOrthographic",S.isOrthographicCamera===!0),U!==S&&(U=S,hi=!0,ns=!0)}if(gt.needsLights&&(sn.state.directionalShadowMap.length>0&&re.setValue(N,"directionalShadowMap",sn.state.directionalShadowMap,y),sn.state.spotShadowMap.length>0&&re.setValue(N,"spotShadowMap",sn.state.spotShadowMap,y),sn.state.pointShadowMap.length>0&&re.setValue(N,"pointShadowMap",sn.state.pointShadowMap,y)),G.isSkinnedMesh){re.setOptional(N,G,"bindMatrix"),re.setOptional(N,G,"bindMatrixInverse");let ae=G.skeleton;ae&&(ae.boneTexture===null&&ae.computeBoneTexture(),re.setValue(N,"boneTexture",ae.boneTexture,y))}G.isBatchedMesh&&(re.setOptional(N,G,"batchingTexture"),re.setValue(N,"batchingTexture",G._matricesTexture,y),re.setOptional(N,G,"batchingIdTexture"),re.setValue(N,"batchingIdTexture",G._indirectTexture,y),re.setOptional(N,G,"batchingColorTexture"),G._colorsTexture!==null&&re.setValue(N,"batchingColorTexture",G._colorsTexture,y));let ui=V.morphAttributes;if((ui.position!==void 0||ui.normal!==void 0||ui.color!==void 0)&&Lt.update(G,V,gn),(hi||gt.receiveShadow!==G.receiveShadow)&&(gt.receiveShadow=G.receiveShadow,re.setValue(N,"receiveShadow",G.receiveShadow)),(z.isMeshStandardMaterial||z.isMeshLambertMaterial||z.isMeshPhongMaterial)&&z.envMap===null&&F.environment!==null&&(Me.envMapIntensity.value=F.environmentIntensity),Me.dfgLUT!==void 0&&(Me.dfgLUT.value=oy()),hi){if(re.setValue(N,"toneMappingExposure",P.toneMappingExposure),gt.needsLights&&um(Me,ns),ut&&z.fog===!0&&X.refreshFogUniforms(Me,ut),X.refreshMaterialUniforms(Me,z,Ut,Qt,w.state.transmissionRenderTarget[S.id]),gt.needsLights&&gt.lightProbeGrid){let ae=gt.lightProbeGrid;Me.probesSH.value=ae.texture,Me.probesMin.value.copy(ae.boundingBox.min),Me.probesMax.value.copy(ae.boundingBox.max),Me.probesResolution.value.copy(ae.resolution)}Ds.upload(N,pu(gt),Me,y)}if(z.isShaderMaterial&&z.uniformsNeedUpdate===!0&&(Ds.upload(N,pu(gt),Me,y),z.uniformsNeedUpdate=!1),z.isSpriteMaterial&&re.setValue(N,"center",G.center),re.setValue(N,"modelViewMatrix",G.modelViewMatrix),re.setValue(N,"normalMatrix",G.normalMatrix),re.setValue(N,"modelMatrix",G.matrixWorld),z.uniformsGroups!==void 0){let ae=z.uniformsGroups;for(let di=0,is=ae.length;di<is;di++){let gu=ae[di];q.update(gu,gn),q.bind(gu,gn)}}return gn}function um(S,F){S.ambientLightColor.needsUpdate=F,S.lightProbe.needsUpdate=F,S.directionalLights.needsUpdate=F,S.directionalLightShadows.needsUpdate=F,S.pointLights.needsUpdate=F,S.pointLightShadows.needsUpdate=F,S.spotLights.needsUpdate=F,S.spotLightShadows.needsUpdate=F,S.rectAreaLights.needsUpdate=F,S.hemisphereLights.needsUpdate=F}function dm(S){return S.isMeshLambertMaterial||S.isMeshToonMaterial||S.isMeshPhongMaterial||S.isMeshStandardMaterial||S.isShadowMaterial||S.isShaderMaterial&&S.lights===!0}this.getActiveCubeFace=function(){return W},this.getActiveMipmapLevel=function(){return H},this.getRenderTarget=function(){return k},this.setRenderTargetTextures=function(S,F,V){let z=T.get(S);z.__autoAllocateDepthBuffer=S.resolveDepthBuffer===!1,z.__autoAllocateDepthBuffer===!1&&(z.__useRenderToTexture=!1),T.get(S.texture).__webglTexture=F,T.get(S.depthTexture).__webglTexture=z.__autoAllocateDepthBuffer?void 0:V,z.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(S,F){let V=T.get(S);V.__webglFramebuffer=F,V.__useDefaultFramebuffer=F===void 0};let fm=N.createFramebuffer();this.setRenderTarget=function(S,F=0,V=0){k=S,W=F,H=V;let z=null,G=!1,ut=!1;if(S){let ht=T.get(S);if(ht.__useDefaultFramebuffer!==void 0){at.bindFramebuffer(N.FRAMEBUFFER,ht.__webglFramebuffer),j.copy(S.viewport),Q.copy(S.scissor),ct=S.scissorTest,at.viewport(j),at.scissor(Q),at.setScissorTest(ct),B=-1;return}else if(ht.__webglFramebuffer===void 0)y.setupRenderTarget(S);else if(ht.__hasExternalTextures)y.rebindTextures(S,T.get(S.texture).__webglTexture,T.get(S.depthTexture).__webglTexture);else if(S.depthBuffer){let Ot=S.depthTexture;if(ht.__boundDepthTexture!==Ot){if(Ot!==null&&T.has(Ot)&&(S.width!==Ot.image.width||S.height!==Ot.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");y.setupDepthRenderbuffer(S)}}let yt=S.texture;(yt.isData3DTexture||yt.isDataArrayTexture||yt.isCompressedArrayTexture)&&(ut=!0);let St=T.get(S).__webglFramebuffer;S.isWebGLCubeRenderTarget?(Array.isArray(St[F])?z=St[F][V]:z=St[F],G=!0):S.samples>0&&y.useMultisampledRTT(S)===!1?z=T.get(S).__webglMultisampledFramebuffer:Array.isArray(St)?z=St[V]:z=St,j.copy(S.viewport),Q.copy(S.scissor),ct=S.scissorTest}else j.copy(it).multiplyScalar(Ut).floor(),Q.copy(Ct).multiplyScalar(Ut).floor(),ct=Nt;if(V!==0&&(z=fm),at.bindFramebuffer(N.FRAMEBUFFER,z)&&at.drawBuffers(S,z),at.viewport(j),at.scissor(Q),at.setScissorTest(ct),G){let ht=T.get(S.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+F,ht.__webglTexture,V)}else if(ut){let ht=F;for(let yt=0;yt<S.textures.length;yt++){let St=T.get(S.textures[yt]);N.framebufferTextureLayer(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0+yt,St.__webglTexture,V,ht)}}else if(S!==null&&V!==0){let ht=T.get(S.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,ht.__webglTexture,V)}B=-1},this.readRenderTargetPixels=function(S,F,V,z,G,ut,vt,ht=0){if(!(S&&S.isWebGLRenderTarget)){Pt("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let yt=T.get(S).__webglFramebuffer;if(S.isWebGLCubeRenderTarget&&vt!==void 0&&(yt=yt[vt]),yt){at.bindFramebuffer(N.FRAMEBUFFER,yt);try{let St=S.textures[ht],Ot=St.format,Gt=St.type;if(S.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+ht),!oe.textureFormatReadable(Ot)){Pt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!oe.textureTypeReadable(Gt)){Pt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}F>=0&&F<=S.width-z&&V>=0&&V<=S.height-G&&N.readPixels(F,V,z,G,I.convert(Ot),I.convert(Gt),ut)}finally{let St=k!==null?T.get(k).__webglFramebuffer:null;at.bindFramebuffer(N.FRAMEBUFFER,St)}}},this.readRenderTargetPixelsAsync=async function(S,F,V,z,G,ut,vt,ht=0){if(!(S&&S.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let yt=T.get(S).__webglFramebuffer;if(S.isWebGLCubeRenderTarget&&vt!==void 0&&(yt=yt[vt]),yt)if(F>=0&&F<=S.width-z&&V>=0&&V<=S.height-G){at.bindFramebuffer(N.FRAMEBUFFER,yt);let St=S.textures[ht],Ot=St.format,Gt=St.type;if(S.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+ht),!oe.textureFormatReadable(Ot))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!oe.textureTypeReadable(Gt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let Et=N.createBuffer();N.bindBuffer(N.PIXEL_PACK_BUFFER,Et),N.bufferData(N.PIXEL_PACK_BUFFER,ut.byteLength,N.STREAM_READ),N.readPixels(F,V,z,G,I.convert(Ot),I.convert(Gt),0);let ne=k!==null?T.get(k).__webglFramebuffer:null;at.bindFramebuffer(N.FRAMEBUFFER,ne);let be=N.fenceSync(N.SYNC_GPU_COMMANDS_COMPLETE,0);return N.flush(),await Td(N,be,4),N.bindBuffer(N.PIXEL_PACK_BUFFER,Et),N.getBufferSubData(N.PIXEL_PACK_BUFFER,0,ut),N.deleteBuffer(Et),N.deleteSync(be),ut}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(S,F=null,V=0){let z=Math.pow(2,-V),G=Math.floor(S.image.width*z),ut=Math.floor(S.image.height*z),vt=F!==null?F.x:0,ht=F!==null?F.y:0;y.setTexture2D(S,0),N.copyTexSubImage2D(N.TEXTURE_2D,V,0,0,vt,ht,G,ut),at.unbindTexture()};let pm=N.createFramebuffer(),mm=N.createFramebuffer();this.copyTextureToTexture=function(S,F,V=null,z=null,G=0,ut=0){let vt,ht,yt,St,Ot,Gt,Et,ne,be,me=S.isCompressedTexture?S.mipmaps[ut]:S.image;if(V!==null)vt=V.max.x-V.min.x,ht=V.max.y-V.min.y,yt=V.isBox3?V.max.z-V.min.z:1,St=V.min.x,Ot=V.min.y,Gt=V.isBox3?V.min.z:0;else{let Me=Math.pow(2,-G);vt=Math.floor(me.width*Me),ht=Math.floor(me.height*Me),S.isDataArrayTexture?yt=me.depth:S.isData3DTexture?yt=Math.floor(me.depth*Me):yt=1,St=0,Ot=0,Gt=0}z!==null?(Et=z.x,ne=z.y,be=z.z):(Et=0,ne=0,be=0);let se=I.convert(F.format),Ge=I.convert(F.type),gt;F.isData3DTexture?(y.setTexture3D(F,0),gt=N.TEXTURE_3D):F.isDataArrayTexture||F.isCompressedArrayTexture?(y.setTexture2DArray(F,0),gt=N.TEXTURE_2D_ARRAY):(y.setTexture2D(F,0),gt=N.TEXTURE_2D),at.activeTexture(N.TEXTURE0),at.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,F.flipY),at.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,F.premultiplyAlpha),at.pixelStorei(N.UNPACK_ALIGNMENT,F.unpackAlignment);let sn=at.getParameter(N.UNPACK_ROW_LENGTH),$t=at.getParameter(N.UNPACK_IMAGE_HEIGHT),gn=at.getParameter(N.UNPACK_SKIP_PIXELS),Nn=at.getParameter(N.UNPACK_SKIP_ROWS),hi=at.getParameter(N.UNPACK_SKIP_IMAGES);at.pixelStorei(N.UNPACK_ROW_LENGTH,me.width),at.pixelStorei(N.UNPACK_IMAGE_HEIGHT,me.height),at.pixelStorei(N.UNPACK_SKIP_PIXELS,St),at.pixelStorei(N.UNPACK_SKIP_ROWS,Ot),at.pixelStorei(N.UNPACK_SKIP_IMAGES,Gt);let ns=S.isDataArrayTexture||S.isData3DTexture,re=F.isDataArrayTexture||F.isData3DTexture;if(S.isDepthTexture){let Me=T.get(S),ui=T.get(F),ae=T.get(Me.__renderTarget),di=T.get(ui.__renderTarget);at.bindFramebuffer(N.READ_FRAMEBUFFER,ae.__webglFramebuffer),at.bindFramebuffer(N.DRAW_FRAMEBUFFER,di.__webglFramebuffer);for(let is=0;is<yt;is++)ns&&(N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,T.get(S).__webglTexture,G,Gt+is),N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,T.get(F).__webglTexture,ut,be+is)),N.blitFramebuffer(St,Ot,vt,ht,Et,ne,vt,ht,N.DEPTH_BUFFER_BIT,N.NEAREST);at.bindFramebuffer(N.READ_FRAMEBUFFER,null),at.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else if(G!==0||S.isRenderTargetTexture||T.has(S)){let Me=T.get(S),ui=T.get(F);at.bindFramebuffer(N.READ_FRAMEBUFFER,pm),at.bindFramebuffer(N.DRAW_FRAMEBUFFER,mm);for(let ae=0;ae<yt;ae++)ns?N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Me.__webglTexture,G,Gt+ae):N.framebufferTexture2D(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,Me.__webglTexture,G),re?N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,ui.__webglTexture,ut,be+ae):N.framebufferTexture2D(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,ui.__webglTexture,ut),G!==0?N.blitFramebuffer(St,Ot,vt,ht,Et,ne,vt,ht,N.COLOR_BUFFER_BIT,N.NEAREST):re?N.copyTexSubImage3D(gt,ut,Et,ne,be+ae,St,Ot,vt,ht):N.copyTexSubImage2D(gt,ut,Et,ne,St,Ot,vt,ht);at.bindFramebuffer(N.READ_FRAMEBUFFER,null),at.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else re?S.isDataTexture||S.isData3DTexture?N.texSubImage3D(gt,ut,Et,ne,be,vt,ht,yt,se,Ge,me.data):F.isCompressedArrayTexture?N.compressedTexSubImage3D(gt,ut,Et,ne,be,vt,ht,yt,se,me.data):N.texSubImage3D(gt,ut,Et,ne,be,vt,ht,yt,se,Ge,me):S.isDataTexture?N.texSubImage2D(N.TEXTURE_2D,ut,Et,ne,vt,ht,se,Ge,me.data):S.isCompressedTexture?N.compressedTexSubImage2D(N.TEXTURE_2D,ut,Et,ne,me.width,me.height,se,me.data):N.texSubImage2D(N.TEXTURE_2D,ut,Et,ne,vt,ht,se,Ge,me);at.pixelStorei(N.UNPACK_ROW_LENGTH,sn),at.pixelStorei(N.UNPACK_IMAGE_HEIGHT,$t),at.pixelStorei(N.UNPACK_SKIP_PIXELS,gn),at.pixelStorei(N.UNPACK_SKIP_ROWS,Nn),at.pixelStorei(N.UNPACK_SKIP_IMAGES,hi),ut===0&&F.generateMipmaps&&N.generateMipmap(gt),at.unbindTexture()},this.initRenderTarget=function(S){T.get(S).__webglFramebuffer===void 0&&y.setupRenderTarget(S)},this.initTexture=function(S){S.isCubeTexture?y.setTextureCube(S,0):S.isData3DTexture?y.setTexture3D(S,0):S.isDataArrayTexture||S.isCompressedArrayTexture?y.setTexture2DArray(S,0):y.setTexture2D(S,0),at.unbindTexture()},this.resetState=function(){W=0,H=0,k=null,at.reset(),nt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Tn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;let e=this.getContext();e.drawingBufferColorSpace=Vt._getDrawingBufferColorSpace(t),e.unpackColorSpace=Vt._getUnpackColorSpace()}};var of=require("obsidian");async function af(i){try{let t=(0,of.normalizePath)(i.vault.configDir+"/graph.json");if(!await i.vault.adapter.exists(t))return null;let e=JSON.parse(await i.vault.adapter.read(t)),n=[];for(let s of e.colorGroups??[]){let r=typeof s.query=="string"?s.query.trim():"",o=s.color?.rgb;!r||typeof o!="number"||n.push({query:r,color:`#${(o&16777215).toString(16).padStart(6,"0")}`})}return n}catch{return null}}var hl=require("obsidian");function ay(i){let t=i.indexOf("/");return t===-1?"":i.slice(0,t)}function cf(i,t,e,n){let s=[],r=new Map;for(let d of i)r.set(d.path,s.length),s.push({id:d.path,name:d.basename,folderTop:ay(d.path),degree:0,inDegree:0,outDegree:0,fileSize:d.size??0,unresolved:!1});let o=[],a=(d,h)=>{o.push({source:d,target:h});let f=s[d],m=s[h];f&&(f.degree++,f.outDegree++),m&&(m.degree++,m.inDegree++)};for(let d of Object.keys(t)){let h=r.get(d);if(h===void 0)continue;let f=t[d]??{};for(let m of Object.keys(f)){let x=r.get(m);x!==void 0&&a(h,x)}}if(n.includeUnresolved)for(let d of Object.keys(e)){let h=r.get(d);if(h===void 0)continue;let f=e[d]??{};for(let m of Object.keys(f)){let x=`unresolved:${m}`,g=r.get(x);g===void 0&&(g=s.length,r.set(x,g),s.push({id:x,name:m,folderTop:"__unresolved__",degree:0,inDegree:0,outDegree:0,fileSize:0,unresolved:!0})),a(h,g)}}let l={nodes:s,links:o};n.includeOrphans||(l=lf(l,d=>d.degree>0));let c=n.nodeCap??null;if(c!==null&&l.nodes.length>c){let d=[...l.nodes.entries()].sort((f,m)=>m[1].degree-f[1].degree||f[0]-m[0]),h=new Set(d.slice(0,c).map(([f])=>f));l=lf(l,(f,m)=>h.has(m))}let u=n.linkCap??null;if(u!==null&&l.links.length>u){let d=h=>l.nodes[h]?.degree??0;l={nodes:l.nodes,links:[...l.links.entries()].sort((h,f)=>Math.min(d(f[1].source),d(f[1].target))-Math.min(d(h[1].source),d(h[1].target))||h[0]-f[0]).slice(0,u).map(([,h])=>h)}}return l}function lf(i,t){let e=new Map,n=[];i.nodes.forEach((r,o)=>{t(r,o)&&(e.set(o,n.length),n.push(r))});let s=[];for(let r of i.links){let o=e.get(r.source),a=e.get(r.target);o!==void 0&&a!==void 0&&s.push({source:o,target:a})}return{nodes:n,links:s}}function Rh(i){let t=2166136261;for(let e=0;e<i.length;e++)t^=i.charCodeAt(e),t=Math.imul(t,16777619);return t>>>0}function Ch(i){return Rh(i)/4294967295}function hf(i,t){let e=Ch(i),n=Ch(i+":v"),s=Ch(i+":w"),r=t*Math.cbrt(e),o=2*Math.PI*n,a=Math.acos(2*s-1);return[r*Math.sin(a)*Math.cos(o),r*Math.sin(a)*Math.sin(o),r*Math.cos(a)]}function ll(i){return 80*Math.cbrt(Math.max(i,1)/1e3)}var cl=class extends hl.Component{constructor(e){super();this.app=e;this.data={nodes:[],links:[]};this.positions=new Float32Array(0);this.includeUnresolved=!1;this.includeOrphans=!0;this.nodeCap=null;this.linkCap=null;this.onChanged=null}init(e,n,s){this.includeUnresolved=e,this.includeOrphans=n,this.onChanged=s;let r=(0,hl.debounce)(()=>this.rebuild(!0),800,!0);this.registerEvent(this.app.metadataCache.on("resolved",r)),this.registerEvent(this.app.vault.on("rename",r)),this.registerEvent(this.app.vault.on("delete",r))}async ensureCacheReady(){Object.keys(this.app.metadataCache.resolvedLinks).length>0||await new Promise(e=>{this.registerEvent(this.app.metadataCache.on("resolved",()=>e()))})}setIncludeUnresolved(e){e!==this.includeUnresolved&&(this.includeUnresolved=e,this.rebuild(!0))}getIncludeUnresolved(){return this.includeUnresolved}setCaps(e,n){e===this.nodeCap&&n===this.linkCap||(this.nodeCap=e,this.linkCap=n,this.rebuild(!0))}setIncludeOrphans(e){e!==this.includeOrphans&&(this.includeOrphans=e,this.rebuild(!0))}rebuild(e){let n=this.app.vault.getMarkdownFiles().map(c=>({path:c.path,basename:c.basename,size:c.stat.size})),s=cf(n,this.app.metadataCache.resolvedLinks,this.app.metadataCache.unresolvedLinks,{includeUnresolved:this.includeUnresolved,includeOrphans:this.includeOrphans,nodeCap:this.nodeCap,linkCap:this.linkCap}),r=new Map;e&&this.data.nodes.forEach((c,u)=>r.set(c.id,u));let o=this.positions,a=ll(s.nodes.length),l=new Float32Array(s.nodes.length*3);s.nodes.forEach((c,u)=>{let d=r.get(c.id);if(d!==void 0&&d*3+2<o.length)l[u*3]=o[d*3]??0,l[u*3+1]=o[d*3+1]??0,l[u*3+2]=o[d*3+2]??0;else{let[h,f,m]=hf(c.id,a);l[u*3]=h,l[u*3+1]=f,l[u*3+2]=m}}),this.data=s,this.positions=l,this.onChanged?.()}};function uf(i){let t=+this._x.call(null,i);return df(this.cover(t),t,i)}function df(i,t,e){if(isNaN(t))return i;var n,s=i._root,r={data:e},o=i._x0,a=i._x1,l,c,u,d,h;if(!s)return i._root=r,i;for(;s.length;)if((u=t>=(l=(o+a)/2))?o=l:a=l,n=s,!(s=s[d=+u]))return n[d]=r,i;if(c=+i._x.call(null,s.data),t===c)return r.next=s,n?n[d]=r:i._root=r,i;do n=n?n[d]=new Array(2):i._root=new Array(2),(u=t>=(l=(o+a)/2))?o=l:a=l;while((d=+u)==(h=+(c>=l)));return n[h]=s,n[d]=r,i}function ff(i){Array.isArray(i)||(i=Array.from(i));let t=i.length,e=new Float64Array(t),n=1/0,s=-1/0;for(let r=0,o;r<t;++r)isNaN(o=+this._x.call(null,i[r]))||(e[r]=o,o<n&&(n=o),o>s&&(s=o));if(n>s)return this;this.cover(n).cover(s);for(let r=0;r<t;++r)df(this,e[r],i[r]);return this}function pf(i){if(isNaN(i=+i))return this;var t=this._x0,e=this._x1;if(isNaN(t))e=(t=Math.floor(i))+1;else{for(var n=e-t||1,s=this._root,r,o;t>i||i>=e;)switch(o=+(i<t),r=new Array(2),r[o]=s,s=r,n*=2,o){case 0:e=t+n;break;case 1:t=e-n;break}this._root&&this._root.length&&(this._root=s)}return this._x0=t,this._x1=e,this}function mf(){var i=[];return this.visit(function(t){if(!t.length)do i.push(t.data);while(t=t.next)}),i}function gf(i){return arguments.length?this.cover(+i[0][0]).cover(+i[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]}function Mn(i,t,e){this.node=i,this.x0=t,this.x1=e}function xf(i,t){var e,n=this._x0,s,r,o=this._x1,a=[],l=this._root,c,u;for(l&&a.push(new Mn(l,n,o)),t==null?t=1/0:(n=i-t,o=i+t);c=a.pop();)if(!(!(l=c.node)||(s=c.x0)>o||(r=c.x1)<n))if(l.length){var d=(s+r)/2;a.push(new Mn(l[1],d,r),new Mn(l[0],s,d)),(u=+(i>=d))&&(c=a[a.length-1],a[a.length-1]=a[a.length-1-u],a[a.length-1-u]=c)}else{var h=Math.abs(i-+this._x.call(null,l.data));h<t&&(t=h,n=i-h,o=i+h,e=l.data)}return e}function vf(i){if(isNaN(l=+this._x.call(null,i)))return this;var t,e=this._root,n,s,r,o=this._x0,a=this._x1,l,c,u,d,h;if(!e)return this;if(e.length)for(;;){if((u=l>=(c=(o+a)/2))?o=c:a=c,t=e,!(e=e[d=+u]))return this;if(!e.length)break;t[d+1&1]&&(n=t,h=d)}for(;e.data!==i;)if(s=e,!(e=e.next))return this;return(r=e.next)&&delete e.next,s?(r?s.next=r:delete s.next,this):t?(r?t[d]=r:delete t[d],(e=t[0]||t[1])&&e===(t[1]||t[0])&&!e.length&&(n?n[h]=e:this._root=e),this):(this._root=r,this)}function _f(i){for(var t=0,e=i.length;t<e;++t)this.remove(i[t]);return this}function yf(){return this._root}function bf(){var i=0;return this.visit(function(t){if(!t.length)do++i;while(t=t.next)}),i}function Mf(i){var t=[],e,n=this._root,s,r,o;for(n&&t.push(new Mn(n,this._x0,this._x1));e=t.pop();)if(!i(n=e.node,r=e.x0,o=e.x1)&&n.length){var a=(r+o)/2;(s=n[1])&&t.push(new Mn(s,a,o)),(s=n[0])&&t.push(new Mn(s,r,a))}return this}function Sf(i){var t=[],e=[],n;for(this._root&&t.push(new Mn(this._root,this._x0,this._x1));n=t.pop();){var s=n.node;if(s.length){var r,o=n.x0,a=n.x1,l=(o+a)/2;(r=s[0])&&t.push(new Mn(r,o,l)),(r=s[1])&&t.push(new Mn(r,l,a))}e.push(n)}for(;n=e.pop();)i(n.node,n.x0,n.x1);return this}function wf(i){return i[0]}function Ef(i){return arguments.length?(this._x=i,this):this._x}function kr(i,t){var e=new Ph(t??wf,NaN,NaN);return i==null?e:e.addAll(i)}function Ph(i,t,e){this._x=i,this._x0=t,this._x1=e,this._root=void 0}function Tf(i){for(var t={data:i.data},e=t;i=i.next;)e=e.next={data:i.data};return t}var tn=kr.prototype=Ph.prototype;tn.copy=function(){var i=new Ph(this._x,this._x0,this._x1),t=this._root,e,n;if(!t)return i;if(!t.length)return i._root=Tf(t),i;for(e=[{source:t,target:i._root=new Array(2)}];t=e.pop();)for(var s=0;s<2;++s)(n=t.source[s])&&(n.length?e.push({source:n,target:t.target[s]=new Array(2)}):t.target[s]=Tf(n));return i};tn.add=uf;tn.addAll=ff;tn.cover=pf;tn.data=mf;tn.extent=gf;tn.find=xf;tn.remove=vf;tn.removeAll=_f;tn.root=yf;tn.size=bf;tn.visit=Mf;tn.visitAfter=Sf;tn.x=Ef;function Af(i){let t=+this._x.call(null,i),e=+this._y.call(null,i);return Cf(this.cover(t,e),t,e,i)}function Cf(i,t,e,n){if(isNaN(t)||isNaN(e))return i;var s,r=i._root,o={data:n},a=i._x0,l=i._y0,c=i._x1,u=i._y1,d,h,f,m,x,g,p,v;if(!r)return i._root=o,i;for(;r.length;)if((x=t>=(d=(a+c)/2))?a=d:c=d,(g=e>=(h=(l+u)/2))?l=h:u=h,s=r,!(r=r[p=g<<1|x]))return s[p]=o,i;if(f=+i._x.call(null,r.data),m=+i._y.call(null,r.data),t===f&&e===m)return o.next=r,s?s[p]=o:i._root=o,i;do s=s?s[p]=new Array(4):i._root=new Array(4),(x=t>=(d=(a+c)/2))?a=d:c=d,(g=e>=(h=(l+u)/2))?l=h:u=h;while((p=g<<1|x)===(v=(m>=h)<<1|f>=d));return s[v]=r,s[p]=o,i}function Rf(i){var t,e,n=i.length,s,r,o=new Array(n),a=new Array(n),l=1/0,c=1/0,u=-1/0,d=-1/0;for(e=0;e<n;++e)isNaN(s=+this._x.call(null,t=i[e]))||isNaN(r=+this._y.call(null,t))||(o[e]=s,a[e]=r,s<l&&(l=s),s>u&&(u=s),r<c&&(c=r),r>d&&(d=r));if(l>u||c>d)return this;for(this.cover(l,c).cover(u,d),e=0;e<n;++e)Cf(this,o[e],a[e],i[e]);return this}function Pf(i,t){if(isNaN(i=+i)||isNaN(t=+t))return this;var e=this._x0,n=this._y0,s=this._x1,r=this._y1;if(isNaN(e))s=(e=Math.floor(i))+1,r=(n=Math.floor(t))+1;else{for(var o=s-e||1,a=this._root,l,c;e>i||i>=s||n>t||t>=r;)switch(c=(t<n)<<1|i<e,l=new Array(4),l[c]=a,a=l,o*=2,c){case 0:s=e+o,r=n+o;break;case 1:e=s-o,r=n+o;break;case 2:s=e+o,n=r-o;break;case 3:e=s-o,n=r-o;break}this._root&&this._root.length&&(this._root=a)}return this._x0=e,this._y0=n,this._x1=s,this._y1=r,this}function If(){var i=[];return this.visit(function(t){if(!t.length)do i.push(t.data);while(t=t.next)}),i}function Lf(i){return arguments.length?this.cover(+i[0][0],+i[0][1]).cover(+i[1][0],+i[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function Ne(i,t,e,n,s){this.node=i,this.x0=t,this.y0=e,this.x1=n,this.y1=s}function Df(i,t,e){var n,s=this._x0,r=this._y0,o,a,l,c,u=this._x1,d=this._y1,h=[],f=this._root,m,x;for(f&&h.push(new Ne(f,s,r,u,d)),e==null?e=1/0:(s=i-e,r=t-e,u=i+e,d=t+e,e*=e);m=h.pop();)if(!(!(f=m.node)||(o=m.x0)>u||(a=m.y0)>d||(l=m.x1)<s||(c=m.y1)<r))if(f.length){var g=(o+l)/2,p=(a+c)/2;h.push(new Ne(f[3],g,p,l,c),new Ne(f[2],o,p,g,c),new Ne(f[1],g,a,l,p),new Ne(f[0],o,a,g,p)),(x=(t>=p)<<1|i>=g)&&(m=h[h.length-1],h[h.length-1]=h[h.length-1-x],h[h.length-1-x]=m)}else{var v=i-+this._x.call(null,f.data),M=t-+this._y.call(null,f.data),b=v*v+M*M;if(b<e){var E=Math.sqrt(e=b);s=i-E,r=t-E,u=i+E,d=t+E,n=f.data}}return n}function Nf(i){if(isNaN(u=+this._x.call(null,i))||isNaN(d=+this._y.call(null,i)))return this;var t,e=this._root,n,s,r,o=this._x0,a=this._y0,l=this._x1,c=this._y1,u,d,h,f,m,x,g,p;if(!e)return this;if(e.length)for(;;){if((m=u>=(h=(o+l)/2))?o=h:l=h,(x=d>=(f=(a+c)/2))?a=f:c=f,t=e,!(e=e[g=x<<1|m]))return this;if(!e.length)break;(t[g+1&3]||t[g+2&3]||t[g+3&3])&&(n=t,p=g)}for(;e.data!==i;)if(s=e,!(e=e.next))return this;return(r=e.next)&&delete e.next,s?(r?s.next=r:delete s.next,this):t?(r?t[g]=r:delete t[g],(e=t[0]||t[1]||t[2]||t[3])&&e===(t[3]||t[2]||t[1]||t[0])&&!e.length&&(n?n[p]=e:this._root=e),this):(this._root=r,this)}function Ff(i){for(var t=0,e=i.length;t<e;++t)this.remove(i[t]);return this}function kf(){return this._root}function Of(){var i=0;return this.visit(function(t){if(!t.length)do++i;while(t=t.next)}),i}function Uf(i){var t=[],e,n=this._root,s,r,o,a,l;for(n&&t.push(new Ne(n,this._x0,this._y0,this._x1,this._y1));e=t.pop();)if(!i(n=e.node,r=e.x0,o=e.y0,a=e.x1,l=e.y1)&&n.length){var c=(r+a)/2,u=(o+l)/2;(s=n[3])&&t.push(new Ne(s,c,u,a,l)),(s=n[2])&&t.push(new Ne(s,r,u,c,l)),(s=n[1])&&t.push(new Ne(s,c,o,a,u)),(s=n[0])&&t.push(new Ne(s,r,o,c,u))}return this}function Bf(i){var t=[],e=[],n;for(this._root&&t.push(new Ne(this._root,this._x0,this._y0,this._x1,this._y1));n=t.pop();){var s=n.node;if(s.length){var r,o=n.x0,a=n.y0,l=n.x1,c=n.y1,u=(o+l)/2,d=(a+c)/2;(r=s[0])&&t.push(new Ne(r,o,a,u,d)),(r=s[1])&&t.push(new Ne(r,u,a,l,d)),(r=s[2])&&t.push(new Ne(r,o,d,u,c)),(r=s[3])&&t.push(new Ne(r,u,d,l,c))}e.push(n)}for(;n=e.pop();)i(n.node,n.x0,n.y0,n.x1,n.y1);return this}function zf(i){return i[0]}function Gf(i){return arguments.length?(this._x=i,this):this._x}function Vf(i){return i[1]}function Hf(i){return arguments.length?(this._y=i,this):this._y}function Or(i,t,e){var n=new Ih(t??zf,e??Vf,NaN,NaN,NaN,NaN);return i==null?n:n.addAll(i)}function Ih(i,t,e,n,s,r){this._x=i,this._y=t,this._x0=e,this._y0=n,this._x1=s,this._y1=r,this._root=void 0}function Wf(i){for(var t={data:i.data},e=t;i=i.next;)e=e.next={data:i.data};return t}var Ke=Or.prototype=Ih.prototype;Ke.copy=function(){var i=new Ih(this._x,this._y,this._x0,this._y0,this._x1,this._y1),t=this._root,e,n;if(!t)return i;if(!t.length)return i._root=Wf(t),i;for(e=[{source:t,target:i._root=new Array(4)}];t=e.pop();)for(var s=0;s<4;++s)(n=t.source[s])&&(n.length?e.push({source:n,target:t.target[s]=new Array(4)}):t.target[s]=Wf(n));return i};Ke.add=Af;Ke.addAll=Rf;Ke.cover=Pf;Ke.data=If;Ke.extent=Lf;Ke.find=Df;Ke.remove=Nf;Ke.removeAll=Ff;Ke.root=kf;Ke.size=Of;Ke.visit=Uf;Ke.visitAfter=Bf;Ke.x=Gf;Ke.y=Hf;function Xf(i){let t=+this._x.call(null,i),e=+this._y.call(null,i),n=+this._z.call(null,i);return qf(this.cover(t,e,n),t,e,n,i)}function qf(i,t,e,n,s){if(isNaN(t)||isNaN(e)||isNaN(n))return i;var r,o=i._root,a={data:s},l=i._x0,c=i._y0,u=i._z0,d=i._x1,h=i._y1,f=i._z1,m,x,g,p,v,M,b,E,w,C,_;if(!o)return i._root=a,i;for(;o.length;)if((b=t>=(m=(l+d)/2))?l=m:d=m,(E=e>=(x=(c+h)/2))?c=x:h=x,(w=n>=(g=(u+f)/2))?u=g:f=g,r=o,!(o=o[C=w<<2|E<<1|b]))return r[C]=a,i;if(p=+i._x.call(null,o.data),v=+i._y.call(null,o.data),M=+i._z.call(null,o.data),t===p&&e===v&&n===M)return a.next=o,r?r[C]=a:i._root=a,i;do r=r?r[C]=new Array(8):i._root=new Array(8),(b=t>=(m=(l+d)/2))?l=m:d=m,(E=e>=(x=(c+h)/2))?c=x:h=x,(w=n>=(g=(u+f)/2))?u=g:f=g;while((C=w<<2|E<<1|b)===(_=(M>=g)<<2|(v>=x)<<1|p>=m));return r[_]=o,r[C]=a,i}function Yf(i){Array.isArray(i)||(i=Array.from(i));let t=i.length,e=new Float64Array(t),n=new Float64Array(t),s=new Float64Array(t),r=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,u=-1/0;for(let d=0,h,f,m,x;d<t;++d)isNaN(f=+this._x.call(null,h=i[d]))||isNaN(m=+this._y.call(null,h))||isNaN(x=+this._z.call(null,h))||(e[d]=f,n[d]=m,s[d]=x,f<r&&(r=f),f>l&&(l=f),m<o&&(o=m),m>c&&(c=m),x<a&&(a=x),x>u&&(u=x));if(r>l||o>c||a>u)return this;this.cover(r,o,a).cover(l,c,u);for(let d=0;d<t;++d)qf(this,e[d],n[d],s[d],i[d]);return this}function Zf(i,t,e){if(isNaN(i=+i)||isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,s=this._y0,r=this._z0,o=this._x1,a=this._y1,l=this._z1;if(isNaN(n))o=(n=Math.floor(i))+1,a=(s=Math.floor(t))+1,l=(r=Math.floor(e))+1;else{for(var c=o-n||1,u=this._root,d,h;n>i||i>=o||s>t||t>=a||r>e||e>=l;)switch(h=(e<r)<<2|(t<s)<<1|i<n,d=new Array(8),d[h]=u,u=d,c*=2,h){case 0:o=n+c,a=s+c,l=r+c;break;case 1:n=o-c,a=s+c,l=r+c;break;case 2:o=n+c,s=a-c,l=r+c;break;case 3:n=o-c,s=a-c,l=r+c;break;case 4:o=n+c,a=s+c,r=l-c;break;case 5:n=o-c,a=s+c,r=l-c;break;case 6:o=n+c,s=a-c,r=l-c;break;case 7:n=o-c,s=a-c,r=l-c;break}this._root&&this._root.length&&(this._root=u)}return this._x0=n,this._y0=s,this._z0=r,this._x1=o,this._y1=a,this._z1=l,this}function $f(){var i=[];return this.visit(function(t){if(!t.length)do i.push(t.data);while(t=t.next)}),i}function Kf(i){return arguments.length?this.cover(+i[0][0],+i[0][1],+i[0][2]).cover(+i[1][0],+i[1][1],+i[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]}function jt(i,t,e,n,s,r,o){this.node=i,this.x0=t,this.y0=e,this.z0=n,this.x1=s,this.y1=r,this.z1=o}function Jf(i,t,e,n){var s,r=this._x0,o=this._y0,a=this._z0,l,c,u,d,h,f,m=this._x1,x=this._y1,g=this._z1,p=[],v=this._root,M,b;for(v&&p.push(new jt(v,r,o,a,m,x,g)),n==null?n=1/0:(r=i-n,o=t-n,a=e-n,m=i+n,x=t+n,g=e+n,n*=n);M=p.pop();)if(!(!(v=M.node)||(l=M.x0)>m||(c=M.y0)>x||(u=M.z0)>g||(d=M.x1)<r||(h=M.y1)<o||(f=M.z1)<a))if(v.length){var E=(l+d)/2,w=(c+h)/2,C=(u+f)/2;p.push(new jt(v[7],E,w,C,d,h,f),new jt(v[6],l,w,C,E,h,f),new jt(v[5],E,c,C,d,w,f),new jt(v[4],l,c,C,E,w,f),new jt(v[3],E,w,u,d,h,C),new jt(v[2],l,w,u,E,h,C),new jt(v[1],E,c,u,d,w,C),new jt(v[0],l,c,u,E,w,C)),(b=(e>=C)<<2|(t>=w)<<1|i>=E)&&(M=p[p.length-1],p[p.length-1]=p[p.length-1-b],p[p.length-1-b]=M)}else{var _=i-+this._x.call(null,v.data),A=t-+this._y.call(null,v.data),P=e-+this._z.call(null,v.data),R=_*_+A*A+P*P;if(R<n){var D=Math.sqrt(n=R);r=i-D,o=t-D,a=e-D,m=i+D,x=t+D,g=e+D,s=v.data}}return s}var ly=(i,t,e,n,s,r)=>Math.sqrt((i-n)**2+(t-s)**2+(e-r)**2);function jf(i,t,e,n){let s=[],r=i-n,o=t-n,a=e-n,l=i+n,c=t+n,u=e+n;return this.visit((d,h,f,m,x,g,p)=>{if(!d.length)do{let v=d.data;ly(i,t,e,this._x(v),this._y(v),this._z(v))<=n&&s.push(v)}while(d=d.next);return h>l||f>c||m>u||x<r||g<o||p<a}),s}function Qf(i){if(isNaN(h=+this._x.call(null,i))||isNaN(f=+this._y.call(null,i))||isNaN(m=+this._z.call(null,i)))return this;var t,e=this._root,n,s,r,o=this._x0,a=this._y0,l=this._z0,c=this._x1,u=this._y1,d=this._z1,h,f,m,x,g,p,v,M,b,E,w;if(!e)return this;if(e.length)for(;;){if((v=h>=(x=(o+c)/2))?o=x:c=x,(M=f>=(g=(a+u)/2))?a=g:u=g,(b=m>=(p=(l+d)/2))?l=p:d=p,t=e,!(e=e[E=b<<2|M<<1|v]))return this;if(!e.length)break;(t[E+1&7]||t[E+2&7]||t[E+3&7]||t[E+4&7]||t[E+5&7]||t[E+6&7]||t[E+7&7])&&(n=t,w=E)}for(;e.data!==i;)if(s=e,!(e=e.next))return this;return(r=e.next)&&delete e.next,s?(r?s.next=r:delete s.next,this):t?(r?t[E]=r:delete t[E],(e=t[0]||t[1]||t[2]||t[3]||t[4]||t[5]||t[6]||t[7])&&e===(t[7]||t[6]||t[5]||t[4]||t[3]||t[2]||t[1]||t[0])&&!e.length&&(n?n[w]=e:this._root=e),this):(this._root=r,this)}function tp(i){for(var t=0,e=i.length;t<e;++t)this.remove(i[t]);return this}function ep(){return this._root}function np(){var i=0;return this.visit(function(t){if(!t.length)do++i;while(t=t.next)}),i}function ip(i){var t=[],e,n=this._root,s,r,o,a,l,c,u;for(n&&t.push(new jt(n,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=t.pop();)if(!i(n=e.node,r=e.x0,o=e.y0,a=e.z0,l=e.x1,c=e.y1,u=e.z1)&&n.length){var d=(r+l)/2,h=(o+c)/2,f=(a+u)/2;(s=n[7])&&t.push(new jt(s,d,h,f,l,c,u)),(s=n[6])&&t.push(new jt(s,r,h,f,d,c,u)),(s=n[5])&&t.push(new jt(s,d,o,f,l,h,u)),(s=n[4])&&t.push(new jt(s,r,o,f,d,h,u)),(s=n[3])&&t.push(new jt(s,d,h,a,l,c,f)),(s=n[2])&&t.push(new jt(s,r,h,a,d,c,f)),(s=n[1])&&t.push(new jt(s,d,o,a,l,h,f)),(s=n[0])&&t.push(new jt(s,r,o,a,d,h,f))}return this}function sp(i){var t=[],e=[],n;for(this._root&&t.push(new jt(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));n=t.pop();){var s=n.node;if(s.length){var r,o=n.x0,a=n.y0,l=n.z0,c=n.x1,u=n.y1,d=n.z1,h=(o+c)/2,f=(a+u)/2,m=(l+d)/2;(r=s[0])&&t.push(new jt(r,o,a,l,h,f,m)),(r=s[1])&&t.push(new jt(r,h,a,l,c,f,m)),(r=s[2])&&t.push(new jt(r,o,f,l,h,u,m)),(r=s[3])&&t.push(new jt(r,h,f,l,c,u,m)),(r=s[4])&&t.push(new jt(r,o,a,m,h,f,d)),(r=s[5])&&t.push(new jt(r,h,a,m,c,f,d)),(r=s[6])&&t.push(new jt(r,o,f,m,h,u,d)),(r=s[7])&&t.push(new jt(r,h,f,m,c,u,d))}e.push(n)}for(;n=e.pop();)i(n.node,n.x0,n.y0,n.z0,n.x1,n.y1,n.z1);return this}function rp(i){return i[0]}function op(i){return arguments.length?(this._x=i,this):this._x}function ap(i){return i[1]}function lp(i){return arguments.length?(this._y=i,this):this._y}function cp(i){return i[2]}function hp(i){return arguments.length?(this._z=i,this):this._z}function Ur(i,t,e,n){var s=new Lh(t??rp,e??ap,n??cp,NaN,NaN,NaN,NaN,NaN,NaN);return i==null?s:s.addAll(i)}function Lh(i,t,e,n,s,r,o,a,l){this._x=i,this._y=t,this._z=e,this._x0=n,this._y0=s,this._z0=r,this._x1=o,this._y1=a,this._z1=l,this._root=void 0}function up(i){for(var t={data:i.data},e=t;i=i.next;)e=e.next={data:i.data};return t}var Be=Ur.prototype=Lh.prototype;Be.copy=function(){var i=new Lh(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),t=this._root,e,n;if(!t)return i;if(!t.length)return i._root=up(t),i;for(e=[{source:t,target:i._root=new Array(8)}];t=e.pop();)for(var s=0;s<8;++s)(n=t.source[s])&&(n.length?e.push({source:n,target:t.target[s]=new Array(8)}):t.target[s]=up(n));return i};Be.add=Xf;Be.addAll=Yf;Be.cover=Zf;Be.data=$f;Be.extent=Kf;Be.find=Jf;Be.findAllWithinRadius=jf;Be.remove=Qf;Be.removeAll=tp;Be.root=ep;Be.size=np;Be.visit=ip;Be.visitAfter=sp;Be.x=op;Be.y=lp;Be.z=hp;function ve(i){return function(){return i}}function In(i){return(i()-.5)*1e-6}function cy(i){return i.index}function dp(i,t){var e=i.get(t);if(!e)throw new Error("node not found: "+t);return e}function Dh(i){var t=cy,e=h,n,s=ve(30),r,o,a,l,c,u,d=1;i==null&&(i=[]);function h(p){return 1/Math.min(l[p.source.index],l[p.target.index])}function f(p){for(var v=0,M=i.length;v<d;++v)for(var b=0,E,w,C,_=0,A=0,P=0,R,D;b<M;++b)E=i[b],w=E.source,C=E.target,_=C.x+C.vx-w.x-w.vx||In(u),a>1&&(A=C.y+C.vy-w.y-w.vy||In(u)),a>2&&(P=C.z+C.vz-w.z-w.vz||In(u)),R=Math.sqrt(_*_+A*A+P*P),R=(R-r[b])/R*p*n[b],_*=R,A*=R,P*=R,C.vx-=_*(D=c[b]),a>1&&(C.vy-=A*D),a>2&&(C.vz-=P*D),w.vx+=_*(D=1-D),a>1&&(w.vy+=A*D),a>2&&(w.vz+=P*D)}function m(){if(o){var p,v=o.length,M=i.length,b=new Map(o.map((w,C)=>[t(w,C,o),w])),E;for(p=0,l=new Array(v);p<M;++p)E=i[p],E.index=p,typeof E.source!="object"&&(E.source=dp(b,E.source)),typeof E.target!="object"&&(E.target=dp(b,E.target)),l[E.source.index]=(l[E.source.index]||0)+1,l[E.target.index]=(l[E.target.index]||0)+1;for(p=0,c=new Array(M);p<M;++p)E=i[p],c[p]=l[E.source.index]/(l[E.source.index]+l[E.target.index]);n=new Array(M),x(),r=new Array(M),g()}}function x(){if(o)for(var p=0,v=i.length;p<v;++p)n[p]=+e(i[p],p,i)}function g(){if(o)for(var p=0,v=i.length;p<v;++p)r[p]=+s(i[p],p,i)}return f.initialize=function(p,...v){o=p,u=v.find(M=>typeof M=="function")||Math.random,a=v.find(M=>[1,2,3].includes(M))||2,m()},f.links=function(p){return arguments.length?(i=p,m(),f):i},f.id=function(p){return arguments.length?(t=p,f):t},f.iterations=function(p){return arguments.length?(d=+p,f):d},f.strength=function(p){return arguments.length?(e=typeof p=="function"?p:ve(+p),x(),f):e},f.distance=function(p){return arguments.length?(s=typeof p=="function"?p:ve(+p),g(),f):s},f}var hy={value:()=>{}};function pp(){for(var i=0,t=arguments.length,e={},n;i<t;++i){if(!(n=arguments[i]+"")||n in e||/[\s.]/.test(n))throw new Error("illegal type: "+n);e[n]=[]}return new ul(e)}function ul(i){this._=i}function uy(i,t){return i.trim().split(/^|\s+/).map(function(e){var n="",s=e.indexOf(".");if(s>=0&&(n=e.slice(s+1),e=e.slice(0,s)),e&&!t.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:n}})}ul.prototype=pp.prototype={constructor:ul,on:function(i,t){var e=this._,n=uy(i+"",e),s,r=-1,o=n.length;if(arguments.length<2){for(;++r<o;)if((s=(i=n[r]).type)&&(s=dy(e[s],i.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++r<o;)if(s=(i=n[r]).type)e[s]=fp(e[s],i.name,t);else if(t==null)for(s in e)e[s]=fp(e[s],i.name,null);return this},copy:function(){var i={},t=this._;for(var e in t)i[e]=t[e].slice();return new ul(i)},call:function(i,t){if((s=arguments.length-2)>0)for(var e=new Array(s),n=0,s,r;n<s;++n)e[n]=arguments[n+2];if(!this._.hasOwnProperty(i))throw new Error("unknown type: "+i);for(r=this._[i],n=0,s=r.length;n<s;++n)r[n].value.apply(t,e)},apply:function(i,t,e){if(!this._.hasOwnProperty(i))throw new Error("unknown type: "+i);for(var n=this._[i],s=0,r=n.length;s<r;++s)n[s].value.apply(t,e)}};function dy(i,t){for(var e=0,n=i.length,s;e<n;++e)if((s=i[e]).name===t)return s.value}function fp(i,t,e){for(var n=0,s=i.length;n<s;++n)if(i[n].name===t){i[n]=hy,i=i.slice(0,n).concat(i.slice(n+1));break}return e!=null&&i.push({name:t,value:e}),i}var Nh=pp;var ks=0,zr=0,Br=0,gp=1e3,dl,Gr,fl=0,Qi=0,pl=0,Vr=typeof performance=="object"&&performance.now?performance:Date,xp=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(i){setTimeout(i,17)};function Oh(){return Qi||(xp(fy),Qi=Vr.now()+pl)}function fy(){Qi=0}function Fh(){this._call=this._time=this._next=null}Fh.prototype=ml.prototype={constructor:Fh,restart:function(i,t,e){if(typeof i!="function")throw new TypeError("callback is not a function");e=(e==null?Oh():+e)+(t==null?0:+t),!this._next&&Gr!==this&&(Gr?Gr._next=this:dl=this,Gr=this),this._call=i,this._time=e,kh()},stop:function(){this._call&&(this._call=null,this._time=1/0,kh())}};function ml(i,t,e){var n=new Fh;return n.restart(i,t,e),n}function vp(){Oh(),++ks;for(var i=dl,t;i;)(t=Qi-i._time)>=0&&i._call.call(void 0,t),i=i._next;--ks}function mp(){Qi=(fl=Vr.now())+pl,ks=zr=0;try{vp()}finally{ks=0,my(),Qi=0}}function py(){var i=Vr.now(),t=i-fl;t>gp&&(pl-=t,fl=i)}function my(){for(var i,t=dl,e,n=1/0;t;)t._call?(n>t._time&&(n=t._time),i=t,t=t._next):(e=t._next,t._next=null,t=i?i._next=e:dl=e);Gr=i,kh(n)}function kh(i){if(!ks){zr&&(zr=clearTimeout(zr));var t=i-Qi;t>24?(i<1/0&&(zr=setTimeout(mp,i-Vr.now()-pl)),Br&&(Br=clearInterval(Br))):(Br||(fl=Vr.now(),Br=setInterval(py,gp)),ks=1,xp(mp))}}function _p(){let i=1;return()=>(i=(1664525*i+1013904223)%4294967296)/4294967296}var yp=3;function gl(i){return i.x}function Uh(i){return i.y}function bp(i){return i.z}var gy=10,xy=Math.PI*(3-Math.sqrt(5)),vy=Math.PI*20/(9+Math.sqrt(221));function Bh(i,t){t=t||2;var e=Math.min(yp,Math.max(1,Math.round(t))),n,s=1,r=.001,o=1-Math.pow(r,1/300),a=0,l=.6,c=new Map,u=ml(f),d=Nh("tick","end"),h=_p();i==null&&(i=[]);function f(){m(),d.call("tick",n),s<r&&(u.stop(),d.call("end",n))}function m(p){var v,M=i.length,b;p===void 0&&(p=1);for(var E=0;E<p;++E)for(s+=(a-s)*o,c.forEach(function(w){w(s)}),v=0;v<M;++v)b=i[v],b.fx==null?b.x+=b.vx*=l:(b.x=b.fx,b.vx=0),e>1&&(b.fy==null?b.y+=b.vy*=l:(b.y=b.fy,b.vy=0)),e>2&&(b.fz==null?b.z+=b.vz*=l:(b.z=b.fz,b.vz=0));return n}function x(){for(var p=0,v=i.length,M;p<v;++p){if(M=i[p],M.index=p,M.fx!=null&&(M.x=M.fx),M.fy!=null&&(M.y=M.fy),M.fz!=null&&(M.z=M.fz),isNaN(M.x)||e>1&&isNaN(M.y)||e>2&&isNaN(M.z)){var b=gy*(e>2?Math.cbrt(.5+p):e>1?Math.sqrt(.5+p):p),E=p*xy,w=p*vy;e===1?M.x=b:e===2?(M.x=b*Math.cos(E),M.y=b*Math.sin(E)):(M.x=b*Math.sin(E)*Math.cos(w),M.y=b*Math.cos(E),M.z=b*Math.sin(E)*Math.sin(w))}(isNaN(M.vx)||e>1&&isNaN(M.vy)||e>2&&isNaN(M.vz))&&(M.vx=0,e>1&&(M.vy=0),e>2&&(M.vz=0))}}function g(p){return p.initialize&&p.initialize(i,h,e),p}return x(),n={tick:m,restart:function(){return u.restart(f),n},stop:function(){return u.stop(),n},numDimensions:function(p){return arguments.length?(e=Math.min(yp,Math.max(1,Math.round(p))),c.forEach(g),n):e},nodes:function(p){return arguments.length?(i=p,x(),c.forEach(g),n):i},alpha:function(p){return arguments.length?(s=+p,n):s},alphaMin:function(p){return arguments.length?(r=+p,n):r},alphaDecay:function(p){return arguments.length?(o=+p,n):+o},alphaTarget:function(p){return arguments.length?(a=+p,n):a},velocityDecay:function(p){return arguments.length?(l=1-p,n):1-l},randomSource:function(p){return arguments.length?(h=p,c.forEach(g),n):h},force:function(p,v){return arguments.length>1?(v==null?c.delete(p):c.set(p,g(v)),n):c.get(p)},find:function(){var p=Array.prototype.slice.call(arguments),v=p.shift()||0,M=(e>1?p.shift():null)||0,b=(e>2?p.shift():null)||0,E=p.shift()||1/0,w=0,C=i.length,_,A,P,R,D,W;for(E*=E,w=0;w<C;++w)D=i[w],_=v-D.x,A=M-(D.y||0),P=b-(D.z||0),R=_*_+A*A+P*P,R<E&&(W=D,E=R);return W},on:function(p,v){return arguments.length>1?(d.on(p,v),n):d.on(p)}}}function zh(){var i,t,e,n,s,r=ve(-30),o,a=1,l=1/0,c=.81;function u(m){var x,g=i.length,p=(t===1?kr(i,gl):t===2?Or(i,gl,Uh):t===3?Ur(i,gl,Uh,bp):null).visitAfter(h);for(s=m,x=0;x<g;++x)e=i[x],p.visit(f)}function d(){if(i){var m,x=i.length,g;for(o=new Array(x),m=0;m<x;++m)g=i[m],o[g.index]=+r(g,m,i)}}function h(m){var x=0,g,p,v=0,M,b,E,w,C=m.length;if(C){for(M=b=E=w=0;w<C;++w)(g=m[w])&&(p=Math.abs(g.value))&&(x+=g.value,v+=p,M+=p*(g.x||0),b+=p*(g.y||0),E+=p*(g.z||0));x*=Math.sqrt(4/C),m.x=M/v,t>1&&(m.y=b/v),t>2&&(m.z=E/v)}else{g=m,g.x=g.data.x,t>1&&(g.y=g.data.y),t>2&&(g.z=g.data.z);do x+=o[g.data.index];while(g=g.next)}m.value=x}function f(m,x,g,p,v){if(!m.value)return!0;var M=[g,p,v][t-1],b=m.x-e.x,E=t>1?m.y-e.y:0,w=t>2?m.z-e.z:0,C=M-x,_=b*b+E*E+w*w;if(C*C/c<_)return _<l&&(b===0&&(b=In(n),_+=b*b),t>1&&E===0&&(E=In(n),_+=E*E),t>2&&w===0&&(w=In(n),_+=w*w),_<a&&(_=Math.sqrt(a*_)),e.vx+=b*m.value*s/_,t>1&&(e.vy+=E*m.value*s/_),t>2&&(e.vz+=w*m.value*s/_)),!0;if(m.length||_>=l)return;(m.data!==e||m.next)&&(b===0&&(b=In(n),_+=b*b),t>1&&E===0&&(E=In(n),_+=E*E),t>2&&w===0&&(w=In(n),_+=w*w),_<a&&(_=Math.sqrt(a*_)));do m.data!==e&&(C=o[m.data.index]*s/_,e.vx+=b*C,t>1&&(e.vy+=E*C),t>2&&(e.vz+=w*C));while(m=m.next)}return u.initialize=function(m,...x){i=m,n=x.find(g=>typeof g=="function")||Math.random,t=x.find(g=>[1,2,3].includes(g))||2,d()},u.strength=function(m){return arguments.length?(r=typeof m=="function"?m:ve(+m),d(),u):r},u.distanceMin=function(m){return arguments.length?(a=m*m,u):Math.sqrt(a)},u.distanceMax=function(m){return arguments.length?(l=m*m,u):Math.sqrt(l)},u.theta=function(m){return arguments.length?(c=m*m,u):Math.sqrt(c)},u}function Gh(i){var t=ve(.1),e,n,s;typeof i!="function"&&(i=ve(i==null?0:+i));function r(a){for(var l=0,c=e.length,u;l<c;++l)u=e[l],u.vx+=(s[l]-u.x)*n[l]*a}function o(){if(e){var a,l=e.length;for(n=new Array(l),s=new Array(l),a=0;a<l;++a)n[a]=isNaN(s[a]=+i(e[a],a,e))?0:+t(e[a],a,e)}}return r.initialize=function(a){e=a,o()},r.strength=function(a){return arguments.length?(t=typeof a=="function"?a:ve(+a),o(),r):t},r.x=function(a){return arguments.length?(i=typeof a=="function"?a:ve(+a),o(),r):i},r}function Vh(i){var t=ve(.1),e,n,s;typeof i!="function"&&(i=ve(i==null?0:+i));function r(a){for(var l=0,c=e.length,u;l<c;++l)u=e[l],u.vy+=(s[l]-u.y)*n[l]*a}function o(){if(e){var a,l=e.length;for(n=new Array(l),s=new Array(l),a=0;a<l;++a)n[a]=isNaN(s[a]=+i(e[a],a,e))?0:+t(e[a],a,e)}}return r.initialize=function(a){e=a,o()},r.strength=function(a){return arguments.length?(t=typeof a=="function"?a:ve(+a),o(),r):t},r.y=function(a){return arguments.length?(i=typeof a=="function"?a:ve(+a),o(),r):i},r}function Hh(i){var t=ve(.1),e,n,s;typeof i!="function"&&(i=ve(i==null?0:+i));function r(a){for(var l=0,c=e.length,u;l<c;++l)u=e[l],u.vz+=(s[l]-u.z)*n[l]*a}function o(){if(e){var a,l=e.length;for(n=new Array(l),s=new Array(l),a=0;a<l;++a)n[a]=isNaN(s[a]=+i(e[a],a,e))?0:+t(e[a],a,e)}}return r.initialize=function(a){e=a,o()},r.strength=function(a){return arguments.length?(t=typeof a=="function"?a:ve(+a),o(),r):t},r.z=function(a){return arguments.length?(i=typeof a=="function"?a:ve(+a),o(),r):i},r}var Hr=class{constructor(){this.positions=new Float32Array(0);this.sim=null;this.simNodes=[];this.degrees=[];this.settled=!0;this._ticks=0}get ticks(){return this._ticks}init(t,e,n,s=1){this.dispose(),this.positions=e,this.degrees=t.nodes.map(o=>Math.max(o.degree,1)),this.simNodes=t.nodes.map((o,a)=>({x:e[a*3]??0,y:e[a*3+1]??0,z:e[a*3+2]??0}));let r=t.links.map(o=>({source:o.source,target:o.target}));this.sim=Bh(this.simNodes,3).alphaDecay(1-Math.pow(.001,1/300)).velocityDecay(n.velocityDecay).force("link",Dh(r).distance(n.linkDistance).strength(this.linkStrengthFn(n.linkStrength))).force("charge",zh().strength(n.charge).distanceMax(800)).force("x",Gh(0).strength(n.centerPull)).force("y",Vh(0).strength(n.centerPull+n.flatten)).force("z",Hh(0).strength(n.centerPull)).stop(),this.sim.alpha(s),this._ticks=0,this.settled=!1}linkStrengthFn(t){let e=this.degrees;return n=>{let s=typeof n.source=="number"?n.source:n.source.index??0,r=typeof n.target=="number"?n.target:n.target.index??0,o=1/Math.min(e[s]??1,e[r]??1);return Math.min(o*t,1)}}updateParams(t){let e=this.sim;if(!e)return;e.force("charge")?.strength(t.charge);let n=e.force("link");n?.distance(t.linkDistance),n?.strength(this.linkStrengthFn(t.linkStrength)),e.force("x")?.strength(t.centerPull),e.force("y")?.strength(t.centerPull+t.flatten),e.force("z")?.strength(t.centerPull),this.reheat(.5)}step(){let t=this.sim;if(!t||this.settled)return!1;t.tick(),this._ticks++;let e=this.positions,n=this.simNodes;for(let s=0;s<n.length;s++){let r=n[s];r&&(e[s*3]=r.x,e[s*3+1]=r.y,e[s*3+2]=r.z)}return t.alpha()<t.alphaMin()&&(this.settled=!0),!this.settled}isSettled(){return this.settled}reheat(t=.3){this.sim&&(this.sim.alpha(Math.max(this.sim.alpha(),t)),this.settled=!1)}dispose(){this.sim?.stop(),this.sim=null,this.simNodes=[],this.settled=!0}};var Mp=`"use strict";(()=>{function Nt(t){let e=+this._x.call(null,t);return At(this.cover(e),e,t)}function At(t,e,r){if(isNaN(e))return t;var n,i=t._root,o={data:r},f=t._x0,a=t._x1,s,l,h,c,x;if(!i)return t._root=o,t;for(;i.length;)if((h=e>=(s=(f+a)/2))?f=s:a=s,n=i,!(i=i[c=+h]))return n[c]=o,t;if(l=+t._x.call(null,i.data),e===l)return o.next=i,n?n[c]=o:t._root=o,t;do n=n?n[c]=new Array(2):t._root=new Array(2),(h=e>=(s=(f+a)/2))?f=s:a=s;while((c=+h)==(x=+(l>=s)));return n[x]=i,n[c]=o,t}function Mt(t){Array.isArray(t)||(t=Array.from(t));let e=t.length,r=new Float64Array(e),n=1/0,i=-1/0;for(let o=0,f;o<e;++o)isNaN(f=+this._x.call(null,t[o]))||(r[o]=f,f<n&&(n=f),f>i&&(i=f));if(n>i)return this;this.cover(n).cover(i);for(let o=0;o<e;++o)At(this,r[o],t[o]);return this}function zt(t){if(isNaN(t=+t))return this;var e=this._x0,r=this._x1;if(isNaN(e))r=(e=Math.floor(t))+1;else{for(var n=r-e||1,i=this._root,o,f;e>t||t>=r;)switch(f=+(t<e),o=new Array(2),o[f]=i,i=o,n*=2,f){case 0:r=e+n;break;case 1:e=r-n;break}this._root&&this._root.length&&(this._root=i)}return this._x0=e,this._x1=r,this}function bt(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function kt(t){return arguments.length?this.cover(+t[0][0]).cover(+t[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]}function E(t,e,r){this.node=t,this.x0=e,this.x1=r}function qt(t,e){var r,n=this._x0,i,o,f=this._x1,a=[],s=this._root,l,h;for(s&&a.push(new E(s,n,f)),e==null?e=1/0:(n=t-e,f=t+e);l=a.pop();)if(!(!(s=l.node)||(i=l.x0)>f||(o=l.x1)<n))if(s.length){var c=(i+o)/2;a.push(new E(s[1],c,o),new E(s[0],i,c)),(h=+(t>=c))&&(l=a[a.length-1],a[a.length-1]=a[a.length-1-h],a[a.length-1-h]=l)}else{var x=Math.abs(t-+this._x.call(null,s.data));x<e&&(e=x,n=t-x,f=t+x,r=s.data)}return r}function It(t){if(isNaN(s=+this._x.call(null,t)))return this;var e,r=this._root,n,i,o,f=this._x0,a=this._x1,s,l,h,c,x;if(!r)return this;if(r.length)for(;;){if((h=s>=(l=(f+a)/2))?f=l:a=l,e=r,!(r=r[c=+h]))return this;if(!r.length)break;e[c+1&1]&&(n=e,x=c)}for(;r.data!==t;)if(i=r,!(r=r.next))return this;return(o=r.next)&&delete r.next,i?(o?i.next=o:delete i.next,this):e?(o?e[c]=o:delete e[c],(r=e[0]||e[1])&&r===(e[1]||e[0])&&!r.length&&(n?n[x]=r:this._root=r),this):(this._root=o,this)}function Pt(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this}function Ft(){return this._root}function Wt(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function Dt(t){var e=[],r,n=this._root,i,o,f;for(n&&e.push(new E(n,this._x0,this._x1));r=e.pop();)if(!t(n=r.node,o=r.x0,f=r.x1)&&n.length){var a=(o+f)/2;(i=n[1])&&e.push(new E(i,a,f)),(i=n[0])&&e.push(new E(i,o,a))}return this}function St(t){var e=[],r=[],n;for(this._root&&e.push(new E(this._root,this._x0,this._x1));n=e.pop();){var i=n.node;if(i.length){var o,f=n.x0,a=n.x1,s=(f+a)/2;(o=i[0])&&e.push(new E(o,f,s)),(o=i[1])&&e.push(new E(o,s,a))}r.push(n)}for(;n=r.pop();)t(n.node,n.x0,n.x1);return this}function Bt(t){return t[0]}function Et(t){return arguments.length?(this._x=t,this):this._x}function X(t,e){var r=new nt(e??Bt,NaN,NaN);return t==null?r:r.addAll(t)}function nt(t,e,r){this._x=t,this._x0=e,this._x1=r,this._root=void 0}function jt(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var D=X.prototype=nt.prototype;D.copy=function(){var t=new nt(this._x,this._x0,this._x1),e=this._root,r,n;if(!e)return t;if(!e.length)return t._root=jt(e),t;for(r=[{source:e,target:t._root=new Array(2)}];e=r.pop();)for(var i=0;i<2;++i)(n=e.source[i])&&(n.length?r.push({source:n,target:e.target[i]=new Array(2)}):e.target[i]=jt(n));return t};D.add=Nt;D.addAll=Mt;D.cover=zt;D.data=bt;D.extent=kt;D.find=qt;D.remove=It;D.removeAll=Pt;D.root=Ft;D.size=Wt;D.visit=Dt;D.visitAfter=St;D.x=Et;function Tt(t){let e=+this._x.call(null,t),r=+this._y.call(null,t);return Lt(this.cover(e,r),e,r,t)}function Lt(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var i,o=t._root,f={data:n},a=t._x0,s=t._y0,l=t._x1,h=t._y1,c,x,v,p,w,y,u,m;if(!o)return t._root=f,t;for(;o.length;)if((w=e>=(c=(a+l)/2))?a=c:l=c,(y=r>=(x=(s+h)/2))?s=x:h=x,i=o,!(o=o[u=y<<1|w]))return i[u]=f,t;if(v=+t._x.call(null,o.data),p=+t._y.call(null,o.data),e===v&&r===p)return f.next=o,i?i[u]=f:t._root=f,t;do i=i?i[u]=new Array(4):t._root=new Array(4),(w=e>=(c=(a+l)/2))?a=c:l=c,(y=r>=(x=(s+h)/2))?s=x:h=x;while((u=y<<1|w)===(m=(p>=x)<<1|v>=c));return i[m]=o,i[u]=f,t}function Ot(t){var e,r,n=t.length,i,o,f=new Array(n),a=new Array(n),s=1/0,l=1/0,h=-1/0,c=-1/0;for(r=0;r<n;++r)isNaN(i=+this._x.call(null,e=t[r]))||isNaN(o=+this._y.call(null,e))||(f[r]=i,a[r]=o,i<s&&(s=i),i>h&&(h=i),o<l&&(l=o),o>c&&(c=o));if(s>h||l>c)return this;for(this.cover(s,l).cover(h,c),r=0;r<n;++r)Lt(this,f[r],a[r],t[r]);return this}function Xt(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var r=this._x0,n=this._y0,i=this._x1,o=this._y1;if(isNaN(r))i=(r=Math.floor(t))+1,o=(n=Math.floor(e))+1;else{for(var f=i-r||1,a=this._root,s,l;r>t||t>=i||n>e||e>=o;)switch(l=(e<n)<<1|t<r,s=new Array(4),s[l]=a,a=s,f*=2,l){case 0:i=r+f,o=n+f;break;case 1:r=i-f,o=n+f;break;case 2:i=r+f,n=o-f;break;case 3:r=i-f,n=o-f;break}this._root&&this._root.length&&(this._root=a)}return this._x0=r,this._y0=n,this._x1=i,this._y1=o,this}function Rt(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function Yt(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function I(t,e,r,n,i){this.node=t,this.x0=e,this.y0=r,this.x1=n,this.y1=i}function Ct(t,e,r){var n,i=this._x0,o=this._y0,f,a,s,l,h=this._x1,c=this._y1,x=[],v=this._root,p,w;for(v&&x.push(new I(v,i,o,h,c)),r==null?r=1/0:(i=t-r,o=e-r,h=t+r,c=e+r,r*=r);p=x.pop();)if(!(!(v=p.node)||(f=p.x0)>h||(a=p.y0)>c||(s=p.x1)<i||(l=p.y1)<o))if(v.length){var y=(f+s)/2,u=(a+l)/2;x.push(new I(v[3],y,u,s,l),new I(v[2],f,u,y,l),new I(v[1],y,a,s,u),new I(v[0],f,a,y,u)),(w=(e>=u)<<1|t>=y)&&(p=x[x.length-1],x[x.length-1]=x[x.length-1-w],x[x.length-1-w]=p)}else{var m=t-+this._x.call(null,v.data),d=e-+this._y.call(null,v.data),g=m*m+d*d;if(g<r){var _=Math.sqrt(r=g);i=t-_,o=e-_,h=t+_,c=e+_,n=v.data}}return n}function Ht(t){if(isNaN(h=+this._x.call(null,t))||isNaN(c=+this._y.call(null,t)))return this;var e,r=this._root,n,i,o,f=this._x0,a=this._y0,s=this._x1,l=this._y1,h,c,x,v,p,w,y,u;if(!r)return this;if(r.length)for(;;){if((p=h>=(x=(f+s)/2))?f=x:s=x,(w=c>=(v=(a+l)/2))?a=v:l=v,e=r,!(r=r[y=w<<1|p]))return this;if(!r.length)break;(e[y+1&3]||e[y+2&3]||e[y+3&3])&&(n=e,u=y)}for(;r.data!==t;)if(i=r,!(r=r.next))return this;return(o=r.next)&&delete r.next,i?(o?i.next=o:delete i.next,this):e?(o?e[y]=o:delete e[y],(r=e[0]||e[1]||e[2]||e[3])&&r===(e[3]||e[2]||e[1]||e[0])&&!r.length&&(n?n[u]=r:this._root=r),this):(this._root=o,this)}function Qt(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this}function Zt(){return this._root}function Ut(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function Gt(t){var e=[],r,n=this._root,i,o,f,a,s;for(n&&e.push(new I(n,this._x0,this._y0,this._x1,this._y1));r=e.pop();)if(!t(n=r.node,o=r.x0,f=r.y0,a=r.x1,s=r.y1)&&n.length){var l=(o+a)/2,h=(f+s)/2;(i=n[3])&&e.push(new I(i,l,h,a,s)),(i=n[2])&&e.push(new I(i,o,h,l,s)),(i=n[1])&&e.push(new I(i,l,f,a,h)),(i=n[0])&&e.push(new I(i,o,f,l,h))}return this}function Jt(t){var e=[],r=[],n;for(this._root&&e.push(new I(this._root,this._x0,this._y0,this._x1,this._y1));n=e.pop();){var i=n.node;if(i.length){var o,f=n.x0,a=n.y0,s=n.x1,l=n.y1,h=(f+s)/2,c=(a+l)/2;(o=i[0])&&e.push(new I(o,f,a,h,c)),(o=i[1])&&e.push(new I(o,h,a,s,c)),(o=i[2])&&e.push(new I(o,f,c,h,l)),(o=i[3])&&e.push(new I(o,h,c,s,l))}r.push(n)}for(;n=r.pop();)t(n.node,n.x0,n.y0,n.x1,n.y1);return this}function Kt(t){return t[0]}function Vt(t){return arguments.length?(this._x=t,this):this._x}function $t(t){return t[1]}function te(t){return arguments.length?(this._y=t,this):this._y}function R(t,e,r){var n=new it(e??Kt,r??$t,NaN,NaN,NaN,NaN);return t==null?n:n.addAll(t)}function it(t,e,r,n,i,o){this._x=t,this._y=e,this._x0=r,this._y0=n,this._x1=i,this._y1=o,this._root=void 0}function ee(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var F=R.prototype=it.prototype;F.copy=function(){var t=new it(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,r,n;if(!e)return t;if(!e.length)return t._root=ee(e),t;for(r=[{source:e,target:t._root=new Array(4)}];e=r.pop();)for(var i=0;i<4;++i)(n=e.source[i])&&(n.length?r.push({source:n,target:e.target[i]=new Array(4)}):e.target[i]=ee(n));return t};F.add=Tt;F.addAll=Ot;F.cover=Xt;F.data=Rt;F.extent=Yt;F.find=Ct;F.remove=Ht;F.removeAll=Qt;F.root=Zt;F.size=Ut;F.visit=Gt;F.visitAfter=Jt;F.x=Vt;F.y=te;function re(t){let e=+this._x.call(null,t),r=+this._y.call(null,t),n=+this._z.call(null,t);return ne(this.cover(e,r,n),e,r,n,t)}function ne(t,e,r,n,i){if(isNaN(e)||isNaN(r)||isNaN(n))return t;var o,f=t._root,a={data:i},s=t._x0,l=t._y0,h=t._z0,c=t._x1,x=t._y1,v=t._z1,p,w,y,u,m,d,g,_,N,A,M;if(!f)return t._root=a,t;for(;f.length;)if((g=e>=(p=(s+c)/2))?s=p:c=p,(_=r>=(w=(l+x)/2))?l=w:x=w,(N=n>=(y=(h+v)/2))?h=y:v=y,o=f,!(f=f[A=N<<2|_<<1|g]))return o[A]=a,t;if(u=+t._x.call(null,f.data),m=+t._y.call(null,f.data),d=+t._z.call(null,f.data),e===u&&r===m&&n===d)return a.next=f,o?o[A]=a:t._root=a,t;do o=o?o[A]=new Array(8):t._root=new Array(8),(g=e>=(p=(s+c)/2))?s=p:c=p,(_=r>=(w=(l+x)/2))?l=w:x=w,(N=n>=(y=(h+v)/2))?h=y:v=y;while((A=N<<2|_<<1|g)===(M=(d>=y)<<2|(m>=w)<<1|u>=p));return o[M]=f,o[A]=a,t}function ie(t){Array.isArray(t)||(t=Array.from(t));let e=t.length,r=new Float64Array(e),n=new Float64Array(e),i=new Float64Array(e),o=1/0,f=1/0,a=1/0,s=-1/0,l=-1/0,h=-1/0;for(let c=0,x,v,p,w;c<e;++c)isNaN(v=+this._x.call(null,x=t[c]))||isNaN(p=+this._y.call(null,x))||isNaN(w=+this._z.call(null,x))||(r[c]=v,n[c]=p,i[c]=w,v<o&&(o=v),v>s&&(s=v),p<f&&(f=p),p>l&&(l=p),w<a&&(a=w),w>h&&(h=w));if(o>s||f>l||a>h)return this;this.cover(o,f,a).cover(s,l,h);for(let c=0;c<e;++c)ne(this,r[c],n[c],i[c],t[c]);return this}function oe(t,e,r){if(isNaN(t=+t)||isNaN(e=+e)||isNaN(r=+r))return this;var n=this._x0,i=this._y0,o=this._z0,f=this._x1,a=this._y1,s=this._z1;if(isNaN(n))f=(n=Math.floor(t))+1,a=(i=Math.floor(e))+1,s=(o=Math.floor(r))+1;else{for(var l=f-n||1,h=this._root,c,x;n>t||t>=f||i>e||e>=a||o>r||r>=s;)switch(x=(r<o)<<2|(e<i)<<1|t<n,c=new Array(8),c[x]=h,h=c,l*=2,x){case 0:f=n+l,a=i+l,s=o+l;break;case 1:n=f-l,a=i+l,s=o+l;break;case 2:f=n+l,i=a-l,s=o+l;break;case 3:n=f-l,i=a-l,s=o+l;break;case 4:f=n+l,a=i+l,o=s-l;break;case 5:n=f-l,a=i+l,o=s-l;break;case 6:f=n+l,i=a-l,o=s-l;break;case 7:n=f-l,i=a-l,o=s-l;break}this._root&&this._root.length&&(this._root=h)}return this._x0=n,this._y0=i,this._z0=o,this._x1=f,this._y1=a,this._z1=s,this}function ae(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function fe(t){return arguments.length?this.cover(+t[0][0],+t[0][1],+t[0][2]).cover(+t[1][0],+t[1][1],+t[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]}function z(t,e,r,n,i,o,f){this.node=t,this.x0=e,this.y0=r,this.z0=n,this.x1=i,this.y1=o,this.z1=f}function se(t,e,r,n){var i,o=this._x0,f=this._y0,a=this._z0,s,l,h,c,x,v,p=this._x1,w=this._y1,y=this._z1,u=[],m=this._root,d,g;for(m&&u.push(new z(m,o,f,a,p,w,y)),n==null?n=1/0:(o=t-n,f=e-n,a=r-n,p=t+n,w=e+n,y=r+n,n*=n);d=u.pop();)if(!(!(m=d.node)||(s=d.x0)>p||(l=d.y0)>w||(h=d.z0)>y||(c=d.x1)<o||(x=d.y1)<f||(v=d.z1)<a))if(m.length){var _=(s+c)/2,N=(l+x)/2,A=(h+v)/2;u.push(new z(m[7],_,N,A,c,x,v),new z(m[6],s,N,A,_,x,v),new z(m[5],_,l,A,c,N,v),new z(m[4],s,l,A,_,N,v),new z(m[3],_,N,h,c,x,A),new z(m[2],s,N,h,_,x,A),new z(m[1],_,l,h,c,N,A),new z(m[0],s,l,h,_,N,A)),(g=(r>=A)<<2|(e>=N)<<1|t>=_)&&(d=u[u.length-1],u[u.length-1]=u[u.length-1-g],u[u.length-1-g]=d)}else{var M=t-+this._x.call(null,m.data),S=e-+this._y.call(null,m.data),B=r-+this._z.call(null,m.data),W=M*M+S*S+B*B;if(W<n){var k=Math.sqrt(n=W);o=t-k,f=e-k,a=r-k,p=t+k,w=e+k,y=r+k,i=m.data}}return i}var Ee=(t,e,r,n,i,o)=>Math.sqrt((t-n)**2+(e-i)**2+(r-o)**2);function ue(t,e,r,n){let i=[],o=t-n,f=e-n,a=r-n,s=t+n,l=e+n,h=r+n;return this.visit((c,x,v,p,w,y,u)=>{if(!c.length)do{let m=c.data;Ee(t,e,r,this._x(m),this._y(m),this._z(m))<=n&&i.push(m)}while(c=c.next);return x>s||v>l||p>h||w<o||y<f||u<a}),i}function le(t){if(isNaN(x=+this._x.call(null,t))||isNaN(v=+this._y.call(null,t))||isNaN(p=+this._z.call(null,t)))return this;var e,r=this._root,n,i,o,f=this._x0,a=this._y0,s=this._z0,l=this._x1,h=this._y1,c=this._z1,x,v,p,w,y,u,m,d,g,_,N;if(!r)return this;if(r.length)for(;;){if((m=x>=(w=(f+l)/2))?f=w:l=w,(d=v>=(y=(a+h)/2))?a=y:h=y,(g=p>=(u=(s+c)/2))?s=u:c=u,e=r,!(r=r[_=g<<2|d<<1|m]))return this;if(!r.length)break;(e[_+1&7]||e[_+2&7]||e[_+3&7]||e[_+4&7]||e[_+5&7]||e[_+6&7]||e[_+7&7])&&(n=e,N=_)}for(;r.data!==t;)if(i=r,!(r=r.next))return this;return(o=r.next)&&delete r.next,i?(o?i.next=o:delete i.next,this):e?(o?e[_]=o:delete e[_],(r=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&r===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!r.length&&(n?n[N]=r:this._root=r),this):(this._root=o,this)}function he(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this}function ce(){return this._root}function pe(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function xe(t){var e=[],r,n=this._root,i,o,f,a,s,l,h;for(n&&e.push(new z(n,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));r=e.pop();)if(!t(n=r.node,o=r.x0,f=r.y0,a=r.z0,s=r.x1,l=r.y1,h=r.z1)&&n.length){var c=(o+s)/2,x=(f+l)/2,v=(a+h)/2;(i=n[7])&&e.push(new z(i,c,x,v,s,l,h)),(i=n[6])&&e.push(new z(i,o,x,v,c,l,h)),(i=n[5])&&e.push(new z(i,c,f,v,s,x,h)),(i=n[4])&&e.push(new z(i,o,f,v,c,x,h)),(i=n[3])&&e.push(new z(i,c,x,a,s,l,v)),(i=n[2])&&e.push(new z(i,o,x,a,c,l,v)),(i=n[1])&&e.push(new z(i,c,f,a,s,x,v)),(i=n[0])&&e.push(new z(i,o,f,a,c,x,v))}return this}function _e(t){var e=[],r=[],n;for(this._root&&e.push(new z(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));n=e.pop();){var i=n.node;if(i.length){var o,f=n.x0,a=n.y0,s=n.z0,l=n.x1,h=n.y1,c=n.z1,x=(f+l)/2,v=(a+h)/2,p=(s+c)/2;(o=i[0])&&e.push(new z(o,f,a,s,x,v,p)),(o=i[1])&&e.push(new z(o,x,a,s,l,v,p)),(o=i[2])&&e.push(new z(o,f,v,s,x,h,p)),(o=i[3])&&e.push(new z(o,x,v,s,l,h,p)),(o=i[4])&&e.push(new z(o,f,a,p,x,v,c)),(o=i[5])&&e.push(new z(o,x,a,p,l,v,c)),(o=i[6])&&e.push(new z(o,f,v,p,x,h,c)),(o=i[7])&&e.push(new z(o,x,v,p,l,h,c))}r.push(n)}for(;n=r.pop();)t(n.node,n.x0,n.y0,n.z0,n.x1,n.y1,n.z1);return this}function ve(t){return t[0]}function ye(t){return arguments.length?(this._x=t,this):this._x}function ge(t){return t[1]}function de(t){return arguments.length?(this._y=t,this):this._y}function me(t){return t[2]}function we(t){return arguments.length?(this._z=t,this):this._z}function Y(t,e,r,n){var i=new ot(e??ve,r??ge,n??me,NaN,NaN,NaN,NaN,NaN,NaN);return t==null?i:i.addAll(t)}function ot(t,e,r,n,i,o,f,a,s){this._x=t,this._y=e,this._z=r,this._x0=n,this._y0=i,this._z0=o,this._x1=f,this._y1=a,this._z1=s,this._root=void 0}function Ne(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var P=Y.prototype=ot.prototype;P.copy=function(){var t=new ot(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),e=this._root,r,n;if(!e)return t;if(!e.length)return t._root=Ne(e),t;for(r=[{source:e,target:t._root=new Array(8)}];e=r.pop();)for(var i=0;i<8;++i)(n=e.source[i])&&(n.length?r.push({source:n,target:e.target[i]=new Array(8)}):e.target[i]=Ne(n));return t};P.add=re;P.addAll=ie;P.cover=oe;P.data=ae;P.extent=fe;P.find=se;P.findAllWithinRadius=ue;P.remove=le;P.removeAll=he;P.root=ce;P.size=pe;P.visit=xe;P.visitAfter=_e;P.x=ye;P.y=de;P.z=we;function b(t){return function(){return t}}function j(t){return(t()-.5)*1e-6}function je(t){return t.index}function Ae(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function at(t){var e=je,r=x,n,i=b(30),o,f,a,s,l,h,c=1;t==null&&(t=[]);function x(u){return 1/Math.min(s[u.source.index],s[u.target.index])}function v(u){for(var m=0,d=t.length;m<c;++m)for(var g=0,_,N,A,M=0,S=0,B=0,W,k;g<d;++g)_=t[g],N=_.source,A=_.target,M=A.x+A.vx-N.x-N.vx||j(h),a>1&&(S=A.y+A.vy-N.y-N.vy||j(h)),a>2&&(B=A.z+A.vz-N.z-N.vz||j(h)),W=Math.sqrt(M*M+S*S+B*B),W=(W-o[g])/W*u*n[g],M*=W,S*=W,B*=W,A.vx-=M*(k=l[g]),a>1&&(A.vy-=S*k),a>2&&(A.vz-=B*k),N.vx+=M*(k=1-k),a>1&&(N.vy+=S*k),a>2&&(N.vz+=B*k)}function p(){if(f){var u,m=f.length,d=t.length,g=new Map(f.map((N,A)=>[e(N,A,f),N])),_;for(u=0,s=new Array(m);u<d;++u)_=t[u],_.index=u,typeof _.source!="object"&&(_.source=Ae(g,_.source)),typeof _.target!="object"&&(_.target=Ae(g,_.target)),s[_.source.index]=(s[_.source.index]||0)+1,s[_.target.index]=(s[_.target.index]||0)+1;for(u=0,l=new Array(d);u<d;++u)_=t[u],l[u]=s[_.source.index]/(s[_.source.index]+s[_.target.index]);n=new Array(d),w(),o=new Array(d),y()}}function w(){if(f)for(var u=0,m=t.length;u<m;++u)n[u]=+r(t[u],u,t)}function y(){if(f)for(var u=0,m=t.length;u<m;++u)o[u]=+i(t[u],u,t)}return v.initialize=function(u,...m){f=u,h=m.find(d=>typeof d=="function")||Math.random,a=m.find(d=>[1,2,3].includes(d))||2,p()},v.links=function(u){return arguments.length?(t=u,p(),v):t},v.id=function(u){return arguments.length?(e=u,v):e},v.iterations=function(u){return arguments.length?(c=+u,v):c},v.strength=function(u){return arguments.length?(r=typeof u=="function"?u:b(+u),w(),v):r},v.distance=function(u){return arguments.length?(i=typeof u=="function"?u:b(+u),y(),v):i},v}var Te={value:()=>{}};function ze(){for(var t=0,e=arguments.length,r={},n;t<e;++t){if(!(n=arguments[t]+"")||n in r||/[\\s.]/.test(n))throw new Error("illegal type: "+n);r[n]=[]}return new G(r)}function G(t){this._=t}function Le(t,e){return t.trim().split(/^|\\s+/).map(function(r){var n="",i=r.indexOf(".");if(i>=0&&(n=r.slice(i+1),r=r.slice(0,i)),r&&!e.hasOwnProperty(r))throw new Error("unknown type: "+r);return{type:r,name:n}})}G.prototype=ze.prototype={constructor:G,on:function(t,e){var r=this._,n=Le(t+"",r),i,o=-1,f=n.length;if(arguments.length<2){for(;++o<f;)if((i=(t=n[o]).type)&&(i=Oe(r[i],t.name)))return i;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++o<f;)if(i=(t=n[o]).type)r[i]=Me(r[i],t.name,e);else if(e==null)for(i in r)r[i]=Me(r[i],t.name,null);return this},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new G(t)},call:function(t,e){if((i=arguments.length-2)>0)for(var r=new Array(i),n=0,i,o;n<i;++n)r[n]=arguments[n+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=this._[t],n=0,i=o.length;n<i;++n)o[n].value.apply(e,r)},apply:function(t,e,r){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var n=this._[t],i=0,o=n.length;i<o;++i)n[i].value.apply(e,r)}};function Oe(t,e){for(var r=0,n=t.length,i;r<n;++r)if((i=t[r]).name===e)return i.value}function Me(t,e,r){for(var n=0,i=t.length;n<i;++n)if(t[n].name===e){t[n]=Te,t=t.slice(0,n).concat(t.slice(n+1));break}return r!=null&&t.push({name:e,value:r}),t}var ft=ze;var O=0,H=0,C=0,ke=1e3,J,Q,K=0,L=0,V=0,Z=typeof performance=="object"&&performance.now?performance:Date,qe=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function lt(){return L||(qe(Xe),L=Z.now()+V)}function Xe(){L=0}function st(){this._call=this._time=this._next=null}st.prototype=$.prototype={constructor:st,restart:function(t,e,r){if(typeof t!="function")throw new TypeError("callback is not a function");r=(r==null?lt():+r)+(e==null?0:+e),!this._next&&Q!==this&&(Q?Q._next=this:J=this,Q=this),this._call=t,this._time=r,ut()},stop:function(){this._call&&(this._call=null,this._time=1/0,ut())}};function $(t,e,r){var n=new st;return n.restart(t,e,r),n}function Ie(){lt(),++O;for(var t=J,e;t;)(e=L-t._time)>=0&&t._call.call(void 0,e),t=t._next;--O}function be(){L=(K=Z.now())+V,O=H=0;try{Ie()}finally{O=0,Ye(),L=0}}function Re(){var t=Z.now(),e=t-K;e>ke&&(V-=e,K=t)}function Ye(){for(var t,e=J,r,n=1/0;e;)e._call?(n>e._time&&(n=e._time),t=e,e=e._next):(r=e._next,e._next=null,e=t?t._next=r:J=r);Q=t,ut(n)}function ut(t){if(!O){H&&(H=clearTimeout(H));var e=t-L;e>24?(t<1/0&&(H=setTimeout(be,t-Z.now()-V)),C&&(C=clearInterval(C))):(C||(K=Z.now(),C=setInterval(Re,ke)),O=1,qe(be))}}function Pe(){let t=1;return()=>(t=(1664525*t+1013904223)%4294967296)/4294967296}var Fe=3;function tt(t){return t.x}function ht(t){return t.y}function We(t){return t.z}var Ce=10,He=Math.PI*(3-Math.sqrt(5)),Qe=Math.PI*20/(9+Math.sqrt(221));function ct(t,e){e=e||2;var r=Math.min(Fe,Math.max(1,Math.round(e))),n,i=1,o=.001,f=1-Math.pow(o,1/300),a=0,s=.6,l=new Map,h=$(v),c=ft("tick","end"),x=Pe();t==null&&(t=[]);function v(){p(),c.call("tick",n),i<o&&(h.stop(),c.call("end",n))}function p(u){var m,d=t.length,g;u===void 0&&(u=1);for(var _=0;_<u;++_)for(i+=(a-i)*f,l.forEach(function(N){N(i)}),m=0;m<d;++m)g=t[m],g.fx==null?g.x+=g.vx*=s:(g.x=g.fx,g.vx=0),r>1&&(g.fy==null?g.y+=g.vy*=s:(g.y=g.fy,g.vy=0)),r>2&&(g.fz==null?g.z+=g.vz*=s:(g.z=g.fz,g.vz=0));return n}function w(){for(var u=0,m=t.length,d;u<m;++u){if(d=t[u],d.index=u,d.fx!=null&&(d.x=d.fx),d.fy!=null&&(d.y=d.fy),d.fz!=null&&(d.z=d.fz),isNaN(d.x)||r>1&&isNaN(d.y)||r>2&&isNaN(d.z)){var g=Ce*(r>2?Math.cbrt(.5+u):r>1?Math.sqrt(.5+u):u),_=u*He,N=u*Qe;r===1?d.x=g:r===2?(d.x=g*Math.cos(_),d.y=g*Math.sin(_)):(d.x=g*Math.sin(_)*Math.cos(N),d.y=g*Math.cos(_),d.z=g*Math.sin(_)*Math.sin(N))}(isNaN(d.vx)||r>1&&isNaN(d.vy)||r>2&&isNaN(d.vz))&&(d.vx=0,r>1&&(d.vy=0),r>2&&(d.vz=0))}}function y(u){return u.initialize&&u.initialize(t,x,r),u}return w(),n={tick:p,restart:function(){return h.restart(v),n},stop:function(){return h.stop(),n},numDimensions:function(u){return arguments.length?(r=Math.min(Fe,Math.max(1,Math.round(u))),l.forEach(y),n):r},nodes:function(u){return arguments.length?(t=u,w(),l.forEach(y),n):t},alpha:function(u){return arguments.length?(i=+u,n):i},alphaMin:function(u){return arguments.length?(o=+u,n):o},alphaDecay:function(u){return arguments.length?(f=+u,n):+f},alphaTarget:function(u){return arguments.length?(a=+u,n):a},velocityDecay:function(u){return arguments.length?(s=1-u,n):1-s},randomSource:function(u){return arguments.length?(x=u,l.forEach(y),n):x},force:function(u,m){return arguments.length>1?(m==null?l.delete(u):l.set(u,y(m)),n):l.get(u)},find:function(){var u=Array.prototype.slice.call(arguments),m=u.shift()||0,d=(r>1?u.shift():null)||0,g=(r>2?u.shift():null)||0,_=u.shift()||1/0,N=0,A=t.length,M,S,B,W,k,wt;for(_*=_,N=0;N<A;++N)k=t[N],M=m-k.x,S=d-(k.y||0),B=g-(k.z||0),W=M*M+S*S+B*B,W<_&&(wt=k,_=W);return wt},on:function(u,m){return arguments.length>1?(c.on(u,m),n):c.on(u)}}}function pt(){var t,e,r,n,i,o=b(-30),f,a=1,s=1/0,l=.81;function h(p){var w,y=t.length,u=(e===1?X(t,tt):e===2?R(t,tt,ht):e===3?Y(t,tt,ht,We):null).visitAfter(x);for(i=p,w=0;w<y;++w)r=t[w],u.visit(v)}function c(){if(t){var p,w=t.length,y;for(f=new Array(w),p=0;p<w;++p)y=t[p],f[y.index]=+o(y,p,t)}}function x(p){var w=0,y,u,m=0,d,g,_,N,A=p.length;if(A){for(d=g=_=N=0;N<A;++N)(y=p[N])&&(u=Math.abs(y.value))&&(w+=y.value,m+=u,d+=u*(y.x||0),g+=u*(y.y||0),_+=u*(y.z||0));w*=Math.sqrt(4/A),p.x=d/m,e>1&&(p.y=g/m),e>2&&(p.z=_/m)}else{y=p,y.x=y.data.x,e>1&&(y.y=y.data.y),e>2&&(y.z=y.data.z);do w+=f[y.data.index];while(y=y.next)}p.value=w}function v(p,w,y,u,m){if(!p.value)return!0;var d=[y,u,m][e-1],g=p.x-r.x,_=e>1?p.y-r.y:0,N=e>2?p.z-r.z:0,A=d-w,M=g*g+_*_+N*N;if(A*A/l<M)return M<s&&(g===0&&(g=j(n),M+=g*g),e>1&&_===0&&(_=j(n),M+=_*_),e>2&&N===0&&(N=j(n),M+=N*N),M<a&&(M=Math.sqrt(a*M)),r.vx+=g*p.value*i/M,e>1&&(r.vy+=_*p.value*i/M),e>2&&(r.vz+=N*p.value*i/M)),!0;if(p.length||M>=s)return;(p.data!==r||p.next)&&(g===0&&(g=j(n),M+=g*g),e>1&&_===0&&(_=j(n),M+=_*_),e>2&&N===0&&(N=j(n),M+=N*N),M<a&&(M=Math.sqrt(a*M)));do p.data!==r&&(A=f[p.data.index]*i/M,r.vx+=g*A,e>1&&(r.vy+=_*A),e>2&&(r.vz+=N*A));while(p=p.next)}return h.initialize=function(p,...w){t=p,n=w.find(y=>typeof y=="function")||Math.random,e=w.find(y=>[1,2,3].includes(y))||2,c()},h.strength=function(p){return arguments.length?(o=typeof p=="function"?p:b(+p),c(),h):o},h.distanceMin=function(p){return arguments.length?(a=p*p,h):Math.sqrt(a)},h.distanceMax=function(p){return arguments.length?(s=p*p,h):Math.sqrt(s)},h.theta=function(p){return arguments.length?(l=p*p,h):Math.sqrt(l)},h}function xt(t){var e=b(.1),r,n,i;typeof t!="function"&&(t=b(t==null?0:+t));function o(a){for(var s=0,l=r.length,h;s<l;++s)h=r[s],h.vx+=(i[s]-h.x)*n[s]*a}function f(){if(r){var a,s=r.length;for(n=new Array(s),i=new Array(s),a=0;a<s;++a)n[a]=isNaN(i[a]=+t(r[a],a,r))?0:+e(r[a],a,r)}}return o.initialize=function(a){r=a,f()},o.strength=function(a){return arguments.length?(e=typeof a=="function"?a:b(+a),f(),o):e},o.x=function(a){return arguments.length?(t=typeof a=="function"?a:b(+a),f(),o):t},o}function _t(t){var e=b(.1),r,n,i;typeof t!="function"&&(t=b(t==null?0:+t));function o(a){for(var s=0,l=r.length,h;s<l;++s)h=r[s],h.vy+=(i[s]-h.y)*n[s]*a}function f(){if(r){var a,s=r.length;for(n=new Array(s),i=new Array(s),a=0;a<s;++a)n[a]=isNaN(i[a]=+t(r[a],a,r))?0:+e(r[a],a,r)}}return o.initialize=function(a){r=a,f()},o.strength=function(a){return arguments.length?(e=typeof a=="function"?a:b(+a),f(),o):e},o.y=function(a){return arguments.length?(t=typeof a=="function"?a:b(+a),f(),o):t},o}function vt(t){var e=b(.1),r,n,i;typeof t!="function"&&(t=b(t==null?0:+t));function o(a){for(var s=0,l=r.length,h;s<l;++s)h=r[s],h.vz+=(i[s]-h.z)*n[s]*a}function f(){if(r){var a,s=r.length;for(n=new Array(s),i=new Array(s),a=0;a<s;++a)n[a]=isNaN(i[a]=+t(r[a],a,r))?0:+e(r[a],a,r)}}return o.initialize=function(a){r=a,f()},o.strength=function(a){return arguments.length?(e=typeof a=="function"?a:b(+a),f(),o):e},o.z=function(a){return arguments.length?(t=typeof a=="function"?a:b(+a),f(),o):t},o}var De=self,q=null,U=[],yt=new Float32Array(0),gt=[],T=!0,mt=0,rt=!1,dt=!1;function Se(t){return e=>{let r=typeof e.source=="number"?e.source:e.source.index??0,n=typeof e.target=="number"?e.target:e.target.index??0,i=1/Math.min(yt[r]??1,yt[n]??1);return Math.min(i*t,1)}}function Ze(t){if(!q)return;q.force("charge")?.strength(t.charge);let e=q.force("link");e?.distance(t.linkDistance),e?.strength(Se(t.linkStrength)),q.force("x")?.strength(t.centerPull),q.force("y")?.strength(t.centerPull+t.flatten),q.force("z")?.strength(t.centerPull)}function et(){dt||(dt=!0,self.setTimeout(Ue,0))}function Ue(){dt=!1;let t=q;if(!t||T)return;let e=Date.now();for(;Date.now()-e<12;)if(t.tick(),mt++,t.alpha()<t.alphaMin()){T=!0;break}rt=!0,Be(),T||et()}function Be(){if(!rt||!q)return;let t=gt.pop();if(!t)return;let e=new Float32Array(t);for(let r=0;r<U.length;r++){let n=U[r];n&&(e[r*3]=n.x,e[r*3+1]=n.y,e[r*3+2]=n.z)}rt=!1,De.postMessage({type:"tick",buffer:t,alpha:q.alpha(),settled:T,ticks:mt},[t])}De.onmessage=t=>{let e=t.data;switch(e.type){case"init":{q?.stop();let r=new Float32Array(e.positions);yt=new Float32Array(e.degrees);let n=new Uint32Array(e.links);U=[];for(let o=0;o<e.count;o++)U.push({x:r[o*3]??0,y:r[o*3+1]??0,z:r[o*3+2]??0});let i=[];for(let o=0;o<n.length;o+=2)i.push({source:n[o]??0,target:n[o+1]??0});q=ct(U,3).alphaDecay(1-Math.pow(.001,1/300)).velocityDecay(e.params.velocityDecay).force("link",at(i).distance(e.params.linkDistance).strength(Se(e.params.linkStrength))).force("charge",pt().strength(e.params.charge).distanceMax(800)).force("x",xt(0).strength(e.params.centerPull)).force("y",_t(0).strength(e.params.centerPull+e.params.flatten)).force("z",vt(0).strength(e.params.centerPull)).stop(),q.alpha(e.initialAlpha),gt=[e.bufA,e.bufB],mt=0,T=e.initialAlpha<q.alphaMin(),rt=!1,T||et();break}case"params":Ze(e.params),q&&(q.alpha(Math.max(q.alpha(),.5)),T=!1,et());break;case"reheat":q&&(q.alpha(Math.max(q.alpha(),e.alpha)),T=!1,et());break;case"buffer":gt.push(e.buffer),Be();break}};})();
`;var xl=class{constructor(){this.positions=new Float32Array(0);this.worker=null;this.url="";this.dirty=!1;this.settled=!0;this._ticks=0}get ticks(){return this._ticks}init(t,e,n,s=1){this.disposeWorker(),this.positions=e,this._ticks=0,this.dirty=!1,this.url=URL.createObjectURL(new Blob([Mp],{type:"text/javascript"})),this.worker=new Worker(this.url),this.worker.onmessage=d=>{let h=d.data;if(h.type!=="tick")return;let f=new Float32Array(h.buffer);this.positions.set(f.subarray(0,this.positions.length)),this._ticks=h.ticks,this.settled=h.settled,this.dirty=!0,this.worker?.postMessage({type:"buffer",buffer:h.buffer},[h.buffer])};let r=t.nodes.length,o=new Float32Array(e),a=new Uint32Array(t.links.length*2);t.links.forEach((d,h)=>{a[h*2]=d.source,a[h*2+1]=d.target});let l=new Float32Array(r);t.nodes.forEach((d,h)=>l[h]=Math.max(d.degree,1));let c=new ArrayBuffer(r*3*4),u=new ArrayBuffer(r*3*4);this.settled=s<.001,this.worker.postMessage({type:"init",count:r,positions:o.buffer,links:a.buffer,degrees:l.buffer,params:n,initialAlpha:s,bufA:c,bufB:u},[o.buffer,a.buffer,l.buffer,c,u])}step(){let t=this.dirty;return this.dirty=!1,t}isSettled(){return this.settled}reheat(t=.3){this.settled=!1,this.worker?.postMessage({type:"reheat",alpha:t})}updateParams(t){this.settled=!1,this.worker?.postMessage({type:"params",params:t})}disposeWorker(){this.worker?.terminate(),this.worker=null,this.url&&(URL.revokeObjectURL(this.url),this.url="")}dispose(){this.disposeWorker(),this.settled=!0,this.dirty=!1}};var Os={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,fragmentShader:`
uniform float opacity;
uniform sampler2D tDiffuse;
varying vec2 vUv;
void main() {
vec4 texel = texture2D( tDiffuse, vUv );
gl_FragColor = opacity * texel;
}`};var pn=class{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}},yy=new oi(-1,1,1,-1,0,1),Wh=class extends he{constructor(){super(),this.setAttribute("position",new Oe([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Oe([0,2,0,0,2,0],2))}},by=new Wh,Ui=class{constructor(t){this._mesh=new Xe(by,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,yy)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}};var vl=class extends pn{constructor(t,e="tDiffuse"){super(),this.textureID=e,this.uniforms=null,this.material=null,t instanceof ue?(this.uniforms=t.uniforms,this.material=t):t&&(this.uniforms=li.clone(t.uniforms),this.material=new ue({name:t.name!==void 0?t.name:"unspecified",defines:Object.assign({},t.defines),uniforms:this.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader})),this._fsQuad=new Ui(this.material)}render(t,e,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this._fsQuad.material=this.material,this.renderToScreen?(t.setRenderTarget(null),this._fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),this._fsQuad.render(t))}dispose(){this.material.dispose(),this._fsQuad.dispose()}};var Wr=class extends pn{constructor(t,e){super(),this.scene=t,this.camera=e,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(t,e,n){let s=t.getContext(),r=t.state;r.buffers.color.setMask(!1),r.buffers.depth.setMask(!1),r.buffers.color.setLocked(!0),r.buffers.depth.setLocked(!0);let o,a;this.inverse?(o=0,a=1):(o=1,a=0),r.buffers.stencil.setTest(!0),r.buffers.stencil.setOp(s.REPLACE,s.REPLACE,s.REPLACE),r.buffers.stencil.setFunc(s.ALWAYS,o,4294967295),r.buffers.stencil.setClear(a),r.buffers.stencil.setLocked(!0),t.setRenderTarget(n),this.clear&&t.clear(),t.render(this.scene,this.camera),t.setRenderTarget(e),this.clear&&t.clear(),t.render(this.scene,this.camera),r.buffers.color.setLocked(!1),r.buffers.depth.setLocked(!1),r.buffers.color.setMask(!0),r.buffers.depth.setMask(!0),r.buffers.stencil.setLocked(!1),r.buffers.stencil.setFunc(s.EQUAL,1,4294967295),r.buffers.stencil.setOp(s.KEEP,s.KEEP,s.KEEP),r.buffers.stencil.setLocked(!0)}},_l=class extends pn{constructor(){super(),this.needsSwap=!1}render(t){t.state.buffers.stencil.setLocked(!1),t.state.buffers.stencil.setTest(!1)}};var yl=class{constructor(t,e){if(this.renderer=t,this._pixelRatio=t.getPixelRatio(),e===void 0){let n=t.getSize(new Tt);this._width=n.width,this._height=n.height,e=new Ce(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:qe}),e.texture.name="EffectComposer.rt1"}else this._width=e.width,this._height=e.height;this.renderTarget1=e,this.renderTarget2=e.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new vl(Os),this.copyPass.material.blending=yn,this.timer=new mr}swapBuffers(){let t=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=t}addPass(t){this.passes.push(t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(t,e){this.passes.splice(e,0,t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(t){let e=this.passes.indexOf(t);e!==-1&&this.passes.splice(e,1)}isLastEnabledPass(t){for(let e=t+1;e<this.passes.length;e++)if(this.passes[e].enabled)return!1;return!0}render(t){this.timer.update(),t===void 0&&(t=this.timer.getDelta());let e=this.renderer.getRenderTarget(),n=!1;for(let s=0,r=this.passes.length;s<r;s++){let o=this.passes[s];if(o.enabled!==!1){if(o.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(s),o.render(this.renderer,this.writeBuffer,this.readBuffer,t,n),o.needsSwap){if(n){let a=this.renderer.getContext(),l=this.renderer.state.buffers.stencil;l.setFunc(a.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,t),l.setFunc(a.EQUAL,1,4294967295)}this.swapBuffers()}Wr!==void 0&&(o instanceof Wr?n=!0:o instanceof _l&&(n=!1))}}this.renderer.setRenderTarget(e)}reset(t){if(t===void 0){let e=this.renderer.getSize(new Tt);this._pixelRatio=this.renderer.getPixelRatio(),this._width=e.width,this._height=e.height,t=this.renderTarget1.clone(),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=t,this.renderTarget2=t.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(t,e){this._width=t,this._height=e;let n=this._width*this._pixelRatio,s=this._height*this._pixelRatio;this.renderTarget1.setSize(n,s),this.renderTarget2.setSize(n,s);for(let r=0;r<this.passes.length;r++)this.passes[r].setSize(n,s)}setPixelRatio(t){this._pixelRatio=t,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}};var bl=class extends pn{constructor(t,e,n=null,s=null,r=null){super(),this.scene=t,this.camera=e,this.overrideMaterial=n,this.clearColor=s,this.clearAlpha=r,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this.isRenderPass=!0,this._oldClearColor=new mt}render(t,e,n){let s=t.autoClear;t.autoClear=!1;let r,o;this.overrideMaterial!==null&&(o=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(t.getClearColor(this._oldClearColor),t.setClearColor(this.clearColor,t.getClearAlpha())),this.clearAlpha!==null&&(r=t.getClearAlpha(),t.setClearAlpha(this.clearAlpha)),this.clearDepth==!0&&t.clearDepth(),t.setRenderTarget(this.renderToScreen?null:n),this.clear===!0&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),t.render(this.scene,this.camera),this.clearColor!==null&&t.setClearColor(this._oldClearColor),this.clearAlpha!==null&&t.setClearAlpha(r),this.overrideMaterial!==null&&(this.scene.overrideMaterial=o),t.autoClear=s}};var Sp={name:"LuminosityHighPassShader",uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new mt(0)},defaultOpacity:{value:0}},vertexShader:`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,fragmentShader:`
uniform sampler2D tDiffuse;
uniform vec3 defaultColor;
uniform float defaultOpacity;
uniform float luminosityThreshold;
uniform float smoothWidth;
varying vec2 vUv;
void main() {
vec4 texel = texture2D( tDiffuse, vUv );
float v = luminance( texel.xyz );
vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );
float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );
gl_FragColor = mix( outputColor, texel, alpha );
}`};var Us=class i extends pn{constructor(t,e=1,n,s){super(),this.strength=e,this.radius=n,this.threshold=s,this.resolution=t!==void 0?new Tt(t.x,t.y):new Tt(256,256),this.clearColor=new mt(0,0,0),this.needsSwap=!1,this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let r=Math.round(this.resolution.x/2),o=Math.round(this.resolution.y/2);this.renderTargetBright=new Ce(r,o,{type:qe}),this.renderTargetBright.texture.name="UnrealBloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(let u=0;u<this.nMips;u++){let d=new Ce(r,o,{type:qe});d.texture.name="UnrealBloomPass.h"+u,d.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(d);let h=new Ce(r,o,{type:qe});h.texture.name="UnrealBloomPass.v"+u,h.texture.generateMipmaps=!1,this.renderTargetsVertical.push(h),r=Math.round(r/2),o=Math.round(o/2)}let a=Sp;this.highPassUniforms=li.clone(a.uniforms),this.highPassUniforms.luminosityThreshold.value=s,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new ue({uniforms:this.highPassUniforms,vertexShader:a.vertexShader,fragmentShader:a.fragmentShader}),this.separableBlurMaterials=[];let l=[6,10,14,18,22];r=Math.round(this.resolution.x/2),o=Math.round(this.resolution.y/2);for(let u=0;u<this.nMips;u++)this.separableBlurMaterials.push(this._getSeparableBlurMaterial(l[u])),this.separableBlurMaterials[u].uniforms.invSize.value=new Tt(1/r,1/o),r=Math.round(r/2),o=Math.round(o/2);this.compositeMaterial=this._getCompositeMaterial(this.nMips),this.compositeMaterial.uniforms.blurTexture1.value=this.renderTargetsVertical[0].texture,this.compositeMaterial.uniforms.blurTexture2.value=this.renderTargetsVertical[1].texture,this.compositeMaterial.uniforms.blurTexture3.value=this.renderTargetsVertical[2].texture,this.compositeMaterial.uniforms.blurTexture4.value=this.renderTargetsVertical[3].texture,this.compositeMaterial.uniforms.blurTexture5.value=this.renderTargetsVertical[4].texture,this.compositeMaterial.uniforms.bloomStrength.value=e,this.compositeMaterial.uniforms.bloomRadius.value=.1;let c=[1,.8,.6,.4,.2];this.compositeMaterial.uniforms.bloomFactors.value=c,this.bloomTintColors=[new L(1,1,1),new L(1,1,1),new L(1,1,1),new L(1,1,1),new L(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,this.copyUniforms=li.clone(Os.uniforms),this.blendMaterial=new ue({uniforms:this.copyUniforms,vertexShader:Os.vertexShader,fragmentShader:Os.fragmentShader,premultipliedAlpha:!0,blending:vr,depthTest:!1,depthWrite:!1,transparent:!0}),this._oldClearColor=new mt,this._oldClearAlpha=1,this._basic=new ii,this._fsQuad=new Ui(null)}dispose(){for(let t=0;t<this.renderTargetsHorizontal.length;t++)this.renderTargetsHorizontal[t].dispose();for(let t=0;t<this.renderTargetsVertical.length;t++)this.renderTargetsVertical[t].dispose();this.renderTargetBright.dispose();for(let t=0;t<this.separableBlurMaterials.length;t++)this.separableBlurMaterials[t].dispose();this.compositeMaterial.dispose(),this.blendMaterial.dispose(),this._basic.dispose(),this._fsQuad.dispose()}setSize(t,e){let n=Math.round(t/2),s=Math.round(e/2);this.renderTargetBright.setSize(n,s);for(let r=0;r<this.nMips;r++)this.renderTargetsHorizontal[r].setSize(n,s),this.renderTargetsVertical[r].setSize(n,s),this.separableBlurMaterials[r].uniforms.invSize.value=new Tt(1/n,1/s),n=Math.round(n/2),s=Math.round(s/2)}render(t,e,n,s,r){t.getClearColor(this._oldClearColor),this._oldClearAlpha=t.getClearAlpha();let o=t.autoClear;t.autoClear=!1,t.setClearColor(this.clearColor,0),r&&t.state.buffers.stencil.setTest(!1),this.renderToScreen&&(this._fsQuad.material=this._basic,this._basic.map=n.texture,t.setRenderTarget(null),t.clear(),this._fsQuad.render(t)),this.highPassUniforms.tDiffuse.value=n.texture,this.highPassUniforms.luminosityThreshold.value=this.threshold,this._fsQuad.material=this.materialHighPassFilter,t.setRenderTarget(this.renderTargetBright),t.clear(),this._fsQuad.render(t);let a=this.renderTargetBright;for(let l=0;l<this.nMips;l++)this._fsQuad.material=this.separableBlurMaterials[l],this.separableBlurMaterials[l].uniforms.colorTexture.value=a.texture,this.separableBlurMaterials[l].uniforms.direction.value=i.BlurDirectionX,t.setRenderTarget(this.renderTargetsHorizontal[l]),t.clear(),this._fsQuad.render(t),this.separableBlurMaterials[l].uniforms.colorTexture.value=this.renderTargetsHorizontal[l].texture,this.separableBlurMaterials[l].uniforms.direction.value=i.BlurDirectionY,t.setRenderTarget(this.renderTargetsVertical[l]),t.clear(),this._fsQuad.render(t),a=this.renderTargetsVertical[l];this._fsQuad.material=this.compositeMaterial,this.compositeMaterial.uniforms.bloomStrength.value=this.strength,this.compositeMaterial.uniforms.bloomRadius.value=this.radius,this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,t.setRenderTarget(this.renderTargetsHorizontal[0]),t.clear(),this._fsQuad.render(t),this._fsQuad.material=this.blendMaterial,this.copyUniforms.tDiffuse.value=this.renderTargetsHorizontal[0].texture,r&&t.state.buffers.stencil.setTest(!0),this.renderToScreen?(t.setRenderTarget(null),this._fsQuad.render(t)):(t.setRenderTarget(n),this._fsQuad.render(t)),t.setClearColor(this._oldClearColor,this._oldClearAlpha),t.autoClear=o}_getSeparableBlurMaterial(t){let e=[],n=t/3;for(let s=0;s<t;s++)e.push(.39894*Math.exp(-.5*s*s/(n*n))/n);return new ue({defines:{KERNEL_RADIUS:t},uniforms:{colorTexture:{value:null},invSize:{value:new Tt(.5,.5)},direction:{value:new Tt(.5,.5)},gaussianCoefficients:{value:e}},vertexShader:`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,fragmentShader:`
#include <common>
varying vec2 vUv;
uniform sampler2D colorTexture;
uniform vec2 invSize;
uniform vec2 direction;
uniform float gaussianCoefficients[KERNEL_RADIUS];
void main() {
float weightSum = gaussianCoefficients[0];
vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum;
for ( int i = 1; i < KERNEL_RADIUS; i ++ ) {
float x = float( i );
float w = gaussianCoefficients[i];
vec2 uvOffset = direction * invSize * x;
vec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb;
vec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb;
diffuseSum += ( sample1 + sample2 ) * w;
}
gl_FragColor = vec4( diffuseSum, 1.0 );
}`})}_getCompositeMaterial(t){return new ue({defines:{NUM_MIPS:t},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,fragmentShader:`
varying vec2 vUv;
uniform sampler2D blurTexture1;
uniform sampler2D blurTexture2;
uniform sampler2D blurTexture3;
uniform sampler2D blurTexture4;
uniform sampler2D blurTexture5;
uniform float bloomStrength;
uniform float bloomRadius;
uniform float bloomFactors[NUM_MIPS];
uniform vec3 bloomTintColors[NUM_MIPS];
float lerpBloomFactor( const in float factor ) {
float mirrorFactor = 1.2 - factor;
return mix( factor, mirrorFactor, bloomRadius );
}
void main() {
// 3.0 for backwards compatibility with previous alpha-based intensity
vec3 bloom = 3.0 * bloomStrength * (
lerpBloomFactor( bloomFactors[ 0 ] ) * bloomTintColors[ 0 ] * texture2D( blurTexture1, vUv ).rgb +
lerpBloomFactor( bloomFactors[ 1 ] ) * bloomTintColors[ 1 ] * texture2D( blurTexture2, vUv ).rgb +
lerpBloomFactor( bloomFactors[ 2 ] ) * bloomTintColors[ 2 ] * texture2D( blurTexture3, vUv ).rgb +
lerpBloomFactor( bloomFactors[ 3 ] ) * bloomTintColors[ 3 ] * texture2D( blurTexture4, vUv ).rgb +
lerpBloomFactor( bloomFactors[ 4 ] ) * bloomTintColors[ 4 ] * texture2D( blurTexture5, vUv ).rgb
);
float bloomAlpha = max( bloom.r, max( bloom.g, bloom.b ) );
gl_FragColor = vec4( bloom, bloomAlpha );
}`})}};Us.BlurDirectionX=new Tt(1,0);Us.BlurDirectionY=new Tt(0,1);var Xr={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},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;
#include <tonemapping_pars_fragment>
#include <colorspace_pars_fragment>
varying vec2 vUv;
void main() {
gl_FragColor = texture2D( tDiffuse, vUv );
// tone mapping
#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
// color space
#ifdef SRGB_TRANSFER
gl_FragColor = sRGBTransferOETF( gl_FragColor );
#endif
}`};var Ml=class extends pn{constructor(){super(),this.isOutputPass=!0,this.uniforms=li.clone(Xr.uniforms),this.material=new As({name:Xr.name,uniforms:this.uniforms,vertexShader:Xr.vertexShader,fragmentShader:Xr.fragmentShader}),this._fsQuad=new Ui(this.material),this._outputColorSpace=null,this._toneMapping=null}render(t,e,n){this.uniforms.tDiffuse.value=n.texture,this.uniforms.toneMappingExposure.value=t.toneMappingExposure,(this._outputColorSpace!==t.outputColorSpace||this._toneMapping!==t.toneMapping)&&(this._outputColorSpace=t.outputColorSpace,this._toneMapping=t.toneMapping,this.material.defines={},Vt.getTransfer(this._outputColorSpace)===Jt&&(this.material.defines.SRGB_TRANSFER=""),this._toneMapping===_r?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===yr?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===br?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===Li?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===Sr?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===wr?this.material.defines.NEUTRAL_TONE_MAPPING="":this._toneMapping===Mr&&(this.material.defines.CUSTOM_TONE_MAPPING=""),this.material.needsUpdate=!0),this.renderToScreen===!0?(t.setRenderTarget(null),this._fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),this._fsQuad.render(t))}dispose(){this.material.dispose(),this._fsQuad.dispose()}};var Sl=`
attribute float aSize;
attribute float aGhost;
attribute float aDim;
varying vec3 vColor;
varying float vGhost;
varying float vDim;
uniform float uPixelScale; // drawingBufferHeight / (2\xB7tan(fov/2))
uniform float uSizeMul; // \u63A7\u5236\u9762\u677F\u300C\u8282\u70B9\u5927\u5C0F\u300D\u500D\u7387
uniform float uMaxPoint; // \u8BBE\u5907\u50CF\u7D20\u94B3\u5236\uFF1A\u7A7F\u884C\u661F\u56E2\u65F6\u9632\u6EE1\u5C4F\u5927\u7CBE\u7075\u6253\u7206\u586B\u5145\u7387\uFF08M3\uFF09
void main() {
vColor = color;
vGhost = aGhost;
vDim = aDim;
vec4 mv = modelViewMatrix * vec4(position, 1.0);
gl_PointSize = min(aSize * uSizeMul * uPixelScale / max(-mv.z, 1.0), uMaxPoint);
gl_Position = projectionMatrix * mv;
}
`,wl=`
varying vec3 vColor;
varying float vGhost;
varying float vDim;
uniform float uLightMode; // 0 = \u6DF1\u7A7A\uFF08\u767D\u70ED\u6838\u5FC3\uFF09\uFF0C1 = \u6668\u663C\uFF08\u58A8\u6C34\u5706\u76D8 + rim\uFF09
void main() {
vec2 uv = gl_PointCoord - 0.5;
float d = length(uv);
float core = smoothstep(0.16, 0.0, d) * 0.18 * (1.0 - vGhost) * (1.0 - uLightMode);
vec3 col = mix(vColor, vec3(1.0), core);
float rim = smoothstep(0.36, 0.48, d) * smoothstep(0.51, 0.45, d);
col = mix(col, col * mix(0.58, 0.68, uLightMode), rim);
float alpha = smoothstep(0.5, 0.43, d) * mix(1.0, 0.5, vGhost) * vDim;
if (alpha < 0.01) discard;
gl_FragColor = vec4(col, alpha);
}
`;function qr(i){let t=i.map(e=>({prefix:e.query.startsWith("path:")?e.query.slice(5).trim():null,raw:e.query,color:new mt(e.color)}));return e=>{if(e.unresolved)return Tp;for(let n of t)if(n.prefix!==null?e.id.startsWith(n.prefix):e.id.includes(n.raw))return n.color;return Ap(e.folderTop,!1)}}var El=i=>Ap(i.folderTop,i.unresolved),wp=[0,40,80,120,160,200,240,280,320],My=new mt("#9aa4b2"),Tp=new mt("#7a8499"),Ep=new Map;function Ap(i,t){if(t)return Tp;if(i==="")return My;let e=Ep.get(i);if(!e){let n=wp[Rh(i)%wp.length]??0;e=new mt().setHSL(n/360,.6,.6),Ep.set(i,e)}return e}function Cp(i,t){let e=i.clone().lerp(t,.5),n={h:0,s:0,l:0};return e.getHSL(n),e.setHSL(n.h,n.s*.4,Math.min(n.l,.35)),e}var Sy=[{count:2600,size:1.2},{count:900,size:2},{count:250,size:3}],wy=new mt("#9da8c4"),Ey=new mt("#ffffff"),Ty=new mt("#ffe9c9"),Ay=new mt("#bfd3ff");function Cy(i){let t=i>>>0;return()=>{t=t+1831565813>>>0;let e=t;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}function Xh(i){for(let t of i.children){let e=t;e.geometry.dispose(),e.material.dispose()}}var Tl=class{constructor(t,e){this.geometry=t;this.starCount=e;this.active=null;this.nextIn=3;this.attr=t.getAttribute("color"),this.baseColors=new Float32Array(this.attr.array)}update(t,e){if(this.active){this.active.t+=t;let n=this.active.t,s=1.6,r=this.attr.array,o=this.active.index*3,a=n>=s?1:1+2.2*Math.sin(Math.PI*n/s);r[o]=(this.baseColors[o]??1)*a,r[o+1]=(this.baseColors[o+1]??1)*a,r[o+2]=(this.baseColors[o+2]??1)*a,this.attr.needsUpdate=!0,n>=s&&(this.active=null);return}e<=.01||(this.nextIn-=t,this.nextIn<=0&&(this.active={index:Math.floor(Math.random()*this.starCount),t:0},this.nextIn=Math.min(Math.max(-Math.log(Math.random()+1e-9)*(6/e),1.5),90)))}};function qh(i,t=1){let e=new Qn,n=Cy(5340353),s=null;for(let r of Sy){let o={count:Math.max(Math.round(r.count*t),50),size:r.size},a=new Float32Array(o.count*3),l=new Float32Array(o.count*3);for(let h=0;h<o.count;h++){let f=2*Math.PI*n(),m=Math.acos(2*n()-1),x=i*(.95+.1*n());a[h*3]=x*Math.sin(m)*Math.cos(f),a[h*3+1]=x*Math.sin(m)*Math.sin(f),a[h*3+2]=x*Math.cos(m);let g=n(),p=g<.85?wy.clone().lerp(Ey,n()):g<.95?Ty.clone():Ay.clone();o.size>=3&&n()<.03&&p.multiplyScalar(1.8),l[h*3]=p.r,l[h*3+1]=p.g,l[h*3+2]=p.b}let c=new he;c.setAttribute("position",new Yt(a,3)),c.setAttribute("color",new Yt(l,3));let u=new Ai({size:o.size,sizeAttenuation:!1,vertexColors:!0,transparent:!0,opacity:.55,depthWrite:!1}),d=new Gn(c,u);d.renderOrder=-1,e.add(d),o.size>=3&&(s=new Tl(c,o.count))}return{group:e,twinkler:s??new Tl(new he().setAttribute("color",new Yt(new Float32Array(3),3)),1)}}var Al={id:"deep-space",background:3,starfield:!0,motes:!1,bloomEnabled:!0,lightMode:!1,nodeLightness:null,linkInk:null,linkOpacityScale:1,panelClass:"gx-theme-dark"},Rp={id:"daylight",background:16184559,starfield:!1,motes:!0,bloomEnabled:!1,lightMode:!0,nodeLightness:.44,linkInk:"#2e2a24",linkOpacityScale:.65,panelClass:"gx-theme-light"};var Ry=.12,Py=.28,Cl=class{constructor(t,e){this.scene=new $i;this.nodePoints=null;this.nodeMaterial=null;this.nodeGeometry=null;this.linkSegments=null;this.linkGeometry=null;this.linkMaterial=null;this.selSegments=null;this.selGeometry=null;this.selMaterial=null;this.selLinkIdx=[];this.twinkleFreq=.5;this.motes=null;this.reveal=null;this.revealBuf=new Float32Array(0);this.data={nodes:[],links:[]};this.positions=new Float32Array(0);this.sizes=new Float32Array(0);this.dimCurrent=new Float32Array(0);this.dimTarget=new Float32Array(0);this.dimAnimating=!1;this.colorFn=El;this.tokens=Al;this.tierBloomAllowed=!0;this.lastW=2;this.lastH=2;this.baseLinkOpacity=.16;this.focusActive=!1;this.projVec=new L;this.pixelScale=1;this.nodeScale=1;this.sizeMode="degree";this.graphRadiusEstimate=e,this.renderer=new Ns({antialias:!1,alpha:!1}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.renderer.toneMapping=Li,this.renderer.toneMappingExposure=1.05,this.renderer.info.autoReset=!1,t.appendChild(this.renderer.domElement),this.scene.background=new mt(this.tokens.background),this.camera=new We(60,1,.5,5e4);let n=qh(e*6.5);this.starfield=n.group,this.twinkler=n.twinkler,this.scene.add(this.starfield),this.composer=new yl(this.renderer),this.renderPass=new bl(this.scene,this.camera),this.bloomPass=new Us(new Tt(2,2),Qr.strength,Qr.radius,Qr.threshold),this.outputPass=new Ml,this.composer.addPass(this.renderPass),this.composer.addPass(this.bloomPass),this.composer.addPass(this.outputPass)}setColorFn(t){this.colorFn=t}setData(t,e){this.data=t,this.positions=e,this.disposeGraphObjects();let n=t.nodes.length,s=t.links.length,r=new Float32Array(n*3);r.set(e.subarray(0,n*3));let o=new Float32Array(n);this.sizes=new Float32Array(n),this.dimCurrent=new Float32Array(n).fill(1),this.dimTarget=new Float32Array(n).fill(1);for(let a=0;a<n;a++){let l=t.nodes[a];l&&(o[a]=l.unresolved?1:0,this.sizes[a]=this.computeSize(l))}this.nodeGeometry=new he,this.nodeGeometry.setAttribute("position",new Yt(r,3)),this.nodeGeometry.setAttribute("color",new Yt(new Float32Array(n*3),3)),this.nodeGeometry.setAttribute("aSize",new Yt(this.sizes,1)),this.nodeGeometry.setAttribute("aGhost",new Yt(o,1)),this.nodeGeometry.setAttribute("aDim",new Yt(this.dimCurrent,1)),this.nodeMaterial=new ue({vertexShader:Sl,fragmentShader:wl,vertexColors:!0,transparent:!0,depthWrite:!1,uniforms:{uPixelScale:{value:this.pixelScale},uSizeMul:{value:this.nodeScale},uLightMode:{value:this.tokens.lightMode?1:0},uMaxPoint:{value:110*this.renderer.getPixelRatio()}}}),this.nodePoints=new Gn(this.nodeGeometry,this.nodeMaterial),this.nodePoints.renderOrder=1,this.nodePoints.frustumCulled=!1,this.scene.add(this.nodePoints),this.linkGeometry=new he,this.linkGeometry.setAttribute("position",new Yt(new Float32Array(s*2*3),3)),this.linkGeometry.setAttribute("color",new Yt(new Float32Array(s*2*3),3)),this.linkMaterial=new zn({vertexColors:!0,transparent:!0,opacity:this.effectiveLinkOpacity(),depthWrite:!1}),this.linkSegments=new si(this.linkGeometry,this.linkMaterial),this.linkSegments.renderOrder=0,this.linkSegments.frustumCulled=!1,this.scene.add(this.linkSegments),this.recolor(),this.updatePositions(),this.setSelectedLinks(this.selLinkIdx)}computeSize(t){switch(this.sizeMode){case"fileSize":return Math.min(Math.max(ss*(.7+1.1*Math.cbrt(t.fileSize/4096)),1.6),rc);case"uniform":return ss*1.3;default:return Math.min(ss*(1+.5*Math.sqrt(t.degree)),rc)}}setSizeMode(t){if(this.sizeMode=t,!!this.nodeGeometry){for(let e=0;e<this.data.nodes.length;e++){let n=this.data.nodes[e];n&&(this.sizes[e]=this.computeSize(n))}this.nodeGeometry.getAttribute("aSize").needsUpdate=!0}}playReveal(t=2600){let e=this.data.nodes.length;if(e===0)return;let n=1;for(let s=0;s<e;s++){let r=Math.hypot(this.positions[s*3]??0,this.positions[s*3+1]??0,this.positions[s*3+2]??0);r>n&&(n=r)}this.revealBuf.length<e*3&&(this.revealBuf=new Float32Array(e*3)),this.reveal={t0:performance.now(),durMs:t,maxR:n}}stepReveal(t){if(!this.reveal||!this.nodeGeometry||!this.linkGeometry)return;let{t0:e,durMs:n,maxR:s}=this.reveal,r=(t-e)/n;if(r>=1){this.reveal=null,this.updatePositions(),this.linkMaterial&&(this.linkMaterial.opacity=this.effectiveLinkOpacity());return}let o=this.data.nodes.length,a=this.revealBuf,l=this.positions;for(let f=0;f<o;f++){let m=l[f*3]??0,x=l[f*3+1]??0,g=l[f*3+2]??0,p=Math.hypot(m,x,g)/s*.55,v=Math.min(Math.max((r-p)/.45,0),1),M=1-Math.pow(1-v,3);a[f*3]=m*M,a[f*3+1]=x*M,a[f*3+2]=g*M}let c=this.nodeGeometry.getAttribute("position");c.array.set(a.subarray(0,o*3)),c.needsUpdate=!0;let u=this.linkGeometry.getAttribute("position"),d=u.array,h=this.data.links;for(let f=0;f<h.length;f++){let m=h[f];if(!m)continue;let x=m.source*3,g=m.target*3,p=f*6;d[p]=a[x]??0,d[p+1]=a[x+1]??0,d[p+2]=a[x+2]??0,d[p+3]=a[g]??0,d[p+4]=a[g+1]??0,d[p+5]=a[g+2]??0}u.needsUpdate=!0,this.linkMaterial&&(this.linkMaterial.opacity=this.effectiveLinkOpacity()*Math.min(r*1.6,1))}get revealing(){return this.reveal!==null}recolor(){if(!this.nodeGeometry||!this.linkGeometry)return;let t=this.data.nodes.length,e=this.nodeGeometry.getAttribute("color"),n=e.array,s=new Array(t),r={h:0,s:0,l:0};for(let u=0;u<t;u++){let d=this.data.nodes[u];if(!d)continue;let h=this.colorFn(d).clone();this.tokens.nodeLightness!==null&&(h.getHSL(r),h=h.setHSL(r.h,r.s*.95,this.tokens.nodeLightness)),s[u]=h,n[u*3]=h.r,n[u*3+1]=h.g,n[u*3+2]=h.b}e.needsUpdate=!0;let o=this.linkGeometry.getAttribute("color"),a=o.array,l=this.tokens.linkInk?new mt(this.tokens.linkInk):null,c=new mt("#7a87a8");for(let u=0;u<this.data.links.length;u++){let d=this.data.links[u];if(!d)continue;let h=l??Cp(s[d.source]??c,s[d.target]??c);for(let f of[0,1])a[(u*2+f)*3]=h.r,a[(u*2+f)*3+1]=h.g,a[(u*2+f)*3+2]=h.b}o.needsUpdate=!0}updatePositions(){if(!this.nodeGeometry||!this.linkGeometry)return;let t=this.data.nodes.length,e=this.nodeGeometry.getAttribute("position");e.array.set(this.positions.subarray(0,t*3)),e.needsUpdate=!0;let n=this.linkGeometry.getAttribute("position"),s=n.array,r=this.positions,o=this.data.links;for(let a=0;a<o.length;a++){let l=o[a];if(!l)continue;let c=l.source*3,u=l.target*3,d=a*6;s[d]=r[c]??0,s[d+1]=r[c+1]??0,s[d+2]=r[c+2]??0,s[d+3]=r[u]??0,s[d+4]=r[u+1]??0,s[d+5]=r[u+2]??0}n.needsUpdate=!0,this.updateSelPositions()}setFocus(t,e){let n=this.data.nodes.length;this.focusActive=e!==null;for(let s=0;s<n;s++)this.dimTarget[s]=!e||e.has(s)||s===t?1:Ry;this.dimAnimating=!0,this.linkMaterial&&(this.linkMaterial.opacity=this.effectiveLinkOpacity())}setSelectedLinks(t){if(this.selLinkIdx=t,this.selSegments&&(this.scene.remove(this.selSegments),this.selGeometry?.dispose(),this.selMaterial?.dispose(),this.selSegments=null,this.selGeometry=null,this.selMaterial=null),t.length===0)return;let e=t.length,n=new Float32Array(e*6),s=new Float32Array(e*6),r={h:0,s:0,l:0};for(let o=0;o<e;o++){let a=this.data.links[t[o]??-1];if(!a)continue;let l=this.data.nodes[a.source],c=l?this.colorFn(l).clone():new mt("#9aa4b2");c.getHSL(r),c.setHSL(r.h,Math.min(r.s*1.2,1),this.tokens.lightMode?.42:.62);for(let u of[0,1])s[o*6+u*3]=c.r,s[o*6+u*3+1]=c.g,s[o*6+u*3+2]=c.b}this.selGeometry=new he,this.selGeometry.setAttribute("position",new Yt(n,3)),this.selGeometry.setAttribute("color",new Yt(s,3)),this.selMaterial=new zn({vertexColors:!0,transparent:!0,opacity:.85,depthWrite:!1}),this.selSegments=new si(this.selGeometry,this.selMaterial),this.selSegments.renderOrder=2,this.selSegments.frustumCulled=!1,this.scene.add(this.selSegments),this.updateSelPositions()}updateSelPositions(){if(!this.selGeometry||this.selLinkIdx.length===0)return;let t=this.selGeometry.getAttribute("position"),e=t.array,n=this.positions;for(let s=0;s<this.selLinkIdx.length;s++){let r=this.data.links[this.selLinkIdx[s]??-1];if(!r)continue;let o=r.source*3,a=r.target*3;e[s*6]=n[o]??0,e[s*6+1]=n[o+1]??0,e[s*6+2]=n[o+2]??0,e[s*6+3]=n[a]??0,e[s*6+4]=n[a+1]??0,e[s*6+5]=n[a+2]??0}t.needsUpdate=!0}effectiveLinkOpacity(){let t=this.baseLinkOpacity*this.tokens.linkOpacityScale;return this.focusActive?t*.25:t}applyTokens(t,e){this.tokens=t,this.scene.background=new mt(t.background),this.starfield.visible=t.starfield,this.renderer.toneMapping=t.lightMode?dn:Li,this.nodeMaterial&&(this.nodeMaterial.uniforms.uLightMode.value=t.lightMode?1:0),this.bloomPass.enabled=t.bloomEnabled&&this.tierBloomAllowed&&e>.001,t.motes&&!this.motes&&this.buildMotes(),this.motes&&(this.motes.visible=t.motes),this.linkMaterial&&(this.linkMaterial.opacity=this.effectiveLinkOpacity()),this.recolor(),this.setSelectedLinks(this.selLinkIdx)}get currentTokens(){return this.tokens}buildMotes(){let e=new Float32Array(1800),n=this.graphRadiusEstimate*2.2;for(let o=0;o<600;o++)e[o*3]=(Math.random()*2-1)*n,e[o*3+1]=(Math.random()*2-1)*n,e[o*3+2]=(Math.random()*2-1)*n;let s=new he;s.setAttribute("position",new Yt(e,3));let r=new Ai({color:new mt("#d8d4cb"),size:1.6,sizeAttenuation:!0,transparent:!0,opacity:.5,depthWrite:!1});this.motes=new Gn(s,r),this.motes.renderOrder=-1,this.scene.add(this.motes)}render(t){this.starfield.rotation.y+=oc*t,this.starfield.visible&&this.twinkler.update(t,this.twinkleFreq),this.motes?.visible&&(this.motes.rotation.y-=oc*2*t),this.dimAnimating&&this.stepDim(t),this.reveal&&this.stepReveal(performance.now()),this.renderer.info.reset(),this.composer.render()}stepDim(t){let e=Math.min(t/Py,1),n=!1;for(let s=0;s<this.dimCurrent.length;s++){let r=this.dimCurrent[s]??1,o=this.dimTarget[s]??1,a=r+(o-r)*e;this.dimCurrent[s]=Math.abs(a-o)<.005?o:a,this.dimCurrent[s]!==o&&(n=!0)}this.dimAnimating=n,this.nodeGeometry&&(this.nodeGeometry.getAttribute("aDim").needsUpdate=!0)}get drawCalls(){return this.renderer.info.render.calls}setBloomParams(t){this.bloomPass.strength=t.strength,this.bloomPass.radius=t.radius,this.bloomPass.threshold=t.threshold,this.bloomPass.enabled=this.tokens.bloomEnabled&&this.tierBloomAllowed&&t.strength>.001}getBloomStrength(){return this.bloomPass.enabled?this.bloomPass.strength:0}setBloomStrength(t){this.bloomPass.strength=t,this.bloomPass.enabled=this.tokens.bloomEnabled&&this.tierBloomAllowed&&t>.001}applyTier(t,e){this.tierBloomAllowed=t.bloomAllowed,this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,t.pixelRatioCap)),this.bloomPass.enabled=this.tokens.bloomEnabled&&this.tierBloomAllowed&&e>.001;let n=this.starfield.visible,s=this.starfield.rotation.y;Xh(this.starfield),this.scene.remove(this.starfield);let r=qh(this.graphRadiusEstimate*6.5,t.starScale);this.starfield=r.group,this.twinkler=r.twinkler,this.starfield.visible=n,this.starfield.rotation.y=s,this.scene.add(this.starfield),this.resize(this.lastW,this.lastH);let o=this.nodeMaterial?.uniforms.uMaxPoint;o&&(o.value=110*this.renderer.getPixelRatio())}setLinkOpacity(t){this.baseLinkOpacity=t,this.linkMaterial&&(this.linkMaterial.opacity=this.effectiveLinkOpacity())}setNodeScale(t){this.nodeScale=t;let e=this.nodeMaterial?.uniforms.uSizeMul;e&&(e.value=t)}resize(t,e){if(t<2||e<2)return;this.lastW=t,this.lastH=e,this.camera.aspect=t/e,this.camera.updateProjectionMatrix(),this.renderer.setSize(t,e),this.composer.setSize(t,e),this.bloomPass.resolution.set(t,e);let n=e*this.renderer.getPixelRatio();this.pixelScale=n/(2*Math.tan(this.camera.fov/2*Math.PI/180));let s=this.nodeMaterial?.uniforms.uPixelScale;s&&(s.value=this.pixelScale)}projectNode(t,e,n){return this.projVec.set(this.positions[t*3]??0,this.positions[t*3+1]??0,this.positions[t*3+2]??0),this.projVec.project(this.camera),{x:(this.projVec.x+1)/2*e,y:(1-this.projVec.y)/2*n,behind:this.projVec.z>1}}pickNearest(t,e,n,s,r){let o=-1,a=r;for(let l=0;l<this.data.nodes.length;l++){let c=this.projectNode(l,n,s);if(c.behind)continue;let u=Math.hypot(c.x-t,c.y-e);u<a&&(a=u,o=l)}return o}nodeRadius(t){return this.sizes[t]??ss}nodePosition(t,e){return e.set(this.positions[t*3]??0,this.positions[t*3+1]??0,this.positions[t*3+2]??0)}nodeColorHex(t){let e=this.data.nodes[t];return e?`#${this.colorFn(e).getHexString()}`:"#9aa4b2"}cameraDistanceTo(t){return this.projVec.set(this.positions[t*3]??0,this.positions[t*3+1]??0,this.positions[t*3+2]??0),this.camera.position.distanceTo(this.projVec)}disposeGraphObjects(){this.nodePoints&&this.scene.remove(this.nodePoints),this.linkSegments&&this.scene.remove(this.linkSegments),this.selSegments&&(this.scene.remove(this.selSegments),this.selGeometry?.dispose(),this.selMaterial?.dispose(),this.selSegments=null,this.selGeometry=null,this.selMaterial=null),this.nodeGeometry?.dispose(),this.nodeMaterial?.dispose(),this.linkGeometry?.dispose(),this.linkMaterial?.dispose(),this.nodePoints=null,this.linkSegments=null,this.nodeGeometry=null,this.linkGeometry=null,this.nodeMaterial=null,this.linkMaterial=null}dispose(){this.disposeGraphObjects(),Xh(this.starfield),this.scene.remove(this.starfield),this.motes&&(this.motes.geometry.dispose(),this.motes.material.dispose(),this.scene.remove(this.motes),this.motes=null),this.bloomPass.dispose(),this.outputPass.dispose(),this.renderPass.dispose(),this.composer.dispose(),this.renderer.dispose();try{this.renderer.forceContextLoss()}catch{}this.renderer.domElement.remove()}};var Pp={type:"change"},Zh={type:"start"},Lp={type:"end"},Rl=new Ti,Ip=new _n,Iy=Math.cos(70*ih.DEG2RAD),Ie=new L,en=2*Math.PI,ie={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Yh=1e-6,Pl=class extends gr{constructor(t,e=null){super(t,e),this.state=ie.NONE,this.target=new L,this.cursor=new L,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:Cn.ROTATE,MIDDLE:Cn.DOLLY,RIGHT:Cn.PAN},this.touches={ONE:Ii.ROTATE,TWO:Ii.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new L,this._lastQuaternion=new cn,this._lastTargetPosition=new L,this._quat=new cn().setFromUnitVectors(t.up,new L(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new un,this._sphericalDelta=new un,this._scale=1,this._panOffset=new L,this._rotateStart=new Tt,this._rotateEnd=new Tt,this._rotateDelta=new Tt,this._panStart=new Tt,this._panEnd=new Tt,this._panDelta=new Tt,this._dollyStart=new Tt,this._dollyEnd=new Tt,this._dollyDelta=new Tt,this._dollyDirection=new L,this._mouse=new Tt,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Dy.bind(this),this._onPointerDown=Ly.bind(this),this._onPointerUp=Ny.bind(this),this._onContextMenu=Gy.bind(this),this._onMouseWheel=Oy.bind(this),this._onKeyDown=Uy.bind(this),this._onTouchStart=By.bind(this),this._onTouchMove=zy.bind(this),this._onMouseDown=Fy.bind(this),this._onMouseMove=ky.bind(this),this._interceptControlDown=Vy.bind(this),this._interceptControlUp=Hy.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(t){this._cursorStyle=t,t==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(t){super.connect(t),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=""}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(t){t.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=t}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(Pp),this.update(),this.state=ie.NONE}pan(t,e){this._pan(t,e),this.update()}dollyIn(t){this._dollyIn(t),this.update()}dollyOut(t){this._dollyOut(t),this.update()}rotateLeft(t){this._rotateLeft(t),this.update()}rotateUp(t){this._rotateUp(t),this.update()}update(t=null){let e=this.object.position;Ie.copy(e).sub(this.target),Ie.applyQuaternion(this._quat),this._spherical.setFromVector3(Ie),this.autoRotate&&this.state===ie.NONE&&this._rotateLeft(this._getAutoRotationAngle(t)),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 n=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(n)&&isFinite(s)&&(n<-Math.PI?n+=en:n>Math.PI&&(n-=en),s<-Math.PI?s+=en:s>Math.PI&&(s-=en),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,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 r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=o!=this._spherical.radius}if(Ie.setFromSpherical(this._spherical),Ie.applyQuaternion(this._quatInverse),e.copy(this.target).add(Ie),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 o=null;if(this.object.isPerspectiveCamera){let a=Ie.length();o=this._clampDistance(a*this._scale);let l=a-o;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){let a=new L(this._mouse.x,this._mouse.y,0);a.unproject(this.object);let l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;let c=new L(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),o=Ie.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(Rl.origin.copy(this.object.position),Rl.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Rl.direction))<Iy?this.object.lookAt(this.target):(Ip.setFromNormalAndCoplanarPoint(this.object.up,this.target),Rl.intersectPlane(Ip,this.target))))}else if(this.object.isOrthographicCamera){let o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>Yh||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Yh||this._lastTargetPosition.distanceToSquared(this.target)>Yh?(this.dispatchEvent(Pp),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(t){return t!==null?en/60*this.autoRotateSpeed*t:en/60/60*this.autoRotateSpeed}_getZoomScale(t){let e=Math.abs(t*.01);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,e){Ie.setFromMatrixColumn(e,0),Ie.multiplyScalar(-t),this._panOffset.add(Ie)}_panUp(t,e){this.screenSpacePanning===!0?Ie.setFromMatrixColumn(e,1):(Ie.setFromMatrixColumn(e,0),Ie.crossVectors(this.object.up,Ie)),Ie.multiplyScalar(t),this._panOffset.add(Ie)}_pan(t,e){let n=this.domElement;if(this.object.isPerspectiveCamera){let s=this.object.position;Ie.copy(s).sub(this.target);let r=Ie.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*r/n.clientHeight,this.object.matrix),this._panUp(2*e*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),s=t-n.left,r=e-n.top,o=n.width,a=n.height;this._mouse.x=s/o*2-1,this._mouse.y=-(r/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let e=this.domElement;this._rotateLeft(en*this._rotateDelta.x/e.clientHeight),this._rotateUp(en*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.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(t){this._panEnd.set(t.clientX,t.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(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let e=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(en*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(-en*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(en*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(-en*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),e=!0;break}e&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(this._pointers.length===1)this._rotateStart.set(t.pageX,t.pageY);else{let e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(t){if(this._pointers.length===1)this._panStart.set(t.pageX,t.pageY);else{let e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._panStart.set(n,s)}}_handleTouchStartDolly(t){let e=this._getSecondPointerPosition(t),n=t.pageX-e.x,s=t.pageY-e.y,r=Math.sqrt(n*n+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(this._pointers.length==1)this._rotateEnd.set(t.pageX,t.pageY);else{let n=this._getSecondPointerPosition(t),s=.5*(t.pageX+n.x),r=.5*(t.pageY+n.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let e=this.domElement;this._rotateLeft(en*this._rotateDelta.x/e.clientHeight),this._rotateUp(en*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(this._pointers.length===1)this._panEnd.set(t.pageX,t.pageY);else{let e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){let e=this._getSecondPointerPosition(t),n=t.pageX-e.x,s=t.pageY-e.y,r=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let o=(t.pageX+e.x)*.5,a=(t.pageY+e.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId){this._pointers.splice(e,1);return}}_isTrackingPointer(t){for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId)return!0;return!1}_trackPointer(t){let e=this._pointerPositions[t.pointerId];e===void 0&&(e=new Tt,this._pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}_getSecondPointerPosition(t){let e=t.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[e]}_customWheelEvent(t){let e=t.deltaMode,n={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(e){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return t.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}};function Ly(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function Dy(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function Ny(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Lp),this.state=ie.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:let t=this._pointers[0],e=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:e.x,pageY:e.y});break}}function Fy(i){let t;switch(i.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case Cn.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=ie.DOLLY;break;case Cn.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=ie.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=ie.ROTATE}break;case Cn.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=ie.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=ie.PAN}break;default:this.state=ie.NONE}this.state!==ie.NONE&&this.dispatchEvent(Zh)}function ky(i){switch(this.state){case ie.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case ie.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case ie.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function Oy(i){this.enabled===!1||this.enableZoom===!1||this.state!==ie.NONE||(i.preventDefault(),this.dispatchEvent(Zh),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(Lp))}function Uy(i){this.enabled!==!1&&this._handleKeyDown(i)}function By(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case Ii.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=ie.TOUCH_ROTATE;break;case Ii.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=ie.TOUCH_PAN;break;default:this.state=ie.NONE}break;case 2:switch(this.touches.TWO){case Ii.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=ie.TOUCH_DOLLY_PAN;break;case Ii.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=ie.TOUCH_DOLLY_ROTATE;break;default:this.state=ie.NONE}break;default:this.state=ie.NONE}this.state!==ie.NONE&&this.dispatchEvent(Zh)}function zy(i){switch(this._trackPointer(i),this.state){case ie.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case ie.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case ie.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case ie.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=ie.NONE}}function Gy(i){this.enabled!==!1&&i.preventDefault()}function Vy(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Hy(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Wy(i){return i<.5?4*i*i*i:1-Math.pow(-2*i+2,3)/2}var Xy=new Set(["w","a","s","d","q","e"]),Il=class{constructor(t,e,n){this.camera=t;this.dom=e;this.hooks=n;this.cruiseEnabled=!0;this.cruiseSpeed=1;this.tween=null;this.lastInputAt=0;this.cruiseAnchor=null;this.cruiseT=0;this.cruiseDir=1;this.pendingDensityDir=null;this.pressed=new Set;this.shiftHeld=!1;this.tmpOffset=new L;this.tmpSph=new un;this.tmpDir=new L;this.tmpRight=new L;this.disposeFns=[];this.controls=new Pl(t,e),this.controls.enableDamping=!0,this.controls.dampingFactor=.08,this.lastInputAt=performance.now(),e.tabIndex=0,this.bindPointer(),this.bindKeys()}get target(){return this.controls.target}markInput(){this.lastInputAt=performance.now(),this.cruiseAnchor=null,this.tween=null}bindPointer(){let t=n=>{this.dom.focus(),this.controls.mouseButtons.LEFT=n.metaKey||n.shiftKey||n.ctrlKey?Cn.PAN:Cn.ROTATE,this.markInput()},e=()=>this.markInput();this.dom.addEventListener("pointerdown",t,{capture:!0}),this.dom.addEventListener("wheel",e,{passive:!0}),this.dom.addEventListener("touchstart",e,{passive:!0}),this.disposeFns.push(()=>{this.dom.removeEventListener("pointerdown",t,{capture:!0}),this.dom.removeEventListener("wheel",e),this.dom.removeEventListener("touchstart",e)})}bindKeys(){let t=s=>{let r=s.key.toLowerCase();this.shiftHeld=s.shiftKey,Xy.has(r)?(this.pressed.add(r),this.markInput(),s.preventDefault(),s.stopPropagation()):r==="f"?(this.hooks.onFlyToSelected(),s.preventDefault()):r==="r"&&(this.hooks.onResetView(),s.preventDefault())},e=s=>{this.shiftHeld=s.shiftKey,this.pressed.delete(s.key.toLowerCase())},n=()=>this.pressed.clear();this.dom.addEventListener("keydown",t),this.dom.addEventListener("keyup",e),this.dom.addEventListener("blur",n),this.disposeFns.push(()=>{this.dom.removeEventListener("keydown",t),this.dom.removeEventListener("keyup",e),this.dom.removeEventListener("blur",n)})}applyFly(t){if(this.pressed.size===0)return!1;let e=this.camera.position.distanceTo(this.controls.target),n=Math.min(Math.max(e*.8,10),600)*(this.shiftHeld?3:1),s=this.camera.getWorldDirection(this.tmpDir);this.tmpRight.crossVectors(s,this.camera.up).normalize();let r=new L;return this.pressed.has("w")&&r.add(s),this.pressed.has("s")&&r.sub(s),this.pressed.has("d")&&r.add(this.tmpRight),this.pressed.has("a")&&r.sub(this.tmpRight),this.pressed.has("e")&&(r.y+=1),this.pressed.has("q")&&(r.y-=1),r.lengthSq()<1e-8?!1:(r.normalize().multiplyScalar(n*t),this.camera.position.add(r),this.controls.target.add(r),this.lastInputAt=performance.now(),!0)}setInitialFraming(t){this.camera.position.copy(this.framingPosition(t)),this.controls.target.set(0,0,0),this.controls.update()}framingPosition(t){let e=t*2.2,n=18*Math.PI/180;return new L(e*Math.cos(n),e*Math.sin(n),e*.35)}resetView(t,e){this.startTween(this.framingPosition(t),new L(0,0,0),1200,e)}beginFocusOrbit(t){this.pendingDensityDir=t,this.cruiseAnchor=null,this.lastInputAt=performance.now()-Fn.resumeDelayMs-1}flyTo(t,e,n){let s=Math.min(Math.max(e*Yn.distancePerRadius,Yn.minDistance),Yn.maxDistance),r=this.camera.position.clone().sub(t);r.lengthSq()<1e-6&&r.set(0,0,1),this.tmpSph.setFromVector3(r),this.tmpSph.theta+=Yn.azimuthOffsetRad,this.tmpSph.radius=s;let o=t.clone().add(new L().setFromSpherical(this.tmpSph)),a=this.camera.position.distanceTo(o),l=Math.min(Math.max(Yn.minMs+Yn.msPerWorldUnit*a,Yn.minMs),Yn.maxMs);this.startTween(o,t.clone(),l,n)}startTween(t,e,n,s){this.tween={t0:performance.now(),durMs:n,fromPos:this.camera.position.clone(),toPos:t,fromTarget:this.controls.target.clone(),toTarget:e},s&&(this.tween.onDone=s)}update(t,e){if(this.tween){let r=this.tween,o=Math.min((t-r.t0)/r.durMs,1),a=Wy(o);return this.camera.position.lerpVectors(r.fromPos,r.toPos,a),this.controls.target.lerpVectors(r.fromTarget,r.toTarget,a),this.controls.update(),o>=1&&(this.tween=null,r.onDone?.(),this.lastInputAt=t),!1}let n=this.applyFly(e),s=t-this.lastInputAt;if(!n&&this.cruiseEnabled&&s>Fn.resumeDelayMs){let r=Math.min((s-Fn.resumeDelayMs)/Fn.rampUpMs,1);if(!this.cruiseAnchor){if(this.cruiseAnchor=new un().setFromVector3(this.tmpOffset.copy(this.camera.position).sub(this.controls.target)),this.cruiseT=0,this.cruiseDir=1,this.pendingDensityDir&&this.pendingDensityDir.lengthSq()>1e-6){let d=new un().setFromVector3(this.pendingDensityDir).theta-this.cruiseAnchor.theta;for(;d>Math.PI;)d-=2*Math.PI;for(;d<-Math.PI;)d+=2*Math.PI;this.cruiseDir=d>=0?1:-1}this.pendingDensityDir=null}this.cruiseT+=e*r;let o=this.cruiseT,a=this.cruiseAnchor,l=Fn.elevationDeg*Math.PI/180*Math.sin(2*Math.PI*o/Fn.elevationPeriodS),c=1+Fn.radiusBreath*Math.sin(2*Math.PI*o/Fn.radiusPeriodS);return this.tmpSph.radius=a.radius*c,this.tmpSph.theta=a.theta+this.cruiseDir*Fn.angularSpeed*this.cruiseSpeed*o,this.tmpSph.phi=Math.min(Math.max(a.phi+l,.05),Math.PI-.05),this.camera.position.setFromSpherical(this.tmpSph).add(this.controls.target),this.camera.lookAt(this.controls.target),!0}return this.controls.update(),!1}dispose(){this.tween=null,this.pressed.clear();for(let t of this.disposeFns)t();this.disposeFns=[],this.controls.dispose()}};var Dp=[{id:"galaxy",name:"\u94F6\u6CB3",bloom:{strength:.35,radius:.35,threshold:.22},physics:{repel:200,linkDistance:70,linkStrength:1,centerPull:.04,flatten:.3},look:{nodeSize:1,linkOpacity:.14,twinkle:.5,sizeBy:"degree"}},{id:"nebula",name:"\u661F\u4E91",bloom:{strength:.6,radius:.4,threshold:.18},physics:{repel:180,linkDistance:80,linkStrength:1,centerPull:.04,flatten:0},look:{nodeSize:1,linkOpacity:.16,twinkle:.5,sizeBy:"degree"}},{id:"minimal",name:"\u6781\u7B80",bloom:{strength:0,radius:.3,threshold:.3},physics:{repel:220,linkDistance:80,linkStrength:1,centerPull:.04,flatten:0},look:{nodeSize:.85,linkOpacity:.08,twinkle:.2,sizeBy:"degree"}},{id:"fireworks",name:"\u70DF\u706B",bloom:{strength:1.2,radius:.6,threshold:.1},physics:{repel:160,linkDistance:60,linkStrength:1.2,centerPull:.05,flatten:0},look:{nodeSize:1.15,linkOpacity:.25,twinkle:1.2,sizeBy:"degree"}}];var Ll=[{id:"hubble",name:"\u54C8\u52C3\u6DF1\u7A7A",colors:["#46d4dc","#ffc35c","#d05a32","#7fd0a0","#e8d9a0","#5a9bd8","#d87fa8","#9a7fe0","#cfd8e8"]},{id:"tiktok",name:"\u6296\u97F3\u9713\u8679",colors:["#25f4ee","#fe2c55","#ffffff","#7ae8e2","#ff7a9c","#19b8b2","#c2244a","#a8f0ec","#ffd0dc"]},{id:"sunset",name:"\u843D\u65E5\u80F6\u7247",colors:["#f58529","#dd2a7b","#8134af","#515bd4","#feda77","#e1306c","#c13584","#fd8d32","#405de6"]},{id:"cyber",name:"\u8D5B\u535A\u90FD\u5E02",colors:["#fcee0a","#00f0ff","#ff003c","#9d00ff","#00ff9f","#ff6ec7","#3df5ff","#ffe600","#c800ff"]},{id:"matrix",name:"\u9ED1\u5BA2\u5E1D\u56FD",colors:["#00ff41","#33ff66","#00cc34","#66ff8c","#00b32d","#80ffa0","#1aff4d","#00e639","#4dff79"]},{id:"aurora",name:"\u6781\u5149",colors:["#1db954","#00d4ff","#7f5fff","#38f0c0","#4fa8ff","#9f7fff","#22e6a8","#66c2ff","#b08fff"]}];var Je=class{constructor(t,e){this.spec=e;let n=t.createDiv({cls:"gx-slider"}),s=n.createDiv({cls:"gx-slider-head"});s.createSpan({cls:"gx-slider-label",text:e.label}),this.valueEl=s.createSpan({cls:"gx-slider-value"}),this.trackEl=n.createDiv({cls:"gx-slider-track"}),this.trackEl.createDiv({cls:"gx-slider-rail"}),this.fillEl=this.trackEl.createDiv({cls:"gx-slider-fill"}),this.trackEl.createDiv({cls:"gx-slider-notch",attr:{title:`${e.defaultLabel??"Default"} ${this.fmt(e.defaultValue)}`}}),this.thumbEl=this.trackEl.createDiv({cls:"gx-slider-thumb"});let r=n.createDiv({cls:"gx-slider-bounds"});r.createSpan({text:this.fmt(e.min)}),r.createSpan({text:this.fmt(e.max)}),this.bindDrag(),this.trackEl.addEventListener("dblclick",()=>{e.set(e.defaultValue),this.refresh(),e.onInput()}),this.refresh()}fmt(t){return this.spec.fmt?this.spec.fmt(t):t.toFixed(2)}posToValue(t){let{min:e,max:n,defaultValue:s,step:r}=this.spec,o=t<=.5?e+(s-e)*(t/.5):s+(n-s)*((t-.5)/.5),a=Math.round(o/r)*r;return Math.min(Math.max(a,e),n)}valueToPos(t){let{min:e,max:n,defaultValue:s}=this.spec;return t<=s?s===e?0:.5*(t-e)/(s-e):n===s?1:.5+.5*(t-s)/(n-s)}bindDrag(){let t=e=>{let n=this.trackEl.getBoundingClientRect(),s=Math.min(Math.max((e.clientX-n.left)/n.width,0),1);this.spec.set(this.posToValue(s)),this.refresh(),this.spec.onInput()};this.trackEl.addEventListener("pointerdown",e=>{e.preventDefault(),this.trackEl.setPointerCapture(e.pointerId),t(e);let n=r=>t(r),s=r=>{this.trackEl.releasePointerCapture(r.pointerId),this.trackEl.removeEventListener("pointermove",n),this.trackEl.removeEventListener("pointerup",s)};this.trackEl.addEventListener("pointermove",n),this.trackEl.addEventListener("pointerup",s)})}refresh(){let t=this.spec.get(),e=this.valueToPos(t);this.thumbEl.style.left=`${(e*100).toFixed(2)}%`;let n=Math.min(e,.5),s=Math.abs(e-.5);this.fillEl.style.left=`${(n*100).toFixed(2)}%`,this.fillEl.style.width=`${(s*100).toFixed(2)}%`,this.valueEl.setText(this.fmt(t)),this.valueEl.toggleClass("is-default",Math.abs(t-this.spec.defaultValue)<this.spec.step/2)}};var Dl=class{constructor(t,e,n,s,r="map3d"){this.settings=e;this.language=n;this.cb=s;this.viewMode=r;this.page="view";this.sliders=[];this.cruiseBtn=null;this.presetBtn=null;this.unresolvedBtn=null;this.orphanBtn=null;this.sizeByBtn=null;this.qualityBtn=null;this.styleChips=[];this.root=t.createDiv({cls:"galaxy-panel gx-theme-dark mwm-map-panel"});let o=this.root.createDiv({cls:"galaxy-panel-header"});this.statsEl=o.createDiv({cls:"galaxy-panel-stats",text:"\u2026"});let a=o.createEl("button",{cls:"galaxy-panel-collapse",text:"-"});this.body=this.root.createDiv({cls:"galaxy-panel-body"}),a.addEventListener("click",()=>{let l=this.body.hasClass("is-hidden");this.body.toggleClass("is-hidden",!l),a.setText(l?"-":"+")}),this.render()}render(){this.body.empty(),this.sliders=[],this.styleChips=[],this.cruiseBtn=null,this.presetBtn=null,this.unresolvedBtn=null,this.orphanBtn=null,this.sizeByBtn=null,this.qualityBtn=null;let t=this.body.createDiv({cls:"mwm-mode-switch"});t.createDiv({cls:"mwm-mode-switch-label",text:this.tt("view.mode")});let e=t.createDiv({cls:"galaxy-mode-row mwm-mode-row"});this.modeButton(e,"radial2d"),this.modeButton(e,"map3d");let n=this.body.createDiv({cls:"mwm-panel-settings mwm-3d-settings"}),s=n.createDiv({cls:"mwm-panel-tabs"});for(let[o,a]of[["view",this.tt("tab.view")],["appearance",this.tt("tab.appearance")],["physics",this.tt("tab.physics")],["motion",this.tt("tab.motion")],["advanced",this.tt("tab.advanced")]])s.createEl("button",{cls:this.page===o?"is-active":"",text:a}).addEventListener("click",()=>{this.page=o,this.render()});let r=n.createDiv({cls:"mwm-panel-page"});this.page==="appearance"?this.renderAppearancePage(r):this.page==="physics"?this.renderPhysicsPage(r):this.page==="motion"?this.renderMotionPage(r):this.page==="advanced"?this.renderAdvancedPage(r):this.renderViewPage(r)}renderViewPage(t){let e=t.createDiv({cls:"galaxy-panel-row"});e.createEl("button",{text:this.tt("common.search")}).addEventListener("click",this.cb.onSearch),e.createEl("button",{text:this.tt("common.recenter")}).addEventListener("click",this.cb.onRecenter),e.createEl("button",{text:this.tt("3d.reveal")}).addEventListener("click",this.cb.onReveal)}renderAppearancePage(t){let e=this.settings,n=xn,s=t.createDiv({cls:"galaxy-panel-row"});this.presetBtn=s.createEl("button",{text:this.presetLabel()}),this.presetBtn.addEventListener("click",()=>{e.preset=e.preset==="deep-space"?"adaptive":"deep-space",this.presetBtn?.setText(this.presetLabel()),this.cb.onPreset()});let r=t.createDiv({cls:"gx-chips"});for(let h of Dp){let f=r.createEl("button",{cls:"gx-chip",text:this.tt(`style.${h.id}`)});f.addEventListener("click",()=>{this.cb.onStylePreset(h),this.refreshAll(),this.markActiveChip(h.id)}),f.dataset.presetId=h.id,this.styleChips.push(f)}this.sliders.push(new Je(t,this.slider("3d.nodeSize",.3,2.5,.05,n.look.nodeSize,()=>e.look.nodeSize,h=>e.look.nodeSize=h,$h("x"),this.cb.onLook)),new Je(t,this.slider("3d.linkOpacity",0,.6,.01,n.look.linkOpacity,()=>e.look.linkOpacity,h=>e.look.linkOpacity=h,void 0,this.cb.onLook)),new Je(t,this.slider("3d.twinkle",0,2,.1,n.look.twinkle,()=>e.look.twinkle,h=>e.look.twinkle=h,h=>h<.05?this.tt("3d.twinkleOff"):h.toFixed(1),this.cb.onLook)),new Je(t,this.slider("3d.glowStrength",0,2.5,.05,n.bloom.strength,()=>e.bloom.strength,h=>e.bloom.strength=h,void 0,this.cb.onBloom)),new Je(t,this.slider("3d.glowRadius",0,1.2,.05,n.bloom.radius,()=>e.bloom.radius,h=>e.bloom.radius=h,void 0,this.cb.onBloom)),new Je(t,this.slider("3d.glowThreshold",0,1,.05,n.bloom.threshold,()=>e.bloom.threshold,h=>e.bloom.threshold=h,void 0,this.cb.onBloom)));let o=t.createDiv({cls:"galaxy-panel-row"});this.sizeByBtn=o.createEl("button",{text:this.sizeByLabel()}),this.sizeByBtn.addEventListener("click",()=>{let h=["degree","fileSize","uniform"];e.look.sizeBy=h[(h.indexOf(e.look.sizeBy)+1)%h.length]??"degree",this.sizeByBtn?.setText(this.sizeByLabel()),this.cb.onSizeBy()});let a=t.createEl("select",{cls:"gx-theme-select"}),l=a.createEl("option",{text:this.tt("3d.colorTheme"),value:""});l.disabled=!0;for(let h of Ll)a.createEl("option",{text:this.tt(`color.${h.id}`),value:h.id});a.value=Ll.some(h=>h.id===e.colorTheme)?e.colorTheme:"",a.value||(l.selected=!0),a.addEventListener("change",()=>{let h=Ll.find(f=>f.id===a.value);h&&this.cb.onColorTheme(h)});let c=t.createDiv({cls:"galaxy-panel-row"});c.createEl("button",{text:this.tt("3d.importColors")}).addEventListener("click",()=>{this.cb.onImportColors(),l.selected=!0}),c.createEl("button",{text:this.tt("3d.shuffleColors")}).addEventListener("click",()=>{this.cb.onShuffleColors(),l.selected=!0})}renderPhysicsPage(t){let e=this.settings,n=xn;this.sliders.push(new Je(t,this.slider("3d.repel",20,400,5,n.physics.repel,()=>e.physics.repel,s=>e.physics.repel=s,s=>String(Math.round(s)),this.cb.onPhysics)),new Je(t,this.slider("3d.linkDistance",20,200,5,n.physics.linkDistance,()=>e.physics.linkDistance,s=>e.physics.linkDistance=s,s=>String(Math.round(s)),this.cb.onPhysics)),new Je(t,this.slider("3d.linkStrength",.1,2,.1,n.physics.linkStrength,()=>e.physics.linkStrength,s=>e.physics.linkStrength=s,$h("x1"),this.cb.onPhysics)),new Je(t,this.slider("3d.centerPull",0,.2,.005,n.physics.centerPull,()=>e.physics.centerPull,s=>e.physics.centerPull=s,s=>s.toFixed(3),this.cb.onPhysics)),new Je(t,this.slider("3d.flatten",0,.8,.02,n.physics.flatten,()=>e.physics.flatten,s=>e.physics.flatten=s,void 0,this.cb.onPhysics)))}renderMotionPage(t){let e=this.settings,n=xn,s=t.createDiv({cls:"galaxy-panel-row"});this.cruiseBtn=s.createEl("button",{text:this.cruiseLabel()}),this.cruiseBtn.addEventListener("click",()=>{e.cruise=!e.cruise,this.cruiseBtn?.setText(this.cruiseLabel()),this.cb.onCruise(e.cruise)}),this.sliders.push(new Je(t,this.slider("3d.speed",.2,3,.1,n.cruiseSpeed,()=>e.cruiseSpeed,o=>e.cruiseSpeed=o,$h("x1"),this.cb.onCruiseSpeed)));let r=t.createDiv({cls:"galaxy-panel-help"});for(let o of["3d.help.drag","3d.help.pan","3d.help.mac","3d.help.fly","3d.help.pick","3d.help.keys","3d.help.slider"])r.createDiv({text:this.tt(o)})}renderAdvancedPage(t){let e=this.settings,n=t.createDiv({cls:"galaxy-panel-row"});this.unresolvedBtn=n.createEl("button",{text:this.unresolvedLabel()}),this.unresolvedBtn.addEventListener("click",()=>{e.showUnresolved=!e.showUnresolved,this.unresolvedBtn?.setText(this.unresolvedLabel()),this.cb.onShowUnresolved(e.showUnresolved)}),this.orphanBtn=n.createEl("button",{text:this.orphanLabel()}),this.orphanBtn.addEventListener("click",()=>{e.showOrphans=!e.showOrphans,this.orphanBtn?.setText(this.orphanLabel()),this.cb.onShowOrphans(e.showOrphans)});let s=t.createDiv({cls:"galaxy-panel-row"});this.qualityBtn=s.createEl("button",{text:this.qualityLabel()}),this.qualityBtn.addEventListener("click",()=>{let o=["auto","high","low","mobile"];e.qualityOverride=o[(o.indexOf(e.qualityOverride)+1)%o.length]??"auto",this.qualityBtn?.setText(this.qualityLabel()),this.cb.onQuality()}),s.createEl("button",{text:this.tt("common.resetDefaults")}).addEventListener("click",()=>{this.cb.onReset(),this.refreshAll()})}modeButton(t,e){t.createEl("button",{cls:this.viewMode===e?"is-active":"",text:pi(this.language,e)}).addEventListener("click",()=>this.cb.onViewMode?.(e))}slider(t,e,n,s,r,o,a,l,c){return{label:this.tt(t),min:e,max:n,step:s,defaultValue:r,get:o,set:a,fmt:l,onInput:c,defaultLabel:this.tt("common.default")}}presetLabel(){return`${this.tt("view.theme")}: ${this.settings.preset==="deep-space"?this.tt("theme.deep"):this.tt("theme.auto")}`}cruiseLabel(){return this.settings.cruise?this.tt("3d.cruiseOn"):this.tt("3d.cruiseOff")}unresolvedLabel(){return this.settings.showUnresolved?this.tt("3d.unresolvedShow"):this.tt("3d.unresolvedHide")}orphanLabel(){return this.settings.showOrphans?this.tt("3d.orphansShow"):this.tt("3d.orphansHide")}sizeByLabel(){return this.tt(`3d.size.${this.settings.look.sizeBy}`)}qualityLabel(){return this.tt(`3d.quality.${this.settings.qualityOverride}`)}markActiveChip(t){for(let e of this.styleChips)e.toggleClass("is-active",e.dataset.presetId===t)}refreshAll(){for(let t of this.sliders)t.refresh();this.cruiseBtn?.setText(this.cruiseLabel()),this.presetBtn?.setText(this.presetLabel()),this.unresolvedBtn?.setText(this.unresolvedLabel()),this.orphanBtn?.setText(this.orphanLabel()),this.sizeByBtn?.setText(this.sizeByLabel()),this.qualityBtn?.setText(this.qualityLabel())}setLanguage(t){this.language=t,this.render()}setPanelTheme(t){this.root.removeClass("gx-theme-dark"),this.root.removeClass("gx-theme-light"),this.root.addClass(t)}dispose(){this.root.remove(),this.sliders=[],this.styleChips=[]}tt(t,e={}){return Rt(this.language,t,e)}};function $h(i){return t=>i==="x1"?`${t.toFixed(1)}x`:`${t.toFixed(2)}x`}var Fl=require("obsidian");var Nl=class{constructor(t,e,n,s,r="en"){this.app=e;this.renderer=n;this.cb=s;this.language=r;this.hubEls=[];this.neighborEls=[];this.hoverIndex=-1;this.cardIndex=-1;this.data={nodes:[],links:[]};this.graphRadius=200;this.snippetToken=0;this.hubBudget=14;this.neighborBudget=20;this.mobileCard=!1;this.root=t.createDiv({cls:"gx-overlay"}),this.hoverEl=this.root.createDiv({cls:"gx-label gx-label-hover"}),this.hoverEl.hide(),this.card=this.root.createDiv({cls:"gx-card"}),this.card.hide()}setLanguage(t){if(this.language=t,this.cardIndex>=0){let e=this.data.nodes[this.cardIndex];e&&this.buildCard(e,this.cardIndex)}}setBudgets(t,e,n){this.hubBudget=t,this.neighborBudget=e,this.mobileCard=n,this.setData(this.data,this.graphRadius)}setData(t,e){this.data=t,this.graphRadius=e;for(let n of this.hubEls)n.el.remove();this.hubEls=[...t.nodes.entries()].filter(([,n])=>!n.unresolved).sort((n,s)=>s[1].degree-n[1].degree).slice(0,this.hubBudget).map(([n,s])=>({index:n,el:this.root.createDiv({cls:"gx-label gx-label-hub",text:s.name})})),this.setHover(-1),this.setSelection(-1,new Set)}setHover(t){if(this.hoverIndex=t,t<0){this.hoverEl.hide();return}let e=this.data.nodes[t];e&&(this.hoverEl.setText(e.name),this.hoverEl.show())}refreshBottomInset(){let t=0,e=activeDocument.querySelector(".mobile-navbar");if(e){let n=e.getBoundingClientRect(),s=this.root.getBoundingClientRect();t=Math.max(0,Math.round(s.bottom-n.top))}this.root.setCssProps({"--gx-bottom-inset":`${t}px`})}setSelection(t,e){for(let r of this.neighborEls)r.el.remove();if(this.neighborEls=[],this.cardIndex=t,t<0){this.card.hide();return}let n=[...e].filter(r=>r!==t).sort((r,o)=>(this.data.nodes[o]?.degree??0)-(this.data.nodes[r]?.degree??0)).slice(0,this.neighborBudget);this.neighborEls=n.map(r=>({index:r,el:this.root.createDiv({cls:"gx-label gx-label-neighbor",text:this.data.nodes[r]?.name??""})}));let s=this.data.nodes[t];s&&(this.mobileCard&&(this.refreshBottomInset(),this.card.style.removeProperty("transform")),this.buildCard(s,t))}buildCard(t,e){this.card.empty(),this.card.show(),this.card.createDiv({cls:"gx-card-title",text:t.name});let n=this.card.createDiv({cls:"gx-card-meta"}),s=n.createSpan({cls:"gx-card-dot"});s.style.background=this.renderer.nodeColorHex(e),n.createSpan({text:t.unresolved?this.tt("3d.card.unresolved"):t.id.includes("/")?t.id.slice(0,t.id.lastIndexOf("/")):this.tt("3d.card.root")});let r=t.unresolved?null:this.app.vault.getAbstractFileByPath(t.id),o=r instanceof Fl.TFile?r:null;if(o){let u=this.app.metadataCache.getFileCache(o),d=u?(0,Fl.getAllTags)(u)??[]:[];if(d.length>0){let h=this.card.createDiv({cls:"gx-card-tags"});for(let f of d.slice(0,5))h.createSpan({cls:"gx-card-tag",text:f})}}if(this.card.createDiv({cls:"gx-card-stats"}).setText(this.tt("3d.card.stats",{in:t.inDegree,out:t.outDegree})+(o?this.tt("3d.card.modified",{date:new Date(o.stat.mtime).toLocaleDateString(this.language==="zh"?"zh-CN":"en-US")}):"")),o){let u=this.card.createDiv({cls:"gx-card-snippet",text:"\u2026"}),d=++this.snippetToken;this.app.vault.cachedRead(o).then(h=>{d===this.snippetToken&&u.setText(qy(h).slice(0,120)||this.tt("3d.card.empty"))})}let l=this.card.createDiv({cls:"gx-card-actions"});t.unresolved||l.createEl("button",{text:this.tt("context.openNote")}).addEventListener("click",()=>this.cb.openNote(t.id)),l.createEl("button",{text:this.tt("common.focus")}).addEventListener("click",()=>this.cb.focusNode(e))}update(t,e){let n=this.graphRadius*2.6,s=this.graphRadius*1.2;for(let{index:r,el:o}of this.hubEls){let a=this.renderer.projectNode(r,t,e);if(a.behind||a.x<0||a.x>t||a.y<0||a.y>e){o.setCssProps({opacity:"0"});continue}let l=this.renderer.cameraDistanceTo(r),c=Math.min(Math.max((n-l)/(n-s),0),1);o.style.opacity=c.toFixed(2),o.style.transform=`translate3d(${a.x.toFixed(1)}px, ${(a.y-14).toFixed(1)}px, 0)`}for(let{index:r,el:o}of this.neighborEls){let a=this.renderer.projectNode(r,t,e);o.style.opacity=a.behind?"0":"0.85",a.behind||(o.style.transform=`translate3d(${a.x.toFixed(1)}px, ${(a.y-12).toFixed(1)}px, 0)`)}if(this.hoverIndex>=0){let r=this.renderer.projectNode(this.hoverIndex,t,e);r.behind||(this.hoverEl.style.transform=`translate3d(${r.x.toFixed(1)}px, ${(r.y-18).toFixed(1)}px, 0)`)}if(this.cardIndex>=0&&!this.mobileCard){let r=this.renderer.projectNode(this.cardIndex,t,e);if(!r.behind){let a=r.x+296>t?r.x-296:r.x+16,l=Math.min(Math.max(r.y-40,12),Math.max(e-this.card.clientHeight-12,12));this.card.style.transform=`translate3d(${a.toFixed(1)}px, ${l.toFixed(1)}px, 0)`}}}dispose(){this.root.remove(),this.hubEls=[],this.neighborEls=[]}tt(t,e={}){return Rt(this.language,t,e)}};function qy(i){return i.replace(/^---\n[\s\S]*?\n---\n?/,"").replace(/!?\[\[([^\]|]+)(\|[^\]]+)?\]\]/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/[#*`>~_]|---/g,"").replace(/\s+/g," ").trim()}var Ol=require("obsidian");var kl=class extends Ol.SuggestModal{constructor(e,n,s,r="en"){super(e);this.nodes=n;this.onPick=s;this.language=r;this.setPlaceholder(this.tt("3d.searchPlaceholder"))}getSuggestions(e){let n=e.trim();if(!n)return[...this.nodes.entries()].filter(([,o])=>!o.unresolved).sort((o,a)=>a[1].degree-o[1].degree).slice(0,20).map(([o,a])=>({index:o,node:a,score:0}));let s=(0,Ol.prepareFuzzySearch)(n),r=[];for(let o=0;o<this.nodes.length;o++){let a=this.nodes[o];if(!a)continue;let l=s(a.name)??s(a.id);l&&r.push({index:o,node:a,score:l.score})}return r.sort((o,a)=>a.score-o.score||a.node.degree-o.node.degree).slice(0,50)}renderSuggestion(e,n){n.createDiv({text:e.node.name}),n.createDiv({cls:"gx-search-path",text:`${e.node.unresolved?this.tt("3d.searchUnresolved"):e.node.id} \xB7 ${this.tt("3d.searchLinks",{count:e.node.degree})}`})}onChooseSuggestion(e){this.onPick(e.index)}tt(e,n={}){return Rt(this.language,e,n)}};var Kh=require("obsidian"),Np="_galaxy_bench";function Fp(i,t){return new Promise(e=>{let n=[],s=performance.now(),r=s,o=a=>{n.push(a-s),s=a;let l=a-r;if(t?.(l),l<i)window.requestAnimationFrame(o);else{n.shift();let c=[...n].sort((h,f)=>h-f),u=n.reduce((h,f)=>h+f,0),d=c[Math.min(Math.floor(c.length*.95),c.length-1)]??0;e({frames:n.length,avgFps:n.length>0?1e3/(u/n.length):0,p95FrameMs:d,worstFrameMs:c[c.length-1]??0,durationMs:u})}};window.requestAnimationFrame(o)})}function kp(){let i=0,t=0,e=0,n=null;try{n=new PerformanceObserver(s=>{for(let r of s.getEntries())i++,e+=r.duration,r.duration>t&&(t=r.duration)}),n.observe({entryTypes:["longtask"]})}catch{}return{stop:()=>(n?.disconnect(),{count:i,longestMs:t,totalMs:e})}}async function Jh(i,t){let e=i.vault.adapter,n=(0,Kh.normalizePath)(Np);await e.exists(n)||await e.mkdir(n);let s=(0,Kh.normalizePath)(`${Np}/${t.scenario}-${Date.now()}.json`);return await e.write(s,JSON.stringify(t,null,2)),s}function jh(i){return new Promise(t=>window.setTimeout(t,i))}var Bs={high:{id:"high",pixelRatioCap:2,bloomAllowed:!0,starScale:1,nodeCap:null,linkCap:null,hubLabels:14,neighborLabels:20,hoverThrottleMs:30},low:{id:"low",pixelRatioCap:1,bloomAllowed:!0,starScale:.4,nodeCap:null,linkCap:null,hubLabels:8,neighborLabels:12,hoverThrottleMs:80},mobile:{id:"mobile",pixelRatioCap:1.5,bloomAllowed:!1,starScale:.32,nodeCap:1500,linkCap:12e3,hubLabels:6,neighborLabels:8,hoverThrottleMs:null}};var Yy=.8,Zy=3200,Ul=class{constructor(t,e,n,s,r=null,o="en",a=null){this.app=t;this.contentEl=e;this.settings=n;this.onViewMode=r;this.language=o;this.onLanguage=a;this.layout=new xl;this.renderer=null;this.director=null;this.overlay=null;this.panel=null;this.rafId=0;this.lastNow=0;this.paused=!1;this.visible=!0;this.benchMode=!1;this.benchRunning=!1;this.selected=-1;this.graphRadius=200;this.wasSettled=!1;this.shot=null;this.maskEl=null;this.hudFrames=[];this.intersection=null;this.disposeFns=[];this.tier=Bs.high;this.watchdogTripped=!1;this.lowFpsChecks=0;this.lastWatchdogAt=0;this.onContextLost=null;this.store=new cl(t),this.saveSoon=(0,_e.debounce)(s,800,!0)}get counts(){return{nodes:this.store.data.nodes.length,links:this.store.data.links.length}}async start(){await this.store.ensureCacheReady(),this.store.init(this.settings.showUnresolved,this.settings.showOrphans,()=>this.onDataChanged()),this.store.rebuild(!1);let e=this.applyPositionCache()>=Yy,n=this.contentEl.createDiv({cls:"galaxy-view-canvas"});this.graphRadius=ll(this.store.data.nodes.length)*1.6;let s=new Cl(n,this.graphRadius);this.renderer=s,s.setColorFn(this.settings.colorGroups.length>0?qr(this.settings.colorGroups):El),s.setData(this.store.data,this.store.positions),this.initLayout(e?.06:1),this.director=new Il(s.camera,s.renderer.domElement,{onFlyToSelected:()=>this.flyToSelected(),onResetView:()=>this.recenter()}),this.overlay=new Nl(this.contentEl,this.app,s,{openNote:o=>void this.app.workspace.openLinkText(o,"",!0),focusNode:o=>this.selectNode(o,!0)},this.language),this.overlay.setData(this.store.data,this.graphRadius),this.applySettings(),this.applyTier(),this.buildPanel(),this.buildFloatingControls(),this.applyPreset(),this.bindPicking(s.renderer.domElement),this.bindContextLost(s.renderer.domElement),this.bindVisibility(),this.resize(),this.settings.colorGroups.length===0&&this.importColors(!1),e?this.playEstablishing():this.director.setInitialFraming(this.graphRadius),this.lastNow=performance.now();let r=o=>{let a=Math.min((o-this.lastNow)/1e3,.1);if(this.lastNow=o,!this.paused){this.layout.step()&&this.renderer?.updatePositions(),this.checkSettled(),this.benchMode||this.director?.update(o,a),this.stepShot(o),this.renderer?.render(a);let{clientWidth:l,clientHeight:c}=this.contentEl;this.overlay?.update(l,c)}this.updateHud(o),this.watchdog(o),this.rafId=window.requestAnimationFrame(r)};this.rafId=window.requestAnimationFrame(r)}bindContextLost(t){let e=n=>{n.preventDefault(),this.contentEl.createDiv({cls:"gx-mask"}).createEl("button",{cls:"gx-mask-btn",text:this.tt("3d.contextLost")}).addEventListener("click",()=>this.onContextLost?.())};t.addEventListener("webglcontextlost",e),this.disposeFns.push(()=>t.removeEventListener("webglcontextlost",e))}resize(){let{clientWidth:t,clientHeight:e}=this.contentEl;this.renderer?.resize(t,e)}applyPositionCache(){let t=this.settings.positionCache,e=this.store.data.nodes;if(e.length===0)return 0;let n=0;return e.forEach((s,r)=>{let o=t[s.id];o&&(this.store.positions[r*3]=o[0],this.store.positions[r*3+1]=o[1],this.store.positions[r*3+2]=o[2],n++)}),n/e.length}checkSettled(){let t=this.layout.isSettled();if(t&&!this.wasSettled){let e={},n=this.store.positions;this.store.data.nodes.forEach((s,r)=>{e[s.id]=[Math.round((n[r*3]??0)*10)/10,Math.round((n[r*3+1]??0)*10)/10,Math.round((n[r*3+2]??0)*10)/10]}),this.settings.positionCache=e,this.saveSoon()}this.wasSettled=t}playEstablishing(){let t=this.renderer,e=this.director;!t||!e||(this.maskEl=this.contentEl.createDiv({cls:"gx-mask"}),this.maskEl.createDiv({cls:"gx-mask-text",text:this.tt("loading.3d")}),window.setTimeout(()=>{if(!this.maskEl)return;this.maskEl.addClass("is-fading"),window.setTimeout(()=>{this.maskEl?.remove(),this.maskEl=null},650);let n=this.graphRadius*.5,s=10*Math.PI/180;t.camera.position.set(n*Math.cos(s),n*Math.sin(s),n*.2),e.target.set(0,0,0),e.resetView(this.graphRadius,()=>e.beginFocusOrbit(null)),t.playReveal(2600),this.shot={t0:performance.now(),durMs:Zy,fromBloom:this.settings.bloom.strength*1.8}},450))}stepShot(t){if(!this.shot||!this.renderer)return;let e=Math.min((t-this.shot.t0)/this.shot.durMs,1),n=this.shot.fromBloom+(this.settings.bloom.strength-this.shot.fromBloom)*e;this.renderer.setBloomStrength(n),e>=1&&(this.shot=null)}onDataChanged(){this.renderer&&(this.clearSelection(),this.renderer.setData(this.store.data,this.store.positions),this.overlay?.setData(this.store.data,this.graphRadius),this.initLayout(.3),this.wasSettled=!1)}initLayout(t){let e=Ws(this.settings.physics);try{this.layout.init(this.store.data,this.store.positions,e,t)}catch{if(this.layout instanceof Hr)throw new Error("layout init failed");this.layout.dispose(),this.layout=new Hr,this.layout.init(this.store.data,this.store.positions,e,t),new _e.Notice(this.tt("3d.workerFallback"))}}pickTier(){if(_e.Platform.isMobile)return Bs.mobile;let t=this.settings.qualityOverride;return t==="high"||t==="low"||t==="mobile"?Bs[t]:this.watchdogTripped?Bs.low:Bs.high}applyTier(){let t=this.tier.id;this.tier=this.pickTier(),this.renderer?.applyTier(this.tier,this.settings.bloom.strength),this.overlay?.setBudgets(this.tier.hubLabels,this.tier.neighborLabels,this.tier.id==="mobile"),this.contentEl.toggleClass("gx-mobile",this.tier.id==="mobile");let e=this.app.vault.getMarkdownFiles().length;this.store.setCaps(this.tier.nodeCap,this.tier.linkCap),this.tier.nodeCap!==null&&e>this.tier.nodeCap&&t!==this.tier.id&&new _e.Notice(this.tt("3d.mobileCap",{cap:this.tier.nodeCap,total:e}))}watchdog(t){this.watchdogTripped||_e.Platform.isMobile||this.settings.qualityOverride!=="auto"||!this.layout.isSettled()||this.benchRunning||t-this.lastWatchdogAt<5e3||(this.lastWatchdogAt=t,this.hudFrames.length>0&&this.hudFrames.length<30&&!this.paused?(this.lowFpsChecks++,this.lowFpsChecks>=3&&(this.watchdogTripped=!0,this.applyTier(),new _e.Notice(this.tt("3d.performanceMode")))):this.lowFpsChecks=0)}applySettings(){let t=this.settings;this.renderer?.setBloomParams(t.bloom),this.renderer?.setNodeScale(t.look.nodeSize),this.renderer?.setLinkOpacity(t.look.linkOpacity),this.renderer?.setSizeMode(t.look.sizeBy),this.renderer&&(this.renderer.twinkleFreq=t.look.twinkle),this.director&&(this.director.cruiseEnabled=t.cruise,this.director.cruiseSpeed=t.cruiseSpeed)}applyStylePreset(t){Object.assign(this.settings.bloom,t.bloom),Object.assign(this.settings.physics,t.physics),Object.assign(this.settings.look,t.look),this.applySettings(),this.layout.updateParams(Ws(this.settings.physics)),this.wasSettled=!1,this.saveSoon()}recenter(){this.clearSelection(),this.director?.resetView(this.graphRadius,()=>this.director?.beginFocusOrbit(null))}applyColorTheme(t){let e=this.settings.colorGroups;if(e.length===0){let n=new Map;for(let s of this.store.data.nodes)s.folderTop&&!s.unresolved&&n.set(s.folderTop,(n.get(s.folderTop)??0)+1);e=[...n.entries()].sort((s,r)=>r[1]-s[1]).slice(0,9).map(([s])=>({query:`path:${s}`,color:"#9aa4b2"})),this.settings.colorGroups=e}e.forEach((n,s)=>n.color=t.colors[s%t.colors.length]??n.color),this.settings.colorTheme=t.id,this.renderer?.setColorFn(qr(e)),this.renderer?.recolor(),this.saveSoon()}playRevealManually(){if(!this.layout.isSettled()){new _e.Notice(this.tt("3d.revealWait"));return}this.renderer?.playReveal()}shuffleColors(){let t=this.settings.colorGroups;if(t.length<2){new _e.Notice(this.tt("3d.shuffleMissing"));return}let e=t.map(n=>n.color);for(let n=e.length-1;n>0;n--){let s=Math.floor(Math.random()*(n+1));[e[n],e[s]]=[e[s],e[n]]}t.forEach((n,s)=>n.color=e[s]??n.color),this.settings.colorTheme="custom",this.renderer?.setColorFn(qr(t)),this.renderer?.recolor(),this.saveSoon()}applyPreset(){if(!this.renderer)return;let t=activeDocument.body.hasClass("theme-dark"),e=this.settings.preset==="deep-space"||t?Al:Rp;this.renderer.applyTokens(e,this.settings.bloom.strength),this.panel?.setPanelTheme(e.id==="daylight"?"gx-theme-light":"gx-theme-dark"),this.contentEl.toggleClass("gx-daylight",e.id==="daylight")}onCssChange(){this.settings.preset==="adaptive"&&this.applyPreset()}async importColors(t){let e=await af(this.app);if(!e||e.length===0){t&&new _e.Notice(this.tt("3d.importMissing"));return}this.settings.colorGroups=e,this.renderer?.setColorFn(qr(e)),this.renderer?.recolor(),this.saveSoon(),t&&new _e.Notice(this.tt("3d.importDone",{count:e.length}))}openSearch(){new kl(this.app,this.store.data.nodes,t=>this.selectNode(t,!0),this.language).open()}selectNode(t,e){let n=this.renderer,s=this.director;if(!n||!s)return;this.selected=t;let r=new Set,o=[];if(this.store.data.links.forEach((a,l)=>{(a.source===t||a.target===t)&&(r.add(a.source),r.add(a.target),o.push(l))}),n.setFocus(t,r),n.setSelectedLinks(o),this.overlay?.setSelection(t,r),e){let a=n.nodePosition(t,new L),l=new L,c=0,u=new L;for(let h of r)h!==t&&(l.add(n.nodePosition(h,u)),c++);let d=c>0?l.divideScalar(c).sub(a):null;s.flyTo(a,n.nodeRadius(t),()=>s.beginFocusOrbit(d))}}clearSelection(){this.selected=-1,this.renderer?.setFocus(-1,null),this.renderer?.setSelectedLinks([]),this.overlay?.setSelection(-1,new Set)}flyToSelected(){if(this.selected<0||!this.renderer||!this.director)return;let t=this.renderer.nodePosition(this.selected,new L);this.director.flyTo(t,this.renderer.nodeRadius(this.selected))}bindPicking(t){let e=0,n=0,s=c=>{e=c.clientX,n=c.clientY},r=c=>{if(c.button!==0||c.ctrlKey||c.metaKey||Math.hypot(c.clientX-e,c.clientY-n)>5)return;let u=t.getBoundingClientRect(),d=this.renderer?.pickNearest(c.clientX-u.left,c.clientY-u.top,u.width,u.height,14)??-1;d>=0?this.selectNode(d,!0):this.clearSelection()},o=!1,a=c=>{let u=this.tier.hoverThrottleMs;u===null||o||(o=!0,window.setTimeout(()=>{o=!1;let d=this.renderer;if(!d)return;let h=t.getBoundingClientRect(),f=d.pickNearest(c.clientX-h.left,c.clientY-h.top,h.width,h.height,10);this.overlay?.setHover(f),t.style.cursor=f>=0?"pointer":"default"},u))},l=c=>{c.key==="Escape"&&(this.clearSelection(),c.preventDefault())};t.addEventListener("pointerdown",s),t.addEventListener("pointerup",r),t.addEventListener("pointermove",a),t.addEventListener("keydown",l),this.disposeFns.push(()=>{t.removeEventListener("pointerdown",s),t.removeEventListener("pointerup",r),t.removeEventListener("pointermove",a),t.removeEventListener("keydown",l)})}bindVisibility(){let t=()=>{this.paused=activeDocument.hidden||!this.visible};activeDocument.addEventListener("visibilitychange",t),this.disposeFns.push(()=>activeDocument.removeEventListener("visibilitychange",t)),this.intersection=new IntersectionObserver(e=>{this.visible=e[0]?.isIntersecting??!0,t()}),this.intersection.observe(this.contentEl)}buildPanel(){this.panel=new Dl(this.contentEl,this.settings,this.language,{onViewMode:t=>this.onViewMode?.(t),onBloom:()=>{this.renderer?.setBloomParams(this.settings.bloom),this.saveSoon()},onPhysics:()=>{this.layout.updateParams(Ws(this.settings.physics)),this.wasSettled=!1,this.saveSoon()},onLook:()=>{this.renderer?.setNodeScale(this.settings.look.nodeSize),this.renderer?.setLinkOpacity(this.settings.look.linkOpacity),this.renderer&&(this.renderer.twinkleFreq=this.settings.look.twinkle),this.saveSoon()},onSizeBy:()=>{this.renderer?.setSizeMode(this.settings.look.sizeBy),this.saveSoon()},onCruise:t=>{this.director&&(this.director.cruiseEnabled=t),this.saveSoon()},onPreset:()=>{this.applyPreset(),this.saveSoon()},onShowUnresolved:t=>{this.store.setIncludeUnresolved(t),this.saveSoon()},onImportColors:()=>void this.importColors(!0),onShuffleColors:()=>this.shuffleColors(),onColorTheme:t=>this.applyColorTheme(t),onRecenter:()=>this.recenter(),onReveal:()=>this.playRevealManually(),onShowOrphans:t=>{this.store.setIncludeOrphans(t),this.saveSoon()},onStylePreset:t=>this.applyStylePreset(t),onCruiseSpeed:()=>{this.director&&(this.director.cruiseSpeed=this.settings.cruiseSpeed),this.saveSoon()},onQuality:()=>{this.watchdogTripped=!1,this.lowFpsChecks=0,this.applyTier(),this.saveSoon()},onSearch:()=>this.openSearch(),onReset:()=>{Object.assign(this.settings.bloom,xn.bloom),Object.assign(this.settings.physics,xn.physics),Object.assign(this.settings.look,xn.look),this.settings.cruise=xn.cruise,this.settings.cruiseSpeed=xn.cruiseSpeed,this.applySettings(),this.layout.updateParams(Ws(this.settings.physics)),this.wasSettled=!1,this.saveSoon()},runScenario:t=>void this.runScenario(t)},"map3d")}buildFloatingControls(){let t=this.contentEl.createDiv({cls:"mwm-floating-controls mwm-3d-floating-controls"}),e=t.createEl("button",{cls:"mwm-floating-button",attr:{type:"button",title:this.tt("language"),"aria-label":this.tt("language")}});(0,_e.setIcon)(e,"languages"),e.addEventListener("click",n=>{n.preventDefault(),n.stopPropagation(),this.openLanguageMenu(e)}),this.disposeFns.push(()=>t.remove())}openLanguageMenu(t){let e=new _e.Menu;for(let[s,r]of as(this.language))e.addItem(o=>{o.setTitle(r),s===this.language&&o.setIcon("check"),o.onClick(()=>{s!==this.language&&(this.language=s,this.overlay?.setLanguage(s),this.panel?.setLanguage(s),this.onLanguage?.(s))})});let n=t.getBoundingClientRect();e.showAtPosition({x:n.right,y:n.bottom})}updateHud(t){for(this.hudFrames.push(t);this.hudFrames.length>0&&t-(this.hudFrames[0]??0)>1e3;)this.hudFrames.shift();let e=this.panel?.statsEl;if(!e||t%500>250)return;let n=this.counts;e.setText(this.tt("stats.3d",{fps:this.hudFrames.length,calls:this.renderer?.drawCalls??0,nodes:n.nodes,links:n.links,state:this.layout.isSettled()?this.tt("state.settled"):this.tt("state.layout")}))}tt(t,e={}){return Rt(this.language,t,e)}waitSettle(t=12e4){return new Promise(e=>{let n=performance.now(),s=()=>{this.layout.isSettled()||performance.now()-n>t?e():window.setTimeout(s,100)};s()})}async runScenario(t){if(this.benchRunning||!this.renderer||!this.director)return null;this.benchRunning=!0;try{return t==="S2"?await this.benchColdLayout():await this.benchOrbit(t)}finally{this.benchRunning=!1}}async benchOrbit(t){let e=this.renderer,n=this.director;if(!e||!n)throw new Error("not ready");let s=t==="S3";this.store.getIncludeUnresolved()!==s&&this.store.setIncludeUnresolved(s),new _e.Notice(this.tt("3d.bench.wait",{scenario:t})),await this.waitSettle(),e.getBloomStrength()<.01&&e.setBloomStrength(.9),await jh(300),this.benchMode=!0;let r=n.target.clone(),o=new un().setFromVector3(e.camera.position.clone().sub(r));new _e.Notice(this.tt("3d.bench.orbit",{scenario:t}));let a=await Fp(2e4,c=>{let u=o.theta+c/2e4*Math.PI*2;e.camera.position.setFromSpherical(new un(o.radius,o.phi,u)).add(r),e.camera.lookAt(r)});this.benchMode=!1;let l={scenario:t,timestamp:new Date().toISOString(),nodes:this.counts.nodes,links:this.counts.links,bloom:e.getBloomStrength()>0,drawCalls:e.drawCalls,renderer:"aggregate",...a};return await Jh(this.app,l),new _e.Notice(this.tt("3d.bench.done",{scenario:t,fps:a.avgFps.toFixed(1),calls:e.drawCalls})),l}async benchColdLayout(){new _e.Notice(this.tt("3d.bench.s2Start")),this.store.getIncludeUnresolved()&&this.store.setIncludeUnresolved(!1),await jh(300);let t=kp(),e=performance.now();this.settings.positionCache={},this.store.rebuild(!1),this.initLayout(1),this.wasSettled=!1,await this.waitSettle();let n=performance.now()-e,s=this.layout.ticks,r=t.stop(),o={scenario:"S2",timestamp:new Date().toISOString(),nodes:this.counts.nodes,links:this.counts.links,bloom:(this.renderer?.getBloomStrength()??0)>0,renderer:"aggregate",settleMs:n,ticks:s,avgTickMs:s>0?n/s:-1,longTaskCount:r.count,longestTaskMs:r.longestMs,longTaskTotalMs:r.totalMs};return await Jh(this.app,o),new _e.Notice(this.tt("3d.bench.s2Done",{seconds:(n/1e3).toFixed(1),ticks:s,longest:r.longestMs.toFixed(0)})),o}dispose(){window.cancelAnimationFrame(this.rafId),this.intersection?.disconnect(),this.intersection=null;for(let t of this.disposeFns)t();this.disposeFns=[],this.maskEl?.remove(),this.maskEl=null,this.overlay?.dispose(),this.overlay=null,this.director?.dispose(),this.director=null,this.layout.dispose(),this.renderer?.dispose(),this.renderer=null,this.panel?.dispose(),this.panel=null}};var zs=class extends Ul{};var ze=require("obsidian");var Ft="",Op="Vault";var Gp=1160,Vp=620,$y=2800,Hp=144,Ky=72,Jy=360;var Bl=.15,Up=.34,Ln=.045;function Wp(i,t){let e=bt(t.ringSpacing,Vp,$y),n=bt(t.nodeSpacing,Ky,Jy),s=340,r=new Map,o=i.nodesById,a=Sb(i.nodes),l=i.nodes.filter(U=>!U.externalProxy&&U.type!=="external"),c=new Set(l.map(U=>U.id)),u=gb(i,c,e,n),d=c.has(i.rootId)?i.rootId:c.has(Ft)?Ft:l[0]?.id??null,h=jy(i,c,o),f=new Map,m=new Set;if(d!==null&&(Xp(d,0,h,u,f),qp(d,h,m)),d!==null){let U=Gl(0,-Math.PI/2,0,Zr(o.get(d),a,u.incidentPressureByNode.get(d)??0),!1);Zp(U,-Math.PI/2,-Math.PI/2+Math.PI*2),r.set(d,U),Yp(d,0,-Math.PI/2,-Math.PI/2+Math.PI*2,-Math.PI/2,h,f,r,o,u,d,a)}let x=l.filter(U=>U.id!==d&&!m.has(U.id)).sort(zl),g=d!==null?f.get(d):null,p=Math.max(0,g?.maxDepth??0),v=Math.max(zp(r),u.ringGap);x.length>0&&(v=Math.max(v,Qh(x,r,i,o,v+u.ringGap*.64,u.nodeGap,-Math.PI/2,p+1,!1,a,u.incidentPressureByNode)));let M=i.nodes.filter(U=>U.type==="external"&&!U.externalProxy).sort(zl);M.length>0&&(v=Math.max(v,Qh(M,r,i,o,v+u.ringGap*.54,u.nodeGap*1.15,-Math.PI/3,p+1,!0,a,u.incidentPressureByNode)));let b=i.nodes.filter(U=>U.externalProxy).sort(zl);b.length>0&&(v=Math.max(v,Qh(b,r,i,o,v+Math.max(180,u.ringGap*.44),u.nodeGap,-Math.PI/5,p+2,!0,a,u.incidentPressureByNode)));let E=ob(r,i,u,u.nodeGap,a);ab(r,i,u,u.nodeGap,E,a),u.radiusExpansion>1.001&&vb(r,E,u);let w=bt(t.swirlStrength,0,100)/100,C=w>.001?bt(.24+w*.34,.24,.58):0;C>.001&&Cb(r,i,u,C),v=Math.max(v,zp(r));let _=p+(M.length||b.length?2:x.length?1:0),A=_b(i.linkEdges,r,_,u.ringGap,v+Math.max(150,u.ringGap*.35)),P=bb(r,Math.max(A.maxRadius,v+Math.max(160,u.ringGap*.34))),R=s-P.minX,D=s-P.minY;Mb(r,A.routes,R,D),Rb(r);let W=yb(r,E),H=Math.max(900,P.maxX-P.minX+s*2),k=Math.max(520,P.maxY-P.minY+s*2),B={minX:0,minY:0,maxX:H,maxY:k};return{positions:r,rings:W,routes:A.routes,bounds:B,width:H,height:k,centerX:R,centerY:D,ringSpacing:u.ringGap,nodeSpacing:u.nodeGap}}function jy(i,t,e){let n=new Map;for(let s of i.nodes){if(!t.has(s.id)||s.parentId===null||s.parentId===void 0||!t.has(s.parentId))continue;let r=n.get(s.parentId);r?r.push(s.id):n.set(s.parentId,[s.id])}for(let s of n.values())s.sort((r,o)=>zl(e.get(r),e.get(o)));return n}function Xp(i,t,e,n,s,r=new Set){let o=s.get(i);if(o)return o;if(r.has(i)){let f={weight:1,count:1,maxDepth:t,spanDemand:Ln};return s.set(i,f),f}r.add(i);let a=n.incidentPressureByNode.get(i)??0,l=Math.min(9,a*.24),c=1,u=t,d=[];for(let f of e.get(i)??[]){let m=Xp(f,t+1,e,n,s,r);d.push(m),l+=m.weight,c+=m.count,u=Math.max(u,m.maxDepth)}r.delete(i);let h={weight:Math.max(1,l||1),count:c,maxDepth:u,spanDemand:Qy(d)};return s.set(i,h),h}function qp(i,t,e){if(!(i==null||e.has(i))){e.add(i);for(let n of t.get(i)??[])qp(n,t,e)}}function Qy(i){if(i.length===0)return Ln;if(i.length===1)return bt((i[0]?.spanDemand??Ln)*.985,Ln,Math.PI*1.94);let t=eu(i.length),e=i.reduce((r,o)=>r+Math.max(Ln,o.spanDemand),0),n=Math.max(0,i.length-1)*.018,s=Math.pow(Math.max(0,e+n),.92)*1.04;return bt(Math.max(t,s),Ln,Math.PI*1.96)}function eu(i){return i<=1?Ln:i<=2?.16:i<=4?.28+(i-2)*.09:i<=8?.52+(i-4)*.13:i<=14?1.06+(i-8)*.18:i<=24?2.16+(i-14)*.17:i<=48?3.88+(i-24)*.062:Math.min(Math.PI*1.84,5.4+Math.log2(i/48)*.34)}function Yp(i,t,e,n,s,r,o,a,l,c,u,d){let h=r.get(i)??[];if(h.length===0)return;let f=e,m=n,x=Math.max(.001,m-f),g=a.get(i)??Gl(0,s,t,5,!1),p=g.radius+tb(i,t,h,o,c,u),v=eb(i,h,o,c,u);if(h.length===1){let P=i===u?Math.PI*2:x;f=s-P/2,m=s+P/2,x=P}else if(i!==u){let P=nb(i,t,h,x,p,v,r,o);f=s-P/2,m=s+P/2,x=P}if(h.length>1){let P=(h.length-1)*v/Math.max(.16,x*.64),R=c.ringGap*(i===u?1.8:2.8);p=Math.max(p,Math.min(g.radius+R,P))}let M=h.map(P=>rb(P,t+1,r,o)),b=Math.max(1,M.reduce((P,R)=>P+R,0)),E=h.length>8?bt(2.2/Math.sqrt(h.length),.28,.82):1,w=h.length>8?bt(.28-Math.min(.14,(h.length-8)*.0065),.14,.28):.38,C=h.length>1?Math.min(v/p*E,x*w/(h.length-1)):0,_=Math.max(.001,x-C*Math.max(0,h.length-1)),A=f;for(let P=0;P<h.length;P++){let R=h[P],D=h.length===1?_:_*((M[P]??1)/b),W=A,H=A+D,k=W+D/2,B=l.get(R),U=Gl(p,k,t+1,Zr(B,d,c.incidentPressureByNode.get(R)??0),!1);Zp(U,W,H),a.set(R,U),Yp(R,t+1,W,H,k,r,o,a,l,c,u,d),A=H+C}}function tb(i,t,e,n,s,r){let o=e.length,a=n.get(i)??{count:1,weight:1,maxDepth:t},l=s.incidentPressureByNode.get(i)??0,c=Math.sqrt(Math.max(1,o)),u=Math.log2(Math.max(1,a.count||a.weight||1)),d=Math.sqrt(Math.max(0,l)),h=.48+t*.068+c*.096+u*.062+d*.052;return i===r&&(h*=.96),o<=4&&(h=Math.min(h,i===r?.78:.92)),o>=14&&(h=Math.max(h,1.02+Math.min(.78,c*.068))),o>=40&&(h=Math.max(h,1.28+Math.min(1.02,c*.064))),bt(s.baseRingGap*h,i===r?220:250,3400)}function eb(i,t,e,n,s){let r=t.length,o=e.get(i)??{count:1,weight:1,maxDepth:1},a=n.incidentPressureByNode.get(i)??0,c=1.58+(Math.sqrt(Math.max(1,r))*.07+Math.log2(Math.max(1,o.count||1))*.052+Math.sqrt(Math.max(0,a))*.05)*1.95;return i===s&&r<=6&&(c*=1.08),r<=4?c=bt(c,1.62,2.08):r<=10&&(c=Math.max(c,1.86)),r>=24&&(c=Math.max(c,2.12)),r>=64&&(c=Math.max(c,2.58)),bt(n.baseNodeGap*c,132,920)}function nb(i,t,e,n,s,r,o,a){if(e.length<=1)return n;let l=(e.length-1)*r/Math.max(1,s)+.08,c=a.get(i)??{count:e.length+1,weight:e.length+1,maxDepth:t+1,spanDemand:eu(e.length)},u=Math.max(...e.map(w=>tu(w,t+1,o,a)),1),d=e.reduce((w,C)=>w+tu(C,t+1,o,a),0),h=Math.log2(Math.max(2,e.length+1)),f=Math.log2(Math.max(2,c.count||e.length+1)),m=u/Math.max(1,d),x=c.count>e.length*2||e.some(w=>(o.get(w)?.length??0)>2),p=bt((x?.965:.88)+h*.018+f*.012-m*.045,.84,.97);e.length<=4&&!x&&(p=Math.min(p,bt(.38+e.length*.095+f*.018,.48,.74)));let v=Math.max(l,n*p,ib(e,o)),b=e.every(w=>(o.get(w)?.length??0)===0)&&n<Math.PI*1.98?Math.max(.08,n*.985):sb(i,t,e,n,s,r,o,a),E=e.length<=4?Math.min(b,.08):Math.min(n,b);return bt(v,E,b)}function ib(i,t){let e=i.length;if(e<=1)return 0;let n=i.map(l=>t.get(l)?.length??0),s=n.filter(l=>l>0).length,r=Math.max(0,...n),o=e>=48?Math.PI*1.68:e>=24?Math.PI*1.26:e>=14?Math.PI*1.1:e>=9?Math.PI*.82:e>=5?Math.PI*.56:e>=3?Math.PI*.34:Math.PI*.2,a=s>0?bt(1-Math.sqrt(s)*.095-Math.sqrt(r)*.03,.56,.92):1;return o*a}function sb(i,t,e,n,s,r,o,a){let l=e.length,c=e.map(E=>o.get(E)?.length??0),u=Math.max(0,...c),d=c.filter(E=>E>0).length,h=a.get(i)??{count:l+1,weight:l+1,maxDepth:t+1,spanDemand:eu(l)},f=Math.max(0,h.maxDepth-t),m=(l-1)*r/Math.max(1,s)+.08,x=l>=48?Math.PI*1.82:l>=24?Math.PI*1.68:l>=14?Math.PI*1.5:l>=9?Math.PI*1.16:l>=5?Math.PI*.72:Math.PI*.48,g=d>0?bt(1-Math.sqrt(d)*.08-Math.sqrt(u)*.025,.62,.94):1,p=bt(1+Math.max(0,t-1)*.035+Math.sqrt(f)*.026,1,1.22),v=m>n?bt(m/Math.max(.08,n),1,1.35):1,M=x*g*p*v,b=n*(l>=9?1.45:l>=5?1.28:1.14);return bt(Math.max(b,M,m*1.04),.12,Math.PI*1.88)}function tu(i,t,e,n){let s=n.get(i)??{count:1,weight:1,maxDepth:t,spanDemand:Ln},r=e.get(i)?.length??0,o=Math.max(0,s.maxDepth-t),a=r>0?Math.pow(r,1.12)*1.35:0,l=Math.pow(Math.max(1,s.count),.78),c=o>0?Math.sqrt(o+1)*.72:0,u=Math.pow(Math.max(1,s.weight),.58)*.34;return Math.max(1,l+a+c+u)}function rb(i,t,e,n){let s=n.get(i)??{count:1,weight:1,maxDepth:t,spanDemand:Ln},r=tu(i,t,e,n),o=bt(s.spanDemand??Ln,Ln,Math.PI*1.98),a=Math.pow(o,1.62)*18,l=Math.pow(Math.max(1,r),.58)*.18;return Math.max(.18,a+l)}function Qh(i,t,e,n,s,r,o,a,l,c,u=new Map){if(i.length===0)return s;let d=Math.PI*2/i.length,h=i.length*(r/Math.max(1,s)),f=i.map((x,g)=>({node:x,preferred:wb(x,e,t,o+g*d)})).sort((x,g)=>ci(x.preferred)-ci(g.preferred)),m=f[0]?f[0].preferred-d*.5:o;for(let x=0;x<f.length;x++){let g=f[x];if(!g)continue;let p=m+x*d,v=nu(p,g.preferred),M=h<Math.PI*1.35?p+v*.55:p;t.set(g.node.id,Gl(s,M,a||g.node.depth||1,Zr(n.get(g.node.id),c,u.get(g.node.id)??0),l))}return s}function ob(i,t,e,n,s){let r=new Map([[0,0]]),o=new Map;for(let[h,f]of i.entries()){let m=Math.max(0,Math.round(f.depth||0)),x=t.nodesById.get(h),p=Zr(x,s,e.incidentPressureByNode.get(h)??0)*2+Math.max(18,n*.36),v=o.get(m)??{count:0,diameterTotal:0,maxDiameter:0,external:0,linkPressure:0};v.count++,v.diameterTotal+=p,v.maxDiameter=Math.max(v.maxDiameter,p),v.linkPressure+=e.incidentPressureByNode.get(h)??0,(f.external||x?.externalProxy||x?.type==="external")&&v.external++,o.set(m,v)}let a=0,l=[...o.keys()].filter(h=>h>0).sort((h,f)=>h-f),c=Math.max(...l,1),u=[...o.values()].reduce((h,f)=>h+f.count,0),d=bt(1-Math.log10(Math.max(1,u))*.085,.58,.9);for(let h of l){let f=o.get(h);if(!f)continue;let m=f.diameterTotal/Math.max(1,f.count),x=f.count>1?f.count*m/(Math.PI*2):0,g=x>0?Math.pow(x,.58)*Math.pow(e.ringGap,.32):0,p=h/Math.max(1,c),v=1+Math.pow(p,1.35)*.2,M=1+Math.min(.22,Math.sqrt(f.linkPressure/Math.max(1,f.count))*.028),b=bt(1-p*.16,.78,.96),E=h*e.ringGap*d*b*v*M,w=a+e.ringGap*(f.external?.44:.5),C=g*d*v*M+f.maxDiameter*1.24,_=a+e.ringGap*(f.external?1.18:1.34)*v,A=Math.min(_,Math.max(E,w,C));r.set(h,A),a=A}for(let h of i.values()){let f=Math.max(0,Math.round(h.depth||0)),m=r.get(f);if(!Number.isFinite(m))continue;let x=m,g=Number.isFinite(h.angle)?h.angle:Math.atan2(h.y,h.x);if(h.ringRadius=x,f===0){h.x=0,h.y=0,h.radius=0,h.angle=-Math.PI/2;continue}h.x=Math.cos(g)*x,h.y=Math.sin(g)*x,h.radius=x,h.angle=ci(g)}return r}function ab(i,t,e,n,s,r){let o=new Map;for(let[u,d]of i.entries()){let h=t.nodesById.get(u);if(!h)continue;let f=Math.max(0,Math.round(d.depth||0));if(f===0){d.x=0,d.y=0,d.radius=0,d.ringRadius=0,d.ringBandMin=0,d.ringBandMax=0,d.angle=-Math.PI/2;continue}let m=Zr(h,r,e.incidentPressureByNode.get(u)??0),x=m*2.4+Ab(h)*1.55+Math.max(18,n*.18),g=h.parentId??t.rootId??Ft,p=o.get(f)??[];p.push({id:u,node:h,point:d,visualRadius:m,arcDemand:x,kind:mb(h),parentKey:g}),o.set(f,p)}let a=0,l=[...o.keys()].sort((u,d)=>u-d),c=Math.max(...l,1);for(let u of l){let d=o.get(u);if(!d?.length)continue;let h=Math.max(...d.map(_=>_.visualRadius),4),f=d.reduce((_,A)=>_+A.arcDemand,0),m=s.get(u)??e.ringGap*u,x=bt((u-1)/Math.max(1,c-1),0,1),g=Math.max(h*(2.18+x*.42)+Math.max(14,n*(.13+x*.035)),e.ringGap*(.074+x*.028)),p=hb(m,u,x,d.length,f,e,n),v=Bp(u,m,e,d.length,f,x),M=db(u,m,d.length,f),b=Math.max(m,p,a+g*.38,a+h*1.72+v*M),E=Math.min(Bp(u,b,e,d.length,f,x),Math.max(0,b-a-h*1.62));s.set(u,b);let w=lb(d,b,n),C=b;for(let _ of d){let A=ci(Number.isFinite(_.point.angle)?_.point.angle:Math.atan2(_.point.y,_.point.x)),P=cb(_.kind),R=Yr(_.parentKey,`depth-${u}-parent-lane`)*(.24+x*.08),D=w.get(_.id)??0,W=_.kind==="folder"?-1:1,H=.38+Math.min(.16,D*.025)+x*.05,k=bt(P+R+D*H*W,-1.22-x*.2,1.3+x*.24),B=fb(_.id,_.parentKey,_.kind,D,k,b,g,E,u,a+h*1.58);_.point.x=Math.cos(A)*B,_.point.y=Math.sin(A)*B,_.point.radius=B,_.point.ringRadius=b,_.point.ringBandMin=b-E,_.point.ringBandMax=b+E,_.point.angle=A,C=Math.max(C,B+h*.96)}a=C+Math.max(10,n*.038)}}function lb(i,t,e){let n=new Map,s=new Map;for(let r of i){let o=`${r.parentKey}:${r.kind}`,a=s.get(o);a?a.push(r):s.set(o,[r])}for(let r of s.values()){if(r.length<=5)continue;let o=r.slice().sort((d,h)=>ci(d.point.angle)-ci(h.point.angle)),a=Math.max(.001,pb(o[0]?.point.angle??0,o.map(d=>d.point.angle)));if(a>Math.PI*1.45)continue;let l=o.reduce((d,h)=>d+h.arcDemand+Math.max(6,e*.08),0),c=Math.max(e*1.85,t*Math.max(a,.14)*.66),u=bt(Math.ceil(l/Math.max(1,c)),1,6);if(!(u<=1))for(let d=0;d<o.length;d++)n.set(o[d].id,d%u)}return n}function cb(i){return i==="folder"?-.34:i==="unresolved"?.5:i==="external"?.62:.14}function Bp(i,t,e,n,s,r){if(i<=0||!Number.isFinite(t)||t<=0)return 0;let o=ub(i,t,e.ringGap,r),a=Tb(i,t,e.ringGap,n,s),l=bt(.96+bt(r,0,1)*.08,.96,1.04),c=i<=1?1:bt(.84+a*.1+bt(r,0,1)*.08,.9,1),u=t*o;return bt(u*l*c,0,u)}function hb(i,t,e,n,s,r,o){if(t<=0||!Number.isFinite(i)||i<=0||n<=1)return i;let a=Math.max(1,n),l=a*Math.max(8,o*.12),c=s+l,u=bt(.46-(1-bt(e,0,1))*.12-Math.min(.06,a/3600),.32,.48),d=c/Math.max(1,Math.PI*2*u);if(d<=i)return i;let h=bt((d-i)/Math.max(1,r.ringGap),0,1),f=bt(.42+(1-bt(e,0,1))*.34,.42,.76),m=r.ringGap*(.18+(1-bt(e,0,1))*.3+h*.2);return Math.max(i,i+Math.min(d-i,m)*f)}function ub(i,t,e,n){if(i<=1)return Bl;let s=bt(n,0,1),r=Number.isFinite(t)&&e>0?Math.max(0,t/e-1):Math.max(0,i-1),o=bt(r/5,0,1),a=Math.max(Math.pow(s,1.12),Math.pow(o,.92)*.72);return bt(Bl+(Up-Bl)*a,Bl,Up)}function db(i,t,e,n){if(i<=1)return .2;let s=Number.isFinite(t)&&t>0?n/Math.max(1,Math.PI*2*t):0,r=bt((s-.28)/.28,0,1),o=bt((Math.sqrt(Math.max(0,e))-8)/10,0,1);return bt(.1+Math.max(r,o)*.76,.1,.86)}function fb(i,t,e,n,s,r,o,a,l,c){let u=Math.max(c,r+s*o);if(a<=0)return u;let d={folder:l<=1?-.36:-.58,note:l<=1?.1:.08,unresolved:l<=1?.36:.55,external:l<=1?.44:.68},h=e==="folder"?-1:1,f=Yr(t,`depth-${l}-parent-radius`)*(l<=1?.1:.2),m=Yr(i,`depth-${l}-node-radius`)*(l<=1?.16:.32),x=n*(l<=1?.12:.24)*h,g=bt((d[e]??.08)+s*.28+x+f+m,-1,1),p=bt(s,-1,1)*Math.min(o*.24,a*.12);return Math.max(c,r+g*a+p)}function pb(i,t){if(!t.length)return 0;let e=1/0,n=-1/0;for(let s of t){let r=nu(i,s);e=Math.min(e,r),n=Math.max(n,r)}return!Number.isFinite(e)||!Number.isFinite(n)?0:Math.max(0,n-e)}function mb(i){return i.type==="external"||i.externalProxy?"external":i.type==="unresolved"?"unresolved":i.type==="folder"?"folder":"note"}function gb(i,t,e,n){let s=new Map,r=0,o=0;for(let C of i.linkEdges){let _=Math.min(7,Math.log2((C.weight||1)+1)),A=Math.min(6,Math.log2((C.rawCount||C.weight||1)+1)),P=.75+_*.62+A*.28+(C.unresolvedCount?.35:0)+(C.externalCount?.85:0);r+=P,C.externalCount&&(o+=P);for(let R of[C.source,C.target])s.set(R,(s.get(R)??0)+P)}let a=0;for(let C of s.values())a=Math.max(a,C);let l=Math.max(1,i.nodes.length||t.size||1),c=xb(i,t),u=r/l,d=i.linkEdges.length/l,h=a/Math.max(1,Math.sqrt(l)*1.65),f=u+Math.sqrt(Math.max(0,h))*.58+Math.min(1.6,d)*.3+o/l*.32,m=Math.sqrt(Math.max(0,f)),x=bt(1.2+m*.92+Math.min(.86,u*.105),1.2,5.8),g=bt(.84+m*.24+Math.min(.24,u*.032),.72,1.72),p=bt(.62+m*.24+Math.min(.3,d*.17),.62,1.35),v=bt(.9+m*.38+Math.min(.42,d*.2),.9,2.55),M=Math.max(0,Math.log2(c.normalCount/520))*.035,b=Math.max(0,Math.sqrt(c.maxRingCount/96)-1)*.16,E=Math.max(0,Math.sqrt(c.averageRingCount/64)-1)*.1,w=Math.max(0,m-.75)*.028;return{baseRingGap:e,baseNodeGap:n,ringGap:bt(e*g,Vp,3400),nodeGap:bt(n*x,86,860),branchFanSpan:Math.PI*p,routeGapFactor:v,radiusExpansion:bt(1+M*.72+b*.68+E*.64+w,1,1.36),ringCountsByDepth:c.countsByDepth,maxDensityDepth:c.maxDepth,incidentPressureByNode:s}}function xb(i,t){let e=new Map;for(let r of i.nodes){if(!t.has(r.id))continue;let o=Math.max(0,Math.round(r.depth||0));o<=0||e.set(o,(e.get(o)??0)+1)}let n=0,s=0;for(let r of e.values())n=Math.max(n,r),s+=r;return{normalCount:Math.max(1,t.size||0),maxRingCount:n,averageRingCount:e.size?s/e.size:Math.max(1,t.size||0),maxDepth:Math.max(...e.keys(),1),countsByDepth:e}}function vb(i,t,e){let n=bt(e.radiusExpansion,1,1.65);if(n<=1.001)return;let s=Math.max(1,e.maxDensityDepth,...t.keys()),r=o=>{if(o<=0)return 1;let a=bt((o-1)/Math.max(1,s-1),0,1),l=Math.pow(a,1.42),c=e.ringCountsByDepth.get(Math.round(o))??0,u=Math.max(0,Math.sqrt(c/72)-1)*.13*l,d=(1-l)*Math.min(.08,(n-1)*.42),h=(n-1)*(.04+l*1.06);return bt(1-d+h+u,.93,1.68)};for(let[o,a]of[...t.entries()])o>0&&t.set(o,a*r(o));for(let o of i.values()){if(o.radius<=.001)continue;let a=Math.max(0,Math.round(o.depth||0)),l=r(a),c=Number.isFinite(o.angle)?o.angle:Math.atan2(o.y,o.x),u=o.radius*l;o.radius=u,o.x=Math.cos(c)*u,o.y=Math.sin(c)*u,o.angle=c,Number.isFinite(o.ringRadius)&&(o.ringRadius=o.ringRadius*l),Number.isFinite(o.ringBandMin)&&(o.ringBandMin=o.ringBandMin*l),Number.isFinite(o.ringBandMax)&&(o.ringBandMax=o.ringBandMax*l)}}function _b(i,t,e,n,s){let r=new Map,o=Math.max(s||0,1);for(let a of i){let l=t.get(a.source),c=t.get(a.target);if(!l||!c)continue;let u=Number.isFinite(l.radius)?l.radius:0,d=Number.isFinite(c.radius)?c.radius:0,h=Number.isFinite(l.angle)?l.angle:Math.atan2(c.y-l.y,c.x-l.x),f=Number.isFinite(c.angle)?c.angle:h,m=Math.abs(nu(h,f)),x=Math.abs(u-d)<n*.44,g=Math.max(l.depth||0,c.depth||0)>=Math.max(1,e-1),p=!!(l.external||c.external||a.externalCount);(p||x||g&&m>.34||m>Math.PI*.42)&&r.set(a.id,{kind:"curve",centerX:0,centerY:0,radius:Math.max(u,d),sourceAngle:h,targetAngle:f,curveStrength:p?.3:x?.22:m>Math.PI*.72?.2:.15})}return{routes:r,maxRadius:o}}function yb(i,t){if(t.size>1){let n=new Map;for(let s of i.values()){let r=Math.max(0,Math.round(s.depth||0));if(r<=0)continue;let o=Number.isFinite(s.ringRadius)?s.ringRadius:t.get(r);if(!Number.isFinite(o)||o<=0)continue;let a=`${r}:${Math.round(o)}`,l=n.get(a);l?(l.count++,l.radiusTotal+=o):n.set(a,{depth:r,radiusTotal:o,count:1})}return[...n.values()].map(s=>({depth:s.depth,radius:s.radiusTotal/Math.max(1,s.count),count:s.count})).sort((s,r)=>s.radius-r.radius)}let e=new Map;for(let n of i.values()){if(n.depth<=0)continue;let s=n.ringRadius??n.radius,r=e.get(n.depth)??{radius:0,count:0};r.radius+=s,r.count++,e.set(n.depth,r)}return[...e.entries()].map(([n,s])=>({depth:n,radius:s.radius/Math.max(1,s.count),count:s.count})).sort((n,s)=>n.radius-s.radius)}function bb(i,t){let e=-Math.max(1,t||1),n=-Math.max(1,t||1),s=Math.max(1,t||1),r=Math.max(1,t||1);for(let o of i.values())e=Math.min(e,o.x-170),n=Math.min(n,o.y-46),s=Math.max(s,o.x+170),r=Math.max(r,o.y+126);return{minX:e,minY:n,maxX:s,maxY:r}}function Mb(i,t,e,n){for(let s of i.values())s.x+=e,s.y+=n,s.centerX=e,s.centerY=n;for(let s of t.values())!Number.isFinite(s.centerX)||!Number.isFinite(s.centerY)||(s.centerX+=e,s.centerY+=n)}function Gl(i,t,e,n,s){let r=Math.cos(t)*i,o=Math.sin(t)*i;return{x:r,y:o,homeX:r,homeY:o,radius:i,homeRadius:i,angle:t,homeAngle:t,depth:e,nodeRadius:n,centerX:0,centerY:0,external:s}}function Zp(i,t,e){let n=bt(Math.max(0,e-t),.024,Math.PI*2),s=t+n/2;i.sectorStart=s-n/2,i.sectorEnd=s+n/2,i.sectorSpan=n}function Zr(i,t,e=0){if(!i)return 3.6;let n=Math.max(0,(i.linkCount||0)+(i.backlinkCount||0)),s=Math.max(0,e*.62),r=Math.max(n,s),o=Math.max(1,t||1,r),a=Math.log1p(r)/Math.max(1,Math.log1p(o)),l=bt(a,0,1),c=r>0?Math.pow(l,.58):0,u=Math.pow(l,1.82),d=c*22+u*30+Math.log2(r+1)*2.15+Math.sqrt(r)*.42;if(i.externalProxy)return i.type==="unresolved"?Math.min(17,4.5+d*.42):Math.min(30,4.8+d*.58);if(i.type==="folder"){let h=Math.log2((i.noteCount||i.descendantCount||1)+1),f=Math.min(5.8,h*.54);return Math.min(64,5.8+f+d*.94)}if(i.type==="external"){let h=Math.log2((i.noteCount||1)+1),f=Math.min(4.2,h*.42);return Math.min(42,4.8+f+d*.82)}return i.type==="unresolved"?Math.min(17,3.8+d*.48):Math.min(62,3.4+d*1.02)}function Sb(i){let t=1;for(let e of i)t=Math.max(t,(e.linkCount||0)+(e.backlinkCount||0));return t}function zl(i,t){if(!i||!t)return i?-1:t?1:0;let e=n=>n.type==="folder"?0:n.type==="note"?1:n.type==="external"?2:3;return e(i)-e(t)||i.title.localeCompare(t.title)||i.id.localeCompare(t.id)}function zp(i){let t=0;for(let e of i.values())t=Math.max(t,e.radius);return t}function wb(i,t,e,n){let s=[];for(let r of t.linkEdges){let o=r.source===i.id?r.target:r.target===i.id?r.source:null;if(!o)continue;let a=e.get(o);a&&Number.isFinite(a.angle)&&s.push(a.angle)}return Eb(s,n)}function Eb(i,t){if(i.length===0)return t;let e=i.reduce((n,s)=>(n.x+=Math.cos(s),n.y+=Math.sin(s),n),{x:0,y:0});return Math.abs(e.x)<1e-4&&Math.abs(e.y)<1e-4?t:Math.atan2(e.y,e.x)}function Tb(i,t,e,n,s){let r=Math.max(0,i||0),o=Number.isFinite(t)&&e>0?t/e:r,a=Number.isFinite(t)&&t>0?s/Math.max(1,Math.PI*2*t):0,l=bt(.82+r*.06+Math.sqrt(Math.max(0,o))*.13,.86,1.62),c=n<=5?.48:n<=10?.68:a<.12?.62:a<.24?.82:a>.52?1.16:1;return bt(l*c,.42,1.72)}function Ab(i){let t=Array.from(String(i.title||"")).length,e=i.type==="folder"?14:0,n=i.type==="external"||i.externalProxy?9:0;return bt(Math.sqrt(Math.max(1,t))*7.5+Math.min(110,t*1.25)+e+n,24,150)}function Cb(i,t,e,n){let s=t.rootId||Ft,r=Yr(s||"vault","swirl-direction")>=0?1:-1;for(let[o,a]of i.entries()){if(a.radius<=.001)continue;let l=Math.max(0,a.depth||0),c=Number.isFinite(a.angle)?a.angle:Math.atan2(a.y,a.x),u=Math.sqrt(Math.max(0,a.radius)/Math.max(1,e.ringGap)),d=Yr(o,"swirl-arm")*.16,h=Math.sin(c*2.35+l*.78)*.11,f=r*n*(l*.32+u*.22+d+h),m=ci(c+f);a.x=Math.cos(m)*a.radius,a.y=Math.sin(m)*a.radius,a.angle=m}}function Rb(i){for(let t of i.values())t.homeX=t.x,t.homeY=t.y,t.homeRadius=t.radius,t.homeAngle=t.angle}function ci(i){let t=Number.isFinite(i)?i:0;return t%=Math.PI*2,t<0&&(t+=Math.PI*2),t}function nu(i,t){let e=ci(t)-ci(i);return e>Math.PI&&(e-=Math.PI*2),e<-Math.PI&&(e+=Math.PI*2),e}function Pb(i,t){let e=`${i}|${t}`,n=2166136261;for(let s=0;s<e.length;s++)n^=e.charCodeAt(s),n=Math.imul(n,16777619);return(n>>>0)/4294967296*Math.PI*2}function Yr(i,t){return Math.sin(Pb(String(i||""),String(t||"")))}function bt(i,t,e){return Math.min(Math.max(Number.isFinite(i)?i:t,t),e)}var Ib={day:{bg:"#f8fafc",ring:"#9aa7b5",tree:"#93a3b8",link:"#a2acba",external:"#7b6fd6",externalLink:"#c98135",unresolved:"#dc4a4a",focus:"#3f7fe8",folder:"#7f92a8",folderMeta:"#4f8ecb",note:"#a2abb7",root:"#3f7fe8",ringOpacity:.22,treeOpacity:.26,linkOpacity:.1,externalLinkOpacity:.16,highlightOpacity:.92,nodeScale:.32,maxLabels:170},night:{bg:"#1e1e1e",ring:"#777b85",tree:"#8a8f9c",link:"#8b8f99",external:"#a78bfa",externalLink:"#f59e0b",unresolved:"#fb7185",focus:"#8b7cf6",folder:"#d5d8de",folderMeta:"#c4b5fd",note:"#a8adb7",root:"#a99cff",ringOpacity:.22,treeOpacity:.28,linkOpacity:.12,externalLinkOpacity:.16,highlightOpacity:.98,nodeScale:.32,maxLabels:300}},Hl=class{constructor(t){this.container=t;this.scene=new $i;this.ringSegments=null;this.hierarchySegments=null;this.linkSegments=null;this.highlightSegments=null;this.nodePoints=null;this.nodeGeometry=null;this.nodeMaterial=null;this.nodeIds=[];this.edgeVisuals=new Map;this.graph=null;this.layout=null;this.active=Wl();this.width=1;this.height=1;this.centerX=0;this.centerY=0;this.zoom=1;this.scheme="night";this.revealFrame=0;this.revealOverlay=null;this.renderBatchDepth=0;this.pendingRender=!1;this.showRingGuides=!1;this.renderer=new Ns({antialias:!0,alpha:!1}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),this.renderer.setClearColor(this.palette().bg,1),this.domElement=this.renderer.domElement,this.domElement.classList.add("mwm-radial-canvas"),this.domElement.tabIndex=0,t.appendChild(this.domElement),this.labelRoot=t.createDiv({cls:"mwm-radial-labels"}),this.camera=new oi(-1,1,1,-1,.1,5e3),this.camera.position.set(0,0,1e3),this.camera.lookAt(0,0,0)}setTheme(t){if(this.scheme===t)return!1;if(this.scheme=t,this.renderer.setClearColor(this.palette().bg,1),this.nodeMaterial){let e=this.nodeMaterial.uniforms.uLightMode,n=this.nodeMaterial.uniforms.uPixelScale;e&&(e.value=t==="day"?1:0),n&&(n.value=1e3*Math.min(window.devicePixelRatio||1,2)),this.updateNodeScale()}return this.render(),!0}setData(t,e,n,s=!1){this.graph=t,this.layout=e,this.showRingGuides=s,this.edgeVisuals.clear(),this.disposeObjects(),this.buildRings(),this.buildEdges(t.hierarchyEdges,e,"hierarchy"),this.buildEdges(t.linkEdges,e,"links");for(let r of t.hoverLinkEdges){if(this.edgeVisuals.has(r.id))continue;let o=this.edgeVisual(r,e);o&&this.edgeVisuals.set(o.key,o)}this.buildNodes(t,e),this.setActive(this.active,n),this.render()}resize(t,e){this.width=Math.max(1,Math.floor(t)),this.height=Math.max(1,Math.floor(e)),this.renderer.setSize(this.width,this.height,!1),this.camera.left=-this.width/2,this.camera.right=this.width/2,this.camera.top=this.height/2,this.camera.bottom=-this.height/2,this.applyCamera(),this.updateLabels()}setView(t,e,n){this.centerX=Number.isFinite(t)?t:0,this.centerY=Number.isFinite(e)?e:0,this.zoom=Math.min(Math.max(Number.isFinite(n)?n:1,.003),6),this.updateNodeScale(),this.applyCamera();let s=this.active.highlightedEdges.size>0;s&&this.rebuildHighlights(),this.updateLabels(),s&&this.render()}getView(){return{centerX:this.centerX,centerY:this.centerY,zoom:this.zoom}}showLoadingMask(t){cancelAnimationFrame(this.revealFrame),this.container.style.setProperty("--mwm-reveal-x","50%"),this.container.style.setProperty("--mwm-reveal-y","50%"),this.container.style.setProperty("--mwm-reveal-radius","0px"),this.container.addClass("is-radial-revealing"),this.ensureRevealOverlay(t)}beginRenderBatch(){this.renderBatchDepth++}endRenderBatch(){this.renderBatchDepth<=0||(this.renderBatchDepth--,this.renderBatchDepth===0&&this.pendingRender&&(this.pendingRender=!1,this.render()))}fitToLayout(){if(!this.layout)return!1;let t=42,e=Math.max(1,this.width-t),n=Math.max(1,this.height-t),s=Math.min(e/Math.max(1,this.layout.width),n/Math.max(1,this.layout.height))*1.08;return this.setView(this.layout.width/2,this.layout.height/2,s),!0}playRevealFromRoot(t,e,n=1200){if(cancelAnimationFrame(this.revealFrame),!this.layout||this.width<2||this.height<2){this.clearRevealMask(!1);return}let s=this.layout.positions.get(t)??{x:0,y:0},r=this.worldToScreen(s.x,s.y),o=Math.hypot(Math.max(r.x,this.width-r.x),Math.max(r.y,this.height-r.y))+120,a=performance.now();this.container.style.setProperty("--mwm-reveal-x",`${r.x.toFixed(1)}px`),this.container.style.setProperty("--mwm-reveal-y",`${r.y.toFixed(1)}px`),this.container.style.setProperty("--mwm-reveal-radius","0px"),this.container.addClass("is-radial-revealing"),this.ensureRevealOverlay(e);let l=c=>{let u=Math.min(Math.max((c-a)/n,0),1),d=1-Math.pow(1-u,3);if(this.container.style.setProperty("--mwm-reveal-radius",`${(o*d).toFixed(1)}px`),u<1){this.revealFrame=window.requestAnimationFrame(l);return}this.clearRevealMask(!0)};this.revealFrame=window.requestAnimationFrame(l)}setActive(t,e){this.active=t,this.updateNodeDim(),this.rebuildHighlights(),this.updateLabels(e),this.render()}render(){if(this.renderBatchDepth>0){this.pendingRender=!0;return}this.renderer.render(this.scene,this.camera)}worldToScreen(t,e){let n=new L(t,e,0).project(this.camera);return{x:(n.x+1)/2*this.width,y:(1-n.y)/2*this.height}}screenToWorld(t,e){return{x:this.centerX+(t-this.width/2)/this.zoom,y:this.centerY-(e-this.height/2)/this.zoom}}hitTest(t,e,n,s=!0){if(!this.graph||!this.layout)return{nodeId:null,edge:null};let r=this.screenToWorld(t,e),o=null;if(s)for(let l of this.graph.nodes){let c=this.layout.positions.get(l.id);if(!c)continue;let u=Math.hypot(r.x-c.x,r.y-c.y),d=Math.max(4,Vl(c.nodeRadius,this.palette().nodeScale)*$r(this.zoom)*.55),h=Math.max(c.nodeRadius*.36,d/Math.max(.003,this.zoom))+Math.max(5,6/this.zoom);u<=h&&(!o||u<o.distance)&&(o={id:l.id,distance:u})}if(o)return{nodeId:o.id,edge:null};if(!n)return{nodeId:null,edge:null};let a=null;for(let l of this.edgeVisuals.values()){if(l.edge.type==="hierarchy"||l.edge.type==="external-hierarchy")continue;let c=Ub(r,l.points);c<=Math.max(10,8/this.zoom)&&(!a||c<a.distance)&&(a={edge:l.edge,distance:c})}return{nodeId:null,edge:a?.edge??null}}nodePoint(t){return this.layout?.positions.get(t)??null}dispose(){cancelAnimationFrame(this.revealFrame),this.disposeObjects(),this.renderer.dispose(),this.revealOverlay?.remove(),this.domElement.remove(),this.labelRoot.remove()}palette(){return Ib[this.scheme]}ensureRevealOverlay(t){if(!this.revealOverlay){this.revealOverlay=this.container.createDiv({cls:"mwm-radial-loading gx-mask-text",text:t});return}this.revealOverlay.removeClass("is-fading"),this.revealOverlay.setText(t)}clearRevealMask(t){if(this.container.removeClass("is-radial-revealing"),!!this.revealOverlay){if(!t){this.revealOverlay.remove(),this.revealOverlay=null;return}this.revealOverlay.addClass("is-fading"),window.setTimeout(()=>{this.revealOverlay?.remove(),this.revealOverlay=null},220)}}applyCamera(){this.camera.position.set(this.centerX,this.centerY,1e3),this.camera.zoom=this.zoom,this.camera.updateProjectionMatrix(),this.render()}buildRings(){if(!this.showRingGuides||!this.layout?.rings.length){this.ringSegments=null;return}let t=[],e=[],n=new mt(this.palette().ring),s=Number.isFinite(this.layout.centerX)?this.layout.centerX:0,r=Number.isFinite(this.layout.centerY)?this.layout.centerY:0;for(let o of this.layout.rings)!Number.isFinite(o.radius)||o.radius<=0||Db(t,e,n,s,r,o.radius,o.depth,-3);if(t.length===0){this.ringSegments=null;return}this.ringSegments=new si(iu(t,e),new zn({vertexColors:!0,transparent:!0,opacity:this.palette().ringOpacity,depthWrite:!1})),this.scene.add(this.ringSegments)}buildEdges(t,e,n){let s=[],r=[],o=this.palette();for(let l of t){let c=this.edgeVisual(l,e);if(!c)continue;this.edgeVisuals.set(c.key,c);let u=kb(l,n,o);for(let d=0;d<c.points.length-1;d++){let h=c.points[d],f=c.points[d+1];!h||!f||(s.push(h.x,h.y,n==="hierarchy"?-1:-2),s.push(f.x,f.y,n==="hierarchy"?-1:-2),Kr(r,u,n==="hierarchy"?.46:l.externalCount?.22:.16),Kr(r,u,n==="hierarchy"?.46:l.externalCount?.22:.16))}}let a=new si(iu(s,r),new zn({vertexColors:!0,transparent:!0,opacity:n==="hierarchy"?o.treeOpacity:t.some(l=>l.externalCount)?o.externalLinkOpacity:o.linkOpacity,depthWrite:!1}));n==="hierarchy"?this.hierarchySegments=a:this.linkSegments=a,this.scene.add(a)}buildNodes(t,e){let n=this.palette(),s=new Float32Array(t.nodes.length*3),r=new Float32Array(t.nodes.length*3),o=new Float32Array(t.nodes.length),a=new Float32Array(t.nodes.length),l=new Float32Array(t.nodes.length).fill(1);this.nodeIds=t.nodes.map(c=>c.id),t.nodes.forEach((c,u)=>{let d=e.positions.get(c.id),h=Fb(c,t.rootId,n);s[u*3]=d?.x??0,s[u*3+1]=d?.y??0,s[u*3+2]=1,r[u*3]=h.r,r[u*3+1]=h.g,r[u*3+2]=h.b,o[u]=Vl(d?.nodeRadius??8,n.nodeScale),a[u]=c.type==="unresolved"||c.type==="external"||c.externalProxy?1:0}),this.nodeGeometry=new he,this.nodeGeometry.setAttribute("position",new Yt(s,3)),this.nodeGeometry.setAttribute("color",new Yt(r,3)),this.nodeGeometry.setAttribute("aSize",new Yt(o,1)),this.nodeGeometry.setAttribute("aGhost",new Yt(a,1)),this.nodeGeometry.setAttribute("aDim",new Yt(l,1)),this.nodeMaterial=new ue({vertexShader:Sl,fragmentShader:wl,vertexColors:!0,transparent:!0,depthWrite:!1,uniforms:{uPixelScale:{value:1e3*Math.min(window.devicePixelRatio||1,2)},uSizeMul:{value:$r(this.zoom)},uLightMode:{value:this.scheme==="day"?1:0},uMaxPoint:{value:72*Math.min(window.devicePixelRatio||1,2)}}}),this.nodePoints=new Gn(this.nodeGeometry,this.nodeMaterial),this.nodePoints.frustumCulled=!1,this.scene.add(this.nodePoints)}updateNodeDim(){if(!this.nodeGeometry)return;let t=this.nodeGeometry.getAttribute("aDim"),e=t.array;for(let n=0;n<this.nodeIds.length;n++){let s=this.nodeIds[n]??"",r=s===this.active.activeNodeId||this.active.pinnedNodeIds.has(s)||s===this.graph?.focusId,o=this.active.relatedNodes.has(s);e[n]=this.active.dimOthers&&!r&&!o?.23:r?1.12:o?.95:.82}t.needsUpdate=!0}updateNodeScale(){if(!this.nodeMaterial)return;let t=this.nodeMaterial.uniforms.uSizeMul,e=this.nodeMaterial.uniforms.uMaxPoint;t&&(t.value=$r(this.zoom)),e&&(e.value=72*Math.min(window.devicePixelRatio||1,2))}rebuildHighlights(){this.highlightSegments&&(this.scene.remove(this.highlightSegments),this.highlightSegments.geometry.dispose(),Array.isArray(this.highlightSegments.material)?this.highlightSegments.material.forEach(o=>o.dispose()):this.highlightSegments.material.dispose(),this.highlightSegments=null);let t=[],e=[],n=this.palette(),s=new mt(n.focus),r=Math.max(.003,this.zoom||1);for(let o of this.active.highlightedEdges){let a=this.edgeVisuals.get(o);if(a)for(let l=0;l<a.points.length-1;l++){let c=a.points[l],u=a.points[l+1];!c||!u||Nb(t,e,s,c,u,zb(a.edge)/r,2)}}this.highlightSegments=new Xe(Lb(t,e),new ii({vertexColors:!0,transparent:!0,opacity:n.highlightOpacity,depthWrite:!1,depthTest:!1})),this.scene.add(this.highlightSegments)}edgeVisual(t,e){let n=e.positions.get(t.source),s=e.positions.get(t.target);if(!n||!s)return null;let r=e.routes.get(t.id);return{key:t.id,edge:t,points:Ob(n,s,r)}}updateLabels(t="auto"){if(!this.graph||!this.layout)return;this.labelRoot.empty();let e=new Set,n=u=>{u!=null&&e.add(u)};for(let u of this.active.labelNodes)n(u);for(let u of this.active.pinnedNodeIds)n(u);n(this.active.activeNodeId),n(Ft),n(this.graph.rootId),n(this.graph.focusId);let s=this.graph.nodes.map(u=>{let d=this.layout?.positions.get(u.id)??null;if(!d)return null;let h=this.worldToScreen(d.x,d.y);return h.x>=-160&&h.y>=-80&&h.x<=this.width+160&&h.y<=this.height+120?{node:u,point:d,screen:h,score:Gb(u,d,this.graph)}:null}).filter(u=>!!u).sort((u,d)=>d.score-u.score),r=Math.max(1,s.length-1),o=mn(Math.sqrt(Math.max(1,this.width*this.height))/1050,.65,1.8),a=22+Fe(.035,.42,this.zoom)*64+Fe(.36,1.3,this.zoom)*112+Fe(1.1,6,this.zoom)*72,l=t==="auto"&&this.zoom>=.045?Math.round(Math.min(this.palette().maxLabels,Math.max(0,a*o))):0,c=0;for(let u=0;u<s.length;u++){let d=s[u],{node:h,point:f,screen:m}=d,x=e.has(h.id),g=x?1:t==="auto"?Vb(h,f,this.zoom,u,r,this.graph,this.width,this.height):0;if(!x){if(g<=.06||c>=l)continue;c++}let p=this.labelRoot.createDiv({cls:h.id===this.graph.rootId||h.id===Ft?"mwm-radial-label is-root":"mwm-radial-label"});p.setText(h.title);let v=Hb(this.zoom)*(h.id===this.graph.rootId||h.id===Ft?1.18:f.nodeRadius>=24?1.1:f.nodeRadius>=15?1.04:1),M=Math.max(h.id===this.graph.rootId||h.id===Ft?12:9.5,12*v);p.style.fontSize=`${M.toFixed(2)}px`,p.style.maxWidth=`${Math.round((h.id===this.graph.rootId||h.id===Ft?190:h.type==="folder"?156:f.nodeRadius>=18?146:124)*v)}px`,p.style.opacity=String(x?.96:Math.min(.9,.22+g*.68));let b=Math.max(5,Vl(f.nodeRadius,this.palette().nodeScale)*$r(this.zoom)*.62),E=Math.max(9,b+6*v);p.style.transform=`translate3d(${m.x.toFixed(1)}px, ${(m.y+E).toFixed(1)}px, 0)`,this.active.dimOthers&&!e.has(h.id)&&!this.active.relatedNodes.has(h.id)&&(p.style.opacity=String(Math.min(Number(p.style.opacity)||1,.34)),p.addClass("is-dim"))}}disposeObjects(){for(let t of[this.ringSegments,this.hierarchySegments,this.linkSegments,this.highlightSegments,this.nodePoints]){if(!t)continue;this.scene.remove(t),"geometry"in t&&t.geometry.dispose();let e=Array.isArray(t.material)?t.material:[t.material];for(let n of e)n.dispose()}this.ringSegments=null,this.hierarchySegments=null,this.linkSegments=null,this.highlightSegments=null,this.nodePoints=null,this.nodeGeometry=null,this.nodeMaterial=null,this.labelRoot.empty()}};function Wl(){return{hasActive:!1,dimOthers:!1,activeNodeId:null,activeLinkId:null,relatedNodes:new Set,highlightedEdges:new Set,labelNodes:new Set,pinnedNodeIds:new Set}}function iu(i,t){let e=new he;return e.setAttribute("position",new Yt(new Float32Array(i),3)),e.setAttribute("color",new Yt(new Float32Array(t),3)),e}function Lb(i,t){let e=iu(i,t);return e.computeBoundingSphere(),e}function Db(i,t,e,n,s,r,o,a){let l=Math.max(96,Math.ceil(r/16)),c=Math.max(3,Math.round(l/72)),u=o%2===0?0:c;for(let d=0;d<l;d++){if((d+u)%(c*2)>=c)continue;let h=d/l*Math.PI*2,f=(d+1)/l*Math.PI*2;i.push(n+Math.cos(h)*r,s+Math.sin(h)*r,a),i.push(n+Math.cos(f)*r,s+Math.sin(f)*r,a),Kr(t,e,1),Kr(t,e,1)}}function Nb(i,t,e,n,s,r,o){let a=s.x-n.x,l=s.y-n.y,c=Math.hypot(a,l);if(!Number.isFinite(c)||c<=.001)return;let u=Math.max(.1,r*.5),d=-l/c*u,h=a/c*u,f=[[n.x+d,n.y+h,o],[n.x-d,n.y-h,o],[s.x-d,s.y-h,o],[n.x+d,n.y+h,o],[s.x-d,s.y-h,o],[s.x+d,s.y+h,o]];for(let m of f)i.push(m[0],m[1],m[2]),Kr(t,e,1)}function Kr(i,t,e){i.push(t.r,t.g,t.b)}function Fb(i,t,e){return i.id===t?new mt(e.root):i.type==="unresolved"?new mt(e.unresolved):i.type==="external"||i.externalProxy?new mt(e.external):i.type==="folder"&&i.representativeFile?new mt(e.folderMeta):i.type==="folder"?new mt(e.folder):new mt(e.note)}function kb(i,t,e){return i.unresolvedCount?new mt(e.unresolved):i.externalCount?new mt(t==="links"?e.externalLink:e.external):new mt(t==="hierarchy"?e.tree:e.link)}function Ob(i,t,e){if(!e)return[i,t];if(e.kind==="outer"){let u=[i],d=e.sourceAngle,h=e.endAngle??e.targetAngle,f=h-d;Math.abs(f)>Math.PI&&(f+=f>0?-Math.PI*2:Math.PI*2),h=d+f;let m=Math.max(8,Math.ceil(Math.abs(f)/.18));for(let x=0;x<=m;x++){let g=d+f*x/m;u.push({x:e.centerX+Math.cos(g)*e.radius,y:e.centerY+Math.sin(g)*e.radius})}return u.push(t),u}let n=(i.x+t.x)/2,s=(i.y+t.y)/2,r=e.curveStrength??.16,o=Number.isFinite(e.centerX)?e.centerX:Number.isFinite(i.centerX)?i.centerX:n,a=Number.isFinite(e.centerY)?e.centerY:Number.isFinite(i.centerY)?i.centerY:s,l={x:n+(o-n)*r,y:s+(a-s)*r},c=[];for(let u=0;u<=12;u++){let d=u/12,h=(1-d)*(1-d),f=2*(1-d)*d,m=d*d;c.push({x:h*i.x+f*l.x+m*t.x,y:h*i.y+f*l.y+m*t.y})}return c}function Ub(i,t){let e=1/0;for(let n=0;n<t.length-1;n++){let s=t[n],r=t[n+1];!s||!r||(e=Math.min(e,Bb(i,s,r)))}return e}function Bb(i,t,e){let n=e.x-t.x,s=e.y-t.y,r=n*n+s*s;if(r<=1e-6)return Math.hypot(i.x-t.x,i.y-t.y);let o=Math.max(0,Math.min(1,((i.x-t.x)*n+(i.y-t.y)*s)/r));return Math.hypot(i.x-(t.x+n*o),i.y-(t.y+s*o))}function zb(i){return i.type==="hierarchy"||i.type==="external-hierarchy"?1.8:i.externalCount?2.05:2.35}function Gb(i,t,e){let n=Math.max(0,(i.linkCount||0)+(i.backlinkCount||0)),s=Math.max(0,t.nodeRadius||0)*2.8+Math.log1p(n)*13+Math.sqrt(n)*1.4-Math.min(34,(i.depth||0)*3.2);return i.id===e.rootId&&(s+=1e4),i.id===e.focusId&&(s+=9e3),i.type==="folder"?(s+=32+Math.log1p(i.noteCount||i.descendantCount||0)*8,i.representativeFile&&(s+=8)):i.type==="note"?s+=10:i.type==="external"||i.externalProxy?s-=10:i.type==="unresolved"&&(s-=22),s}function Vb(i,t,e,n,s,r,o,a){let l=mn(e,.003,6);if(i.id===r.rootId)return .68+Fe(.04,.2,l)*.32;let u=Math.max(0,(i.linkCount||0)+(i.backlinkCount||0)),d=i.type==="folder",h=i.type==="external"||i.externalProxy,f=i.type==="unresolved",m=mn((t.nodeRadius-4)/42,0,1),x=mn(Math.log1p(u)/Math.log1p(80),0,1),g=mn(1-n/Math.max(1,s),0,1),p=Vl(t.nodeRadius,.24)*$r(l),v=mn((p-2.5)/13,0,1),M=mn(Math.sqrt(Math.max(1,o*a))/1200,.55,1.45),b=Math.max(1,r.nodes.length||1),E=n<Math.max(10,Math.min(58,Math.ceil(b*.05))),w=n<Math.max(28,Math.min(170,Math.ceil(b*.18))),C=n<Math.max(80,Math.min(520,Math.ceil(b*.38))),_=1.04-v*.5-m*.34-x*.2-g*.3-(M-.55)*.08;E?_-=.24:w?_-=.17:C&&(_-=.08),d?_-=i.representativeFile?.22:.15:h&&(_-=.06),f&&(_+=.18),_=mn(_,.08,1.22);let A=Fe(_-.18,_+.1,l),P=E?Fe(.07,.26,l):w?Fe(.14,.44,l)*.92:C?Fe(.28,.7,l)*.74:0,R=t.nodeRadius>=24?Fe(.14,.42,l)*.98:t.nodeRadius>=15?Fe(.24,.64,l)*.82:0,D=f?0:Fe(.12,.82,l)*v*.96,W=f?0:Fe(.48,.98,l)*.9,H=f?0:Fe(.82,1.18,l)*.98;return mn(Math.max(A,P,R,D,W,H),0,1)}function Hb(i){let t=mn(i,.003,6);return .62+Fe(.06,1.48,t)*.88}function Vl(i,t){let e=Math.max(0,Number.isFinite(i)?i:8),n=3.9+e*t*.86+Math.sqrt(e)*.48,s=Fe(14,64,e)*e*t*.42;return mn(n+s,4.8,42)}function $r(i){let t=mn(i,.003,6);return .68+Fe(.035,.24,t)*.4+Fe(.18,1.2,t)*.5+Fe(1.2,6,t)*.24}function Fe(i,t,e){if(i===t)return e>=t?1:0;let n=mn((e-i)/(t-i),0,1);return n*n*(3-2*n)}function mn(i,t,e){return Number.isFinite(i)?Math.min(e,Math.max(t,i)):t}var Kl=require("obsidian");function Jp(i,t,e,n){let s=new Map,r=[],o=[],a=new Map,l=new Map,c=new Map,u=new Map,d=0,h=0,f=v=>Wb(v,n.ignoreFolders),m=v=>{s.has(v.id)||f(v.id)||s.set(v.id,v)};m({id:Ft,path:Ft,title:Op,type:"folder",parentId:null,depth:0,noteCount:0,linkCount:0,backlinkCount:0,descendantCount:0});let x=v=>{let M=Bi(v);if(!M)return Ft;let b=Ft;for(let E of M.split("/").filter(Boolean)){let w=b?`${b}/${E}`:E;if(f(w))return b;s.has(w)||m({id:w,path:w,title:Xl(w),type:"folder",parentId:b,depth:$p(w),noteCount:0,linkCount:0,backlinkCount:0,descendantCount:0}),b=w}return b};for(let v of i){d++;let M=Bi(v.path);if(!M||f(M))continue;if(v.kind==="folder"){x(M);continue}h++;let b=x(su(M));m({id:M,path:M,title:v.basename||Xl(M).replace(/\.md$/i,""),type:"note",parentId:b,depth:$p(M),noteCount:1,linkCount:0,backlinkCount:0,descendantCount:0})}Xb(s,u);let g=(v,M,b,E)=>{if(v===M||!s.has(v)||!s.has(M))return;let w={id:`${E}:${v}->${M}:${o.length}`,type:E,source:v,target:M,weight:b};o.push(w);let C=s.get(v),_=s.get(M);C&&(C.linkCount+=b),_&&(_.backlinkCount+=b),ql(l,v,w),ql(c,M,w)};for(let[v,M]of Object.entries(t))if(!(!s.has(v)||f(v)))for(let[b,E]of Object.entries(M??{}))!s.has(b)||f(b)||g(v,b,Math.max(1,Number(E)||1),"link");if(n.includeUnresolvedLinks){for(let[v,M]of Object.entries(e))if(!(!s.has(v)||f(v)))for(let[b,E]of Object.entries(M??{})){let w=`unresolved:${v}:${b}`;if(!s.has(w)){let C=s.get(v);m({id:w,path:b,title:b,type:"unresolved",parentId:C?.parentId??Ft,depth:(C?.depth??0)+1,noteCount:0,linkCount:0,backlinkCount:0,descendantCount:0})}g(v,w,Math.max(1,Number(E)||1),"unresolved-link")}}qb(s,r,a),Yb(s);let p={loadedEntries:d,scannedMarkdown:h,folders:[...s.values()].filter(v=>v.type==="folder").length,notes:[...s.values()].filter(v=>v.type==="note").length,unresolved:[...s.values()].filter(v=>v.type==="unresolved").length,hierarchyEdges:r.length,linkEdges:o.length,maxDepth:Math.max(0,...[...s.values()].map(v=>v.depth))};return{nodes:s,hierarchyEdges:r,linkEdges:o,childrenByParent:a,linkEdgesBySource:l,linkEdgesByTarget:c,folderRepresentatives:u,stats:p}}function Yl(i,t){if(!i||!t)return i?-1:t?1:0;let e=n=>n.type==="folder"?0:n.type==="note"?1:n.type==="external"?2:3;return i.depth-t.depth||e(i)-e(t)||i.title.localeCompare(t.title)||i.id.localeCompare(t.id)}function Bi(i){return String(i||"").trim().replace(/^\/+|\/+$/g,"")}function su(i){let t=Bi(i),e=t.lastIndexOf("/");return e===-1?Ft:t.slice(0,e)}function Xl(i){let t=Bi(i),e=t.lastIndexOf("/");return e===-1?t:t.slice(e+1)}function $p(i){let t=Bi(i);return t?t.split("/").filter(Boolean).length:0}function Wb(i,t){let e=Bi(i);return e?t.some(n=>e===n||e.startsWith(`${n}/`)):!1}function Xb(i,t){let e=new Map;for(let n of i.values())n.type==="note"&&n.parentId!==null&&ql(e,n.parentId,n);for(let n of i.values()){if(n.type!=="folder"||n.id===Ft)continue;let s=Kp(n.title),r=(e.get(n.id)??[]).find(o=>Kp(o.title)===s);r&&(n.representativeFile=r.id,r.isRepresentativeFile=!0,r.representativeFor=n.id,t.set(n.id,r.id))}}function qb(i,t,e){for(let n of i.values())n.parentId===null||!i.has(n.parentId)||(t.push({id:`hierarchy:${n.parentId}->${n.id}`,type:"hierarchy",source:n.parentId,target:n.id,weight:1}),ql(e,n.parentId,n.id));for(let n of e.values())n.sort((s,r)=>Yl(i.get(s),i.get(r)))}function Yb(i){let t=[...i.values()].sort((e,n)=>n.depth-e.depth);for(let e of t){if(e.descendantCount=e.type==="note"?1:e.noteCount,!e.parentId||!i.has(e.parentId))continue;let n=i.get(e.parentId);if(!n)continue;let s=e.type==="note"?1:e.noteCount;n.descendantCount+=s,n.noteCount+=s,n.linkCount+=e.linkCount,n.backlinkCount+=e.backlinkCount}}function Kp(i){return i.replace(/\.md$/i,"").trim().toLowerCase()}function ql(i,t,e){let n=i.get(t);n?n.push(e):i.set(t,[e])}function sm(i){let t=i.hiddenLegendItems.slice(),e=new Set(t);return{mode:"atlas",rootPath:Ft,focusPath:null,search:"",atlasDepth:i.atlasDepth,focusSiblingLimit:i.focusSiblingLimit,nodeLimit:i.renderNodeLimit,linkLimit:i.linkLimit,externalLinkAnchorLimit:i.externalLinkAnchorLimit,showLinkOverlay:i.showLinkOverlay||!e.has("link"),showExternalLinks:i.showExternalLinks,externalDetailMode:i.externalDetailMode,showCompleteRoot:!1,hoverHighlightMode:i.hoverHighlightMode,pinNeedsHoverLinks:!1,selectedNodeId:null,selectedLink:null,hiddenLegendItems:t,labelVisibility:i.labelVisibility}}function rm(i,t,e=ke){return t.mode==="focus"?$b(i,t,e):Zb(i,t,e)}function ou(i,t){if(t==null)return null;let e=i.nodes.get(t);return e?.isRepresentativeFile&&e.representativeFor&&i.nodes.has(e.representativeFor)?e.representativeFor:t}function Zb(i,t,e){let n=i.nodes.has(t.rootPath)?t.rootPath:Ft,s=i.nodes.get(n)?.depth??0,r=Ae(t.atlasDepth,1,80,e.atlasDepth),o=au(t.search),a=new Set,l=[n];for(;l.length>0;){let c=l.pop(),u=c?i.nodes.get(c):i.nodes.get(Ft);if(!u)continue;let h=Math.max(0,u.depth-s)<=r,f=o.length>0&&Zl(u,o);if((h||f)&&(a.add(u.id),f&&Gs(i,u.id,a,n)),h||f)for(let m of[...i.childrenByParent.get(u.id)??[]].reverse())l.push(m)}if(o)for(let c of i.nodes.values())Zl(c,o)&&(a.add(c.id),Gs(i,c.id,a,n));return am(i,a),om(i,a,n,t,e,null)}function $b(i,t,e){let n=t.focusPath&&i.nodes.has(t.focusPath)?t.focusPath:rM(i),s=new Set([Ft]),r=Ae(t.focusSiblingLimit,10,1e3,e.focusSiblingLimit);if(n){s.add(n),Gs(i,n,s,Ft),Qb(i,n,s,Math.max(30,r));let a=i.nodes.get(n);if(a?.parentId)for(let c of(i.childrenByParent.get(a.parentId)??[]).slice(0,r))s.add(c);let l=[...i.linkEdgesBySource.get(n)??[],...i.linkEdgesByTarget.get(n)??[]].sort((c,u)=>u.weight-c.weight);for(let c of l.slice(0,Math.max(30,r)))s.add(c.source),s.add(c.target),Gs(i,c.source,s,Ft),Gs(i,c.target,s,Ft)}let o=au(t.search);if(o)for(let a of i.nodes.values())Zl(a,o)&&(s.add(a.id),Gs(i,a.id,s,Ft));return am(i,s),om(i,s,Ft,t,e,n)}function om(i,t,e,n,s,r){let o=[...t].map(h=>i.nodes.get(h)).filter(h=>!!h);o.sort(Yl);let a=Jb(i,o,e,n,s,r);o=jb(i,a.nodes);let l=new Set(o.map(h=>h.id)),c=i.hierarchyEdges.filter(h=>l.has(h.source)&&l.has(h.target)),u=Kb(i,l,n,s,e);o=o.concat(u.externalNodes);let d=new Map(o.map(h=>[h.id,h]));return{nodes:o,nodesById:d,hierarchyEdges:c.concat(u.externalHierarchyEdges),linkEdges:u.linkEdges,hoverLinkEdges:u.hoverLinkEdges,rootId:e,focusId:ou(i,r),hiddenNodeCount:a.hiddenNodeCount,externalNodeCount:u.externalNodes.length,externalFileCount:u.externalNodes.filter(h=>h.externalProxy).length,externalGroupCount:u.externalNodes.filter(h=>h.type==="external"&&!h.externalProxy).length}}function Kb(i,t,e,n,s){let r=new Set(e.hiddenLegendItems),o=e.showLinkOverlay&&!r.has("link"),a=o&&!r.has("dashed-link"),l=!r.has("outside-link"),c=!r.has("outside")||!r.has("outside-file"),u=qs(e.hoverHighlightMode)||e.pinNeedsHoverLinks,d=e.showExternalLinks&&s!==Ft&&(c||l);if(!o&&!a&&!u&&!d)return{linkEdges:[],hoverLinkEdges:[],externalNodes:[],externalHierarchyEdges:[]};let h=new Map,f=new Map,m=[],x=Ae(e.externalLinkAnchorLimit,0,2e4,n.externalLinkAnchorLimit),g={fileCount:0,overflowId:null};for(let A of i.linkEdges){let P=Qp(i,A.source,t,s),R=Qp(i,A.target,t,s),D=0;if(d&&(!P&&R&&(P=tm(i,A.source,s,f,m,x,g,em(A,e,R)),P&&(D=1)),P&&!R&&(R=tm(i,A.target,s,f,m,x,g,em(A,e,P)),R&&(D=1))),!P||!R||P===R)continue;let W=`${P}->${R}`,H=h.get(W)??{id:`visible-link:${W}`,type:"visible-link",source:P,target:R,weight:0,rawCount:0,unresolvedCount:0,externalCount:0};H.weight+=A.weight,H.rawCount=(H.rawCount??0)+1,A.type==="unresolved-link"&&(H.unresolvedCount=(H.unresolvedCount??0)+1),H.externalCount=(H.externalCount??0)+D,h.set(W,H)}let p=[...h.values()].sort((A,P)=>im(P)-im(A)),v=A=>A.externalCount?l&&(!A.unresolvedCount||a):A.unresolvedCount?a:o,M=A=>A.externalCount?d&&l&&(!A.unresolvedCount||!r.has("dashed-link")):A.unresolvedCount?!r.has("dashed-link"):!r.has("link"),b=e.showCompleteRoot?3e4:Ae(e.linkLimit,0,3e4,n.linkLimit),E=p.filter(v).slice(0,b),w=e.showCompleteRoot?E:p.filter(M),C=new Set;for(let A of d?p.filter(P=>P.externalCount):u?w:[])f.has(A.source)&&C.add(A.source),f.has(A.target)&&C.add(A.target);let _=iM(C,f);return{linkEdges:E,hoverLinkEdges:w,externalNodes:_,externalHierarchyEdges:m.filter(A=>C.has(A.target))}}function Jb(i,t,e,n,s,r){if(n.showCompleteRoot&&t.length<=2e4)return{nodes:t,hiddenNodeCount:0};let o=Ae(n.nodeLimit,200,2e4,s.renderNodeLimit);if(t.length<=o)return{nodes:t,hiddenNodeCount:0};let a=t.slice().sort((d,h)=>nm(h,e,r,n.search)-nm(d,e,r,n.search)),l=new Map(t.map(d=>[d.id,d])),c=new Set([e,r].filter(d=>d!=null));jp(i,e,c,o,n.showCompleteRoot?128:64);for(let d of a){if(c.size>=o)break;tM(i,d.id,c,l,o),d.type==="folder"&&jp(i,d.id,c,o,n.showCompleteRoot?18:8)}let u=t.filter(d=>c.has(d.id));return{nodes:u,hiddenNodeCount:Math.max(0,t.length-u.length)}}function jb(i,t){let e=new Set(t.map(n=>n.id));return t.filter(n=>!n.isRepresentativeFile||!n.representativeFor||!e.has(n.representativeFor))}function am(i,t){for(let e of[...t]){let n=i.nodes.get(e);if(!(!n||n.type!=="folder"))for(let s of i.childrenByParent.get(e)??[]){let r=i.nodes.get(s);(r?.type==="note"||r?.type==="unresolved")&&t.add(s)}}}function Qb(i,t,e,n){let s=[...i.childrenByParent.get(t)??[]],r=0;for(;s.length>0&&r<n;){let o=s.shift();!o||e.has(o)||(e.add(o),r++,s.push(...i.childrenByParent.get(o)??[]))}}function Gs(i,t,e,n){let s=i.nodes.get(t);for(;s&&s.parentId!==null&&(e.add(s.id),s.id!==n);)s=i.nodes.get(s.parentId);e.add(n||Ft)}function tM(i,t,e,n,s){let r=[],o=n.get(t);for(;o&&!e.has(o.id);)r.push(o.id),o=o.parentId===null?void 0:n.get(o.parentId);for(let a=r.length-1;a>=0&&e.size<s;a--)e.add(r[a]??Ft)}function jp(i,t,e,n,s){let r=0;for(let o of i.childrenByParent.get(t)??[]){if(e.size>=n||r>=s)return;let a=i.nodes.get(o);a?.type!=="note"&&a?.type!=="unresolved"||(e.add(o),r++)}}function Qp(i,t,e,n){let s=i.nodes.get(t);for(;s;){if(e.has(s.id))return s.id;if(s.id===n)return n;s=s.parentId===null?void 0:i.nodes.get(s.parentId)}return e.has(Ft)?Ft:null}function tm(i,t,e,n,s,r,o,a){let l=i.nodes.get(t);if(!l)return null;let c=sM(l,e);if(!c)return null;let u=eM(i,c,e,n);return!a||l.type!=="note"&&l.type!=="unresolved"?u:n.has(l.id)?l.id:o.fileCount>=r?nM(e,u,n,s,o):(n.set(l.id,{...l,externalProxy:!0,externalParentId:u,externalAnchorPath:c}),o.fileCount++,s.push({id:`external-hierarchy:${u}->${l.id}`,type:"external-hierarchy",source:u,target:l.id,weight:1}),l.id)}function eM(i,t,e,n){let s=`external-group:${e}:${t}`;if(!n.has(s)){let r=i.nodes.get(t);n.set(s,{id:s,path:t,title:`Outside: ${r?.title??Xl(t)}`,type:"external",parentId:null,depth:(i.nodes.get(e)?.depth??0)+1,noteCount:r?.noteCount??r?.descendantCount??0,linkCount:0,backlinkCount:0,descendantCount:r?.descendantCount??r?.noteCount??0,externalAnchorPath:t})}return s}function nM(i,t,e,n,s){return s.overflowId||(s.overflowId=`external-overflow:${i}`,e.set(s.overflowId,{id:s.overflowId,path:"outside current root",title:"More outside files",type:"external",parentId:null,depth:1,noteCount:0,linkCount:0,backlinkCount:0,descendantCount:0,externalProxy:!0,externalParentId:t,externalAnchorPath:null}),n.push({id:`external-hierarchy:${t}->${s.overflowId}`,type:"external-hierarchy",source:t,target:s.overflowId,weight:1})),s.overflowId}function iM(i,t){let e=new Map;for(let n of i){let s=t.get(n);if(s){if(s.externalParentId&&t.has(s.externalParentId)){let r=t.get(s.externalParentId);r&&e.set(r.id,r)}e.set(n,s)}}return[...e.values()].sort(Yl)}function em(i,t,e){if(t.externalDetailMode==="exact")return!0;if(t.externalDetailMode==="grouped")return!1;if(t.selectedNodeId&&(i.source===t.selectedNodeId||i.target===t.selectedNodeId||e===t.selectedNodeId))return!0;let n=t.selectedLink;return!!(n&&(n.source===e||n.target===e||n.source===i.source||n.target===i.target))}function sM(i,t){let e=i.type==="unresolved"?su(i.path):i.path,n=e.split("/").filter(Boolean);if(!t)return n[0]??e;let s=t.split("/").filter(Boolean),r=0;for(;r<s.length&&r<n.length&&s[r]===n[r];)r++;return r<s.length?s.slice(0,r+1).join("/"):n.slice(0,r+1).join("/")}function rM(i){return[...i.nodes.values()].find(t=>t.type==="note")?.id??null}function au(i){return i.trim().toLowerCase()}function Zl(i,t){return i.title.toLowerCase().includes(t)||i.path.toLowerCase().includes(t)}function nm(i,t,e,n){let s=0;return i.id===t&&(s+=1e6),i.id===e&&(s+=9e5),n&&Zl(i,au(n))&&(s+=1e5),i.type==="folder"&&(s+=5e3+Math.min(4e3,Math.log2((i.noteCount||i.descendantCount||1)+1)*720)),i.type==="note"&&(s+=1e3+Math.min(3e3,Math.log2((i.linkCount||0)+(i.backlinkCount||0)+1)*520)),i.type==="unresolved"&&(s+=350),s-i.depth*3}function im(i){return(i.weight||1)*10+(i.rawCount||0)*4+(i.externalCount||0)*25+(i.unresolvedCount||0)*8}var $l=class{constructor(t,e){this.app=t;this.settings=e;this.model=null}get ready(){return this.model!==null}get nodes(){return this.model?.nodes??new Map}get stats(){return this.model?.stats??{loadedEntries:0,scannedMarkdown:0,folders:0,notes:0,unresolved:0,hierarchyEdges:0,linkEdges:0,maxDepth:0}}get linkEdgesBySource(){return this.model?.linkEdgesBySource??new Map}get linkEdgesByTarget(){return this.model?.linkEdgesByTarget??new Map}rebuild(t=this.settings){this.settings=t,this.model=Jp(this.collectVaultEntries(),this.app.metadataCache.resolvedLinks,this.app.metadataCache.unresolvedLinks,t)}buildVisibleGraph(t){return this.model||this.rebuild(),rm(this.model,t,this.settings)}visualNodeId(t){return this.model?ou(this.model,t):t??null}getActiveNotePath(){let t=this.app.workspace.getActiveFile();return t&&this.nodes.has(t.path)?t.path:[...this.nodes.values()].find(e=>e.type==="note")?.id??null}collectVaultEntries(){let t=[],e=typeof this.app.vault.getRoot=="function"?this.app.vault.getRoot():null,n=e&&Array.isArray(e.children)?[...e.children]:[];for(;n.length>0;){let s=n.pop();if(s instanceof Kl.TFolder){let r=Bi(s.path);if(r&&t.push({path:r,basename:s.name,kind:"folder"}),Array.isArray(s.children))for(let o=s.children.length-1;o>=0;o--){let a=s.children[o];a&&n.push(a)}}else s instanceof Kl.TFile&&s.extension==="md"&&t.push({path:s.path,basename:s.basename,kind:"note",size:s.stat.size})}if(t.length===0)for(let s of this.app.vault.getMarkdownFiles())t.push({path:s.path,basename:s.basename,kind:"note",size:s.stat.size});return t.some(s=>s.path===Ft)?t.filter(s=>s.path!==Ft):t}};var jl=class extends ze.Component{constructor(e,n,s,r,o,a){super();this.app=e;this.contentEl=n;this.settings=s;this.saveSettings=r;this.onViewMode=o;this.onLanguage=a;this.graph=null;this.layout=null;this.renderer=null;this.canvasHost=null;this.panel=null;this.panelBody=null;this.statsEl=null;this.activePanelPage="inspect";this.selectedNodeId=null;this.selectedLink=null;this.hoverNodeId=null;this.hoverLink=null;this.pinnedPaths=[];this.pinGroups=[];this.selectedPinIds=new Set;this.nextPinId=1;this.nextPinGroupId=1;this.pinGroupName="";this.disposed=!1;this.startupSettled=!1;this.drag=null;this.needsFit=!0;this.index=new $l(e,s.radial),this.state=sm(s.radial),this.saveSoon=(0,ze.debounce)(r,500,!0),this.redrawSoon=(0,ze.debounce)(()=>this.rebuild("metadata"),600,!0)}get counts(){return{nodes:this.graph?.nodes.length??0,links:this.graph?.linkEdges.length??0}}async start(){console.info("[Mini World Map] starting 2D map"),this.contentEl.addClass("mwm-radial-mode"),this.canvasHost=this.contentEl.createDiv({cls:"mwm-radial-host"}),this.renderer=new Hl(this.canvasHost),this.syncThemeClass(),this.buildPanel(),this.buildFloatingControls(),this.bindRendererEvents(),this.registerVaultEvents(),this.renderer.showLoadingMask(this.t("loading.radial")),await this.waitForStartupReady(),!this.disposed&&(this.startupSettled=!0,this.rebuild("start"))}onunload(){this.disposed=!0,super.onunload()}resize(){if(!(!this.renderer||!this.canvasHost)){if(this.renderer.resize(this.canvasHost.clientWidth,this.canvasHost.clientHeight),this.needsFit&&this.renderer.fitToLayout()){this.needsFit=!1;return}this.renderer.render()}}onCssChange(){this.syncThemeClass()}rebuild(e){let n=this.radial(),s=["start","manual","root","focus","atlas"].includes(e),r=this.t("loading.radial");s&&this.renderer?.showLoadingMask(r),this.index.rebuild(n),this.state.hoverHighlightMode=n.hoverHighlightMode,this.state.labelVisibility=n.labelVisibility,this.state.hiddenLegendItems=n.hiddenLegendItems.slice(),this.state.showLinkOverlay=n.showLinkOverlay||!this.state.hiddenLegendItems.includes("link"),this.state.pinNeedsHoverLinks=this.pinnedPathsNeedHoverLinks(),this.state.selectedNodeId=this.selectedNodeId,this.state.selectedLink=this.selectedLink;let o=this.index.buildVisibleGraph({...this.state}),a=new Set(this.state.hiddenLegendItems);this.state.showLinkOverlay||a.add("link");let l=cM(o,a);this.graph=l,this.layout=Wp(l,{ringSpacing:Gp,nodeSpacing:Hp,swirlStrength:n.swirlStrength});let c=this.renderer;c?.beginRenderBatch();try{c?.setTheme(this.resolvedCanvasScheme()),c?.setData(l,this.layout,n.labelVisibility,n.showRingGuides),this.resize(),this.applyActiveState(),s&&c?.playRevealFromRoot(l.rootId,r)}finally{c?.endRenderBatch()}this.renderPanel()}radial(){return this.settings.radial}registerVaultEvents(){this.registerEvent(this.app.metadataCache.on("resolved",()=>{this.startupSettled&&this.redrawSoon()})),this.registerEvent(this.app.vault.on("rename",this.redrawSoon)),this.registerEvent(this.app.vault.on("delete",this.redrawSoon)),this.registerEvent(this.app.vault.on("create",this.redrawSoon)),this.registerEvent(this.app.vault.on("modify",e=>{e instanceof ze.TFile&&e.extension==="md"&&this.redrawSoon()}))}async waitForStartupReady(){await Promise.race([this.waitForMetadataResolved(),oM(900)]),await aM(2)}waitForMetadataResolved(){let e=this.app.metadataCache;return Object.keys(e.resolvedLinks).length>0||Object.keys(e.unresolvedLinks).length>0?Promise.resolve():new Promise(n=>{let s=!1;this.registerEvent(e.on("resolved",()=>{s||(s=!0,n())}))})}bindRendererEvents(){let e=this.renderer?.domElement;if(!e)return;let n=u=>{u.preventDefault();let d=this.renderer;if(!d)return;let h=e.getBoundingClientRect(),f=d.screenToWorld(u.clientX-h.left,u.clientY-h.top),m=d.getView(),x=Math.pow(1.45,-u.deltaY/120),g=Math.min(Math.max(m.zoom*x,.003),6),p=f.x-(u.clientX-h.left-h.width/2)/g,v=f.y+(u.clientY-h.top-h.height/2)/g;d.setView(p,v,g)},s=u=>{if(u.button!==0)return;e.focus();let d=this.renderer?.getView();d&&(this.drag={pointerId:u.pointerId,startX:u.clientX,startY:u.clientY,centerX:d.centerX,centerY:d.centerY,moved:!1},e.setPointerCapture?.(u.pointerId))},r=u=>{let d=e.getBoundingClientRect();if(this.drag){let h=this.renderer;if(!h)return;let f=u.clientX-this.drag.startX,m=u.clientY-this.drag.startY;this.drag.moved=this.drag.moved||Math.hypot(f,m)>3;let x=h.getView();h.setView(this.drag.centerX-f/x.zoom,this.drag.centerY+m/x.zoom,x.zoom);return}this.updateHover(u.clientX-d.left,u.clientY-d.top)},o=u=>{let d=this.drag?.moved??!1;if(this.drag=null,e.releasePointerCapture?.(u.pointerId),d)return;let h=e.getBoundingClientRect();this.activateAt(u.clientX-h.left,u.clientY-h.top,u)},a=()=>{this.drag||(this.hoverNodeId=null,this.hoverLink=null,this.applyActiveState())},l=u=>{let d=e.getBoundingClientRect(),h=this.renderer?.hitTest(u.clientX-d.left,u.clientY-d.top,!1,this.hoverTargets().nodes);if(!h?.nodeId||!this.graph)return;let f=this.graph.nodesById.get(h.nodeId);f&&(u.preventDefault(),f.type==="note"?this.openNode(f.id,u):f.type==="folder"&&this.useAsRoot(f.id))},c=u=>{let d=e.getBoundingClientRect(),h=this.renderer?.hitTest(u.clientX-d.left,u.clientY-d.top,!1,this.hoverTargets().nodes);if(!h?.nodeId||!this.graph)return;let f=this.graph.nodesById.get(h.nodeId);f&&(u.preventDefault(),this.showNodeMenu(u,f))};e.addEventListener("wheel",n,{passive:!1}),e.addEventListener("pointerdown",s),e.addEventListener("pointermove",r),e.addEventListener("pointerup",o),e.addEventListener("pointerleave",a),e.addEventListener("dblclick",l),e.addEventListener("contextmenu",c),this.register(()=>{e.removeEventListener("wheel",n),e.removeEventListener("pointerdown",s),e.removeEventListener("pointermove",r),e.removeEventListener("pointerup",o),e.removeEventListener("pointerleave",a),e.removeEventListener("dblclick",l),e.removeEventListener("contextmenu",c)})}updateHover(e,n){let s=this.hoverTargets(),r=this.renderer?.hitTest(e,n,s.links,s.nodes),o=r?.nodeId??null,a=o?null:r?.edge??null;o===this.hoverNodeId&&(a?.id??null)===(this.hoverLink?.id??null)||(this.hoverNodeId=o,this.hoverLink=a,this.canvasHost?.toggleClass("is-pointing",!!(o||a)),this.applyActiveState())}activateAt(e,n,s){let r=this.hoverTargets(),o=this.renderer?.hitTest(e,n,r.links,r.nodes);o?.nodeId?(s.preventDefault(),this.selectedNodeId=o.nodeId,this.selectedLink=null,this.activePanelPage="inspect"):o?.edge?(s.preventDefault(),this.selectedNodeId=null,this.selectedLink=o.edge,this.activePanelPage="inspect"):(this.selectedNodeId=null,this.selectedLink=null),this.state.selectedNodeId=this.selectedNodeId,this.state.selectedLink=this.selectedLink,this.applyActiveState(),this.renderPanel()}applyActiveState(){if(!this.graph||!this.renderer)return;let e=this.resolveActiveState();this.renderer.setActive(e,this.radial().labelVisibility)}resolveActiveState(){if(!this.graph)return Wl();let e=this.hoverNodeId??this.selectedNodeId,n=this.hoverLink??this.selectedLink,s=Wl();s.activeNodeId=e,s.activeLinkId=n?.id??null;let r=(a,l,c)=>{if(!(!a||!this.graph?.nodesById.has(a))){if(s.relatedNodes.add(a),s.labelNodes.add(a),c&&s.pinnedNodeIds.add(a),qs(l))for(let u of[...this.graph.linkEdges,...this.graph.hoverLinkEdges])u.source!==a&&u.target!==a||(s.highlightedEdges.add(u.id),s.relatedNodes.add(u.source),s.relatedNodes.add(u.target),s.labelNodes.add(u.source),s.labelNodes.add(u.target));lM(this.graph,a,fi(l),s)}},o=(a,l)=>{a&&(s.highlightedEdges.add(a.id),s.relatedNodes.add(a.source),s.relatedNodes.add(a.target),s.labelNodes.add(a.source),s.labelNodes.add(a.target),l&&(s.pinnedNodeIds.add(a.source),s.pinnedNodeIds.add(a.target)))};r(e,this.state.hoverHighlightMode,!1),o(n,!1);for(let a of this.pinnedPaths)a.active&&(a.kind==="node"?r(a.nodeId,a.mode,!0):o(this.findGraphEdgeForPin(a),!0));return s.hasActive=!!(e||n||this.pinnedPaths.some(a=>a.active)),s.dimOthers=!!(e||n),s}hoverTargets(){let e=os(this.radial().hoverTargetMode);return{nodes:e!=="links",links:e!=="nodes"}}buildPanel(){this.panel=this.contentEl.createDiv({cls:"galaxy-panel mwm-radial-panel mwm-map-panel"}),this.syncThemeClass();let e=this.panel.createDiv({cls:"galaxy-panel-header"});this.statsEl=e.createDiv({cls:"galaxy-panel-stats",text:"Mini World Map"});let n=e.createEl("button",{cls:"galaxy-panel-collapse",text:"-"});this.panelBody=this.panel.createDiv({cls:"galaxy-panel-body"}),n.addEventListener("click",()=>{let s=this.panelBody?.hasClass("is-hidden")??!1;this.panelBody?.toggleClass("is-hidden",!s),n.setText(s?"-":"+")}),this.renderPanel()}renderPanel(){if(!this.panelBody)return;let e=this.graph;this.panelBody.empty(),this.statsEl&&this.statsEl.setText(this.t("stats.counts",{nodes:e?.nodes.length??0,links:e?.linkEdges.length??0}));let n=this.panelBody.createDiv({cls:"mwm-mode-switch"});n.createDiv({cls:"mwm-mode-switch-label",text:this.t("view.mode")});let s=n.createDiv({cls:"galaxy-mode-row mwm-mode-row"});this.modeButton(s,pi(this.settings.language,"radial2d"),"radial2d"),this.modeButton(s,pi(this.settings.language,"map3d"),"map3d");let r=this.panelBody.createDiv({cls:"mwm-panel-settings mwm-radial-settings"}),o=r.createDiv({cls:"mwm-panel-tabs"});for(let[l,c]of[["inspect",this.t("tab.inspect")],["pins",this.t("tab.pins")],["view",this.t("tab.view")],["controls",this.t("tab.controls")],["defaults",this.t("tab.defaults")]])o.createEl("button",{cls:this.activePanelPage===l?"is-active":"",text:c}).addEventListener("click",()=>{this.activePanelPage=l,this.renderPanel()});let a=r.createDiv({cls:"mwm-panel-page"});this.activePanelPage==="pins"?this.renderPinsPage(a):this.activePanelPage==="view"?this.renderViewPage(a):this.activePanelPage==="controls"?this.renderControlsPage(a):this.activePanelPage==="defaults"?this.renderDefaultsPage(a):this.renderInspectPage(a)}modeButton(e,n,s){let r=this.settings.viewMode===s;e.createEl("button",{cls:r?"is-active":"",text:n}).addEventListener("click",()=>this.onViewMode(s))}renderInspectPage(e){if(!this.graph)return;if(this.selectedLink){this.renderLinkInspect(e,this.selectedLink);return}let n=this.graph.nodesById.get(this.selectedNodeId??this.graph.focusId??this.graph.rootId);if(e.createDiv({cls:"mwm-side-title",text:n?.title??"Mini World Map"}),!n)return;e.createDiv({cls:"mwm-side-path",text:n.path||"/"});let s=e.createDiv({cls:"mwm-facts"});for(let[a,l]of[[this.t("inspect.type"),n.externalProxy?`${this.t("inspect.external")} ${n.type}`:n.type],[this.t("inspect.depth"),String(n.depth)],[this.t("inspect.notes"),String(n.noteCount||n.descendantCount||0)],[this.t("inspect.out"),String(n.linkCount||0)],[this.t("inspect.in"),String(n.backlinkCount||0)]])s.createSpan({text:a}),s.createSpan({text:l});let r=e.createDiv({cls:"galaxy-panel-row"});this.button(r,this.t("common.pin"),()=>this.pinNode(n)),n.type==="note"&&this.button(r,this.t("common.open"),()=>void this.openNode(n.id)),n.type==="note"&&this.button(r,this.t("common.focus"),()=>this.focusNote(n.id)),n.type==="folder"&&this.button(r,this.t("common.root"),()=>this.useAsRoot(n.id));let o=this.currentRootParentId();o!==null&&this.button(r,this.t("inspect.parentRoot"),()=>this.useAsRoot(o)),this.renderNeighborList(e,n)}renderLinkInspect(e,n){e.createDiv({cls:"mwm-side-title",text:this.t("inspect.linkOverlay")});let s=this.graph?.nodesById.get(n.source),r=this.graph?.nodesById.get(n.target),o=e.createDiv({cls:"mwm-facts"});for(let[l,c]of[[this.t("common.source"),s?.title??n.source],[this.t("common.target"),r?.title??n.target],[this.t("inspect.weight"),String(n.weight||0)],[this.t("inspect.raw"),String(n.rawCount||n.weight||0)],[this.t("inspect.unresolved"),String(n.unresolvedCount||0)],[this.t("inspect.external"),String(n.externalCount||0)]])o.createSpan({text:l}),o.createSpan({text:c});let a=e.createDiv({cls:"galaxy-panel-row"});this.button(a,this.t("common.pin"),()=>this.pinLink(n)),this.button(a,this.t("common.source"),()=>this.inspectNode(n.source)),this.button(a,this.t("common.target"),()=>this.inspectNode(n.target))}renderNeighborList(e,n){let s=(this.index.linkEdgesBySource.get(n.id)??[]).slice(0,20),r=(this.index.linkEdgesByTarget.get(n.id)??[]).slice(0,20);for(let[o,a,l]of[[this.t("inspect.outgoing",{count:s.length}),s,"target"],[this.t("inspect.backlinks",{count:r.length}),r,"source"]]){e.createDiv({cls:"mwm-side-heading",text:o}),a.length===0&&e.createDiv({cls:"mwm-side-muted",text:this.t("common.none")});for(let c of a){let u=this.index.nodes.get(c[l]);if(!u)continue;e.createEl("button",{cls:"mwm-link-row",text:`${u.title} (${c.weight})`}).addEventListener("click",()=>this.inspectNode(u.id))}}}renderPinsPage(e){let n=e.createDiv({cls:"galaxy-panel-row"});this.button(n,this.t("common.pinCurrent"),()=>this.pinCurrent()),this.button(n,this.t("common.clear"),()=>this.clearPins());let s=e.createDiv({cls:"mwm-pin-group-row"}),r=s.createEl("input",{attr:{value:this.pinGroupName,placeholder:this.t("pins.groupName")}});if(r.addEventListener("input",()=>this.pinGroupName=r.value),this.button(s,this.t("common.group"),()=>this.groupSelectedPins()),this.pinnedPaths.length===0){e.createDiv({cls:"mwm-side-muted",text:this.t("pins.empty")});return}let o=new Map(this.pinGroups.map(c=>[c.id,c])),a=new Map,l=[];for(let c of this.pinnedPaths){if(!c.groupId||!o.has(c.groupId)){l.push(c);continue}let u=a.get(c.groupId)??[];u.push(c),a.set(c.groupId,u)}l.length&&this.renderPinGroup(e,null,l);for(let c of this.pinGroups){let u=a.get(c.id)??[];u.length&&this.renderPinGroup(e,c,u)}}renderPinGroup(e,n,s){let r=e.createDiv({cls:"mwm-pin-group"}),o=r.createDiv({cls:"mwm-pin-group-header"});o.createSpan({cls:"mwm-pin-group-title",text:n?.name??this.t("pins.ungrouped")}),o.createSpan({cls:"mwm-pin-count",text:String(s.length)}),n&&this.button(o,this.t("common.ungroup"),()=>this.removePinGroup(n.id));for(let a of s)this.renderPinRow(r,a)}renderPinRow(e,n){let s=e.createDiv({cls:n.active?"mwm-pin-row":"mwm-pin-row is-muted"}),r=s.createEl("input",{cls:"mwm-pin-check",attr:{type:"checkbox",title:this.t("pins.selectForGroup"),"aria-label":this.t("pins.selectForGroup")}});r.checked=this.selectedPinIds.has(n.id),r.addEventListener("change",()=>{r.checked?this.selectedPinIds.add(n.id):this.selectedPinIds.delete(n.id),this.renderPanel()});let o=s.createEl("button",{cls:"mwm-pin-main",attr:{type:"button",title:n.path||n.title}});o.addEventListener("click",()=>this.locatePin(n)),o.createDiv({cls:"mwm-pin-title",text:n.title}),o.createDiv({cls:"mwm-pin-meta",text:`${this.pinKindLabel(n)} - ${n.path||"/"}`}),this.button(s,n.active?this.t("pins.hideHighlight"):this.t("pins.showHighlight"),()=>this.togglePinHighlight(n.id)),this.button(s,this.t("common.inspect"),()=>this.inspectPin(n)),n.groupId&&this.button(s,this.t("common.ungroup"),()=>this.ungroupPin(n.id)),this.button(s,"X",()=>this.removePin(n.id))}renderViewPage(e){this.textInput(e,this.t("common.search"),this.state.search,r=>{this.state.search=r.trim(),this.needsFit=!0,this.rebuild("search")}),this.select(e,this.t("view.theme"),this.radial().colorScheme,_u(this.settings.language),r=>{this.radial().colorScheme=no(r),this.saveSoon(),this.syncThemeClass()});let n=e.createDiv({cls:"galaxy-panel-row"});this.button(n,this.t("view.atlas"),()=>this.resetToAtlas(),this.state.mode==="atlas"),this.button(n,this.t("view.focus"),()=>this.focusActiveNote(),this.state.mode==="focus"),this.button(n,this.t("view.vaultRoot"),()=>this.resetToRoot());let s=e.createDiv({cls:"galaxy-panel-row"});this.button(s,this.t("common.fit"),()=>this.renderer?.fitToLayout()),this.button(s,this.t("common.rebuild"),()=>this.rebuild("manual"))}renderControlsPage(e){let n=this.radial();this.numberInput(e,this.t("control.depth"),this.state.atlasDepth,1,80,1,o=>{this.state.atlasDepth=o,this.rebuild("depth")}),this.numberInput(e,this.t("control.nodes"),this.state.nodeLimit,200,2e4,100,o=>{this.state.nodeLimit=o,this.rebuild("nodes")}),this.numberInput(e,this.t("control.noteLinks"),this.state.linkLimit,0,3e4,50,o=>{this.state.linkLimit=o,this.rebuild("links")});let s=new Set(n.hiddenLegendItems),r=this.state.showLinkOverlay&&!s.has("link");this.toggle(e,this.t("control.showNoteLinks"),r,o=>{n.showLinkOverlay=o,this.state.showLinkOverlay=o,this.setLegendHidden("link",!o),this.saveSoon(),this.rebuild("link-overlay")}),this.select(e,this.t("control.hover"),this.state.hoverHighlightMode,io(this.settings.language,Vs),o=>{let a=fi(o);this.state.hoverHighlightMode=a,n.hoverHighlightMode=a,this.state.pinNeedsHoverLinks=this.pinnedPathsNeedHoverLinks(),this.saveSoon(),this.rebuild("hover")}),this.select(e,this.t("control.hoverTargets"),n.hoverTargetMode,so(this.settings.language,Hs),o=>{n.hoverTargetMode=os(o),this.clearDisallowedHoverTargets(),this.saveSoon(),this.applyActiveState(),this.renderPanel()}),this.select(e,this.t("control.labels"),n.labelVisibility,ro(this.settings.language,to),o=>{n.labelVisibility=Xs(o),this.state.labelVisibility=n.labelVisibility,this.saveSoon(),this.applyActiveState()}),this.numberInput(e,this.t("control.spin"),n.swirlStrength,0,100,1,o=>{n.swirlStrength=o,this.saveSoon(),this.rebuild("spin")}),this.toggle(e,this.t("control.ringGuides"),n.showRingGuides,o=>{n.showRingGuides=o,this.saveSoon(),this.graph&&this.layout&&this.renderer&&(this.renderer.setData(this.graph,this.layout,n.labelVisibility,n.showRingGuides),this.applyActiveState()),this.renderPanel()}),this.toggle(e,this.t("control.outsideLinks"),this.state.showExternalLinks,o=>{this.state.showExternalLinks=o,n.showExternalLinks=o,this.saveSoon(),this.rebuild("external")}),this.select(e,this.t("control.outsideDetail"),this.state.externalDetailMode,yu(this.settings.language),o=>{this.state.externalDetailMode=cc(o),n.externalDetailMode=this.state.externalDetailMode,this.saveSoon(),this.rebuild("external-mode")}),this.numberInput(e,this.t("control.exactOutsideFiles"),this.state.externalLinkAnchorLimit,0,2e4,50,o=>{this.state.externalLinkAnchorLimit=o,n.externalLinkAnchorLimit=o,this.saveSoon(),this.rebuild("external-limit")}),this.renderLegend(e)}renderDefaultsPage(e){let n=this.radial();this.numberInput(e,this.t("control.defaultDepth"),n.atlasDepth,1,80,1,s=>{n.atlasDepth=s,this.state.atlasDepth=s,this.saveSoon()}),this.numberInput(e,this.t("control.defaultNodes"),n.renderNodeLimit,200,2e4,100,s=>{n.renderNodeLimit=s,this.state.nodeLimit=s,this.saveSoon()}),this.numberInput(e,this.t("control.defaultNoteLinks"),n.linkLimit,0,3e4,50,s=>{n.linkLimit=s,this.state.linkLimit=s,this.saveSoon()}),this.toggle(e,this.t("control.unresolvedLinks"),n.includeUnresolvedLinks,s=>{n.includeUnresolvedLinks=s,this.saveSoon(),this.rebuild("unresolved")}),this.textArea(e,this.t("control.ignoredFolders"),n.ignoreFolders.join(`
`),s=>{n.ignoreFolders=s.split(`
`).map(r=>r.trim()).filter(Boolean),this.saveSoon(),this.rebuild("ignored")})}renderLegend(e){e.createDiv({cls:"mwm-side-heading",text:this.t("control.legend")});let n=new Set(this.radial().hiddenLegendItems);for(let[s,r,o,a]of ac){let l=e.createEl("label",{cls:n.has(s)?"mwm-legend-item is-muted":"mwm-legend-item",attr:{title:this.t(o)}}),c=l.createEl("input",{attr:{type:"checkbox"}});c.checked=!n.has(s),l.createSpan({cls:`mwm-legend-mark ${a}`});let u=l.createSpan({cls:"mwm-legend-copy"});u.createSpan({cls:"mwm-legend-label",text:this.t(r)}),u.createSpan({cls:"mwm-legend-desc",text:this.t(o)}),c.addEventListener("change",()=>{let d=c.checked;d?n.delete(s):n.add(s),this.radial().hiddenLegendItems=[...n],this.state.hiddenLegendItems=[...n],s==="link"&&(this.radial().showLinkOverlay=d,this.state.showLinkOverlay=d),this.saveSoon(),this.rebuild("legend")})}}setLegendHidden(e,n){let s=new Set(this.radial().hiddenLegendItems);n?s.add(e):s.delete(e),this.radial().hiddenLegendItems=[...s],this.state.hiddenLegendItems=[...s]}buildFloatingControls(){let e=this.canvasHost;if(!e)return;let n=e.createDiv({cls:"mwm-floating-controls"}),s=n.createEl("button",{cls:"mwm-floating-button",attr:{type:"button",title:this.t("language"),"aria-label":this.t("language")}});(0,ze.setIcon)(s,"languages"),s.addEventListener("click",r=>{r.preventDefault(),r.stopPropagation(),this.openLanguageMenu(s)}),this.iconButton(n,"home",this.t("view.vaultRoot"),()=>this.resetToRoot()),this.iconButton(n,"pin",this.t("common.pinCurrent"),()=>this.pinCurrent()),this.iconButton(n,"maximize",this.t("common.fit"),()=>this.renderer?.fitToLayout()),this.iconButton(n,"refresh-cw",this.t("common.rebuild"),()=>this.rebuild("manual"))}openLanguageMenu(e){let n=new ze.Menu;for(let[r,o]of as(this.settings.language))n.addItem(a=>{a.setTitle(o),r===this.settings.language&&a.setIcon("check"),a.onClick(()=>{let l=rs(r);l!==this.settings.language&&(this.settings.language=l,this.onLanguage(l),this.renderPanel())})});let s=e.getBoundingClientRect();n.showAtPosition({x:s.right,y:s.bottom})}iconButton(e,n,s,r){let o=e.createEl("button",{cls:"mwm-floating-button",attr:{type:"button",title:s,"aria-label":s}});return(0,ze.setIcon)(o,n),o.addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),r()}),o}button(e,n,s,r=!1){let o=e.createEl("button",{cls:r?"is-active":"",text:n});return o.addEventListener("click",s),o}textInput(e,n,s,r){let o=e.createEl("label",{cls:"mwm-panel-field"});o.createSpan({text:n});let a=o.createEl("input",{attr:{value:s,type:"search"}});a.addEventListener("change",()=>r(a.value))}numberInput(e,n,s,r,o,a,l){let c=e.createEl("label",{cls:"mwm-panel-field"});c.createSpan({text:n});let u=c.createEl("input",{attr:{value:String(s),type:"number",min:String(r),max:String(o),step:String(a)}});u.addEventListener("change",()=>l(Ae(u.value,r,o,s)))}textArea(e,n,s,r){let o=e.createEl("label",{cls:"mwm-panel-field"});o.createSpan({text:n});let a=o.createEl("textarea");a.value=s,a.addEventListener("change",()=>r(a.value))}toggle(e,n,s,r,o){let a=e.createEl("label",{cls:"mwm-panel-toggle",attr:{title:o??n}}),l=a.createEl("input",{attr:{type:"checkbox"}});l.checked=s,a.createSpan({text:n}),l.addEventListener("change",()=>r(l.checked))}select(e,n,s,r,o){let a=e.createEl("label",{cls:"mwm-panel-field"});a.createSpan({text:n});let l=a.createEl("select");for(let[c,u]of r)l.createEl("option",{attr:{value:c},text:u});l.value=s,l.addEventListener("change",()=>o(l.value))}pinCurrent(){this.selectedLink?this.pinLink(this.selectedLink):this.selectedNodeId&&this.graph?.nodesById.has(this.selectedNodeId)?this.pinNode(this.graph.nodesById.get(this.selectedNodeId)):this.hoverLink?this.pinLink(this.hoverLink):this.hoverNodeId&&this.graph?.nodesById.has(this.hoverNodeId)?this.pinNode(this.graph.nodesById.get(this.hoverNodeId)):new ze.Notice(this.t("pins.selectBeforePin"))}pinNode(e){this.addPin({kind:"node",nodeId:e.id,mode:this.state.hoverHighlightMode,title:e.title,path:e.path||"/"})}pinLink(e){let n=this.graph?.nodesById.get(e.source),s=this.graph?.nodesById.get(e.target);this.addPin({kind:"link",edgeId:e.id,source:e.source,target:e.target,mode:"note-links",title:`${n?.title??e.source} -> ${s?.title??e.target}`,path:`${n?.path??e.source} -> ${s?.path??e.target}`})}addPin(e){let n=e.kind==="node"?`node:${e.nodeId}:${e.mode}`:`link:${e.edgeId??`${e.source}->${e.target}`}`,s={...e,id:`pin-${this.nextPinId++}`,key:n,active:!0,groupId:null};this.pinnedPaths.push(s),this.selectedPinIds.add(s.id),this.state.pinNeedsHoverLinks=this.pinnedPathsNeedHoverLinks(),this.applyActiveState(),this.activePanelPage="pins",this.renderPanel()}removePin(e){this.pinnedPaths=this.pinnedPaths.filter(n=>n.id!==e),this.selectedPinIds.delete(e),this.dropEmptyPinGroups(),this.state.pinNeedsHoverLinks=this.pinnedPathsNeedHoverLinks(),this.applyActiveState(),this.renderPanel()}clearPins(){this.pinnedPaths=[],this.pinGroups=[],this.selectedPinIds.clear(),this.state.pinNeedsHoverLinks=!1,this.applyActiveState(),this.renderPanel()}groupSelectedPins(){let e=this.pinnedPaths.filter(s=>this.selectedPinIds.has(s.id));if(e.length===0){new ze.Notice(this.t("pins.selectFirst"));return}let n=`pin-group-${this.nextPinGroupId++}`;this.pinGroups.push({id:n,name:this.pinGroupName.trim()||`Group ${this.pinGroups.length+1}`});for(let s of e)s.groupId=n;this.dropEmptyPinGroups(),this.pinGroupName="",this.selectedPinIds.clear(),this.renderPanel()}removePinGroup(e){this.pinGroups=this.pinGroups.filter(n=>n.id!==e);for(let n of this.pinnedPaths)n.groupId===e&&(n.groupId=null);this.renderPanel()}ungroupPin(e){let n=this.pinnedPaths.find(s=>s.id===e);n&&(n.groupId=null,this.dropEmptyPinGroups(),this.renderPanel())}dropEmptyPinGroups(){let e=new Set(this.pinnedPaths.map(n=>n.groupId).filter(n=>!!n));this.pinGroups=this.pinGroups.filter(n=>e.has(n.id))}togglePinHighlight(e){let n=this.pinnedPaths.find(s=>s.id===e);n&&(n.active=!n.active,this.state.pinNeedsHoverLinks=this.pinnedPathsNeedHoverLinks(),this.applyActiveState(),this.renderPanel())}locatePin(e){let n=e.kind==="node"?e.nodeId:e.source;if(!n)return;let s=this.renderer?.nodePoint(n),r=this.renderer?.getView();s&&r&&this.renderer?.setView(s.x,s.y,Math.max(r.zoom,.22))}inspectPin(e){this.activePanelPage="inspect",e.kind==="node"&&e.nodeId?this.inspectNode(e.nodeId):this.selectedLink=this.findGraphEdgeForPin(e),this.applyActiveState(),this.renderPanel()}findGraphEdgeForPin(e){return e.kind!=="link"||!this.graph?null:[...this.graph.linkEdges,...this.graph.hoverLinkEdges].find(n=>n.id===e.edgeId||n.source===e.source&&n.target===e.target)??null}pinnedPathsNeedHoverLinks(){return this.pinnedPaths.some(e=>e.active&&(e.kind==="link"||e.kind==="node"&&qs(e.mode)))}pinKindLabel(e){return e.kind==="link"?this.t("inspect.linkOverlay"):this.t(`hover.${fi(e.mode)}`)}clearDisallowedHoverTargets(){let e=this.hoverTargets();e.nodes||(this.hoverNodeId=null),e.links||(this.hoverLink=null),this.canvasHost?.toggleClass("is-pointing",!!(e.nodes&&this.hoverNodeId||e.links&&this.hoverLink))}inspectNode(e){this.selectedNodeId=e,this.selectedLink=null,this.applyActiveState(),this.renderPanel()}resetToAtlas(){this.state.mode="atlas",this.state.rootPath=this.state.rootPath||Ft,this.state.focusPath=null,this.needsFit=!0,this.rebuild("atlas")}resetToRoot(){this.state.mode="atlas",this.state.rootPath=Ft,this.state.focusPath=null,this.needsFit=!0,this.rebuild("root")}currentRootParentId(){let e=this.graph?.rootId??this.state.rootPath;if(e===Ft)return null;let n=this.graph?.nodesById.get(e)??this.index.nodes.get(e);if(n?.parentId!==void 0&&n.parentId!==null)return n.parentId;let s=e.lastIndexOf("/");return s>=0?e.slice(0,s):Ft}useAsRoot(e){this.state.mode="atlas",this.state.rootPath=e,this.state.focusPath=null,this.needsFit=!0,this.rebuild("root")}focusActiveNote(){let e=this.selectedNodeId?this.index.nodes.get(this.selectedNodeId):null,n=e?.type==="note"?e.id:this.index.getActiveNotePath();n&&this.focusNote(n)}focusNote(e){this.state.mode="focus",this.state.focusPath=e,this.state.rootPath=Ft,this.needsFit=!0,this.rebuild("focus")}showNodeMenu(e,n){let s=new ze.Menu;n.type==="note"&&(s.addItem(r=>r.setTitle(this.t("context.openNote")).setIcon("file-text").onClick(()=>void this.openNode(n.id,e))),s.addItem(r=>r.setTitle(this.t("context.focusNote")).setIcon("locate-fixed").onClick(()=>this.focusNote(n.id)))),n.type==="folder"&&(s.addItem(r=>r.setTitle(this.t("context.useAsRoot")).setIcon("folder-open").onClick(()=>this.useAsRoot(n.id))),n.representativeFile&&s.addItem(r=>r.setTitle(this.t("context.openRepresentative")).setIcon("file-text").onClick(()=>void this.openNode(n.representativeFile,e)))),s.addItem(r=>r.setTitle(this.t("context.pinPath")).setIcon("pin").onClick(()=>this.pinNode(n))),s.showAtMouseEvent(e)}async openNode(e,n){let s=this.app.vault.getAbstractFileByPath(e);if(!(s instanceof ze.TFile))return;let r=n&&(n.metaKey||n.ctrlKey)?"split":"tab";await this.app.workspace.openLinkText(s.path,"",r,{active:!0})}syncThemeClass(){let e=this.resolvedCanvasScheme(),n=this.resolvedPanelScheme();this.contentEl.toggleClass("is-day-scheme",e==="day"),this.contentEl.toggleClass("is-night-scheme",e==="night"),this.panel?.removeClass("gx-theme-dark"),this.panel?.removeClass("gx-theme-light"),this.panel?.addClass(n==="day"?"gx-theme-light":"gx-theme-dark");let s=this.renderer;s?.beginRenderBatch();try{(s?.setTheme(e)??!1)&&this.graph&&this.layout&&s?.setData(this.graph,this.layout,this.radial().labelVisibility,this.radial().showRingGuides)}finally{s?.endRenderBatch()}}resolvedCanvasScheme(){let e=no(this.radial().colorScheme);return e==="day"||e==="night"?e:activeDocument.body.hasClass("theme-dark")?"night":"day"}resolvedPanelScheme(){return activeDocument.body.hasClass("theme-dark")?"night":"day"}t(e,n={}){return Rt(this.settings.language,e,n)}dispose(){this.unload(),this.renderer?.dispose(),this.renderer=null,this.contentEl.removeClass("mwm-radial-mode"),this.contentEl.empty()}};function oM(i){return new Promise(t=>{window.setTimeout(t,i)})}function aM(i){return new Promise(t=>{let e=Math.max(0,i),n=()=>{if(e--,e<=0){t();return}window.requestAnimationFrame(n)};window.requestAnimationFrame(n)})}function lM(i,t,e,n){if(e==="none"||e==="note-links")return;let s=new Map(i.hierarchyEdges.map(a=>[a.target,a])),r=new Map;for(let a of i.hierarchyEdges){let l=r.get(a.source);l?l.push(a):r.set(a.source,[a])}let o=a=>{n.highlightedEdges.add(a.id),n.relatedNodes.add(a.source),n.relatedNodes.add(a.target),n.labelNodes.add(a.source),n.labelNodes.add(a.target)};if(e==="hierarchy-parents"||e==="hierarchy-parents-direct"||e==="hierarchy-all"){let a=s.get(t);for(;a;)o(a),a=s.get(a.source)}if(e==="hierarchy-direct-children"||e==="hierarchy-parents-direct"||e==="hierarchy-all")for(let a of r.get(t)??[])o(a);if(e==="hierarchy-descendants"||e==="hierarchy-all"){let a=[...r.get(t)??[]];for(;a.length>0;){let l=a.pop();l&&(o(l),a.push(...r.get(l.target)??[]))}}}function cM(i,t){if(t.size===0)return i;let e=d=>!(d.id===i.rootId&&t.has("root")||d.externalProxy&&t.has("outside-file")||d.type==="external"&&!d.externalProxy&&t.has("outside")||d.type==="unresolved"&&t.has("missing")||d.type==="folder"&&d.representativeFile&&t.has("folder-meta")||d.type==="folder"&&!d.representativeFile&&t.has("folder")||d.type==="note"&&t.has("file")),n=i.nodes.filter(e),s=new Set(n.map(d=>d.id)),r=d=>s.has(d.source)&&s.has(d.target),o=t.has("tree")?[]:i.hierarchyEdges.filter(r),a=d=>!r(d)||d.externalCount&&t.has("outside-link")||d.unresolvedCount&&t.has("dashed-link")?!1:!!d.externalCount||!t.has("link"),l=d=>!(!r(d)||d.externalCount&&t.has("outside-link")||d.unresolvedCount&&t.has("dashed-link")),c=i.linkEdges.filter(a),u=i.hoverLinkEdges.filter(l);return{...i,nodes:n,nodesById:new Map(n.map(d=>[d.id,d])),hierarchyEdges:o,linkEdges:c,hoverLinkEdges:u}}var zi=class extends tc.ItemView{constructor(e,n){super(e);this.host=n;this.navigation=!0;this.controller=null;this.initRetryTimer=0;this.initRetryCount=0;this.bootStatusEl=null;this.bootStatusTimer=0}getViewType(){return qn}getDisplayText(){return"Mini World Map"}getIcon(){return"network"}get counts(){return this.controller?.counts??{nodes:0,links:0}}async onOpen(){this.contentEl.empty(),this.contentEl.addClass("mini-world-map-view","galaxy-view-content"),this.showBootStatus(`Mini World Map view opening (${this.host.settings.viewMode})`),this.registerEvent(this.app.workspace.on("css-change",()=>this.controller?.onCssChange?.())),this.tryInit()}onResize(){if(!this.controller){this.tryInit();return}this.controller.resize()}switchMode(e){if(this.host.settings.viewMode!==e){this.host.setViewMode(e);return}this.rebuild()}tryInit(){if(this.controller)return;let{clientWidth:e,clientHeight:n}=this.contentEl;if(e<10||n<10){this.showBootStatus(`Mini World Map waiting for pane size (${Math.round(e)} x ${Math.round(n)})`),this.scheduleInitRetry();return}if(this.clearInitRetry(),this.initRetryCount=0,this.showBootStatus(`Mini World Map starting ${this.host.settings.viewMode==="map3d"?"3D":"2D"} map`),this.host.settings.viewMode==="map3d"){let s=new zs(this.app,this.contentEl,this.host.settings.galaxy3d,()=>void this.host.saveSettings(),r=>this.switchMode(r),this.host.settings.language,r=>this.host.setLanguage(r));s.onContextLost=()=>this.rebuild(),this.controller=s,this.addChild(s.store),this.startController(s)}else{let s=new jl(this.app,this.contentEl,this.host.settings,()=>void this.host.saveSettings(),r=>this.switchMode(r),r=>this.host.setLanguage(r));this.controller=s,this.addChild(s),this.startController(s)}}startController(e){e.start().then(()=>{this.controller===e&&(this.showBootStatus(`Mini World Map ${this.host.settings.viewMode==="map3d"?"3D":"2D"} map started: ${e.counts.nodes} nodes, ${e.counts.links} links`),this.clearBootStatus(12e3))}).catch(n=>{this.controller===e&&(console.error("[Mini World Map] failed to start view",n),new tc.Notice("Mini World Map failed to load. Check the developer console for details."),e.dispose(),this.controller=null,this.contentEl.empty(),this.contentEl.addClass("mini-world-map-view","galaxy-view-content"),this.showBootStatus("Mini World Map failed to start. Check the developer console."))})}scheduleInitRetry(){if(this.initRetryTimer)return;let e=Math.min(600,32+this.initRetryCount*48);this.initRetryCount++,this.initRetryTimer=window.setTimeout(()=>{this.initRetryTimer=0,this.tryInit()},e)}clearInitRetry(){this.initRetryTimer&&(window.clearTimeout(this.initRetryTimer),this.initRetryTimer=0)}rebuild(){this.clearInitRetry(),this.controller?.dispose(),this.controller=null,this.contentEl.empty(),this.contentEl.addClass("mini-world-map-view","galaxy-view-content"),this.showBootStatus(`Mini World Map rebuilding (${this.host.settings.viewMode})`),this.tryInit()}async onClose(){this.clearInitRetry(),this.clearBootStatus(),this.controller?.dispose(),this.controller=null,this.contentEl.empty()}showBootStatus(e){this.bootStatusTimer&&(window.clearTimeout(this.bootStatusTimer),this.bootStatusTimer=0),this.bootStatusEl||(this.bootStatusEl=this.contentEl.createDiv({cls:"mwm-boot-status"})),this.bootStatusEl.setText(e)}clearBootStatus(e=0){if(this.bootStatusTimer&&(window.clearTimeout(this.bootStatusTimer),this.bootStatusTimer=0),e>0){this.bootStatusTimer=window.setTimeout(()=>{this.bootStatusTimer=0,this.clearBootStatus()},e);return}this.bootStatusEl?.remove(),this.bootStatusEl=null}};var ec=class extends we.Plugin{constructor(){super(...arguments);this.settings=lc(null)}async onload(){console.info("[Mini World Map] loading"),this.settings=lc(await this.loadData()),this.registerView(qn,e=>new zi(e,this)),this.addRibbonIcon("network","Open Mini World Map",()=>{this.activateView()}),this.addCommand({id:"open-map",name:"Open Mini World Map",callback:()=>void this.activateView()}),this.addCommand({id:"toggle-render-mode",name:"Toggle Mini World Map render mode",callback:()=>{this.setViewMode(this.settings.viewMode==="radial2d"?"map3d":"radial2d"),this.activateView()}}),this.addCommand({id:"rebuild-index",name:"Rebuild Mini World Map index",callback:()=>{let e=!1;for(let n of this.app.workspace.getLeavesOfType(qn)){let s=n.view;s instanceof zi&&"rebuild"in(s.controller??{})&&(s.controller.rebuild?.("manual"),e=!0)}new we.Notice(Rt(this.settings.language,e?"notice.rebuilt":"notice.openToBuild"))}}),this.addCommand({id:"search-3d",name:"Search 3D map node and fly",callback:()=>{this.activateView().then(e=>{e?.controller instanceof zs?e.controller.openSearch():new we.Notice(Rt(this.settings.language,"notice.switchTo3d"))})}}),this.addSettingTab(new lu(this.app,this))}async saveSettings(){await this.saveData(this.settings)}setViewMode(e){this.settings.viewMode=eo(e),this.saveSettings();for(let n of this.app.workspace.getLeavesOfType(qn)){let s=n.view;s instanceof zi&&s.switchMode(this.settings.viewMode)}}setLanguage(e){this.settings.language=rs(e),this.saveSettings();for(let n of this.app.workspace.getLeavesOfType(qn)){let s=n.view;s instanceof zi&&s.switchMode(this.settings.viewMode)}}async activateView(){let{workspace:e}=this.app,n=e.getLeavesOfType(qn)[0]??null;return n||(n=e.getLeaf(!0),await n.setViewState({type:qn,active:!0})),n.isDeferred&&await n.loadIfDeferred(),await e.revealLeaf(n),n.view instanceof zi?n.view:null}},lu=class extends we.PluginSettingTab{constructor(e,n){super(e,n);this.plugin=n}display(){let{containerEl:e}=this,n=this.plugin.settings.radial,s=this.plugin.settings.language;e.empty(),e.createEl("h2",{text:Rt(s,"settings.title")}),new we.Setting(e).setName(Rt(s,"language")).setDesc(Rt(s,"settings.languageDesc")).addDropdown(r=>{for(let[o,a]of as(s))r.addOption(o,a);r.setValue(this.plugin.settings.language).onChange(async o=>{this.plugin.settings.language=rs(o),await this.plugin.saveSettings(),this.display()})}),new we.Setting(e).setName(Rt(s,"settings.defaultMode")).setDesc(Rt(s,"settings.defaultModeDesc")).addDropdown(r=>r.addOption("radial2d",pi(s,"radial2d")).addOption("map3d",pi(s,"map3d")).setValue(this.plugin.settings.viewMode).onChange(async o=>{this.plugin.settings.viewMode=eo(o),await this.plugin.saveSettings()})),new we.Setting(e).setName(Rt(s,"control.defaultDepth")).setDesc(Rt(s,"settings.depthDesc")).addSlider(r=>r.setLimits(1,20,1).setValue(n.atlasDepth).setDynamicTooltip().onChange(async o=>{n.atlasDepth=Ae(o,1,80,ke.atlasDepth),await this.plugin.saveSettings()})),new we.Setting(e).setName(Rt(s,"control.defaultNodes")).setDesc(Rt(s,"settings.nodeLimitDesc")).addText(r=>r.setPlaceholder(String(ke.renderNodeLimit)).setValue(String(n.renderNodeLimit)).onChange(async o=>{n.renderNodeLimit=Ae(o,200,2e4,ke.renderNodeLimit),await this.plugin.saveSettings()})),new we.Setting(e).setName(Rt(s,"control.defaultNoteLinks")).setDesc(Rt(s,"settings.linkLimitDesc")).addText(r=>r.setPlaceholder(String(ke.linkLimit)).setValue(String(n.linkLimit)).onChange(async o=>{n.linkLimit=Ae(o,0,3e4,ke.linkLimit),await this.plugin.saveSettings()})),new we.Setting(e).setName(Rt(s,"control.showNoteLinks")).setDesc(Rt(s,"settings.showLinksDesc")).addToggle(r=>r.setValue(n.showLinkOverlay&&!n.hiddenLegendItems.includes("link")).onChange(async o=>{n.showLinkOverlay=o;let a=new Set(n.hiddenLegendItems);o?a.delete("link"):a.add("link"),n.hiddenLegendItems=[...a],await this.plugin.saveSettings()})),new we.Setting(e).setName(Rt(s,"control.hover")).setDesc(Rt(s,"settings.hoverDesc")).addDropdown(r=>{for(let[o,a]of io(s,Vs))r.addOption(o,a);r.setValue(n.hoverHighlightMode).onChange(async o=>{n.hoverHighlightMode=fi(o),await this.plugin.saveSettings()})}),new we.Setting(e).setName(Rt(s,"control.hoverTargets")).setDesc(Rt(s,"settings.hoverTargetsDesc")).addDropdown(r=>{for(let[o,a]of so(s,Hs))r.addOption(o,a);r.setValue(n.hoverTargetMode).onChange(async o=>{n.hoverTargetMode=os(o),await this.plugin.saveSettings()})}),new we.Setting(e).setName(Rt(s,"control.labels")).setDesc(Rt(s,"settings.labelsDesc")).addDropdown(r=>{for(let[o,a]of ro(s,to))r.addOption(o,a);r.setValue(n.labelVisibility).onChange(async o=>{n.labelVisibility=Xs(o),await this.plugin.saveSettings()})}),new we.Setting(e).setName(Rt(s,"control.spin")).setDesc(Rt(s,"settings.spinDesc")).addSlider(r=>r.setLimits(0,100,1).setValue(n.swirlStrength).setDynamicTooltip().onChange(async o=>{n.swirlStrength=Ae(o,0,100,ke.swirlStrength),await this.plugin.saveSettings()})),new we.Setting(e).setName(Rt(s,"control.unresolvedLinks")).setDesc(Rt(s,"settings.unresolvedDesc")).addToggle(r=>r.setValue(n.includeUnresolvedLinks).onChange(async o=>{n.includeUnresolvedLinks=o,await this.plugin.saveSettings()})),new we.Setting(e).setName(Rt(s,"control.ignoredFolders")).setDesc(Rt(s,"settings.ignoredDesc")).addTextArea(r=>r.setValue(n.ignoreFolders.join(`
`)).onChange(async o=>{n.ignoreFolders=o.split(`
`).map(a=>a.trim()).filter(Boolean),await this.plugin.saveSettings()}))}};
/*! Bundled license information:
three/build/three.core.js:
three/build/three.module.js:
(**
* @license
* Copyright 2010-2026 Three.js Authors
* SPDX-License-Identifier: MIT
*)
*/