/* 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 gc=Object.defineProperty;var Zm=Object.getOwnPropertyDescriptor;var $m=Object.getOwnPropertyNames;var Km=Object.prototype.hasOwnProperty;var Jm=(i,e)=>{for(var t in e)gc(i,t,{get:e[t],enumerable:!0})},jm=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of $m(e))!Km.call(i,s)&&s!==t&&gc(i,s,{get:()=>e[s],enumerable:!(n=Zm(e,s))||n.enumerable});return i};var Qm=i=>jm(gc({},"__esModule",{value:!0}),i);var wS={};Jm(wS,{default:()=>fc});module.exports=Qm(wS);var ns=require("obsidian");var Yn="mini-world-map-view";var Vi=2.2,xc=Vi*6;var to={strength:.6,radius:.4,threshold:.18};var Fn={angularSpeed:.022,elevationDeg:8,elevationPeriodS:90,radiusBreath:.04,radiusPeriodS:60,resumeDelayMs:1e4,rampUpMs:2e3},Zn={distancePerRadius:12,minDistance:40,maxDistance:140,azimuthOffsetRad:15*Math.PI/180,minMs:800,maxMs:1800,msPerWorldUnit:.45},vc=8e-4;var Xs=[["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"]],no=[["auto","Auto"],["hover","Hover only"]],qs=[["nodes","Nodes"],["links","Links"],["both","Nodes + links"]],_c=[["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"]],kt={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"]},rn={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:"auto",colorGroups:[],positionCache:{}},Hu={language:"en",viewMode:"radial2d",radial:kt,galaxy3d:rn};function yc(i){let e=gn(i)?i:{},t=gn(e.radial),n=t?e.radial:e,s=gn(e.galaxy3d)?e.galaxy3d:e,r=eg(n);return!t&&e.showLinkOverlay===!1&&(r.showLinkOverlay=kt.showLinkOverlay),{language:rs(e.language??e.locale??e.lang),viewMode:io(e.viewMode),radial:r,galaxy3d:tg(s)}}function Wu(i,e,t){if(ig(e))return i;let n=sg(t);return n&&!i.radial.ignoreFolders.includes(n)&&(i.radial.ignoreFolders=[...i.radial.ignoreFolders,n]),i}function eg(i){let e=gn(i)?i:{},t=kt,n=new Set(_c.map(([r])=>r)),s=e.hoverHighlightMode??(e.enableLinkHover===!0?"note-links":t.hoverHighlightMode);return{atlasDepth:At(e.atlasDepth,1,80,t.atlasDepth),focusSiblingLimit:At(e.focusSiblingLimit,10,1e3,t.focusSiblingLimit),linkLimit:At(e.linkLimit,0,3e4,t.linkLimit),renderNodeLimit:At(e.renderNodeLimit,200,2e4,t.renderNodeLimit),externalLinkAnchorLimit:At(e.externalLinkAnchorLimit,0,2e4,t.externalLinkAnchorLimit),adaptiveDetail:typeof e.adaptiveDetail=="boolean"?e.adaptiveDetail:t.adaptiveDetail,includeUnresolvedLinks:typeof e.includeUnresolvedLinks=="boolean"?e.includeUnresolvedLinks:t.includeUnresolvedLinks,showLinkOverlay:typeof e.showLinkOverlay=="boolean"?e.showLinkOverlay:t.showLinkOverlay,showExternalLinks:typeof e.showExternalLinks=="boolean"?e.showExternalLinks:t.showExternalLinks,externalDetailMode:bc(e.externalDetailMode),colorScheme:so(e.colorScheme),labelVisibility:Zs(e.labelVisibility),hoverHighlightMode:fi(s),hoverTargetMode:os(e.hoverTargetMode),swirlStrength:At(e.swirlStrength,0,100,t.swirlStrength),showRingGuides:typeof e.showRingGuides=="boolean"?e.showRingGuides:t.showRingGuides,hiddenLegendItems:Array.isArray(e.hiddenLegendItems)?e.hiddenLegendItems.filter(r=>typeof r=="string"&&n.has(r)):t.hiddenLegendItems.slice(),ignoreFolders:Array.isArray(e.ignoreFolders)?e.ignoreFolders.filter(r=>typeof r=="string"&&r.trim().length>0):t.ignoreFolders.slice()}}function tg(i){let e=gn(i)?i:{},t=rn,n=gn(e.bloom)?e.bloom:{},s=gn(e.physics)?e.physics:{},r=gn(e.look)?e.look:{};return{bloom:{strength:sn(n.strength,t.bloom.strength),radius:sn(n.radius,t.bloom.radius),threshold:sn(n.threshold,t.bloom.threshold)},physics:{repel:sn(s.repel,t.physics.repel),linkDistance:sn(s.linkDistance,t.physics.linkDistance),linkStrength:sn(s.linkStrength,t.physics.linkStrength),centerPull:sn(s.centerPull,t.physics.centerPull),flatten:sn(s.flatten,t.physics.flatten)},look:{nodeSize:sn(r.nodeSize,t.look.nodeSize),linkOpacity:sn(r.linkOpacity,t.look.linkOpacity),twinkle:sn(r.twinkle,t.look.twinkle),sizeBy:["degree","fileSize","uniform"].includes(r.sizeBy)?r.sizeBy:t.look.sizeBy},cruise:typeof e.cruise=="boolean"?e.cruise:t.cruise,cruiseSpeed:sn(e.cruiseSpeed,t.cruiseSpeed),showUnresolved:typeof e.showUnresolved=="boolean"?e.showUnresolved:typeof e.includeUnresolvedLinks=="boolean"?e.includeUnresolvedLinks:t.showUnresolved,showOrphans:typeof e.showOrphans=="boolean"?e.showOrphans:t.showOrphans,colorTheme:typeof e.colorTheme=="string"?e.colorTheme:t.colorTheme,qualityOverride:["auto","high","low","mobile"].includes(e.qualityOverride)?e.qualityOverride:t.qualityOverride,preset:ng(e.preset),colorGroups:Array.isArray(e.colorGroups)?e.colorGroups.filter(o=>gn(o)&&typeof o.query=="string"&&typeof o.color=="string"):[],positionCache:gn(e.positionCache)&&!Array.isArray(e.positionCache)?e.positionCache:{}}}function Ys(i){return{charge:-i.repel,linkDistance:i.linkDistance,linkStrength:i.linkStrength,centerPull:i.centerPull,flatten:i.flatten,velocityDecay:.6}}function io(i){return i==="map3d"||i==="radial2d"?i:Hu.viewMode}function rs(i){return i==="zh"?"zh":Hu.language}function so(i){return i==="auto"||i==="day"||i==="night"?i:kt.colorScheme}function ng(i){return i==="auto"||i==="day"||i==="night"||i==="deep-space"?i:i==="adaptive"?"auto":rn.preset}function Zs(i){return i==="hover"?"hover":kt.labelVisibility}function fi(i){return Xs.some(([e])=>e===i)?i:kt.hoverHighlightMode}function os(i){return qs.some(([e])=>e===i)?i:kt.hoverTargetMode}function $s(i){return fi(i)==="note-links"}function bc(i){return i==="selected"||i==="exact"||i==="grouped"?i:kt.externalDetailMode}function At(i,e,t,n){let s=sn(i,n);return Math.min(Math.max(s,e),t)}function sn(i,e){return typeof i=="number"&&Number.isFinite(i)?i:Number.parseFloat(String(i))||e}function ig(i){let e=gn(i)?i:{},t=gn(e.radial)?e.radial:e;return Array.isArray(t.ignoreFolders)}function sg(i){return i.trim().replace(/\\/g,"/").replace(/^\/+|\/+$/g,"")}function gn(i){return typeof i=="object"&&i!==null}var rg=[["en","English"],["zh","\u4E2D\u6587"]],Xu={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"},"2d.searchPlaceholder":{en:"Search notes or folders, press Enter to locate\u2026",zh:"\u641C\u7D22\u7B14\u8BB0\u6216\u6587\u4EF6\u5939\uFF0C\u56DE\u8F66\u5B9A\u4F4D\u2026"},"search.folder":{en:"Folder",zh:"\u6587\u4EF6\u5939"},"search.note":{en:"Note",zh:"\u7B14\u8BB0"},"search.external":{en:"Outside",zh:"\u5916\u90E8"},"search.notes":{en:"{count} notes",zh:"{count} \u4E2A\u7B14\u8BB0"},"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.sizeBy":{en:"Size",zh:"\u5927\u5C0F"},"3d.sizeOption.degree":{en:"Links",zh:"\u94FE\u63A5\u6570"},"3d.sizeOption.fileSize":{en:"File size",zh:"\u6587\u6863\u91CF"},"3d.sizeOption.uniform":{en:"Uniform",zh:"\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.openToSearch":{en:"Open Mini World Map to search.",zh:"\u6253\u5F00 Mini World Map \u540E\u624D\u80FD\u641C\u7D22\u3002"}};function Le(i,e,t={}){return(Xu[e]?.[i]??Xu[e]?.en??e).replace(/\{(\w+)\}/g,(s,r)=>String(t[r]??`{${r}}`))}function pi(i,e){return Le(i,`mode.${e}`)}function qu(i){return[["auto",Le(i,"theme.radialAuto")],["day",Le(i,"theme.day")],["night",Le(i,"theme.night")]]}function as(i){return rg.map(([e,t])=>[e,t])}function ro(i,e){return e.map(([t])=>[t,Le(i,`hover.${t}`)])}function oo(i,e){return e.map(([t])=>[t,Le(i,`hoverTarget.${t}`)])}function ao(i,e){return e.map(([t])=>[t,Le(i,`labels.${t}`)])}function Yu(i){return[["grouped",Le(i,"outside.grouped")],["selected",Le(i,"outside.selected")],["exact",Le(i,"outside.exact")]]}var dc=require("obsidian");var yt=require("obsidian");var ga="184",Cn={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2};var _d=0,Qc=1,yd=2;var yr=1,bd=2,Rs=3,ni=0,$t=1,Hn=2,_n=0,Yi=1,br=2,eh=3,th=4,Md=5;var Mi=100,Sd=101,wd=102,Ed=103,Td=104,Ad=200,Cd=201,Rd=202,Pd=203,Do=204,Fo=205,Id=206,Ld=207,Nd=208,Dd=209,Fd=210,kd=211,Od=212,Ud=213,Bd=214,ko=0,Oo=1,Uo=2,Zi=3,Bo=4,zo=5,Vo=6,Go=7,nh=0,zd=1,Vd=2,hn=0,Mr=1,Sr=2,wr=3,Pi=4,Er=5,Tr=6,Ar=7;var ih=300,Ii=301,Ki=302,xa=303,va=304,Cr=306,Ho=1e3,Un=1001,Wo=1002,Lt=1003,Gd=1004;var Rr=1005;var Ut=1006,_a=1007;var Li=1008;var un=1009,sh=1010,rh=1011,Ps=1012,ya=1013,Rn=1014,Pn=1015,Xt=1016,ba=1017,Ma=1018,Is=1020,oh=35902,ah=35899,lh=1021,ch=1022,yn=1023,Bn=1026,Ni=1027,hh=1028,Sa=1029,Di=1030,wa=1031;var Ea=1033,Pr=33776,Ir=33777,Lr=33778,Nr=33779,Ta=35840,Aa=35841,Ca=35842,Ra=35843,Pa=36196,Ia=37492,La=37496,Na=37488,Da=37489,Dr=37490,Fa=37491,ka=37808,Oa=37809,Ua=37810,Ba=37811,za=37812,Va=37813,Ga=37814,Ha=37815,Wa=37816,Xa=37817,qa=37818,Ya=37819,Za=37820,$a=37821,Ka=36492,Ja=36494,ja=36495,Qa=36283,el=36284,Fr=36285,tl=36286;var ir=2300,Xo=2301,No=2302,Wc=2303,Xc=2400,qc=2401,Yc=2402;var Hd=3200;var uh=0,Wd=1,li="",ln="srgb",sr="srgb-linear",rr="linear",je="srgb";var qi=7680;var Zc=519,Xd=512,qd=513,Yd=514,nl=515,Zd=516,$d=517,il=518,Kd=519,$c=35044;var dh="300 es",Tn=2e3,or=2001;function og(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function ag(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function ar(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Jd(){let i=ar("canvas");return i.style.display="block",i}var Zu={},Ms=null;function fh(...i){let e="THREE."+i.shift();Ms?Ms("log",e,...i):console.log(e,...i)}function jd(i){let e=i[0];if(typeof e=="string"&&e.startsWith("TSL:")){let t=i[1];t&&t.isStackTrace?i[0]+=" "+t.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function Te(...i){i=jd(i);let e="THREE."+i.shift();if(Ms)Ms("warn",e,...i);else{let t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function Re(...i){i=jd(i);let e="THREE."+i.shift();if(Ms)Ms("error",e,...i);else{let t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function qo(...i){let e=i.join(" ");e in Zu||(Zu[e]=!0,Te(...i))}function Qd(i,e,t){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}var ef={[ko]:Oo,[Uo]:Vo,[Bo]:Go,[Zi]:zo,[Oo]:ko,[Vo]:Uo,[Go]:Bo,[zo]:Zi},An=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let s=n[e];if(s!==void 0){let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let s=n.slice(0);for(let r=0,o=s.length;r>8&255]+Vt[i>>16&255]+Vt[i>>24&255]+"-"+Vt[e&255]+Vt[e>>8&255]+"-"+Vt[e>>16&15|64]+Vt[e>>24&255]+"-"+Vt[t&63|128]+Vt[t>>8&255]+"-"+Vt[t>>16&255]+Vt[t>>24&255]+Vt[n&255]+Vt[n>>8&255]+Vt[n>>16&255]+Vt[n>>24&255]).toLowerCase()}function He(i,e,t){return Math.max(e,Math.min(t,i))}function ph(i,e){return(i%e+e)%e}function lg(i,e,t,n,s){return n+(i-e)*(s-n)/(t-e)}function cg(i,e,t){return i!==e?(t-i)/(e-i):0}function nr(i,e,t){return(1-t)*i+t*e}function hg(i,e,t,n){return nr(i,e,1-Math.exp(-t*n))}function ug(i,e=1){return e-Math.abs(ph(i,e*2)-e)}function dg(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function fg(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function pg(i,e){return i+Math.floor(Math.random()*(e-i+1))}function mg(i,e){return i+Math.random()*(e-i)}function gg(i){return i*(.5-Math.random())}function xg(i){i!==void 0&&($u=i);let e=$u+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function vg(i){return i*tr}function _g(i){return i*Ss}function yg(i){return(i&i-1)===0&&i!==0}function bg(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Mg(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Sg(i,e,t,n,s){let r=Math.cos,o=Math.sin,a=r(t/2),l=o(t/2),c=r((e+n)/2),h=o((e+n)/2),d=r((e-n)/2),u=o((e-n)/2),f=r((n-e)/2),m=o((n-e)/2);switch(s){case"XYX":i.set(a*h,l*d,l*u,a*c);break;case"YZY":i.set(l*u,a*h,l*d,a*c);break;case"ZXZ":i.set(l*d,l*u,a*h,a*c);break;case"XZX":i.set(a*h,l*m,l*f,a*c);break;case"YXY":i.set(l*f,a*h,l*m,a*c);break;case"ZYZ":i.set(l*m,l*f,a*h,a*c);break;default:Te("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function ys(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function Zt(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}var sl={DEG2RAD:tr,RAD2DEG:Ss,generateUUID:Ls,clamp:He,euclideanModulo:ph,mapLinear:lg,inverseLerp:cg,lerp:nr,damp:hg,pingpong:ug,smoothstep:dg,smootherstep:fg,randInt:pg,randFloat:mg,randFloatSpread:gg,seededRandom:xg,degToRad:vg,radToDeg:_g,isPowerOfTwo:yg,ceilPowerOfTwo:bg,floorPowerOfTwo:Mg,setQuaternionFromProperEuler:Sg,normalize:Zt,denormalize:ys},_h=class _h{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=He(this.x,e.x,t.x),this.y=He(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=He(this.x,e,t),this.y=He(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(He(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(He(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),s=Math.sin(t),r=this.x-e.x,o=this.y-e.y;return this.x=r*n-o*s+e.x,this.y=r*s+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};_h.prototype.isVector2=!0;var Ae=_h,vn=class{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,r,o,a){let l=n[s+0],c=n[s+1],h=n[s+2],d=n[s+3],u=r[o+0],f=r[o+1],m=r[o+2],x=r[o+3];if(d!==x||l!==u||c!==f||h!==m){let g=l*u+c*f+h*m+d*x;g<0&&(u=-u,f=-f,m=-m,x=-x,g=-g);let p=1-a;if(g<.9995){let v=Math.acos(g),b=Math.sin(v);p=Math.sin(p*v)/b,a=Math.sin(a*v)/b,l=l*p+u*a,c=c*p+f*a,h=h*p+m*a,d=d*p+x*a}else{l=l*p+u*a,c=c*p+f*a,h=h*p+m*a,d=d*p+x*a;let v=1/Math.sqrt(l*l+c*c+h*h+d*d);l*=v,c*=v,h*=v,d*=v}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,n,s,r,o){let a=n[s],l=n[s+1],c=n[s+2],h=n[s+3],d=r[o],u=r[o+1],f=r[o+2],m=r[o+3];return e[t]=a*m+h*d+l*f-c*u,e[t+1]=l*m+h*u+c*d-a*f,e[t+2]=c*m+h*f+a*u-l*d,e[t+3]=h*m-a*d-l*u-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,s){return this._x=e,this._y=t,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,s=e._y,r=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(n/2),h=a(s/2),d=a(r/2),u=l(n/2),f=l(s/2),m=l(r/2);switch(o){case"XYZ":this._x=u*h*d+c*f*m,this._y=c*f*d-u*h*m,this._z=c*h*m+u*f*d,this._w=c*h*d-u*f*m;break;case"YXZ":this._x=u*h*d+c*f*m,this._y=c*f*d-u*h*m,this._z=c*h*m-u*f*d,this._w=c*h*d+u*f*m;break;case"ZXY":this._x=u*h*d-c*f*m,this._y=c*f*d+u*h*m,this._z=c*h*m+u*f*d,this._w=c*h*d-u*f*m;break;case"ZYX":this._x=u*h*d-c*f*m,this._y=c*f*d+u*h*m,this._z=c*h*m-u*f*d,this._w=c*h*d+u*f*m;break;case"YZX":this._x=u*h*d+c*f*m,this._y=c*f*d+u*h*m,this._z=c*h*m-u*f*d,this._w=c*h*d-u*f*m;break;case"XZY":this._x=u*h*d-c*f*m,this._y=c*f*d-u*h*m,this._z=c*h*m+u*f*d,this._w=c*h*d+u*f*m;break;default:Te("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,s=Math.sin(n);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],s=t[4],r=t[8],o=t[1],a=t[5],l=t[9],c=t[2],h=t[6],d=t[10],u=n+a+d;if(u>0){let f=.5/Math.sqrt(u+1);this._w=.25/f,this._x=(h-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=(h-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+h)/f}else{let f=2*Math.sqrt(1+d-n-a);this._w=(o-s)/f,this._x=(r+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(He(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let s=Math.min(1,t/n);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,s=e._y,r=e._z,o=e._w,a=t._x,l=t._y,c=t._z,h=t._w;return this._x=n*h+o*a+s*c-r*l,this._y=s*h+o*l+r*a-n*c,this._z=r*h+o*c+n*l-s*a,this._w=o*h-n*a-s*l-r*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,s=e._y,r=e._z,o=e._w,a=this.dot(e);a<0&&(n=-n,s=-s,r=-r,o=-o,a=-a);let l=1-t;if(a<.9995){let c=Math.acos(a),h=Math.sin(c);l=Math.sin(l*c)/h,t=Math.sin(t*c)/h,this._x=this._x*l+n*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+o*t,this._onChangeCallback()}else this._x=this._x*l+n*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+o*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},yh=class yh{constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Ku.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ku.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*s,this.y=r[1]*t+r[4]*n+r[7]*s,this.z=r[2]*t+r[5]*n+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,s=this.z,r=e.elements,o=1/(r[3]*t+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*s+r[12])*o,this.y=(r[1]*t+r[5]*n+r[9]*s+r[13])*o,this.z=(r[2]*t+r[6]*n+r[10]*s+r[14])*o,this}applyQuaternion(e){let t=this.x,n=this.y,s=this.z,r=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*s-a*n),h=2*(a*t-r*s),d=2*(r*n-o*t);return this.x=t+l*c+o*d-a*h,this.y=n+l*h+a*c-r*d,this.z=s+l*d+r*h-o*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*s,this.y=r[1]*t+r[5]*n+r[9]*s,this.z=r[2]*t+r[6]*n+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=He(this.x,e.x,t.x),this.y=He(this.y,e.y,t.y),this.z=He(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=He(this.x,e,t),this.y=He(this.y,e,t),this.z=He(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(He(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,s=e.y,r=e.z,o=t.x,a=t.y,l=t.z;return this.x=s*l-r*a,this.y=r*o-n*l,this.z=n*a-s*o,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Mc.copy(this).projectOnVector(e),this.sub(Mc)}reflect(e){return this.sub(Mc.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(He(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,s=this.z-e.z;return t*t+n*n+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let s=Math.sin(t)*e;return this.x=s*Math.sin(n),this.y=Math.cos(t)*e,this.z=s*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};yh.prototype.isVector3=!0;var N=yh,Mc=new N,Ku=new vn,bh=class bh{constructor(e,t,n,s,r,o,a,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,o,a,l,c)}set(e,t,n,s,r,o,a,l,c){let h=this.elements;return h[0]=e,h[1]=s,h[2]=a,h[3]=t,h[4]=r,h[5]=l,h[6]=n,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,s=t.elements,r=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],h=n[4],d=n[7],u=n[2],f=n[5],m=n[8],x=s[0],g=s[3],p=s[6],v=s[1],b=s[4],M=s[7],S=s[2],w=s[5],C=s[8];return r[0]=o*x+a*v+l*S,r[3]=o*g+a*b+l*w,r[6]=o*p+a*M+l*C,r[1]=c*x+h*v+d*S,r[4]=c*g+h*b+d*w,r[7]=c*p+h*M+d*C,r[2]=u*x+f*v+m*S,r[5]=u*g+f*b+m*w,r[8]=u*p+f*M+m*C,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8];return t*o*h-t*a*c-n*r*h+n*a*l+s*r*c-s*o*l}invert(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],d=h*o-a*c,u=a*l-h*r,f=c*r-o*l,m=t*d+n*u+s*f;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);let x=1/m;return e[0]=d*x,e[1]=(s*c-h*n)*x,e[2]=(a*n-s*o)*x,e[3]=u*x,e[4]=(h*t-s*l)*x,e[5]=(s*r-a*t)*x,e[6]=f*x,e[7]=(n*l-c*t)*x,e[8]=(o*t-n*r)*x,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,s,r,o,a){let l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*o+c*a)+o+e,-s*c,s*l,-s*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(Sc.makeScale(e,t)),this}rotate(e){return this.premultiply(Sc.makeRotation(-e)),this}translate(e,t){return this.premultiply(Sc.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let s=0;s<9;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};bh.prototype.isMatrix3=!0;var De=bh,Sc=new De,Ju=new De().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ju=new De().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function wg(){let i={enabled:!0,workingColorSpace:sr,spaces:{},convert:function(s,r,o){return this.enabled===!1||r===o||!r||!o||(this.spaces[r].transfer===je&&(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===je&&(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===li?rr: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 qo("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return qo("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(s,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[sr]:{primaries:e,whitePoint:n,transfer:rr,toXYZ:Ju,fromXYZ:ju,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:ln},outputColorSpaceConfig:{drawingBufferColorSpace:ln}},[ln]:{primaries:e,whitePoint:n,transfer:je,toXYZ:Ju,fromXYZ:ju,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:ln}}}),i}var Ge=wg();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,Yo=class{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{ls===void 0&&(ls=ar("canvas")),ls.width=e.width,ls.height=e.height;let s=ls.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=ls}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=ar("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let s=n.getImageData(0,0,e.width,e.height),r=s.data;for(let o=0;o1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Ec).x}get height(){return this.source.getSize(Ec).y}get depth(){return this.source.getSize(Ec).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){Te(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let s=this[t];if(s===void 0){Te(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==ih)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ho:e.x=e.x-Math.floor(e.x);break;case Un:e.x=e.x<0?0:1;break;case Wo:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Ho:e.y=e.y-Math.floor(e.y);break;case Un:e.y=e.y<0?0:1;break;case Wo:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};jt.DEFAULT_IMAGE=null;jt.DEFAULT_MAPPING=ih;jt.DEFAULT_ANISOTROPY=1;var Mh=class Mh{constructor(e=0,t=0,n=0,s=1){this.x=e,this.y=t,this.z=n,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,s){return this.x=e,this.y=t,this.z=n,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,s=this.z,r=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*s+o[12]*r,this.y=o[1]*t+o[5]*n+o[9]*s+o[13]*r,this.z=o[2]*t+o[6]*n+o[10]*s+o[14]*r,this.w=o[3]*t+o[7]*n+o[11]*s+o[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,s,r,l=e.elements,c=l[0],h=l[4],d=l[8],u=l[1],f=l[5],m=l[9],x=l[2],g=l[6],p=l[10];if(Math.abs(h-u)<.01&&Math.abs(d-x)<.01&&Math.abs(m-g)<.01){if(Math.abs(h+u)<.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;t=Math.PI;let b=(c+1)/2,M=(f+1)/2,S=(p+1)/2,w=(h+u)/4,C=(d+x)/4,_=(m+g)/4;return b>M&&b>S?b<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(b),s=w/n,r=C/n):M>S?M<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(M),n=w/s,r=_/s):S<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(S),n=C/r,s=_/r),this.set(n,s,r,t),this}let v=Math.sqrt((g-m)*(g-m)+(d-x)*(d-x)+(u-h)*(u-h));return Math.abs(v)<.001&&(v=1),this.x=(g-m)/v,this.y=(d-x)/v,this.z=(u-h)/v,this.w=Math.acos((c+f+p-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=He(this.x,e.x,t.x),this.y=He(this.y,e.y,t.y),this.z=He(this.z,e.z,t.z),this.w=He(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=He(this.x,e,t),this.y=He(this.y,e,t),this.z=He(this.z,e,t),this.w=He(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(He(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};Mh.prototype.isVector4=!0;var vt=Mh,Zo=class extends An{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ut,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new vt(0,0,e,t),this.scissorTest=!1,this.viewport=new vt(0,0,e,t),this.textures=[];let s={width:e,height:t,depth:n.depth},r=new jt(s),o=n.count;for(let a=0;a1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0&&(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(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);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,h=l.length;c0){s.children=[];for(let a=0;a0){s.animations=[];for(let a=0;a0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),d.length>0&&(n.shapes=d),u.length>0&&(n.skeletons=u),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 h=a[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;nf+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&u<=f-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:e,target:this})));a!==null&&(s=t.getPose(e.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(Ng)))}return a!==null&&(a.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new ei;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},tf={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},ho={h:0,s:0,l:0};function Ac(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}var ge=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=ln){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ge.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=Ge.workingColorSpace){return this.r=e,this.g=t,this.b=n,Ge.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=Ge.workingColorSpace){if(e=ph(e,1),t=He(t,0,1),n=He(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,o=2*n-r;this.r=Ac(o,r,e+1/3),this.g=Ac(o,r,e),this.b=Ac(o,r,e-1/3)}return Ge.colorSpaceToWorking(this,s),this}setStyle(e,t=ln){function n(r){r!==void 0&&parseFloat(r)<1&&Te("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){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,t);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,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Te("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){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,t);if(o===6)return this.setHex(parseInt(r,16),t);Te("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=ln){let n=tf[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Te("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=ti(e.r),this.g=ti(e.g),this.b=ti(e.b),this}copyLinearToSRGB(e){return this.r=bs(e.r),this.g=bs(e.g),this.b=bs(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=ln){return Ge.workingToColorSpace(Gt.copy(this),e),Math.round(He(Gt.r*255,0,255))*65536+Math.round(He(Gt.g*255,0,255))*256+Math.round(He(Gt.b*255,0,255))}getHexString(e=ln){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ge.workingColorSpace){Ge.workingToColorSpace(Gt.copy(this),t);let n=Gt.r,s=Gt.g,r=Gt.b,o=Math.max(n,s,r),a=Math.min(n,s,r),l,c,h=(a+o)/2;if(a===o)l=0,c=0;else{let d=o-a;switch(c=h<=.5?d/(o+a):d/(2-o-a),o){case n:l=(s-r)/d+(s0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},wn=new N,Kn=new N,Cc=new N,Jn=new N,ds=new N,fs=new N,od=new N,Rc=new N,Pc=new N,Ic=new N,Lc=new vt,Nc=new vt,Dc=new vt,bi=class i{constructor(e=new N,t=new N,n=new N){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,s){s.subVectors(n,t),wn.subVectors(e,t),s.cross(wn);let r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,n,s,r){wn.subVectors(s,t),Kn.subVectors(n,t),Cc.subVectors(e,t);let o=wn.dot(wn),a=wn.dot(Kn),l=wn.dot(Cc),c=Kn.dot(Kn),h=Kn.dot(Cc),d=o*c-a*a;if(d===0)return r.set(0,0,0),null;let u=1/d,f=(c*l-a*h)*u,m=(o*h-a*l)*u;return r.set(1-f-m,m,f)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,Jn)===null?!1:Jn.x>=0&&Jn.y>=0&&Jn.x+Jn.y<=1}static getInterpolation(e,t,n,s,r,o,a,l){return this.getBarycoord(e,t,n,s,Jn)===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,Jn.x),l.addScaledVector(o,Jn.y),l.addScaledVector(a,Jn.z),l)}static getInterpolatedAttribute(e,t,n,s,r,o){return Lc.setScalar(0),Nc.setScalar(0),Dc.setScalar(0),Lc.fromBufferAttribute(e,t),Nc.fromBufferAttribute(e,n),Dc.fromBufferAttribute(e,s),o.setScalar(0),o.addScaledVector(Lc,r.x),o.addScaledVector(Nc,r.y),o.addScaledVector(Dc,r.z),o}static isFrontFacing(e,t,n,s){return wn.subVectors(n,t),Kn.subVectors(e,t),wn.cross(Kn).dot(s)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,s){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,n,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return wn.subVectors(this.c,this.b),Kn.subVectors(this.a,this.b),wn.cross(Kn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return i.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return i.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,r){return i.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}containsPoint(e){return i.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return i.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,s=this.b,r=this.c,o,a;ds.subVectors(s,n),fs.subVectors(r,n),Rc.subVectors(e,n);let l=ds.dot(Rc),c=fs.dot(Rc);if(l<=0&&c<=0)return t.copy(n);Pc.subVectors(e,s);let h=ds.dot(Pc),d=fs.dot(Pc);if(h>=0&&d<=h)return t.copy(s);let u=l*d-h*c;if(u<=0&&l>=0&&h<=0)return o=l/(l-h),t.copy(n).addScaledVector(ds,o);Ic.subVectors(e,r);let f=ds.dot(Ic),m=fs.dot(Ic);if(m>=0&&f<=m)return t.copy(r);let x=f*c-l*m;if(x<=0&&c>=0&&m<=0)return a=c/(c-m),t.copy(n).addScaledVector(fs,a);let g=h*m-f*d;if(g<=0&&d-h>=0&&f-m>=0)return od.subVectors(r,s),a=(d-h)/(d-h+(f-m)),t.copy(s).addScaledVector(od,a);let p=1/(g+x+u);return o=x*p,a=u*p,t.copy(n).addScaledVector(ds,o).addScaledVector(fs,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},wi=class{constructor(e=new N(1/0,1/0,1/0),t=new N(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,En),En.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Js),fo.subVectors(this.max,Js),ps.subVectors(e.a,Js),ms.subVectors(e.b,Js),gs.subVectors(e.c,Js),xi.subVectors(ms,ps),vi.subVectors(gs,ms),Gi.subVectors(ps,gs);let t=[0,-xi.z,xi.y,0,-vi.z,vi.y,0,-Gi.z,Gi.y,xi.z,0,-xi.x,vi.z,0,-vi.x,Gi.z,0,-Gi.x,-xi.y,xi.x,0,-vi.y,vi.x,0,-Gi.y,Gi.x,0];return!Fc(t,ps,ms,gs,fo)||(t=[1,0,0,0,1,0,0,0,1],!Fc(t,ps,ms,gs,fo))?!1:(po.crossVectors(xi,vi),t=[po.x,po.y,po.z],Fc(t,ps,ms,gs,fo))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,En).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(En).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(jn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),jn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),jn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),jn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),jn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),jn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),jn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),jn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(jn),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},jn=[new N,new N,new N,new N,new N,new N,new N,new N],En=new N,uo=new wi,ps=new N,ms=new N,gs=new N,xi=new N,vi=new N,Gi=new N,Js=new N,fo=new N,po=new N,Hi=new N;function Fc(i,e,t,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=e.dot(Hi),c=t.dot(Hi),h=n.dot(Hi);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}var wt=new N,mo=new Ae,Dg=0,Ye=class extends An{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Dg++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=$c,this.updateRanges=[],this.gpuType=Pn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let s=0,r=this.itemSize;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;js.subVectors(e,this.center);let t=js.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(js,s/n),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(kc.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(js.copy(e.center).add(kc)),this.expandByPoint(js.copy(e.center).sub(kc))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},kg=0,xn=new xt,Oc=new Qt,xs=new N,an=new wi,Qs=new wi,It=new N,ht=class i extends An{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:kg++}),this.uuid=Ls(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(og(e)?ur:hr)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let r=new De().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return xn.makeRotationFromQuaternion(e),this.applyMatrix4(xn),this}rotateX(e){return xn.makeRotationX(e),this.applyMatrix4(xn),this}rotateY(e){return xn.makeRotationY(e),this.applyMatrix4(xn),this}rotateZ(e){return xn.makeRotationZ(e),this.applyMatrix4(xn),this}translate(e,t,n){return xn.makeTranslation(e,t,n),this.applyMatrix4(xn),this}scale(e,t,n){return xn.makeScale(e,t,n),this.applyMatrix4(xn),this}lookAt(e){return Oc.lookAt(e),Oc.updateMatrix(),this.applyMatrix4(Oc.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(xs).negate(),this.translate(xs.x,xs.y,xs.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let s=0,r=e.length;st.count&&Te("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new wi);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Re("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new N(-1/0,-1/0,-1/0),new N(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,s=t.length;n0&&(e.userData=this.userData),this.parameters!==void 0){let l=this.parameters;for(let c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let l in n){let c=n[l];e.data.attributes[l]=c.toJSON(e.data)}let s={},r=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],h=[];for(let d=0,u=c.length;d0&&(s[l]=h,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere=a.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let s=e.attributes;for(let c in s){let h=s[c];this.setAttribute(c,h.clone(t))}let r=e.morphAttributes;for(let c in r){let h=[],d=r[c];for(let u=0,f=d.length;u0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){Te(`Material: parameter '${t}' has value of undefined.`);continue}let s=this[t];if(s===void 0){Te(`Material: '${t}' 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[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={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(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Yi&&(n.blending=this.blending),this.side!==ni&&(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!==Do&&(n.blendSrc=this.blendSrc),this.blendDst!==Fo&&(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!==Zc&&(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(t){let r=s(e.textures),o=s(e.images);r.length>0&&(n.textures=r),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let s=t.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}};var Qn=new N,Uc=new N,go=new N,_i=new N,Bc=new N,xo=new N,zc=new N,Ts=class{constructor(e=new N,t=new N(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Qn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Qn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Qn.copy(this.origin).addScaledVector(this.direction,t),Qn.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){Uc.copy(e).add(t).multiplyScalar(.5),go.copy(t).sub(e).normalize(),_i.copy(this.origin).sub(Uc);let r=e.distanceTo(t)*.5,o=-this.direction.dot(go),a=_i.dot(this.direction),l=-_i.dot(go),c=_i.lengthSq(),h=Math.abs(1-o*o),d,u,f,m;if(h>0)if(d=o*l-a,u=o*a-l,m=r*h,d>=0)if(u>=-m)if(u<=m){let x=1/h;d*=x,u*=x,f=d*(d+o*u+2*a)+u*(o*d+u+2*l)+c}else u=r,d=Math.max(0,-(o*u+a)),f=-d*d+u*(u+2*l)+c;else u=-r,d=Math.max(0,-(o*u+a)),f=-d*d+u*(u+2*l)+c;else u<=-m?(d=Math.max(0,-(-o*r+a)),u=d>0?-r:Math.min(Math.max(-r,-l),r),f=-d*d+u*(u+2*l)+c):u<=m?(d=0,u=Math.min(Math.max(-r,-l),r),f=u*(u+2*l)+c):(d=Math.max(0,-(o*r+a)),u=d>0?r:Math.min(Math.max(-r,-l),r),f=-d*d+u*(u+2*l)+c);else u=o>0?-r:r,d=Math.max(0,-(o*u+a)),f=-d*d+u*(u+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(Uc).addScaledVector(go,u),f}intersectSphere(e,t){Qn.subVectors(e.center,this.origin);let n=Qn.dot(this.direction),s=Qn.dot(Qn)-n*n,r=e.radius*e.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,t):this.at(a,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,s,r,o,a,l,c=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,u=this.origin;return c>=0?(n=(e.min.x-u.x)*c,s=(e.max.x-u.x)*c):(n=(e.max.x-u.x)*c,s=(e.min.x-u.x)*c),h>=0?(r=(e.min.y-u.y)*h,o=(e.max.y-u.y)*h):(r=(e.max.y-u.y)*h,o=(e.min.y-u.y)*h),n>o||r>s||((r>n||isNaN(n))&&(n=r),(o=0?(a=(e.min.z-u.z)*d,l=(e.max.z-u.z)*d):(a=(e.max.z-u.z)*d,l=(e.min.z-u.z)*d),n>l||a>s)||((a>n||n!==n)&&(n=a),(l=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,Qn)!==null}intersectTriangle(e,t,n,s,r){Bc.subVectors(t,e),xo.subVectors(n,e),zc.crossVectors(Bc,xo);let o=this.direction.dot(zc),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,e);let l=a*this.direction.dot(xo.crossVectors(_i,xo));if(l<0)return null;let c=a*this.direction.dot(Bc.cross(_i));if(c<0||l+c>o)return null;let h=-a*_i.dot(zc);return h<0?null:this.at(h/o,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},si=class extends ii{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ge(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=nh,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},ad=new xt,Wi=new Ts,vo=new Ei,ld=new N,_o=new N,yo=new N,bo=new N,Vc=new N,Mo=new N,cd=new N,So=new N,Wt=class extends Qt{constructor(e=new ht,t=new si){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;r(e.far-e.near)**2))&&(ad.copy(r).invert(),Wi.copy(e.ray).applyMatrix4(ad),!(n.boundingBox!==null&&Wi.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Wi)))}_computeIntersections(e,t,n){let s,r=this.geometry,o=this.material,a=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,d=r.attributes.normal,u=r.groups,f=r.drawRange;if(a!==null)if(Array.isArray(o))for(let m=0,x=u.length;mt.far?null:{distance:c,point:So.clone(),object:i}}function wo(i,e,t,n,s,r,o,a,l,c){i.getVertexPosition(a,_o),i.getVertexPosition(l,yo),i.getVertexPosition(c,bo);let h=Ug(i,e,t,n,_o,yo,bo,cd);if(h){let d=new N;bi.getBarycoord(cd,_o,yo,bo,d),s&&(h.uv=bi.getInterpolatedAttribute(s,a,l,c,d,new Ae)),r&&(h.uv1=bi.getInterpolatedAttribute(r,a,l,c,d,new Ae)),o&&(h.normal=bi.getInterpolatedAttribute(o,a,l,c,d,new N),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let u={a,b:l,c,normal:new N,materialIndex:0};bi.getNormal(_o,yo,bo,u.normal),h.face=u,h.barycoord=d}return h}var Ko=class extends jt{constructor(e=null,t=1,n=1,s,r,o,a,l,c=Lt,h=Lt,d,u){super(null,o,a,l,c,h,s,r,d,u),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Gc=new N,Bg=new N,zg=new De,On=class{constructor(e=new N(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,s){return this.normal.set(e,t,n),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let s=Gc.subVectors(n,t).cross(Bg.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){let s=e.delta(Gc),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let o=-(e.start.dot(this.normal)+this.constant)/r;return n===!0&&(o<0||o>1)?null:t.copy(e.start).addScaledVector(s,o)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||zg.getNormalMatrix(e),s=this.coplanarPoint(Gc).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},Xi=new Ei,Vg=new Ae(.5,.5),Eo=new N,dr=class{constructor(e=new On,t=new On,n=new On,s=new On,r=new On,o=new On){this.planes=[e,t,n,s,r,o]}set(e,t,n,s,r,o){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(s),a[4].copy(r),a[5].copy(o),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Tn,n=!1){let s=this.planes,r=e.elements,o=r[0],a=r[1],l=r[2],c=r[3],h=r[4],d=r[5],u=r[6],f=r[7],m=r[8],x=r[9],g=r[10],p=r[11],v=r[12],b=r[13],M=r[14],S=r[15];if(s[0].setComponents(c-o,f-h,p-m,S-v).normalize(),s[1].setComponents(c+o,f+h,p+m,S+v).normalize(),s[2].setComponents(c+a,f+d,p+x,S+b).normalize(),s[3].setComponents(c-a,f-d,p-x,S-b).normalize(),n)s[4].setComponents(l,u,g,M).normalize(),s[5].setComponents(c-l,f-u,p-g,S-M).normalize();else if(s[4].setComponents(c-l,f-u,p-g,S-M).normalize(),t===Tn)s[5].setComponents(c+l,f+u,p+g,S+M).normalize();else if(t===or)s[5].setComponents(l,u,g,M).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Xi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Xi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Xi)}intersectsSprite(e){Xi.center.set(0,0,0);let t=Vg.distanceTo(e.center);return Xi.radius=.7071067811865476+t,Xi.applyMatrix4(e.matrixWorld),this.intersectsSphere(Xi)}intersectsSphere(e){let t=this.planes,n=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)0?e.max.x:e.min.x,Eo.y=s.normal.y>0?e.max.y:e.min.y,Eo.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(Eo)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};var zn=class extends ii{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ge(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},Jo=new N,jo=new N,hd=new xt,er=new Ts,To=new Ei,Hc=new N,ud=new N,Qo=class extends Qt{constructor(e=new ht,t=new zn){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let s=1,r=t.count;s0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;rn)return;Hc.applyMatrix4(i.matrixWorld);let c=e.ray.origin.distanceTo(Hc);if(!(ce.far))return{distance:c,point:ud.clone().applyMatrix4(i.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:i}}var dd=new N,fd=new N,ri=class extends Qo{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let s=0,r=t.count;s0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;rs.far)return;r.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:o})}}var fr=class extends jt{constructor(e=[],t=Ii,n,s,r,o,a,l,c,h){super(e,t,n,s,r,o,a,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}};var oi=class extends jt{constructor(e,t,n=Rn,s,r,o,a=Lt,l=Lt,c,h=Bn,d=1){if(h!==Bn&&h!==Ni)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let u={width:e,height:t,depth:d};super(u,s,r,o,a,l,h,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new ws(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},ea=class extends oi{constructor(e,t=Rn,n=Ii,s,r,o=Lt,a=Lt,l,c=Bn){let h={width:e,height:e,depth:1},d=[h,h,h,h,h,h];super(e,e,t,n,s,r,o,a,l,c),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},pr=class extends jt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},As=class i extends ht{constructor(e=1,t=1,n=1,s=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,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=[],h=[],d=[],u=0,f=0;m("z","y","x",-1,-1,n,t,e,o,r,0),m("z","y","x",1,-1,n,t,-e,o,r,1),m("x","z","y",1,1,e,n,t,s,o,2),m("x","z","y",1,-1,e,n,-t,s,o,3),m("x","y","z",1,-1,e,t,n,s,r,4),m("x","y","z",-1,-1,e,t,-n,s,r,5),this.setIndex(l),this.setAttribute("position",new Ot(c,3)),this.setAttribute("normal",new Ot(h,3)),this.setAttribute("uv",new Ot(d,2));function m(x,g,p,v,b,M,S,w,C,_,A){let P=M/C,R=S/_,I=M/2,H=S/2,W=w/2,F=C+1,O=_+1,U=0,J=0,ee=new N;for(let le=0;le0?1:-1,h.push(ee.x,ee.y,ee.z),d.push(Me/C),d.push(1-le/_),U+=1}}for(let le=0;le<_;le++)for(let ye=0;ye0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}},Cs=class extends ut{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};var ta=class extends ii{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Hd,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},na=class extends ii{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}};function Po(i,e){return!i||i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}var Ai=class{constructor(e,t,n,s){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,s=t[n],r=t[n-1];n:{e:{let o;t:{i:if(!(e=r)){let a=t[1];e=r)break e}o=n,n=0;break t}break n}for(;n>>1;et;)--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 e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(Re("KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,s=this.values,r=n.length;r===0&&(Re("KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==r;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){Re("KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){Re("KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(s!==void 0&&ag(s))for(let a=0,l=s.length;a!==l;++a){let c=s[a];if(isNaN(c)){Re("KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===No,r=e.length-1,o=1;for(let a=1;a0){e[o]=e[r];for(let a=r*n,l=o*n,c=0;c!==n;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*n)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,s=new n(this.name,e,t);return s.createInterpolant=this.createInterpolant,s}};cn.prototype.ValueTypeName="";cn.prototype.TimeBufferType=Float32Array;cn.prototype.ValueBufferType=Float32Array;cn.prototype.DefaultInterpolation=Xo;var Ci=class extends cn{constructor(e,t,n){super(e,t,n)}};Ci.prototype.ValueTypeName="bool";Ci.prototype.ValueBufferType=Array;Ci.prototype.DefaultInterpolation=ir;Ci.prototype.InterpolantFactoryMethodLinear=void 0;Ci.prototype.InterpolantFactoryMethodSmooth=void 0;var aa=class extends cn{constructor(e,t,n,s){super(e,t,n,s)}};aa.prototype.ValueTypeName="color";var la=class extends cn{constructor(e,t,n,s){super(e,t,n,s)}};la.prototype.ValueTypeName="number";var ca=class extends Ai{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-t)/(s-t),c=e*a;for(let h=c+a;c!==h;c+=4)vn.slerpFlat(r,0,o,c-a,o,c,l);return r}},gr=class extends cn{constructor(e,t,n,s){super(e,t,n,s)}InterpolantFactoryMethodLinear(e){return new ca(this.times,this.values,this.getValueSize(),e)}};gr.prototype.ValueTypeName="quaternion";gr.prototype.InterpolantFactoryMethodSmooth=void 0;var Ri=class extends cn{constructor(e,t,n){super(e,t,n)}};Ri.prototype.ValueTypeName="string";Ri.prototype.ValueBufferType=Array;Ri.prototype.DefaultInterpolation=ir;Ri.prototype.InterpolantFactoryMethodLinear=void 0;Ri.prototype.InterpolantFactoryMethodSmooth=void 0;var ha=class extends cn{constructor(e,t,n,s){super(e,t,n,s)}};ha.prototype.ValueTypeName="vector";var ua=class{constructor(e,t,n){let s=this,r=!1,o=0,a=0,l,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(h){a++,r===!1&&s.onStart!==void 0&&s.onStart(h,o,a),r=!0},this.itemEnd=function(h){o++,s.onProgress!==void 0&&s.onProgress(h,o,a),o===a&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(h){s.onError!==void 0&&s.onError(h)},this.resolveURL=function(h){return l?l(h):h},this.setURLModifier=function(h){return l=h,this},this.addHandler=function(h,d){return c.push(h,d),this},this.removeHandler=function(h){let d=c.indexOf(h);return d!==-1&&c.splice(d,2),this},this.getHandler=function(h){for(let d=0,u=c.length;df.start-m.start);let u=0;for(let f=1;f 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`,v0=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,_0=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,y0=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,b0=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #endif`,M0=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) varying vec4 vColor; #endif`,S0=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) varying vec4 vColor; #endif`,w0=`#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`,E0=`#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`,T0=`#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`,A0=`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`,C0=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,R0=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); #endif`,P0=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE emissiveColor = sRGBTransferEOTF( emissiveColor ); #endif totalEmissiveRadiance *= emissiveColor.rgb; #endif`,I0=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,L0="gl_FragColor = linearToOutputTexel( gl_FragColor );",N0=`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 ); }`,D0=`#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`,F0=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform mat3 envMapRotation; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #else uniform sampler2D envMap; #endif #endif`,k0=`#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`,O0=`#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`,U0=`#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`,B0=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,z0=`#ifdef USE_FOG varying float vFogDepth; #endif`,V0=`#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`,G0=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,H0=`#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 }`,W0=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,X0=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,q0=`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`,Y0=`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 `,Z0=`#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`,$0=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,K0=`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`,J0=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,j0=`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`,Q0=`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`,ex=`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 ); }`,tx=` 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`,nx=`#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`,ix=`#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`,sx=`#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`,rx=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,ox=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,ax=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER varying float vFragDepth; varying float vIsPerspective; #endif`,lx=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #endif`,cx=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); #endif diffuseColor *= sampledDiffuseColor; #endif`,hx=`#ifdef USE_MAP uniform sampler2D map; #endif`,ux=`#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`,dx=`#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`,fx=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; #endif`,px=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,mx=`#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`,gx=`#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`,xx=`#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`,vx=`#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`,_x=`#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`,yx=`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;`,bx=`#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`,Mx=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,Sx=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,wx=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`,Ex=`#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`,Tx=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; #endif`,Ax=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); #endif`,Cx=`#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`,Rx=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,Px=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Ix=`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 }`,Lx=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,Nx=`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;`,Dx=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,Fx=`#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`,kx=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; #endif`,Ox=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,Ux=`#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`,Bx=`#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`,zx=`#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`,Vx=`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; }`,Gx=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,Hx=`#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`,Wx=`#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`,Xx=`#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`,qx=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,Yx=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,Zx=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,$x=`#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; }`,Kx=`#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`,Jx=`#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`,jx=`#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`,Qx=`#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`,ev=`#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`,tv=`#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`,nv=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,iv=`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 #include }`,sv=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,rv=`#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 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 #include }`,ov=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,av=`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 #include }`,lv=`#include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include #include #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vHighPrecisionZW = gl_Position.zw; }`,cv=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include #include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { vec4 diffuseColor = vec4( 1.0 ); #include #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #include #include #include #include #include #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 }`,hv=`#define DISTANCE varying vec3 vWorldPosition; #include #include #include #include #include #include #include void main() { #include #include #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vWorldPosition = worldPosition.xyz; }`,uv=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include #include #include #include #include #include #include void main () { vec4 diffuseColor = vec4( 1.0 ); #include #include #include #include #include float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); }`,dv=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,fv=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`,pv=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include #include #include #include #include #include #include void main() { vLineDistance = scale * lineDistance; #include #include #include #include #include #include #include #include #include #include }`,mv=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include if ( mod( vLineDistance, totalSize ) > dashSize ) { discard; } vec3 outgoingLight = vec3( 0.0 ); #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,gv=`#include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) #include #include #include #include #include #endif #include #include #include #include #include #include #include #include #include }`,xv=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include #include 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 reflectedLight.indirectDiffuse *= diffuseColor.rgb; vec3 outgoingLight = reflectedLight.indirectDiffuse; #include #include #include #include #include #include #include }`,vv=`#define LAMBERT varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,_v=`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,yv=`#define MATCAP varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; }`,bv=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include #include #include 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 #include #include #include #include #include }`,Mv=`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) vViewPosition = - mvPosition.xyz; #endif }`,Sv=`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); #include #include #include #include gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); #ifdef OPAQUE gl_FragColor.a = 1.0; #endif }`,wv=`#define PHONG varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,Ev=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,Tv=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; #endif #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif }`,Av=`#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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; #include 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 #include #include #include #include #include }`,Cv=`#define TOON varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`,Rv=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include }`,Pv=`uniform float size; uniform float scale; #include #include #include #include #include #include #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 #include #include #include #include #include gl_PointSize = size; #ifdef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); #endif #include #include #include #include }`,Iv=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include vec3 outgoingLight = vec3( 0.0 ); #include #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,Lv=`#include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include }`,Nv=`uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include void main() { #include gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include #include }`,Dv=`uniform float rotation; uniform vec2 center; #include #include #include #include #include void main() { #include 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 #include #include }`,Fv=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include vec3 outgoingLight = vec3( 0.0 ); #include #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include }`,ze={alphahash_fragment:n0,alphahash_pars_fragment:i0,alphamap_fragment:s0,alphamap_pars_fragment:r0,alphatest_fragment:o0,alphatest_pars_fragment:a0,aomap_fragment:l0,aomap_pars_fragment:c0,batching_pars_vertex:h0,batching_vertex:u0,begin_vertex:d0,beginnormal_vertex:f0,bsdfs:p0,iridescence_fragment:m0,bumpmap_pars_fragment:g0,clipping_planes_fragment:x0,clipping_planes_pars_fragment:v0,clipping_planes_pars_vertex:_0,clipping_planes_vertex:y0,color_fragment:b0,color_pars_fragment:M0,color_pars_vertex:S0,color_vertex:w0,common:E0,cube_uv_reflection_fragment:T0,defaultnormal_vertex:A0,displacementmap_pars_vertex:C0,displacementmap_vertex:R0,emissivemap_fragment:P0,emissivemap_pars_fragment:I0,colorspace_fragment:L0,colorspace_pars_fragment:N0,envmap_fragment:D0,envmap_common_pars_fragment:F0,envmap_pars_fragment:k0,envmap_pars_vertex:O0,envmap_physical_pars_fragment:Z0,envmap_vertex:U0,fog_vertex:B0,fog_pars_vertex:z0,fog_fragment:V0,fog_pars_fragment:G0,gradientmap_pars_fragment:H0,lightmap_pars_fragment:W0,lights_lambert_fragment:X0,lights_lambert_pars_fragment:q0,lights_pars_begin:Y0,lights_toon_fragment:$0,lights_toon_pars_fragment:K0,lights_phong_fragment:J0,lights_phong_pars_fragment:j0,lights_physical_fragment:Q0,lights_physical_pars_fragment:ex,lights_fragment_begin:tx,lights_fragment_maps:nx,lights_fragment_end:ix,lightprobes_pars_fragment:sx,logdepthbuf_fragment:rx,logdepthbuf_pars_fragment:ox,logdepthbuf_pars_vertex:ax,logdepthbuf_vertex:lx,map_fragment:cx,map_pars_fragment:hx,map_particle_fragment:ux,map_particle_pars_fragment:dx,metalnessmap_fragment:fx,metalnessmap_pars_fragment:px,morphinstance_vertex:mx,morphcolor_vertex:gx,morphnormal_vertex:xx,morphtarget_pars_vertex:vx,morphtarget_vertex:_x,normal_fragment_begin:yx,normal_fragment_maps:bx,normal_pars_fragment:Mx,normal_pars_vertex:Sx,normal_vertex:wx,normalmap_pars_fragment:Ex,clearcoat_normal_fragment_begin:Tx,clearcoat_normal_fragment_maps:Ax,clearcoat_pars_fragment:Cx,iridescence_pars_fragment:Rx,opaque_fragment:Px,packing:Ix,premultiplied_alpha_fragment:Lx,project_vertex:Nx,dithering_fragment:Dx,dithering_pars_fragment:Fx,roughnessmap_fragment:kx,roughnessmap_pars_fragment:Ox,shadowmap_pars_fragment:Ux,shadowmap_pars_vertex:Bx,shadowmap_vertex:zx,shadowmask_pars_fragment:Vx,skinbase_vertex:Gx,skinning_pars_vertex:Hx,skinning_vertex:Wx,skinnormal_vertex:Xx,specularmap_fragment:qx,specularmap_pars_fragment:Yx,tonemapping_fragment:Zx,tonemapping_pars_fragment:$x,transmission_fragment:Kx,transmission_pars_fragment:Jx,uv_pars_fragment:jx,uv_pars_vertex:Qx,uv_vertex:ev,worldpos_vertex:tv,background_vert:nv,background_frag:iv,backgroundCube_vert:sv,backgroundCube_frag:rv,cube_vert:ov,cube_frag:av,depth_vert:lv,depth_frag:cv,distance_vert:hv,distance_frag:uv,equirect_vert:dv,equirect_frag:fv,linedashed_vert:pv,linedashed_frag:mv,meshbasic_vert:gv,meshbasic_frag:xv,meshlambert_vert:vv,meshlambert_frag:_v,meshmatcap_vert:yv,meshmatcap_frag:bv,meshnormal_vert:Mv,meshnormal_frag:Sv,meshphong_vert:wv,meshphong_frag:Ev,meshphysical_vert:Tv,meshphysical_frag:Av,meshtoon_vert:Cv,meshtoon_frag:Rv,points_vert:Pv,points_frag:Iv,shadow_vert:Lv,shadow_frag:Nv,sprite_vert:Dv,sprite_frag:Fv},he={common:{diffuse:{value:new ge(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new De},alphaMap:{value:null},alphaMapTransform:{value:new De},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new De}},envmap:{envMap:{value:null},envMapRotation:{value:new De},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new De}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new De}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new De},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new De},normalScale:{value:new Ae(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new De},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new De}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new De}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new De}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ge(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 N},probesMax:{value:new N},probesResolution:{value:new N}},points:{diffuse:{value:new ge(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new De},alphaTest:{value:0},uvTransform:{value:new De}},sprite:{diffuse:{value:new ge(16777215)},opacity:{value:1},center:{value:new Ae(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new De},alphaMap:{value:null},alphaMapTransform:{value:new De},alphaTest:{value:0}}},Xn={basic:{uniforms:qt([he.common,he.specularmap,he.envmap,he.aomap,he.lightmap,he.fog]),vertexShader:ze.meshbasic_vert,fragmentShader:ze.meshbasic_frag},lambert:{uniforms:qt([he.common,he.specularmap,he.envmap,he.aomap,he.lightmap,he.emissivemap,he.bumpmap,he.normalmap,he.displacementmap,he.fog,he.lights,{emissive:{value:new ge(0)},envMapIntensity:{value:1}}]),vertexShader:ze.meshlambert_vert,fragmentShader:ze.meshlambert_frag},phong:{uniforms:qt([he.common,he.specularmap,he.envmap,he.aomap,he.lightmap,he.emissivemap,he.bumpmap,he.normalmap,he.displacementmap,he.fog,he.lights,{emissive:{value:new ge(0)},specular:{value:new ge(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:ze.meshphong_vert,fragmentShader:ze.meshphong_frag},standard:{uniforms:qt([he.common,he.envmap,he.aomap,he.lightmap,he.emissivemap,he.bumpmap,he.normalmap,he.displacementmap,he.roughnessmap,he.metalnessmap,he.fog,he.lights,{emissive:{value:new ge(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ze.meshphysical_vert,fragmentShader:ze.meshphysical_frag},toon:{uniforms:qt([he.common,he.aomap,he.lightmap,he.emissivemap,he.bumpmap,he.normalmap,he.displacementmap,he.gradientmap,he.fog,he.lights,{emissive:{value:new ge(0)}}]),vertexShader:ze.meshtoon_vert,fragmentShader:ze.meshtoon_frag},matcap:{uniforms:qt([he.common,he.bumpmap,he.normalmap,he.displacementmap,he.fog,{matcap:{value:null}}]),vertexShader:ze.meshmatcap_vert,fragmentShader:ze.meshmatcap_frag},points:{uniforms:qt([he.points,he.fog]),vertexShader:ze.points_vert,fragmentShader:ze.points_frag},dashed:{uniforms:qt([he.common,he.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ze.linedashed_vert,fragmentShader:ze.linedashed_frag},depth:{uniforms:qt([he.common,he.displacementmap]),vertexShader:ze.depth_vert,fragmentShader:ze.depth_frag},normal:{uniforms:qt([he.common,he.bumpmap,he.normalmap,he.displacementmap,{opacity:{value:1}}]),vertexShader:ze.meshnormal_vert,fragmentShader:ze.meshnormal_frag},sprite:{uniforms:qt([he.sprite,he.fog]),vertexShader:ze.sprite_vert,fragmentShader:ze.sprite_frag},background:{uniforms:{uvTransform:{value:new De},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ze.background_vert,fragmentShader:ze.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new De}},vertexShader:ze.backgroundCube_vert,fragmentShader:ze.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ze.cube_vert,fragmentShader:ze.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ze.equirect_vert,fragmentShader:ze.equirect_frag},distance:{uniforms:qt([he.common,he.displacementmap,{referencePosition:{value:new N},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ze.distance_vert,fragmentShader:ze.distance_frag},shadow:{uniforms:qt([he.lights,he.fog,{color:{value:new ge(0)},opacity:{value:1}}]),vertexShader:ze.shadow_vert,fragmentShader:ze.shadow_frag}};Xn.physical={uniforms:qt([Xn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new De},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new De},clearcoatNormalScale:{value:new Ae(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new De},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new De},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new De},sheen:{value:0},sheenColor:{value:new ge(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new De},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new De},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new De},transmissionSamplerSize:{value:new Ae},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new De},attenuationDistance:{value:0},attenuationColor:{value:new ge(0)},specularColor:{value:new ge(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new De},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new De},anisotropyVector:{value:new Ae},anisotropyMap:{value:null},anisotropyMapTransform:{value:new De}}]),vertexShader:ze.meshphysical_vert,fragmentShader:ze.meshphysical_frag};var rl={r:0,b:0,g:0},kv=new xt,Af=new De;Af.set(-1,0,0,0,1,0,0,0,1);function Ov(i,e,t,n,s,r){let o=new ge(0),a=s===!0?0:1,l,c,h=null,d=0,u=null;function f(v){let b=v.isScene===!0?v.background:null;if(b&&b.isTexture){let M=v.backgroundBlurriness>0;b=e.get(b,M)}return b}function m(v){let b=!1,M=f(v);M===null?g(o,a):M&&M.isColor&&(g(M,1),b=!0);let S=i.xr.getEnvironmentBlendMode();S==="additive"?t.buffers.color.setClear(0,0,0,1,r):S==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(i.autoClear||b)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function x(v,b){let M=f(b);M&&(M.isCubeTexture||M.mapping===Cr)?(c===void 0&&(c=new Wt(new As(1,1,1),new ut({name:"BackgroundCubeMaterial",uniforms:Ji(Xn.backgroundCube.uniforms),vertexShader:Xn.backgroundCube.vertexShader,fragmentShader:Xn.backgroundCube.fragmentShader,side:$t,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(S,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=M,c.material.uniforms.backgroundBlurriness.value=b.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(kv.makeRotationFromEuler(b.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(Af),c.material.toneMapped=Ge.getTransfer(M.colorSpace)!==je,(h!==M||d!==M.version||u!==i.toneMapping)&&(c.material.needsUpdate=!0,h=M,d=M.version,u=i.toneMapping),c.layers.enableAll(),v.unshift(c,c.geometry,c.material,0,0,null)):M&&M.isTexture&&(l===void 0&&(l=new Wt(new mr(2,2),new ut({name:"BackgroundMaterial",uniforms:Ji(Xn.background.uniforms),vertexShader:Xn.background.vertexShader,fragmentShader:Xn.background.fragmentShader,side:ni,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=M,l.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,l.material.toneMapped=Ge.getTransfer(M.colorSpace)!==je,M.matrixAutoUpdate===!0&&M.updateMatrix(),l.material.uniforms.uvTransform.value.copy(M.matrix),(h!==M||d!==M.version||u!==i.toneMapping)&&(l.material.needsUpdate=!0,h=M,d=M.version,u=i.toneMapping),l.layers.enableAll(),v.unshift(l,l.geometry,l.material,0,0,null))}function g(v,b){v.getRGB(rl,mh(i)),t.buffers.color.setClear(rl.r,rl.g,rl.b,b,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,b=1){o.set(v),a=b,g(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(v){a=v,g(o,a)},render:m,addToRenderList:x,dispose:p}}function Uv(i,e){let t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=u(null),r=s,o=!1;function a(R,I,H,W,F){let O=!1,U=d(R,W,H,I);r!==U&&(r=U,c(r.object)),O=f(R,W,H,F),O&&m(R,W,H,F),F!==null&&e.update(F,i.ELEMENT_ARRAY_BUFFER),(O||o)&&(o=!1,M(R,I,H,W),F!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(F).buffer))}function l(){return i.createVertexArray()}function c(R){return i.bindVertexArray(R)}function h(R){return i.deleteVertexArray(R)}function d(R,I,H,W){let F=W.wireframe===!0,O=n[I.id];O===void 0&&(O={},n[I.id]=O);let U=R.isInstancedMesh===!0?R.id:0,J=O[U];J===void 0&&(J={},O[U]=J);let ee=J[H.id];ee===void 0&&(ee={},J[H.id]=ee);let le=ee[F];return le===void 0&&(le=u(l()),ee[F]=le),le}function u(R){let I=[],H=[],W=[];for(let F=0;F=0){let ye=F[ee],Me=O[ee];if(Me===void 0&&(ee==="instanceMatrix"&&R.instanceMatrix&&(Me=R.instanceMatrix),ee==="instanceColor"&&R.instanceColor&&(Me=R.instanceColor)),ye===void 0||ye.attribute!==Me||Me&&ye.data!==Me.data)return!0;U++}return r.attributesNum!==U||r.index!==W}function m(R,I,H,W){let F={},O=I.attributes,U=0,J=H.getAttributes();for(let ee in J)if(J[ee].location>=0){let ye=O[ee];ye===void 0&&(ee==="instanceMatrix"&&R.instanceMatrix&&(ye=R.instanceMatrix),ee==="instanceColor"&&R.instanceColor&&(ye=R.instanceColor));let Me={};Me.attribute=ye,ye&&ye.data&&(Me.data=ye.data),F[ee]=Me,U++}r.attributes=F,r.attributesNum=U,r.index=W}function x(){let R=r.newAttributes;for(let I=0,H=R.length;I=0){let le=F[J];if(le===void 0&&(J==="instanceMatrix"&&R.instanceMatrix&&(le=R.instanceMatrix),J==="instanceColor"&&R.instanceColor&&(le=R.instanceColor)),le!==void 0){let ye=le.normalized,Me=le.itemSize,Ze=e.get(le);if(Ze===void 0)continue;let Ke=Ze.buffer,Fe=Ze.type,Z=Ze.bytesPerElement,fe=Fe===i.INT||Fe===i.UNSIGNED_INT||le.gpuType===ya;if(le.isInterleavedBufferAttribute){let se=le.data,Ce=se.stride,ke=le.offset;if(se.isInstancedInterleavedBuffer){for(let Ie=0;Ie0&&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=t.precision!==void 0?t.precision:"highp",h=l(c);h!==c&&(Te("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);let d=t.logarithmicDepthBuffer===!0,u=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&u===!1&&Te("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),b=i.getParameter(i.MAX_VARYING_VECTORS),M=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),S=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:u,maxTextures:f,maxVertexTextures:m,maxTextureSize:x,maxCubemapSize:g,maxAttributes:p,maxVertexUniforms:v,maxVaryings:b,maxFragmentUniforms:M,maxSamples:S,samples:w}}function Vv(i){let e=this,t=null,n=0,s=!1,r=!1,o=new On,a=new De,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){let f=d.length!==0||u||n!==0||s;return s=u,n=d.length,f},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,u){t=h(d,u,0)},this.setState=function(d,u,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?h(null):c();else{let v=r?0:n,b=v*4,M=p.clippingState||null;l.value=M,M=h(m,u,b,f);for(let S=0;S!==b;++S)M[S]=t[S];p.clippingState=M,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=v}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(d,u,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=u.matrixWorldInverse;a.getNormalMatrix(v),(g===null||g.length0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=lf(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=af(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?S:0,S,S),d.setRenderTarget(s),p&&d.render(x,l),d.render(e,l)}d.toneMapping=f,d.autoClear=u,e.background=v}_textureToCubeUV(e,t){let n=this._renderer,s=e.mapping===Ii||e.mapping===Ki;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=lf()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=af());let r=s?this._cubemapMaterial:this._equirectMaterial,o=this._lodMeshes[0];o.material=r;let a=r.uniforms;a.envMap.value=e;let l=this._cubeSize;Ns(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(o,kr)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let s=this._lodMeshes.length;for(let r=1;rm-Fi?n-m+Fi:0),p=4*(this._cubeSize-x);l.envMap.value=e.texture,l.roughness.value=f,l.mipInt.value=m-t,Ns(r,g,p,3*x,2*x),s.setRenderTarget(r),s.render(a,kr),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=m-n,Ns(e,g,p,3*x,2*x),s.setRenderTarget(e),s.render(a,kr)}_blur(e,t,n,s,r){let o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,s,"latitudinal",r),this._halfBlur(o,e,n,n,s,"longitudinal",r)}_halfBlur(e,t,n,s,r,o,a){let l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&Re("blur direction must be either latitudinal or longitudinal!");let h=3,d=this._lodMeshes[s];d.material=c;let u=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(h*x):ji;g>ji&&Te(`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;Cb-Fi?s-b+Fi:0),w=4*(this._cubeSize-M);Ns(t,S,w,3*M,2*M),l.setRenderTarget(t),l.render(d,kr)}};function Wv(i){let e=[],t=[],n=[],s=i,r=i-Fi+1+sf.length;for(let o=0;oi-Fi?l=sf[o-i+Fi-1]:o===0&&(l=0),t.push(l);let c=1/(a-2),h=-c,d=1+c,u=[h,h,d,h,d,d,h,h,d,d,h,d],f=6,m=6,x=3,g=2,p=1,v=new Float32Array(x*m*f),b=new Float32Array(g*m*f),M=new Float32Array(p*m*f);for(let w=0;w2?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),b.set(u,g*m*w);let P=[w,w,w,w,w,w];M.set(P,p*m*w)}let S=new ht;S.setAttribute("position",new Ye(v,x)),S.setAttribute("uv",new Ye(b,g)),S.setAttribute("faceIndex",new Ye(M,p)),n.push(new Wt(S,null)),s>Fi&&s--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function of(i,e,t){let n=new Ct(i,e,t);return n.texture.mapping=Cr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Ns(i,e,t,n,s){i.viewport.set(e,t,n,s),i.scissor.set(e,t,n,s)}function Xv(i,e,t){return new ut({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Gv,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:cl(),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 #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:_n,depthTest:!1,depthWrite:!1})}function qv(i,e,t){let n=new Float32Array(ji),s=new N(0,1,0);return new ut({name:"SphericalGaussianBlur",defines:{n:ji,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:cl(),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 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:_n,depthTest:!1,depthWrite:!1})}function af(){return new ut({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:cl(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; #include void main() { vec3 outputDirection = normalize( vOutputDirection ); vec2 uv = equirectUv( outputDirection ); gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } `,blending:_n,depthTest:!1,depthWrite:!1})}function lf(){return new ut({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:cl(),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:_n,depthTest:!1,depthWrite:!1})}function cl(){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 ll=class extends Ct{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},s=[n,n,n,n,n,n];this.texture=new fr(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;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 #include } `,fragmentShader:` uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); } `},s=new As(5,5,5),r=new ut({name:"CubemapFromEquirect",uniforms:Ji(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:$t,blending:_n});r.uniforms.tEquirect.value=t;let o=new Wt(s,r),a=t.minFilter;return t.minFilter===Li&&(t.minFilter=Ut),new fa(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t=!0,n=!0,s=!0){let r=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,s);e.setRenderTarget(r)}};function Yv(i){let e=new WeakMap,t=new WeakMap,n=null;function s(u,f=!1){return u==null?null:f?o(u):r(u)}function r(u){if(u&&u.isTexture){let f=u.mapping;if(f===xa||f===va)if(e.has(u)){let m=e.get(u).texture;return a(m,u.mapping)}else{let m=u.image;if(m&&m.height>0){let x=new ll(m.height);return x.fromEquirectangularTexture(i,u),e.set(u,x),u.addEventListener("dispose",c),a(x.texture,u.mapping)}else return null}}return u}function o(u){if(u&&u.isTexture){let f=u.mapping,m=f===xa||f===va,x=f===Ii||f===Ki;if(m||x){let g=t.get(u),p=g!==void 0?g.texture.pmremVersion:0;if(u.isRenderTargetTexture&&u.pmremVersion!==p)return n===null&&(n=new al(i)),g=m?n.fromEquirectangular(u,g):n.fromCubemap(u,g),g.texture.pmremVersion=u.pmremVersion,t.set(u,g),g.texture;if(g!==void 0)return g.texture;{let v=u.image;return m&&v&&v.height>0||x&&v&&l(v)?(n===null&&(n=new al(i)),g=m?n.fromEquirectangular(u):n.fromCubemap(u),g.texture.pmremVersion=u.pmremVersion,t.set(u,g),u.addEventListener("dispose",h),g.texture):null}}}return u}function a(u,f){return f===xa?u.mapping=Ii:f===va&&(u.mapping=Ki),u}function l(u){let f=0,m=6;for(let x=0;x=65535?ur:hr)(u,1);g.version=x;let p=r.get(d);p&&e.remove(p),r.set(d,g)}function h(d){let u=r.get(d);if(u){let f=d.index;f!==null&&u.versione.maxTextureSize&&(S=Math.ceil(M/e.maxTextureSize),M=e.maxTextureSize);let w=new Float32Array(M*S*4*d),C=new lr(w,M,S,d);C.type=Pn,C.needsUpdate=!0;let _=b*4;for(let P=0;P #include 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 Wt(a,l),h=new ai(-1,1,1,-1,0,1),d=null,u=null,f=!1,m,x=null,g=[],p=!1;this.setSize=function(v,b){r.setSize(v,b),o.setSize(v,b);for(let M=0;M0&&g[0].isRenderPass===!0;let b=r.width,M=r.height;for(let S=0;S0)return i;let s=e*t,r=cf[s];if(r===void 0&&(r=new Float32Array(s),cf[s]=r),e!==0){n.toArray(r,0);for(let o=1,a=0;o!==e;++o)a+=t,i[o].toArray(r,a)}return r}function Rt(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t0&&(this.seq=s.concat(r))}setValue(e,t,n,s){let r=this.map[t];r!==void 0&&r.setValue(e,n,s)}setOptional(e,t,n){let s=t[n];s!==void 0&&this.setValue(e,n,s)}static upload(e,t,n,s){for(let r=0,o=t.length;r!==o;++r){let a=t[r],l=n[a.id];l.needsUpdate!==!1&&a.setValue(e,l.value,s)}}static seqWithValue(e,t){let n=[];for(let s=0,r=e.length;s!==r;++s){let o=e[s];o.id in t&&n.push(o)}return n}};function mf(i,e,t){let n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}var H_=37297,W_=0;function X_(i,e){let t=i.split(` `),n=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let o=s;o":" "} ${a}: ${t[o]}`)}return n.join(` `)}var gf=new De;function q_(i){Ge._getMatrix(gf,Ge.workingColorSpace,i);let e=`mat3( ${gf.elements.map(t=>t.toFixed(4))} )`;switch(Ge.getTransfer(i)){case rr:return[e,"LinearTransferOETF"];case je:return[e,"sRGBTransferOETF"];default:return Te("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function xf(i,e,t){let n=i.getShaderParameter(e,i.COMPILE_STATUS),r=(i.getShaderInfoLog(e)||"").trim();if(n&&r==="")return"";let o=/ERROR: 0:(\d+)/.exec(r);if(o){let a=parseInt(o[1]);return t.toUpperCase()+` `+r+` `+X_(i.getShaderSource(e),a)}else return r}function Y_(i,e){let t=q_(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` `)}var Z_={[Mr]:"Linear",[Sr]:"Reinhard",[wr]:"Cineon",[Pi]:"ACESFilmic",[Tr]:"AgX",[Ar]:"Neutral",[Er]:"Custom"};function $_(i,e){let t=Z_[e];return t===void 0?(Te("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}var ol=new N;function K_(){Ge.getLuminanceCoefficients(ol);let i=ol.x.toFixed(4),e=ol.y.toFixed(4),t=ol.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` `)}function J_(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Ur).join(` `)}function j_(i){let e=[];for(let t in i){let n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(` `)}function Q_(i,e){let t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let s=0;s/gm;function Dh(i){return i.replace(ey,ny)}var ty=new Map;function ny(i,e){let t=ze[e];if(t===void 0){let n=ty.get(e);if(n!==void 0)t=ze[n],Te('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return Dh(t)}var iy=/#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 yf(i){return i.replace(iy,sy)}function sy(i,e,t,n){let s="";for(let r=parseInt(e);r0&&(g+=` `),p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(Ur).join(` `),p.length>0&&(p+=` `)):(g=[bf(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` `].filter(Ur).join(` `),p=[bf(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+h:"",t.envMap?"#define "+d:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==hn?"#define TONE_MAPPING":"",t.toneMapping!==hn?ze.tonemapping_pars_fragment:"",t.toneMapping!==hn?$_("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",ze.colorspace_pars_fragment,Y_("linearToOutputTexel",t.outputColorSpace),K_(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` `].filter(Ur).join(` `)),o=Dh(o),o=vf(o,t),o=_f(o,t),a=Dh(a),a=vf(a,t),a=_f(a,t),o=yf(o),a=yf(a),t.isRawShaderMaterial!==!0&&(v=`#version 300 es `,g=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+g,p=["#define varying in",t.glslVersion===dh?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===dh?"":"#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 b=v+g+o,M=v+p+a,S=mf(s,s.VERTEX_SHADER,b),w=mf(s,s.FRAGMENT_SHADER,M);s.attachShader(x,S),s.attachShader(x,w),t.index0AttributeName!==void 0?s.bindAttribLocation(x,0,t.index0AttributeName):t.morphTargets===!0&&s.bindAttribLocation(x,0,"position"),s.linkProgram(x);function C(R){if(i.debug.checkShaderErrors){let I=s.getProgramInfoLog(x)||"",H=s.getShaderInfoLog(S)||"",W=s.getShaderInfoLog(w)||"",F=I.trim(),O=H.trim(),U=W.trim(),J=!0,ee=!0;if(s.getProgramParameter(x,s.LINK_STATUS)===!1)if(J=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,x,S,w);else{let le=xf(s,S,"vertex"),ye=xf(s,w,"fragment");Re("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: `+F+` `+le+` `+ye)}else F!==""?Te("WebGLProgram: Program Info Log:",F):(O===""||U==="")&&(ee=!1);ee&&(R.diagnostics={runnable:J,programLog:F,vertexShader:{log:O,prefix:g},fragmentShader:{log:U,prefix:p}})}s.deleteShader(S),s.deleteShader(w),_=new Ds(s,x),A=Q_(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=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return P===!1&&(P=s.getProgramParameter(x,H_)),P},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(x),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=W_++,this.cacheKey=e,this.usedTimes=1,this.program=x,this.vertexShader=S,this.fragmentShader=w,this}var my=0,Fh=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,n=e.fragmentShader,s=this._getShaderStage(t),r=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return o.has(s)===!1&&(o.add(s),s.usedTimes++),o.has(r)===!1&&(o.add(r),r.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new kh(e),t.set(e,n)),n}},kh=class{constructor(e){this.id=my++,this.code=e,this.usedTimes=0}};function gy(i){return i===Di||i===Dr||i===Fr}function xy(i,e,t,n,s,r){let o=new cr,a=new Fh,l=new Set,c=[],h=new Map,d=n.logarithmicDepthBuffer,u=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,I,H){let W=R.fog,F=I.geometry,O=_.isMeshStandardMaterial||_.isMeshLambertMaterial||_.isMeshPhongMaterial?R.environment:null,U=_.isMeshStandardMaterial||_.isMeshLambertMaterial&&!_.envMap||_.isMeshPhongMaterial&&!_.envMap,J=e.get(_.envMap||O,U),ee=J&&J.mapping===Cr?J.image.height:null,le=f[_.type];_.precision!==null&&(u=n.getMaxPrecision(_.precision),u!==_.precision&&Te("WebGLProgram.getParameters:",_.precision,"not supported, using",u,"instead."));let ye=F.morphAttributes.position||F.morphAttributes.normal||F.morphAttributes.color,Me=ye!==void 0?ye.length:0,Ze=0;F.morphAttributes.position!==void 0&&(Ze=1),F.morphAttributes.normal!==void 0&&(Ze=2),F.morphAttributes.color!==void 0&&(Ze=3);let Ke,Fe,Z,fe;if(le){let Oe=Xn[le];Ke=Oe.vertexShader,Fe=Oe.fragmentShader}else Ke=_.vertexShader,Fe=_.fragmentShader,a.update(_),Z=a.getVertexShaderID(_),fe=a.getFragmentShaderID(_);let se=i.getRenderTarget(),Ce=i.state.buffers.depth.getReversed(),ke=I.isInstancedMesh===!0,Ie=I.isBatchedMesh===!0,ft=!!_.map,Xe=!!_.matcap,tt=!!J,lt=!!_.aoMap,We=!!_.lightMap,Et=!!_.bumpMap,pt=!!_.normalMap,tn=!!_.displacementMap,D=!!_.emissiveMap,Tt=!!_.metalnessMap,qe=!!_.roughnessMap,ot=_.anisotropy>0,ce=_.clearcoat>0,mt=_.dispersion>0,T=_.iridescence>0,y=_.sheen>0,B=_.transmission>0,$=ot&&!!_.anisotropyMap,Q=ce&&!!_.clearcoatMap,te=ce&&!!_.clearcoatNormalMap,ae=ce&&!!_.clearcoatRoughnessMap,X=T&&!!_.iridescenceMap,K=T&&!!_.iridescenceThicknessMap,pe=y&&!!_.sheenColorMap,ve=y&&!!_.sheenRoughnessMap,re=!!_.specularMap,ne=!!_.specularColorMap,Ne=!!_.specularIntensityMap,Be=B&&!!_.transmissionMap,Je=B&&!!_.thicknessMap,L=!!_.gradientMap,ie=!!_.alphaMap,q=_.alphaTest>0,me=!!_.alphaHash,oe=!!_.extensions,j=hn;_.toneMapped&&(se===null||se.isXRRenderTarget===!0)&&(j=i.toneMapping);let Se={shaderID:le,shaderType:_.type,shaderName:_.name,vertexShader:Ke,fragmentShader:Fe,defines:_.defines,customVertexShaderID:Z,customFragmentShaderID:fe,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:u,batching:Ie,batchingColor:Ie&&I._colorsTexture!==null,instancing:ke,instancingColor:ke&&I.instanceColor!==null,instancingMorph:ke&&I.morphTexture!==null,outputColorSpace:se===null?i.outputColorSpace:se.isXRRenderTarget===!0?se.texture.colorSpace:Ge.workingColorSpace,alphaToCoverage:!!_.alphaToCoverage,map:ft,matcap:Xe,envMap:tt,envMapMode:tt&&J.mapping,envMapCubeUVHeight:ee,aoMap:lt,lightMap:We,bumpMap:Et,normalMap:pt,displacementMap:tn,emissiveMap:D,normalMapObjectSpace:pt&&_.normalMapType===Wd,normalMapTangentSpace:pt&&_.normalMapType===uh,packedNormalMap:pt&&_.normalMapType===uh&&gy(_.normalMap.format),metalnessMap:Tt,roughnessMap:qe,anisotropy:ot,anisotropyMap:$,clearcoat:ce,clearcoatMap:Q,clearcoatNormalMap:te,clearcoatRoughnessMap:ae,dispersion:mt,iridescence:T,iridescenceMap:X,iridescenceThicknessMap:K,sheen:y,sheenColorMap:pe,sheenRoughnessMap:ve,specularMap:re,specularColorMap:ne,specularIntensityMap:Ne,transmission:B,transmissionMap:Be,thicknessMap:Je,gradientMap:L,opaque:_.transparent===!1&&_.blending===Yi&&_.alphaToCoverage===!1,alphaMap:ie,alphaTest:q,alphaHash:me,combine:_.combine,mapUv:ft&&m(_.map.channel),aoMapUv:lt&&m(_.aoMap.channel),lightMapUv:We&&m(_.lightMap.channel),bumpMapUv:Et&&m(_.bumpMap.channel),normalMapUv:pt&&m(_.normalMap.channel),displacementMapUv:tn&&m(_.displacementMap.channel),emissiveMapUv:D&&m(_.emissiveMap.channel),metalnessMapUv:Tt&&m(_.metalnessMap.channel),roughnessMapUv:qe&&m(_.roughnessMap.channel),anisotropyMapUv:$&&m(_.anisotropyMap.channel),clearcoatMapUv:Q&&m(_.clearcoatMap.channel),clearcoatNormalMapUv:te&&m(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ae&&m(_.clearcoatRoughnessMap.channel),iridescenceMapUv:X&&m(_.iridescenceMap.channel),iridescenceThicknessMapUv:K&&m(_.iridescenceThicknessMap.channel),sheenColorMapUv:pe&&m(_.sheenColorMap.channel),sheenRoughnessMapUv:ve&&m(_.sheenRoughnessMap.channel),specularMapUv:re&&m(_.specularMap.channel),specularColorMapUv:ne&&m(_.specularColorMap.channel),specularIntensityMapUv:Ne&&m(_.specularIntensityMap.channel),transmissionMapUv:Be&&m(_.transmissionMap.channel),thicknessMapUv:Je&&m(_.thicknessMap.channel),alphaMapUv:ie&&m(_.alphaMap.channel),vertexTangents:!!F.attributes.tangent&&(pt||ot),vertexNormals:!!F.attributes.normal,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!F.attributes.color&&F.attributes.color.itemSize===4,pointsUvs:I.isPoints===!0&&!!F.attributes.uv&&(ft||ie),fog:!!W,useFog:_.fog===!0,fogExp2:!!W&&W.isFogExp2,flatShading:_.wireframe===!1&&(_.flatShading===!0||F.attributes.normal===void 0&&pt===!1&&(_.isMeshLambertMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isMeshPhysicalMaterial)),sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:Ce,skinning:I.isSkinnedMesh===!0,morphTargets:F.morphAttributes.position!==void 0,morphNormals:F.morphAttributes.normal!==void 0,morphColors:F.morphAttributes.color!==void 0,morphTargetsCount:Me,morphTextureStride:Ze,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:H.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:_.dithering,shadowMapEnabled:i.shadowMap.enabled&&P.length>0,shadowMapType:i.shadowMap.type,toneMapping:j,decodeVideoTexture:ft&&_.map.isVideoTexture===!0&&Ge.getTransfer(_.map.colorSpace)===je,decodeVideoTextureEmissive:D&&_.emissiveMap.isVideoTexture===!0&&Ge.getTransfer(_.emissiveMap.colorSpace)===je,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===Hn,flipSided:_.side===$t,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:oe&&_.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(oe&&_.extensions.multiDraw===!0||Ie)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return Se.vertexUv1s=l.has(1),Se.vertexUv2s=l.has(2),Se.vertexUv3s=l.has(3),l.clear(),Se}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 b(_){let A=f[_.type],P;if(A){let R=Xn[A];P=ci.clone(R.uniforms)}else P=_.uniforms;return P}function M(_,A){let P=h.get(A);return P!==void 0?++P.usedTimes:(P=new py(i,A,_,s),c.push(P),h.set(A,P)),P}function S(_){if(--_.usedTimes===0){let A=c.indexOf(_);c[A]=c[c.length-1],c.pop(),h.delete(_.cacheKey),_.destroy()}}function w(_){a.remove(_)}function C(){a.dispose()}return{getParameters:x,getProgramCacheKey:g,getUniforms:b,acquireProgram:M,releaseProgram:S,releaseShaderCache:w,programs:c,dispose:C}}function vy(){let i=new WeakMap;function e(o){return i.has(o)}function t(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:e,get:t,remove:n,update:s,dispose:r}}function _y(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.materialVariant!==e.materialVariant?i.materialVariant-e.materialVariant:i.z!==e.z?i.z-e.z:i.id-e.id}function Mf(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function Sf(){let i=[],e=0,t=[],n=[],s=[];function r(){e=0,t.length=0,n.length=0,s.length=0}function o(u){let f=0;return u.isInstancedMesh&&(f+=2),u.isSkinnedMesh&&(f+=1),f}function a(u,f,m,x,g,p){let v=i[e];return v===void 0?(v={id:u.id,object:u,geometry:f,material:m,materialVariant:o(u),groupOrder:x,renderOrder:u.renderOrder,z:g,group:p},i[e]=v):(v.id=u.id,v.object=u,v.geometry=f,v.material=m,v.materialVariant=o(u),v.groupOrder=x,v.renderOrder=u.renderOrder,v.z=g,v.group=p),e++,v}function l(u,f,m,x,g,p){let v=a(u,f,m,x,g,p);m.transmission>0?n.push(v):m.transparent===!0?s.push(v):t.push(v)}function c(u,f,m,x,g,p){let v=a(u,f,m,x,g,p);m.transmission>0?n.unshift(v):m.transparent===!0?s.unshift(v):t.unshift(v)}function h(u,f){t.length>1&&t.sort(u||_y),n.length>1&&n.sort(f||Mf),s.length>1&&s.sort(f||Mf)}function d(){for(let u=e,f=i.length;u=r.length?(o=new Sf,r.push(o)):o=r[s],o}function t(){i=new WeakMap}return{get:e,dispose:t}}function by(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new N,color:new ge};break;case"SpotLight":t={position:new N,direction:new N,color:new ge,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new N,color:new ge,distance:0,decay:0};break;case"HemisphereLight":t={direction:new N,skyColor:new ge,groundColor:new ge};break;case"RectAreaLight":t={color:new ge,position:new N,halfWidth:new N,halfHeight:new N};break}return i[e.id]=t,t}}}function My(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ae};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ae};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ae,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}var Sy=0;function wy(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function Ey(i){let e=new by,t=My(),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 N);let s=new N,r=new xt,o=new xt;function a(c){let h=0,d=0,u=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,b=0,M=0,S=0,w=0,C=0;c.sort(wy);for(let A=0,P=c.length;A0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=he.LTC_FLOAT_1,n.rectAreaLTC2=he.LTC_FLOAT_2):(n.rectAreaLTC1=he.LTC_HALF_1,n.rectAreaLTC2=he.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=d,n.ambient[2]=u;let _=n.hash;(_.directionalLength!==f||_.pointLength!==m||_.spotLength!==x||_.rectAreaLength!==g||_.hemiLength!==p||_.numDirectionalShadows!==v||_.numPointShadows!==b||_.numSpotShadows!==M||_.numSpotMaps!==S||_.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=b,n.pointShadowMap.length=b,n.spotShadow.length=M,n.spotShadowMap.length=M,n.directionalShadowMatrix.length=v,n.pointShadowMatrix.length=b,n.spotLightMatrix.length=M+S-w,n.spotLightMap.length=S,n.numSpotLightShadowsWithMaps=w,n.numLightProbes=C,_.directionalLength=f,_.pointLength=m,_.spotLength=x,_.rectAreaLength=g,_.hemiLength=p,_.numDirectionalShadows=v,_.numPointShadows=b,_.numSpotShadows=M,_.numSpotMaps=S,_.numLightProbes=C,n.version=Sy++)}function l(c,h){let d=0,u=0,f=0,m=0,x=0,g=h.matrixWorldInverse;for(let p=0,v=c.length;p=o.length?(a=new wf(i),o.push(a)):a=o[r],a}function n(){e=new WeakMap}return{get:t,dispose:n}}var Ay=`void main() { gl_Position = vec4( position, 1.0 ); }`,Cy=`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 ); }`,Ry=[new N(1,0,0),new N(-1,0,0),new N(0,1,0),new N(0,-1,0),new N(0,0,1),new N(0,0,-1)],Py=[new N(0,-1,0),new N(0,-1,0),new N(0,0,1),new N(0,0,-1),new N(0,-1,0),new N(0,-1,0)],Ef=new xt,Or=new N,Rh=new N;function Iy(i,e,t){let n=new dr,s=new Ae,r=new Ae,o=new vt,a=new ta,l=new na,c={},h=t.maxTextureSize,d={[ni]:$t,[$t]:ni,[Hn]:Hn},u=new ut({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ae},radius:{value:4}},vertexShader:Ay,fragmentShader:Cy}),f=u.clone();f.defines.HORIZONTAL_PASS=1;let m=new ht;m.setAttribute("position",new Ye(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let x=new Wt(m,u),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=yr;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===bd&&(Te("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=yr);let A=i.getRenderTarget(),P=i.getActiveCubeFace(),R=i.getActiveMipmapLevel(),I=i.state;I.setBlending(_n),I.buffers.depth.getReversed()===!0?I.buffers.color.setClear(0,0,0,0):I.buffers.color.setClear(1,1,1,1),I.buffers.depth.setTest(!0),I.setScissorTest(!1);let H=p!==this.type;H&&C.traverse(function(W){W.material&&(Array.isArray(W.material)?W.material.forEach(F=>F.needsUpdate=!0):W.material.needsUpdate=!0)});for(let W=0,F=w.length;Wh||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/J.x),s.x=r.x*J.x,U.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/J.y),s.y=r.y*J.y,U.mapSize.y=r.y));let ee=i.state.buffers.depth.getReversed();if(U.camera._reversedDepth=ee,U.map===null||H===!0){if(U.map!==null&&(U.map.depthTexture!==null&&(U.map.depthTexture.dispose(),U.map.depthTexture=null),U.map.dispose()),this.type===Rs){if(O.isPointLight){Te("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}U.map=new Ct(s.x,s.y,{format:Di,type:Xt,minFilter:Ut,magFilter:Ut,generateMipmaps:!1}),U.map.texture.name=O.name+".shadowMap",U.map.depthTexture=new oi(s.x,s.y,Pn),U.map.depthTexture.name=O.name+".shadowMapDepth",U.map.depthTexture.format=Bn,U.map.depthTexture.compareFunction=null,U.map.depthTexture.minFilter=Lt,U.map.depthTexture.magFilter=Lt}else O.isPointLight?(U.map=new ll(s.x),U.map.depthTexture=new ea(s.x,Rn)):(U.map=new Ct(s.x,s.y),U.map.depthTexture=new oi(s.x,s.y,Rn)),U.map.depthTexture.name=O.name+".shadowMap",U.map.depthTexture.format=Bn,this.type===yr?(U.map.depthTexture.compareFunction=ee?il:nl,U.map.depthTexture.minFilter=Ut,U.map.depthTexture.magFilter=Ut):(U.map.depthTexture.compareFunction=null,U.map.depthTexture.minFilter=Lt,U.map.depthTexture.magFilter=Lt);U.camera.updateProjectionMatrix()}let le=U.map.isWebGLCubeRenderTarget?6:1;for(let ye=0;ye0||C.map&&C.alphaTest>0||C.alphaToCoverage===!0){let I=P.uuid,H=C.uuid,W=c[I];W===void 0&&(W={},c[I]=W);let F=W[H];F===void 0&&(F=P.clone(),W[H]=F,C.addEventListener("dispose",S)),P=F}if(P.visible=C.visible,P.wireframe=C.wireframe,A===Rs?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 I=i.properties.get(P);I.light=_}return P}function M(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===Rs)&&(!w.frustumCulled||n.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,w.matrixWorld);let H=e.update(w),W=w.material;if(Array.isArray(W)){let F=H.groups;for(let O=0,U=F.length;O=1):ee.indexOf("OpenGL ES")!==-1&&(J=parseFloat(/^OpenGL ES (\d)/.exec(ee)[1]),U=J>=2);let le=null,ye={},Me=i.getParameter(i.SCISSOR_BOX),Ze=i.getParameter(i.VIEWPORT),Ke=new vt().fromArray(Me),Fe=new vt().fromArray(Ze);function Z(L,ie,q,me){let oe=new Uint8Array(4),j=i.createTexture();i.bindTexture(L,j),i.texParameteri(L,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(L,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Se=0;Se"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Ae,h=new WeakMap,d=new Set,u,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):ar("canvas")}function g(T,y,B){let $=1,Q=mt(T);if((Q.width>B||Q.height>B)&&($=B/Math.max(Q.width,Q.height)),$<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 te=Math.floor($*Q.width),ae=Math.floor($*Q.height);u===void 0&&(u=x(te,ae));let X=y?x(te,ae):u;return X.width=te,X.height=ae,X.getContext("2d").drawImage(T,0,0,te,ae),Te("WebGLRenderer: Texture has been resized from ("+Q.width+"x"+Q.height+") to ("+te+"x"+ae+")."),X}else return"data"in T&&Te("WebGLRenderer: Image in DataTexture is too big ("+Q.width+"x"+Q.height+")."),T;return T}function p(T){return T.generateMipmaps}function v(T){i.generateMipmap(T)}function b(T){return T.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:T.isWebGL3DRenderTarget?i.TEXTURE_3D:T.isWebGLArrayRenderTarget||T.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function M(T,y,B,$,Q,te=!1){if(T!==null){if(i[T]!==void 0)return i[T];Te("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let ae;$&&(ae=e.get("EXT_texture_norm16"),ae||Te("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let X=y;if(y===i.RED&&(B===i.FLOAT&&(X=i.R32F),B===i.HALF_FLOAT&&(X=i.R16F),B===i.UNSIGNED_BYTE&&(X=i.R8),B===i.UNSIGNED_SHORT&&ae&&(X=ae.R16_EXT),B===i.SHORT&&ae&&(X=ae.R16_SNORM_EXT)),y===i.RED_INTEGER&&(B===i.UNSIGNED_BYTE&&(X=i.R8UI),B===i.UNSIGNED_SHORT&&(X=i.R16UI),B===i.UNSIGNED_INT&&(X=i.R32UI),B===i.BYTE&&(X=i.R8I),B===i.SHORT&&(X=i.R16I),B===i.INT&&(X=i.R32I)),y===i.RG&&(B===i.FLOAT&&(X=i.RG32F),B===i.HALF_FLOAT&&(X=i.RG16F),B===i.UNSIGNED_BYTE&&(X=i.RG8),B===i.UNSIGNED_SHORT&&ae&&(X=ae.RG16_EXT),B===i.SHORT&&ae&&(X=ae.RG16_SNORM_EXT)),y===i.RG_INTEGER&&(B===i.UNSIGNED_BYTE&&(X=i.RG8UI),B===i.UNSIGNED_SHORT&&(X=i.RG16UI),B===i.UNSIGNED_INT&&(X=i.RG32UI),B===i.BYTE&&(X=i.RG8I),B===i.SHORT&&(X=i.RG16I),B===i.INT&&(X=i.RG32I)),y===i.RGB_INTEGER&&(B===i.UNSIGNED_BYTE&&(X=i.RGB8UI),B===i.UNSIGNED_SHORT&&(X=i.RGB16UI),B===i.UNSIGNED_INT&&(X=i.RGB32UI),B===i.BYTE&&(X=i.RGB8I),B===i.SHORT&&(X=i.RGB16I),B===i.INT&&(X=i.RGB32I)),y===i.RGBA_INTEGER&&(B===i.UNSIGNED_BYTE&&(X=i.RGBA8UI),B===i.UNSIGNED_SHORT&&(X=i.RGBA16UI),B===i.UNSIGNED_INT&&(X=i.RGBA32UI),B===i.BYTE&&(X=i.RGBA8I),B===i.SHORT&&(X=i.RGBA16I),B===i.INT&&(X=i.RGBA32I)),y===i.RGB&&(B===i.UNSIGNED_SHORT&&ae&&(X=ae.RGB16_EXT),B===i.SHORT&&ae&&(X=ae.RGB16_SNORM_EXT),B===i.UNSIGNED_INT_5_9_9_9_REV&&(X=i.RGB9_E5),B===i.UNSIGNED_INT_10F_11F_11F_REV&&(X=i.R11F_G11F_B10F)),y===i.RGBA){let K=te?rr:Ge.getTransfer(Q);B===i.FLOAT&&(X=i.RGBA32F),B===i.HALF_FLOAT&&(X=i.RGBA16F),B===i.UNSIGNED_BYTE&&(X=K===je?i.SRGB8_ALPHA8:i.RGBA8),B===i.UNSIGNED_SHORT&&ae&&(X=ae.RGBA16_EXT),B===i.SHORT&&ae&&(X=ae.RGBA16_SNORM_EXT),B===i.UNSIGNED_SHORT_4_4_4_4&&(X=i.RGBA4),B===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)&&e.get("EXT_color_buffer_float"),X}function S(T,y){let B;return T?y===null||y===Rn||y===Is?B=i.DEPTH24_STENCIL8:y===Pn?B=i.DEPTH32F_STENCIL8:y===Ps&&(B=i.DEPTH24_STENCIL8,Te("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):y===null||y===Rn||y===Is?B=i.DEPTH_COMPONENT24:y===Pn?B=i.DEPTH_COMPONENT32F:y===Ps&&(B=i.DEPTH_COMPONENT16),B}function w(T,y){return p(T)===!0||T.isFramebufferTexture&&T.minFilter!==Lt&&T.minFilter!==Ut?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&&h.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 B=T.source,$=f.get(B);if($){let Q=$[y.__cacheKey];Q.usedTimes--,Q.usedTimes===0&&P(T),Object.keys($).length===0&&f.delete(B)}n.remove(T)}function P(T){let y=n.get(T);i.deleteTexture(y.__webglTexture);let B=T.source,$=f.get(B);delete $[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 $=0;$<6;$++){if(Array.isArray(y.__webglFramebuffer[$]))for(let Q=0;Q=s.maxTextures&&Te("WebGLTextures: Trying to use "+T+" texture units while this GPU supports only "+s.maxTextures),I+=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 B=n.get(T);if(T.isVideoTexture&&ot(T),T.isRenderTargetTexture===!1&&T.isExternalTexture!==!0&&T.version>0&&B.__version!==T.version){let $=T.image;if($===null)Te("WebGLRenderer: Texture marked for update but no image data found.");else if($.complete===!1)Te("WebGLRenderer: Texture marked for update but image is incomplete");else{Ce(B,T,y);return}}else T.isExternalTexture&&(B.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,B.__webglTexture,i.TEXTURE0+y)}function ee(T,y){let B=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&B.__version!==T.version){Ce(B,T,y);return}else T.isExternalTexture&&(B.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,B.__webglTexture,i.TEXTURE0+y)}function le(T,y){let B=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&B.__version!==T.version){Ce(B,T,y);return}t.bindTexture(i.TEXTURE_3D,B.__webglTexture,i.TEXTURE0+y)}function ye(T,y){let B=n.get(T);if(T.isCubeDepthTexture!==!0&&T.version>0&&B.__version!==T.version){ke(B,T,y);return}t.bindTexture(i.TEXTURE_CUBE_MAP,B.__webglTexture,i.TEXTURE0+y)}let Me={[Ho]:i.REPEAT,[Un]:i.CLAMP_TO_EDGE,[Wo]:i.MIRRORED_REPEAT},Ze={[Lt]:i.NEAREST,[Gd]:i.NEAREST_MIPMAP_NEAREST,[Rr]:i.NEAREST_MIPMAP_LINEAR,[Ut]:i.LINEAR,[_a]:i.LINEAR_MIPMAP_NEAREST,[Li]:i.LINEAR_MIPMAP_LINEAR},Ke={[Xd]:i.NEVER,[Kd]:i.ALWAYS,[qd]:i.LESS,[nl]:i.LEQUAL,[Yd]:i.EQUAL,[il]:i.GEQUAL,[Zd]:i.GREATER,[$d]:i.NOTEQUAL};function Fe(T,y){if(y.type===Pn&&e.has("OES_texture_float_linear")===!1&&(y.magFilter===Ut||y.magFilter===_a||y.magFilter===Rr||y.magFilter===Li||y.minFilter===Ut||y.minFilter===_a||y.minFilter===Rr||y.minFilter===Li)&&Te("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,Me[y.wrapS]),i.texParameteri(T,i.TEXTURE_WRAP_T,Me[y.wrapT]),(T===i.TEXTURE_3D||T===i.TEXTURE_2D_ARRAY)&&i.texParameteri(T,i.TEXTURE_WRAP_R,Me[y.wrapR]),i.texParameteri(T,i.TEXTURE_MAG_FILTER,Ze[y.magFilter]),i.texParameteri(T,i.TEXTURE_MIN_FILTER,Ze[y.minFilter]),y.compareFunction&&(i.texParameteri(T,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(T,i.TEXTURE_COMPARE_FUNC,Ke[y.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(y.magFilter===Lt||y.minFilter!==Rr&&y.minFilter!==Li||y.type===Pn&&e.has("OES_texture_float_linear")===!1)return;if(y.anisotropy>1||n.get(y).__currentAnisotropy){let B=e.get("EXT_texture_filter_anisotropic");i.texParameterf(T,B.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(y.anisotropy,s.getMaxAnisotropy())),n.get(y).__currentAnisotropy=y.anisotropy}}}function Z(T,y){let B=!1;T.__webglInit===void 0&&(T.__webglInit=!0,y.addEventListener("dispose",C));let $=y.source,Q=f.get($);Q===void 0&&(Q={},f.set($,Q));let te=U(y);if(te!==T.__cacheKey){Q[te]===void 0&&(Q[te]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,B=!0),Q[te].usedTimes++;let ae=Q[T.__cacheKey];ae!==void 0&&(Q[T.__cacheKey].usedTimes--,ae.usedTimes===0&&P(y)),T.__cacheKey=te,T.__webglTexture=Q[te].texture}return B}function fe(T,y,B){return Math.floor(Math.floor(T/B)/y)}function se(T,y,B,$){let te=T.updateRanges;if(te.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,y.width,y.height,B,$,y.data);else{te.sort((ve,re)=>ve.start-re.start);let ae=0;for(let ve=1;ve0){Be&&Je&&t.texStorage2D(i.TEXTURE_2D,ie,re,Ne[0].width,Ne[0].height);for(let q=0,me=Ne.length;q0){let oe=vh(ne.width,ne.height,y.format,y.type);for(let j of y.layerUpdates){let Se=ne.data.subarray(j*oe/ne.data.BYTES_PER_ELEMENT,(j+1)*oe/ne.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,q,0,0,j,ne.width,ne.height,1,pe,Se)}y.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,q,0,0,0,ne.width,ne.height,K.depth,pe,ne.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,q,re,ne.width,ne.height,K.depth,0,ne.data,0,0);else Te("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Be?L&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,q,0,0,0,ne.width,ne.height,K.depth,pe,ve,ne.data):t.texImage3D(i.TEXTURE_2D_ARRAY,q,re,ne.width,ne.height,K.depth,0,pe,ve,ne.data)}else{Be&&Je&&t.texStorage2D(i.TEXTURE_2D,ie,re,Ne[0].width,Ne[0].height);for(let q=0,me=Ne.length;q0){let q=vh(K.width,K.height,y.format,y.type);for(let me of y.layerUpdates){let oe=K.data.subarray(me*q/K.data.BYTES_PER_ELEMENT,(me+1)*q/K.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,me,K.width,K.height,1,pe,ve,oe)}y.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,K.width,K.height,K.depth,pe,ve,K.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,re,K.width,K.height,K.depth,0,pe,ve,K.data);else if(y.isData3DTexture)Be?(Je&&t.texStorage3D(i.TEXTURE_3D,ie,re,K.width,K.height,K.depth),L&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,K.width,K.height,K.depth,pe,ve,K.data)):t.texImage3D(i.TEXTURE_3D,0,re,K.width,K.height,K.depth,0,pe,ve,K.data);else if(y.isFramebufferTexture){if(Je)if(Be)t.texStorage2D(i.TEXTURE_2D,ie,re,K.width,K.height);else{let q=K.width,me=K.height;for(let oe=0;oe>=1,me>>=1}}else if(y.isHTMLTexture){if("texElementImage2D"in i){let q=i.canvas;if(q.hasAttribute("layoutsubtree")||q.setAttribute("layoutsubtree","true"),K.parentNode!==q){q.appendChild(K),d.add(y),q.onpaint=Oe=>{let bt=Oe.changedElements;for(let nt of d)bt.includes(nt.image)&&(nt.needsUpdate=!0)},q.requestPaint();return}let me=0,oe=i.RGBA,j=i.RGBA,Se=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,me,oe,j,Se,K),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(Ne.length>0){if(Be&&Je){let q=mt(Ne[0]);t.texStorage2D(i.TEXTURE_2D,ie,re,q.width,q.height)}for(let q=0,me=Ne.length;q0&&me++;let j=mt(re[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,me,Je,j.width,j.height)}for(let j=0;j<6;j++)if(ve){L?q&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,0,0,re[j].width,re[j].height,Ne,Be,re[j].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,Je,re[j].width,re[j].height,0,Ne,Be,re[j].data);for(let Se=0;Se>te),ne=Math.max(1,y.height>>te);Q===i.TEXTURE_3D||Q===i.TEXTURE_2D_ARRAY?t.texImage3D(Q,te,K,re,ne,y.depth,0,ae,X,null):t.texImage2D(Q,te,K,re,ne,0,ae,X,null)}t.bindFramebuffer(i.FRAMEBUFFER,T),qe(y)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,$,Q,ve.__webglTexture,0,Tt(y)):(Q===i.TEXTURE_2D||Q>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&Q<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,$,Q,ve.__webglTexture,te),t.bindFramebuffer(i.FRAMEBUFFER,null)}function ft(T,y,B){if(i.bindRenderbuffer(i.RENDERBUFFER,T),y.depthBuffer){let $=y.depthTexture,Q=$&&$.isDepthTexture?$.type:null,te=S(y.stencilBuffer,Q),ae=y.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;qe(y)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Tt(y),te,y.width,y.height):B?i.renderbufferStorageMultisample(i.RENDERBUFFER,Tt(y),te,y.width,y.height):i.renderbufferStorage(i.RENDERBUFFER,te,y.width,y.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,ae,i.RENDERBUFFER,T)}else{let $=y.textures;for(let Q=0;Q<$.length;Q++){let te=$[Q],ae=r.convert(te.format,te.colorSpace),X=r.convert(te.type),K=M(te.internalFormat,ae,X,te.normalized,te.colorSpace);qe(y)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Tt(y),K,y.width,y.height):B?i.renderbufferStorageMultisample(i.RENDERBUFFER,Tt(y),K,y.width,y.height):i.renderbufferStorage(i.RENDERBUFFER,K,y.width,y.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Xe(T,y,B){let $=y.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(i.FRAMEBUFFER,T),!(y.depthTexture&&y.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");let Q=n.get(y.depthTexture);if(Q.__renderTarget=y,(!Q.__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),$){if(Q.__webglInit===void 0&&(Q.__webglInit=!0,y.depthTexture.addEventListener("dispose",C)),Q.__webglTexture===void 0){Q.__webglTexture=i.createTexture(),t.bindTexture(i.TEXTURE_CUBE_MAP,Q.__webglTexture),Fe(i.TEXTURE_CUBE_MAP,y.depthTexture);let pe=r.convert(y.depthTexture.format),ve=r.convert(y.depthTexture.type),re;y.depthTexture.format===Bn?re=i.DEPTH_COMPONENT24:y.depthTexture.format===Ni&&(re=i.DEPTH24_STENCIL8);for(let ne=0;ne<6;ne++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ne,0,re,y.width,y.height,0,pe,ve,null)}}else J(y.depthTexture,0);let te=Q.__webglTexture,ae=Tt(y),X=$?i.TEXTURE_CUBE_MAP_POSITIVE_X+B:i.TEXTURE_2D,K=y.depthTexture.format===Ni?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(y.depthTexture.format===Bn)qe(y)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,K,X,te,0,ae):i.framebufferTexture2D(i.FRAMEBUFFER,K,X,te,0);else if(y.depthTexture.format===Ni)qe(y)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,K,X,te,0,ae):i.framebufferTexture2D(i.FRAMEBUFFER,K,X,te,0);else throw new Error("Unknown depthTexture format")}function tt(T){let y=n.get(T),B=T.isWebGLCubeRenderTarget===!0;if(y.__boundDepthTexture!==T.depthTexture){let $=T.depthTexture;if(y.__depthDisposeCallback&&y.__depthDisposeCallback(),$){let Q=()=>{delete y.__boundDepthTexture,delete y.__depthDisposeCallback,$.removeEventListener("dispose",Q)};$.addEventListener("dispose",Q),y.__depthDisposeCallback=Q}y.__boundDepthTexture=$}if(T.depthTexture&&!y.__autoAllocateDepthBuffer)if(B)for(let $=0;$<6;$++)Xe(y.__webglFramebuffer[$],T,$);else{let $=T.texture.mipmaps;$&&$.length>0?Xe(y.__webglFramebuffer[0],T,0):Xe(y.__webglFramebuffer,T,0)}else if(B){y.__webglDepthbuffer=[];for(let $=0;$<6;$++)if(t.bindFramebuffer(i.FRAMEBUFFER,y.__webglFramebuffer[$]),y.__webglDepthbuffer[$]===void 0)y.__webglDepthbuffer[$]=i.createRenderbuffer(),ft(y.__webglDepthbuffer[$],T,!1);else{let Q=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,te=y.__webglDepthbuffer[$];i.bindRenderbuffer(i.RENDERBUFFER,te),i.framebufferRenderbuffer(i.FRAMEBUFFER,Q,i.RENDERBUFFER,te)}}else{let $=T.texture.mipmaps;if($&&$.length>0?t.bindFramebuffer(i.FRAMEBUFFER,y.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,y.__webglFramebuffer),y.__webglDepthbuffer===void 0)y.__webglDepthbuffer=i.createRenderbuffer(),ft(y.__webglDepthbuffer,T,!1);else{let Q=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,te=y.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,te),i.framebufferRenderbuffer(i.FRAMEBUFFER,Q,i.RENDERBUFFER,te)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function lt(T,y,B){let $=n.get(T);y!==void 0&&Ie($.__webglFramebuffer,T,T.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),B!==void 0&&tt(T)}function We(T){let y=T.texture,B=n.get(T),$=n.get(y);T.addEventListener("dispose",_);let Q=T.textures,te=T.isWebGLCubeRenderTarget===!0,ae=Q.length>1;if(ae||($.__webglTexture===void 0&&($.__webglTexture=i.createTexture()),$.__version=y.version,o.memory.textures++),te){B.__webglFramebuffer=[];for(let X=0;X<6;X++)if(y.mipmaps&&y.mipmaps.length>0){B.__webglFramebuffer[X]=[];for(let K=0;K0){B.__webglFramebuffer=[];for(let X=0;X0&&qe(T)===!1){B.__webglMultisampledFramebuffer=i.createFramebuffer(),B.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,B.__webglMultisampledFramebuffer);for(let X=0;X0)for(let K=0;K0)for(let K=0;K0){if(qe(T)===!1){let y=T.textures,B=T.width,$=T.height,Q=i.COLOR_BUFFER_BIT,te=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ae=n.get(T),X=y.length>1;if(X)for(let pe=0;pe0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ae.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ae.__webglFramebuffer);for(let pe=0;pe0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&y.__useRenderToTexture!==!1}function ot(T){let y=o.render.frame;h.get(T)!==y&&(h.set(T,y),T.update())}function ce(T,y){let B=T.colorSpace,$=T.format,Q=T.type;return T.isCompressedTexture===!0||T.isVideoTexture===!0||B!==sr&&B!==li&&(Ge.getTransfer(B)===je?($!==yn||Q!==un)&&Te("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Re("WebGLTextures: Unsupported texture color space:",B)),y}function mt(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=O,this.resetTextureUnits=H,this.getTextureUnits=W,this.setTextureUnits=F,this.setTexture2D=J,this.setTexture2DArray=ee,this.setTexture3D=le,this.setTextureCube=ye,this.rebindTextures=lt,this.setupRenderTarget=We,this.updateRenderTargetMipmap=Et,this.updateMultisampleRenderTarget=D,this.setupDepthRenderbuffer=tt,this.setupFrameBufferTexture=Ie,this.useMultisampledRTT=qe,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Dy(i,e){function t(n,s=li){let r,o=Ge.getTransfer(s);if(n===un)return i.UNSIGNED_BYTE;if(n===ba)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Ma)return i.UNSIGNED_SHORT_5_5_5_1;if(n===oh)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===ah)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===sh)return i.BYTE;if(n===rh)return i.SHORT;if(n===Ps)return i.UNSIGNED_SHORT;if(n===ya)return i.INT;if(n===Rn)return i.UNSIGNED_INT;if(n===Pn)return i.FLOAT;if(n===Xt)return i.HALF_FLOAT;if(n===lh)return i.ALPHA;if(n===ch)return i.RGB;if(n===yn)return i.RGBA;if(n===Bn)return i.DEPTH_COMPONENT;if(n===Ni)return i.DEPTH_STENCIL;if(n===hh)return i.RED;if(n===Sa)return i.RED_INTEGER;if(n===Di)return i.RG;if(n===wa)return i.RG_INTEGER;if(n===Ea)return i.RGBA_INTEGER;if(n===Pr||n===Ir||n===Lr||n===Nr)if(o===je)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Pr)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Ir)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Lr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Nr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Pr)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Ir)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Lr)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Nr)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Ta||n===Aa||n===Ca||n===Ra)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Ta)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Aa)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Ca)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Ra)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Pa||n===Ia||n===La||n===Na||n===Da||n===Dr||n===Fa)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Pa||n===Ia)return o===je?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===La)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===Na)return r.COMPRESSED_R11_EAC;if(n===Da)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Dr)return r.COMPRESSED_RG11_EAC;if(n===Fa)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===ka||n===Oa||n===Ua||n===Ba||n===za||n===Va||n===Ga||n===Ha||n===Wa||n===Xa||n===qa||n===Ya||n===Za||n===$a)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===ka)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Oa)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Ua)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Ba)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===za)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Va)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Ga)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Ha)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Wa)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Xa)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===qa)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Ya)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Za)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===$a)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Ka||n===Ja||n===ja)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===Ka)return o===je?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Ja)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===ja)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Qa||n===el||n===Fr||n===tl)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===Qa)return r.COMPRESSED_RED_RGTC1_EXT;if(n===el)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Fr)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===tl)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Is?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}var Fy=` void main() { gl_Position = vec4( position, 1.0 ); }`,ky=` 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; } }`,Oh=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new pr(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new ut({vertexShader:Fy,fragmentShader:ky,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Wt(new mr(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Uh=class extends An{constructor(e,t){super();let n=this,s=null,r=1,o=null,a="local-floor",l=1,c=null,h=null,d=null,u=null,f=null,m=null,x=typeof XRWebGLBinding<"u",g=new Oh,p={},v=t.getContextAttributes(),b=null,M=null,S=[],w=[],C=new Ae,_=null,A=new Ht;A.viewport=new vt;let P=new Ht;P.viewport=new vt;let R=[A,P],I=new pa,H=null,W=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let fe=S[Z];return fe===void 0&&(fe=new Es,S[Z]=fe),fe.getTargetRaySpace()},this.getControllerGrip=function(Z){let fe=S[Z];return fe===void 0&&(fe=new Es,S[Z]=fe),fe.getGripSpace()},this.getHand=function(Z){let fe=S[Z];return fe===void 0&&(fe=new Es,S[Z]=fe),fe.getHandSpace()};function F(Z){let fe=w.indexOf(Z.inputSource);if(fe===-1)return;let se=S[fe];se!==void 0&&(se.update(Z.inputSource,Z.frame,c||o),se.dispatchEvent({type:Z.type,data:Z.inputSource}))}function O(){s.removeEventListener("select",F),s.removeEventListener("selectstart",F),s.removeEventListener("selectend",F),s.removeEventListener("squeeze",F),s.removeEventListener("squeezestart",F),s.removeEventListener("squeezeend",F),s.removeEventListener("end",O),s.removeEventListener("inputsourceschange",U);for(let Z=0;Z=0&&(w[Ce]=null,S[Ce].disconnect(se))}for(let fe=0;fe=w.length){w.push(se),Ce=Ie;break}else if(w[Ie]===null){w[Ie]=se,Ce=Ie;break}if(Ce===-1)break}let ke=S[Ce];ke&&ke.connect(se)}}let J=new N,ee=new N;function le(Z,fe,se){J.setFromMatrixPosition(fe.matrixWorld),ee.setFromMatrixPosition(se.matrixWorld);let Ce=J.distanceTo(ee),ke=fe.projectionMatrix.elements,Ie=se.projectionMatrix.elements,ft=ke[14]/(ke[10]-1),Xe=ke[14]/(ke[10]+1),tt=(ke[9]+1)/ke[5],lt=(ke[9]-1)/ke[5],We=(ke[8]-1)/ke[0],Et=(Ie[8]+1)/Ie[0],pt=ft*We,tn=ft*Et,D=Ce/(-We+Et),Tt=D*-We;if(fe.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(Tt),Z.translateZ(D),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert(),ke[10]===-1)Z.projectionMatrix.copy(fe.projectionMatrix),Z.projectionMatrixInverse.copy(fe.projectionMatrixInverse);else{let qe=ft+D,ot=Xe+D,ce=pt-Tt,mt=tn+(Ce-Tt),T=tt*Xe/ot*qe,y=lt*Xe/ot*qe;Z.projectionMatrix.makePerspective(ce,mt,T,y,qe,ot),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert()}}function ye(Z,fe){fe===null?Z.matrixWorld.copy(Z.matrix):Z.matrixWorld.multiplyMatrices(fe.matrixWorld,Z.matrix),Z.matrixWorldInverse.copy(Z.matrixWorld).invert()}this.updateCamera=function(Z){if(s===null)return;let fe=Z.near,se=Z.far;g.texture!==null&&(g.depthNear>0&&(fe=g.depthNear),g.depthFar>0&&(se=g.depthFar)),I.near=P.near=A.near=fe,I.far=P.far=A.far=se,(H!==I.near||W!==I.far)&&(s.updateRenderState({depthNear:I.near,depthFar:I.far}),H=I.near,W=I.far),I.layers.mask=Z.layers.mask|6,A.layers.mask=I.layers.mask&-5,P.layers.mask=I.layers.mask&-3;let Ce=Z.parent,ke=I.cameras;ye(I,Ce);for(let Ie=0;Ie0&&(g.alphaTest.value=p.alphaTest);let v=e.get(p),b=v.envMap,M=v.envMapRotation;b&&(g.envMap.value=b,g.envMapRotation.value.setFromMatrix4(Oy.makeRotationFromEuler(M)).transpose(),b.isCubeTexture&&b.isRenderTargetTexture===!1&&g.envMapRotation.value.premultiply(Lf),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,t(p.lightMap,g.lightMapTransform)),p.aoMap&&(g.aoMap.value=p.aoMap,g.aoMapIntensity.value=p.aoMapIntensity,t(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,t(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,b){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.size.value=p.size*v,g.scale.value=b*.5,p.map&&(g.map.value=p.map,t(p.map,g.uvTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,t(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,t(p.map,g.mapTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,t(p.alphaMap,g.alphaMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest)}function h(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 u(g,p){g.metalness.value=p.metalness,p.metalnessMap&&(g.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,g.metalnessMapTransform)),g.roughness.value=p.roughness,p.roughnessMap&&(g.roughnessMap.value=p.roughnessMap,t(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,t(p.sheenColorMap,g.sheenColorMapTransform)),p.sheenRoughnessMap&&(g.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,g.sheenRoughnessMapTransform))),p.clearcoat>0&&(g.clearcoat.value=p.clearcoat,g.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(g.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,g.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(g.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===$t&&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,t(p.iridescenceMap,g.iridescenceMapTransform)),p.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(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,t(p.transmissionMap,g.transmissionMapTransform)),g.thickness.value=p.thickness,p.thicknessMap&&(g.thicknessMap.value=p.thicknessMap,t(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,t(p.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=p.specularIntensity,g.specularColor.value.copy(p.specularColor),p.specularColorMap&&(g.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,g.specularColorMapTransform)),p.specularIntensityMap&&(g.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,g.specularIntensityMapTransform))}function m(g,p){p.matcap&&(g.matcap.value=p.matcap)}function x(g,p){let v=e.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 By(i,e,t,n){let s={},r={},o=[],a=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(v,b){let M=b.program;n.uniformBlockBinding(v,M)}function c(v,b){let M=s[v.id];M===void 0&&(m(v),M=h(v),s[v.id]=M,v.addEventListener("dispose",g));let S=b.program;n.updateUBOMapping(v,S);let w=e.render.frame;r[v.id]!==w&&(u(v),r[v.id]=w)}function h(v){let b=d();v.__bindingPointIndex=b;let M=i.createBuffer(),S=v.__size,w=v.usage;return i.bindBuffer(i.UNIFORM_BUFFER,M),i.bufferData(i.UNIFORM_BUFFER,S,w),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,b,M),M}function d(){for(let v=0;v0&&(M+=S-w),v.__size=M,v.__cache={},this}function x(v){let b={boundary:0,storage:0};return typeof v=="number"||typeof v=="boolean"?(b.boundary=4,b.storage=4):v.isVector2?(b.boundary=8,b.storage=8):v.isVector3||v.isColor?(b.boundary=16,b.storage=12):v.isVector4?(b.boundary=16,b.storage=16):v.isMatrix3?(b.boundary=48,b.storage=48):v.isMatrix4?(b.boundary=64,b.storage=64):v.isTexture?Te("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(v)?(b.boundary=16,b.storage=v.byteLength):Te("WebGLRenderer: Unsupported uniform value type.",v),b}function g(v){let b=v.target;b.removeEventListener("dispose",g);let M=o.indexOf(b.__bindingPointIndex);o.splice(M,1),i.deleteBuffer(s[b.id]),delete s[b.id],delete r[b.id]}function p(){for(let v in s)i.deleteBuffer(s[v]);o=[],s={},r={}}return{bind:l,update:c,dispose:p}}var zy=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]),Wn=null;function Vy(){return Wn===null&&(Wn=new Ko(zy,16,16,Di,Xt),Wn.name="DFG_LUT",Wn.minFilter=Ut,Wn.magFilter=Ut,Wn.wrapS=Un,Wn.wrapT=Un,Wn.generateMipmaps=!1,Wn.needsUpdate=!0),Wn}var Fs=class{constructor(e={}){let{canvas:t=Jd(),context:n=null,depth:s=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:u=!1,outputBufferType:f=un}=e;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([Ea,wa,Sa]),p=new Set([un,Rn,Ps,Is,ba,Ma]),v=new Uint32Array(4),b=new Int32Array(4),M=new N,S=null,w=null,C=[],_=[],A=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=hn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let P=this,R=!1,I=null;this._outputColorSpace=ln;let H=0,W=0,F=null,O=-1,U=null,J=new vt,ee=new vt,le=null,ye=new ge(0),Me=0,Ze=t.width,Ke=t.height,Fe=1,Z=null,fe=null,se=new vt(0,0,Ze,Ke),Ce=new vt(0,0,Ze,Ke),ke=!1,Ie=new dr,ft=!1,Xe=!1,tt=new xt,lt=new N,We=new vt,Et={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},pt=!1;function tn(){return F===null?Fe:1}let D=n;function Tt(E,k){return t.getContext(E,k)}try{let E={alpha:!0,depth:s,stencil:r,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${ga}`),t.addEventListener("webglcontextlost",j,!1),t.addEventListener("webglcontextrestored",Se,!1),t.addEventListener("webglcontextcreationerror",Oe,!1),D===null){let k="webgl2";if(D=Tt(k,E),D===null)throw Tt(k)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(E){throw Re("WebGLRenderer: "+E.message),E}let qe,ot,ce,mt,T,y,B,$,Q,te,ae,X,K,pe,ve,re,ne,Ne,Be,Je,L,ie,q;function me(){qe=new Zv(D),qe.init(),L=new Dy(D,qe),ot=new zv(D,qe,e,L),ce=new Ly(D,qe),ot.reversedDepthBuffer&&u&&ce.buffers.depth.setReversed(!0),mt=new Jv(D),T=new vy,y=new Ny(D,qe,ce,T,ot,L,mt),B=new Yv(P),$=new t0(D),ie=new Uv(D,$),Q=new $v(D,$,mt,ie),te=new Qv(D,Q,$,ie,mt),Ne=new jv(D,ot,y),ve=new Vv(T),ae=new xy(P,B,qe,ot,ie,ve),X=new Uy(P,T),K=new yy,pe=new Ty(qe),ne=new Ov(P,B,ce,te,m,l),re=new Iy(P,te,ot),q=new By(D,mt,ot,ce),Be=new Bv(D,qe,mt),Je=new Kv(D,qe,mt),mt.programs=ae.programs,P.capabilities=ot,P.extensions=qe,P.properties=T,P.renderLists=K,P.shadowMap=re,P.state=ce,P.info=mt}me(),x!==un&&(A=new t_(x,t.width,t.height,s,r));let oe=new Uh(P,D);this.xr=oe,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){let E=qe.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){let E=qe.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return Fe},this.setPixelRatio=function(E){E!==void 0&&(Fe=E,this.setSize(Ze,Ke,!1))},this.getSize=function(E){return E.set(Ze,Ke)},this.setSize=function(E,k,G=!0){if(oe.isPresenting){Te("WebGLRenderer: Can't change size while VR device is presenting.");return}Ze=E,Ke=k,t.width=Math.floor(E*Fe),t.height=Math.floor(k*Fe),G===!0&&(t.style.width=E+"px",t.style.height=k+"px"),A!==null&&A.setSize(t.width,t.height),this.setViewport(0,0,E,k)},this.getDrawingBufferSize=function(E){return E.set(Ze*Fe,Ke*Fe).floor()},this.setDrawingBufferSize=function(E,k,G){Ze=E,Ke=k,Fe=G,t.width=Math.floor(E*G),t.height=Math.floor(k*G),this.setViewport(0,0,E,k)},this.setEffects=function(E){if(x===un){Re("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(E){for(let k=0;k{function de(){if(z.forEach(function(_e){T.get(_e).currentProgram.isReady()&&z.delete(_e)}),z.size===0){V(E);return}setTimeout(de,10)}qe.get("KHR_parallel_shader_compile")!==null?de():setTimeout(de,10)})};let pc=null;function zm(E){pc&&pc(E)}function Fu(){zi.stop()}function ku(){zi.start()}let zi=new Tf;zi.setAnimationLoop(zm),typeof self<"u"&&zi.setContext(self),this.setAnimationLoop=function(E){pc=E,oe.setAnimationLoop(E),E===null?zi.stop():zi.start()},oe.addEventListener("sessionstart",Fu),oe.addEventListener("sessionend",ku),this.render=function(E,k){if(k!==void 0&&k.isCamera!==!0){Re("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(R===!0)return;I!==null&&I.renderStart(E,k);let G=oe.enabled===!0&&oe.isPresenting===!0,z=A!==null&&(F===null||G)&&A.begin(P,F);if(E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),k.parent===null&&k.matrixWorldAutoUpdate===!0&&k.updateMatrixWorld(),oe.enabled===!0&&oe.isPresenting===!0&&(A===null||A.isCompositing()===!1)&&(oe.cameraAutoUpdate===!0&&oe.updateCamera(k),k=oe.getCamera()),E.isScene===!0&&E.onBeforeRender(P,E,k,F),w=pe.get(E,_.length),w.init(k),w.state.textureUnits=y.getTextureUnits(),_.push(w),tt.multiplyMatrices(k.projectionMatrix,k.matrixWorldInverse),Ie.setFromProjectionMatrix(tt,Tn,k.reversedDepth),Xe=this.localClippingEnabled,ft=ve.init(this.clippingPlanes,Xe),S=K.get(E,C.length),S.init(),C.push(S),oe.enabled===!0&&oe.isPresenting===!0){let _e=P.xr.getDepthSensingMesh();_e!==null&&mc(_e,k,-1/0,P.sortObjects)}mc(E,k,0,P.sortObjects),S.finish(),P.sortObjects===!0&&S.sort(Z,fe),pt=oe.enabled===!1||oe.isPresenting===!1||oe.hasDepthSensing()===!1,pt&&ne.addToRenderList(S,E),this.info.render.frame++,ft===!0&&ve.beginShadows();let V=w.state.shadowsArray;if(re.render(V,E,k),ft===!0&&ve.endShadows(),this.info.autoReset===!0&&this.info.reset(),(z&&A.hasRenderPass())===!1){let _e=S.opaque,ue=S.transmissive;if(w.setupLights(),k.isArrayCamera){let be=k.cameras;if(ue.length>0)for(let we=0,Ue=be.length;we0&&Uu(_e,ue,E,k),pt&&ne.render(E),Ou(S,E,k)}F!==null&&W===0&&(y.updateMultisampleRenderTarget(F),y.updateRenderTargetMipmap(F)),z&&A.end(P),E.isScene===!0&&E.onAfterRender(P,E,k),ie.resetDefaultState(),O=-1,U=null,_.pop(),_.length>0?(w=_[_.length-1],y.setTextureUnits(w.state.textureUnits),ft===!0&&ve.setGlobalState(P.clippingPlanes,w.state.camera)):w=null,C.pop(),C.length>0?S=C[C.length-1]:S=null,I!==null&&I.renderEnd()};function mc(E,k,G,z){if(E.visible===!1)return;if(E.layers.test(k.layers)){if(E.isGroup)G=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(k);else if(E.isLightProbeGrid)w.pushLightProbeGrid(E);else if(E.isLight)w.pushLight(E),E.castShadow&&w.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||Ie.intersectsSprite(E)){z&&We.setFromMatrixPosition(E.matrixWorld).applyMatrix4(tt);let _e=te.update(E),ue=E.material;ue.visible&&S.push(E,_e,ue,G,We.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||Ie.intersectsObject(E))){let _e=te.update(E),ue=E.material;if(z&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),We.copy(E.boundingSphere.center)):(_e.boundingSphere===null&&_e.computeBoundingSphere(),We.copy(_e.boundingSphere.center)),We.applyMatrix4(E.matrixWorld).applyMatrix4(tt)),Array.isArray(ue)){let be=_e.groups;for(let we=0,Ue=be.length;we0&&Qr(V,k,G),de.length>0&&Qr(de,k,G),_e.length>0&&Qr(_e,k,G),ce.buffers.depth.setTest(!0),ce.buffers.depth.setMask(!0),ce.buffers.color.setMask(!0),ce.setPolygonOffset(!1)}function Uu(E,k,G,z){if((G.isScene===!0?G.overrideMaterial:null)!==null)return;if(w.state.transmissionRenderTarget[z.id]===void 0){let Ee=qe.has("EXT_color_buffer_half_float")||qe.has("EXT_color_buffer_float");w.state.transmissionRenderTarget[z.id]=new Ct(1,1,{generateMipmaps:!0,type:Ee?Xt:un,minFilter:Li,samples:Math.max(4,ot.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ge.workingColorSpace})}let de=w.state.transmissionRenderTarget[z.id],_e=z.viewport||J;de.setSize(_e.z*P.transmissionResolutionScale,_e.w*P.transmissionResolutionScale);let ue=P.getRenderTarget(),be=P.getActiveCubeFace(),we=P.getActiveMipmapLevel();P.setRenderTarget(de),P.getClearColor(ye),Me=P.getClearAlpha(),Me<1&&P.setClearColor(16777215,.5),P.clear(),pt&&ne.render(G);let Ue=P.toneMapping;P.toneMapping=hn;let Ve=z.viewport;if(z.viewport!==void 0&&(z.viewport=void 0),w.setupLightsView(z),ft===!0&&ve.setGlobalState(P.clippingPlanes,z),Qr(E,G,z),y.updateMultisampleRenderTarget(de),y.updateRenderTargetMipmap(de),qe.has("WEBGL_multisampled_render_to_texture")===!1){let Ee=!1;for(let it=0,Mt=k.length;it0,z.currentProgram=Ve,z.uniformsList=null,Ve}function zu(E){if(E.uniformsList===null){let k=E.currentProgram.getUniforms();E.uniformsList=Ds.seqWithValue(k.seq,E.uniforms)}return E.uniformsList}function Vu(E,k){let G=T.get(E);G.outputColorSpace=k.outputColorSpace,G.batching=k.batching,G.batchingColor=k.batchingColor,G.instancing=k.instancing,G.instancingColor=k.instancingColor,G.instancingMorph=k.instancingMorph,G.skinning=k.skinning,G.morphTargets=k.morphTargets,G.morphNormals=k.morphNormals,G.morphColors=k.morphColors,G.morphTargetsCount=k.morphTargetsCount,G.numClippingPlanes=k.numClippingPlanes,G.numIntersection=k.numClipIntersection,G.vertexAlphas=k.vertexAlphas,G.vertexTangents=k.vertexTangents,G.toneMapping=k.toneMapping}function Vm(E,k){if(E.length===0)return null;if(E.length===1)return E[0].texture!==null?E[0]:null;M.setFromMatrixPosition(k.matrixWorld);for(let G=0,z=E.length;G0),Ee=!!G.morphAttributes.position,it=!!G.morphAttributes.normal,Mt=!!G.morphAttributes.color,gt=hn;z.toneMapped&&(F===null||F.isXRRenderTarget===!0)&&(gt=P.toneMapping);let st=G.morphAttributes.position||G.morphAttributes.normal||G.morphAttributes.color,zt=st!==void 0?st.length:0,xe=T.get(z),nn=w.state.lights;if(ft===!0&&(Xe===!0||E!==U)){let at=E===U&&z.id===O;ve.setState(z,E,at)}let $e=!1;z.version===xe.__version?(xe.needsLights&&xe.lightsStateVersion!==nn.state.version||xe.outputColorSpace!==ue||V.isBatchedMesh&&xe.batching===!1||!V.isBatchedMesh&&xe.batching===!0||V.isBatchedMesh&&xe.batchingColor===!0&&V.colorTexture===null||V.isBatchedMesh&&xe.batchingColor===!1&&V.colorTexture!==null||V.isInstancedMesh&&xe.instancing===!1||!V.isInstancedMesh&&xe.instancing===!0||V.isSkinnedMesh&&xe.skinning===!1||!V.isSkinnedMesh&&xe.skinning===!0||V.isInstancedMesh&&xe.instancingColor===!0&&V.instanceColor===null||V.isInstancedMesh&&xe.instancingColor===!1&&V.instanceColor!==null||V.isInstancedMesh&&xe.instancingMorph===!0&&V.morphTexture===null||V.isInstancedMesh&&xe.instancingMorph===!1&&V.morphTexture!==null||xe.envMap!==we||z.fog===!0&&xe.fog!==de||xe.numClippingPlanes!==void 0&&(xe.numClippingPlanes!==ve.numPlanes||xe.numIntersection!==ve.numIntersection)||xe.vertexAlphas!==Ue||xe.vertexTangents!==Ve||xe.morphTargets!==Ee||xe.morphNormals!==it||xe.morphColors!==Mt||xe.toneMapping!==gt||xe.morphTargetsCount!==zt||!!xe.lightProbeGrid!=w.state.lightProbeGridArray.length>0)&&($e=!0):($e=!0,xe.__version=z.version);let mn=xe.currentProgram;$e===!0&&(mn=eo(z,k,V),I&&z.isNodeMaterial&&I.onUpdateProgram(z,mn,xe));let Dn=!1,hi=!1,is=!1,rt=mn.getUniforms(),St=xe.uniforms;if(ce.useProgram(mn.program)&&(Dn=!0,hi=!0,is=!0),z.id!==O&&(O=z.id,hi=!0),xe.needsLights){let at=Vm(w.state.lightProbeGridArray,V);xe.lightProbeGrid!==at&&(xe.lightProbeGrid=at,hi=!0)}if(Dn||U!==E){ce.buffers.depth.getReversed()&&E.reversedDepth!==!0&&(E._reversedDepth=!0,E.updateProjectionMatrix()),rt.setValue(D,"projectionMatrix",E.projectionMatrix),rt.setValue(D,"viewMatrix",E.matrixWorldInverse);let di=rt.map.cameraPosition;di!==void 0&&di.setValue(D,lt.setFromMatrixPosition(E.matrixWorld)),ot.logarithmicDepthBuffer&&rt.setValue(D,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),(z.isMeshPhongMaterial||z.isMeshToonMaterial||z.isMeshLambertMaterial||z.isMeshBasicMaterial||z.isMeshStandardMaterial||z.isShaderMaterial)&&rt.setValue(D,"isOrthographic",E.isOrthographicCamera===!0),U!==E&&(U=E,hi=!0,is=!0)}if(xe.needsLights&&(nn.state.directionalShadowMap.length>0&&rt.setValue(D,"directionalShadowMap",nn.state.directionalShadowMap,y),nn.state.spotShadowMap.length>0&&rt.setValue(D,"spotShadowMap",nn.state.spotShadowMap,y),nn.state.pointShadowMap.length>0&&rt.setValue(D,"pointShadowMap",nn.state.pointShadowMap,y)),V.isSkinnedMesh){rt.setOptional(D,V,"bindMatrix"),rt.setOptional(D,V,"bindMatrixInverse");let at=V.skeleton;at&&(at.boneTexture===null&&at.computeBoneTexture(),rt.setValue(D,"boneTexture",at.boneTexture,y))}V.isBatchedMesh&&(rt.setOptional(D,V,"batchingTexture"),rt.setValue(D,"batchingTexture",V._matricesTexture,y),rt.setOptional(D,V,"batchingIdTexture"),rt.setValue(D,"batchingIdTexture",V._indirectTexture,y),rt.setOptional(D,V,"batchingColorTexture"),V._colorsTexture!==null&&rt.setValue(D,"batchingColorTexture",V._colorsTexture,y));let ui=G.morphAttributes;if((ui.position!==void 0||ui.normal!==void 0||ui.color!==void 0)&&Ne.update(V,G,mn),(hi||xe.receiveShadow!==V.receiveShadow)&&(xe.receiveShadow=V.receiveShadow,rt.setValue(D,"receiveShadow",V.receiveShadow)),(z.isMeshStandardMaterial||z.isMeshLambertMaterial||z.isMeshPhongMaterial)&&z.envMap===null&&k.environment!==null&&(St.envMapIntensity.value=k.environmentIntensity),St.dfgLUT!==void 0&&(St.dfgLUT.value=Vy()),hi){if(rt.setValue(D,"toneMappingExposure",P.toneMappingExposure),xe.needsLights&&Hm(St,is),de&&z.fog===!0&&X.refreshFogUniforms(St,de),X.refreshMaterialUniforms(St,z,Fe,Ke,w.state.transmissionRenderTarget[E.id]),xe.needsLights&&xe.lightProbeGrid){let at=xe.lightProbeGrid;St.probesSH.value=at.texture,St.probesMin.value.copy(at.boundingBox.min),St.probesMax.value.copy(at.boundingBox.max),St.probesResolution.value.copy(at.resolution)}Ds.upload(D,zu(xe),St,y)}if(z.isShaderMaterial&&z.uniformsNeedUpdate===!0&&(Ds.upload(D,zu(xe),St,y),z.uniformsNeedUpdate=!1),z.isSpriteMaterial&&rt.setValue(D,"center",V.center),rt.setValue(D,"modelViewMatrix",V.modelViewMatrix),rt.setValue(D,"normalMatrix",V.normalMatrix),rt.setValue(D,"modelMatrix",V.matrixWorld),z.uniformsGroups!==void 0){let at=z.uniformsGroups;for(let di=0,ss=at.length;di0&&y.useMultisampledRTT(E)===!1?z=T.get(E).__webglMultisampledFramebuffer:Array.isArray(we)?z=we[G]:z=we,J.copy(E.viewport),ee.copy(E.scissor),le=E.scissorTest}else J.copy(se).multiplyScalar(Fe).floor(),ee.copy(Ce).multiplyScalar(Fe).floor(),le=ke;if(G!==0&&(z=Xm),ce.bindFramebuffer(D.FRAMEBUFFER,z)&&ce.drawBuffers(E,z),ce.viewport(J),ce.scissor(ee),ce.setScissorTest(le),V){let ue=T.get(E.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+k,ue.__webglTexture,G)}else if(de){let ue=k;for(let be=0;be1&&D.readBuffer(D.COLOR_ATTACHMENT0+ue),!ot.textureFormatReadable(Ue)){Re("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!ot.textureTypeReadable(Ve)){Re("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}k>=0&&k<=E.width-z&&G>=0&&G<=E.height-V&&D.readPixels(k,G,z,V,L.convert(Ue),L.convert(Ve),de)}finally{let we=F!==null?T.get(F).__webglFramebuffer:null;ce.bindFramebuffer(D.FRAMEBUFFER,we)}}},this.readRenderTargetPixelsAsync=async function(E,k,G,z,V,de,_e,ue=0){if(!(E&&E.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let be=T.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&_e!==void 0&&(be=be[_e]),be)if(k>=0&&k<=E.width-z&&G>=0&&G<=E.height-V){ce.bindFramebuffer(D.FRAMEBUFFER,be);let we=E.textures[ue],Ue=we.format,Ve=we.type;if(E.textures.length>1&&D.readBuffer(D.COLOR_ATTACHMENT0+ue),!ot.textureFormatReadable(Ue))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!ot.textureTypeReadable(Ve))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let Ee=D.createBuffer();D.bindBuffer(D.PIXEL_PACK_BUFFER,Ee),D.bufferData(D.PIXEL_PACK_BUFFER,de.byteLength,D.STREAM_READ),D.readPixels(k,G,z,V,L.convert(Ue),L.convert(Ve),0);let it=F!==null?T.get(F).__webglFramebuffer:null;ce.bindFramebuffer(D.FRAMEBUFFER,it);let Mt=D.fenceSync(D.SYNC_GPU_COMMANDS_COMPLETE,0);return D.flush(),await Qd(D,Mt,4),D.bindBuffer(D.PIXEL_PACK_BUFFER,Ee),D.getBufferSubData(D.PIXEL_PACK_BUFFER,0,de),D.deleteBuffer(Ee),D.deleteSync(Mt),de}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(E,k=null,G=0){let z=Math.pow(2,-G),V=Math.floor(E.image.width*z),de=Math.floor(E.image.height*z),_e=k!==null?k.x:0,ue=k!==null?k.y:0;y.setTexture2D(E,0),D.copyTexSubImage2D(D.TEXTURE_2D,G,0,0,_e,ue,V,de),ce.unbindTexture()};let qm=D.createFramebuffer(),Ym=D.createFramebuffer();this.copyTextureToTexture=function(E,k,G=null,z=null,V=0,de=0){let _e,ue,be,we,Ue,Ve,Ee,it,Mt,gt=E.isCompressedTexture?E.mipmaps[de]:E.image;if(G!==null)_e=G.max.x-G.min.x,ue=G.max.y-G.min.y,be=G.isBox3?G.max.z-G.min.z:1,we=G.min.x,Ue=G.min.y,Ve=G.isBox3?G.min.z:0;else{let St=Math.pow(2,-V);_e=Math.floor(gt.width*St),ue=Math.floor(gt.height*St),E.isDataArrayTexture?be=gt.depth:E.isData3DTexture?be=Math.floor(gt.depth*St):be=1,we=0,Ue=0,Ve=0}z!==null?(Ee=z.x,it=z.y,Mt=z.z):(Ee=0,it=0,Mt=0);let st=L.convert(k.format),zt=L.convert(k.type),xe;k.isData3DTexture?(y.setTexture3D(k,0),xe=D.TEXTURE_3D):k.isDataArrayTexture||k.isCompressedArrayTexture?(y.setTexture2DArray(k,0),xe=D.TEXTURE_2D_ARRAY):(y.setTexture2D(k,0),xe=D.TEXTURE_2D),ce.activeTexture(D.TEXTURE0),ce.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,k.flipY),ce.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,k.premultiplyAlpha),ce.pixelStorei(D.UNPACK_ALIGNMENT,k.unpackAlignment);let nn=ce.getParameter(D.UNPACK_ROW_LENGTH),$e=ce.getParameter(D.UNPACK_IMAGE_HEIGHT),mn=ce.getParameter(D.UNPACK_SKIP_PIXELS),Dn=ce.getParameter(D.UNPACK_SKIP_ROWS),hi=ce.getParameter(D.UNPACK_SKIP_IMAGES);ce.pixelStorei(D.UNPACK_ROW_LENGTH,gt.width),ce.pixelStorei(D.UNPACK_IMAGE_HEIGHT,gt.height),ce.pixelStorei(D.UNPACK_SKIP_PIXELS,we),ce.pixelStorei(D.UNPACK_SKIP_ROWS,Ue),ce.pixelStorei(D.UNPACK_SKIP_IMAGES,Ve);let is=E.isDataArrayTexture||E.isData3DTexture,rt=k.isDataArrayTexture||k.isData3DTexture;if(E.isDepthTexture){let St=T.get(E),ui=T.get(k),at=T.get(St.__renderTarget),di=T.get(ui.__renderTarget);ce.bindFramebuffer(D.READ_FRAMEBUFFER,at.__webglFramebuffer),ce.bindFramebuffer(D.DRAW_FRAMEBUFFER,di.__webglFramebuffer);for(let ss=0;ss{o.push({source:d,target:u});let f=s[d],m=s[u];f&&(f.degree++,f.outDegree++),m&&(m.degree++,m.inDegree++)};for(let d of Object.keys(e)){let u=r.get(d);if(u===void 0)continue;let f=e[d]??{};for(let m of Object.keys(f)){let x=r.get(m);x!==void 0&&a(u,x)}}if(n.includeUnresolved)for(let d of Object.keys(t)){let u=r.get(d);if(u===void 0)continue;let f=t[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(u,g)}}let l={nodes:s,links:o};n.includeOrphans||(l=Ff(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]),u=new Set(d.slice(0,c).map(([f])=>f));l=Ff(l,(f,m)=>u.has(m))}let h=n.linkCap??null;if(h!==null&&l.links.length>h){let d=u=>l.nodes[u]?.degree??0;l={nodes:l.nodes,links:[...l.links.entries()].sort((u,f)=>Math.min(d(f[1].source),d(f[1].target))-Math.min(d(u[1].source),d(u[1].target))||u[0]-f[0]).slice(0,h).map(([,u])=>u)}}return l}function Ff(i,e){let t=new Map,n=[];i.nodes.forEach((r,o)=>{e(r,o)&&(t.set(o,n.length),n.push(r))});let s=[];for(let r of i.links){let o=t.get(r.source),a=t.get(r.target);o!==void 0&&a!==void 0&&s.push({source:o,target:a})}return{nodes:n,links:s}}function zh(i){let e=2166136261;for(let t=0;t>>0}function Bh(i){return zh(i)/4294967295}function Of(i,e){let t=Bh(i),n=Bh(i+":v"),s=Bh(i+":w"),r=e*Math.cbrt(t),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 ul(i){return 80*Math.cbrt(Math.max(i,1)/1e3)}var dl=class extends fl.Component{constructor(t){super();this.app=t;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(t,n,s){this.includeUnresolved=t,this.includeOrphans=n,this.onChanged=s;let r=(0,fl.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(t=>{this.registerEvent(this.app.metadataCache.on("resolved",()=>t()))})}setIncludeUnresolved(t){t!==this.includeUnresolved&&(this.includeUnresolved=t,this.rebuild(!0))}getIncludeUnresolved(){return this.includeUnresolved}setCaps(t,n){t===this.nodeCap&&n===this.linkCap||(this.nodeCap=t,this.linkCap=n,this.rebuild(!0))}setIncludeOrphans(t){t!==this.includeOrphans&&(this.includeOrphans=t,this.rebuild(!0))}rebuild(t){let n=this.app.vault.getMarkdownFiles().map(c=>({path:c.path,basename:c.basename,size:c.stat.size})),s=kf(n,this.app.metadataCache.resolvedLinks,this.app.metadataCache.unresolvedLinks,{includeUnresolved:this.includeUnresolved,includeOrphans:this.includeOrphans,nodeCap:this.nodeCap,linkCap:this.linkCap}),r=new Map;t&&this.data.nodes.forEach((c,h)=>r.set(c.id,h));let o=this.positions,a=ul(s.nodes.length),l=new Float32Array(s.nodes.length*3);s.nodes.forEach((c,h)=>{let d=r.get(c.id);if(d!==void 0&&d*3+2=(l=(o+a)/2))?o=l:a=l,n=s,!(s=s[d=+h]))return n[d]=r,i;if(c=+i._x.call(null,s.data),e===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),(h=e>=(l=(o+a)/2))?o=l:a=l;while((d=+h)==(u=+(c>=l)));return n[u]=s,n[d]=r,i}function zf(i){Array.isArray(i)||(i=Array.from(i));let e=i.length,t=new Float64Array(e),n=1/0,s=-1/0;for(let r=0,o;rs&&(s=o));if(n>s)return this;this.cover(n).cover(s);for(let r=0;ri||i>=t;)switch(o=+(io||(r=c.x1)=d))&&(c=a[a.length-1],a[a.length-1]=a[a.length-1-h],a[a.length-1-h]=c)}else{var u=Math.abs(i-+this._x.call(null,l.data));u=(c=(o+a)/2))?o=c:a=c,e=t,!(t=t[d=+h]))return this;if(!t.length)break;e[d+1&1]&&(n=e,u=d)}for(;t.data!==i;)if(s=t,!(t=t.next))return this;return(r=t.next)&&delete t.next,s?(r?s.next=r:delete s.next,this):e?(r?e[d]=r:delete e[d],(t=e[0]||e[1])&&t===(e[1]||e[0])&&!t.length&&(n?n[u]=t:this._root=t),this):(this._root=r,this)}function qf(i){for(var e=0,t=i.length;e=(d=(a+c)/2))?a=d:c=d,(g=t>=(u=(l+h)/2))?l=u:h=u,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),e===f&&t===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=e>=(d=(a+c)/2))?a=d:c=d,(g=t>=(u=(l+h)/2))?l=u:h=u;while((p=g<<1|x)===(v=(m>=u)<<1|f>=d));return s[v]=r,s[p]=o,i}function np(i){var e,t,n=i.length,s,r,o=new Array(n),a=new Array(n),l=1/0,c=1/0,h=-1/0,d=-1/0;for(t=0;th&&(h=s),rd&&(d=r));if(l>h||c>d)return this;for(this.cover(l,c).cover(h,d),t=0;ti||i>=s||n>e||e>=r;)switch(c=(eh||(a=m.y0)>d||(l=m.x1)=p)<<1|i>=g)&&(m=u[u.length-1],u[u.length-1]=u[u.length-1-x],u[u.length-1-x]=m)}else{var v=i-+this._x.call(null,f.data),b=e-+this._y.call(null,f.data),M=v*v+b*b;if(M=(u=(o+l)/2))?o=u:l=u,(x=d>=(f=(a+c)/2))?a=f:c=f,e=t,!(t=t[g=x<<1|m]))return this;if(!t.length)break;(e[g+1&3]||e[g+2&3]||e[g+3&3])&&(n=e,p=g)}for(;t.data!==i;)if(s=t,!(t=t.next))return this;return(r=t.next)&&delete t.next,s?(r?s.next=r:delete s.next,this):e?(r?e[g]=r:delete e[g],(t=e[0]||e[1]||e[2]||e[3])&&t===(e[3]||e[2]||e[1]||e[0])&&!t.length&&(n?n[p]=t:this._root=t),this):(this._root=r,this)}function lp(i){for(var e=0,t=i.length;e=(m=(l+d)/2))?l=m:d=m,(S=t>=(x=(c+u)/2))?c=x:u=x,(w=n>=(g=(h+f)/2))?h=g:f=g,r=o,!(o=o[C=w<<2|S<<1|M]))return r[C]=a,i;if(p=+i._x.call(null,o.data),v=+i._y.call(null,o.data),b=+i._z.call(null,o.data),e===p&&t===v&&n===b)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),(M=e>=(m=(l+d)/2))?l=m:d=m,(S=t>=(x=(c+u)/2))?c=x:u=x,(w=n>=(g=(h+f)/2))?h=g:f=g;while((C=w<<2|S<<1|M)===(_=(b>=g)<<2|(v>=x)<<1|p>=m));return r[_]=o,r[C]=a,i}function yp(i){Array.isArray(i)||(i=Array.from(i));let e=i.length,t=new Float64Array(e),n=new Float64Array(e),s=new Float64Array(e),r=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,h=-1/0;for(let d=0,u,f,m,x;dl&&(l=f),mc&&(c=m),xh&&(h=x));if(r>l||o>c||a>h)return this;this.cover(r,o,a).cover(l,c,h);for(let d=0;di||i>=o||s>e||e>=a||r>t||t>=l;)switch(u=(tm||(c=b.y0)>x||(h=b.z0)>g||(d=b.x1)=C)<<2|(e>=w)<<1|i>=S)&&(b=p[p.length-1],p[p.length-1]=p[p.length-1-M],p[p.length-1-M]=b)}else{var _=i-+this._x.call(null,v.data),A=e-+this._y.call(null,v.data),P=t-+this._z.call(null,v.data),R=_*_+A*A+P*P;if(RMath.sqrt((i-n)**2+(e-s)**2+(t-r)**2);function Ep(i,e,t,n){let s=[],r=i-n,o=e-n,a=t-n,l=i+n,c=e+n,h=t+n;return this.visit((d,u,f,m,x,g,p)=>{if(!d.length)do{let v=d.data;Hy(i,e,t,this._x(v),this._y(v),this._z(v))<=n&&s.push(v)}while(d=d.next);return u>l||f>c||m>h||x=(x=(o+c)/2))?o=x:c=x,(b=f>=(g=(a+h)/2))?a=g:h=g,(M=m>=(p=(l+d)/2))?l=p:d=p,e=t,!(t=t[S=M<<2|b<<1|v]))return this;if(!t.length)break;(e[S+1&7]||e[S+2&7]||e[S+3&7]||e[S+4&7]||e[S+5&7]||e[S+6&7]||e[S+7&7])&&(n=e,w=S)}for(;t.data!==i;)if(s=t,!(t=t.next))return this;return(r=t.next)&&delete t.next,s?(r?s.next=r:delete s.next,this):e?(r?e[S]=r:delete e[S],(t=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&t===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!t.length&&(n?n[w]=t:this._root=t),this):(this._root=r,this)}function Ap(i){for(var e=0,t=i.length;e1&&(A=C.y+C.vy-w.y-w.vy||In(h)),a>2&&(P=C.z+C.vz-w.z-w.vz||In(h)),R=Math.sqrt(_*_+A*A+P*P),R=(R-r[M])/R*p*n[M],_*=R,A*=R,P*=R,C.vx-=_*(I=c[M]),a>1&&(C.vy-=A*I),a>2&&(C.vz-=P*I),w.vx+=_*(I=1-I),a>1&&(w.vy+=A*I),a>2&&(w.vz+=P*I)}function m(){if(o){var p,v=o.length,b=i.length,M=new Map(o.map((w,C)=>[e(w,C,o),w])),S;for(p=0,l=new Array(v);ptypeof b=="function")||Math.random,a=v.find(b=>[1,2,3].includes(b))||2,m()},f.links=function(p){return arguments.length?(i=p,m(),f):i},f.id=function(p){return arguments.length?(e=p,f):e},f.iterations=function(p){return arguments.length?(d=+p,f):d},f.strength=function(p){return arguments.length?(t=typeof p=="function"?p:_t(+p),x(),f):t},f.distance=function(p){return arguments.length?(s=typeof p=="function"?p:_t(+p),g(),f):s},f}var Xy={value:()=>{}};function Vp(){for(var i=0,e=arguments.length,t={},n;i=0&&(n=t.slice(s+1),t=t.slice(0,s)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}pl.prototype=Vp.prototype={constructor:pl,on:function(i,e){var t=this._,n=qy(i+"",t),s,r=-1,o=n.length;if(arguments.length<2){for(;++r0)for(var t=new Array(s),n=0,s,r;n=0&&i._call.call(void 0,e),i=i._next;--Os}function Gp(){Qi=(gl=Xr.now())+xl,Os=Hr=0;try{Xp()}finally{Os=0,Ky(),Qi=0}}function $y(){var i=Xr.now(),e=i-gl;e>Hp&&(xl-=e,gl=i)}function Ky(){for(var i,e=ml,t,n=1/0;e;)e._call?(n>e._time&&(n=e._time),i=e,e=e._next):(t=e._next,e._next=null,e=i?i._next=t:ml=t);Wr=i,Yh(n)}function Yh(i){if(!Os){Hr&&(Hr=clearTimeout(Hr));var e=i-Qi;e>24?(i<1/0&&(Hr=setTimeout(Gp,i-Xr.now()-xl)),Gr&&(Gr=clearInterval(Gr))):(Gr||(gl=Xr.now(),Gr=setInterval($y,Hp)),Os=1,Wp(Gp))}}function qp(){let i=1;return()=>(i=(1664525*i+1013904223)%4294967296)/4294967296}var Yp=3;function _l(i){return i.x}function $h(i){return i.y}function Zp(i){return i.z}var Jy=10,jy=Math.PI*(3-Math.sqrt(5)),Qy=Math.PI*20/(9+Math.sqrt(221));function Kh(i,e){e=e||2;var t=Math.min(Yp,Math.max(1,Math.round(e))),n,s=1,r=.001,o=1-Math.pow(r,1/300),a=0,l=.6,c=new Map,h=vl(f),d=Xh("tick","end"),u=qp();i==null&&(i=[]);function f(){m(),d.call("tick",n),s1&&(M.fy==null?M.y+=M.vy*=l:(M.y=M.fy,M.vy=0)),t>2&&(M.fz==null?M.z+=M.vz*=l:(M.z=M.fz,M.vz=0));return n}function x(){for(var p=0,v=i.length,b;p1&&isNaN(b.y)||t>2&&isNaN(b.z)){var M=Jy*(t>2?Math.cbrt(.5+p):t>1?Math.sqrt(.5+p):p),S=p*jy,w=p*Qy;t===1?b.x=M:t===2?(b.x=M*Math.cos(S),b.y=M*Math.sin(S)):(b.x=M*Math.sin(S)*Math.cos(w),b.y=M*Math.cos(S),b.z=M*Math.sin(S)*Math.sin(w))}(isNaN(b.vx)||t>1&&isNaN(b.vy)||t>2&&isNaN(b.vz))&&(b.vx=0,t>1&&(b.vy=0),t>2&&(b.vz=0))}}function g(p){return p.initialize&&p.initialize(i,u,t),p}return x(),n={tick:m,restart:function(){return h.restart(f),n},stop:function(){return h.stop(),n},numDimensions:function(p){return arguments.length?(t=Math.min(Yp,Math.max(1,Math.round(p))),c.forEach(g),n):t},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?(u=p,c.forEach(g),n):u},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,b=(t>1?p.shift():null)||0,M=(t>2?p.shift():null)||0,S=p.shift()||1/0,w=0,C=i.length,_,A,P,R,I,H;for(S*=S,w=0;w1?(d.on(p,v),n):d.on(p)}}}function Jh(){var i,e,t,n,s,r=_t(-30),o,a=1,l=1/0,c=.81;function h(m){var x,g=i.length,p=(e===1?Br(i,_l):e===2?zr(i,_l,$h):e===3?Vr(i,_l,$h,Zp):null).visitAfter(u);for(s=m,x=0;x1&&(m.y=M/v),e>2&&(m.z=S/v)}else{g=m,g.x=g.data.x,e>1&&(g.y=g.data.y),e>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 b=[g,p,v][e-1],M=m.x-t.x,S=e>1?m.y-t.y:0,w=e>2?m.z-t.z:0,C=b-x,_=M*M+S*S+w*w;if(C*C/c<_)return _1&&S===0&&(S=In(n),_+=S*S),e>2&&w===0&&(w=In(n),_+=w*w),_1&&(t.vy+=S*m.value*s/_),e>2&&(t.vz+=w*m.value*s/_)),!0;if(m.length||_>=l)return;(m.data!==t||m.next)&&(M===0&&(M=In(n),_+=M*M),e>1&&S===0&&(S=In(n),_+=S*S),e>2&&w===0&&(w=In(n),_+=w*w),_1&&(t.vy+=S*C),e>2&&(t.vz+=w*C));while(m=m.next)}return h.initialize=function(m,...x){i=m,n=x.find(g=>typeof g=="function")||Math.random,e=x.find(g=>[1,2,3].includes(g))||2,d()},h.strength=function(m){return arguments.length?(r=typeof m=="function"?m:_t(+m),d(),h):r},h.distanceMin=function(m){return arguments.length?(a=m*m,h):Math.sqrt(a)},h.distanceMax=function(m){return arguments.length?(l=m*m,h):Math.sqrt(l)},h.theta=function(m){return arguments.length?(c=m*m,h):Math.sqrt(c)},h}function jh(i){var e=_t(.1),t,n,s;typeof i!="function"&&(i=_t(i==null?0:+i));function r(a){for(var l=0,c=t.length,h;lMath.max(o.degree,1)),this.simNodes=e.nodes.map((o,a)=>({x:t[a*3]??0,y:t[a*3+1]??0,z:t[a*3+2]??0}));let r=e.links.map(o=>({source:o.source,target:o.target}));this.sim=Kh(this.simNodes,3).alphaDecay(1-Math.pow(.001,1/300)).velocityDecay(n.velocityDecay).force("link",Wh(r).distance(n.linkDistance).strength(this.linkStrengthFn(n.linkStrength))).force("charge",Jh().strength(n.charge).distanceMax(800)).force("x",jh(0).strength(n.centerPull)).force("y",Qh(0).strength(n.centerPull+n.flatten)).force("z",eu(0).strength(n.centerPull)).stop(),this.sim.alpha(s),this._ticks=0,this.settled=!1}linkStrengthFn(e){let t=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(t[s]??1,t[r]??1);return Math.min(o*e,1)}}updateParams(e){let t=this.sim;if(!t)return;t.force("charge")?.strength(e.charge);let n=t.force("link");n?.distance(e.linkDistance),n?.strength(this.linkStrengthFn(e.linkStrength)),t.force("x")?.strength(e.centerPull),t.force("y")?.strength(e.centerPull+e.flatten),t.force("z")?.strength(e.centerPull),this.reheat(.5)}step(){let e=this.sim;if(!e||this.settled)return!1;e.tick(),this._ticks++;let t=this.positions,n=this.simNodes;for(let s=0;s{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;oi&&(i=f));if(n>i)return this;this.cover(n).cover(i);for(let o=0;ot||t>=r;)switch(f=+(tf||(o=l.x1)=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=(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=(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;rh&&(h=i),oc&&(c=o));if(s>h||l>c)return this;for(this.cover(s,l).cover(h,c),r=0;rt||t>=i||n>e||e>=o;)switch(l=(eh||(a=p.y0)>c||(s=p.x1)=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=(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=(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;cs&&(s=v),pl&&(l=p),wh&&(h=w));if(o>s||f>l||a>h)return this;this.cover(o,f,a).cover(s,l,h);for(let c=0;ct||t>=f||i>e||e>=a||o>r||r>=s;)switch(x=(rp||(l=d.y0)>w||(h=d.z0)>y||(c=d.x1)=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(WMath.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=(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;e1&&(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);utypeof 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=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(;++o0)for(var r=new Array(i),n=0,i,o;n=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),i1&&(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;u1&&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;N1?(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;w1&&(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/l1&&_===0&&(_=j(n),M+=_*_),e>2&&N===0&&(N=j(n),M+=N*N),M1&&(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),M1&&(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{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(){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{let u=d.data;if(u.type!=="tick")return;let f=new Float32Array(u.buffer);this.positions.set(f.subarray(0,this.positions.length)),this._ticks=u.ticks,this.settled=u.settled,this.dirty=!0,this.worker?.postMessage({type:"buffer",buffer:u.buffer},[u.buffer])};let r=e.nodes.length,o=new Float32Array(t),a=new Uint32Array(e.links.length*2);e.links.forEach((d,u)=>{a[u*2]=d.source,a[u*2+1]=d.target});let l=new Float32Array(r);e.nodes.forEach((d,u)=>l[u]=Math.max(d.degree,1));let c=new ArrayBuffer(r*3*4),h=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:h},[o.buffer,a.buffer,l.buffer,c,h])}step(){let e=this.dirty;return this.dirty=!1,e}isSettled(){return this.settled}reheat(e=.3){this.settled=!1,this.worker?.postMessage({type:"reheat",alpha:e})}updateParams(e){this.settled=!1,this.worker?.postMessage({type:"params",params:e})}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 Us={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 dn=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(){}},tb=new ai(-1,1,1,-1,0,1),tu=class extends ht{constructor(){super(),this.setAttribute("position",new Ot([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Ot([0,2,0,0,2,0],2))}},nb=new tu,ki=class{constructor(e){this._mesh=new Wt(nb,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,tb)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}};var bl=class extends dn{constructor(e,t="tDiffuse"){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof ut?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=ci.clone(e.uniforms),this.material=new ut({name:e.name!==void 0?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this._fsQuad=new ki(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this._fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}};var Yr=class extends dn{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){let s=e.getContext(),r=e.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),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.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)}},Ml=class extends dn{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}};var Sl=class{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){let n=e.getSize(new Ae);this._width=n.width,this._height=n.height,t=new Ct(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Xt}),t.texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new bl(Us),this.copyPass.material.blending=_n,this.timer=new vr}swapBuffers(){let e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){let t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t 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(e){return new ut({defines:{NUM_MIPS:e},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 ); }`})}};Bs.BlurDirectionX=new Ae(1,0);Bs.BlurDirectionY=new Ae(0,1);var Zr={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 #include 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 El=class extends dn{constructor(){super(),this.isOutputPass=!0,this.uniforms=ci.clone(Zr.uniforms),this.material=new Cs({name:Zr.name,uniforms:this.uniforms,vertexShader:Zr.vertexShader,fragmentShader:Zr.fragmentShader}),this._fsQuad=new ki(this.material),this._outputColorSpace=null,this._toneMapping=null}render(e,t,n){this.uniforms.tDiffuse.value=n.texture,this.uniforms.toneMappingExposure.value=e.toneMappingExposure,(this._outputColorSpace!==e.outputColorSpace||this._toneMapping!==e.toneMapping)&&(this._outputColorSpace=e.outputColorSpace,this._toneMapping=e.toneMapping,this.material.defines={},Ge.getTransfer(this._outputColorSpace)===je&&(this.material.defines.SRGB_TRANSFER=""),this._toneMapping===Mr?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===Sr?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===wr?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===Pi?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===Tr?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===Ar?this.material.defines.NEUTRAL_TONE_MAPPING="":this._toneMapping===Er&&(this.material.defines.CUSTOM_TONE_MAPPING=""),this.material.needsUpdate=!0),this.renderToScreen===!0?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}};var Tl=` 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 uSizeContrast; uniform float uBasePoint; uniform float uMinPoint; 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); float localSize = max(uBasePoint, uBasePoint + max(aSize - uBasePoint, 0.0) * uSizeContrast); float pointSize = localSize * uSizeMul * uPixelScale / max(-mv.z, 1.0); gl_PointSize = min(max(pointSize, uMinPoint), uMaxPoint); gl_Position = projectionMatrix * mv; } `,Al=` 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 $r(i){let e=i.map(t=>({prefix:t.query.startsWith("path:")?t.query.slice(5).trim():null,raw:t.query,color:new ge(t.color)}));return t=>{if(t.unresolved)return Qp;for(let n of e)if(n.prefix!==null?t.id.startsWith(n.prefix):t.id.includes(n.raw))return n.color;return em(t.folderTop,!1)}}var Cl=i=>em(i.folderTop,i.unresolved),Jp=[0,40,80,120,160,200,240,280,320],ib=new ge("#9aa4b2"),Qp=new ge("#7a8499"),jp=new Map;function em(i,e){if(e)return Qp;if(i==="")return ib;let t=jp.get(i);if(!t){let n=Jp[zh(i)%Jp.length]??0;t=new ge().setHSL(n/360,.6,.6),jp.set(i,t)}return t}function tm(i,e){let t=i.clone().lerp(e,.5),n={h:0,s:0,l:0};return t.getHSL(n),t.setHSL(n.h,n.s*.4,Math.min(n.l,.35)),t}var sb=[{count:2600,size:1.2},{count:900,size:2},{count:250,size:3}],rb=new ge("#9da8c4"),ob=new ge("#ffffff"),ab=new ge("#ffe9c9"),lb=new ge("#bfd3ff");function cb(i){let e=i>>>0;return()=>{e=e+1831565813>>>0;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}function nu(i){for(let e of i.children){let t=e;t.geometry.dispose(),t.material.dispose()}}var Rl=class{constructor(e,t){this.geometry=e;this.starCount=t;this.active=null;this.nextIn=3;this.attr=e.getAttribute("color"),this.baseColors=new Float32Array(this.attr.array)}update(e,t){if(this.active){this.active.t+=e;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}t<=.01||(this.nextIn-=e,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/t),1.5),90)))}};function iu(i,e=1){let t=new ei,n=cb(5340353),s=null;for(let r of sb){let o={count:Math.max(Math.round(r.count*e),50),size:r.size},a=new Float32Array(o.count*3),l=new Float32Array(o.count*3);for(let u=0;u=3&&n()<.03&&p.multiplyScalar(1.8),l[u*3]=p.r,l[u*3+1]=p.g,l[u*3+2]=p.b}let c=new ht;c.setAttribute("position",new Ye(a,3)),c.setAttribute("color",new Ye(l,3));let h=new Ti({size:o.size,sizeAttenuation:!1,vertexColors:!0,transparent:!0,opacity:.55,depthWrite:!1}),d=new Vn(c,h);d.renderOrder=-1,t.add(d),o.size>=3&&(s=new Rl(c,o.count))}return{group:t,twinkler:s??new Rl(new ht().setAttribute("color",new Ye(new Float32Array(3),3)),1)}}var Pl={id:"deep-space",background:3,starfield:!0,motes:!1,bloomEnabled:!0,lightMode:!1,nodeLightness:null,linkInk:null,linkOpacityScale:1,panelClass:"gx-theme-space"},su={id:"daylight",background:16184559,starfield:!1,motes:!0,bloomEnabled:!1,lightMode:!0,nodeLightness:.44,linkInk:"#2e2a24",linkOpacityScale:.65,panelClass:"gx-theme-light"},ru={id:"night",background:1973790,starfield:!1,motes:!1,bloomEnabled:!1,lightMode:!0,nodeLightness:.62,linkInk:"#8b8f99",linkOpacityScale:.78,panelClass:"gx-theme-night"};var hb=.12,ub=.28,Il=class{constructor(e,t){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=Cl;this.tokens=Pl;this.tierBloomAllowed=!0;this.lastW=2;this.lastH=2;this.baseLinkOpacity=.16;this.focusActive=!1;this.projVec=new N;this.viewVec=new N;this.pixelScale=1;this.nodeScale=1;this.sizeMode="degree";this.graphRadiusEstimate=t,this.renderer=new Fs({antialias:!1,alpha:!1}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.renderer.toneMapping=Pi,this.renderer.toneMappingExposure=1.05,this.renderer.info.autoReset=!1,e.appendChild(this.renderer.domElement),this.scene.background=new ge(this.tokens.background),this.camera=new Ht(60,1,.5,5e4);let n=iu(t*6.5);this.starfield=n.group,this.twinkler=n.twinkler,this.scene.add(this.starfield),this.composer=new Sl(this.renderer),this.renderPass=new wl(this.scene,this.camera),this.bloomPass=new Bs(new Ae(2,2),to.strength,to.radius,to.threshold),this.outputPass=new El,this.composer.addPass(this.renderPass),this.composer.addPass(this.bloomPass),this.composer.addPass(this.outputPass)}setColorFn(e){this.colorFn=e}setData(e,t){this.data=e,this.positions=t,this.disposeGraphObjects();let n=e.nodes.length,s=e.links.length,r=new Float32Array(n*3);r.set(t.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;an&&(n=r)}this.revealBuf.length=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.001,e.motes&&!this.motes&&this.buildMotes(),this.motes&&(this.motes.visible=e.motes),this.linkMaterial&&(this.linkMaterial.opacity=this.effectiveLinkOpacity()),this.recolor(),this.setSelectedLinks(this.selLinkIdx)}get currentTokens(){return this.tokens}buildMotes(){let t=new Float32Array(1800),n=this.graphRadiusEstimate*2.2;for(let o=0;o<600;o++)t[o*3]=(Math.random()*2-1)*n,t[o*3+1]=(Math.random()*2-1)*n,t[o*3+2]=(Math.random()*2-1)*n;let s=new ht;s.setAttribute("position",new Ye(t,3));let r=new Ti({color:new ge("#d8d4cb"),size:1.6,sizeAttenuation:!0,transparent:!0,opacity:.5,depthWrite:!1});this.motes=new Vn(s,r),this.motes.renderOrder=-1,this.scene.add(this.motes)}render(e){this.starfield.rotation.y+=vc*e,this.starfield.visible&&this.twinkler.update(e,this.twinkleFreq),this.motes?.visible&&(this.motes.rotation.y-=vc*2*e),this.dimAnimating&&this.stepDim(e),this.reveal&&this.stepReveal(performance.now()),this.renderer.info.reset(),this.composer.render()}stepDim(e){let t=Math.min(e/ub,1),n=!1;for(let s=0;s.001}getBloomStrength(){return this.bloomPass.enabled?this.bloomPass.strength:0}setBloomStrength(e){this.bloomPass.strength=e,this.bloomPass.enabled=this.tokens.bloomEnabled&&this.tierBloomAllowed&&e>.001}applyTier(e,t){this.tierBloomAllowed=e.bloomAllowed,this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,e.pixelRatioCap)),this.bloomPass.enabled=this.tokens.bloomEnabled&&this.tierBloomAllowed&&t>.001;let n=this.starfield.visible,s=this.starfield.rotation.y;nu(this.starfield),this.scene.remove(this.starfield);let r=iu(this.graphRadiusEstimate*6.5,e.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(e){this.baseLinkOpacity=e,this.linkMaterial&&(this.linkMaterial.opacity=this.effectiveLinkOpacity())}setNodeScale(e){this.nodeScale=e;let t=this.nodeMaterial?.uniforms.uSizeMul;t&&(t.value=e)}resize(e,t){if(e<2||t<2)return;this.lastW=e,this.lastH=t,this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.renderer.setSize(e,t),this.composer.setSize(e,t),this.bloomPass.resolution.set(e,t);let n=t*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(e,t,n){this.projVec.set(this.positions[e*3]??0,this.positions[e*3+1]??0,this.positions[e*3+2]??0);let s=-this.viewVec.copy(this.projVec).applyMatrix4(this.camera.matrixWorldInverse).z;return this.projVec.project(this.camera),{x:(this.projVec.x+1)/2*t,y:(1-this.projVec.y)/2*n,behind:s<=0||this.projVec.z<-1||this.projVec.z>1}}projectedNodeHit(e,t,n){this.projVec.set(this.positions[e*3]??0,this.positions[e*3+1]??0,this.positions[e*3+2]??0);let s=-this.viewVec.copy(this.projVec).applyMatrix4(this.camera.matrixWorldInverse).z;return this.projVec.project(this.camera),{x:(this.projVec.x+1)/2*t,y:(1-this.projVec.y)/2*n,depth:s,visible:s>0&&this.projVec.z>=-1&&this.projVec.z<=1}}nodeScreenRadius(e,t){let n=Math.min((this.sizes[e]??Vi)*this.nodeScale*this.pixelScale/Math.max(t,1),110*this.renderer.getPixelRatio());return Math.max(n/this.renderer.getPixelRatio()/2,1)}pickNearest(e,t,n,s,r){let o=-1,a=1/0,l=1/0,c=-1,h=r;for(let d=0;d=0?o:c}nodeRadius(e){return this.sizes[e]??Vi}nodePosition(e,t){return t.set(this.positions[e*3]??0,this.positions[e*3+1]??0,this.positions[e*3+2]??0)}nodeColorHex(e){let t=this.data.nodes[e];return t?`#${this.colorFn(t).getHexString()}`:"#9aa4b2"}cameraDistanceTo(e){return this.projVec.set(this.positions[e*3]??0,this.positions[e*3+1]??0,this.positions[e*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(),nu(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 db={day:"#f8fafc",night:"#1e1e1e"};function Ll(i,e=db[i]){let t=fb(i);return t&&gb(t,i)?t:mb(e)}function fb(i){let e=activeDocument,t=e.body,n=i==="night"?"theme-dark":"theme-light",s=i==="night"?"theme-light":"theme-dark",r=t.classList.contains("theme-light"),o=t.classList.contains("theme-dark");try{(!t.classList.contains(n)||t.classList.contains(s))&&(t.classList.remove(s),t.classList.add(n));let a=e.defaultView?.getComputedStyle(t)??getComputedStyle(t);return pb(a.getPropertyValue("--background-primary").trim()||a.backgroundColor)}finally{t.classList.toggle("theme-light",r),t.classList.toggle("theme-dark",o)}}function pb(i){let e=activeDocument,t=e.body,n=e.createElement("span");if(n.setCssStyles({color:i,display:"none"}),!n.style.color)return null;t.appendChild(n);try{let s=e.defaultView?.getComputedStyle(n).color??getComputedStyle(n).color;return xb(s)}finally{n.remove()}}function mb(i){return typeof i=="number"?`#${i.toString(16).padStart(6,"0")}`:i}function gb(i,e){let t=yb(i);if(!t)return!1;let n=bb(t);return e==="day"?n>=.5:n<=.45}function xb(i){if(i.trim().toLowerCase()==="transparent")return null;let e=i.match(/^rgba?\((.*)\)$/i);if(!e)return sm(i);let t=e[1]?.replaceAll(","," ").split(/[ /]+/).map(r=>r.trim()).filter(Boolean);if(!t||t.length<3)return null;let n=t[3]===void 0?1:_b(t[3]);if(n===null||n<=.05)return null;let s=t.slice(0,3).map(vb);return s.some(r=>r===null)?null:`#${s.map(r=>r.toString(16).padStart(2,"0")).join("")}`}function sm(i){let e=i.trim(),t=e.match(/^#([0-9a-f]{3})$/i);if(t?.[1])return`#${[...t[1]].map(s=>`${s}${s}`).join("").toLowerCase()}`;let n=e.match(/^#([0-9a-f]{6})$/i);return n?.[1]?`#${n[1].toLowerCase()}`:null}function vb(i){if(i.endsWith("%")){let t=Number.parseFloat(i);return Number.isFinite(t)?nm(t/100*255):null}let e=Number.parseFloat(i);return Number.isFinite(e)?nm(e):null}function _b(i){if(i.endsWith("%")){let t=Number.parseFloat(i);return Number.isFinite(t)?im(t/100):null}let e=Number.parseFloat(i);return Number.isFinite(e)?im(e):null}function nm(i){return Math.min(255,Math.max(0,Math.round(i)))}function im(i){return Math.min(1,Math.max(0,i))}function yb(i){let e=sm(i);return e?{r:Number.parseInt(e.slice(1,3),16),g:Number.parseInt(e.slice(3,5),16),b:Number.parseInt(e.slice(5,7),16)}:null}function bb(i){let e=t=>{let n=t/255;return n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4)};return .2126*e(i.r)+.7152*e(i.g)+.0722*e(i.b)}var ou={type:"change"},cu={type:"start"},hu={type:"end"},rm=1e-6,Qe={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4},Nl=new Ae,Oi=new Ae,Mb=new N,Dl=new N,au=new N,zs=new vn,om=new N,Fl=new N,lu=new N,kl=new N,Ol=class extends _r{constructor(e,t=null){super(e,t),this.screen={left:0,top:0,width:0,height:0},this.rotateSpeed=1,this.zoomSpeed=1.2,this.panSpeed=.3,this.noRotate=!1,this.noZoom=!1,this.noPan=!1,this.staticMoving=!1,this.dynamicDampingFactor=.2,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.keys=["KeyA","KeyS","KeyD"],this.mouseButtons={LEFT:Cn.ROTATE,MIDDLE:Cn.DOLLY,RIGHT:Cn.PAN},this.target=new N,this.state=Qe.NONE,this.keyState=Qe.NONE,this._lastPosition=new N,this._lastZoom=1,this._touchZoomDistanceStart=0,this._touchZoomDistanceEnd=0,this._lastAngle=0,this._eye=new N,this._movePrev=new Ae,this._moveCurr=new Ae,this._lastAxis=new N,this._zoomStart=new Ae,this._zoomEnd=new Ae,this._panStart=new Ae,this._panEnd=new Ae,this._pointers=[],this._pointerPositions={},this._onPointerMove=wb.bind(this),this._onPointerDown=Sb.bind(this),this._onPointerUp=Eb.bind(this),this._onPointerCancel=Tb.bind(this),this._onContextMenu=Nb.bind(this),this._onMouseWheel=Lb.bind(this),this._onKeyDown=Cb.bind(this),this._onKeyUp=Ab.bind(this),this._onTouchStart=Db.bind(this),this._onTouchMove=Fb.bind(this),this._onTouchEnd=kb.bind(this),this._onMouseDown=Rb.bind(this),this._onMouseMove=Pb.bind(this),this._onMouseUp=Ib.bind(this),this._target0=this.target.clone(),this._position0=this.object.position.clone(),this._up0=this.object.up.clone(),this._zoom0=this.object.zoom,t!==null&&(this.connect(t),this.handleResize()),this.update()}connect(e){super.connect(e),window.addEventListener("keydown",this._onKeyDown),window.addEventListener("keyup",this._onKeyUp),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerCancel),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="none"}disconnect(){window.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("keyup",this._onKeyUp),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._onPointerCancel),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction=""}dispose(){this.disconnect()}handleResize(){let e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}update(){this._eye.subVectors(this.object.position,this.target),this.noRotate||this._rotateCamera(),this.noZoom||this._zoomCamera(),this.noPan||this._panCamera(),this.object.position.addVectors(this.target,this._eye),this.object.isPerspectiveCamera?(this._checkDistances(),this.object.lookAt(this.target),this._lastPosition.distanceToSquared(this.object.position)>rm&&(this.dispatchEvent(ou),this._lastPosition.copy(this.object.position))):this.object.isOrthographicCamera?(this.object.lookAt(this.target),(this._lastPosition.distanceToSquared(this.object.position)>rm||this._lastZoom!==this.object.zoom)&&(this.dispatchEvent(ou),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom)):console.warn("THREE.TrackballControls: Unsupported camera type.")}reset(){this.state=Qe.NONE,this.keyState=Qe.NONE,this.target.copy(this._target0),this.object.position.copy(this._position0),this.object.up.copy(this._up0),this.object.zoom=this._zoom0,this.object.updateProjectionMatrix(),this._eye.subVectors(this.object.position,this.target),this.object.lookAt(this.target),this.dispatchEvent(ou),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom}_panCamera(){if(Oi.copy(this._panEnd).sub(this._panStart),Oi.lengthSq()){if(this.object.isOrthographicCamera){let e=(this.object.right-this.object.left)/this.object.zoom/this.domElement.clientWidth,t=(this.object.top-this.object.bottom)/this.object.zoom/this.domElement.clientWidth;Oi.x*=e,Oi.y*=t}Oi.multiplyScalar(this._eye.length()*this.panSpeed),Dl.copy(this._eye).cross(this.object.up).setLength(Oi.x),Dl.add(Mb.copy(this.object.up).setLength(Oi.y)),this.object.position.add(Dl),this.target.add(Dl),this.staticMoving?this._panStart.copy(this._panEnd):this._panStart.add(Oi.subVectors(this._panEnd,this._panStart).multiplyScalar(this.dynamicDampingFactor))}}_rotateCamera(){kl.set(this._moveCurr.x-this._movePrev.x,this._moveCurr.y-this._movePrev.y,0);let e=kl.length();e?(this._eye.copy(this.object.position).sub(this.target),om.copy(this._eye).normalize(),Fl.copy(this.object.up).normalize(),lu.crossVectors(Fl,om).normalize(),Fl.setLength(this._moveCurr.y-this._movePrev.y),lu.setLength(this._moveCurr.x-this._movePrev.x),kl.copy(Fl.add(lu)),au.crossVectors(kl,this._eye).normalize(),e*=this.rotateSpeed,zs.setFromAxisAngle(au,e),this._eye.applyQuaternion(zs),this.object.up.applyQuaternion(zs),this._lastAxis.copy(au),this._lastAngle=e):!this.staticMoving&&this._lastAngle&&(this._lastAngle*=Math.sqrt(1-this.dynamicDampingFactor),this._eye.copy(this.object.position).sub(this.target),zs.setFromAxisAngle(this._lastAxis,this._lastAngle),this._eye.applyQuaternion(zs),this.object.up.applyQuaternion(zs)),this._movePrev.copy(this._moveCurr)}_zoomCamera(){let e;this.state===Qe.TOUCH_ZOOM_PAN?(e=this._touchZoomDistanceStart/this._touchZoomDistanceEnd,this._touchZoomDistanceStart=this._touchZoomDistanceEnd,this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=sl.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")):(e=1+(this._zoomEnd.y-this._zoomStart.y)*this.zoomSpeed,e!==1&&e>0&&(this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=sl.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")),this.staticMoving?this._zoomStart.copy(this._zoomEnd):this._zoomStart.y+=(this._zoomEnd.y-this._zoomStart.y)*this.dynamicDampingFactor)}_getMouseOnScreen(e,t){return Nl.set((e-this.screen.left)/this.screen.width,(t-this.screen.top)/this.screen.height),Nl}_getMouseOnCircle(e,t){return Nl.set((e-this.screen.width*.5-this.screen.left)/(this.screen.width*.5),(this.screen.height+2*(this.screen.top-t))/this.screen.width),Nl}_addPointer(e){this._pointers.push(e)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;tthis.maxDistance*this.maxDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.maxDistance)),this._zoomStart.copy(this._zoomEnd)),this._eye.lengthSq(){this.dom.focus(),this.controls.mouseButtons.LEFT=n.metaKey||n.shiftKey||n.ctrlKey?Cn.PAN:Cn.ROTATE,this.markInput()},t=()=>this.markInput();this.dom.addEventListener("pointerdown",e,{capture:!0}),this.dom.addEventListener("wheel",t,{passive:!0}),this.dom.addEventListener("touchstart",t,{passive:!0}),this.disposeFns.push(()=>{this.dom.removeEventListener("pointerdown",e,{capture:!0}),this.dom.removeEventListener("wheel",t),this.dom.removeEventListener("touchstart",t)})}bindKeys(){let e=s=>{let r=s.key.toLowerCase();this.shiftHeld=s.shiftKey,Ub.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())},t=s=>{this.shiftHeld=s.shiftKey,this.pressed.delete(s.key.toLowerCase())},n=()=>this.pressed.clear();this.dom.addEventListener("keydown",e),this.dom.addEventListener("keyup",t),this.dom.addEventListener("blur",n),this.disposeFns.push(()=>{this.dom.removeEventListener("keydown",e),this.dom.removeEventListener("keyup",t),this.dom.removeEventListener("blur",n)})}applyFly(e){if(this.pressed.size===0)return!1;let t=this.camera.position.distanceTo(this.controls.target),n=Math.min(Math.max(t*.8,10),600)*(this.shiftHeld?3:1),s=this.camera.getWorldDirection(this.tmpDir);this.tmpRight.crossVectors(s,this.camera.up).normalize();let r=new N;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*e),this.camera.position.add(r),this.controls.target.add(r),this.lastInputAt=performance.now(),!0)}setInitialFraming(e){this.camera.position.copy(this.framingPosition(e)),this.controls.target.set(0,0,0),this.controls.update()}framingPosition(e){let t=e*2.2,n=18*Math.PI/180;return new N(t*Math.cos(n),t*Math.sin(n),t*.35)}resetView(e,t){this.startTween(this.framingPosition(e),new N(0,0,0),1200,t)}beginFocusOrbit(e){this.pendingDensityDir=e,this.cruiseAnchor=null,this.lastInputAt=performance.now()-Fn.resumeDelayMs-1}flyTo(e,t,n){let s=Math.min(Math.max(t*Zn.distancePerRadius,Zn.minDistance),Zn.maxDistance),r=this.camera.position.clone().sub(e);r.lengthSq()<1e-6&&r.set(0,0,1),this.tmpSph.setFromVector3(r),this.tmpSph.theta+=Zn.azimuthOffsetRad,this.tmpSph.radius=s;let o=e.clone().add(new N().setFromSpherical(this.tmpSph)),a=this.camera.position.distanceTo(o),l=Math.min(Math.max(Zn.minMs+Zn.msPerWorldUnit*a,Zn.minMs),Zn.maxMs);this.startTween(o,e.clone(),l,n)}startTween(e,t,n,s){this.tween={t0:performance.now(),durMs:n,fromPos:this.camera.position.clone(),toPos:e,fromTarget:this.controls.target.clone(),toTarget:t},s&&(this.tween.onDone=s)}update(e,t){if(this.tween){let r=this.tween,o=Math.min((e-r.t0)/r.durMs,1),a=Ob(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=e),!1}let n=this.applyFly(t),s=e-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 Gn().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 Gn().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+=t*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 e of this.disposeFns)e();this.disposeFns=[],this.controls.dispose()}};var am=[{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 Bl=[{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 Jt=class{constructor(e,t){this.spec=t;let n=e.createDiv({cls:"gx-slider"}),s=n.createDiv({cls:"gx-slider-head"});s.createSpan({cls:"gx-slider-label",text:t.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:`${t.defaultLabel??"Default"} ${this.fmt(t.defaultValue)}`}}),this.thumbEl=this.trackEl.createDiv({cls:"gx-slider-thumb"});let r=n.createDiv({cls:"gx-slider-bounds"});r.createSpan({text:this.fmt(t.min)}),r.createSpan({text:this.fmt(t.max)}),this.bindDrag(),this.trackEl.addEventListener("dblclick",()=>{t.set(t.defaultValue),this.refresh(),t.onInput()}),this.refresh()}fmt(e){return this.spec.fmt?this.spec.fmt(e):e.toFixed(2)}posToValue(e){let{min:t,max:n,defaultValue:s,step:r}=this.spec,o=e<=.5?t+(s-t)*(e/.5):s+(n-s)*((e-.5)/.5),a=Math.round(o/r)*r;return Math.min(Math.max(a,t),n)}valueToPos(e){let{min:t,max:n,defaultValue:s}=this.spec;return e<=s?s===t?0:.5*(e-t)/(s-t):n===s?1:.5+.5*(e-s)/(n-s)}bindDrag(){let e=t=>{let n=this.trackEl.getBoundingClientRect(),s=Math.min(Math.max((t.clientX-n.left)/n.width,0),1);this.spec.set(this.posToValue(s)),this.refresh(),this.spec.onInput()};this.trackEl.addEventListener("pointerdown",t=>{t.preventDefault(),this.trackEl.setPointerCapture(t.pointerId),e(t);let n=r=>e(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 e=this.spec.get(),t=this.valueToPos(e);this.thumbEl.style.left=`${(t*100).toFixed(2)}%`;let n=Math.min(t,.5),s=Math.abs(t-.5);this.fillEl.style.left=`${(n*100).toFixed(2)}%`,this.fillEl.style.width=`${(s*100).toFixed(2)}%`,this.valueEl.setText(this.fmt(e)),this.valueEl.toggleClass("is-default",Math.abs(e-this.spec.defaultValue){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.presetSelect=null,this.unresolvedBtn=null,this.orphanBtn=null,this.sizeBySelect=null,this.qualityBtn=null;let e=this.body.createDiv({cls:"mwm-mode-switch"});e.createDiv({cls:"mwm-mode-switch-label",text:this.tt("view.mode")});let t=e.createDiv({cls:"galaxy-mode-row mwm-mode-row"});this.modeButton(t,"radial2d"),this.modeButton(t,"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(e){let t=e.createDiv({cls:"galaxy-panel-row"});t.createEl("button",{text:this.tt("common.search")}).addEventListener("click",this.cb.onSearch),t.createEl("button",{text:this.tt("common.recenter")}).addEventListener("click",this.cb.onRecenter),t.createEl("button",{text:this.tt("3d.reveal")}).addEventListener("click",this.cb.onReveal)}renderAppearancePage(e){let t=this.settings,n=rn,s=e.createEl("label",{cls:"mwm-panel-field"});s.createSpan({text:this.tt("view.theme")}),this.presetSelect=s.createEl("select");for(let[u,f]of this.themeOptions())this.presetSelect.createEl("option",{attr:{value:u},text:f});this.presetSelect.value=t.preset,this.presetSelect.addEventListener("change",()=>{this.presetSelect&&(t.preset=this.presetSelect.value,this.cb.onPreset())});let r=e.createDiv({cls:"gx-chips"});for(let u of am){let f=r.createEl("button",{cls:"gx-chip",text:this.tt(`style.${u.id}`)});f.addEventListener("click",()=>{this.cb.onStylePreset(u),this.refreshAll(),this.markActiveChip(u.id)}),f.dataset.presetId=u.id,this.styleChips.push(f)}this.sliders.push(new Jt(e,this.slider("3d.nodeSize",.3,2.5,.05,n.look.nodeSize,()=>t.look.nodeSize,u=>t.look.nodeSize=u,uu("x"),this.cb.onLook)),new Jt(e,this.slider("3d.linkOpacity",0,.6,.01,n.look.linkOpacity,()=>t.look.linkOpacity,u=>t.look.linkOpacity=u,void 0,this.cb.onLook)),new Jt(e,this.slider("3d.twinkle",0,2,.1,n.look.twinkle,()=>t.look.twinkle,u=>t.look.twinkle=u,u=>u<.05?this.tt("3d.twinkleOff"):u.toFixed(1),this.cb.onLook)),new Jt(e,this.slider("3d.glowStrength",0,2.5,.05,n.bloom.strength,()=>t.bloom.strength,u=>t.bloom.strength=u,void 0,this.cb.onBloom)),new Jt(e,this.slider("3d.glowRadius",0,1.2,.05,n.bloom.radius,()=>t.bloom.radius,u=>t.bloom.radius=u,void 0,this.cb.onBloom)),new Jt(e,this.slider("3d.glowThreshold",0,1,.05,n.bloom.threshold,()=>t.bloom.threshold,u=>t.bloom.threshold=u,void 0,this.cb.onBloom)));let o=e.createEl("label",{cls:"mwm-panel-field"});o.createSpan({text:this.tt("3d.sizeBy")}),this.sizeBySelect=o.createEl("select");for(let[u,f]of this.sizeOptions())this.sizeBySelect.createEl("option",{attr:{value:u},text:f});this.sizeBySelect.value=t.look.sizeBy,this.sizeBySelect.addEventListener("change",()=>{this.sizeBySelect&&(t.look.sizeBy=this.sizeBySelect.value,this.cb.onSizeBy())});let a=e.createEl("select",{cls:"gx-theme-select"}),l=a.createEl("option",{text:this.tt("3d.colorTheme"),value:""});l.disabled=!0;for(let u of Bl)a.createEl("option",{text:this.tt(`color.${u.id}`),value:u.id});a.value=Bl.some(u=>u.id===t.colorTheme)?t.colorTheme:"",a.value||(l.selected=!0),a.addEventListener("change",()=>{let u=Bl.find(f=>f.id===a.value);u&&this.cb.onColorTheme(u)});let c=e.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(e){let t=this.settings,n=rn;this.sliders.push(new Jt(e,this.slider("3d.repel",20,400,5,n.physics.repel,()=>t.physics.repel,s=>t.physics.repel=s,s=>String(Math.round(s)),this.cb.onPhysics)),new Jt(e,this.slider("3d.linkDistance",20,200,5,n.physics.linkDistance,()=>t.physics.linkDistance,s=>t.physics.linkDistance=s,s=>String(Math.round(s)),this.cb.onPhysics)),new Jt(e,this.slider("3d.linkStrength",.1,2,.1,n.physics.linkStrength,()=>t.physics.linkStrength,s=>t.physics.linkStrength=s,uu("x1"),this.cb.onPhysics)),new Jt(e,this.slider("3d.centerPull",0,.2,.005,n.physics.centerPull,()=>t.physics.centerPull,s=>t.physics.centerPull=s,s=>s.toFixed(3),this.cb.onPhysics)),new Jt(e,this.slider("3d.flatten",0,.8,.02,n.physics.flatten,()=>t.physics.flatten,s=>t.physics.flatten=s,void 0,this.cb.onPhysics)))}renderMotionPage(e){let t=this.settings,n=rn,s=e.createDiv({cls:"galaxy-panel-row"});this.cruiseBtn=s.createEl("button",{text:this.cruiseLabel()}),this.cruiseBtn.addEventListener("click",()=>{t.cruise=!t.cruise,this.cruiseBtn?.setText(this.cruiseLabel()),this.cb.onCruise(t.cruise)}),this.sliders.push(new Jt(e,this.slider("3d.speed",.2,3,.1,n.cruiseSpeed,()=>t.cruiseSpeed,o=>t.cruiseSpeed=o,uu("x1"),this.cb.onCruiseSpeed)));let r=e.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(e){let t=this.settings,n=e.createDiv({cls:"galaxy-panel-row"});this.unresolvedBtn=n.createEl("button",{text:this.unresolvedLabel()}),this.unresolvedBtn.addEventListener("click",()=>{t.showUnresolved=!t.showUnresolved,this.unresolvedBtn?.setText(this.unresolvedLabel()),this.cb.onShowUnresolved(t.showUnresolved)}),this.orphanBtn=n.createEl("button",{text:this.orphanLabel()}),this.orphanBtn.addEventListener("click",()=>{t.showOrphans=!t.showOrphans,this.orphanBtn?.setText(this.orphanLabel()),this.cb.onShowOrphans(t.showOrphans)});let s=e.createDiv({cls:"galaxy-panel-row"});this.qualityBtn=s.createEl("button",{text:this.qualityLabel()}),this.qualityBtn.addEventListener("click",()=>{let o=["auto","high","low","mobile"];t.qualityOverride=o[(o.indexOf(t.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(e,t){e.createEl("button",{cls:this.viewMode===t?"is-active":"",text:pi(this.language,t)}).addEventListener("click",()=>this.cb.onViewMode?.(t))}slider(e,t,n,s,r,o,a,l,c){return{label:this.tt(e),min:t,max:n,step:s,defaultValue:r,get:o,set:a,fmt:l,onInput:c,defaultLabel:this.tt("common.default")}}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")}qualityLabel(){return this.tt(`3d.quality.${this.settings.qualityOverride}`)}themeOptions(){return[["auto",this.tt("theme.auto")],["night",this.tt("theme.night")],["day",this.tt("theme.day")],["deep-space",this.tt("theme.deep")]]}sizeOptions(){return[["degree",this.tt("3d.sizeOption.degree")],["fileSize",this.tt("3d.sizeOption.fileSize")],["uniform",this.tt("3d.sizeOption.uniform")]]}markActiveChip(e){for(let t of this.styleChips)t.toggleClass("is-active",t.dataset.presetId===e)}refreshAll(){for(let e of this.sliders)e.refresh();this.cruiseBtn?.setText(this.cruiseLabel()),this.presetSelect&&(this.presetSelect.value=this.settings.preset),this.unresolvedBtn?.setText(this.unresolvedLabel()),this.orphanBtn?.setText(this.orphanLabel()),this.sizeBySelect&&(this.sizeBySelect.value=this.settings.look.sizeBy),this.qualityBtn?.setText(this.qualityLabel())}setLanguage(e){this.language=e,this.render()}setPanelTheme(e){this.root.removeClass("gx-theme-space"),this.root.removeClass("gx-theme-night"),this.root.removeClass("gx-theme-dark"),this.root.removeClass("gx-theme-light"),this.root.addClass(e)}dispose(){this.root.remove(),this.sliders=[],this.styleChips=[]}tt(e,t={}){return Le(this.language,e,t)}};function uu(i){return e=>i==="x1"?`${e.toFixed(1)}x`:`${e.toFixed(2)}x`}var Gl=require("obsidian");var Vl=class{constructor(e,t,n,s,r="en"){this.app=t;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=e.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(e){if(this.language=e,this.cardIndex>=0){let t=this.data.nodes[this.cardIndex];t&&this.buildCard(t,this.cardIndex)}}setBudgets(e,t,n){this.hubBudget=e,this.neighborBudget=t,this.mobileCard=n,this.setData(this.data,this.graphRadius)}setData(e,t){this.data=e,this.graphRadius=t;for(let n of this.hubEls)n.el.remove();this.hubEls=[...e.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(e){if(this.hoverIndex=e,e<0){this.hoverEl.hide();return}let t=this.data.nodes[e];t&&(this.hoverEl.setText(t.name),this.hoverEl.show())}refreshBottomInset(){let e=0,t=activeDocument.querySelector(".mobile-navbar");if(t){let n=t.getBoundingClientRect(),s=this.root.getBoundingClientRect();e=Math.max(0,Math.round(s.bottom-n.top))}this.root.setCssProps({"--gx-bottom-inset":`${e}px`})}setSelection(e,t){for(let r of this.neighborEls)r.el.remove();if(this.neighborEls=[],this.cardIndex=e,e<0){this.card.hide();return}let n=[...t].filter(r=>r!==e).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[e];s&&(this.mobileCard&&(this.refreshBottomInset(),this.card.style.removeProperty("transform")),this.buildCard(s,e))}buildCard(e,t){this.card.empty(),this.card.show(),this.card.createDiv({cls:"gx-card-title",text:e.name});let n=this.card.createDiv({cls:"gx-card-meta"}),s=n.createSpan({cls:"gx-card-dot"});s.style.background=this.renderer.nodeColorHex(t),n.createSpan({text:e.unresolved?this.tt("3d.card.unresolved"):e.id.includes("/")?e.id.slice(0,e.id.lastIndexOf("/")):this.tt("3d.card.root")});let r=e.unresolved?null:this.app.vault.getAbstractFileByPath(e.id),o=r instanceof Gl.TFile?r:null;if(o){let h=this.app.metadataCache.getFileCache(o),d=h?(0,Gl.getAllTags)(h)??[]:[];if(d.length>0){let u=this.card.createDiv({cls:"gx-card-tags"});for(let f of d.slice(0,5))u.createSpan({cls:"gx-card-tag",text:f})}}if(this.card.createDiv({cls:"gx-card-stats"}).setText(this.tt("3d.card.stats",{in:e.inDegree,out:e.outDegree})+(o?this.tt("3d.card.modified",{date:new Date(o.stat.mtime).toLocaleDateString(this.language==="zh"?"zh-CN":"en-US")}):"")),o){let h=this.card.createDiv({cls:"gx-card-snippet",text:"\u2026"}),d=++this.snippetToken;this.app.vault.cachedRead(o).then(u=>{d===this.snippetToken&&h.setText(Bb(u).slice(0,120)||this.tt("3d.card.empty"))})}let l=this.card.createDiv({cls:"gx-card-actions"});e.unresolved||l.createEl("button",{text:this.tt("context.openNote")}).addEventListener("click",()=>this.cb.openNote(e.id)),l.createEl("button",{text:this.tt("common.focus")}).addEventListener("click",()=>this.cb.focusNode(t))}update(e,t){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,e,t);if(a.behind||a.x<0||a.x>e||a.y<0||a.y>t){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,e,t);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,e,t);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,e,t);if(!r.behind){let a=r.x+296>e?r.x-296:r.x+16,l=Math.min(Math.max(r.y-40,12),Math.max(t-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(e,t={}){return Le(this.language,e,t)}};function Bb(i){return i.replace(/^---\n[\s\S]*?\n---\n?/,"").replace(/!?\[\[([^\]|]+)(\|[^\]]+)?\]\]/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/[#*`>~_]|---/g,"").replace(/\s+/g," ").trim()}var Hl=require("obsidian"),Vs=class extends Hl.SuggestModal{constructor(t,n,s,r){super(t);this.items=n;this.onPick=s;this.setPlaceholder(r)}getSuggestions(t){let n=t.trim();if(!n)return this.items.filter(o=>!o.unresolved&&!o.hideWhenEmpty).sort((o,a)=>a.rank-o.rank||o.title.localeCompare(a.title)).slice(0,20).map(o=>({item:o,score:0}));let s=(0,Hl.prepareFuzzySearch)(n),r=[];for(let o of this.items){let a=null;for(let l of o.searchText??[o.title,o.path]){let c=s(l);c&&(a=a===null?c.score:Math.max(a,c.score))}a!==null&&r.push({item:o,score:a})}return r.sort((o,a)=>a.score-o.score||a.item.rank-o.item.rank||o.item.title.localeCompare(a.item.title)).slice(0,50)}renderSuggestion(t,n){n.createDiv({text:t.item.title}),n.createDiv({cls:"gx-search-path",text:t.item.detail})}onChooseSuggestion(t){this.onPick(t.item.value)}};var du=require("obsidian"),lm="_galaxy_bench";function cm(i,e){return new Promise(t=>{let n=[],s=performance.now(),r=s,o=a=>{n.push(a-s),s=a;let l=a-r;if(e?.(l),lu-f),h=n.reduce((u,f)=>u+f,0),d=c[Math.min(Math.floor(c.length*.95),c.length-1)]??0;t({frames:n.length,avgFps:n.length>0?1e3/(h/n.length):0,p95FrameMs:d,worstFrameMs:c[c.length-1]??0,durationMs:h})}};window.requestAnimationFrame(o)})}function hm(){let i=0,e=0,t=0,n=null;try{n=new PerformanceObserver(s=>{for(let r of s.getEntries())i++,t+=r.duration,r.duration>e&&(e=r.duration)}),n.observe({entryTypes:["longtask"]})}catch{}return{stop:()=>(n?.disconnect(),{count:i,longestMs:e,totalMs:t})}}async function fu(i,e){let t=i.vault.adapter,n=(0,du.normalizePath)(lm);await t.exists(n)||await t.mkdir(n);let s=(0,du.normalizePath)(`${lm}/${e.scenario}-${Date.now()}.json`);return await t.write(s,JSON.stringify(e,null,2)),s}function pu(i){return new Promise(e=>window.setTimeout(e,i))}var Gs={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 zb=.8,Vb=3200,Wl=class{constructor(e,t,n,s,r=null,o="en",a=null){this.app=e;this.contentEl=t;this.settings=n;this.onViewMode=r;this.language=o;this.onLanguage=a;this.layout=new yl;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=Gs.high;this.watchdogTripped=!1;this.lowFpsChecks=0;this.lastWatchdogAt=0;this.onContextLost=null;this.store=new dl(e),this.saveSoon=(0,yt.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 t=this.applyPositionCache()>=zb,n=this.contentEl.createDiv({cls:"galaxy-view-canvas"});this.graphRadius=ul(this.store.data.nodes.length)*1.6;let s=new Il(n,this.graphRadius);this.renderer=s,s.setColorFn(this.settings.colorGroups.length>0?$r(this.settings.colorGroups):Cl),s.setData(this.store.data,this.store.positions),this.initLayout(t?.06:1),this.director=new Ul(s.camera,s.renderer.domElement,{onFlyToSelected:()=>this.flyToSelected(),onResetView:()=>this.recenter()}),this.overlay=new Vl(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),t?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(e){let t=n=>{n.preventDefault(),this.contentEl.createDiv({cls:"gx-mask"}).createEl("button",{cls:"gx-mask-btn",text:this.tt("3d.contextLost")}).addEventListener("click",()=>this.onContextLost?.())};e.addEventListener("webglcontextlost",t),this.disposeFns.push(()=>e.removeEventListener("webglcontextlost",t))}resize(){let{clientWidth:e,clientHeight:t}=this.contentEl;this.renderer?.resize(e,t),this.director?.handleResize()}applyPositionCache(){let e=this.settings.positionCache,t=this.store.data.nodes;if(t.length===0)return 0;let n=0;return t.forEach((s,r)=>{let o=e[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/t.length}checkSettled(){let e=this.layout.isSettled();if(e&&!this.wasSettled){let t={},n=this.store.positions;this.store.data.nodes.forEach((s,r)=>{t[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=t,this.saveSoon()}this.wasSettled=e}playEstablishing(){let e=this.renderer,t=this.director;!e||!t||(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;e.camera.position.set(n*Math.cos(s),n*Math.sin(s),n*.2),t.target.set(0,0,0),t.resetView(this.graphRadius,()=>t.beginFocusOrbit(null)),e.playReveal(2600),this.shot={t0:performance.now(),durMs:Vb,fromBloom:this.settings.bloom.strength*1.8}},450))}stepShot(e){if(!this.shot||!this.renderer)return;let t=Math.min((e-this.shot.t0)/this.shot.durMs,1),n=this.shot.fromBloom+(this.settings.bloom.strength-this.shot.fromBloom)*t;this.renderer.setBloomStrength(n),t>=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(e){let t=Ys(this.settings.physics);try{this.layout.init(this.store.data,this.store.positions,t,e)}catch{if(this.layout instanceof qr)throw new Error("layout init failed");this.layout.dispose(),this.layout=new qr,this.layout.init(this.store.data,this.store.positions,t,e),new yt.Notice(this.tt("3d.workerFallback"))}}pickTier(){if(yt.Platform.isMobile)return Gs.mobile;let e=this.settings.qualityOverride;return e==="high"||e==="low"||e==="mobile"?Gs[e]:this.watchdogTripped?Gs.low:Gs.high}applyTier(){let e=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 t=this.app.vault.getMarkdownFiles().length;this.store.setCaps(this.tier.nodeCap,this.tier.linkCap),this.tier.nodeCap!==null&&t>this.tier.nodeCap&&e!==this.tier.id&&new yt.Notice(this.tt("3d.mobileCap",{cap:this.tier.nodeCap,total:t}))}watchdog(e){this.watchdogTripped||yt.Platform.isMobile||this.settings.qualityOverride!=="auto"||!this.layout.isSettled()||this.benchRunning||e-this.lastWatchdogAt<5e3||(this.lastWatchdogAt=e,this.hudFrames.length>0&&this.hudFrames.length<30&&!this.paused?(this.lowFpsChecks++,this.lowFpsChecks>=3&&(this.watchdogTripped=!0,this.applyTier(),new yt.Notice(this.tt("3d.performanceMode")))):this.lowFpsChecks=0)}applySettings(){let e=this.settings;this.renderer?.setBloomParams(e.bloom),this.renderer?.setNodeScale(e.look.nodeSize),this.renderer?.setLinkOpacity(e.look.linkOpacity),this.renderer?.setSizeMode(e.look.sizeBy),this.renderer&&(this.renderer.twinkleFreq=e.look.twinkle),this.director&&(this.director.cruiseEnabled=e.cruise,this.director.cruiseSpeed=e.cruiseSpeed)}applyStylePreset(e){Object.assign(this.settings.bloom,e.bloom),Object.assign(this.settings.physics,e.physics),Object.assign(this.settings.look,e.look),this.applySettings(),this.layout.updateParams(Ys(this.settings.physics)),this.wasSettled=!1,this.saveSoon()}recenter(){this.clearSelection(),this.director?.resetView(this.graphRadius,()=>this.director?.beginFocusOrbit(null))}applyColorTheme(e){let t=this.settings.colorGroups;if(t.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);t=[...n.entries()].sort((s,r)=>r[1]-s[1]).slice(0,9).map(([s])=>({query:`path:${s}`,color:"#9aa4b2"})),this.settings.colorGroups=t}t.forEach((n,s)=>n.color=e.colors[s%e.colors.length]??n.color),this.settings.colorTheme=e.id,this.renderer?.setColorFn($r(t)),this.renderer?.recolor(),this.saveSoon()}playRevealManually(){if(!this.layout.isSettled()){new yt.Notice(this.tt("3d.revealWait"));return}this.renderer?.playReveal()}shuffleColors(){let e=this.settings.colorGroups;if(e.length<2){new yt.Notice(this.tt("3d.shuffleMissing"));return}let t=e.map(n=>n.color);for(let n=t.length-1;n>0;n--){let s=Math.floor(Math.random()*(n+1));[t[n],t[s]]=[t[s],t[n]]}e.forEach((n,s)=>n.color=t[s]??n.color),this.settings.colorTheme="custom",this.renderer?.setColorFn($r(e)),this.renderer?.recolor(),this.saveSoon()}applyPreset(){if(!this.renderer)return;let e=this.resolveVisualTokens();this.renderer.applyTokens(e,this.settings.bloom.strength),this.panel?.setPanelTheme(e.panelClass),this.contentEl.toggleClass("gx-daylight",e.id==="daylight")}onCssChange(){this.settings.preset!=="deep-space"&&this.applyPreset()}resolveVisualTokens(){let e=this.settings.preset;if(e==="deep-space")return Pl;let t=e==="day"?su:e==="night"?ru:activeDocument.body.hasClass("theme-dark")?ru:su,n=t.id==="daylight"?"day":"night";return{...t,background:Ll(n,t.background)}}async importColors(e){let t=await Df(this.app);if(!t||t.length===0){e&&new yt.Notice(this.tt("3d.importMissing"));return}this.settings.colorGroups=t,this.renderer?.setColorFn($r(t)),this.renderer?.recolor(),this.saveSoon(),e&&new yt.Notice(this.tt("3d.importDone",{count:t.length}))}openSearch(){new Vs(this.app,this.store.data.nodes.map((e,t)=>({value:t,title:e.name,path:e.id,detail:`${e.unresolved?this.tt("3d.searchUnresolved"):e.id} \xB7 ${this.tt("3d.searchLinks",{count:e.degree})}`,rank:e.degree,unresolved:e.unresolved,searchText:[e.name,e.id,e.folderTop]})),e=>this.selectNode(e,!0),this.tt("3d.searchPlaceholder")).open()}selectNode(e,t){let n=this.renderer,s=this.director;if(!n||!s)return;this.selected=e;let r=new Set,o=[];if(this.store.data.links.forEach((a,l)=>{(a.source===e||a.target===e)&&(r.add(a.source),r.add(a.target),o.push(l))}),n.setFocus(e,r),n.setSelectedLinks(o),this.overlay?.setSelection(e,r),t){let a=n.nodePosition(e,new N),l=new N,c=0,h=new N;for(let u of r)u!==e&&(l.add(n.nodePosition(u,h)),c++);let d=c>0?l.divideScalar(c).sub(a):null;s.flyTo(a,n.nodeRadius(e),()=>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 e=this.renderer.nodePosition(this.selected,new N);this.director.flyTo(e,this.renderer.nodeRadius(this.selected))}bindPicking(e){let t=0,n=0,s=c=>{t=c.clientX,n=c.clientY},r=c=>{if(c.button!==0||c.ctrlKey||c.metaKey||Math.hypot(c.clientX-t,c.clientY-n)>5)return;let h=e.getBoundingClientRect(),d=this.renderer?.pickNearest(c.clientX-h.left,c.clientY-h.top,h.width,h.height,14)??-1;d>=0?this.selectNode(d,!0):this.clearSelection()},o=!1,a=c=>{let h=this.tier.hoverThrottleMs;h===null||o||(o=!0,window.setTimeout(()=>{o=!1;let d=this.renderer;if(!d)return;let u=e.getBoundingClientRect(),f=d.pickNearest(c.clientX-u.left,c.clientY-u.top,u.width,u.height,10);this.overlay?.setHover(f),e.style.cursor=f>=0?"pointer":"default"},h))},l=c=>{c.key==="Escape"&&(this.clearSelection(),c.preventDefault())};e.addEventListener("pointerdown",s),e.addEventListener("pointerup",r),e.addEventListener("pointermove",a),e.addEventListener("keydown",l),this.disposeFns.push(()=>{e.removeEventListener("pointerdown",s),e.removeEventListener("pointerup",r),e.removeEventListener("pointermove",a),e.removeEventListener("keydown",l)})}bindVisibility(){let e=()=>{this.paused=activeDocument.hidden||!this.visible};activeDocument.addEventListener("visibilitychange",e),this.disposeFns.push(()=>activeDocument.removeEventListener("visibilitychange",e)),this.intersection=new IntersectionObserver(t=>{this.visible=t[0]?.isIntersecting??!0,e()}),this.intersection.observe(this.contentEl)}buildPanel(){this.panel=new zl(this.contentEl,this.settings,this.language,{onViewMode:e=>this.onViewMode?.(e),onBloom:()=>{this.renderer?.setBloomParams(this.settings.bloom),this.saveSoon()},onPhysics:()=>{this.layout.updateParams(Ys(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:e=>{this.director&&(this.director.cruiseEnabled=e),this.saveSoon()},onPreset:()=>{this.applyPreset(),this.saveSoon()},onShowUnresolved:e=>{this.store.setIncludeUnresolved(e),this.saveSoon()},onImportColors:()=>void this.importColors(!0),onShuffleColors:()=>this.shuffleColors(),onColorTheme:e=>this.applyColorTheme(e),onRecenter:()=>this.recenter(),onReveal:()=>this.playRevealManually(),onShowOrphans:e=>{this.store.setIncludeOrphans(e),this.saveSoon()},onStylePreset:e=>this.applyStylePreset(e),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,rn.bloom),Object.assign(this.settings.physics,rn.physics),Object.assign(this.settings.look,rn.look),this.settings.cruise=rn.cruise,this.settings.cruiseSpeed=rn.cruiseSpeed,this.applySettings(),this.layout.updateParams(Ys(this.settings.physics)),this.wasSettled=!1,this.saveSoon()},runScenario:e=>void this.runScenario(e)},"map3d")}buildFloatingControls(){let e=this.contentEl.createDiv({cls:"mwm-floating-controls mwm-3d-floating-controls"}),t=e.createEl("button",{cls:"mwm-floating-button",attr:{type:"button",title:this.tt("language"),"aria-label":this.tt("language")}});(0,yt.setIcon)(t,"languages"),t.addEventListener("click",n=>{n.preventDefault(),n.stopPropagation(),this.openLanguageMenu(t)}),this.disposeFns.push(()=>e.remove())}openLanguageMenu(e){let t=new yt.Menu;for(let[s,r]of as(this.language))t.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=e.getBoundingClientRect();t.showAtPosition({x:n.right,y:n.bottom})}updateHud(e){for(this.hudFrames.push(e);this.hudFrames.length>0&&e-(this.hudFrames[0]??0)>1e3;)this.hudFrames.shift();let t=this.panel?.statsEl;if(!t||e%500>250)return;let n=this.counts;t.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(e,t={}){return Le(this.language,e,t)}waitSettle(e=12e4){return new Promise(t=>{let n=performance.now(),s=()=>{this.layout.isSettled()||performance.now()-n>e?t():window.setTimeout(s,100)};s()})}async runScenario(e){if(this.benchRunning||!this.renderer||!this.director)return null;this.benchRunning=!0;try{return e==="S2"?await this.benchColdLayout():await this.benchOrbit(e)}finally{this.benchRunning=!1}}async benchOrbit(e){let t=this.renderer,n=this.director;if(!t||!n)throw new Error("not ready");let s=e==="S3";this.store.getIncludeUnresolved()!==s&&this.store.setIncludeUnresolved(s),new yt.Notice(this.tt("3d.bench.wait",{scenario:e})),await this.waitSettle(),t.getBloomStrength()<.01&&t.setBloomStrength(.9),await pu(300),this.benchMode=!0;let r=n.target.clone(),o=new Gn().setFromVector3(t.camera.position.clone().sub(r));new yt.Notice(this.tt("3d.bench.orbit",{scenario:e}));let a=await cm(2e4,c=>{let h=o.theta+c/2e4*Math.PI*2;t.camera.position.setFromSpherical(new Gn(o.radius,o.phi,h)).add(r),t.camera.lookAt(r)});this.benchMode=!1;let l={scenario:e,timestamp:new Date().toISOString(),nodes:this.counts.nodes,links:this.counts.links,bloom:t.getBloomStrength()>0,drawCalls:t.drawCalls,renderer:"aggregate",...a};return await fu(this.app,l),new yt.Notice(this.tt("3d.bench.done",{scenario:e,fps:a.avgFps.toFixed(1),calls:t.drawCalls})),l}async benchColdLayout(){new yt.Notice(this.tt("3d.bench.s2Start")),this.store.getIncludeUnresolved()&&this.store.setIncludeUnresolved(!1),await pu(300);let e=hm(),t=performance.now();this.settings.positionCache={},this.store.rebuild(!1),this.initLayout(1),this.wasSettled=!1,await this.waitSettle();let n=performance.now()-t,s=this.layout.ticks,r=e.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 fu(this.app,o),new yt.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 e of this.disposeFns)e();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 Xl=class extends Wl{};var Yt=require("obsidian");var Pe="",mu="Vault";var mm=1160,gm=620,Gb=2800,xm=144,Hb=72,Wb=360;var ql=.15,um=.34,Dt=.045;function vm(i,e){let t=Y(e.ringSpacing,gm,Gb),n=Y(e.nodeSpacing,Hb,Wb),s=340,r=new Map,o=i.nodesById,a=CM(i.nodes),l=i.nodes.filter(U=>!U.externalProxy&&U.type!=="external"),c=new Set(l.map(U=>U.id)),h=_M(i,c,t,n),d=c.has(i.rootId)?i.rootId:c.has(Pe)?Pe:l[0]?.id??null,u=Xb(i,c,o),f=new Map,m=new Set;if(d!==null&&(_m(d,0,u,h,f),ym(d,u,m)),d!==null){let U=Zl(0,-Math.PI/2,0,Hs(o.get(d),a,h.incidentPressureByNode.get(d)??0),!1);Mu(U,-Math.PI/2,-Math.PI/2+Math.PI*2),r.set(d,U),bm(d,0,-Math.PI/2,-Math.PI/2+Math.PI*2,-Math.PI/2,u,f,r,o,h,d,a)}let x=l.filter(U=>U.id!==d&&!m.has(U.id)).sort(Yl),g=d!==null?f.get(d):null,p=Math.max(0,g?.maxDepth??0),v=Math.max(pm(r),h.ringGap);x.length>0&&(v=Math.max(v,vu(x,r,i,o,v+h.ringGap*.64,h.nodeGap,-Math.PI/2,p+1,!1,a,h.incidentPressureByNode)));let b=i.nodes.filter(U=>U.type==="external"&&!U.externalProxy).sort(Yl),M=i.nodes.filter(U=>U.externalProxy).sort(Yl),S=nM(r,i,h,h.nodeGap,a);rM(r,i,h,h.nodeGap,S,a),h.radiusExpansion>1.001&&bM(r,S,h),MM(r,S),SM(r,S,h);let w=Y(e.swirlStrength,0,100)/100,C=w>.001?Y(.24+w*.34,.24,.58):0;C>.001&&LM(r,i,h,C),UM(r,i),NM(r,i,h),v=Math.max(v,pm(r)),v=Math.max(v,tM(b,M,r,i,o,v,p,h,a));let _=Math.max(1,...[...r.values()].map(U=>Math.max(0,Math.round(U.depth||0)))),A=wM(i.linkEdges,r,_,h.ringGap,v+Math.max(150,h.ringGap*.35)),P=TM(r,Math.max(A.maxRadius,v+Math.max(160,h.ringGap*.34))),R=s-P.minX,I=s-P.minY;AM(r,A.routes,R,I),GM(r);let H=EM(r,S),W=Math.max(900,P.maxX-P.minX+s*2),F=Math.max(520,P.maxY-P.minY+s*2),O={minX:0,minY:0,maxX:W,maxY:F};return{positions:r,rings:H,routes:A.routes,bounds:O,width:W,height:F,centerX:R,centerY:I,ringSpacing:h.ringGap,nodeSpacing:h.nodeGap}}function Xb(i,e,t){let n=new Map;for(let s of i.nodes){if(!e.has(s.id)||s.parentId===null||s.parentId===void 0||!e.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)=>Yl(t.get(r),t.get(o)));return n}function _m(i,e,t,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:e,spanDemand:Dt};return s.set(i,f),f}r.add(i);let a=n.incidentPressureByNode.get(i)??0,l=Math.min(9,a*.24),c=1,h=e,d=[];for(let f of t.get(i)??[]){let m=_m(f,e+1,t,n,s,r);d.push(m),l+=m.weight,c+=m.count,h=Math.max(h,m.maxDepth)}r.delete(i);let u={weight:Math.max(1,l||1),count:c,maxDepth:h,spanDemand:qb(d)};return s.set(i,u),u}function ym(i,e,t){if(!(i==null||t.has(i))){t.add(i);for(let n of e.get(i)??[])ym(n,e,t)}}function qb(i){if(i.length===0)return Dt;if(i.length===1)return Y((i[0]?.spanDemand??Dt)*.985,Dt,Math.PI*1.94);let e=bu(i.length),t=i.reduce((r,o)=>r+Math.max(Dt,o.spanDemand),0),n=Math.max(0,i.length-1)*.018,s=Math.pow(Math.max(0,t+n),.92)*1.04;return Y(Math.max(e,s),Dt,Math.PI*1.96)}function bu(i){return i<=1?Dt: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 bm(i,e,t,n,s,r,o,a,l,c,h,d){let u=r.get(i)??[];if(u.length===0)return;let f=t,m=n,x=Math.max(.001,m-f),g=a.get(i)??Zl(0,s,e,5,!1),p=g.radius+Yb(i,e,u,o,c,h),v=Zb(i,u,o,c,h);if(u.length===1){let R=i===h?Math.PI*2:x;f=s-R/2,m=s+R/2,x=R}else if(i!==h){let R=$b(i,e,u,x,p,v,r,o);f=s-R/2,m=s+R/2,x=R}if(u.length>1){let R=(u.length-1)*v/Math.max(.16,x*.64),I=c.ringGap*(i===h?1.8:2.8);p=Math.max(p,Math.min(g.radius+I,R))}let b=u.map(R=>jb(R,e+1,r,o)),M=Qb(u,e+1,r,o,b),S=Math.max(1,M.reduce((R,I)=>R+I,0)),w=u.length>8?Y(2.2/Math.sqrt(u.length),.28,.82):1,C=u.length>8?Y(.28-Math.min(.14,(u.length-8)*.0065),.14,.28):.38,_=u.length>1?Math.min(v/p*w,x*C/(u.length-1)):0,A=Math.max(.001,x-_*Math.max(0,u.length-1)),P=f;for(let R=0;R=14&&(u=Math.max(u,1.02+Math.min(.78,c*.068))),o>=40&&(u=Math.max(u,1.28+Math.min(1.02,c*.064))),Y(s.baseRingGap*u,i===r?220:250,3400)}function Zb(i,e,t,n,s){let r=e.length,o=t.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=Y(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)),Y(n.baseNodeGap*c,132,920)}function $b(i,e,t,n,s,r,o,a){if(t.length<=1)return n;let l=(t.length-1)*r/Math.max(1,s)+.08,c=a.get(i)??{count:t.length+1,weight:t.length+1,maxDepth:e+1,spanDemand:bu(t.length)},h=Math.max(...t.map(w=>xu(w,e+1,o,a)),1),d=t.reduce((w,C)=>w+xu(C,e+1,o,a),0),u=Math.log2(Math.max(2,t.length+1)),f=Math.log2(Math.max(2,c.count||t.length+1)),m=h/Math.max(1,d),x=c.count>t.length*2||t.some(w=>(o.get(w)?.length??0)>2),p=Y((x?.965:.88)+u*.018+f*.012-m*.045,.84,.97);t.length<=4&&!x&&(p=Math.min(p,Y(.38+t.length*.095+f*.018,.48,.74)));let v=Math.max(l,n*p,Kb(t,o)),M=t.every(w=>(o.get(w)?.length??0)===0)&&ne.get(l)?.length??0),s=n.filter(l=>l>0).length,r=Math.max(0,...n),o=t>=48?Math.PI*1.68:t>=24?Math.PI*1.26:t>=14?Math.PI*1.1:t>=9?Math.PI*.82:t>=5?Math.PI*.56:t>=3?Math.PI*.34:Math.PI*.2,a=s>0?Y(1-Math.sqrt(s)*.095-Math.sqrt(r)*.03,.56,.92):1;return o*a}function Jb(i,e,t,n,s,r,o,a){let l=t.length,c=t.map(S=>o.get(S)?.length??0),h=Math.max(0,...c),d=c.filter(S=>S>0).length,u=a.get(i)??{count:l+1,weight:l+1,maxDepth:e+1,spanDemand:bu(l)},f=Math.max(0,u.maxDepth-e),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?Y(1-Math.sqrt(d)*.08-Math.sqrt(h)*.025,.62,.94):1,p=Y(1+Math.max(0,e-1)*.035+Math.sqrt(f)*.026,1,1.22),v=m>n?Y(m/Math.max(.08,n),1,1.35):1,b=x*g*p*v,M=n*(l>=9?1.45:l>=5?1.28:1.14);return Y(Math.max(M,b,m*1.04),.12,Math.PI*1.88)}function xu(i,e,t,n){let s=n.get(i)??{count:1,weight:1,maxDepth:e,spanDemand:Dt},r=t.get(i)?.length??0,o=Math.max(0,s.maxDepth-e),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,h=Math.pow(Math.max(1,s.weight),.58)*.34;return Math.max(1,l+a+c+h)}function jb(i,e,t,n){let s=n.get(i)??{count:1,weight:1,maxDepth:e,spanDemand:Dt},r=xu(i,e,t,n),o=Y(s.spanDemand??Dt,Dt,Math.PI*1.98),a=Math.pow(o,1.62)*18,l=Math.pow(Math.max(1,r),.58)*.18,c=Y(1-Math.max(0,e-1)*.34,0,1),h=Math.pow(Math.max(1,s.count),.62),d=Math.sqrt(Math.max(1,s.maxDepth-e+1)),u=c*(h*.72+d*.48+o*2.2);return Math.max(.18,a+l+u)}function Qb(i,e,t,n,s){if(i.length<=1)return s;let r=i.map(m=>n.get(m)??{count:1,weight:1,maxDepth:e,spanDemand:Dt}),o=r.map(m=>Math.max(1,m.count)),l=o.reduce((m,x)=>m+x,0)/Math.max(1,o.length),c=Math.max(1,...o),h=r.map(m=>Math.max(Dt,m.spanDemand??Dt)),d=h.reduce((m,x)=>m+x,0)/Math.max(1,h.length),u=Y(1-Math.max(0,e-1)*.16,.32,1),f=Y(Math.sqrt(c/Math.max(1,l))-1,0,1.9);return f<=.04&&c{let g=r[x]??{count:1,weight:1,maxDepth:e,spanDemand:Dt},p=o[x]??1,v=p/Math.max(1,l),b=p/Math.max(1,c),M=Math.max(Dt,g.spanDemand??Dt)/Math.max(Dt,d),S=t.get(i[x]??"")?.length??0,w=1+fn(1.06,2.85,v)*(.34+u*.46+f*.1)+fn(.42,.78,b)*(.12+u*.18),C=1+fn(1.05,2.25,M)*(.16+u*.24),_=1+fn(2,10,S)*(.08+u*.14),A=v<.72?Y(.9+v*.14,.84,1):1;return Math.max(.12,m*Y(w*C*_*A,.72,2.38))})}function vu(i,e,t,n,s,r,o,a,l,c,h=new Map){if(i.length===0)return s;s=Math.max(s,eM(i,n,r,c,h));let d=Math.PI*2/i.length,u=i.length*(r/Math.max(1,s)),f=i.map((x,g)=>({node:x,preferred:RM(x,t,e,o+g*d)})).sort((x,g)=>pn(x.preferred)-pn(g.preferred)),m=f[0]?f[0].preferred-d*.5:o;for(let x=0;x{let c=Hs(e.get(l.id),n,s.get(l.id)??0);return a+c*2.6+jl(l)*1.35+Math.max(18,t*.18)},0),o=i.length>80?.48:i.length>28?.42:.36;return r/Math.max(1,Math.PI*2*o)}function tM(i,e,t,n,s,r,o,a,l){let c=r,h=i.length>0,d=e.length>0;if(!h&&!d)return c;let u=gu(r,a,d?1.1:1);if(h&&(c=vu(i,t,n,s,r+u,a.nodeGap*1.18,-Math.PI/3,o+1,!0,l,a.incidentPressureByNode)),d){let f=Math.max(c,r)+(h?gu(r,a,.58):gu(r,a,1.08));c=vu(e,t,n,s,f,a.nodeGap,-Math.PI/5,o+(h?2:1),!0,l,a.incidentPressureByNode)}return c}function gu(i,e,t){let n=Math.max(0,i)*.1;return Math.max(e.ringGap*1.05,e.nodeGap*2.15,n,720)*t}function nM(i,e,t,n,s){let r=new Map([[0,0]]),o=new Map;for(let[d,u]of i.entries()){let f=Math.max(0,Math.round(u.depth||0)),m=e.nodesById.get(d),x=Hs(m,s,t.incidentPressureByNode.get(d)??0),g=x*2+Math.max(18,n*.36),p=x*2.55+(m?jl(m):24)*1.42+Math.max(18,n*.2),v=o.get(f)??{count:0,diameterTotal:0,maxDiameter:0,external:0,linkPressure:0,arcDemand:0};v.count++,v.diameterTotal+=g,v.maxDiameter=Math.max(v.maxDiameter,g),v.linkPressure+=t.incidentPressureByNode.get(d)??0,v.arcDemand+=p,(u.external||m?.externalProxy||m?.type==="external")&&v.external++,o.set(f,v)}let a=0,l=t.ringGap,c=[...o.keys()].filter(d=>d>0).sort((d,u)=>d-u),h=Kl(new Map(c.map(d=>[d,o.get(d)?.count??0])));for(let d of c){let u=o.get(d);if(!u)continue;let f=Jl(h,d),m=$l(u.count,h.averageCount,h.maxCount),x=Math.sqrt(u.linkPressure/Math.max(1,u.count)),g=iM(u,n,m.pressure,x,f),p=Mm(l,t,f),v=Math.max(sM(u,t,m,x,f),p,t.ringGap*(.86+f.outerWeight*.1+f.sparseTail*.48)),b=a+v,M=Math.max(b,g);r.set(d,M),l=M-a,a=M}for(let d of i.values()){let u=Math.max(0,Math.round(d.depth||0)),f=r.get(u);if(!Number.isFinite(f))continue;let m=f,x=Number.isFinite(d.angle)?d.angle:Math.atan2(d.y,d.x);if(d.ringRadius=m,u===0){d.x=0,d.y=0,d.radius=0,d.angle=-Math.PI/2;continue}d.x=Math.cos(x)*m,d.y=Math.sin(x)*m,d.radius=m,d.angle=pn(x)}return r}function iM(i,e,t,n,s){if(i.count<=1)return i.maxDiameter*1.18;let o=Math.max(1,i.count)*Math.max(10,e*(.14+s.outerWeight*.05+s.sparseTail*.08+s.middleCrowdWeight*.115)),a=Math.max(i.diameterTotal,i.arcDemand*(.78+s.outerWeight*.12+s.sparseTail*.16+s.middleCrowdWeight*.22))+o,l=Y(.62-s.utilizationDrop-Math.min(.18+s.outerWeight*.02+s.sparseTail*.02,t*.07)-Math.min(.08+s.outerWeight*.02+s.sparseTail*.02+s.middleCrowdWeight*.038,n*.012)-(i.external?.04:0),.32-s.sparseTail*.06-s.middleCrowdWeight*.06,.62);return a/Math.max(1,Math.PI*2*l)+i.maxDiameter*(.9+s.outerWeight*.18+s.sparseTail*.34+s.middleCrowdWeight*.36)}function Mm(i,e,t){return t.outerWeight<=.03&&t.sparseTail<=.03&&t.middleCrowdWeight<=.03?Math.min(i*.82,e.ringGap*1.55):Math.max(i*Y(.9+t.outerWeight*.16+t.sparseTail*.1+t.middleCrowdWeight*.22,.9,1.34),e.ringGap*Y(.9+(t.radialScale-1)*.64+t.middleCrowdWeight*.48,.9,2.78))}function sM(i,e,t,n,s){let r=Y(1-t.relativeToAverage,0,.32),o=Y(.92+t.pressure*.18+t.maxPressure*.12+s.outerWeight*.08+s.middleCrowdWeight*.52+s.sparseTail*.28+Math.min(.12,n*.018)+(i.external?.08:0)-r*.08,.84,2.9);return e.ringGap*o+i.maxDiameter*.62}function $l(i,e,t){let n=Math.max(0,i||0),s=n/Math.max(1,e||1),r=n/Math.max(1,t||n||1);return{relativeToAverage:s,pressure:Y(Math.sqrt(s),0,2.8),maxPressure:Y(Math.sqrt(r),0,1)}}function Kl(i){let e=[...i.keys()].filter(c=>c>0).sort((c,h)=>c-h),t=Math.max(1,...e),n=e.reduce((c,h)=>c+Math.max(0,i.get(h)??0),0),s=n/Math.max(1,e.length),r=Math.max(1,...e.map(c=>Math.max(0,i.get(c)??0))),o=new Map,a=dm(0,0,t,s,r,0),l=0;for(let c of e){let h=Math.max(0,i.get(c)??0);l+=h;let d=n>0?l/n:0;o.set(c,dm(c,h,t,s,r,d))}return{maxDepth:t,averageCount:s,maxCount:r,byDepth:o,fallback:a}}function dm(i,e,t,n,s,r){let o=Math.max(0,i||0),a=o<=1?0:Y((o-1)/Math.max(1,t-1),0,1),l=Math.max(0,e||0)/Math.max(1,n||1),c=Math.max(0,e||0)/Math.max(1,s||1),h=Math.max(fn(.5,.95,l),fn(.16,.38,c)),d=fn(.38,.88,a),u=fn(.62,.92,r)*fn(.18,.42,a)*h,f=Y(Math.max(d,u*.72),0,1),m=Y(Math.sqrt(l)*.62+Math.sqrt(c)*.52,0,2.2),x=fn(.06,.24,a)*(1-fn(.76,.98,a)),g=Y(x*h*Math.max(0,m-.72)*(1-f*.35),0,1.55),p=Y((.9-Math.min(.9,l))/.9,0,1),v=Y((.24-Math.min(.24,c))/.24,0,1),b=f*Math.max(p,v*.86),M=Y(1+f*.05+b*1.02+g*.56+Math.max(0,m-1.05)*.06*f,1,2.58),S=Y(1+f*.07+b*.96+g*.72+Math.max(0,m-1.05)*.16*f,1,2.86),w=Y(f*.022+b*.085+g*.09+Math.max(0,m-1.05)*.03*f,0,.36);return{depth:i,count:e,depthRatio:a,outerWeight:f,crowdPressure:m,middleCrowdWeight:g,sparseTail:b,radialScale:M,bandScale:S,utilizationDrop:w}}function Jl(i,e){return i.byDepth.get(Math.max(0,Math.round(e||0)))??i.fallback}function fn(i,e,t){if(i===e)return t>=e?1:0;let n=Y((t-i)/(e-i),0,1);return n*n*(3-2*n)}function rM(i,e,t,n,s,r){let o=new Map;for(let[d,u]of i.entries()){let f=e.nodesById.get(d);if(!f)continue;let m=Math.max(0,Math.round(u.depth||0));if(m===0){u.x=0,u.y=0,u.radius=0,u.ringRadius=0,u.ringBandMin=0,u.ringBandMax=0,u.angle=-Math.PI/2;continue}let x=Hs(f,r,t.incidentPressureByNode.get(d)??0),g=x*2.4+jl(f)*1.55+Math.max(18,n*.18),p=f.parentId??e.rootId??Pe,v=o.get(m)??[];v.push({id:d,node:f,point:u,visualRadius:x,arcDemand:g,kind:vM(f),parentKey:p}),o.set(m,v)}let a=0,l=[...o.keys()].sort((d,u)=>d-u),c=Math.max(...l,1),h=Kl(new Map(l.map(d=>[d,o.get(d)?.length??0])));for(let d of l){let u=o.get(d);if(!u?.length)continue;let f=Jl(h,d),m=Math.max(...u.map(O=>O.visualRadius),4),x=u.reduce((O,U)=>O+U.arcDemand,0),g=s.get(d)??t.ringGap*d,p=Y((d-1)/Math.max(1,c-1),0,1),v=$l(u.length,h.averageCount,h.maxCount),b=v.pressure*.72+v.maxPressure*.42,M=Math.max(f.outerWeight,f.sparseTail),S=Y(b+Math.max(0,f.crowdPressure-b)*Math.max(M,f.middleCrowdWeight*.82),0,2.8),w=Math.max((m*(2.08+S*.22+p*.12)+Math.max(14,n*(.12+S*.018+p*.018)))*Y(1+f.sparseTail*.22+f.middleCrowdWeight*.42,1,1.84),t.ringGap*(.064+S*.024+p*.012)*f.bandScale),C=fM(g,d,p,S,u.length,x,t,n),_=f.outerWeight>.04||f.sparseTail>.04?hM(u,i,t,n,S,a,w,f):0,A=Y(1+f.sparseTail*.92+f.outerWeight*.08-Math.max(0,S-1.4)*.05,.88,2.1),P=fm(d,g,t,u.length,x,S)*A,R=mM(g,u.length,x),I=Math.max(g,C,_,a+w*.38,f.outerWeight>.04||f.sparseTail>.04?a+lM(t,w,f):0,a+m*(1.72+f.middleCrowdWeight*.26)+P*R),H=Math.min(fm(d,I,t,u.length,x,S)*A,Math.max(0,I-a-m*(1.44-f.sparseTail*.12)));s.set(d,I);let W=oM(u,I,n),F=I;for(let O of u){let U=pn(Number.isFinite(O.point.angle)?O.point.angle:Math.atan2(O.point.y,O.point.x)),J=aM(O.kind),ee=Kr(O.parentKey,`depth-${d}-parent-lane`)*(.24+p*.08),le=W.get(O.id)??0,ye=O.kind==="folder"?-1:1,Me=.38+Math.min(.16,le*.025)+p*.05,Ze=Y(J+ee+le*Me*ye,-1.22-p*.2,1.3+p*.24),Ke=O.node.parentId!==null&&O.node.parentId!==void 0?i.get(O.node.parentId):null,Fe=Ke?Ke.radius+cM(Ke,t,n,p,S,f):0,Z=gM(O.id,O.parentKey,O.kind,le,Ze,I,w,H,d,Math.max(a+m*1.58,Fe));O.point.x=Math.cos(U)*Z,O.point.y=Math.sin(U)*Z,O.point.radius=Z,O.point.ringRadius=I,O.point.ringBandMin=I-H,O.point.ringBandMax=Math.max(I+H,Z),O.point.angle=U,F=Math.max(F,Z+m*.96)}a=F+Math.max(10,n*.038)}}function oM(i,e,t){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,u)=>pn(d.point.angle)-pn(u.point.angle)),a=Math.max(.001,xM(o[0]?.point.angle??0,o.map(d=>d.point.angle)));if(a>Math.PI*1.45)continue;let l=o.reduce((d,u)=>d+u.arcDemand+Math.max(6,t*.08),0),c=Math.max(t*1.85,e*Math.max(a,.14)*.66),h=Y(Math.ceil(l/Math.max(1,c)),1,6);if(!(h<=1))for(let d=0;df.visualRadius),4),c=i.reduce((f,m)=>f+m.arcDemand,0)+i.length*Math.max(10,n*.18),h=Y(.52-a.outerWeight*.035-a.sparseTail*.055-s*.035-Math.min(.06,i.length/3600),.3-a.sparseTail*.022,.52),d=c/Math.max(1,Math.PI*2*h)+l*1.3,u=new Map;for(let f of i){let m=u.get(f.parentKey);m?m.push(f):u.set(f.parentKey,[f])}for(let f of u.values()){if(f.length<=1)continue;let m=uM(f[0],e),x=Math.max(0,Math.round(m?.depth??0)),g=Y(m?.sectorSpan??Math.PI*2,.08,Math.PI*2),p=dM(f.length,x,g,a),v=f.reduce((M,S)=>M+S.arcDemand,0)+Math.max(0,f.length-1)*Math.max(12,n*.22),b=Y(.72-a.outerWeight*.035-a.sparseTail*.055-s*.045-Math.min(.08,Math.sqrt(f.length)*.012),.42-a.sparseTail*.045,.72);d=Math.max(d,v/Math.max(1,p*b)+l*2.15)}return Math.max(d,r+Math.max(o*(1.06+a.outerWeight*.1+a.sparseTail*.24),t.ringGap*(1.1+a.outerWeight*.14+a.sparseTail*.52))+l*1.2)}function uM(i,e){return i.node.parentId!==null&&i.node.parentId!==void 0?e.get(i.node.parentId)??null:e.get(i.parentKey)??null}function dM(i,e,t,n){if(e<=0)return Y(t*.96,.12,Math.PI*2);let s=wm(i,e,t),r=.14+Math.sqrt(Math.max(1,i))*.22,o=Y(1-Math.max(0,e-1)*.04,.66,.96),a=r*o,l=t*Y(.8-n.outerWeight*.08-n.sparseTail*.1,.54,.8);return Y(Math.min(s,a,l),.08,t)}function fm(i,e,t,n,s,r){if(i<=0||!Number.isFinite(e)||e<=0)return 0;let o=pM(i,e,t.ringGap,r),a=IM(i,e,t.ringGap,n,s),l=Y(.94+Y(r,0,2.6)*.035,.94,1.03),c=Y(.78+a*.1+Y(r,0,2.6)*.08,.86,1.04),h=e*o;return Y(h*l*c,0,h)}function fM(i,e,t,n,s,r,o,a){if(e<=0||!Number.isFinite(i)||i<=0||s<=1)return i;let l=Math.max(1,s),c=l*Math.max(8,a*.12),h=r+c,d=Y(.5-Math.min(.14,n*.045)-Math.min(.06,l/3600),.34,.5),u=h/Math.max(1,Math.PI*2*d);if(u<=i)return i;let f=Y((u-i)/Math.max(1,o.ringGap),0,1),m=Y(.46+n*.18+f*.14-Y(t,0,1)*.04,.46,.88),x=o.ringGap*Y(.16+n*.2+f*.24,.16,.72),g=u-i,p=Math.min(g,x),v=Math.max(0,g-x)*Y(.16+n*.08+f*.12,.16,.42);return Math.max(i,i+(p+v)*m)}function pM(i,e,t,n){if(i<=1)return ql;let s=Number.isFinite(e)&&t>0?Math.max(0,e/t-1):Math.max(0,i-1),r=Y(s/7,0,1),o=Y(n/2.6,0,1),a=Math.max(o,Math.pow(r,.92)*.48);return Y(ql+(um-ql)*a,ql,um)}function mM(i,e,t){let n=Number.isFinite(i)&&i>0?t/Math.max(1,Math.PI*2*i):0,s=Y((n-.28)/.28,0,1),r=Y((Math.sqrt(Math.max(0,e))-8)/10,0,1);return Y(.12+Math.max(s,r)*.74,.12,.86)}function gM(i,e,t,n,s,r,o,a,l,c){let h=Math.max(c,r+s*o);if(a<=0)return h;let d=Y(o*1.8/Math.max(1,r),0,1),u={folder:-.58+d*.22,note:.08+d*.02,unresolved:.55-d*.19,external:.68-d*.24},f=t==="folder"?-1:1,m=Kr(e,`depth-${l}-parent-radius`)*(.2-d*.1),x=Kr(i,`depth-${l}-node-radius`)*(.32-d*.16),g=n*(.24-d*.12)*f,p=Y((u[t]??.08)+s*.28+g+m+x,-1,1),v=Y(s,-1,1)*Math.min(o*.24,a*.12);return Math.max(c,r+p*a+v)}function xM(i,e){if(!e.length)return 0;let t=1/0,n=-1/0;for(let s of e){let r=Jr(i,s);t=Math.min(t,r),n=Math.max(n,r)}return!Number.isFinite(t)||!Number.isFinite(n)?0:Math.max(0,n-t)}function vM(i){return i.type==="external"||i.externalProxy?"external":i.type==="unresolved"?"unresolved":i.type==="folder"?"folder":"note"}function _M(i,e,t,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||e.size||1),c=yM(i,e),h=r/l,d=i.linkEdges.length/l,u=a/Math.max(1,Math.sqrt(l)*1.65),f=h+Math.sqrt(Math.max(0,u))*.58+Math.min(1.6,d)*.3+o/l*.32,m=Math.sqrt(Math.max(0,f)),x=Y(1.2+m*.92+Math.min(.86,h*.105),1.2,5.8),g=Y(.84+m*.24+Math.min(.24,h*.032),.72,1.72),p=Y(.62+m*.24+Math.min(.3,d*.17),.62,1.35),v=Y(.9+m*.38+Math.min(.42,d*.2),.9,2.55),b=Math.max(0,Math.log2(c.normalCount/520))*.035,M=Math.max(0,Math.sqrt(c.maxRingCount/96)-1)*.16,S=Math.max(0,Math.sqrt(c.averageRingCount/64)-1)*.1,w=Math.max(0,m-.75)*.028;return{baseRingGap:t,baseNodeGap:n,ringGap:Y(t*g,gm,3400),nodeGap:Y(n*x,86,860),branchFanSpan:Math.PI*p,routeGapFactor:v,radiusExpansion:Y(1+b*.72+M*.68+S*.64+w,1,1.36),ringCountsByDepth:c.countsByDepth,maxDensityDepth:c.maxDepth,incidentPressureByNode:s}}function yM(i,e){let t=new Map;for(let r of i.nodes){if(!e.has(r.id))continue;let o=Math.max(0,Math.round(r.depth||0));o<=0||t.set(o,(t.get(o)??0)+1)}let n=0,s=0;for(let r of t.values())n=Math.max(n,r),s+=r;return{normalCount:Math.max(1,e.size||0),maxRingCount:n,averageRingCount:t.size?s/t.size:Math.max(1,e.size||0),maxDepth:Math.max(...t.keys(),1),countsByDepth:t}}function bM(i,e,t){let n=Y(t.radiusExpansion,1,1.65);if(n<=1.001)return;let s=Math.max(1,t.maxDensityDepth,...e.keys()),r=[...t.ringCountsByDepth.values()].filter(c=>c>0),o=r.reduce((c,h)=>c+h,0)/Math.max(1,r.length),a=Math.max(1,...r),l=c=>{if(c<=0)return 1;let h=Y((c-1)/Math.max(1,s-1),0,1),d=t.ringCountsByDepth.get(Math.round(c))??0,u=$l(d,o,a),f=Y(u.pressure*.62+u.maxPressure*.44,0,1.35),m=(n-1)*(.08+f*.86+h*.08),x=Math.max(0,u.pressure-1)*.1+Math.max(0,u.maxPressure-.72)*.06;return Y(1+m+x,1,1.68)};for(let[c,h]of[...e.entries()])c>0&&e.set(c,h*l(c));for(let c of i.values()){if(c.radius<=.001)continue;let h=Math.max(0,Math.round(c.depth||0)),d=l(h),u=Number.isFinite(c.angle)?c.angle:Math.atan2(c.y,c.x),f=c.radius*d;c.radius=f,c.x=Math.cos(u)*f,c.y=Math.sin(u)*f,c.angle=u,Number.isFinite(c.ringRadius)&&(c.ringRadius=c.ringRadius*d),Number.isFinite(c.ringBandMin)&&(c.ringBandMin=c.ringBandMin*d),Number.isFinite(c.ringBandMax)&&(c.ringBandMax=c.ringBandMax*d)}}function MM(i,e){let t=[...e.keys()].filter(h=>h>0).sort((h,d)=>h-d);if(t.length===0)return;let n=new Map;for(let h of i.values()){if(h.external||h.radius<=.001)continue;let d=Math.max(0,Math.round(h.depth||0));d<=0||n.set(d,(n.get(d)??0)+1)}let s=[...n.values()].reduce((h,d)=>h+d,0),r=Math.max(1,...n.values()),o=s/Math.max(1,n.size),a=Y(1+Math.max(0,Math.log2(Math.max(1,s)/420))*.044+Math.max(0,Math.sqrt(r/72)-1)*.12+Math.max(0,Math.sqrt(o/48)-1)*.075,1,1.46),l=Math.max(...t,1),c=h=>{let d=n.get(h)??0,u=$l(d,o,r),f=Y((h-1)/Math.max(1,l-1),0,1),m=Math.sin(Math.PI*Y(f,0,1)),x=Y(1-f*.68,.28,1),g=Y(u.pressure*.78+u.maxPressure*.88,0,2.08),p=fn(.08,.28,f)*(1-fn(.72,.96,f)),v=m*.7+p*.84+x*.28,b=(a-1)*(.34+v)*g,M=d>0&&u.relativeToAverage<.55?(a-1)*.12:0;return Y(a+b+M,1,1.86)};if(!(a<=1.001&&t.every(h=>c(h)<=1.001))){for(let[h,d]of[...e.entries()])h<=0||e.set(h,d*c(h));for(let h of i.values()){if(h.external||h.radius<=.001)continue;let d=Math.max(0,Math.round(h.depth||0)),u=c(d);if(u<=1.001)continue;let f=Number.isFinite(h.angle)?h.angle:Math.atan2(h.y,h.x);h.radius*=u,h.x=Math.cos(f)*h.radius,h.y=Math.sin(f)*h.radius,h.angle=pn(f),Number.isFinite(h.ringRadius)&&(h.ringRadius=h.ringRadius*u),Number.isFinite(h.ringBandMin)&&(h.ringBandMin=h.ringBandMin*u),Number.isFinite(h.ringBandMax)&&(h.ringBandMax=h.ringBandMax*u)}}}function SM(i,e,t){let n=[...e.keys()].filter(l=>l>0).sort((l,c)=>l-c),s=new Map;for(let l of i.values()){if(l.external||l.radius<=.001)continue;let c=Math.max(0,Math.round(l.depth||0));c>0&&s.set(c,(s.get(c)??0)+1)}let r=Kl(s),o=0,a=t.ringGap;for(let l of n){let c=e.get(l)??0,h=Jl(r,l),d=Mm(a,t,h),u=o+Math.max(t.ringGap*(.86+h.outerWeight*.12+h.sparseTail*.68),d),f=u>c?u-c:0,m=c+f;if(f>0){e.set(l,m);for(let x of i.values()){if(Math.max(0,Math.round(x.depth||0))!==l||x.radius<=.001)continue;x.radius+=f,Number.isFinite(x.ringRadius)&&(x.ringRadius=x.ringRadius+f),Number.isFinite(x.ringBandMin)&&(x.ringBandMin=x.ringBandMin+f),Number.isFinite(x.ringBandMax)&&(x.ringBandMax=x.ringBandMax+f);let g=Number.isFinite(x.angle)?x.angle:Math.atan2(x.y,x.x);x.x=Math.cos(g)*x.radius,x.y=Math.sin(g)*x.radius,x.angle=pn(g)}}a=m-o,o=m}}function wM(i,e,t,n,s){let r=new Map,o=Math.max(s||0,1);for(let a of i){let l=e.get(a.source),c=e.get(a.target);if(!l||!c)continue;let h=Number.isFinite(l.radius)?l.radius:0,d=Number.isFinite(c.radius)?c.radius:0,u=Number.isFinite(l.angle)?l.angle:Math.atan2(c.y-l.y,c.x-l.x),f=Number.isFinite(c.angle)?c.angle:u,m=Math.abs(Jr(u,f)),x=Math.abs(h-d)=Math.max(1,t-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(h,d),sourceAngle:u,targetAngle:f,curveStrength:p?.3:x?.22:m>Math.PI*.72?.2:.15})}return{routes:r,maxRadius:o}}function EM(i,e){if(e.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:e.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 t=new Map;for(let n of i.values()){if(n.depth<=0)continue;let s=n.ringRadius??n.radius,r=t.get(n.depth)??{radius:0,count:0};r.radius+=s,r.count++,t.set(n.depth,r)}return[...t.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 TM(i,e){let t=-Math.max(1,e||1),n=-Math.max(1,e||1),s=Math.max(1,e||1),r=Math.max(1,e||1);for(let o of i.values())t=Math.min(t,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:t,minY:n,maxX:s,maxY:r}}function AM(i,e,t,n){for(let s of i.values())s.x+=t,s.y+=n,s.centerX=t,s.centerY=n;for(let s of e.values())!Number.isFinite(s.centerX)||!Number.isFinite(s.centerY)||(s.centerX+=t,s.centerY+=n)}function Zl(i,e,t,n,s){let r=Math.cos(e)*i,o=Math.sin(e)*i;return{x:r,y:o,homeX:r,homeY:o,radius:i,homeRadius:i,angle:e,homeAngle:e,depth:t,nodeRadius:n,centerX:0,centerY:0,external:s}}function Mu(i,e,t){let n=Y(Math.max(0,t-e),.024,Math.PI*2),s=e+n/2;i.sectorStart=s-n/2,i.sectorEnd=s+n/2,i.sectorSpan=n}function Hs(i,e,t=0){if(!i)return 3.6;let n=Math.max(0,(i.linkCount||0)+(i.backlinkCount||0)),s=Math.max(0,t*.62),r=Math.max(n,s),o=Math.max(1,e||1,r),a=Math.log1p(r)/Math.max(1,Math.log1p(o)),l=Y(a,0,1),c=r>0?Math.pow(l,.58):0,h=Math.pow(l,1.82),d=c*22+h*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 u=Math.log2((i.noteCount||i.descendantCount||1)+1),f=Math.min(5.8,u*.54);return Math.min(64,5.8+f+d*.94)}if(i.type==="external"){let u=Math.log2((i.noteCount||1)+1),f=Math.min(4.2,u*.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 CM(i){let e=1;for(let t of i)e=Math.max(e,(t.linkCount||0)+(t.backlinkCount||0));return e}function Yl(i,e){if(!i||!e)return i?-1:e?1:0;let t=n=>n.type==="folder"?0:n.type==="note"?1:n.type==="external"?2:3;return t(i)-t(e)||i.title.localeCompare(e.title)||i.id.localeCompare(e.id)}function pm(i){let e=0;for(let t of i.values())e=Math.max(e,t.radius);return e}function RM(i,e,t,n){let s=[];for(let r of e.linkEdges){let o=r.source===i.id?r.target:r.target===i.id?r.source:null;if(!o)continue;let a=t.get(o);a&&Number.isFinite(a.angle)&&s.push(a.angle)}return PM(s,n)}function PM(i,e){if(i.length===0)return e;let t=i.reduce((n,s)=>(n.x+=Math.cos(s),n.y+=Math.sin(s),n),{x:0,y:0});return Math.abs(t.x)<1e-4&&Math.abs(t.y)<1e-4?e:Math.atan2(t.y,t.x)}function IM(i,e,t,n,s){let r=Math.max(0,i||0),o=Number.isFinite(e)&&t>0?e/t:r,a=Number.isFinite(e)&&e>0?s/Math.max(1,Math.PI*2*e):0,l=Y(.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 Y(l*c,.42,1.72)}function jl(i){let e=Array.from(String(i.title||"")).length,t=i.type==="folder"?14:0,n=i.type==="external"||i.externalProxy?9:0;return Y(Math.sqrt(Math.max(1,e))*7.5+Math.min(110,e*1.25)+t+n,24,150)}function LM(i,e,t,n){let s=e.rootId||Pe,r=Kr(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),h=Math.sqrt(Math.max(0,a.radius)/Math.max(1,t.ringGap)),d=Kr(o,"swirl-arm")*.16,u=Math.sin(c*2.35+l*.78)*.11,f=r*n*(l*.32+h*.22+d+u),m=pn(c+f);a.x=Math.cos(m)*a.radius,a.y=Math.sin(m)*a.radius,a.angle=m}}function NM(i,e,t){if([...new Set([...i.values()].filter(r=>!r.external&&r.radius>.001).map(r=>Math.max(0,Math.round(r.depth||0))).filter(r=>r>0))].sort((r,o)=>r-o).length===0)return;let s=new Map;for(let r of i.values()){if(r.external||r.radius<=.001)continue;let o=Math.max(0,Math.round(r.depth||0));o>0&&s.set(o,(s.get(o)??0)+1)}DM(i,e,t,Kl(s))}function DM(i,e,t,n){let s=new Map;for(let o of e.hierarchyEdges){if(!i.has(o.source)||!i.has(o.target))continue;let a=s.get(o.source);a?a.push(o.target):s.set(o.source,[o.target])}let r=e.hierarchyEdges.filter(o=>i.has(o.source)&&i.has(o.target)).sort((o,a)=>(i.get(o.source)?.depth??0)-(i.get(a.source)?.depth??0));for(let o=0;o<2;o++){let a=!1;for(let l of r){let c=i.get(l.source),h=i.get(l.target);if(!c||!h||c.external||h.external)continue;let d=Math.max(0,Math.round(c.depth||0)),u=Math.max(0,Math.round(h.depth||0));if(u<=d)continue;let f=Jl(n,u),m=Math.max(f.outerWeight,f.sparseTail*.82);if(m<=.18)continue;let x=Number.isFinite(c.angle)?c.angle:Math.atan2(c.y,c.x),g=Number.isFinite(h.angle)?h.angle:Math.atan2(h.y,h.x),p=Math.abs(Jr(x,g)),v=FM(c,h,t,p,Y(.28+m*.58,.28,.86)),b=c.radius+v-h.radius;if(!(b<=Math.max(2,t.ringGap*.012))){for(let M of kM(l.target,s,i,u)){let S=i.get(M);!S||S.external||S.radius<=.001||OM(S,b)}a=!0}}if(!a)break}}function FM(i,e,t,n,s){let r=Y((n-.42)/1.18,0,.36),o=Y((Math.PI*.72-Y(i.sectorSpan??Math.PI*2,.024,Math.PI*2))/(Math.PI*.72),0,1),a=t.ringGap*(.9+s*.32+r*.22+o*.14)+Math.max(i.nodeRadius,e.nodeRadius)*2.4;if(n<=.08)return a;let h=Math.max(1,(Math.max(0,i.radius)+Math.max(0,e.radius))*.5)*n*(.34+Y(s,0,1)*.14),d=t.ringGap*(s>=.82?2.3:1.76)+Math.max(i.nodeRadius,e.nodeRadius)*3.2;return Math.max(a,Math.min(h,d))}function kM(i,e,t,n){let s=[],r=[i],o=new Set;for(;r.length;){let a=r.pop();if(o.has(a))continue;o.add(a);let l=t.get(a);l&&Math.max(0,Math.round(l.depth||0))>=n&&s.push(a);for(let c of e.get(a)??[])r.push(c)}return s}function OM(i,e){if(i.radius+=e,Number.isFinite(i.ringRadius)){let n=i.ringRadius;Number.isFinite(i.ringBandMin)||(i.ringBandMin=n),i.ringBandMax=Math.max(Number.isFinite(i.ringBandMax)?i.ringBandMax:n,i.radius)}let t=Number.isFinite(i.angle)?i.angle:Math.atan2(i.y,i.x);i.x=Math.cos(t)*i.radius,i.y=Math.sin(t)*i.radius,i.angle=pn(t)}function UM(i,e){let t=new Map;for(let r of e.hierarchyEdges){if(!i.has(r.source)||!i.has(r.target))continue;let o=t.get(r.source);o?o.push(r.target):t.set(r.source,[r.target])}let n=Math.max(0,...[...i.values()].map(r=>Math.max(0,Math.round(r.depth||0)))),s=[...t.keys()].sort((r,o)=>(i.get(r)?.depth??0)-(i.get(o)?.depth??0));for(let r of s){let o=i.get(r),a=t.get(r)??[];if(!o||a.length===0)continue;let l=a.map(S=>({id:S,point:i.get(S),node:e.nodesById.get(S)})).filter(S=>!!S.point);if(l.length<=1)continue;let c=Number.isFinite(o.angle)?o.angle:Math.atan2(o.y,o.x),h=Math.max(0,Math.round(o.depth||0)),d=Y(o.sectorSpan??Math.PI*2,.024,Math.PI*2),u=d>=Math.PI*2-.001?Math.PI*2:d*.985,f=l.length>1&&u1?Math.min(.045,Math.max(.003,g/(l.length*18))):0,v=l.map(S=>({...S,angle:_u(S.point.angle,c)})).sort((S,w)=>S.angle-w.angle||S.id.localeCompare(w.id)),b=v.every(S=>Math.max(0,Math.round(S.point.depth||0))>=n);if(h>1&&BM(v,o,c,m,x,b))continue;let M=m-p;for(let S=0;S1?f/(i.length-1):0;for(let g=0;gn.point.radius),i[0]?.point.radius??1));return(i.reduce((n,s)=>{let r=s.node?jl(s.node)*1.28:28;return n+s.point.nodeRadius*2.6+r+18},0)+Math.max(0,i.length-1)*16)/e}function VM(i,e){if(i<=1)return 0;let t=.18+Math.log2(i+1)*.125;return Y(t,.18,Math.min(e*.55,Math.PI*.36))}function Sm(i,e){if(i<=1)return 0;let t=.1+Math.log2(i+1)*.17;return Y(t,.16,Math.min(e*.55,Math.PI*.42))}function wm(i,e,t){let n=.38+Math.sqrt(Math.max(1,i))*.24,s=Y(1-Math.max(0,e-1)*.045,.68,1),r=n*s,o=Sm(i,t),a=Math.max(o,Math.min(t*.74,Math.PI*.9));return Y(r,o,a)}function _u(i,e){return e+Jr(e,i)}function yu(i,e){let t=pn(e);if(i.x=Math.cos(t)*i.radius,i.y=Math.sin(t)*i.radius,i.angle=t,Number.isFinite(i.sectorSpan)&&(i.sectorSpan??0)>0){let n=Y(i.sectorSpan,.024,Math.PI*2);Mu(i,t-n/2,t+n/2)}}function GM(i){for(let e of i.values())e.homeX=e.x,e.homeY=e.y,e.homeRadius=e.radius,e.homeAngle=e.angle}function pn(i){let e=Number.isFinite(i)?i:0;return e%=Math.PI*2,e<0&&(e+=Math.PI*2),e}function Jr(i,e){let t=pn(e)-pn(i);return t>Math.PI&&(t-=Math.PI*2),t<-Math.PI&&(t+=Math.PI*2),t}function HM(i,e){let t=`${i}|${e}`,n=2166136261;for(let s=0;s>>0)/4294967296*Math.PI*2}function Kr(i,e){return Math.sin(HM(String(i||""),String(e||"")))}function WM(i,e){let t=i.filter(Number.isFinite).sort((s,r)=>s-r);if(!t.length)return e;let n=Math.floor(t.length/2);return t.length%2?t[n]??e:((t[n-1]??e)+(t[n]??e))/2}function Y(i,e,t){return Math.min(Math.max(Number.isFinite(i)?i:e,e),t)}var Ln=1e-4,Mn=6,Ql=4.8,Su={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}};function Cu(i){return Su[i].bg}var ec=class{constructor(e){this.container=e;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=nc();this.width=1;this.height=1;this.centerX=0;this.centerY=0;this.zoom=1;this.scheme="night";this.background=Su.night.bg;this.revealFrame=0;this.revealOverlay=null;this.renderBatchDepth=0;this.pendingRender=!1;this.showRingGuides=!1;this.revealDepthLimit=Number.POSITIVE_INFINITY;this.currentLabelVisibility="auto";this.container.addClass("is-radial-preparing"),this.renderer=new Fs({antialias:!0,alpha:!1}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),this.renderer.setClearColor(this.background,1),this.domElement=this.renderer.domElement,this.domElement.classList.add("mwm-radial-canvas"),this.domElement.tabIndex=0,e.appendChild(this.domElement),this.labelRoot=e.createDiv({cls:"mwm-radial-labels"}),this.camera=new ai(-1,1,1,-1,.1,5e3),this.camera.position.set(0,0,1e3),this.camera.lookAt(0,0,0)}setTheme(e,t=Cu(e)){let n=this.scheme!==e,s=this.background!==t;if(!n&&!s)return!1;if(this.scheme=e,this.background=t,this.renderer.setClearColor(this.background,1),n&&this.nodeMaterial){let r=this.nodeMaterial.uniforms.uLightMode,o=this.nodeMaterial.uniforms.uPixelScale;r&&(r.value=e==="day"?1:0),o&&(o.value=1e3*Math.min(window.devicePixelRatio||1,2)),this.updateNodeScale()}return this.render(),n}setData(e,t,n,s=!1){this.graph=e,this.layout=t,this.showRingGuides=s,this.currentLabelVisibility=n,this.rebuildSceneObjects(n)}rebuildSceneObjects(e=this.currentLabelVisibility){if(!(!this.graph||!this.layout)){this.edgeVisuals.clear(),this.disposeObjects(),this.buildRings(),this.buildEdges(this.graph.hierarchyEdges,this.layout,"hierarchy"),this.buildEdges(this.graph.linkEdges,this.layout,"links");for(let t of this.graph.hoverLinkEdges){if(!this.edgeRevealVisible(t,this.layout)||this.edgeVisuals.has(t.id))continue;let n=this.edgeVisual(t,this.layout);n&&this.edgeVisuals.set(n.key,n)}this.buildNodes(this.graph,this.layout),this.setActive(this.active,e),this.render()}}resize(e,t){this.width=Math.max(1,Math.floor(e)),this.height=Math.max(1,Math.floor(t)),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(e,t,n){this.centerX=Number.isFinite(e)?e:0,this.centerY=Number.isFinite(t)?t:0,this.zoom=Math.min(Math.max(Number.isFinite(n)?n:1,Ln),Mn),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(e){cancelAnimationFrame(this.revealFrame),this.revealDepthLimit=Number.POSITIVE_INFINITY,this.container.removeClass("is-radial-revealing"),this.container.removeClass("is-radial-depth-revealing"),this.container.addClass("is-radial-preparing"),this.ensureRevealOverlay(e)}clearLoadingMask(e=!1){cancelAnimationFrame(this.revealFrame),this.setRevealDepthLimit(Number.POSITIVE_INFINITY),this.clearRevealMask(e),this.render()}beginRenderBatch(){this.renderBatchDepth++}endRenderBatch(){this.renderBatchDepth<=0||(this.renderBatchDepth--,this.renderBatchDepth===0&&this.pendingRender&&(this.pendingRender=!1,this.render()))}fitToLayout(e=null){if(!this.layout||this.width<8||this.height<8)return!1;let t=42,n=Math.max(1,this.width-t),s=Math.max(1,this.height-t),r=Math.min(n/Math.max(1,this.layout.width),s/Math.max(1,this.layout.height))*1.08,o=e!==null?this.layout.positions.get(e)??this.layout.positions.get(Pe):null;return this.setView(o?.x??this.layout.width/2,o?.y??this.layout.height/2,r),!0}playRevealFromRoot(e,t,n=0){if(cancelAnimationFrame(this.revealFrame),!this.graph||!this.layout||this.width<2||this.height<2){this.clearRevealMask(!1);return}let s=KM(this.graph,this.layout,e);if(s.length===0){this.clearRevealMask(!1);return}let r=n>0?n:Ft(680+s.length*165,1150,3600),o=0;this.container.addClass("is-radial-preparing"),this.container.removeClass("is-radial-depth-revealing"),this.setRevealDepthLimit(s[0]??0),this.ensureRevealOverlay(t),this.render(),this.container.removeClass("is-radial-preparing"),this.container.addClass("is-radial-depth-revealing"),this.fadeRevealOverlay();let a=performance.now(),l=c=>{let h=Math.min(Math.max((c-a)/r,0),1),d=Math.min(s.length-1,Math.floor(h*s.length));if(d!==o&&(o=d,this.setRevealDepthLimit(s[d]??0)),h<1){this.revealFrame=window.requestAnimationFrame(l);return}this.setRevealDepthLimit(Number.POSITIVE_INFINITY),this.clearRevealMask(!0)};this.revealFrame=window.requestAnimationFrame(l)}setActive(e,t){this.active=e,this.updateNodeDim(),this.rebuildHighlights(),this.updateLabels(t),this.render()}render(){if(this.renderBatchDepth>0){this.pendingRender=!0;return}this.renderer.render(this.scene,this.camera)}worldToScreen(e,t){let n=new N(e,t,0).project(this.camera);return{x:(n.x+1)/2*this.width,y:(1-n.y)/2*this.height}}screenToWorld(e,t){return{x:this.centerX+(e-this.width/2)/this.zoom,y:this.centerY-(t-this.height/2)/this.zoom}}hitTest(e,t,n,s=!0){if(!this.graph||!this.layout)return{nodeId:null,edge:null};let r=this.screenToWorld(e,t),o=null;if(s)for(let l of this.graph.nodes){let c=this.layout.positions.get(l.id);if(!this.pointRevealVisible(c))continue;let h=Math.hypot(r.x-c.x,r.y-c.y),d=Math.max(4,Em(c.nodeRadius,this.palette().nodeScale,this.zoom)*.55),u=Math.max(c.nodeRadius*.36,d/Math.max(Ln,this.zoom))+Math.max(5,6/this.zoom);h<=u&&(!o||h{this.revealOverlay===e&&(e.remove(),this.revealOverlay=null)},220)}setRevealDepthLimit(e){let t=Number.isFinite(e)?e:Number.POSITIVE_INFINITY;this.revealDepthLimit!==t&&(this.revealDepthLimit=t,this.rebuildSceneObjects(this.currentLabelVisibility))}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 e=[],t=[],n=new ge(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)o.depth>this.revealDepthLimit||!Number.isFinite(o.radius)||o.radius<=0||qM(e,t,n,s,r,o.radius,o.depth,-3);if(e.length===0){this.ringSegments=null;return}this.ringSegments=new ri(wu(e,t),new zn({vertexColors:!0,transparent:!0,opacity:this.palette().ringOpacity,depthWrite:!1})),this.scene.add(this.ringSegments)}buildEdges(e,t,n){let s=[],r=[],o=this.palette();for(let l of e){if(!this.edgeRevealVisible(l,t))continue;let c=this.edgeVisual(l,t);if(!c)continue;this.edgeVisuals.set(c.key,c);let h=$M(l,n,o);for(let d=0;dl.externalCount)?o.externalLinkOpacity:o.linkOpacity,depthWrite:!1}));n==="hierarchy"?this.hierarchySegments=a:this.linkSegments=a,this.scene.add(a)}buildNodes(e,t){let n=this.palette(),s=e.nodes.filter(h=>this.pointRevealVisible(t.positions.get(h.id))),r=new Float32Array(s.length*3),o=new Float32Array(s.length*3),a=new Float32Array(s.length),l=new Float32Array(s.length),c=new Float32Array(s.length).fill(1);this.nodeIds=s.map(h=>h.id),s.forEach((h,d)=>{let u=t.positions.get(h.id),f=ZM(h,e.rootId,n);r[d*3]=u?.x??0,r[d*3+1]=u?.y??0,r[d*3+2]=1,o[d*3]=f.r,o[d*3+1]=f.g,o[d*3+2]=f.b,a[d]=Ru(u?.nodeRadius??8,n.nodeScale),l[d]=h.type==="unresolved"||h.type==="external"||h.externalProxy?1:0}),this.nodeGeometry=new ht,this.nodeGeometry.setAttribute("position",new Ye(r,3)),this.nodeGeometry.setAttribute("color",new Ye(o,3)),this.nodeGeometry.setAttribute("aSize",new Ye(a,1)),this.nodeGeometry.setAttribute("aGhost",new Ye(l,1)),this.nodeGeometry.setAttribute("aDim",new Ye(c,1)),this.nodeMaterial=new ut({vertexShader:Tl,fragmentShader:Al,vertexColors:!0,transparent:!0,depthWrite:!1,uniforms:{uPixelScale:{value:1e3*Math.min(window.devicePixelRatio||1,2)},uSizeMul:{value:tc(this.zoom)},uSizeContrast:{value:Eu(this.zoom)},uBasePoint:{value:Ql},uMinPoint:{value:Tu(this.zoom)*Math.min(window.devicePixelRatio||1,2)},uLightMode:{value:this.scheme==="day"?1:0},uMaxPoint:{value:Au(this.zoom)*Math.min(window.devicePixelRatio||1,2)}}}),this.nodePoints=new Vn(this.nodeGeometry,this.nodeMaterial),this.nodePoints.frustumCulled=!1,this.scene.add(this.nodePoints)}updateNodeDim(){if(!this.nodeGeometry)return;let e=this.nodeGeometry.getAttribute("aDim"),t=e.array;for(let n=0;no.dispose()):this.highlightSegments.material.dispose(),this.highlightSegments=null);let e=[],t=[],n=this.palette(),s=new ge(n.focus),r=Math.max(Ln,this.zoom||1);for(let o of this.active.highlightedEdges){let a=this.edgeVisuals.get(o);if(a)for(let l=0;l{h!=null&&t.add(h)};for(let h of this.active.labelNodes)n(h);for(let h of this.active.pinnedNodeIds)n(h);n(this.active.activeNodeId),n(Pe),n(this.graph.rootId),n(this.graph.focusId);let s=this.graph.nodes.map(h=>{let d=this.layout?.positions.get(h.id)??null;if(!this.pointRevealVisible(d))return null;let u=this.worldToScreen(d.x,d.y);return u.x>=-160&&u.y>=-80&&u.x<=this.width+160&&u.y<=this.height+120?{node:h,point:d,screen:u,score:tS(h,d,this.graph)}:null}).filter(h=>!!h).sort((h,d)=>d.score-h.score),r=Math.max(1,s.length-1),o=Ft(Math.sqrt(Math.max(1,this.width*this.height))/1050,.65,1.8),a=22+dt(.035,.42,this.zoom)*64+dt(.36,1.3,this.zoom)*112+dt(1.1,6,this.zoom)*72,l=e==="auto"&&this.zoom>=.045?Math.round(Math.min(this.palette().maxLabels,Math.max(0,a*o))):0,c=0;for(let h=0;h=l)continue;c++}let p=u.id===this.graph.rootId||u.id===Pe,v=h<36,b=["mwm-radial-label"];p&&b.push("is-root"),!p&&(v||u.type==="folder")&&b.push("is-strong");let M=this.labelRoot.createDiv({cls:b.join(" ")});M.setText(u.title);let S=iS(this.zoom)*(p?1.18:f.nodeRadius>=24?1.1:f.nodeRadius>=15?1.04:1),w=Math.max(p?12:9.5,12*S);M.style.fontSize=`${w.toFixed(2)}px`,M.style.maxWidth=`${Math.round((p?240:u.type==="folder"?210:v?196:180)*S)}px`,M.style.opacity=String(x?.96:Math.min(.9,.22+g*.68));let C=Math.max(5,Em(f.nodeRadius,this.palette().nodeScale,this.zoom)*.62),_=Math.max(9,C+6*S);M.style.transform=`translate3d(${m.x.toFixed(1)}px, ${(m.y+_).toFixed(1)}px, 0)`,this.active.dimOthers&&!t.has(u.id)&&!this.active.relatedNodes.has(u.id)&&(M.style.opacity=String(Math.min(Number(M.style.opacity)||1,.34)),M.addClass("is-dim"))}}disposeObjects(){for(let e of[this.ringSegments,this.hierarchySegments,this.linkSegments,this.highlightSegments,this.nodePoints]){if(!e)continue;this.scene.remove(e),"geometry"in e&&e.geometry.dispose();let t=Array.isArray(e.material)?e.material:[e.material];for(let n of t)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 nc(){return{hasActive:!1,dimOthers:!1,activeNodeId:null,activeLinkId:null,relatedNodes:new Set,highlightedEdges:new Set,labelNodes:new Set,pinnedNodeIds:new Set}}function wu(i,e){let t=new ht;return t.setAttribute("position",new Ye(new Float32Array(i),3)),t.setAttribute("color",new Ye(new Float32Array(e),3)),t}function XM(i,e){let t=wu(i,e);return t.computeBoundingSphere(),t}function qM(i,e,t,n,s,r,o,a){let l=Math.max(96,Math.ceil(r/16)),c=Math.max(3,Math.round(l/72)),h=o%2===0?0:c;for(let d=0;d=c)continue;let u=d/l*Math.PI*2,f=(d+1)/l*Math.PI*2;i.push(n+Math.cos(u)*r,s+Math.sin(u)*r,a),i.push(n+Math.cos(f)*r,s+Math.sin(f)*r,a),jr(e,t,1),jr(e,t,1)}}function YM(i,e,t,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 h=Math.max(.1,r*.5),d=-l/c*h,u=a/c*h,f=[[n.x+d,n.y+u,o],[n.x-d,n.y-u,o],[s.x-d,s.y-u,o],[n.x+d,n.y+u,o],[s.x-d,s.y-u,o],[s.x+d,s.y+u,o]];for(let m of f)i.push(m[0],m[1],m[2]),jr(e,t,1)}function jr(i,e,t){i.push(e.r,e.g,e.b)}function ZM(i,e,t){return i.id===e?new ge(t.root):i.type==="unresolved"?new ge(t.unresolved):i.type==="external"||i.externalProxy?new ge(t.external):i.type==="folder"&&i.representativeFile?new ge(t.folderMeta):i.type==="folder"?new ge(t.folder):new ge(t.note)}function $M(i,e,t){return i.unresolvedCount?new ge(t.unresolved):i.externalCount?new ge(e==="links"?t.externalLink:t.external):new ge(e==="hierarchy"?t.tree:t.link)}function KM(i,e,t){let n=new Set,s=e.positions.get(t)?.depth??0;n.add(s);for(let r of i.nodes){let o=e.positions.get(r.id);!o||!Number.isFinite(o.depth)||n.add(Math.max(s,Math.round(o.depth)))}return[...n].sort((r,o)=>r-o)}function JM(i,e,t){if(!t)return[i,e];if(t.kind==="outer"){let h=[i],d=t.sourceAngle,u=t.endAngle??t.targetAngle,f=u-d;Math.abs(f)>Math.PI&&(f+=f>0?-Math.PI*2:Math.PI*2),u=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;h.push({x:t.centerX+Math.cos(g)*t.radius,y:t.centerY+Math.sin(g)*t.radius})}return h.push(e),h}let n=(i.x+e.x)/2,s=(i.y+e.y)/2,r=t.curveStrength??.16,o=Number.isFinite(t.centerX)?t.centerX:Number.isFinite(i.centerX)?i.centerX:n,a=Number.isFinite(t.centerY)?t.centerY:Number.isFinite(i.centerY)?i.centerY:s,l={x:n+(o-n)*r,y:s+(a-s)*r},c=[];for(let h=0;h<=12;h++){let d=h/12,u=(1-d)*(1-d),f=2*(1-d)*d,m=d*d;c.push({x:u*i.x+f*l.x+m*e.x,y:u*i.y+f*l.y+m*e.y})}return c}function jM(i,e){let t=1/0;for(let n=0;n=24?dt(.14,.42,l)*.98:e.nodeRadius>=15?dt(.24,.64,l)*.82:0,I=f?0:dt(.12,.82,l)*v*.96,H=f?0:dt(.48,.98,l)*.9,W=f?0:dt(.82,1.18,l)*.98;return Ft(Math.max(A,P,R,I,H,W),0,1)}function iS(i){let e=Ft(i,Ln,Mn);return .62+dt(.06,1.48,e)*.88}function Ru(i,e){let t=Math.max(0,Number.isFinite(i)?i:8),n=3.9+t*e*.86+Math.sqrt(t)*.48,s=dt(14,64,t)*t*e*.42;return Ft(n+s,Ql,42)}function Em(i,e,t){let n=Ru(i,e),s=Ql+Math.max(0,n-Ql)*Eu(t);return Ft(s*tc(t),Tu(t),Au(t))}function tc(i){let e=Ft(i,Ln,Mn);return .86+dt(.025,.28,e)*.13+dt(.28,1.3,e)*.15+dt(1.3,Mn,e)*.08}function Eu(i){let e=Ft(i,Ln,Mn);return .4+dt(.025,.28,e)*.28+dt(.28,1.25,e)*.44+dt(1.25,Mn,e)*.58}function Tu(i){let e=Ft(i,Ln,Mn);return 4.6+dt(.02,.22,e)*.2}function Au(i){let e=Ft(i,Ln,Mn);return 30+dt(.025,.42,e)*24+dt(.42,1.6,e)*30+dt(1.6,Mn,e)*28}function dt(i,e,t){if(i===e)return t>=e?1:0;let n=Ft((t-i)/(e-i),0,1);return n*n*(3-2*n)}function Ft(i,e,t){return Number.isFinite(i)?Math.min(t,Math.max(e,i)):e}var lc=require("obsidian");function Cm(i,e,t,n,s=mu){let r=new Map,o=[],a=[],l=new Map,c=new Map,h=new Map,d=new Map,u=0,f=0,m=b=>sS(b,n.ignoreFolders),x=b=>{r.has(b.id)||m(b.id)||r.set(b.id,b)};x({id:Pe,path:Pe,title:s.trim()||mu,type:"folder",parentId:null,depth:0,noteCount:0,linkCount:0,backlinkCount:0,descendantCount:0});let g=b=>{let M=Ui(b);if(!M)return Pe;let S=Pe;for(let w of M.split("/").filter(Boolean)){let C=S?`${S}/${w}`:w;if(m(C))return S;r.has(C)||x({id:C,path:C,title:ic(C),type:"folder",parentId:S,depth:Tm(C),noteCount:0,linkCount:0,backlinkCount:0,descendantCount:0}),S=C}return S};for(let b of i){u++;let M=Ui(b.path);if(!M||m(M))continue;if(b.kind==="folder"){g(M);continue}f++;let S=g(Pu(M));x({id:M,path:M,title:b.basename||ic(M).replace(/\.md$/i,""),type:"note",parentId:S,depth:Tm(M),noteCount:1,linkCount:0,backlinkCount:0,descendantCount:0})}rS(r,d);let p=(b,M,S,w)=>{if(b===M||!r.has(b)||!r.has(M))return;let C={id:`${w}:${b}->${M}:${a.length}`,type:w,source:b,target:M,weight:S};a.push(C);let _=r.get(b),A=r.get(M);_&&(_.linkCount+=S),A&&(A.backlinkCount+=S),sc(c,b,C),sc(h,M,C)};for(let[b,M]of Object.entries(e))if(!(!r.has(b)||m(b)))for(let[S,w]of Object.entries(M??{}))!r.has(S)||m(S)||p(b,S,Math.max(1,Number(w)||1),"link");if(n.includeUnresolvedLinks){for(let[b,M]of Object.entries(t))if(!(!r.has(b)||m(b)))for(let[S,w]of Object.entries(M??{})){let C=`unresolved:${b}:${S}`;if(!r.has(C)){let _=r.get(b);x({id:C,path:S,title:S,type:"unresolved",parentId:_?.parentId??Pe,depth:(_?.depth??0)+1,noteCount:0,linkCount:0,backlinkCount:0,descendantCount:0})}p(b,C,Math.max(1,Number(w)||1),"unresolved-link")}}oS(r,o,l),aS(r);let v={loadedEntries:u,scannedMarkdown:f,folders:[...r.values()].filter(b=>b.type==="folder").length,notes:[...r.values()].filter(b=>b.type==="note").length,unresolved:[...r.values()].filter(b=>b.type==="unresolved").length,hierarchyEdges:o.length,linkEdges:a.length,maxDepth:Math.max(0,...[...r.values()].map(b=>b.depth))};return{nodes:r,hierarchyEdges:o,linkEdges:a,childrenByParent:l,linkEdgesBySource:c,linkEdgesByTarget:h,folderRepresentatives:d,stats:v}}function rc(i,e){if(!i||!e)return i?-1:e?1:0;let t=n=>n.type==="folder"?0:n.type==="note"?1:n.type==="external"?2:3;return i.depth-e.depth||t(i)-t(e)||i.title.localeCompare(e.title)||i.id.localeCompare(e.id)}function Ui(i){return String(i||"").trim().replace(/^\/+|\/+$/g,"")}function Pu(i){let e=Ui(i),t=e.lastIndexOf("/");return t===-1?Pe:e.slice(0,t)}function ic(i){let e=Ui(i),t=e.lastIndexOf("/");return t===-1?e:e.slice(t+1)}function Tm(i){let e=Ui(i);return e?e.split("/").filter(Boolean).length:0}function sS(i,e){let t=Ui(i);return t?e.some(n=>t===n||t.startsWith(`${n}/`)):!1}function rS(i,e){let t=new Map;for(let n of i.values())n.type==="note"&&n.parentId!==null&&sc(t,n.parentId,n);for(let n of i.values()){if(n.type!=="folder"||n.id===Pe)continue;let s=Am(n.title),r=(t.get(n.id)??[]).find(o=>Am(o.title)===s);r&&(n.representativeFile=r.id,r.isRepresentativeFile=!0,r.representativeFor=n.id,e.set(n.id,r.id))}}function oS(i,e,t){for(let n of i.values())n.parentId===null||!i.has(n.parentId)||(e.push({id:`hierarchy:${n.parentId}->${n.id}`,type:"hierarchy",source:n.parentId,target:n.id,weight:1}),sc(t,n.parentId,n.id));for(let n of t.values())n.sort((s,r)=>rc(i.get(s),i.get(r)))}function aS(i){let e=[...i.values()].sort((t,n)=>n.depth-t.depth);for(let t of e){if(t.descendantCount=t.type==="note"?1:t.noteCount,!t.parentId||!i.has(t.parentId))continue;let n=i.get(t.parentId);if(!n)continue;let s=t.type==="note"?1:t.noteCount;n.descendantCount+=s,n.noteCount+=s,n.linkCount+=t.linkCount,n.backlinkCount+=t.backlinkCount}}function Am(i){return i.replace(/\.md$/i,"").trim().toLowerCase()}function sc(i,e,t){let n=i.get(e);n?n.push(t):i.set(e,[t])}function Fm(i){let e=i.hiddenLegendItems.slice(),t=new Set(e);return{mode:"atlas",rootPath:Pe,focusPath:null,search:"",atlasDepth:i.atlasDepth,focusSiblingLimit:i.focusSiblingLimit,nodeLimit:i.renderNodeLimit,linkLimit:i.linkLimit,externalLinkAnchorLimit:i.externalLinkAnchorLimit,showLinkOverlay:i.showLinkOverlay||!t.has("link"),showExternalLinks:i.showExternalLinks,externalDetailMode:i.externalDetailMode,showCompleteRoot:!1,hoverHighlightMode:i.hoverHighlightMode,pinNeedsHoverLinks:!1,selectedNodeId:null,selectedLink:null,hiddenLegendItems:e,labelVisibility:i.labelVisibility}}function km(i,e,t=kt){return e.mode==="focus"?cS(i,e,t):lS(i,e,t)}function Lu(i,e){if(e==null)return null;let t=i.nodes.get(e);return t?.isRepresentativeFile&&t.representativeFor&&i.nodes.has(t.representativeFor)?t.representativeFor:e}function lS(i,e,t){let n=i.nodes.has(e.rootPath)?e.rootPath:Pe,s=i.nodes.get(n)?.depth??0,r=At(e.atlasDepth,1,80,t.atlasDepth),o=Nu(e.search),a=new Set,l=[n];for(;l.length>0;){let c=l.pop(),h=c?i.nodes.get(c):i.nodes.get(Pe);if(!h)continue;let u=Math.max(0,h.depth-s)<=r,f=o.length>0&&oc(h,o);if((u||f)&&(a.add(h.id),f&&Ws(i,h.id,a,n)),u||f)for(let m of[...i.childrenByParent.get(h.id)??[]].reverse())l.push(m)}if(o)for(let c of i.nodes.values())oc(c,o)&&(a.add(c.id),Ws(i,c.id,a,n));return Um(i,a),Om(i,a,n,e,t,null)}function cS(i,e,t){let n=e.focusPath&&i.nodes.has(e.focusPath)?e.focusPath:_S(i),s=new Set([Pe]),r=At(e.focusSiblingLimit,10,1e3,t.focusSiblingLimit);if(n){s.add(n),Ws(i,n,s,Pe),fS(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,h)=>h.weight-c.weight);for(let c of l.slice(0,Math.max(30,r)))s.add(c.source),s.add(c.target),Ws(i,c.source,s,Pe),Ws(i,c.target,s,Pe)}let o=Nu(e.search);if(o)for(let a of i.nodes.values())oc(a,o)&&(s.add(a.id),Ws(i,a.id,s,Pe));return Um(i,s),Om(i,s,Pe,e,t,n)}function Om(i,e,t,n,s,r){let o=[...e].map(u=>i.nodes.get(u)).filter(u=>!!u);o.sort(rc);let a=uS(i,o,t,n,s,r);o=dS(i,a.nodes);let l=new Set(o.map(u=>u.id)),c=i.hierarchyEdges.filter(u=>l.has(u.source)&&l.has(u.target)),h=hS(i,l,n,s,t);o=o.concat(h.externalNodes);let d=new Map(o.map(u=>[u.id,u]));return{nodes:o,nodesById:d,hierarchyEdges:c.concat(h.externalHierarchyEdges),linkEdges:h.linkEdges,hoverLinkEdges:h.hoverLinkEdges,rootId:t,focusId:Lu(i,r),hiddenNodeCount:a.hiddenNodeCount,externalNodeCount:h.externalNodes.length,externalFileCount:h.externalNodes.filter(u=>u.externalProxy).length,externalGroupCount:h.externalNodes.filter(u=>u.type==="external"&&!u.externalProxy).length}}function hS(i,e,t,n,s){let r=new Set(t.hiddenLegendItems),o=t.showLinkOverlay&&!r.has("link"),a=o&&!r.has("dashed-link"),l=!r.has("outside-link"),c=!r.has("outside")||!r.has("outside-file"),h=$s(t.hoverHighlightMode)||t.pinNeedsHoverLinks,d=t.showExternalLinks&&s!==Pe&&(c||l);if(!o&&!a&&!h&&!d)return{linkEdges:[],hoverLinkEdges:[],externalNodes:[],externalHierarchyEdges:[]};let u=new Map,f=new Map,m=[],x=At(t.externalLinkAnchorLimit,0,2e4,n.externalLinkAnchorLimit),g={fileCount:0,overflowId:null};for(let A of i.linkEdges){let P=Pm(i,A.source,e,s),R=Pm(i,A.target,e,s),I=0;if(d&&(!P&&R&&(P=Im(i,A.source,s,f,m,x,g,Lm(A,t,R)),P&&(I=1)),P&&!R&&(R=Im(i,A.target,s,f,m,x,g,Lm(A,t,P)),R&&(I=1))),!P||!R||P===R)continue;let H=`${P}->${R}`,W=u.get(H)??{id:`visible-link:${H}`,type:"visible-link",source:P,target:R,weight:0,rawCount:0,unresolvedCount:0,externalCount:0};W.weight+=A.weight,W.rawCount=(W.rawCount??0)+1,A.type==="unresolved-link"&&(W.unresolvedCount=(W.unresolvedCount??0)+1),W.externalCount=(W.externalCount??0)+I,u.set(H,W)}let p=[...u.values()].sort((A,P)=>Dm(P)-Dm(A)),v=A=>A.externalCount?l&&(!A.unresolvedCount||a):A.unresolvedCount?a:o,b=A=>A.externalCount?d&&l&&(!A.unresolvedCount||!r.has("dashed-link")):A.unresolvedCount?!r.has("dashed-link"):!r.has("link"),M=t.showCompleteRoot?3e4:At(t.linkLimit,0,3e4,n.linkLimit),S=p.filter(v).slice(0,M),w=t.showCompleteRoot?S:p.filter(b),C=new Set;for(let A of d?p.filter(P=>P.externalCount):h?w:[])f.has(A.source)&&C.add(A.source),f.has(A.target)&&C.add(A.target);let _=xS(C,f);return{linkEdges:S,hoverLinkEdges:w,externalNodes:_,externalHierarchyEdges:m.filter(A=>C.has(A.target))}}function uS(i,e,t,n,s,r){if(n.showCompleteRoot&&e.length<=2e4)return{nodes:e,hiddenNodeCount:0};let o=At(n.nodeLimit,200,2e4,s.renderNodeLimit);if(e.length<=o)return{nodes:e,hiddenNodeCount:0};let a=e.slice().sort((d,u)=>Nm(u,t,r,n.search)-Nm(d,t,r,n.search)),l=new Map(e.map(d=>[d.id,d])),c=new Set([t,r].filter(d=>d!=null));Rm(i,t,c,o,n.showCompleteRoot?128:64);for(let d of a){if(c.size>=o)break;pS(i,d.id,c,l,o),d.type==="folder"&&Rm(i,d.id,c,o,n.showCompleteRoot?18:8)}let h=e.filter(d=>c.has(d.id));return{nodes:h,hiddenNodeCount:Math.max(0,e.length-h.length)}}function dS(i,e){let t=new Set(e.map(n=>n.id));return e.filter(n=>!n.isRepresentativeFile||!n.representativeFor||!t.has(n.representativeFor))}function Um(i,e){for(let t of[...e]){let n=i.nodes.get(t);if(!(!n||n.type!=="folder"))for(let s of i.childrenByParent.get(t)??[]){let r=i.nodes.get(s);(r?.type==="note"||r?.type==="unresolved")&&e.add(s)}}}function fS(i,e,t,n){let s=[...i.childrenByParent.get(e)??[]],r=0;for(;s.length>0&&r=0&&t.size=n||r>=s)return;let a=i.nodes.get(o);a?.type!=="note"&&a?.type!=="unresolved"||(t.add(o),r++)}}function Pm(i,e,t,n){let s=i.nodes.get(e);for(;s;){if(t.has(s.id))return s.id;if(s.id===n)return n;s=s.parentId===null?void 0:i.nodes.get(s.parentId)}return t.has(Pe)?Pe:null}function Im(i,e,t,n,s,r,o,a){let l=i.nodes.get(e);if(!l)return null;let c=vS(l,t);if(!c)return null;let h=mS(i,c,t,n);return!a||l.type!=="note"&&l.type!=="unresolved"?h:n.has(l.id)?l.id:o.fileCount>=r?gS(t,h,n,s,o):(n.set(l.id,{...l,externalProxy:!0,externalParentId:h,externalAnchorPath:c}),o.fileCount++,s.push({id:`external-hierarchy:${h}->${l.id}`,type:"external-hierarchy",source:h,target:l.id,weight:1}),l.id)}function mS(i,e,t,n){let s=`external-group:${t}:${e}`;if(!n.has(s)){let r=i.nodes.get(e);n.set(s,{id:s,path:e,title:`Outside: ${r?.title??ic(e)}`,type:"external",parentId:null,depth:(i.nodes.get(t)?.depth??0)+1,noteCount:r?.noteCount??r?.descendantCount??0,linkCount:0,backlinkCount:0,descendantCount:r?.descendantCount??r?.noteCount??0,externalAnchorPath:e})}return s}function gS(i,e,t,n,s){return s.overflowId||(s.overflowId=`external-overflow:${i}`,t.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:e,externalAnchorPath:null}),n.push({id:`external-hierarchy:${e}->${s.overflowId}`,type:"external-hierarchy",source:e,target:s.overflowId,weight:1})),s.overflowId}function xS(i,e){let t=new Map;for(let n of i){let s=e.get(n);if(s){if(s.externalParentId&&e.has(s.externalParentId)){let r=e.get(s.externalParentId);r&&t.set(r.id,r)}t.set(n,s)}}return[...t.values()].sort(rc)}function Lm(i,e,t){if(e.externalDetailMode==="exact")return!0;if(e.externalDetailMode==="grouped")return!1;if(e.selectedNodeId&&(i.source===e.selectedNodeId||i.target===e.selectedNodeId||t===e.selectedNodeId))return!0;let n=e.selectedLink;return!!(n&&(n.source===t||n.target===t||n.source===i.source||n.target===i.target))}function vS(i,e){let t=i.type==="unresolved"?Pu(i.path):i.path,n=t.split("/").filter(Boolean);if(!e)return n[0]??t;let s=e.split("/").filter(Boolean),r=0;for(;re.type==="note")?.id??null}function Nu(i){return i.trim().toLowerCase()}function oc(i,e){return i.title.toLowerCase().includes(e)||i.path.toLowerCase().includes(e)}function Nm(i,e,t,n){let s=0;return i.id===e&&(s+=1e6),i.id===t&&(s+=9e5),n&&oc(i,Nu(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 Dm(i){return(i.weight||1)*10+(i.rawCount||0)*4+(i.externalCount||0)*25+(i.unresolvedCount||0)*8}var ac=class{constructor(e,t){this.app=e;this.settings=t;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(e=this.settings){this.settings=e,this.model=Cm(this.collectVaultEntries(),this.app.metadataCache.resolvedLinks,this.app.metadataCache.unresolvedLinks,e,this.app.vault.getName())}buildVisibleGraph(e){return this.model||this.rebuild(),km(this.model,e,this.settings)}visualNodeId(e){return this.model?Lu(this.model,e):e??null}getActiveNotePath(){let e=this.app.workspace.getActiveFile();return e&&this.nodes.has(e.path)?e.path:[...this.nodes.values()].find(t=>t.type==="note")?.id??null}collectVaultEntries(){let e=[],t=typeof this.app.vault.getRoot=="function"?this.app.vault.getRoot():null,n=t&&Array.isArray(t.children)?[...t.children]:[];for(;n.length>0;){let s=n.pop();if(s instanceof lc.TFolder){let r=Ui(s.path);if(r&&e.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 lc.TFile&&s.extension==="md"&&e.push({path:s.path,basename:s.basename,kind:"note",size:s.stat.size})}if(e.length===0)for(let s of this.app.vault.getMarkdownFiles())e.push({path:s.path,basename:s.basename,kind:"note",size:s.stat.size});return e.some(s=>s.path===Pe)?e.filter(s=>s.path!==Pe):e}};var yS=.22,hc=class extends Yt.Component{constructor(t,n,s,r,o,a){super();this.app=t;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="view";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.rebuildToken=0;this.drag=null;this.needsFit=!0;this.index=new ac(t,s.radial),this.state=Fm(s.radial),this.saveSoon=(0,Yt.debounce)(r,500,!0),this.redrawSoon=(0,Yt.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 ec(this.canvasHost),this.syncThemeClass(),this.buildPanel(),this.buildFloatingControls(),this.bindRendererEvents(),this.registerVaultEvents(),this.renderer.showLoadingMask(this.t("loading.radial")),await this.waitForStartupReady(),!this.disposed&&(await this.queueRebuild("start"),this.disposed||(this.startupSettled=!0))}onunload(){this.disposed=!0,super.onunload()}resize(){this.resizeRenderer(!0)}resizeRenderer(t){if(!(!this.renderer||!this.canvasHost)){if(this.renderer.resize(this.canvasHost.clientWidth,this.canvasHost.clientHeight),t&&this.needsFit&&this.renderer.fitToLayout(this.graph?.rootId??Pe)){this.needsFit=!1;return}this.renderer.render()}}onCssChange(){this.syncThemeClass()}rebuild(t){this.queueRebuild(t)}async queueRebuild(t){let n=++this.rebuildToken;await this.rebuildNow(t,n)}async rebuildNow(t,n){let s=this.radial(),r=["start","manual","root","focus","atlas"].includes(t),o=this.t("loading.radial");if(r&&(this.renderer?.showLoadingMask(o),await Bm(2),this.disposed||n!==this.rebuildToken))return;this.index.rebuild(s),this.state.hoverHighlightMode=s.hoverHighlightMode,this.state.labelVisibility=s.labelVisibility,this.state.hiddenLegendItems=s.hiddenLegendItems.slice(),this.state.showLinkOverlay=s.showLinkOverlay||!this.state.hiddenLegendItems.includes("link"),this.state.pinNeedsHoverLinks=this.pinnedPathsNeedHoverLinks(),this.state.selectedNodeId=this.selectedNodeId,this.state.selectedLink=this.selectedLink;let a=this.shouldPreserveView(t)?this.renderer?.getView():null,l=a?this.graph?.rootId??this.state.rootPath??Pe:null,c=l!==null?this.layout?.positions.get(l)??this.layout?.positions.get(Pe)??null:null,h=this.index.buildVisibleGraph({...this.state}),d=this.index.buildVisibleGraph(this.legendNeutralLayoutState()),u=new Set(this.state.hiddenLegendItems);this.state.showLinkOverlay||u.add("link");let f=SS(h,u);this.graph=f,this.layout=vm(d,{ringSpacing:mm,nodeSpacing:xm,swirlStrength:s.swirlStrength});let m=this.renderer,x=null;m?.beginRenderBatch();try{if(m?.setTheme(this.resolvedCanvasScheme()),m?.setData(f,this.layout,s.labelVisibility,s.showRingGuides),this.resizeRenderer(!a),a){let g=l!==null?this.layout.positions.get(l)??this.layout.positions.get(Pe)??null:null,p=g&&c?g.x-c.x:0,v=g&&c?g.y-c.y:0;m?.setView(a.centerX+p,a.centerY+v,a.zoom)}this.applyActiveState(),r&&(x=f.rootId)}finally{m?.endRenderBatch()}r&&!this.disposed&&n===this.rebuildToken&&(x!==null?m?.playRevealFromRoot(x,o):m?.clearLoadingMask(!0)),this.renderPanel()}radial(){return this.settings.radial}shouldPreserveView(t){return["legend","link-overlay","metadata"].includes(t)}legendNeutralLayoutState(){return{...this.state,hiddenLegendItems:[],showLinkOverlay:!0}}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",t=>{t instanceof Yt.TFile&&t.extension==="md"&&this.redrawSoon()}))}async waitForStartupReady(){await Promise.race([this.waitForMetadataResolved(),bS(1600)]),await Bm(2)}waitForMetadataResolved(){let t=this.app.metadataCache;return new Promise(n=>{let s=!1;this.registerEvent(t.on("resolved",()=>{s||(s=!0,n())}))})}bindRendererEvents(){let t=this.renderer?.domElement;if(!t)return;let n=h=>{h.preventDefault();let d=this.renderer;if(!d)return;let u=t.getBoundingClientRect(),f=d.screenToWorld(h.clientX-u.left,h.clientY-u.top),m=d.getView(),x=Math.pow(1.45,-h.deltaY/120),g=Math.min(Math.max(m.zoom*x,Ln),Mn),p=f.x-(h.clientX-u.left-u.width/2)/g,v=f.y+(h.clientY-u.top-u.height/2)/g;d.setView(p,v,g)},s=h=>{if(h.button!==0)return;t.focus();let d=this.renderer?.getView();d&&(this.drag={pointerId:h.pointerId,startX:h.clientX,startY:h.clientY,centerX:d.centerX,centerY:d.centerY,moved:!1},t.setPointerCapture?.(h.pointerId))},r=h=>{let d=t.getBoundingClientRect();if(this.drag){let u=this.renderer;if(!u)return;let f=h.clientX-this.drag.startX,m=h.clientY-this.drag.startY;this.drag.moved=this.drag.moved||Math.hypot(f,m)>3;let x=u.getView();u.setView(this.drag.centerX-f/x.zoom,this.drag.centerY+m/x.zoom,x.zoom);return}this.updateHover(h.clientX-d.left,h.clientY-d.top)},o=h=>{let d=this.drag?.moved??!1;if(this.drag=null,t.releasePointerCapture?.(h.pointerId),d)return;let u=t.getBoundingClientRect();this.activateAt(h.clientX-u.left,h.clientY-u.top,h)},a=()=>{this.drag||(this.hoverNodeId=null,this.hoverLink=null,this.applyActiveState())},l=h=>{let d=t.getBoundingClientRect(),u=this.renderer?.hitTest(h.clientX-d.left,h.clientY-d.top,!1,this.hoverTargets().nodes);if(!u?.nodeId||!this.graph)return;let f=this.graph.nodesById.get(u.nodeId);f&&(h.preventDefault(),f.type==="note"?this.openNode(f.id,h):f.type==="folder"&&this.useAsRoot(f.id))},c=h=>{let d=t.getBoundingClientRect(),u=this.renderer?.hitTest(h.clientX-d.left,h.clientY-d.top,!1,this.hoverTargets().nodes);if(!u?.nodeId||!this.graph)return;let f=this.graph.nodesById.get(u.nodeId);f&&(h.preventDefault(),this.showNodeMenu(h,f))};t.addEventListener("wheel",n,{passive:!1}),t.addEventListener("pointerdown",s),t.addEventListener("pointermove",r),t.addEventListener("pointerup",o),t.addEventListener("pointerleave",a),t.addEventListener("dblclick",l),t.addEventListener("contextmenu",c),this.register(()=>{t.removeEventListener("wheel",n),t.removeEventListener("pointerdown",s),t.removeEventListener("pointermove",r),t.removeEventListener("pointerup",o),t.removeEventListener("pointerleave",a),t.removeEventListener("dblclick",l),t.removeEventListener("contextmenu",c)})}updateHover(t,n){let s=this.hoverTargets(),r=this.renderer?.hitTest(t,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(t,n,s){let r=this.hoverTargets(),o=this.renderer?.hitTest(t,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 t=this.resolveActiveState();this.renderer.setActive(t,this.radial().labelVisibility)}resolveActiveState(){if(!this.graph)return nc();let t=this.hoverNodeId??this.selectedNodeId,n=this.hoverLink??this.selectedLink,s=nc();s.activeNodeId=t,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),$s(l))for(let h of[...this.graph.linkEdges,...this.graph.hoverLinkEdges])h.source!==a&&h.target!==a||(s.highlightedEdges.add(h.id),s.relatedNodes.add(h.source),s.relatedNodes.add(h.target),s.labelNodes.add(h.source),s.labelNodes.add(h.target));MS(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(t,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=!!(t||n||this.pinnedPaths.some(a=>a.active)),s.dimOthers=!!(t||n),s}hoverTargets(){let t=os(this.radial().hoverTargetMode);return{nodes:t!=="links",links:t!=="nodes"}}buildPanel(){this.panel=this.contentEl.createDiv({cls:"galaxy-panel mwm-radial-panel mwm-map-panel"}),this.syncThemeClass();let t=this.panel.createDiv({cls:"galaxy-panel-header"});this.statsEl=t.createDiv({cls:"galaxy-panel-stats",text:"Mini World Map"});let n=t.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 t=this.graph;this.panelBody.empty(),this.statsEl&&this.statsEl.setText(this.t("stats.counts",{nodes:t?.nodes.length??0,links:t?.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(t,n,s){let r=this.settings.viewMode===s;t.createEl("button",{cls:r?"is-active":"",text:n}).addEventListener("click",()=>this.onViewMode(s))}renderInspectPage(t){if(!this.graph)return;if(this.selectedLink){this.renderLinkInspect(t,this.selectedLink);return}let n=this.graph.nodesById.get(this.selectedNodeId??this.graph.focusId??this.graph.rootId);if(t.createDiv({cls:"mwm-side-title",text:n?.title??"Mini World Map"}),!n)return;t.createDiv({cls:"mwm-side-path",text:n.path||"/"});let s=t.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=t.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(t,n)}renderLinkInspect(t,n){t.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=t.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=t.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(t,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"]]){t.createDiv({cls:"mwm-side-heading",text:o}),a.length===0&&t.createDiv({cls:"mwm-side-muted",text:this.t("common.none")});for(let c of a){let h=this.index.nodes.get(c[l]);if(!h)continue;t.createEl("button",{cls:"mwm-link-row",text:`${h.title} (${c.weight})`}).addEventListener("click",()=>this.inspectNode(h.id))}}}renderPinsPage(t){let n=t.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=t.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){t.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 h=a.get(c.groupId)??[];h.push(c),a.set(c.groupId,h)}l.length&&this.renderPinGroup(t,null,l);for(let c of this.pinGroups){let h=a.get(c.id)??[];h.length&&this.renderPinGroup(t,c,h)}}renderPinGroup(t,n,s){let r=t.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(t,n){let s=t.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(t){let n=t.createDiv({cls:"galaxy-panel-row"});this.button(n,this.t("common.search"),()=>this.openSearch()),this.button(n,this.t("common.recenter"),()=>this.centerCurrentView()),this.button(n,this.t("common.rebuild"),()=>this.rebuild("manual"));let s=t.createDiv({cls:"galaxy-panel-row"});this.button(s,this.t("view.atlas"),()=>this.resetToAtlas(),this.state.mode==="atlas"),this.button(s,this.t("view.focus"),()=>this.focusActiveNote(),this.state.mode==="focus"),this.button(s,this.t("view.vaultRoot"),()=>this.resetToRoot()),this.select(t,this.t("view.theme"),this.radial().colorScheme,qu(this.settings.language),r=>{this.radial().colorScheme=so(r),this.saveSoon(),this.syncThemeClass()})}openSearch(){this.index.ready||this.index.rebuild(this.radial());let t=[...this.index.nodes.values()].map(n=>{let s=Math.max(0,(n.linkCount||0)+(n.backlinkCount||0)),r=Math.max(0,n.noteCount||n.descendantCount||0),o=n.path||this.t("3d.card.root"),a=this.searchKindLabel(n),l=n.type==="folder"||n.type==="external"?this.t("search.notes",{count:r}):this.t("3d.searchLinks",{count:s});return{value:n,title:n.title,path:o,detail:`${a} \xB7 ${o} \xB7 ${l}`,rank:s+Math.log2(r+1)*8-n.depth,unresolved:n.type==="unresolved",hideWhenEmpty:n.id===Pe,searchText:[n.title,n.path,n.id]}});new Vs(this.app,t,n=>void this.selectSearchNode(n),this.t("2d.searchPlaceholder")).open()}async selectSearchNode(t){let n=this.index.visualNodeId(t.id)??t.id;this.selectedNodeId=n,this.selectedLink=null,this.hoverNodeId=null,this.hoverLink=null,this.activePanelPage="inspect",this.state.search="",this.state.selectedNodeId=n,this.state.selectedLink=null,this.state.mode==="focus"&&t.type!=="folder"?(this.state.mode="focus",this.state.rootPath=Pe,this.state.focusPath=t.id,await this.queueRebuild("focus")):await this.showSearchNodeInAtlas(t,n),this.centerNode(n)}async showSearchNodeInAtlas(t,n){if(this.state.mode="atlas",this.state.focusPath=null,t.type==="folder"){this.state.rootPath=n,await this.queueRebuild("root");return}if(this.graph?.nodesById.has(n)){this.applyActiveState(),this.renderPanel();return}this.state.rootPath=this.searchAtlasRoot(t,n),await this.queueRebuild("root")}searchAtlasRoot(t,n){let s=this.index.nodes.get(n);if(s?.type==="folder")return s.id;let r=s?.parentId??t.parentId;return r&&this.index.nodes.has(r)?r:Pe}centerCurrentView(){let t=this.graph?.rootId??Pe;this.renderer?.fitToLayout(t)&&(this.needsFit=!1)}centerNode(t){let n=this.renderer?.nodePoint(t),s=this.renderer?.getView();!n||!s||(this.renderer?.setView(n.x,n.y,Math.max(s.zoom,yS)),this.needsFit=!1)}searchKindLabel(t){return t.type==="folder"?this.t("search.folder"):t.type==="unresolved"?this.t("3d.searchUnresolved"):t.type==="external"?this.t("search.external"):this.t("search.note")}renderControlsPage(t){let n=this.radial();this.numberInput(t,this.t("control.depth"),this.state.atlasDepth,1,80,1,o=>{this.state.atlasDepth=o,this.rebuild("depth")}),this.numberInput(t,this.t("control.nodes"),this.state.nodeLimit,200,2e4,100,o=>{this.state.nodeLimit=o,this.rebuild("nodes")}),this.numberInput(t,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(t,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(t,this.t("control.hover"),this.state.hoverHighlightMode,ro(this.settings.language,Xs),o=>{let a=fi(o);this.state.hoverHighlightMode=a,n.hoverHighlightMode=a,this.state.pinNeedsHoverLinks=this.pinnedPathsNeedHoverLinks(),this.saveSoon(),this.rebuild("hover")}),this.select(t,this.t("control.hoverTargets"),n.hoverTargetMode,oo(this.settings.language,qs),o=>{n.hoverTargetMode=os(o),this.clearDisallowedHoverTargets(),this.saveSoon(),this.applyActiveState(),this.renderPanel()}),this.select(t,this.t("control.labels"),n.labelVisibility,ao(this.settings.language,no),o=>{n.labelVisibility=Zs(o),this.state.labelVisibility=n.labelVisibility,this.saveSoon(),this.applyActiveState()}),this.numberInput(t,this.t("control.spin"),n.swirlStrength,0,100,1,o=>{n.swirlStrength=o,this.saveSoon(),this.rebuild("spin")}),this.toggle(t,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(t,this.t("control.outsideLinks"),this.state.showExternalLinks,o=>{this.state.showExternalLinks=o,n.showExternalLinks=o,this.saveSoon(),this.rebuild("external")}),this.select(t,this.t("control.outsideDetail"),this.state.externalDetailMode,Yu(this.settings.language),o=>{this.state.externalDetailMode=bc(o),n.externalDetailMode=this.state.externalDetailMode,this.saveSoon(),this.rebuild("external-mode")}),this.numberInput(t,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(t)}renderDefaultsPage(t){let n=this.radial();this.numberInput(t,this.t("control.defaultDepth"),n.atlasDepth,1,80,1,s=>{n.atlasDepth=s,this.state.atlasDepth=s,this.saveSoon()}),this.numberInput(t,this.t("control.defaultNodes"),n.renderNodeLimit,200,2e4,100,s=>{n.renderNodeLimit=s,this.state.nodeLimit=s,this.saveSoon()}),this.numberInput(t,this.t("control.defaultNoteLinks"),n.linkLimit,0,3e4,50,s=>{n.linkLimit=s,this.state.linkLimit=s,this.saveSoon()}),this.toggle(t,this.t("control.unresolvedLinks"),n.includeUnresolvedLinks,s=>{n.includeUnresolvedLinks=s,this.saveSoon(),this.rebuild("unresolved")}),this.textArea(t,this.t("control.ignoredFolders"),n.ignoreFolders.join(` `),s=>{n.ignoreFolders=s.split(` `).map(r=>r.trim()).filter(Boolean),this.saveSoon(),this.rebuild("ignored")})}renderLegend(t){t.createDiv({cls:"mwm-side-heading",text:this.t("control.legend")});let n=new Set(this.radial().hiddenLegendItems);for(let[s,r,o,a]of _c){let l=t.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 h=l.createSpan({cls:"mwm-legend-copy"});h.createSpan({cls:"mwm-legend-label",text:this.t(r)}),h.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(t,n){let s=new Set(this.radial().hiddenLegendItems);n?s.add(t):s.delete(t),this.radial().hiddenLegendItems=[...s],this.state.hiddenLegendItems=[...s]}buildFloatingControls(){let t=this.canvasHost;if(!t)return;let s=t.createDiv({cls:"mwm-floating-controls"}).createEl("button",{cls:"mwm-floating-button",attr:{type:"button",title:this.t("language"),"aria-label":this.t("language")}});(0,Yt.setIcon)(s,"languages"),s.addEventListener("click",r=>{r.preventDefault(),r.stopPropagation(),this.openLanguageMenu(s)})}openLanguageMenu(t){let n=new Yt.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=t.getBoundingClientRect();n.showAtPosition({x:s.right,y:s.bottom})}button(t,n,s,r=!1){let o=t.createEl("button",{cls:r?"is-active":"",text:n});return o.addEventListener("click",s),o}numberInput(t,n,s,r,o,a,l){let c=t.createEl("label",{cls:"mwm-panel-field"});c.createSpan({text:n});let h=c.createEl("input",{attr:{value:String(s),type:"number",min:String(r),max:String(o),step:String(a)}});h.addEventListener("change",()=>l(At(h.value,r,o,s)))}textArea(t,n,s,r){let o=t.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(t,n,s,r,o){let a=t.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(t,n,s,r,o){let a=t.createEl("label",{cls:"mwm-panel-field"});a.createSpan({text:n});let l=a.createEl("select");for(let[c,h]of r)l.createEl("option",{attr:{value:c},text:h});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 Yt.Notice(this.t("pins.selectBeforePin"))}pinNode(t){this.addPin({kind:"node",nodeId:t.id,mode:this.state.hoverHighlightMode,title:t.title,path:t.path||"/"})}pinLink(t){let n=this.graph?.nodesById.get(t.source),s=this.graph?.nodesById.get(t.target);this.addPin({kind:"link",edgeId:t.id,source:t.source,target:t.target,mode:"note-links",title:`${n?.title??t.source} -> ${s?.title??t.target}`,path:`${n?.path??t.source} -> ${s?.path??t.target}`})}addPin(t){let n=t.kind==="node"?`node:${t.nodeId}:${t.mode}`:`link:${t.edgeId??`${t.source}->${t.target}`}`,s={...t,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(t){this.pinnedPaths=this.pinnedPaths.filter(n=>n.id!==t),this.selectedPinIds.delete(t),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 t=this.pinnedPaths.filter(s=>this.selectedPinIds.has(s.id));if(t.length===0){new Yt.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 t)s.groupId=n;this.dropEmptyPinGroups(),this.pinGroupName="",this.selectedPinIds.clear(),this.renderPanel()}removePinGroup(t){this.pinGroups=this.pinGroups.filter(n=>n.id!==t);for(let n of this.pinnedPaths)n.groupId===t&&(n.groupId=null);this.renderPanel()}ungroupPin(t){let n=this.pinnedPaths.find(s=>s.id===t);n&&(n.groupId=null,this.dropEmptyPinGroups(),this.renderPanel())}dropEmptyPinGroups(){let t=new Set(this.pinnedPaths.map(n=>n.groupId).filter(n=>!!n));this.pinGroups=this.pinGroups.filter(n=>t.has(n.id))}togglePinHighlight(t){let n=this.pinnedPaths.find(s=>s.id===t);n&&(n.active=!n.active,this.state.pinNeedsHoverLinks=this.pinnedPathsNeedHoverLinks(),this.applyActiveState(),this.renderPanel())}locatePin(t){let n=t.kind==="node"?t.nodeId:t.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(t){this.activePanelPage="inspect",t.kind==="node"&&t.nodeId?this.inspectNode(t.nodeId):this.selectedLink=this.findGraphEdgeForPin(t),this.applyActiveState(),this.renderPanel()}findGraphEdgeForPin(t){return t.kind!=="link"||!this.graph?null:[...this.graph.linkEdges,...this.graph.hoverLinkEdges].find(n=>n.id===t.edgeId||n.source===t.source&&n.target===t.target)??null}pinnedPathsNeedHoverLinks(){return this.pinnedPaths.some(t=>t.active&&(t.kind==="link"||t.kind==="node"&&$s(t.mode)))}pinKindLabel(t){return t.kind==="link"?this.t("inspect.linkOverlay"):this.t(`hover.${fi(t.mode)}`)}clearDisallowedHoverTargets(){let t=this.hoverTargets();t.nodes||(this.hoverNodeId=null),t.links||(this.hoverLink=null),this.canvasHost?.toggleClass("is-pointing",!!(t.nodes&&this.hoverNodeId||t.links&&this.hoverLink))}inspectNode(t){this.selectedNodeId=t,this.selectedLink=null,this.applyActiveState(),this.renderPanel()}resetToAtlas(){this.state.mode="atlas",this.state.rootPath=this.state.rootPath||Pe,this.state.focusPath=null,this.needsFit=!0,this.rebuild("atlas")}resetToRoot(){this.state.mode="atlas",this.state.rootPath=Pe,this.state.focusPath=null,this.needsFit=!0,this.rebuild("root")}currentRootParentId(){let t=this.graph?.rootId??this.state.rootPath;if(t===Pe)return null;let n=this.graph?.nodesById.get(t)??this.index.nodes.get(t);if(n?.parentId!==void 0&&n.parentId!==null)return n.parentId;let s=t.lastIndexOf("/");return s>=0?t.slice(0,s):Pe}useAsRoot(t){this.state.mode="atlas",this.state.rootPath=t,this.state.focusPath=null,this.needsFit=!0,this.rebuild("root")}focusActiveNote(){let t=this.selectedNodeId?this.index.nodes.get(this.selectedNodeId):null,n=t?.type==="note"?t.id:this.index.getActiveNotePath();n&&this.focusNote(n)}focusNote(t){this.state.mode="focus",this.state.focusPath=t,this.state.rootPath=Pe,this.needsFit=!0,this.rebuild("focus")}showNodeMenu(t,n){let s=new Yt.Menu;n.type==="note"&&(s.addItem(r=>r.setTitle(this.t("context.openNote")).setIcon("file-text").onClick(()=>void this.openNode(n.id,t))),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,t)))),s.addItem(r=>r.setTitle(this.t("context.pinPath")).setIcon("pin").onClick(()=>this.pinNode(n))),s.showAtMouseEvent(t)}async openNode(t,n){let s=this.app.vault.getAbstractFileByPath(t);if(!(s instanceof Yt.TFile))return;let r=n&&(n.metaKey||n.ctrlKey)?"split":"tab";await this.app.workspace.openLinkText(s.path,"",r,{active:!0})}syncThemeClass(){let t=this.resolvedCanvasScheme(),n=this.resolvedPanelScheme(),s=Ll(t,Cu(t));this.contentEl.style.setProperty("--mwm-radial-bg",s),this.contentEl.toggleClass("is-day-scheme",t==="day"),this.contentEl.toggleClass("is-night-scheme",t==="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 r=this.renderer;r?.beginRenderBatch();try{(r?.setTheme(t,s)??!1)&&this.graph&&this.layout&&r?.setData(this.graph,this.layout,this.radial().labelVisibility,this.radial().showRingGuides)}finally{r?.endRenderBatch()}}resolvedCanvasScheme(){let t=so(this.radial().colorScheme);return t==="day"||t==="night"?t:activeDocument.body.hasClass("theme-dark")?"night":"day"}resolvedPanelScheme(){return activeDocument.body.hasClass("theme-dark")?"night":"day"}t(t,n={}){return Le(this.settings.language,t,n)}dispose(){this.unload(),this.renderer?.dispose(),this.renderer=null,this.contentEl.removeClass("mwm-radial-mode"),this.contentEl.empty()}};function bS(i){return new Promise(e=>{window.setTimeout(e,i)})}function Bm(i){return new Promise(e=>{let t=!1,n=0,s=()=>{t||(t=!0,window.clearTimeout(n),e())};n=window.setTimeout(s,96);let r=Math.max(0,i),o=()=>{if(!t){if(r--,r<=0){s();return}window.requestAnimationFrame(o)}};r<=0?s():window.requestAnimationFrame(o)})}function MS(i,e,t,n){if(t==="none"||t==="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(t==="hierarchy-parents"||t==="hierarchy-parents-direct"||t==="hierarchy-all"){let a=s.get(e);for(;a;)o(a),a=s.get(a.source)}if(t==="hierarchy-direct-children"||t==="hierarchy-parents-direct"||t==="hierarchy-all")for(let a of r.get(e)??[])o(a);if(t==="hierarchy-descendants"||t==="hierarchy-all"){let a=[...r.get(e)??[]];for(;a.length>0;){let l=a.pop();l&&(o(l),a.push(...r.get(l.target)??[]))}}}function SS(i,e){if(e.size===0)return i;let t=d=>!(d.id===i.rootId&&e.has("root")||d.externalProxy&&e.has("outside-file")||d.type==="external"&&!d.externalProxy&&e.has("outside")||d.type==="unresolved"&&e.has("missing")||d.type==="folder"&&d.representativeFile&&e.has("folder-meta")||d.type==="folder"&&!d.representativeFile&&e.has("folder")||d.type==="note"&&e.has("file")),n=i.nodes.filter(t),s=new Set(n.map(d=>d.id)),r=d=>s.has(d.source)&&s.has(d.target),o=e.has("tree")?[]:i.hierarchyEdges.filter(r),a=d=>!r(d)||d.externalCount&&e.has("outside-link")||d.unresolvedCount&&e.has("dashed-link")?!1:!!d.externalCount||!e.has("link"),l=d=>!(!r(d)||d.externalCount&&e.has("outside-link")||d.unresolvedCount&&e.has("dashed-link")),c=i.linkEdges.filter(a),h=i.hoverLinkEdges.filter(l);return{...i,nodes:n,nodesById:new Map(n.map(d=>[d.id,d])),hierarchyEdges:o,linkEdges:c,hoverLinkEdges:h}}var Bi=class extends dc.ItemView{constructor(t,n){super(t);this.host=n;this.navigation=!0;this.controller=null;this.initRetryTimer=0;this.initRetryCount=0;this.bootStatusEl=null;this.bootStatusTimer=0}getViewType(){return Yn}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(t){if(this.host.settings.viewMode!==t){this.host.setViewMode(t);return}this.rebuild()}tryInit(){if(this.controller)return;let{clientWidth:t,clientHeight:n}=this.contentEl;if(t<10||n<10){this.showBootStatus(`Mini World Map waiting for pane size (${Math.round(t)} 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 Xl(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 hc(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(t){t.start().then(()=>{this.controller===t&&(this.showBootStatus(`Mini World Map ${this.host.settings.viewMode==="map3d"?"3D":"2D"} map started: ${t.counts.nodes} nodes, ${t.counts.links} links`),this.clearBootStatus(12e3))}).catch(n=>{this.controller===t&&(console.error("[Mini World Map] failed to start view",n),new dc.Notice("Mini World Map failed to load. Check the developer console for details."),t.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 t=Math.min(600,32+this.initRetryCount*48);this.initRetryCount++,this.initRetryTimer=window.setTimeout(()=>{this.initRetryTimer=0,this.tryInit()},t)}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(t){this.bootStatusTimer&&(window.clearTimeout(this.bootStatusTimer),this.bootStatusTimer=0),this.bootStatusEl||(this.bootStatusEl=this.contentEl.createDiv({cls:"mwm-boot-status"})),this.bootStatusEl.setText(t)}clearBootStatus(t=0){if(this.bootStatusTimer&&(window.clearTimeout(this.bootStatusTimer),this.bootStatusTimer=0),t>0){this.bootStatusTimer=window.setTimeout(()=>{this.bootStatusTimer=0,this.clearBootStatus()},t);return}this.bootStatusEl?.remove(),this.bootStatusEl=null}};var fc=class extends ns.Plugin{constructor(){super(...arguments);this.settings=yc(null)}async onload(){console.info("[Mini World Map] loading");let t=await this.loadData();this.settings=Wu(yc(t),t,this.app.vault.configDir),this.registerView(Yn,n=>new Bi(n,this)),this.addRibbonIcon("network","Open Mini World Map",()=>{this.activateView()}),this.addCommand({id:"open-map",name:"Open map",callback:()=>void this.activateView()}),this.addCommand({id:"toggle-render-mode",name:"Toggle render mode",callback:()=>{this.setViewMode(this.settings.viewMode==="radial2d"?"map3d":"radial2d"),this.activateView()}}),this.addCommand({id:"rebuild-index",name:"Rebuild index",callback:()=>{let n=!1;for(let s of this.app.workspace.getLeavesOfType(Yn)){let r=s.view;r instanceof Bi&&"rebuild"in(r.controller??{})&&(r.controller.rebuild?.("manual"),n=!0)}new ns.Notice(Le(this.settings.language,n?"notice.rebuilt":"notice.openToBuild"))}}),this.addCommand({id:"search-3d",name:"Search map",callback:()=>{this.activateView().then(n=>{let s=n?.controller;s&&"openSearch"in s&&typeof s.openSearch=="function"?s.openSearch():new ns.Notice(Le(this.settings.language,"notice.openToSearch"))})}}),this.addSettingTab(new Du(this.app,this))}async saveSettings(){await this.saveData(this.settings)}setViewMode(t){this.settings.viewMode=io(t),this.saveSettings();for(let n of this.app.workspace.getLeavesOfType(Yn)){let s=n.view;s instanceof Bi&&s.switchMode(this.settings.viewMode)}}setLanguage(t){this.settings.language=rs(t),this.saveSettings();for(let n of this.app.workspace.getLeavesOfType(Yn)){let s=n.view;s instanceof Bi&&s.switchMode(this.settings.viewMode)}}async activateView(){let{workspace:t}=this.app,n=t.getLeavesOfType(Yn)[0]??null;return n||(n=t.getLeaf(!0),await n.setViewState({type:Yn,active:!0})),n.isDeferred&&await n.loadIfDeferred(),await t.revealLeaf(n),n.view instanceof Bi?n.view:null}},Du=class extends ns.PluginSettingTab{constructor(t,n){super(t,n);this.plugin=n}getSettingDefinitions(){let t=this.plugin.settings.radial,n=this.plugin.settings.language;return[{type:"group",heading:Le(n,"settings.title"),items:[this.renderSetting(Le(n,"language"),Le(n,"settings.languageDesc"),s=>{s.addDropdown(r=>{for(let[o,a]of as(n))r.addOption(o,a);r.setValue(this.plugin.settings.language).onChange(async o=>{this.plugin.settings.language=rs(o),await this.plugin.saveSettings(),this.update()})})}),this.renderSetting(Le(n,"settings.defaultMode"),Le(n,"settings.defaultModeDesc"),s=>{s.addDropdown(r=>r.addOption("radial2d",pi(n,"radial2d")).addOption("map3d",pi(n,"map3d")).setValue(this.plugin.settings.viewMode).onChange(async o=>{this.plugin.settings.viewMode=io(o),await this.plugin.saveSettings()}))}),this.renderSetting(Le(n,"control.defaultDepth"),Le(n,"settings.depthDesc"),s=>{s.addSlider(r=>r.setLimits(1,20,1).setValue(t.atlasDepth).onChange(async o=>{t.atlasDepth=At(o,1,80,kt.atlasDepth),await this.plugin.saveSettings()}))}),this.renderSetting(Le(n,"control.defaultNodes"),Le(n,"settings.nodeLimitDesc"),s=>{s.addText(r=>r.setPlaceholder(String(kt.renderNodeLimit)).setValue(String(t.renderNodeLimit)).onChange(async o=>{t.renderNodeLimit=At(o,200,2e4,kt.renderNodeLimit),await this.plugin.saveSettings()}))}),this.renderSetting(Le(n,"control.defaultNoteLinks"),Le(n,"settings.linkLimitDesc"),s=>{s.addText(r=>r.setPlaceholder(String(kt.linkLimit)).setValue(String(t.linkLimit)).onChange(async o=>{t.linkLimit=At(o,0,3e4,kt.linkLimit),await this.plugin.saveSettings()}))}),this.renderSetting(Le(n,"control.showNoteLinks"),Le(n,"settings.showLinksDesc"),s=>{s.addToggle(r=>r.setValue(t.showLinkOverlay&&!t.hiddenLegendItems.includes("link")).onChange(async o=>{t.showLinkOverlay=o;let a=new Set(t.hiddenLegendItems);o?a.delete("link"):a.add("link"),t.hiddenLegendItems=[...a],await this.plugin.saveSettings()}))}),this.renderSetting(Le(n,"control.hover"),Le(n,"settings.hoverDesc"),s=>{s.addDropdown(r=>{for(let[o,a]of ro(n,Xs))r.addOption(o,a);r.setValue(t.hoverHighlightMode).onChange(async o=>{t.hoverHighlightMode=fi(o),await this.plugin.saveSettings()})})}),this.renderSetting(Le(n,"control.hoverTargets"),Le(n,"settings.hoverTargetsDesc"),s=>{s.addDropdown(r=>{for(let[o,a]of oo(n,qs))r.addOption(o,a);r.setValue(t.hoverTargetMode).onChange(async o=>{t.hoverTargetMode=os(o),await this.plugin.saveSettings()})})}),this.renderSetting(Le(n,"control.labels"),Le(n,"settings.labelsDesc"),s=>{s.addDropdown(r=>{for(let[o,a]of ao(n,no))r.addOption(o,a);r.setValue(t.labelVisibility).onChange(async o=>{t.labelVisibility=Zs(o),await this.plugin.saveSettings()})})}),this.renderSetting(Le(n,"control.spin"),Le(n,"settings.spinDesc"),s=>{s.addSlider(r=>r.setLimits(0,100,1).setValue(t.swirlStrength).onChange(async o=>{t.swirlStrength=At(o,0,100,kt.swirlStrength),await this.plugin.saveSettings()}))}),this.renderSetting(Le(n,"control.unresolvedLinks"),Le(n,"settings.unresolvedDesc"),s=>{s.addToggle(r=>r.setValue(t.includeUnresolvedLinks).onChange(async o=>{t.includeUnresolvedLinks=o,await this.plugin.saveSettings()}))}),this.renderSetting(Le(n,"control.ignoredFolders"),Le(n,"settings.ignoredDesc"),s=>{s.addTextArea(r=>r.setValue(t.ignoreFolders.join(` `)).onChange(async o=>{t.ignoreFolders=o.split(` `).map(a=>a.trim()).filter(Boolean),await this.plugin.saveSettings()}))})]}]}renderSetting(t,n,s){return{name:t,desc:n,render:s}}}; /*! Bundled license information: three/build/three.core.js: three/build/three.module.js: (** * @license * Copyright 2010-2026 Three.js Authors * SPDX-License-Identifier: MIT *) */