mirror of
https://github.com/miro0o/miniWorldMap.git
synced 2026-07-22 07:46:00 +00:00
4376 lines
793 KiB
JavaScript
4376 lines
793 KiB
JavaScript
/*
|
|
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
|
if you want to view the source, please visit the github repository of this plugin
|
|
*/
|
|
|
|
"use strict";var xc=Object.defineProperty;var Zm=Object.getOwnPropertyDescriptor;var $m=Object.getOwnPropertyNames;var Km=Object.prototype.hasOwnProperty;var Jm=(i,e)=>{for(var t in e)xc(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&&xc(i,s,{get:()=>e[s],enumerable:!(n=Zm(e,s))||n.enumerable});return i};var Qm=i=>jm(xc({},"__esModule",{value:!0}),i);var wS={};Jm(wS,{default:()=>pc});module.exports=Qm(wS);var is=require("obsidian");var Yn="mini-world-map-view";var Wi=2.2,vc=Wi*6;var io={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},_c=8e-4;var qs=[["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"]],so=[["auto","Auto"],["hover","Hover only"]],Ys=[["nodes","Nodes"],["links","Links"],["both","Nodes + links"]],yc=[["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 bc(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:os(e.language??e.locale??e.lang),viewMode:ro(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(yc.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:Mc(e.externalDetailMode),colorScheme:oo(e.colorScheme),labelVisibility:$s(e.labelVisibility),hoverHighlightMode:pi(s),hoverTargetMode:as(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 Zs(i){return{charge:-i.repel,linkDistance:i.linkDistance,linkStrength:i.linkStrength,centerPull:i.centerPull,flatten:i.flatten,velocityDecay:.6}}function ro(i){return i==="map3d"||i==="radial2d"?i:Hu.viewMode}function os(i){return i==="zh"?"zh":Hu.language}function oo(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 $s(i){return i==="hover"?"hover":kt.labelVisibility}function pi(i){return qs.some(([e])=>e===i)?i:kt.hoverHighlightMode}function as(i){return Ys.some(([e])=>e===i)?i:kt.hoverTargetMode}function Ks(i){return pi(i)==="note-links"}function Mc(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.completeMap":{en:"Complete map",zh:"\u5B8C\u6574\u5730\u56FE"},"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 mi(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 ls(i){return rg.map(([e,t])=>[e,t])}function ao(i,e){return e.map(([t])=>[t,Le(i,`hover.${t}`)])}function lo(i,e){return e.map(([t])=>[t,Le(i,`hoverTarget.${t}`)])}function co(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 fc=require("obsidian");var yt=require("obsidian");var va="184",Cn={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2};var _d=0,eh=1,yd=2;var br=1,bd=2,Ps=3,ni=0,$t=1,Hn=2,_n=0,Ki=1,Mr=2,th=3,nh=4,Md=5;var Si=100,Sd=101,wd=102,Ed=103,Td=104,Ad=200,Cd=201,Rd=202,Pd=203,ko=204,Oo=205,Id=206,Ld=207,Nd=208,Dd=209,Fd=210,kd=211,Od=212,Ud=213,Bd=214,Uo=0,Bo=1,zo=2,Ji=3,Vo=4,Go=5,Ho=6,Wo=7,ih=0,zd=1,Vd=2,hn=0,Sr=1,wr=2,Er=3,Ii=4,Tr=5,Ar=6,Cr=7;var sh=300,Li=301,Qi=302,_a=303,ya=304,Rr=306,Xo=1e3,Un=1001,qo=1002,Lt=1003,Gd=1004;var Pr=1005;var Ut=1006,ba=1007;var Ni=1008;var un=1009,rh=1010,oh=1011,Is=1012,Ma=1013,Rn=1014,Pn=1015,Xt=1016,Sa=1017,wa=1018,Ls=1020,ah=35902,lh=35899,ch=1021,hh=1022,yn=1023,Bn=1026,Di=1027,uh=1028,Ea=1029,Fi=1030,Ta=1031;var Aa=1033,Ir=33776,Lr=33777,Nr=33778,Dr=33779,Ca=35840,Ra=35841,Pa=35842,Ia=35843,La=36196,Na=37492,Da=37496,Fa=37488,ka=37489,Fr=37490,Oa=37491,Ua=37808,Ba=37809,za=37810,Va=37811,Ga=37812,Ha=37813,Wa=37814,Xa=37815,qa=37816,Ya=37817,Za=37818,$a=37819,Ka=37820,Ja=37821,ja=36492,Qa=36494,el=36495,tl=36283,nl=36284,kr=36285,il=36286;var sr=2300,Yo=2301,Fo=2302,Xc=2303,qc=2400,Yc=2401,Zc=2402;var Hd=3200;var dh=0,Wd=1,li="",ln="srgb",rr="srgb-linear",or="linear",je="srgb";var $i=7680;var $c=519,Xd=512,qd=513,Yd=514,sl=515,Zd=516,$d=517,rl=518,Kd=519,Kc=35044;var fh="300 es",Tn=2e3,ar=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 lr(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Jd(){let i=lr("canvas");return i.style.display="block",i}var Zu={},Ss=null;function ph(...i){let e="THREE."+i.shift();Ss?Ss("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(Ss)Ss("warn",e,...i);else{let t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function Pe(...i){i=jd(i);let e="THREE."+i.shift();if(Ss)Ss("error",e,...i);else{let t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function Zo(...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={[Uo]:Bo,[zo]:Ho,[Vo]:Wo,[Ji]:Go,[Bo]:Uo,[Ho]:zo,[Wo]:Vo,[Go]:Ji},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<o;r++)s[r].call(this,e);e.target=null}}},Vt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],$u=1234567,nr=Math.PI/180,ws=180/Math.PI;function Ns(){let i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Vt[i&255]+Vt[i>>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 mh(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 ir(i,e,t){return(1-t)*i+t*e}function hg(i,e,t,n){return ir(i,e,1-Math.exp(-t*n))}function ug(i,e=1){return e-Math.abs(mh(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*nr}function _g(i){return i*ws}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 bs(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 ol={DEG2RAD:nr,RAD2DEG:ws,generateUUID:Ns,clamp:He,euclideanModulo:mh,mapLinear:lg,inverseLerp:cg,lerp:ir,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:bs},yh=class yh{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}};yh.prototype.isVector2=!0;var Ae=yh,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}},bh=class bh{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 Sc.copy(this).projectOnVector(e),this.sub(Sc)}reflect(e){return this.sub(Sc.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}};bh.prototype.isVector3=!0;var N=bh,Sc=new N,Ku=new vn,Mh=class Mh{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(wc.makeScale(e,t)),this}rotate(e){return this.premultiply(wc.makeRotation(-e)),this}translate(e,t){return this.premultiply(wc.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)}};Mh.prototype.isMatrix3=!0;var De=Mh,wc=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:rr,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=Ms(s.r),s.g=Ms(s.g),s.b=Ms(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?or: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 Zo("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Zo("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({[rr]:{primaries:e,whitePoint:n,transfer:or,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 Ms(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var cs,$o=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{cs===void 0&&(cs=lr("canvas")),cs.width=e.width,cs.height=e.height;let s=cs.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=cs}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=lr("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;o<r.length;o++)r[o]=ti(r[o]/255)*255;return n.putImageData(s,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(ti(t[n]/255)*255):t[n]=ti(t[n]);return{data:t,width:e.width,height:e.height}}else return Te("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Eg=0,Es=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Eg++}),this.uuid=Ns(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let o=0,a=s.length;o<a;o++)s[o].isDataTexture?r.push(Ec(s[o].image)):r.push(Ec(s[o]))}else r=Ec(s);n.url=r}return t||(e.images[this.uuid]=n),n}};function Ec(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?$o.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(Te("Texture: Unable to serialize Texture."),{})}var Tg=0,Tc=new N,jt=class i extends An{constructor(e=i.DEFAULT_IMAGE,t=i.DEFAULT_MAPPING,n=Un,s=Un,r=Ut,o=Ni,a=yn,l=un,c=i.DEFAULT_ANISOTROPY,h=li){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Tg++}),this.uuid=Ns(),this.name="",this.source=new Es(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new Ae(0,0),this.repeat=new Ae(1,1),this.center=new Ae(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new De,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Tc).x}get height(){return this.source.getSize(Tc).y}get depth(){return this.source.getSize(Tc).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!==sh)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Xo:e.x=e.x-Math.floor(e.x);break;case Un:e.x=e.x<0?0:1;break;case qo: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 Xo:e.y=e.y-Math.floor(e.y);break;case Un:e.y=e.y<0?0:1;break;case qo: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=sh;jt.DEFAULT_ANISOTROPY=1;var Sh=class Sh{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}};Sh.prototype.isVector4=!0;var vt=Sh,Ko=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;a<o;a++)this.textures[a]=r.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){let t={minFilter:Ut,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=e,this.textures[s].image.height=t,this.textures[s].image.depth=n,this.textures[s].isData3DTexture!==!0&&(this.textures[s].isArrayTexture=this.textures[s].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let s=Object.assign({},e.textures[t].image);this.textures[t].source=new Es(s)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this.multiview=e.multiview,this}dispose(){this.dispatchEvent({type:"dispose"})}},Ct=class extends Ko{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},cr=class extends jt{constructor(e=null,t=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=Lt,this.minFilter=Lt,this.wrapR=Un,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}};var Jo=class extends jt{constructor(e=null,t=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=Lt,this.minFilter=Lt,this.wrapR=Un,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var xa=class xa{constructor(e,t,n,s,r,o,a,l,c,h,d,u,f,m,x,g){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,o,a,l,c,h,d,u,f,m,x,g)}set(e,t,n,s,r,o,a,l,c,h,d,u,f,m,x,g){let p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=s,p[1]=r,p[5]=o,p[9]=a,p[13]=l,p[2]=c,p[6]=h,p[10]=d,p[14]=u,p[3]=f,p[7]=m,p[11]=x,p[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new xa().fromArray(this.elements)}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],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();let t=this.elements,n=e.elements,s=1/hs.setFromMatrixColumn(e,0).length(),r=1/hs.setFromMatrixColumn(e,1).length(),o=1/hs.setFromMatrixColumn(e,2).length();return t[0]=n[0]*s,t[1]=n[1]*s,t[2]=n[2]*s,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,s=e.y,r=e.z,o=Math.cos(n),a=Math.sin(n),l=Math.cos(s),c=Math.sin(s),h=Math.cos(r),d=Math.sin(r);if(e.order==="XYZ"){let u=o*h,f=o*d,m=a*h,x=a*d;t[0]=l*h,t[4]=-l*d,t[8]=c,t[1]=f+m*c,t[5]=u-x*c,t[9]=-a*l,t[2]=x-u*c,t[6]=m+f*c,t[10]=o*l}else if(e.order==="YXZ"){let u=l*h,f=l*d,m=c*h,x=c*d;t[0]=u+x*a,t[4]=m*a-f,t[8]=o*c,t[1]=o*d,t[5]=o*h,t[9]=-a,t[2]=f*a-m,t[6]=x+u*a,t[10]=o*l}else if(e.order==="ZXY"){let u=l*h,f=l*d,m=c*h,x=c*d;t[0]=u-x*a,t[4]=-o*d,t[8]=m+f*a,t[1]=f+m*a,t[5]=o*h,t[9]=x-u*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){let u=o*h,f=o*d,m=a*h,x=a*d;t[0]=l*h,t[4]=m*c-f,t[8]=u*c+x,t[1]=l*d,t[5]=x*c+u,t[9]=f*c-m,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){let u=o*l,f=o*c,m=a*l,x=a*c;t[0]=l*h,t[4]=x-u*d,t[8]=m*d+f,t[1]=d,t[5]=o*h,t[9]=-a*h,t[2]=-c*h,t[6]=f*d+m,t[10]=u-x*d}else if(e.order==="XZY"){let u=o*l,f=o*c,m=a*l,x=a*c;t[0]=l*h,t[4]=-d,t[8]=c*h,t[1]=u*d+x,t[5]=o*h,t[9]=f*d-m,t[2]=m*d-f,t[6]=a*h,t[10]=x*d+u}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Ag,e,Cg)}lookAt(e,t,n){let s=this.elements;return on.subVectors(e,t),on.lengthSq()===0&&(on.z=1),on.normalize(),gi.crossVectors(n,on),gi.lengthSq()===0&&(Math.abs(n.z)===1?on.x+=1e-4:on.z+=1e-4,on.normalize(),gi.crossVectors(n,on)),gi.normalize(),ho.crossVectors(on,gi),s[0]=gi.x,s[4]=ho.x,s[8]=on.x,s[1]=gi.y,s[5]=ho.y,s[9]=on.y,s[2]=gi.z,s[6]=ho.z,s[10]=on.z,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[4],l=n[8],c=n[12],h=n[1],d=n[5],u=n[9],f=n[13],m=n[2],x=n[6],g=n[10],p=n[14],v=n[3],b=n[7],M=n[11],S=n[15],w=s[0],C=s[4],_=s[8],A=s[12],P=s[1],R=s[5],I=s[9],H=s[13],W=s[2],F=s[6],O=s[10],U=s[14],J=s[3],ee=s[7],le=s[11],ye=s[15];return r[0]=o*w+a*P+l*W+c*J,r[4]=o*C+a*R+l*F+c*ee,r[8]=o*_+a*I+l*O+c*le,r[12]=o*A+a*H+l*U+c*ye,r[1]=h*w+d*P+u*W+f*J,r[5]=h*C+d*R+u*F+f*ee,r[9]=h*_+d*I+u*O+f*le,r[13]=h*A+d*H+u*U+f*ye,r[2]=m*w+x*P+g*W+p*J,r[6]=m*C+x*R+g*F+p*ee,r[10]=m*_+x*I+g*O+p*le,r[14]=m*A+x*H+g*U+p*ye,r[3]=v*w+b*P+M*W+S*J,r[7]=v*C+b*R+M*F+S*ee,r[11]=v*_+b*I+M*O+S*le,r[15]=v*A+b*H+M*U+S*ye,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],s=e[8],r=e[12],o=e[1],a=e[5],l=e[9],c=e[13],h=e[2],d=e[6],u=e[10],f=e[14],m=e[3],x=e[7],g=e[11],p=e[15],v=l*f-c*u,b=a*f-c*d,M=a*u-l*d,S=o*f-c*h,w=o*u-l*h,C=o*d-a*h;return t*(x*v-g*b+p*M)-n*(m*v-g*S+p*w)+s*(m*b-x*S+p*C)-r*(m*M-x*w+g*C)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=n),this}invert(){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=e[9],u=e[10],f=e[11],m=e[12],x=e[13],g=e[14],p=e[15],v=t*a-n*o,b=t*l-s*o,M=t*c-r*o,S=n*l-s*a,w=n*c-r*a,C=s*c-r*l,_=h*x-d*m,A=h*g-u*m,P=h*p-f*m,R=d*g-u*x,I=d*p-f*x,H=u*p-f*g,W=v*H-b*I+M*R+S*P-w*A+C*_;if(W===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let F=1/W;return e[0]=(a*H-l*I+c*R)*F,e[1]=(s*I-n*H-r*R)*F,e[2]=(x*C-g*w+p*S)*F,e[3]=(u*w-d*C-f*S)*F,e[4]=(l*P-o*H-c*A)*F,e[5]=(t*H-s*P+r*A)*F,e[6]=(g*M-m*C-p*b)*F,e[7]=(h*C-u*M+f*b)*F,e[8]=(o*I-a*P+c*_)*F,e[9]=(n*P-t*I-r*_)*F,e[10]=(m*w-x*M+p*v)*F,e[11]=(d*M-h*w-f*v)*F,e[12]=(a*A-o*R-l*_)*F,e[13]=(t*R-n*A+s*_)*F,e[14]=(x*b-m*S-g*v)*F,e[15]=(h*S-d*b+u*v)*F,this}scale(e){let t=this.elements,n=e.x,s=e.y,r=e.z;return t[0]*=n,t[4]*=s,t[8]*=r,t[1]*=n,t[5]*=s,t[9]*=r,t[2]*=n,t[6]*=s,t[10]*=r,t[3]*=n,t[7]*=s,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,s))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),s=Math.sin(t),r=1-n,o=e.x,a=e.y,l=e.z,c=r*o,h=r*a;return this.set(c*o+n,c*a-s*l,c*l+s*a,0,c*a+s*l,h*a+n,h*l-s*o,0,c*l-s*a,h*l+s*o,r*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,s,r,o){return this.set(1,n,r,0,e,1,o,0,t,s,1,0,0,0,0,1),this}compose(e,t,n){let s=this.elements,r=t._x,o=t._y,a=t._z,l=t._w,c=r+r,h=o+o,d=a+a,u=r*c,f=r*h,m=r*d,x=o*h,g=o*d,p=a*d,v=l*c,b=l*h,M=l*d,S=n.x,w=n.y,C=n.z;return s[0]=(1-(x+p))*S,s[1]=(f+M)*S,s[2]=(m-b)*S,s[3]=0,s[4]=(f-M)*w,s[5]=(1-(u+p))*w,s[6]=(g+v)*w,s[7]=0,s[8]=(m+b)*C,s[9]=(g-v)*C,s[10]=(1-(u+x))*C,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,n){let s=this.elements;e.x=s[12],e.y=s[13],e.z=s[14];let r=this.determinant();if(r===0)return n.set(1,1,1),t.identity(),this;let o=hs.set(s[0],s[1],s[2]).length(),a=hs.set(s[4],s[5],s[6]).length(),l=hs.set(s[8],s[9],s[10]).length();r<0&&(o=-o),Sn.copy(this);let c=1/o,h=1/a,d=1/l;return Sn.elements[0]*=c,Sn.elements[1]*=c,Sn.elements[2]*=c,Sn.elements[4]*=h,Sn.elements[5]*=h,Sn.elements[6]*=h,Sn.elements[8]*=d,Sn.elements[9]*=d,Sn.elements[10]*=d,t.setFromRotationMatrix(Sn),n.x=o,n.y=a,n.z=l,this}makePerspective(e,t,n,s,r,o,a=Tn,l=!1){let c=this.elements,h=2*r/(t-e),d=2*r/(n-s),u=(t+e)/(t-e),f=(n+s)/(n-s),m,x;if(l)m=r/(o-r),x=o*r/(o-r);else if(a===Tn)m=-(o+r)/(o-r),x=-2*o*r/(o-r);else if(a===ar)m=-o/(o-r),x=-o*r/(o-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=u,c[12]=0,c[1]=0,c[5]=d,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,s,r,o,a=Tn,l=!1){let c=this.elements,h=2/(t-e),d=2/(n-s),u=-(t+e)/(t-e),f=-(n+s)/(n-s),m,x;if(l)m=1/(o-r),x=o/(o-r);else if(a===Tn)m=-2/(o-r),x=-(o+r)/(o-r);else if(a===ar)m=-1/(o-r),x=-r/(o-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=0,c[12]=u,c[1]=0,c[5]=d,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=m,c[14]=x,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let s=0;s<16;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){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[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}};xa.prototype.isMatrix4=!0;var xt=xa,hs=new N,Sn=new xt,Ag=new N(0,0,0),Cg=new N(1,1,1),gi=new N,ho=new N,on=new N,Qu=new xt,ed=new vn,wi=class i{constructor(e=0,t=0,n=0,s=i.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=s}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,s=this._order){return this._x=e,this._y=t,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let s=e.elements,r=s[0],o=s[4],a=s[8],l=s[1],c=s[5],h=s[9],d=s[2],u=s[6],f=s[10];switch(t){case"XYZ":this._y=Math.asin(He(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(u,c),this._z=0);break;case"YXZ":this._x=Math.asin(-He(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-d,r),this._z=0);break;case"ZXY":this._x=Math.asin(He(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-d,f),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-He(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(u,f),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(He(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-d,r)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-He(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(u,c),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-h,f),this._y=0);break;default:Te("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Qu.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Qu,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return ed.setFromEuler(this),this.setFromQuaternion(ed,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};wi.DEFAULT_ORDER="XYZ";var hr=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},Rg=0,td=new N,us=new vn,$n=new xt,uo=new N,Js=new N,Pg=new N,Ig=new vn,nd=new N(1,0,0),id=new N(0,1,0),sd=new N(0,0,1),rd={type:"added"},Lg={type:"removed"},ds={type:"childadded",child:null},Ac={type:"childremoved",child:null},Qt=class i extends An{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Rg++}),this.uuid=Ns(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=i.DEFAULT_UP.clone();let e=new N,t=new wi,n=new vn,s=new N(1,1,1);function r(){n.setFromEuler(t,!1)}function o(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new xt},normalMatrix:{value:new De}}),this.matrix=new xt,this.matrixWorld=new xt,this.matrixAutoUpdate=i.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=i.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new hr,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return us.setFromAxisAngle(e,t),this.quaternion.multiply(us),this}rotateOnWorldAxis(e,t){return us.setFromAxisAngle(e,t),this.quaternion.premultiply(us),this}rotateX(e){return this.rotateOnAxis(nd,e)}rotateY(e){return this.rotateOnAxis(id,e)}rotateZ(e){return this.rotateOnAxis(sd,e)}translateOnAxis(e,t){return td.copy(e).applyQuaternion(this.quaternion),this.position.add(td.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(nd,e)}translateY(e){return this.translateOnAxis(id,e)}translateZ(e){return this.translateOnAxis(sd,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4($n.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?uo.copy(e):uo.set(e,t,n);let s=this.parent;this.updateWorldMatrix(!0,!1),Js.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?$n.lookAt(Js,uo,this.up):$n.lookAt(uo,Js,this.up),this.quaternion.setFromRotationMatrix($n),s&&($n.extractRotation(s.matrixWorld),us.setFromRotationMatrix($n),this.quaternion.premultiply(us.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Pe("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(rd),ds.child=e,this.dispatchEvent(ds),ds.child=null):Pe("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Lg),Ac.child=e,this.dispatchEvent(Ac),Ac.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),$n.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),$n.multiply(e.parent.matrixWorld)),e.applyMatrix4($n),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(rd),ds.child=e,this.dispatchEvent(ds),ds.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,s=this.children.length;n<s;n++){let o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let s=this.children;for(let r=0,o=s.length;r<o;r++)s[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Js,e,Pg),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Js,Ig,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,n=e.y,s=e.z,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*s,r[13]+=n-r[1]*t-r[5]*n-r[9]*s,r[14]+=s-r[2]*t-r[6]*n-r[10]*s}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){let s=this.children;for(let r=0,o=s.length;r<o;r++)s[r].updateWorldMatrix(!1,!0)}}toJSON(e){let t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});let s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),this.static!==!1&&(s.static=this.static),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.pivot!==null&&(s.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(a=>({...a})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(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;c<h;c++){let d=l[c];r(e.shapes,d)}else r(e.shapes,l)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(r(e.materials,this.material[l]));s.material=a}else s.material=r(e.materials,this.material);if(this.children.length>0){s.children=[];for(let a=0;a<this.children.length;a++)s.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let a=0;a<this.animations.length;a++){let l=this.animations[a];s.animations.push(r(e.animations,l))}}if(t){let a=o(e.geometries),l=o(e.materials),c=o(e.textures),h=o(e.images),d=o(e.shapes),u=o(e.skeletons),f=o(e.animations),m=o(e.nodes);a.length>0&&(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;n<e.children.length;n++){let s=e.children[n];this.add(s.clone())}return this}};Qt.DEFAULT_UP=new N(0,1,0);Qt.DEFAULT_MATRIX_AUTO_UPDATE=!0;Qt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var ei=class extends Qt{constructor(){super(),this.isGroup=!0,this.type="Group"}},Ng={type:"move"},Ts=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ei,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new ei,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new N,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new N),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ei,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new N,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new N,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let s=null,r=null,o=null,a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(let x of e.hand.values()){let g=t.getJointPose(x,n),p=this._getHandJoint(c,x);g!==null&&(p.matrix.fromArray(g.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=g.radius),p.visible=g!==null}let h=c.joints["index-finger-tip"],d=c.joints["thumb-tip"],u=h.position.distanceTo(d.position),f=.02,m=.005;c.inputState.pinching&&u>f+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},xi={h:0,s:0,l:0},fo={h:0,s:0,l:0};function Cc(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=mh(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=Cc(o,r,e+1/3),this.g=Cc(o,r,e),this.b=Cc(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=Ms(e.r),this.g=Ms(e.g),this.b=Ms(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+(s<r?6:0);break;case s:l=(r-n)/d+2;break;case r:l=(n-s)/d+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=Ge.workingColorSpace){return Ge.workingToColorSpace(Gt.copy(this),t),e.r=Gt.r,e.g=Gt.g,e.b=Gt.b,e}getStyle(e=ln){Ge.workingToColorSpace(Gt.copy(this),e);let t=Gt.r,n=Gt.g,s=Gt.b;return e!==ln?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(e,t,n){return this.getHSL(xi),this.setHSL(xi.h+e,xi.s+t,xi.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(xi),e.getHSL(fo);let n=ir(xi.h,fo.h,t),s=ir(xi.s,fo.s,t),r=ir(xi.l,fo.l,t);return this.setHSL(n,s,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,s=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*s,this.g=r[1]*t+r[4]*n+r[7]*s,this.b=r[2]*t+r[5]*n+r[8]*s,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},Gt=new ge;ge.NAMES=tf;var ji=class extends Qt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new wi,this.environmentIntensity=1,this.environmentRotation=new wi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},wn=new N,Kn=new N,Rc=new N,Jn=new N,fs=new N,ps=new N,od=new N,Pc=new N,Ic=new N,Lc=new N,Nc=new vt,Dc=new vt,Fc=new vt,Mi=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),Rc.subVectors(e,t);let o=wn.dot(wn),a=wn.dot(Kn),l=wn.dot(Rc),c=Kn.dot(Kn),h=Kn.dot(Rc),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 Nc.setScalar(0),Dc.setScalar(0),Fc.setScalar(0),Nc.fromBufferAttribute(e,t),Dc.fromBufferAttribute(e,n),Fc.fromBufferAttribute(e,s),o.setScalar(0),o.addScaledVector(Nc,r.x),o.addScaledVector(Dc,r.y),o.addScaledVector(Fc,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;fs.subVectors(s,n),ps.subVectors(r,n),Pc.subVectors(e,n);let l=fs.dot(Pc),c=ps.dot(Pc);if(l<=0&&c<=0)return t.copy(n);Ic.subVectors(e,s);let h=fs.dot(Ic),d=ps.dot(Ic);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(fs,o);Lc.subVectors(e,r);let f=fs.dot(Lc),m=ps.dot(Lc);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(ps,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(fs,o).addScaledVector(ps,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Ei=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<n;t+=3)this.expandByPoint(En.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(En.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=En.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=r.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,En):En.fromBufferAttribute(r,o),En.applyMatrix4(e.matrixWorld),this.expandByPoint(En);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),po.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),po.copy(n.boundingBox)),po.applyMatrix4(e.matrixWorld),this.union(po)}let s=e.children;for(let r=0,o=s.length;r<o;r++)this.expandByObject(s[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,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),mo.subVectors(this.max,js),ms.subVectors(e.a,js),gs.subVectors(e.b,js),xs.subVectors(e.c,js),vi.subVectors(gs,ms),_i.subVectors(xs,gs),Xi.subVectors(ms,xs);let t=[0,-vi.z,vi.y,0,-_i.z,_i.y,0,-Xi.z,Xi.y,vi.z,0,-vi.x,_i.z,0,-_i.x,Xi.z,0,-Xi.x,-vi.y,vi.x,0,-_i.y,_i.x,0,-Xi.y,Xi.x,0];return!kc(t,ms,gs,xs,mo)||(t=[1,0,0,0,1,0,0,0,1],!kc(t,ms,gs,xs,mo))?!1:(go.crossVectors(vi,_i),t=[go.x,go.y,go.z],kc(t,ms,gs,xs,mo))}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,po=new Ei,ms=new N,gs=new N,xs=new N,vi=new N,_i=new N,Xi=new N,js=new N,mo=new N,go=new N,qi=new N;function kc(i,e,t,n,s){for(let r=0,o=i.length-3;r<=o;r+=3){qi.fromArray(i,r);let a=s.x*Math.abs(qi.x)+s.y*Math.abs(qi.y)+s.z*Math.abs(qi.z),l=e.dot(qi),c=t.dot(qi),h=n.dot(qi);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>a)return!1}return!0}var wt=new N,xo=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=Kc,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;s<r;s++)this.array[e+s]=t.array[n+s];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)xo.fromBufferAttribute(this,t),xo.applyMatrix3(e),this.setXY(t,xo.x,xo.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)wt.fromBufferAttribute(this,t),wt.applyMatrix3(e),this.setXYZ(t,wt.x,wt.y,wt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)wt.fromBufferAttribute(this,t),wt.applyMatrix4(e),this.setXYZ(t,wt.x,wt.y,wt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)wt.fromBufferAttribute(this,t),wt.applyNormalMatrix(e),this.setXYZ(t,wt.x,wt.y,wt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)wt.fromBufferAttribute(this,t),wt.transformDirection(e),this.setXYZ(t,wt.x,wt.y,wt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=bs(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Zt(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=bs(t,this.array)),t}setX(e,t){return this.normalized&&(t=Zt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=bs(t,this.array)),t}setY(e,t){return this.normalized&&(t=Zt(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=bs(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Zt(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=bs(t,this.array)),t}setW(e,t){return this.normalized&&(t=Zt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Zt(t,this.array),n=Zt(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,s){return e*=this.itemSize,this.normalized&&(t=Zt(t,this.array),n=Zt(n,this.array),s=Zt(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e*=this.itemSize,this.normalized&&(t=Zt(t,this.array),n=Zt(n,this.array),s=Zt(s,this.array),r=Zt(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Kc&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}};var ur=class extends Ye{constructor(e,t,n){super(new Uint16Array(e),t,n)}};var dr=class extends Ye{constructor(e,t,n){super(new Uint32Array(e),t,n)}};var Ot=class extends Ye{constructor(e,t,n){super(new Float32Array(e),t,n)}},Fg=new Ei,Qs=new N,Oc=new N,Ti=class{constructor(e=new N,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t!==void 0?n.copy(t):Fg.setFromPoints(e).getCenter(n);let s=0;for(let r=0,o=e.length;r<o;r++)s=Math.max(s,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(s),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Qs.subVectors(e,this.center);let t=Qs.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(Qs,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):(Oc.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Qs.copy(e.center).add(Oc)),this.expandByPoint(Qs.copy(e.center).sub(Oc))),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,Uc=new Qt,vs=new N,an=new Ei,er=new Ei,It=new N,ht=class i extends An{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:kg++}),this.uuid=Ns(),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)?dr:ur)(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 Uc.lookAt(e),Uc.updateMatrix(),this.applyMatrix4(Uc.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(vs).negate(),this.translate(vs.x,vs.y,vs.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let s=0,r=e.length;s<r;s++){let o=e[s];n.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Ot(n,3))}else{let n=Math.min(e.length,t.count);for(let s=0;s<n;s++){let r=e[s];t.setXYZ(s,r.x,r.y,r.z||0)}e.length>t.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 Ei);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Pe("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;n<s;n++){let r=t[n];an.setFromBufferAttribute(r),this.morphTargetsRelative?(It.addVectors(this.boundingBox.min,an.min),this.boundingBox.expandByPoint(It),It.addVectors(this.boundingBox.max,an.max),this.boundingBox.expandByPoint(It)):(this.boundingBox.expandByPoint(an.min),this.boundingBox.expandByPoint(an.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Pe('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ti);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Pe("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new N,1/0);return}if(e){let n=this.boundingSphere.center;if(an.setFromBufferAttribute(e),t)for(let r=0,o=t.length;r<o;r++){let a=t[r];er.setFromBufferAttribute(a),this.morphTargetsRelative?(It.addVectors(an.min,er.min),an.expandByPoint(It),It.addVectors(an.max,er.max),an.expandByPoint(It)):(an.expandByPoint(er.min),an.expandByPoint(er.max))}an.getCenter(n);let s=0;for(let r=0,o=e.count;r<o;r++)It.fromBufferAttribute(e,r),s=Math.max(s,n.distanceToSquared(It));if(t)for(let r=0,o=t.length;r<o;r++){let a=t[r],l=this.morphTargetsRelative;for(let c=0,h=a.count;c<h;c++)It.fromBufferAttribute(a,c),l&&(vs.fromBufferAttribute(e,c),It.add(vs)),s=Math.max(s,n.distanceToSquared(It))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&Pe('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Pe("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=t.position,s=t.normal,r=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Ye(new Float32Array(4*n.count),4));let o=this.getAttribute("tangent"),a=[],l=[];for(let _=0;_<n.count;_++)a[_]=new N,l[_]=new N;let c=new N,h=new N,d=new N,u=new Ae,f=new Ae,m=new Ae,x=new N,g=new N;function p(_,A,P){c.fromBufferAttribute(n,_),h.fromBufferAttribute(n,A),d.fromBufferAttribute(n,P),u.fromBufferAttribute(r,_),f.fromBufferAttribute(r,A),m.fromBufferAttribute(r,P),h.sub(c),d.sub(c),f.sub(u),m.sub(u);let R=1/(f.x*m.y-m.x*f.y);isFinite(R)&&(x.copy(h).multiplyScalar(m.y).addScaledVector(d,-f.y).multiplyScalar(R),g.copy(d).multiplyScalar(f.x).addScaledVector(h,-m.x).multiplyScalar(R),a[_].add(x),a[A].add(x),a[P].add(x),l[_].add(g),l[A].add(g),l[P].add(g))}let v=this.groups;v.length===0&&(v=[{start:0,count:e.count}]);for(let _=0,A=v.length;_<A;++_){let P=v[_],R=P.start,I=P.count;for(let H=R,W=R+I;H<W;H+=3)p(e.getX(H+0),e.getX(H+1),e.getX(H+2))}let b=new N,M=new N,S=new N,w=new N;function C(_){S.fromBufferAttribute(s,_),w.copy(S);let A=a[_];b.copy(A),b.sub(S.multiplyScalar(S.dot(A))).normalize(),M.crossVectors(w,A);let R=M.dot(l[_])<0?-1:1;o.setXYZW(_,b.x,b.y,b.z,R)}for(let _=0,A=v.length;_<A;++_){let P=v[_],R=P.start,I=P.count;for(let H=R,W=R+I;H<W;H+=3)C(e.getX(H+0)),C(e.getX(H+1)),C(e.getX(H+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new Ye(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let u=0,f=n.count;u<f;u++)n.setXYZ(u,0,0,0);let s=new N,r=new N,o=new N,a=new N,l=new N,c=new N,h=new N,d=new N;if(e)for(let u=0,f=e.count;u<f;u+=3){let m=e.getX(u+0),x=e.getX(u+1),g=e.getX(u+2);s.fromBufferAttribute(t,m),r.fromBufferAttribute(t,x),o.fromBufferAttribute(t,g),h.subVectors(o,r),d.subVectors(s,r),h.cross(d),a.fromBufferAttribute(n,m),l.fromBufferAttribute(n,x),c.fromBufferAttribute(n,g),a.add(h),l.add(h),c.add(h),n.setXYZ(m,a.x,a.y,a.z),n.setXYZ(x,l.x,l.y,l.z),n.setXYZ(g,c.x,c.y,c.z)}else for(let u=0,f=t.count;u<f;u+=3)s.fromBufferAttribute(t,u+0),r.fromBufferAttribute(t,u+1),o.fromBufferAttribute(t,u+2),h.subVectors(o,r),d.subVectors(s,r),h.cross(d),n.setXYZ(u+0,h.x,h.y,h.z),n.setXYZ(u+1,h.x,h.y,h.z),n.setXYZ(u+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)It.fromBufferAttribute(e,t),It.normalize(),e.setXYZ(t,It.x,It.y,It.z)}toNonIndexed(){function e(a,l){let c=a.array,h=a.itemSize,d=a.normalized,u=new c.constructor(l.length*h),f=0,m=0;for(let x=0,g=l.length;x<g;x++){a.isInterleavedBufferAttribute?f=l[x]*a.data.stride+a.offset:f=l[x]*h;for(let p=0;p<h;p++)u[m++]=c[f++]}return new Ye(u,h,d)}if(this.index===null)return Te("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new i,n=this.index.array,s=this.attributes;for(let a in s){let l=s[a],c=e(l,n);t.setAttribute(a,c)}let r=this.morphAttributes;for(let a in r){let l=[],c=r[a];for(let h=0,d=c.length;h<d;h++){let u=c[h],f=e(u,n);l.push(f)}t.morphAttributes[a]=l}t.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,l=o.length;a<l;a++){let c=o[a];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){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;d<u;d++){let f=c[d];h.push(f.toJSON(e.data))}h.length>0&&(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;u<f;u++)h.push(d[u].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;let o=e.groups;for(let c=0,h=o.length;c<h;c++){let d=o[c];this.addGroup(d.start,d.count,d.materialIndex)}let a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());let l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}};var Og=0,ii=class extends An{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Og++}),this.uuid=Ns(),this.name="",this.type="Material",this.blending=Ki,this.side=ni,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=ko,this.blendDst=Oo,this.blendEquation=Si,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ge(0,0,0),this.blendAlpha=0,this.depthFunc=Ji,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=$c,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=$i,this.stencilZFail=$i,this.stencilZPass=$i,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(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!==Ki&&(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!==ko&&(n.blendSrc=this.blendSrc),this.blendDst!==Oo&&(n.blendDst=this.blendDst),this.blendEquation!==Si&&(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!==Ji&&(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!==$c&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==$i&&(n.stencilFail=this.stencilFail),this.stencilZFail!==$i&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==$i&&(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,Bc=new N,vo=new N,yi=new N,zc=new N,_o=new N,Vc=new N,As=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){Bc.copy(e).add(t).multiplyScalar(.5),vo.copy(t).sub(e).normalize(),yi.copy(this.origin).sub(Bc);let r=e.distanceTo(t)*.5,o=-this.direction.dot(vo),a=yi.dot(this.direction),l=-yi.dot(vo),c=yi.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(Bc).addScaledVector(vo,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<s||isNaN(s))&&(s=o),d>=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<s||s!==s)&&(s=l),s<0)?null:this.at(n>=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,Qn)!==null}intersectTriangle(e,t,n,s,r){zc.subVectors(t,e),_o.subVectors(n,e),Vc.crossVectors(zc,_o);let o=this.direction.dot(Vc),a;if(o>0){if(s)return null;a=1}else if(o<0)a=-1,o=-o;else return null;yi.subVectors(this.origin,e);let l=a*this.direction.dot(_o.crossVectors(yi,_o));if(l<0)return null;let c=a*this.direction.dot(zc.cross(yi));if(c<0||l+c>o)return null;let h=-a*yi.dot(Vc);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 wi,this.combine=ih,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(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,Yi=new As,yo=new Ti,ld=new N,bo=new N,Mo=new N,So=new N,Gc=new N,wo=new N,cd=new N,Eo=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<o;r++){let a=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,t){let n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,o=n.morphTargetsRelative;t.fromBufferAttribute(s,e);let a=this.morphTargetInfluences;if(r&&a){wo.set(0,0,0);for(let l=0,c=r.length;l<c;l++){let h=a[l],d=r[l];h!==0&&(Gc.fromBufferAttribute(d,e),o?wo.addScaledVector(Gc,h):wo.addScaledVector(Gc.sub(t),h))}t.add(wo)}return t}raycast(e,t){let n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),yo.copy(n.boundingSphere),yo.applyMatrix4(r),Yi.copy(e.ray).recast(e.near),!(yo.containsPoint(Yi.origin)===!1&&(Yi.intersectSphere(yo,ld)===null||Yi.origin.distanceToSquared(ld)>(e.far-e.near)**2))&&(ad.copy(r).invert(),Yi.copy(e.ray).applyMatrix4(ad),!(n.boundingBox!==null&&Yi.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Yi)))}_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;m<x;m++){let g=u[m],p=o[g.materialIndex],v=Math.max(g.start,f.start),b=Math.min(a.count,Math.min(g.start+g.count,f.start+f.count));for(let M=v,S=b;M<S;M+=3){let w=a.getX(M),C=a.getX(M+1),_=a.getX(M+2);s=To(this,p,e,n,c,h,d,w,C,_),s&&(s.faceIndex=Math.floor(M/3),s.face.materialIndex=g.materialIndex,t.push(s))}}else{let m=Math.max(0,f.start),x=Math.min(a.count,f.start+f.count);for(let g=m,p=x;g<p;g+=3){let v=a.getX(g),b=a.getX(g+1),M=a.getX(g+2);s=To(this,o,e,n,c,h,d,v,b,M),s&&(s.faceIndex=Math.floor(g/3),t.push(s))}}else if(l!==void 0)if(Array.isArray(o))for(let m=0,x=u.length;m<x;m++){let g=u[m],p=o[g.materialIndex],v=Math.max(g.start,f.start),b=Math.min(l.count,Math.min(g.start+g.count,f.start+f.count));for(let M=v,S=b;M<S;M+=3){let w=M,C=M+1,_=M+2;s=To(this,p,e,n,c,h,d,w,C,_),s&&(s.faceIndex=Math.floor(M/3),s.face.materialIndex=g.materialIndex,t.push(s))}}else{let m=Math.max(0,f.start),x=Math.min(l.count,f.start+f.count);for(let g=m,p=x;g<p;g+=3){let v=g,b=g+1,M=g+2;s=To(this,o,e,n,c,h,d,v,b,M),s&&(s.faceIndex=Math.floor(g/3),t.push(s))}}}};function Ug(i,e,t,n,s,r,o,a){let l;if(e.side===$t?l=n.intersectTriangle(o,r,s,!0,a):l=n.intersectTriangle(s,r,o,e.side===ni,a),l===null)return null;Eo.copy(a),Eo.applyMatrix4(i.matrixWorld);let c=t.ray.origin.distanceTo(Eo);return c<t.near||c>t.far?null:{distance:c,point:Eo.clone(),object:i}}function To(i,e,t,n,s,r,o,a,l,c){i.getVertexPosition(a,bo),i.getVertexPosition(l,Mo),i.getVertexPosition(c,So);let h=Ug(i,e,t,n,bo,Mo,So,cd);if(h){let d=new N;Mi.getBarycoord(cd,bo,Mo,So,d),s&&(h.uv=Mi.getInterpolatedAttribute(s,a,l,c,d,new Ae)),r&&(h.uv1=Mi.getInterpolatedAttribute(r,a,l,c,d,new Ae)),o&&(h.normal=Mi.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};Mi.getNormal(bo,Mo,So,u.normal),h.face=u,h.barycoord=d}return h}var jo=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 Hc=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=Hc.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(Hc),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(Hc).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)}},Zi=new Ti,Vg=new Ae(.5,.5),Ao=new N,fr=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===ar)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(),Zi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Zi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Zi)}intersectsSprite(e){Zi.center.set(0,0,0);let t=Vg.distanceTo(e.center);return Zi.radius=.7071067811865476+t,Zi.applyMatrix4(e.matrixWorld),this.intersectsSphere(Zi)}intersectsSphere(e){let t=this.planes,n=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<s)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let s=t[n];if(Ao.x=s.normal.x>0?e.max.x:e.min.x,Ao.y=s.normal.y>0?e.max.y:e.min.y,Ao.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(Ao)<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}},Qo=new N,ea=new N,hd=new xt,tr=new As,Co=new Ti,Wc=new N,ud=new N,ta=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;s<r;s++)Qo.fromBufferAttribute(t,s-1),ea.fromBufferAttribute(t,s),n[s]=n[s-1],n[s]+=Qo.distanceTo(ea);e.setAttribute("lineDistance",new Ot(n,1))}else Te("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let n=this.geometry,s=this.matrixWorld,r=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Co.copy(n.boundingSphere),Co.applyMatrix4(s),Co.radius+=r,e.ray.intersectsSphere(Co)===!1)return;hd.copy(s).invert(),tr.copy(e.ray).applyMatrix4(hd);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=this.isLineSegments?2:1,h=n.index,u=n.attributes.position;if(h!==null){let f=Math.max(0,o.start),m=Math.min(h.count,o.start+o.count);for(let x=f,g=m-1;x<g;x+=c){let p=h.getX(x),v=h.getX(x+1),b=Ro(this,e,tr,l,p,v,x);b&&t.push(b)}if(this.isLineLoop){let x=h.getX(m-1),g=h.getX(f),p=Ro(this,e,tr,l,x,g,m-1);p&&t.push(p)}}else{let f=Math.max(0,o.start),m=Math.min(u.count,o.start+o.count);for(let x=f,g=m-1;x<g;x+=c){let p=Ro(this,e,tr,l,x,x+1,x);p&&t.push(p)}if(this.isLineLoop){let x=Ro(this,e,tr,l,m-1,f,m-1);x&&t.push(x)}}}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<o;r++){let a=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};function Ro(i,e,t,n,s,r,o){let a=i.geometry.attributes.position;if(Qo.fromBufferAttribute(a,s),ea.fromBufferAttribute(a,r),t.distanceSqToSegment(Qo,ea,Wc,ud)>n)return;Wc.applyMatrix4(i.matrixWorld);let c=e.ray.origin.distanceTo(Wc);if(!(c<e.near||c>e.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 ta{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;s<r;s+=2)dd.fromBufferAttribute(t,s),fd.fromBufferAttribute(t,s+1),n[s]=s===0?0:n[s-1],n[s+1]=n[s]+dd.distanceTo(fd);e.setAttribute("lineDistance",new Ot(n,1))}else Te("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var Ai=class extends ii{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new ge(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},pd=new xt,Jc=new As,Po=new Ti,Io=new N,Vn=class extends Qt{constructor(e=new ht,t=new Ai){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){let n=this.geometry,s=this.matrixWorld,r=e.params.Points.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Po.copy(n.boundingSphere),Po.applyMatrix4(s),Po.radius+=r,e.ray.intersectsSphere(Po)===!1)return;pd.copy(s).invert(),Jc.copy(e.ray).applyMatrix4(pd);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=n.index,d=n.attributes.position;if(c!==null){let u=Math.max(0,o.start),f=Math.min(c.count,o.start+o.count);for(let m=u,x=f;m<x;m++){let g=c.getX(m);Io.fromBufferAttribute(d,g),md(Io,g,l,s,e,t,this)}}else{let u=Math.max(0,o.start),f=Math.min(d.count,o.start+o.count);for(let m=u,x=f;m<x;m++)Io.fromBufferAttribute(d,m),md(Io,m,l,s,e,t,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<o;r++){let a=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};function md(i,e,t,n,s,r,o){let a=Jc.distanceSqToPoint(i);if(a<t){let l=new N;Jc.closestPointToPoint(i,l),l.applyMatrix4(n);let c=s.ray.origin.distanceTo(l);if(c<s.near||c>s.far)return;r.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:o})}}var pr=class extends jt{constructor(e=[],t=Li,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!==Di)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 Es(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}},na=class extends oi{constructor(e,t=Rn,n=Li,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}},mr=class extends jt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},Cs=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;le<O;le++){let ye=le*R-H;for(let Me=0;Me<F;Me++){let Ze=Me*P-I;ee[x]=Ze*v,ee[g]=ye*b,ee[p]=W,c.push(ee.x,ee.y,ee.z),ee[x]=0,ee[g]=0,ee[p]=w>0?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;ye<C;ye++){let Me=u+ye+F*le,Ze=u+ye+F*(le+1),Ke=u+(ye+1)+F*(le+1),Fe=u+(ye+1)+F*le;l.push(Me,Ze,Fe),l.push(Ze,Ke,Fe),J+=6}a.addGroup(f,J,A),f+=J,u+=U}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};var gr=class i extends ht{constructor(e=1,t=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:s};let r=e/2,o=t/2,a=Math.floor(n),l=Math.floor(s),c=a+1,h=l+1,d=e/a,u=t/l,f=[],m=[],x=[],g=[];for(let p=0;p<h;p++){let v=p*u-o;for(let b=0;b<c;b++){let M=b*d-r;m.push(M,-v,0),x.push(0,0,1),g.push(b/a),g.push(1-p/l)}}for(let p=0;p<l;p++)for(let v=0;v<a;v++){let b=v+c*p,M=v+c*(p+1),S=v+1+c*(p+1),w=v+1+c*p;f.push(b,M,w),f.push(M,S,w)}this.setIndex(f),this.setAttribute("position",new Ot(m,3)),this.setAttribute("normal",new Ot(x,3)),this.setAttribute("uv",new Ot(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.width,e.height,e.widthSegments,e.heightSegments)}};function es(i){let e={};for(let t in i){e[t]={};for(let n in i[t]){let s=i[t][n];if(gd(s))s.isRenderTargetTexture?(Te("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=s.clone();else if(Array.isArray(s))if(gd(s[0])){let r=[];for(let o=0,a=s.length;o<a;o++)r[o]=s[o].clone();e[t][n]=r}else e[t][n]=s.slice();else e[t][n]=s}}return e}function qt(i){let e={};for(let t=0;t<i.length;t++){let n=es(i[t]);for(let s in n)e[s]=n[s]}return e}function gd(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function Gg(i){let e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function gh(i){let e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Ge.workingColorSpace}var ci={clone:es,merge:qt},Hg=`void main() {
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
}`,Wg=`void main() {
|
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
}`,ut=class extends ii{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Hg,this.fragmentShader=Wg,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=es(e.uniforms),this.uniformsGroups=Gg(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let s in this.uniforms){let o=this.uniforms[s].value;o&&o.isTexture?t.uniforms[s]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[s]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[s]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[s]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[s]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[s]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[s]={type:"m4",value:o.toArray()}:t.uniforms[s]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;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}},Rs=class extends ut{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};var ia=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}},sa=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 Lo(i,e){return!i||i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}var Ci=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<s)){for(let a=n+2;;){if(s===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(r=s,s=t[++n],e<s)break e}o=t.length;break t}if(!(e>=r)){let a=t[1];e<a&&(n=2,r=a);for(let l=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===l)break;if(s=r,r=t[--n-1],e>=r)break e}o=n,n=0;break t}break n}for(;n<o;){let a=n+o>>>1;e<t[a]?o=a:n=a+1}if(s=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(s===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,s)}return this.interpolate_(n,r,e,s)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=e*s;for(let o=0;o!==s;++o)t[o]=n[r+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},ra=class extends Ci{constructor(e,t,n,s){super(e,t,n,s),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:qc,endingEnd:qc}}intervalChanged_(e,t,n){let s=this.parameterPositions,r=e-2,o=e+1,a=s[r],l=s[o];if(a===void 0)switch(this.getSettings_().endingStart){case Yc:r=e,a=2*t-n;break;case Zc:r=s.length-2,a=t+s[r]-s[r+1];break;default:r=e,a=n}if(l===void 0)switch(this.getSettings_().endingEnd){case Yc:o=e,l=2*n-t;break;case Zc:o=1,l=n+s[1]-s[0];break;default:o=e-1,l=t}let c=(n-t)*.5,h=this.valueSize;this._weightPrev=c/(t-a),this._weightNext=c/(l-n),this._offsetPrev=r*h,this._offsetNext=o*h}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,h=this._offsetPrev,d=this._offsetNext,u=this._weightPrev,f=this._weightNext,m=(n-t)/(s-t),x=m*m,g=x*m,p=-u*g+2*u*x-u*m,v=(1+u)*g+(-1.5-2*u)*x+(-.5+u)*m+1,b=(-1-f)*g+(1.5+f)*x+.5*m,M=f*g-f*x;for(let S=0;S!==a;++S)r[S]=p*o[h+S]+v*o[c+S]+b*o[l+S]+M*o[d+S];return r}},oa=class extends Ci{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=e*a,c=l-a,h=(n-t)/(s-t),d=1-h;for(let u=0;u!==a;++u)r[u]=o[c+u]*d+o[l+u]*h;return r}},aa=class extends Ci{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e){return this.copySampleValue_(e-1)}},la=class extends Ci{interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,h=this.settings||this.DefaultSettings_,d=h.inTangents,u=h.outTangents;if(!d||!u){let x=(n-t)/(s-t),g=1-x;for(let p=0;p!==a;++p)r[p]=o[c+p]*g+o[l+p]*x;return r}let f=a*2,m=e-1;for(let x=0;x!==a;++x){let g=o[c+x],p=o[l+x],v=m*f+x*2,b=u[v],M=u[v+1],S=e*f+x*2,w=d[S],C=d[S+1],_=(n-t)/(s-t),A,P,R,I,H;for(let W=0;W<8;W++){A=_*_,P=A*_,R=1-_,I=R*R,H=I*R;let O=H*t+3*I*_*b+3*R*A*w+P*s-n;if(Math.abs(O)<1e-10)break;let U=3*I*(b-t)+6*R*_*(w-b)+3*A*(s-w);if(Math.abs(U)<1e-10)break;_=_-O/U,_=Math.max(0,Math.min(1,_))}r[x]=H*g+3*I*_*M+3*R*A*C+P*p}return r}},cn=class{constructor(e,t,n,s){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Lo(t,this.TimeBufferType),this.values=Lo(n,this.ValueBufferType),this.setInterpolation(s||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Lo(e.times,Array),values:Lo(e.values,Array)};let s=e.getInterpolation();s!==e.DefaultInterpolation&&(n.interpolation=s)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new aa(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new oa(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new ra(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new la(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.settings=this.settings),t}setInterpolation(e){let t;switch(e){case sr:t=this.InterpolantFactoryMethodDiscrete;break;case Yo:t=this.InterpolantFactoryMethodLinear;break;case Fo:t=this.InterpolantFactoryMethodSmooth;break;case Xc:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return Te("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return sr;case this.InterpolantFactoryMethodLinear:return Yo;case this.InterpolantFactoryMethodSmooth:return Fo;case this.InterpolantFactoryMethodBezier:return Xc}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]*=e}return this}trim(e,t){let n=this.times,s=n.length,r=0,o=s-1;for(;r!==s&&n[r]<e;)++r;for(;o!==-1&&n[o]>t;)--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&&(Pe("KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,s=this.values,r=n.length;r===0&&(Pe("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)){Pe("KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){Pe("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)){Pe("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()===Fo,r=e.length-1,o=1;for(let a=1;a<r;++a){let l=!1,c=e[a],h=e[a+1];if(c!==h&&(a!==1||c!==e[0]))if(s)l=!0;else{let d=a*n,u=d-n,f=d+n;for(let m=0;m!==n;++m){let x=t[d+m];if(x!==t[u+m]||x!==t[f+m]){l=!0;break}}}if(l){if(a!==o){e[o]=e[a];let d=a*n,u=o*n;for(let f=0;f!==n;++f)t[u+f]=t[d+f]}++o}}if(r>0){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=Yo;var Ri=class extends cn{constructor(e,t,n){super(e,t,n)}};Ri.prototype.ValueTypeName="bool";Ri.prototype.ValueBufferType=Array;Ri.prototype.DefaultInterpolation=sr;Ri.prototype.InterpolantFactoryMethodLinear=void 0;Ri.prototype.InterpolantFactoryMethodSmooth=void 0;var ca=class extends cn{constructor(e,t,n,s){super(e,t,n,s)}};ca.prototype.ValueTypeName="color";var ha=class extends cn{constructor(e,t,n,s){super(e,t,n,s)}};ha.prototype.ValueTypeName="number";var ua=class extends Ci{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}},xr=class extends cn{constructor(e,t,n,s){super(e,t,n,s)}InterpolantFactoryMethodLinear(e){return new ua(this.times,this.values,this.getValueSize(),e)}};xr.prototype.ValueTypeName="quaternion";xr.prototype.InterpolantFactoryMethodSmooth=void 0;var Pi=class extends cn{constructor(e,t,n){super(e,t,n)}};Pi.prototype.ValueTypeName="string";Pi.prototype.ValueBufferType=Array;Pi.prototype.DefaultInterpolation=sr;Pi.prototype.InterpolantFactoryMethodLinear=void 0;Pi.prototype.InterpolantFactoryMethodSmooth=void 0;var da=class extends cn{constructor(e,t,n,s){super(e,t,n,s)}};da.prototype.ValueTypeName="vector";var fa=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;d<u;d+=2){let f=c[d],m=c[d+1];if(f.global&&(f.lastIndex=0),f.test(h))return m}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}},nf=new fa,pa=class{constructor(e){this.manager=e!==void 0?e:nf,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(s,r){n.load(e,s,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}};pa.DEFAULT_MATERIAL_NAME="__DEFAULT";var No=new N,Do=new vn,kn=new N,vr=class extends Qt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new xt,this.projectionMatrix=new xt,this.projectionMatrixInverse=new xt,this.coordinateSystem=Tn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(No,Do,kn),kn.x===1&&kn.y===1&&kn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(No,Do,kn.set(1,1,1)).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorld.decompose(No,Do,kn),kn.x===1&&kn.y===1&&kn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(No,Do,kn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}},bi=new N,xd=new Ae,vd=new Ae,Ht=class extends vr{constructor(e=50,t=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=ws*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(nr*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ws*2*Math.atan(Math.tan(nr*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){bi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(bi.x,bi.y).multiplyScalar(-e/bi.z),bi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(bi.x,bi.y).multiplyScalar(-e/bi.z)}getViewSize(e,t){return this.getViewBounds(e,xd,vd),t.subVectors(vd,xd)}setViewOffset(e,t,n,s,r,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(nr*.5*this.fov)/this.zoom,n=2*t,s=this.aspect*n,r=-.5*s,o=this.view;if(this.view!==null&&this.view.enabled){let l=o.fullWidth,c=o.fullHeight;r+=o.offsetX*s/l,t-=o.offsetY*n/c,s*=o.width/l,n*=o.height/c}let a=this.filmOffset;a!==0&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}};var ai=class extends vr{constructor(e=-1,t=1,n=1,s=-1,r=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=s,this.near=r,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,s,r,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2,r=n-e,o=n+e,a=s+t,l=s-t;if(this.view!==null&&this.view.enabled){let c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,o=r+c*this.view.width,a-=h*this.view.offsetY,l=a-h*this.view.height}this.projectionMatrix.makeOrthographic(r,o,a,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}};var _s=-90,ys=1,ma=class extends Qt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let s=new Ht(_s,ys,e,t);s.layers=this.layers,this.add(s);let r=new Ht(_s,ys,e,t);r.layers=this.layers,this.add(r);let o=new Ht(_s,ys,e,t);o.layers=this.layers,this.add(o);let a=new Ht(_s,ys,e,t);a.layers=this.layers,this.add(a);let l=new Ht(_s,ys,e,t);l.layers=this.layers,this.add(l);let c=new Ht(_s,ys,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,s,r,o,a,l]=t;for(let c of t)this.remove(c);if(e===Tn)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===ar)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[r,o,a,l,c,h]=this.children,d=e.getRenderTarget(),u=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),m=e.xr.enabled;e.xr.enabled=!1;let x=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let g=!1;e.isWebGLRenderer===!0?g=e.state.buffers.depth.getReversed():g=e.reversedDepthBuffer,e.setRenderTarget(n,0,s),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,1,s),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,2,s),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,3,s),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(n,4,s),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),n.texture.generateMipmaps=x,e.setRenderTarget(n,5,s),g&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(d,u,f),e.xr.enabled=m,n.texture.needsPMREMUpdate=!0}},ga=class extends Ht{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},_r=class{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(e){this._document=e,e.hidden!==void 0&&(this._pageVisibilityHandler=Xg.bind(this),e.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){this._pageVisibilityHandler!==null&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(e){return this._timescale=e,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(e){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(e!==void 0?e:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}};function Xg(){this._document.hidden===!1&&this.reset()}var xh="\\[\\]\\.:\\/",qg=new RegExp("["+xh+"]","g"),vh="[^"+xh+"]",Yg="[^"+xh.replace("\\.","")+"]",Zg=/((?:WC+[\/:])*)/.source.replace("WC",vh),$g=/(WCOD+)?/.source.replace("WCOD",Yg),Kg=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",vh),Jg=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",vh),jg=new RegExp("^"+Zg+$g+Kg+Jg+"$"),Qg=["material","materials","bones","map"],jc=class{constructor(e,t,n){let s=n||ct.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,s)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,s=this._bindings[n];s!==void 0&&s.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let s=this._targetGroup.nCachedObjects_,r=n.length;s!==r;++s)n[s].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},ct=class i{constructor(e,t,n){this.path=t,this.parsedPath=n||i.parseTrackName(t),this.node=i.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new i.Composite(e,t,n):new i(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(qg,"")}static parseTrackName(e){let t=jg.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},s=n.nodeName&&n.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){let r=n.nodeName.substring(s+1);Qg.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,s),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let o=0;o<r.length;o++){let a=r[o];if(a.name===t||a.uuid===t)return a;let l=n(a.children);if(l)return l}return null},s=n(e.children);if(s)return s}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)e[t++]=n[s]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,n=t.objectName,s=t.propertyName,r=t.propertyIndex;if(e||(e=i.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Te("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let c=t.objectIndex;switch(n){case"materials":if(!e.material){Pe("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Pe("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Pe("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===c){c=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Pe("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Pe("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){Pe("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){Pe("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}let o=e[s];if(o===void 0){let c=t.nodeName;Pe("PropertyBinding: Trying to update property for track: "+c+"."+s+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?a=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let l=this.BindingType.Direct;if(r!==void 0){if(s==="morphTargetInfluences"){if(!e.geometry){Pe("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Pe("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}l=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=r}else o.fromArray!==void 0&&o.toArray!==void 0?(l=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(l=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=s;this.getValue=this.GetterByBindingType[l],this.setValue=this.SetterByBindingTypeAndVersioning[l][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};ct.Composite=jc;ct.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ct.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ct.prototype.GetterByBindingType=[ct.prototype._getValue_direct,ct.prototype._getValue_array,ct.prototype._getValue_arrayElement,ct.prototype._getValue_toArray];ct.prototype.SetterByBindingTypeAndVersioning=[[ct.prototype._setValue_direct,ct.prototype._setValue_direct_setNeedsUpdate,ct.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ct.prototype._setValue_array,ct.prototype._setValue_array_setNeedsUpdate,ct.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ct.prototype._setValue_arrayElement,ct.prototype._setValue_arrayElement_setNeedsUpdate,ct.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ct.prototype._setValue_fromArray,ct.prototype._setValue_fromArray_setNeedsUpdate,ct.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var RS=new Float32Array(1);var Gn=class{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=He(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(He(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var wh=class wh{constructor(e,t,n,s){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,s)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,s){let r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=s,this}};wh.prototype.isMatrix2=!0;var Qc=wh;var yr=class extends An{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){Te("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}};function _h(i,e,t,n){let s=e0(n);switch(t){case ch:return i*e;case uh:return i*e/s.components*s.byteLength;case Ea:return i*e/s.components*s.byteLength;case Fi:return i*e*2/s.components*s.byteLength;case Ta:return i*e*2/s.components*s.byteLength;case hh:return i*e*3/s.components*s.byteLength;case yn:return i*e*4/s.components*s.byteLength;case Aa:return i*e*4/s.components*s.byteLength;case Ir:case Lr:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Nr:case Dr:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Ra:case Ia:return Math.max(i,16)*Math.max(e,8)/4;case Ca:case Pa:return Math.max(i,8)*Math.max(e,8)/2;case La:case Na:case Fa:case ka:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Da:case Fr:case Oa:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Ua:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Ba:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case za:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case Va:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case Ga:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case Ha:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case Wa:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case Xa:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case qa:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case Ya:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case Za:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case $a:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case Ka:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case Ja:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case ja:case Qa:case el:return Math.ceil(i/4)*Math.ceil(e/4)*16;case tl:case nl:return Math.ceil(i/4)*Math.ceil(e/4)*8;case kr:case il:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function e0(i){switch(i){case un:case rh:return{byteLength:1,components:1};case Is:case oh:case Xt:return{byteLength:2,components:1};case Sa:case wa:return{byteLength:2,components:4};case Rn:case Ma:case Pn:return{byteLength:4,components:1};case ah:case lh:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:va}}));typeof window<"u"&&(window.__THREE__?Te("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=va);function Tf(){let i=null,e=!1,t=null,n=null;function s(r,o){t(r,o),n=i.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&i!==null&&(n=i.requestAnimationFrame(s),e=!0)},stop:function(){i!==null&&i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){i=r}}}function t0(i){let e=new WeakMap;function t(a,l){let c=a.array,h=a.usage,d=c.byteLength,u=i.createBuffer();i.bindBuffer(l,u),i.bufferData(l,c,h),a.onUploadCallback();let f;if(c instanceof Float32Array)f=i.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)f=i.HALF_FLOAT;else if(c instanceof Uint16Array)a.isFloat16BufferAttribute?f=i.HALF_FLOAT:f=i.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=i.SHORT;else if(c instanceof Uint32Array)f=i.UNSIGNED_INT;else if(c instanceof Int32Array)f=i.INT;else if(c instanceof Int8Array)f=i.BYTE;else if(c instanceof Uint8Array)f=i.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:u,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:a.version,size:d}}function n(a,l,c){let h=l.array,d=l.updateRanges;if(i.bindBuffer(c,a),d.length===0)i.bufferSubData(c,0,h);else{d.sort((f,m)=>f.start-m.start);let u=0;for(let f=1;f<d.length;f++){let m=d[u],x=d[f];x.start<=m.start+m.count+1?m.count=Math.max(m.count,x.start+x.count-m.start):(++u,d[u]=x)}d.length=u+1;for(let f=0,m=d.length;f<m;f++){let x=d[f];i.bufferSubData(c,x.start*h.BYTES_PER_ELEMENT,h,x.start,x.count)}l.clearUpdateRanges()}l.onUploadCallback()}function s(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function r(a){a.isInterleavedBufferAttribute&&(a=a.data);let l=e.get(a);l&&(i.deleteBuffer(l.buffer),e.delete(a))}function o(a,l){if(a.isInterleavedBufferAttribute&&(a=a.data),a.isGLBufferAttribute){let h=e.get(a);(!h||h.version<a.version)&&e.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let c=e.get(a);if(c===void 0)e.set(a,t(a,l));else if(c.version<a.version){if(c.size!==a.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(c.buffer,a,l),c.version=a.version}}return{get:s,remove:r,update:o}}var n0=`#ifdef USE_ALPHAHASH
|
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
#endif`,i0=`#ifdef USE_ALPHAHASH
|
|
const float ALPHA_HASH_SCALE = 0.05;
|
|
float hash2D( vec2 value ) {
|
|
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
|
|
}
|
|
float hash3D( vec3 value ) {
|
|
return hash2D( vec2( hash2D( value.xy ), value.z ) );
|
|
}
|
|
float getAlphaHashThreshold( vec3 position ) {
|
|
float maxDeriv = max(
|
|
length( dFdx( position.xyz ) ),
|
|
length( dFdy( position.xyz ) )
|
|
);
|
|
float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
|
|
vec2 pixScales = vec2(
|
|
exp2( floor( log2( pixScale ) ) ),
|
|
exp2( ceil( log2( pixScale ) ) )
|
|
);
|
|
vec2 alpha = vec2(
|
|
hash3D( floor( pixScales.x * position.xyz ) ),
|
|
hash3D( floor( pixScales.y * position.xyz ) )
|
|
);
|
|
float lerpFactor = fract( log2( pixScale ) );
|
|
float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
|
|
float a = min( lerpFactor, 1.0 - lerpFactor );
|
|
vec3 cases = vec3(
|
|
x * x / ( 2.0 * a * ( 1.0 - a ) ),
|
|
( x - 0.5 * a ) / ( 1.0 - a ),
|
|
1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
|
|
);
|
|
float threshold = ( x < ( 1.0 - a ) )
|
|
? ( ( x < a ) ? cases.x : cases.y )
|
|
: cases.z;
|
|
return clamp( threshold , 1.0e-6, 1.0 );
|
|
}
|
|
#endif`,s0=`#ifdef USE_ALPHAMAP
|
|
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
|
#endif`,r0=`#ifdef USE_ALPHAMAP
|
|
uniform sampler2D alphaMap;
|
|
#endif`,o0=`#ifdef USE_ALPHATEST
|
|
#ifdef ALPHA_TO_COVERAGE
|
|
diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
|
|
if ( diffuseColor.a == 0.0 ) discard;
|
|
#else
|
|
if ( diffuseColor.a < alphaTest ) discard;
|
|
#endif
|
|
#endif`,a0=`#ifdef USE_ALPHATEST
|
|
uniform float alphaTest;
|
|
#endif`,l0=`#ifdef USE_AOMAP
|
|
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
|
|
reflectedLight.indirectDiffuse *= ambientOcclusion;
|
|
#if defined( USE_CLEARCOAT )
|
|
clearcoatSpecularIndirect *= ambientOcclusion;
|
|
#endif
|
|
#if defined( USE_SHEEN )
|
|
sheenSpecularIndirect *= ambientOcclusion;
|
|
#endif
|
|
#if defined( USE_ENVMAP ) && defined( STANDARD )
|
|
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
|
|
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
|
|
#endif
|
|
#endif`,c0=`#ifdef USE_AOMAP
|
|
uniform sampler2D aoMap;
|
|
uniform float aoMapIntensity;
|
|
#endif`,h0=`#ifdef USE_BATCHING
|
|
#if ! defined( GL_ANGLE_multi_draw )
|
|
#define gl_DrawID _gl_DrawID
|
|
uniform int _gl_DrawID;
|
|
#endif
|
|
uniform highp sampler2D batchingTexture;
|
|
uniform highp usampler2D batchingIdTexture;
|
|
mat4 getBatchingMatrix( const in float i ) {
|
|
int size = textureSize( batchingTexture, 0 ).x;
|
|
int j = int( i ) * 4;
|
|
int x = j % size;
|
|
int y = j / size;
|
|
vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
|
|
vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
|
|
vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
|
|
vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
|
|
return mat4( v1, v2, v3, v4 );
|
|
}
|
|
float getIndirectIndex( const in int i ) {
|
|
int size = textureSize( batchingIdTexture, 0 ).x;
|
|
int x = i % size;
|
|
int y = i / size;
|
|
return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
|
|
}
|
|
#endif
|
|
#ifdef USE_BATCHING_COLOR
|
|
uniform sampler2D batchingColorTexture;
|
|
vec4 getBatchingColor( const in float i ) {
|
|
int size = textureSize( batchingColorTexture, 0 ).x;
|
|
int j = int( i );
|
|
int x = j % size;
|
|
int y = j / size;
|
|
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
|
|
}
|
|
#endif`,u0=`#ifdef USE_BATCHING
|
|
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
|
#endif`,d0=`vec3 transformed = vec3( position );
|
|
#ifdef USE_ALPHAHASH
|
|
vPosition = vec3( position );
|
|
#endif`,f0=`vec3 objectNormal = vec3( normal );
|
|
#ifdef USE_TANGENT
|
|
vec3 objectTangent = vec3( tangent.xyz );
|
|
#endif`,p0=`float G_BlinnPhong_Implicit( ) {
|
|
return 0.25;
|
|
}
|
|
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
|
|
return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
|
|
}
|
|
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
|
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|
float dotNH = saturate( dot( normal, halfDir ) );
|
|
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|
vec3 F = F_Schlick( specularColor, 1.0, dotVH );
|
|
float G = G_BlinnPhong_Implicit( );
|
|
float D = D_BlinnPhong( shininess, dotNH );
|
|
return F * ( G * D );
|
|
} // validated`,m0=`#ifdef USE_IRIDESCENCE
|
|
const mat3 XYZ_TO_REC709 = mat3(
|
|
3.2404542, -0.9692660, 0.0556434,
|
|
-1.5371385, 1.8760108, -0.2040259,
|
|
-0.4985314, 0.0415560, 1.0572252
|
|
);
|
|
vec3 Fresnel0ToIor( vec3 fresnel0 ) {
|
|
vec3 sqrtF0 = sqrt( fresnel0 );
|
|
return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
|
|
}
|
|
vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
|
|
return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
|
|
}
|
|
float IorToFresnel0( float transmittedIor, float incidentIor ) {
|
|
return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
|
|
}
|
|
vec3 evalSensitivity( float OPD, vec3 shift ) {
|
|
float phase = 2.0 * PI * OPD * 1.0e-9;
|
|
vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
|
|
vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
|
|
vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
|
|
vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
|
|
xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
|
|
xyz /= 1.0685e-7;
|
|
vec3 rgb = XYZ_TO_REC709 * xyz;
|
|
return rgb;
|
|
}
|
|
vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
|
|
vec3 I;
|
|
float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
|
|
float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
|
|
float cosTheta2Sq = 1.0 - sinTheta2Sq;
|
|
if ( cosTheta2Sq < 0.0 ) {
|
|
return vec3( 1.0 );
|
|
}
|
|
float cosTheta2 = sqrt( cosTheta2Sq );
|
|
float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
|
|
float R12 = F_Schlick( R0, 1.0, cosTheta1 );
|
|
float T121 = 1.0 - R12;
|
|
float phi12 = 0.0;
|
|
if ( iridescenceIOR < outsideIOR ) phi12 = PI;
|
|
float phi21 = PI - phi12;
|
|
vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
|
|
vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
|
|
vec3 phi23 = vec3( 0.0 );
|
|
if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
|
|
if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
|
|
if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
|
|
float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
|
|
vec3 phi = vec3( phi21 ) + phi23;
|
|
vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
|
|
vec3 r123 = sqrt( R123 );
|
|
vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
|
|
vec3 C0 = R12 + Rs;
|
|
I = C0;
|
|
vec3 Cm = Rs - T121;
|
|
for ( int m = 1; m <= 2; ++ m ) {
|
|
Cm *= r123;
|
|
vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
|
|
I += Cm * Sm;
|
|
}
|
|
return max( I, vec3( 0.0 ) );
|
|
}
|
|
#endif`,g0=`#ifdef USE_BUMPMAP
|
|
uniform sampler2D bumpMap;
|
|
uniform float bumpScale;
|
|
vec2 dHdxy_fwd() {
|
|
vec2 dSTdx = dFdx( vBumpMapUv );
|
|
vec2 dSTdy = dFdy( vBumpMapUv );
|
|
float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
|
|
float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
|
|
float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
|
|
return vec2( dBx, dBy );
|
|
}
|
|
vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
|
|
vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
|
|
vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
|
|
vec3 vN = surf_norm;
|
|
vec3 R1 = cross( vSigmaY, vN );
|
|
vec3 R2 = cross( vN, vSigmaX );
|
|
float fDet = dot( vSigmaX, R1 ) * faceDirection;
|
|
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
|
return normalize( abs( fDet ) * surf_norm - vGrad );
|
|
}
|
|
#endif`,x0=`#if NUM_CLIPPING_PLANES > 0
|
|
vec4 plane;
|
|
#ifdef ALPHA_TO_COVERAGE
|
|
float distanceToPlane, distanceGradient;
|
|
float clipOpacity = 1.0;
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
|
|
plane = clippingPlanes[ i ];
|
|
distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
|
|
distanceGradient = fwidth( distanceToPlane ) / 2.0;
|
|
clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
|
|
if ( clipOpacity == 0.0 ) discard;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
|
|
float unionClipOpacity = 1.0;
|
|
#pragma unroll_loop_start
|
|
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
|
|
plane = clippingPlanes[ i ];
|
|
distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
|
|
distanceGradient = fwidth( distanceToPlane ) / 2.0;
|
|
unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
|
|
}
|
|
#pragma unroll_loop_end
|
|
clipOpacity *= 1.0 - unionClipOpacity;
|
|
#endif
|
|
diffuseColor.a *= clipOpacity;
|
|
if ( diffuseColor.a == 0.0 ) discard;
|
|
#else
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
|
|
plane = clippingPlanes[ i ];
|
|
if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
|
|
bool clipped = true;
|
|
#pragma unroll_loop_start
|
|
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
|
|
plane = clippingPlanes[ i ];
|
|
clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
|
|
}
|
|
#pragma unroll_loop_end
|
|
if ( clipped ) discard;
|
|
#endif
|
|
#endif
|
|
#endif`,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 <lightprobes_pars_fragment>`,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 <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
}`,sv=`varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
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 <cube_uv_reflection_fragment>
|
|
void main() {
|
|
#ifdef ENVMAP_TYPE_CUBE
|
|
vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection );
|
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
|
|
#else
|
|
vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
|
|
#endif
|
|
texColor.rgb *= backgroundIntensity;
|
|
gl_FragColor = texColor;
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
}`,ov=`varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
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 <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
}`,lv=`#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
varying vec2 vHighPrecisionZW;
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <batching_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <morphinstance_vertex>
|
|
#ifdef USE_DISPLACEMENTMAP
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinnormal_vertex>
|
|
#endif
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vHighPrecisionZW = gl_Position.zw;
|
|
}`,cv=`#if DEPTH_PACKING == 3200
|
|
uniform float opacity;
|
|
#endif
|
|
#include <common>
|
|
#include <packing>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
varying vec2 vHighPrecisionZW;
|
|
void main() {
|
|
vec4 diffuseColor = vec4( 1.0 );
|
|
#include <clipping_planes_fragment>
|
|
#if DEPTH_PACKING == 3200
|
|
diffuseColor.a = opacity;
|
|
#endif
|
|
#include <map_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <logdepthbuf_fragment>
|
|
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
|
|
#else
|
|
float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
|
|
#endif
|
|
#if DEPTH_PACKING == 3200
|
|
gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
|
|
#elif DEPTH_PACKING == 3201
|
|
gl_FragColor = packDepthToRGBA( fragCoordZ );
|
|
#elif DEPTH_PACKING == 3202
|
|
gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
|
|
#elif DEPTH_PACKING == 3203
|
|
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
|
|
#endif
|
|
}`,hv=`#define DISTANCE
|
|
varying vec3 vWorldPosition;
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <batching_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <morphinstance_vertex>
|
|
#ifdef USE_DISPLACEMENTMAP
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinnormal_vertex>
|
|
#endif
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vWorldPosition = worldPosition.xyz;
|
|
}`,uv=`#define DISTANCE
|
|
uniform vec3 referencePosition;
|
|
uniform float nearDistance;
|
|
uniform float farDistance;
|
|
varying vec3 vWorldPosition;
|
|
#include <common>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main () {
|
|
vec4 diffuseColor = vec4( 1.0 );
|
|
#include <clipping_planes_fragment>
|
|
#include <map_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
float dist = length( vWorldPosition - referencePosition );
|
|
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
|
dist = saturate( dist );
|
|
gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
|
|
}`,dv=`varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
}`,fv=`uniform sampler2D tEquirect;
|
|
varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vec3 direction = normalize( vWorldDirection );
|
|
vec2 sampleUV = equirectUv( direction );
|
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
}`,pv=`uniform float scale;
|
|
attribute float lineDistance;
|
|
varying float vLineDistance;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
vLineDistance = scale * lineDistance;
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <fog_vertex>
|
|
}`,mv=`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
uniform float dashSize;
|
|
uniform float totalSize;
|
|
varying float vLineDistance;
|
|
#include <common>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
if ( mod( vLineDistance, totalSize ) > dashSize ) {
|
|
discard;
|
|
}
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
outgoingLight = diffuseColor.rgb;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
}`,gv=`#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <envmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#endif
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <envmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,xv=`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
#ifndef FLAT_SHADED
|
|
varying vec3 vNormal;
|
|
#endif
|
|
#include <common>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <specularmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <specularmap_fragment>
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
#ifdef USE_LIGHTMAP
|
|
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
|
|
#else
|
|
reflectedLight.indirectDiffuse += vec3( 1.0 );
|
|
#endif
|
|
#include <aomap_fragment>
|
|
reflectedLight.indirectDiffuse *= diffuseColor.rgb;
|
|
vec3 outgoingLight = reflectedLight.indirectDiffuse;
|
|
#include <envmap_fragment>
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,vv=`#define LAMBERT
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <envmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <envmap_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,_v=`#define LAMBERT
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <cube_uv_reflection_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_pars_fragment>
|
|
#include <envmap_physical_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_lambert_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <specularmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <specularmap_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_lambert_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
|
#include <envmap_fragment>
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,yv=`#define MATCAP
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <fog_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
}`,bv=`#define MATCAP
|
|
uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
uniform sampler2D matcap;
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <normal_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
vec3 viewDir = normalize( vViewPosition );
|
|
vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
|
|
vec3 y = cross( viewDir, x );
|
|
vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
|
|
#ifdef USE_MATCAP
|
|
vec4 matcapColor = texture2D( matcap, uv );
|
|
#else
|
|
vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
|
|
#endif
|
|
vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,Mv=`#define NORMAL
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
varying vec3 vViewPosition;
|
|
#endif
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
vViewPosition = - mvPosition.xyz;
|
|
#endif
|
|
}`,Sv=`#define NORMAL
|
|
uniform float opacity;
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
varying vec3 vViewPosition;
|
|
#endif
|
|
#include <uv_pars_fragment>
|
|
#include <normal_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
|
|
#include <clipping_planes_fragment>
|
|
#include <logdepthbuf_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );
|
|
#ifdef OPAQUE
|
|
gl_FragColor.a = 1.0;
|
|
#endif
|
|
}`,wv=`#define PHONG
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <envmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <envmap_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,Ev=`#define PHONG
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform vec3 specular;
|
|
uniform float shininess;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <cube_uv_reflection_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_pars_fragment>
|
|
#include <envmap_physical_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_phong_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <specularmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <specularmap_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_phong_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
|
|
#include <envmap_fragment>
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,Tv=`#define STANDARD
|
|
varying vec3 vViewPosition;
|
|
#ifdef USE_TRANSMISSION
|
|
varying vec3 vWorldPosition;
|
|
#endif
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
#ifdef USE_TRANSMISSION
|
|
vWorldPosition = worldPosition.xyz;
|
|
#endif
|
|
}`,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 <common>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <iridescence_fragment>
|
|
#include <cube_uv_reflection_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_physical_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_physical_pars_fragment>
|
|
#include <transmission_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <clearcoat_pars_fragment>
|
|
#include <iridescence_pars_fragment>
|
|
#include <roughnessmap_pars_fragment>
|
|
#include <metalnessmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <roughnessmap_fragment>
|
|
#include <metalnessmap_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <clearcoat_normal_fragment_begin>
|
|
#include <clearcoat_normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_physical_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
|
|
vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
|
|
#include <transmission_fragment>
|
|
vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
|
|
#ifdef USE_SHEEN
|
|
|
|
outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;
|
|
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
|
|
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
|
|
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
|
|
#endif
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,Cv=`#define TOON
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,Rv=`#define TOON
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <gradientmap_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_toon_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_toon_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,Pv=`uniform float size;
|
|
uniform float scale;
|
|
#include <common>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
#ifdef USE_POINTS_UV
|
|
varying vec2 vUv;
|
|
uniform mat3 uvTransform;
|
|
#endif
|
|
void main() {
|
|
#ifdef USE_POINTS_UV
|
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
#endif
|
|
#include <color_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <project_vertex>
|
|
gl_PointSize = size;
|
|
#ifdef USE_SIZEATTENUATION
|
|
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
|
if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
|
|
#endif
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <fog_vertex>
|
|
}`,Iv=`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <color_pars_fragment>
|
|
#include <map_particle_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_particle_fragment>
|
|
#include <color_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
outgoingLight = diffuseColor.rgb;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
}`,Lv=`#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
void main() {
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,Nv=`uniform vec3 color;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <shadowmask_pars_fragment>
|
|
void main() {
|
|
#include <logdepthbuf_fragment>
|
|
gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
}`,Dv=`uniform float rotation;
|
|
uniform vec2 center;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
vec4 mvPosition = modelViewMatrix[ 3 ];
|
|
vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
|
|
#ifndef USE_SIZEATTENUATION
|
|
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
|
if ( isPerspective ) scale *= - mvPosition.z;
|
|
#endif
|
|
vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
|
|
vec2 rotatedPosition;
|
|
rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
|
|
rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
|
|
mvPosition.xy += rotatedPosition;
|
|
gl_Position = projectionMatrix * mvPosition;
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <fog_vertex>
|
|
}`,Fv=`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
outgoingLight = diffuseColor.rgb;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
}`,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 al={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===Rr)?(c===void 0&&(c=new Wt(new Cs(1,1,1),new ut({name:"BackgroundCubeMaterial",uniforms:es(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 gr(2,2),new ut({name:"BackgroundMaterial",uniforms:es(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(al,gh(i)),t.buffers.color.setClear(al.r,al.g,al.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<t;F++)I[F]=0,H[F]=0,W[F]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:I,enabledAttributes:H,attributeDivisors:W,object:R,attributes:{},index:null}}function f(R,I,H,W){let F=r.attributes,O=I.attributes,U=0,J=H.getAttributes();for(let ee in J)if(J[ee].location>=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<H;I++)R[I]=0}function g(R){p(R,0)}function p(R,I){let H=r.newAttributes,W=r.enabledAttributes,F=r.attributeDivisors;H[R]=1,W[R]===0&&(i.enableVertexAttribArray(R),W[R]=1),F[R]!==I&&(i.vertexAttribDivisor(R,I),F[R]=I)}function v(){let R=r.newAttributes,I=r.enabledAttributes;for(let H=0,W=I.length;H<W;H++)I[H]!==R[H]&&(i.disableVertexAttribArray(H),I[H]=0)}function b(R,I,H,W,F,O,U){U===!0?i.vertexAttribIPointer(R,I,H,F,O):i.vertexAttribPointer(R,I,H,W,F,O)}function M(R,I,H,W){x();let F=W.attributes,O=H.getAttributes(),U=I.defaultAttributeValues;for(let J in O){let ee=O[J];if(ee.location>=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===Ma;if(le.isInterleavedBufferAttribute){let se=le.data,Re=se.stride,ke=le.offset;if(se.isInstancedInterleavedBuffer){for(let Ie=0;Ie<ee.locationSize;Ie++)p(ee.location+Ie,se.meshPerAttribute);R.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=se.meshPerAttribute*se.count)}else for(let Ie=0;Ie<ee.locationSize;Ie++)g(ee.location+Ie);i.bindBuffer(i.ARRAY_BUFFER,Ke);for(let Ie=0;Ie<ee.locationSize;Ie++)b(ee.location+Ie,Me/ee.locationSize,Fe,ye,Re*Z,(ke+Me/ee.locationSize*Ie)*Z,fe)}else{if(le.isInstancedBufferAttribute){for(let se=0;se<ee.locationSize;se++)p(ee.location+se,le.meshPerAttribute);R.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=le.meshPerAttribute*le.count)}else for(let se=0;se<ee.locationSize;se++)g(ee.location+se);i.bindBuffer(i.ARRAY_BUFFER,Ke);for(let se=0;se<ee.locationSize;se++)b(ee.location+se,Me/ee.locationSize,Fe,ye,Me*Z,Me/ee.locationSize*se*Z,fe)}}else if(U!==void 0){let ye=U[J];if(ye!==void 0)switch(ye.length){case 2:i.vertexAttrib2fv(ee.location,ye);break;case 3:i.vertexAttrib3fv(ee.location,ye);break;case 4:i.vertexAttrib4fv(ee.location,ye);break;default:i.vertexAttrib1fv(ee.location,ye)}}}}v()}function S(){A();for(let R in n){let I=n[R];for(let H in I){let W=I[H];for(let F in W){let O=W[F];for(let U in O)h(O[U].object),delete O[U];delete W[F]}}delete n[R]}}function w(R){if(n[R.id]===void 0)return;let I=n[R.id];for(let H in I){let W=I[H];for(let F in W){let O=W[F];for(let U in O)h(O[U].object),delete O[U];delete W[F]}}delete n[R.id]}function C(R){for(let I in n){let H=n[I];for(let W in H){let F=H[W];if(F[R.id]===void 0)continue;let O=F[R.id];for(let U in O)h(O[U].object),delete O[U];delete F[R.id]}}}function _(R){for(let I in n){let H=n[I],W=R.isInstancedMesh===!0?R.id:0,F=H[W];if(F!==void 0){for(let O in F){let U=F[O];for(let J in U)h(U[J].object),delete U[J];delete F[O]}delete H[W],Object.keys(H).length===0&&delete n[I]}}}function A(){P(),o=!0,r!==s&&(r=s,c(r.object))}function P(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:a,reset:A,resetDefaultState:P,dispose:S,releaseStatesOfGeometry:w,releaseStatesOfObject:_,releaseStatesOfProgram:C,initAttributes:x,enableAttribute:g,disableUnusedAttributes:v}}function Bv(i,e,t){let n;function s(l){n=l}function r(l,c){i.drawArrays(n,l,c),t.update(c,n,1)}function o(l,c,h){h!==0&&(i.drawArraysInstanced(n,l,c,h),t.update(c,n,h))}function a(l,c,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,c,0,h);let u=0;for(let f=0;f<h;f++)u+=c[f];t.update(u,n,1)}this.setMode=s,this.render=r,this.renderInstances=o,this.renderMultiDraw=a}function zv(i,e,t,n){let s;function r(){if(s!==void 0)return s;if(e.has("EXT_texture_filter_anisotropic")===!0){let C=e.get("EXT_texture_filter_anisotropic");s=i.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function o(C){return!(C!==yn&&n.convert(C)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(C){let _=C===Xt&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(C!==un&&n.convert(C)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&C!==Pn&&!_)}function l(C){if(C==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=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.length<p)&&(g=new Float32Array(p));for(let b=0,M=f;b!==x;++b,M+=4)o.copy(d[b]).applyMatrix4(v,a),o.normal.toArray(g,M),g[M+3]=o.constant}l.value=g,l.needsUpdate=!0}return e.numPlanes=x,e.numIntersection=0,g}}var ki=4,sf=[.125,.215,.35,.446,.526,.582],ts=20,Gv=256,Or=new ai,rf=new ge,Eh=null,Th=0,Ah=0,Ch=!1,Hv=new N,cl=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,s=100,r={}){let{size:o=256,position:a=Hv}=r;Eh=this._renderer.getRenderTarget(),Th=this._renderer.getActiveCubeFace(),Ah=this._renderer.getActiveMipmapLevel(),Ch=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(o);let l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,n,s,l,a),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=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;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Eh,Th,Ah),this._renderer.xr.enabled=Ch,e.scissorTest=!1,Ds(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Li||e.mapping===Qi?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Eh=this._renderer.getRenderTarget(),Th=this._renderer.getActiveCubeFace(),Ah=this._renderer.getActiveMipmapLevel(),Ch=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Ut,minFilter:Ut,generateMipmaps:!1,type:Xt,format:yn,colorSpace:rr,depthBuffer:!1},s=of(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=of(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Wv(r)),this._blurMaterial=qv(r,e,t),this._ggxMaterial=Xv(r,e,t)}return s}_compileMaterial(e){let t=new Wt(new ht,e);this._renderer.compile(t,Or)}_sceneToCubeUV(e,t,n,s,r){let l=new Ht(90,1,t,n),c=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],d=this._renderer,u=d.autoClear,f=d.toneMapping;d.getClearColor(rf),d.toneMapping=hn,d.autoClear=!1,d.state.buffers.depth.getReversed()&&(d.setRenderTarget(s),d.clearDepth(),d.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Wt(new Cs,new si({name:"PMREM.Background",side:$t,depthWrite:!1,depthTest:!1})));let x=this._backgroundBox,g=x.material,p=!1,v=e.background;v?v.isColor&&(g.color.copy(v),e.background=null,p=!0):(g.color.copy(rf),p=!0);for(let b=0;b<6;b++){let M=b%3;M===0?(l.up.set(0,c[b],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x+h[b],r.y,r.z)):M===1?(l.up.set(0,0,c[b]),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y+h[b],r.z)):(l.up.set(0,c[b],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y,r.z+h[b]));let S=this._cubeSize;Ds(s,M*S,b>2?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===Li||e.mapping===Qi;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;Ds(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(o,Or)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let s=this._lodMeshes.length;for(let r=1;r<s;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){let s=this._renderer,r=this._pingPongRenderTarget,o=this._ggxMaterial,a=this._lodMeshes[n];a.material=o;let l=o.uniforms,c=n/(this._lodMeshes.length-1),h=t/(this._lodMeshes.length-1),d=Math.sqrt(c*c-h*h),u=0+c*1.25,f=d*u,{_lodMax:m}=this,x=this._sizeLods[n],g=3*x*(n>m-ki?n-m+ki:0),p=4*(this._cubeSize-x);l.envMap.value=e.texture,l.roughness.value=f,l.mipInt.value=m-t,Ds(r,g,p,3*x,2*x),s.setRenderTarget(r),s.render(a,Or),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=m-n,Ds(e,g,p,3*x,2*x),s.setRenderTarget(e),s.render(a,Or)}_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"&&Pe("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*ts-1),x=r/m,g=isFinite(r)?1+Math.floor(h*x):ts;g>ts&&Te(`sigmaRadians, ${r}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${ts}`);let p=[],v=0;for(let C=0;C<ts;++C){let _=C/x,A=Math.exp(-_*_/2);p.push(A),C===0?v+=A:C<g&&(v+=2*A)}for(let C=0;C<p.length;C++)p[C]=p[C]/v;u.envMap.value=e.texture,u.samples.value=g,u.weights.value=p,u.latitudinal.value=o==="latitudinal",a&&(u.poleAxis.value=a);let{_lodMax:b}=this;u.dTheta.value=m,u.mipInt.value=b-n;let M=this._sizeLods[s],S=3*M*(s>b-ki?s-b+ki:0),w=4*(this._cubeSize-M);Ds(t,S,w,3*M,2*M),l.setRenderTarget(t),l.render(d,Or)}};function Wv(i){let e=[],t=[],n=[],s=i,r=i-ki+1+sf.length;for(let o=0;o<r;o++){let a=Math.pow(2,s);e.push(a);let l=1/a;o>i-ki?l=sf[o-i+ki-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;w<f;w++){let C=w%3*2/3-1,_=w>2?0:-1,A=[C,_,0,C+2/3,_,0,C+2/3,_+1,0,C,_,0,C+2/3,_+1,0,C,_+1,0];v.set(A,x*m*w),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>ki&&s--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function of(i,e,t){let n=new Ct(i,e,t);return n.texture.mapping=Rr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Ds(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:ul(),fragmentShader:`
|
|
|
|
precision highp float;
|
|
precision highp int;
|
|
|
|
varying vec3 vOutputDirection;
|
|
|
|
uniform sampler2D envMap;
|
|
uniform float roughness;
|
|
uniform float mipInt;
|
|
|
|
#define ENVMAP_TYPE_CUBE_UV
|
|
#include <cube_uv_reflection_fragment>
|
|
|
|
#define PI 3.14159265359
|
|
|
|
// Van der Corput radical inverse
|
|
float radicalInverse_VdC(uint bits) {
|
|
bits = (bits << 16u) | (bits >> 16u);
|
|
bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
|
|
bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
|
|
bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
|
|
bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
|
|
return float(bits) * 2.3283064365386963e-10; // / 0x100000000
|
|
}
|
|
|
|
// Hammersley sequence
|
|
vec2 hammersley(uint i, uint N) {
|
|
return vec2(float(i) / float(N), radicalInverse_VdC(i));
|
|
}
|
|
|
|
// GGX VNDF importance sampling (Eric Heitz 2018)
|
|
// "Sampling the GGX Distribution of Visible Normals"
|
|
// https://jcgt.org/published/0007/04/01/
|
|
vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
|
|
float alpha = roughness * roughness;
|
|
|
|
// Section 4.1: Orthonormal basis
|
|
vec3 T1 = vec3(1.0, 0.0, 0.0);
|
|
vec3 T2 = cross(V, T1);
|
|
|
|
// Section 4.2: Parameterization of projected area
|
|
float r = sqrt(Xi.x);
|
|
float phi = 2.0 * PI * Xi.y;
|
|
float t1 = r * cos(phi);
|
|
float t2 = r * sin(phi);
|
|
float s = 0.5 * (1.0 + V.z);
|
|
t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
|
|
|
|
// Section 4.3: Reprojection onto hemisphere
|
|
vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V;
|
|
|
|
// Section 3.4: Transform back to ellipsoid configuration
|
|
return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
|
|
}
|
|
|
|
void main() {
|
|
vec3 N = normalize(vOutputDirection);
|
|
vec3 V = N; // Assume view direction equals normal for pre-filtering
|
|
|
|
vec3 prefilteredColor = vec3(0.0);
|
|
float totalWeight = 0.0;
|
|
|
|
// For very low roughness, just sample the environment directly
|
|
if (roughness < 0.001) {
|
|
gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
|
|
return;
|
|
}
|
|
|
|
// Tangent space basis for VNDF sampling
|
|
vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
|
|
vec3 tangent = normalize(cross(up, N));
|
|
vec3 bitangent = cross(N, tangent);
|
|
|
|
for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
|
|
vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
|
|
|
|
// For PMREM, V = N, so in tangent space V is always (0, 0, 1)
|
|
vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
|
|
|
|
// Transform H back to world space
|
|
vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
|
|
vec3 L = normalize(2.0 * dot(V, H) * H - V);
|
|
|
|
float NdotL = max(dot(N, L), 0.0);
|
|
|
|
if(NdotL > 0.0) {
|
|
// Sample environment at fixed mip level
|
|
// VNDF importance sampling handles the distribution filtering
|
|
vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
|
|
|
|
// Weight by NdotL for the split-sum approximation
|
|
// VNDF PDF naturally accounts for the visible microfacet distribution
|
|
prefilteredColor += sampleColor * NdotL;
|
|
totalWeight += NdotL;
|
|
}
|
|
}
|
|
|
|
if (totalWeight > 0.0) {
|
|
prefilteredColor = prefilteredColor / totalWeight;
|
|
}
|
|
|
|
gl_FragColor = vec4(prefilteredColor, 1.0);
|
|
}
|
|
`,blending:_n,depthTest:!1,depthWrite:!1})}function qv(i,e,t){let n=new Float32Array(ts),s=new N(0,1,0);return new ut({name:"SphericalGaussianBlur",defines:{n:ts,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:ul(),fragmentShader:`
|
|
|
|
precision mediump float;
|
|
precision mediump int;
|
|
|
|
varying vec3 vOutputDirection;
|
|
|
|
uniform sampler2D envMap;
|
|
uniform int samples;
|
|
uniform float weights[ n ];
|
|
uniform bool latitudinal;
|
|
uniform float dTheta;
|
|
uniform float mipInt;
|
|
uniform vec3 poleAxis;
|
|
|
|
#define ENVMAP_TYPE_CUBE_UV
|
|
#include <cube_uv_reflection_fragment>
|
|
|
|
vec3 getSample( float theta, vec3 axis ) {
|
|
|
|
float cosTheta = cos( theta );
|
|
// Rodrigues' axis-angle rotation
|
|
vec3 sampleDirection = vOutputDirection * cosTheta
|
|
+ cross( axis, vOutputDirection ) * sin( theta )
|
|
+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
|
|
|
|
return bilinearCubeUV( envMap, sampleDirection, mipInt );
|
|
|
|
}
|
|
|
|
void main() {
|
|
|
|
vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
|
|
|
|
if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
|
|
|
|
axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
|
|
|
|
}
|
|
|
|
axis = normalize( axis );
|
|
|
|
gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
|
|
gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
|
|
|
|
for ( int i = 1; i < n; i++ ) {
|
|
|
|
if ( i >= samples ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
float theta = dTheta * float( i );
|
|
gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
|
|
gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
|
|
|
|
}
|
|
|
|
}
|
|
`,blending:_n,depthTest:!1,depthWrite:!1})}function af(){return new ut({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ul(),fragmentShader:`
|
|
|
|
precision mediump float;
|
|
precision mediump int;
|
|
|
|
varying vec3 vOutputDirection;
|
|
|
|
uniform sampler2D envMap;
|
|
|
|
#include <common>
|
|
|
|
void main() {
|
|
|
|
vec3 outputDirection = normalize( vOutputDirection );
|
|
vec2 uv = equirectUv( outputDirection );
|
|
|
|
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
|
|
|
|
}
|
|
`,blending:_n,depthTest:!1,depthWrite:!1})}function lf(){return new ut({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ul(),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 ul(){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 hl=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 pr(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 <begin_vertex>
|
|
#include <project_vertex>
|
|
|
|
}
|
|
`,fragmentShader:`
|
|
|
|
uniform sampler2D tEquirect;
|
|
|
|
varying vec3 vWorldDirection;
|
|
|
|
#include <common>
|
|
|
|
void main() {
|
|
|
|
vec3 direction = normalize( vWorldDirection );
|
|
|
|
vec2 sampleUV = equirectUv( direction );
|
|
|
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
|
|
}
|
|
`},s=new Cs(5,5,5),r=new ut({name:"CubemapFromEquirect",uniforms:es(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===Ni&&(t.minFilter=Ut),new ma(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===_a||f===ya)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 hl(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===_a||f===ya,x=f===Li||f===Qi;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 cl(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 cl(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===_a?u.mapping=Li:f===ya&&(u.mapping=Qi),u}function l(u){let f=0,m=6;for(let x=0;x<m;x++)u[x]!==void 0&&f++;return f===m}function c(u){let f=u.target;f.removeEventListener("dispose",c);let m=e.get(f);m!==void 0&&(e.delete(f),m.dispose())}function h(u){let f=u.target;f.removeEventListener("dispose",h);let m=t.get(f);m!==void 0&&(t.delete(f),m.dispose())}function d(){e=new WeakMap,t=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:s,dispose:d}}function Zv(i){let e={};function t(n){if(e[n]!==void 0)return e[n];let s=i.getExtension(n);return e[n]=s,s}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){let s=t(n);return s===null&&Zo("WebGLRenderer: "+n+" extension not supported."),s}}}function $v(i,e,t,n){let s={},r=new WeakMap;function o(d){let u=d.target;u.index!==null&&e.remove(u.index);for(let m in u.attributes)e.remove(u.attributes[m]);u.removeEventListener("dispose",o),delete s[u.id];let f=r.get(u);f&&(e.remove(f),r.delete(u)),n.releaseStatesOfGeometry(u),u.isInstancedBufferGeometry===!0&&delete u._maxInstanceCount,t.memory.geometries--}function a(d,u){return s[u.id]===!0||(u.addEventListener("dispose",o),s[u.id]=!0,t.memory.geometries++),u}function l(d){let u=d.attributes;for(let f in u)e.update(u[f],i.ARRAY_BUFFER)}function c(d){let u=[],f=d.index,m=d.attributes.position,x=0;if(m===void 0)return;if(f!==null){let v=f.array;x=f.version;for(let b=0,M=v.length;b<M;b+=3){let S=v[b+0],w=v[b+1],C=v[b+2];u.push(S,w,w,C,C,S)}}else{let v=m.array;x=m.version;for(let b=0,M=v.length/3-1;b<M;b+=3){let S=b+0,w=b+1,C=b+2;u.push(S,w,w,C,C,S)}}let g=new(m.count>=65535?dr:ur)(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.version<f.version&&c(d)}else c(d);return r.get(d)}return{get:a,update:l,getWireframeAttribute:h}}function Kv(i,e,t){let n;function s(d){n=d}let r,o;function a(d){r=d.type,o=d.bytesPerElement}function l(d,u){i.drawElements(n,u,r,d*o),t.update(u,n,1)}function c(d,u,f){f!==0&&(i.drawElementsInstanced(n,u,r,d*o,f),t.update(u,n,f))}function h(d,u,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,u,0,r,d,0,f);let x=0;for(let g=0;g<f;g++)x+=u[g];t.update(x,n,1)}this.setMode=s,this.setIndex=a,this.render=l,this.renderInstances=c,this.renderMultiDraw=h}function Jv(i){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,o,a){switch(t.calls++,o){case i.TRIANGLES:t.triangles+=a*(r/3);break;case i.LINES:t.lines+=a*(r/2);break;case i.LINE_STRIP:t.lines+=a*(r-1);break;case i.LINE_LOOP:t.lines+=a*r;break;case i.POINTS:t.points+=a*r;break;default:Pe("WebGLInfo: Unknown draw mode:",o);break}}function s(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:s,update:n}}function jv(i,e,t){let n=new WeakMap,s=new vt;function r(o,a,l){let c=o.morphTargetInfluences,h=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,d=h!==void 0?h.length:0,u=n.get(a);if(u===void 0||u.count!==d){let A=function(){C.dispose(),n.delete(a),a.removeEventListener("dispose",A)};u!==void 0&&u.texture.dispose();let f=a.morphAttributes.position!==void 0,m=a.morphAttributes.normal!==void 0,x=a.morphAttributes.color!==void 0,g=a.morphAttributes.position||[],p=a.morphAttributes.normal||[],v=a.morphAttributes.color||[],b=0;f===!0&&(b=1),m===!0&&(b=2),x===!0&&(b=3);let M=a.attributes.position.count*b,S=1;M>e.maxTextureSize&&(S=Math.ceil(M/e.maxTextureSize),M=e.maxTextureSize);let w=new Float32Array(M*S*4*d),C=new cr(w,M,S,d);C.type=Pn,C.needsUpdate=!0;let _=b*4;for(let P=0;P<d;P++){let R=g[P],I=p[P],H=v[P],W=M*S*4*P;for(let F=0;F<R.count;F++){let O=F*_;f===!0&&(s.fromBufferAttribute(R,F),w[W+O+0]=s.x,w[W+O+1]=s.y,w[W+O+2]=s.z,w[W+O+3]=0),m===!0&&(s.fromBufferAttribute(I,F),w[W+O+4]=s.x,w[W+O+5]=s.y,w[W+O+6]=s.z,w[W+O+7]=0),x===!0&&(s.fromBufferAttribute(H,F),w[W+O+8]=s.x,w[W+O+9]=s.y,w[W+O+10]=s.z,w[W+O+11]=H.itemSize===4?s.w:1)}}u={count:d,texture:C,size:new Ae(M,S)},n.set(a,u),a.addEventListener("dispose",A)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)l.getUniforms().setValue(i,"morphTexture",o.morphTexture,t);else{let f=0;for(let x=0;x<c.length;x++)f+=c[x];let m=a.morphTargetsRelative?1:1-f;l.getUniforms().setValue(i,"morphTargetBaseInfluence",m),l.getUniforms().setValue(i,"morphTargetInfluences",c)}l.getUniforms().setValue(i,"morphTargetsTexture",u.texture,t),l.getUniforms().setValue(i,"morphTargetsTextureSize",u.size)}return{update:r}}function Qv(i,e,t,n,s){let r=new WeakMap;function o(c){let h=s.render.frame,d=c.geometry,u=e.get(c,d);if(r.get(u)!==h&&(e.update(u),r.set(u,h)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),r.get(c)!==h&&(t.update(c.instanceMatrix,i.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,i.ARRAY_BUFFER),r.set(c,h))),c.isSkinnedMesh){let f=c.skeleton;r.get(f)!==h&&(f.update(),r.set(f,h))}return u}function a(){r=new WeakMap}function l(c){let h=c.target;h.removeEventListener("dispose",l),n.releaseStatesOfObject(h),t.remove(h.instanceMatrix),h.instanceColor!==null&&t.remove(h.instanceColor)}return{update:o,dispose:a}}var e_={[Sr]:"LINEAR_TONE_MAPPING",[wr]:"REINHARD_TONE_MAPPING",[Er]:"CINEON_TONE_MAPPING",[Ii]:"ACES_FILMIC_TONE_MAPPING",[Ar]:"AGX_TONE_MAPPING",[Cr]:"NEUTRAL_TONE_MAPPING",[Tr]:"CUSTOM_TONE_MAPPING"};function t_(i,e,t,n,s){let r=new Ct(e,t,{type:i,depthBuffer:n,stencilBuffer:s,depthTexture:n?new oi(e,t):void 0}),o=new Ct(e,t,{type:Xt,depthBuffer:!1,stencilBuffer:!1}),a=new ht;a.setAttribute("position",new Ot([-1,3,0,-1,-1,0,3,-1,0],3)),a.setAttribute("uv",new Ot([0,2,0,0,2,0],2));let l=new Rs({uniforms:{tDiffuse:{value:null}},vertexShader:`
|
|
precision highp float;
|
|
|
|
uniform mat4 modelViewMatrix;
|
|
uniform mat4 projectionMatrix;
|
|
|
|
attribute vec3 position;
|
|
attribute vec2 uv;
|
|
|
|
varying vec2 vUv;
|
|
|
|
void main() {
|
|
vUv = uv;
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
}`,fragmentShader:`
|
|
precision highp float;
|
|
|
|
uniform sampler2D tDiffuse;
|
|
|
|
varying vec2 vUv;
|
|
|
|
#include <tonemapping_pars_fragment>
|
|
#include <colorspace_pars_fragment>
|
|
|
|
void main() {
|
|
gl_FragColor = texture2D( tDiffuse, vUv );
|
|
|
|
#ifdef LINEAR_TONE_MAPPING
|
|
gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
|
|
#elif defined( REINHARD_TONE_MAPPING )
|
|
gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
|
|
#elif defined( CINEON_TONE_MAPPING )
|
|
gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
|
|
#elif defined( ACES_FILMIC_TONE_MAPPING )
|
|
gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
|
|
#elif defined( AGX_TONE_MAPPING )
|
|
gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
|
|
#elif defined( NEUTRAL_TONE_MAPPING )
|
|
gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
|
|
#elif defined( CUSTOM_TONE_MAPPING )
|
|
gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
|
|
#endif
|
|
|
|
#ifdef SRGB_TRANSFER
|
|
gl_FragColor = sRGBTransferOETF( gl_FragColor );
|
|
#endif
|
|
}`,depthTest:!1,depthWrite:!1}),c=new 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;M<g.length;M++){let S=g[M];S.setSize&&S.setSize(v,b)}},this.setEffects=function(v){g=v,p=g.length>0&&g[0].isRenderPass===!0;let b=r.width,M=r.height;for(let S=0;S<g.length;S++){let w=g[S];w.setSize&&w.setSize(b,M)}},this.begin=function(v,b){if(f||v.toneMapping===hn&&g.length===0)return!1;if(x=b,b!==null){let M=b.width,S=b.height;(r.width!==M||r.height!==S)&&this.setSize(M,S)}return p===!1&&v.setRenderTarget(r),m=v.toneMapping,v.toneMapping=hn,!0},this.hasRenderPass=function(){return p},this.end=function(v,b){v.toneMapping=m,f=!0;let M=r,S=o;for(let w=0;w<g.length;w++){let C=g[w];if(C.enabled!==!1&&(C.render(v,S,M,b),C.needsSwap!==!1)){let _=M;M=S,S=_}}if(d!==v.outputColorSpace||u!==v.toneMapping){d=v.outputColorSpace,u=v.toneMapping,l.defines={},Ge.getTransfer(d)===je&&(l.defines.SRGB_TRANSFER="");let w=e_[u];w&&(l.defines[w]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=M.texture,v.setRenderTarget(x),v.render(c,h),x=null,f=!1},this.isCompositing=function(){return f},this.dispose=function(){r.depthTexture&&r.depthTexture.dispose(),r.dispose(),o.dispose(),a.dispose(),l.dispose()}}var Cf=new jt,Ih=new oi(1,1),Rf=new cr,Pf=new Jo,If=new pr,cf=[],hf=[],uf=new Float32Array(16),df=new Float32Array(9),ff=new Float32Array(4);function Os(i,e,t){let n=i[0];if(n<=0||n>0)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;t<n;t++)if(i[t]!==e[t])return!1;return!0}function Pt(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function dl(i,e){let t=hf[e];t===void 0&&(t=new Int32Array(e),hf[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function n_(i,e){let t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function i_(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Rt(t,e))return;i.uniform2fv(this.addr,e),Pt(t,e)}}function s_(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Rt(t,e))return;i.uniform3fv(this.addr,e),Pt(t,e)}}function r_(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Rt(t,e))return;i.uniform4fv(this.addr,e),Pt(t,e)}}function o_(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(Rt(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),Pt(t,e)}else{if(Rt(t,n))return;ff.set(n),i.uniformMatrix2fv(this.addr,!1,ff),Pt(t,n)}}function a_(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(Rt(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),Pt(t,e)}else{if(Rt(t,n))return;df.set(n),i.uniformMatrix3fv(this.addr,!1,df),Pt(t,n)}}function l_(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(Rt(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),Pt(t,e)}else{if(Rt(t,n))return;uf.set(n),i.uniformMatrix4fv(this.addr,!1,uf),Pt(t,n)}}function c_(i,e){let t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function h_(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Rt(t,e))return;i.uniform2iv(this.addr,e),Pt(t,e)}}function u_(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Rt(t,e))return;i.uniform3iv(this.addr,e),Pt(t,e)}}function d_(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Rt(t,e))return;i.uniform4iv(this.addr,e),Pt(t,e)}}function f_(i,e){let t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function p_(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Rt(t,e))return;i.uniform2uiv(this.addr,e),Pt(t,e)}}function m_(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Rt(t,e))return;i.uniform3uiv(this.addr,e),Pt(t,e)}}function g_(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Rt(t,e))return;i.uniform4uiv(this.addr,e),Pt(t,e)}}function x_(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let r;this.type===i.SAMPLER_2D_SHADOW?(Ih.compareFunction=t.isReversedDepthBuffer()?rl:sl,r=Ih):r=Cf,t.setTexture2D(e||r,s)}function v_(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture3D(e||Pf,s)}function __(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTextureCube(e||If,s)}function y_(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture2DArray(e||Rf,s)}function b_(i){switch(i){case 5126:return n_;case 35664:return i_;case 35665:return s_;case 35666:return r_;case 35674:return o_;case 35675:return a_;case 35676:return l_;case 5124:case 35670:return c_;case 35667:case 35671:return h_;case 35668:case 35672:return u_;case 35669:case 35673:return d_;case 5125:return f_;case 36294:return p_;case 36295:return m_;case 36296:return g_;case 35678:case 36198:case 36298:case 36306:case 35682:return x_;case 35679:case 36299:case 36307:return v_;case 35680:case 36300:case 36308:case 36293:return __;case 36289:case 36303:case 36311:case 36292:return y_}}function M_(i,e){i.uniform1fv(this.addr,e)}function S_(i,e){let t=Os(e,this.size,2);i.uniform2fv(this.addr,t)}function w_(i,e){let t=Os(e,this.size,3);i.uniform3fv(this.addr,t)}function E_(i,e){let t=Os(e,this.size,4);i.uniform4fv(this.addr,t)}function T_(i,e){let t=Os(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function A_(i,e){let t=Os(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function C_(i,e){let t=Os(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function R_(i,e){i.uniform1iv(this.addr,e)}function P_(i,e){i.uniform2iv(this.addr,e)}function I_(i,e){i.uniform3iv(this.addr,e)}function L_(i,e){i.uniform4iv(this.addr,e)}function N_(i,e){i.uniform1uiv(this.addr,e)}function D_(i,e){i.uniform2uiv(this.addr,e)}function F_(i,e){i.uniform3uiv(this.addr,e)}function k_(i,e){i.uniform4uiv(this.addr,e)}function O_(i,e,t){let n=this.cache,s=e.length,r=dl(t,s);Rt(n,r)||(i.uniform1iv(this.addr,r),Pt(n,r));let o;this.type===i.SAMPLER_2D_SHADOW?o=Ih:o=Cf;for(let a=0;a!==s;++a)t.setTexture2D(e[a]||o,r[a])}function U_(i,e,t){let n=this.cache,s=e.length,r=dl(t,s);Rt(n,r)||(i.uniform1iv(this.addr,r),Pt(n,r));for(let o=0;o!==s;++o)t.setTexture3D(e[o]||Pf,r[o])}function B_(i,e,t){let n=this.cache,s=e.length,r=dl(t,s);Rt(n,r)||(i.uniform1iv(this.addr,r),Pt(n,r));for(let o=0;o!==s;++o)t.setTextureCube(e[o]||If,r[o])}function z_(i,e,t){let n=this.cache,s=e.length,r=dl(t,s);Rt(n,r)||(i.uniform1iv(this.addr,r),Pt(n,r));for(let o=0;o!==s;++o)t.setTexture2DArray(e[o]||Rf,r[o])}function V_(i){switch(i){case 5126:return M_;case 35664:return S_;case 35665:return w_;case 35666:return E_;case 35674:return T_;case 35675:return A_;case 35676:return C_;case 5124:case 35670:return R_;case 35667:case 35671:return P_;case 35668:case 35672:return I_;case 35669:case 35673:return L_;case 5125:return N_;case 36294:return D_;case 36295:return F_;case 36296:return k_;case 35678:case 36198:case 36298:case 36306:case 35682:return O_;case 35679:case 36299:case 36307:return U_;case 35680:case 36300:case 36308:case 36293:return B_;case 36289:case 36303:case 36311:case 36292:return z_}}var Lh=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=b_(t.type)}},Nh=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=V_(t.type)}},Dh=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let s=this.seq;for(let r=0,o=s.length;r!==o;++r){let a=s[r];a.setValue(e,t[a.id],n)}}},Rh=/(\w+)(\])?(\[|\.)?/g;function pf(i,e){i.seq.push(e),i.map[e.id]=e}function G_(i,e,t){let n=i.name,s=n.length;for(Rh.lastIndex=0;;){let r=Rh.exec(n),o=Rh.lastIndex,a=r[1],l=r[2]==="]",c=r[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===s){pf(t,c===void 0?new Lh(a,i,e):new Nh(a,i,e));break}else{let d=t.map[a];d===void 0&&(d=new Dh(a),pf(t,d)),t=d}}}var Fs=class{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let o=0;o<n;++o){let a=e.getActiveUniform(t,o),l=e.getUniformLocation(t,a.name);G_(a,l,this)}let s=[],r=[];for(let o of this.seq)o.type===e.SAMPLER_2D_SHADOW||o.type===e.SAMPLER_CUBE_SHADOW||o.type===e.SAMPLER_2D_ARRAY_SHADOW?s.push(o):r.push(o);s.length>0&&(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<r;o++){let a=o+1;n.push(`${a===e?">":" "} ${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 or: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_={[Sr]:"Linear",[wr]:"Reinhard",[Er]:"Cineon",[Ii]:"ACESFilmic",[Ar]:"AgX",[Cr]:"Neutral",[Tr]:"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 ll=new N;function K_(){Ge.getLuminanceCoefficients(ll);let i=ll.x.toFixed(4),e=ll.y.toFixed(4),t=ll.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(Br).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<n;s++){let r=i.getActiveAttrib(e,s),o=r.name,a=1;r.type===i.FLOAT_MAT2&&(a=2),r.type===i.FLOAT_MAT3&&(a=3),r.type===i.FLOAT_MAT4&&(a=4),t[o]={type:r.type,location:i.getAttribLocation(e,o),locationSize:a}}return t}function Br(i){return i!==""}function vf(i,e){let t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function _f(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var ey=/^[ \t]*#include +<([\w\d./]+)>/gm;function Fh(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 Fh(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);r<parseInt(t);r++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function bf(i){let e=`precision ${i.precision} float;
|
|
precision ${i.precision} int;
|
|
precision ${i.precision} sampler2D;
|
|
precision ${i.precision} samplerCube;
|
|
precision ${i.precision} sampler3D;
|
|
precision ${i.precision} sampler2DArray;
|
|
precision ${i.precision} sampler2DShadow;
|
|
precision ${i.precision} samplerCubeShadow;
|
|
precision ${i.precision} sampler2DArrayShadow;
|
|
precision ${i.precision} isampler2D;
|
|
precision ${i.precision} isampler3D;
|
|
precision ${i.precision} isamplerCube;
|
|
precision ${i.precision} isampler2DArray;
|
|
precision ${i.precision} usampler2D;
|
|
precision ${i.precision} usampler3D;
|
|
precision ${i.precision} usamplerCube;
|
|
precision ${i.precision} usampler2DArray;
|
|
`;return i.precision==="highp"?e+=`
|
|
#define HIGH_PRECISION`:i.precision==="mediump"?e+=`
|
|
#define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
|
|
#define LOW_PRECISION`),e}var ry={[br]:"SHADOWMAP_TYPE_PCF",[Ps]:"SHADOWMAP_TYPE_VSM"};function oy(i){return ry[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var ay={[Li]:"ENVMAP_TYPE_CUBE",[Qi]:"ENVMAP_TYPE_CUBE",[Rr]:"ENVMAP_TYPE_CUBE_UV"};function ly(i){return i.envMap===!1?"ENVMAP_TYPE_CUBE":ay[i.envMapMode]||"ENVMAP_TYPE_CUBE"}var cy={[Qi]:"ENVMAP_MODE_REFRACTION"};function hy(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":cy[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}var uy={[ih]:"ENVMAP_BLENDING_MULTIPLY",[zd]:"ENVMAP_BLENDING_MIX",[Vd]:"ENVMAP_BLENDING_ADD"};function dy(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":uy[i.combine]||"ENVMAP_BLENDING_NONE"}function fy(i){let e=i.envMapCubeUVHeight;if(e===null)return null;let t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:n,maxMip:t}}function py(i,e,t,n){let s=i.getContext(),r=t.defines,o=t.vertexShader,a=t.fragmentShader,l=oy(t),c=ly(t),h=hy(t),d=dy(t),u=fy(t),f=J_(t),m=j_(r),x=s.createProgram(),g,p,v=t.glslVersion?"#version "+t.glslVersion+`
|
|
`:"";t.isRawShaderMaterial?(g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(Br).join(`
|
|
`),g.length>0&&(g+=`
|
|
`),p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(Br).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(Br).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(Br).join(`
|
|
`)),o=Fh(o),o=vf(o,t),o=_f(o,t),a=Fh(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===fh?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===fh?"":"#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");Pe("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 Fs(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,kh=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 Oh(e),t.set(e,n)),n}},Oh=class{constructor(e){this.id=my++,this.code=e,this.usedTimes=0}};function gy(i){return i===Fi||i===Fr||i===kr}function xy(i,e,t,n,s,r){let o=new hr,a=new kh,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===Rr?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(),Re=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===dh,packedNormalMap:pt&&_.normalMapType===dh&&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===Ki&&_.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:Re,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<f;u++){let m=i[u];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:t,transmissive:n,transparent:s,init:r,push:l,unshift:c,finish:d,sort:h}}function yy(){let i=new WeakMap;function e(n,s){let r=i.get(n),o;return r===void 0?(o=new Sf,i.set(n,[o])):s>=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;A<P;A++){let R=c[A],I=R.color,H=R.intensity,W=R.distance,F=null;if(R.shadow&&R.shadow.map&&(R.shadow.map.texture.format===Fi?F=R.shadow.map.texture:F=R.shadow.map.depthTexture||R.shadow.map.texture),R.isAmbientLight)h+=I.r*H,d+=I.g*H,u+=I.b*H;else if(R.isLightProbe){for(let O=0;O<9;O++)n.probe[O].addScaledVector(R.sh.coefficients[O],H);C++}else if(R.isDirectionalLight){let O=e.get(R);if(O.color.copy(R.color).multiplyScalar(R.intensity),R.castShadow){let U=R.shadow,J=t.get(R);J.shadowIntensity=U.intensity,J.shadowBias=U.bias,J.shadowNormalBias=U.normalBias,J.shadowRadius=U.radius,J.shadowMapSize=U.mapSize,n.directionalShadow[f]=J,n.directionalShadowMap[f]=F,n.directionalShadowMatrix[f]=R.shadow.matrix,v++}n.directional[f]=O,f++}else if(R.isSpotLight){let O=e.get(R);O.position.setFromMatrixPosition(R.matrixWorld),O.color.copy(I).multiplyScalar(H),O.distance=W,O.coneCos=Math.cos(R.angle),O.penumbraCos=Math.cos(R.angle*(1-R.penumbra)),O.decay=R.decay,n.spot[x]=O;let U=R.shadow;if(R.map&&(n.spotLightMap[S]=R.map,S++,U.updateMatrices(R),R.castShadow&&w++),n.spotLightMatrix[x]=U.matrix,R.castShadow){let J=t.get(R);J.shadowIntensity=U.intensity,J.shadowBias=U.bias,J.shadowNormalBias=U.normalBias,J.shadowRadius=U.radius,J.shadowMapSize=U.mapSize,n.spotShadow[x]=J,n.spotShadowMap[x]=F,M++}x++}else if(R.isRectAreaLight){let O=e.get(R);O.color.copy(I).multiplyScalar(H),O.halfWidth.set(R.width*.5,0,0),O.halfHeight.set(0,R.height*.5,0),n.rectArea[g]=O,g++}else if(R.isPointLight){let O=e.get(R);if(O.color.copy(R.color).multiplyScalar(R.intensity),O.distance=R.distance,O.decay=R.decay,R.castShadow){let U=R.shadow,J=t.get(R);J.shadowIntensity=U.intensity,J.shadowBias=U.bias,J.shadowNormalBias=U.normalBias,J.shadowRadius=U.radius,J.shadowMapSize=U.mapSize,J.shadowCameraNear=U.camera.near,J.shadowCameraFar=U.camera.far,n.pointShadow[m]=J,n.pointShadowMap[m]=F,n.pointShadowMatrix[m]=R.shadow.matrix,b++}n.point[m]=O,m++}else if(R.isHemisphereLight){let O=e.get(R);O.skyColor.copy(R.color).multiplyScalar(H),O.groundColor.copy(R.groundColor).multiplyScalar(H),n.hemi[p]=O,p++}}g>0&&(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<v;p++){let b=c[p];if(b.isDirectionalLight){let M=n.directional[d];M.direction.setFromMatrixPosition(b.matrixWorld),s.setFromMatrixPosition(b.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(g),d++}else if(b.isSpotLight){let M=n.spot[f];M.position.setFromMatrixPosition(b.matrixWorld),M.position.applyMatrix4(g),M.direction.setFromMatrixPosition(b.matrixWorld),s.setFromMatrixPosition(b.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(g),f++}else if(b.isRectAreaLight){let M=n.rectArea[m];M.position.setFromMatrixPosition(b.matrixWorld),M.position.applyMatrix4(g),o.identity(),r.copy(b.matrixWorld),r.premultiply(g),o.extractRotation(r),M.halfWidth.set(b.width*.5,0,0),M.halfHeight.set(0,b.height*.5,0),M.halfWidth.applyMatrix4(o),M.halfHeight.applyMatrix4(o),m++}else if(b.isPointLight){let M=n.point[u];M.position.setFromMatrixPosition(b.matrixWorld),M.position.applyMatrix4(g),u++}else if(b.isHemisphereLight){let M=n.hemi[x];M.direction.setFromMatrixPosition(b.matrixWorld),M.direction.transformDirection(g),x++}}}return{setup:a,setupView:l,state:n}}function wf(i){let e=new Ey(i),t=[],n=[],s=[];function r(u){d.camera=u,t.length=0,n.length=0,s.length=0}function o(u){t.push(u)}function a(u){n.push(u)}function l(u){s.push(u)}function c(){e.setup(t)}function h(u){e.setupView(t,u)}let d={lightsArray:t,shadowsArray:n,lightProbeGridArray:s,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:d,setupLights:c,setupLightsView:h,pushLight:o,pushShadow:a,pushLightProbeGrid:l}}function Ty(i){let e=new WeakMap;function t(s,r=0){let o=e.get(s),a;return o===void 0?(a=new wf(i),e.set(s,[a])):r>=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,Ur=new N,Ph=new N;function Iy(i,e,t){let n=new fr,s=new Ae,r=new Ae,o=new vt,a=new ia,l=new sa,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=br;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=br);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;W<F;W++){let O=w[W],U=O.shadow;if(U===void 0){Te("WebGLShadowMap:",O,"has no shadow.");continue}if(U.autoUpdate===!1&&U.needsUpdate===!1)continue;s.copy(U.mapSize);let J=U.getFrameExtents();s.multiply(J),r.copy(U.mapSize),(s.x>h||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===Ps){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:Fi,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 hl(s.x),U.map.depthTexture=new na(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===br?(U.map.depthTexture.compareFunction=ee?rl:sl,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;ye<le;ye++){if(U.map.isWebGLCubeRenderTarget)i.setRenderTarget(U.map,ye),i.clear();else{ye===0&&(i.setRenderTarget(U.map),i.clear());let Me=U.getViewport(ye);o.set(r.x*Me.x,r.y*Me.y,r.x*Me.z,r.y*Me.w),I.viewport(o)}if(O.isPointLight){let Me=U.camera,Ze=U.matrix,Ke=O.distance||Me.far;Ke!==Me.far&&(Me.far=Ke,Me.updateProjectionMatrix()),Ur.setFromMatrixPosition(O.matrixWorld),Me.position.copy(Ur),Ph.copy(Me.position),Ph.add(Ry[ye]),Me.up.copy(Py[ye]),Me.lookAt(Ph),Me.updateMatrixWorld(),Ze.makeTranslation(-Ur.x,-Ur.y,-Ur.z),Ef.multiplyMatrices(Me.projectionMatrix,Me.matrixWorldInverse),U._frustum.setFromProjectionMatrix(Ef,Me.coordinateSystem,Me.reversedDepth)}else U.updateMatrices(O);n=U.getFrustum(),M(C,_,U.camera,O,this.type)}U.isPointLightShadow!==!0&&this.type===Ps&&v(U,_),U.needsUpdate=!1}p=this.type,g.needsUpdate=!1,i.setRenderTarget(A,P,R)};function v(w,C){let _=e.update(x);u.defines.VSM_SAMPLES!==w.blurSamples&&(u.defines.VSM_SAMPLES=w.blurSamples,f.defines.VSM_SAMPLES=w.blurSamples,u.needsUpdate=!0,f.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new Ct(s.x,s.y,{format:Fi,type:Xt})),u.uniforms.shadow_pass.value=w.map.depthTexture,u.uniforms.resolution.value=w.mapSize,u.uniforms.radius.value=w.radius,i.setRenderTarget(w.mapPass),i.clear(),i.renderBufferDirect(C,null,_,u,x,null),f.uniforms.shadow_pass.value=w.mapPass.texture,f.uniforms.resolution.value=w.mapSize,f.uniforms.radius.value=w.radius,i.setRenderTarget(w.map),i.clear(),i.renderBufferDirect(C,null,_,f,x,null)}function b(w,C,_,A){let P=null,R=_.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(R!==void 0)P=R;else if(P=_.isPointLight===!0?l:a,i.localClippingEnabled&&C.clipShadows===!0&&Array.isArray(C.clippingPlanes)&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0||C.map&&C.alphaTest>0||C.alphaToCoverage===!0){let 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===Ps?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===Ps)&&(!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<U;O++){let J=F[O],ee=W[J.materialIndex];if(ee&&ee.visible){let le=b(w,ee,A,P);w.onBeforeShadow(i,w,C,_,H,le,J),i.renderBufferDirect(_,null,H,le,w,J),w.onAfterShadow(i,w,C,_,H,le,J)}}}else if(W.visible){let F=b(w,W,A,P);w.onBeforeShadow(i,w,C,_,H,F,null),i.renderBufferDirect(_,null,H,F,w,null),w.onAfterShadow(i,w,C,_,H,F,null)}}let I=w.children;for(let H=0,W=I.length;H<W;H++)M(I[H],C,_,A,P)}function S(w){w.target.removeEventListener("dispose",S);for(let _ in c){let A=c[_],P=w.target.uuid;P in A&&(A[P].dispose(),delete A[P])}}}function Ly(i,e){function t(){let L=!1,ie=new vt,q=null,me=new vt(0,0,0,0);return{setMask:function(oe){q!==oe&&!L&&(i.colorMask(oe,oe,oe,oe),q=oe)},setLocked:function(oe){L=oe},setClear:function(oe,j,Se,Oe,bt){bt===!0&&(oe*=Oe,j*=Oe,Se*=Oe),ie.set(oe,j,Se,Oe),me.equals(ie)===!1&&(i.clearColor(oe,j,Se,Oe),me.copy(ie))},reset:function(){L=!1,q=null,me.set(-1,0,0,0)}}}function n(){let L=!1,ie=!1,q=null,me=null,oe=null;return{setReversed:function(j){if(ie!==j){let Se=e.get("EXT_clip_control");j?Se.clipControlEXT(Se.LOWER_LEFT_EXT,Se.ZERO_TO_ONE_EXT):Se.clipControlEXT(Se.LOWER_LEFT_EXT,Se.NEGATIVE_ONE_TO_ONE_EXT),ie=j;let Oe=oe;oe=null,this.setClear(Oe)}},getReversed:function(){return ie},setTest:function(j){j?se(i.DEPTH_TEST):Re(i.DEPTH_TEST)},setMask:function(j){q!==j&&!L&&(i.depthMask(j),q=j)},setFunc:function(j){if(ie&&(j=ef[j]),me!==j){switch(j){case Uo:i.depthFunc(i.NEVER);break;case Bo:i.depthFunc(i.ALWAYS);break;case zo:i.depthFunc(i.LESS);break;case Ji:i.depthFunc(i.LEQUAL);break;case Vo:i.depthFunc(i.EQUAL);break;case Go:i.depthFunc(i.GEQUAL);break;case Ho:i.depthFunc(i.GREATER);break;case Wo:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}me=j}},setLocked:function(j){L=j},setClear:function(j){oe!==j&&(oe=j,ie&&(j=1-j),i.clearDepth(j))},reset:function(){L=!1,q=null,me=null,oe=null,ie=!1}}}function s(){let L=!1,ie=null,q=null,me=null,oe=null,j=null,Se=null,Oe=null,bt=null;return{setTest:function(nt){L||(nt?se(i.STENCIL_TEST):Re(i.STENCIL_TEST))},setMask:function(nt){ie!==nt&&!L&&(i.stencilMask(nt),ie=nt)},setFunc:function(nt,qn,Nn){(q!==nt||me!==qn||oe!==Nn)&&(i.stencilFunc(nt,qn,Nn),q=nt,me=qn,oe=Nn)},setOp:function(nt,qn,Nn){(j!==nt||Se!==qn||Oe!==Nn)&&(i.stencilOp(nt,qn,Nn),j=nt,Se=qn,Oe=Nn)},setLocked:function(nt){L=nt},setClear:function(nt){bt!==nt&&(i.clearStencil(nt),bt=nt)},reset:function(){L=!1,ie=null,q=null,me=null,oe=null,j=null,Se=null,Oe=null,bt=null}}}let r=new t,o=new n,a=new s,l=new WeakMap,c=new WeakMap,h={},d={},u={},f=new WeakMap,m=[],x=null,g=!1,p=null,v=null,b=null,M=null,S=null,w=null,C=null,_=new ge(0,0,0),A=0,P=!1,R=null,I=null,H=null,W=null,F=null,O=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS),U=!1,J=0,ee=i.getParameter(i.VERSION);ee.indexOf("WebGL")!==-1?(J=parseFloat(/^WebGL (\d)/.exec(ee)[1]),U=J>=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<q;Se++)L===i.TEXTURE_3D||L===i.TEXTURE_2D_ARRAY?i.texImage3D(ie,0,i.RGBA,1,1,me,0,i.RGBA,i.UNSIGNED_BYTE,oe):i.texImage2D(ie+Se,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,oe);return j}let fe={};fe[i.TEXTURE_2D]=Z(i.TEXTURE_2D,i.TEXTURE_2D,1),fe[i.TEXTURE_CUBE_MAP]=Z(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),fe[i.TEXTURE_2D_ARRAY]=Z(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),fe[i.TEXTURE_3D]=Z(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),o.setClear(1),a.setClear(0),se(i.DEPTH_TEST),o.setFunc(Ji),Et(!1),pt(eh),se(i.CULL_FACE),lt(_n);function se(L){h[L]!==!0&&(i.enable(L),h[L]=!0)}function Re(L){h[L]!==!1&&(i.disable(L),h[L]=!1)}function ke(L,ie){return u[L]!==ie?(i.bindFramebuffer(L,ie),u[L]=ie,L===i.DRAW_FRAMEBUFFER&&(u[i.FRAMEBUFFER]=ie),L===i.FRAMEBUFFER&&(u[i.DRAW_FRAMEBUFFER]=ie),!0):!1}function Ie(L,ie){let q=m,me=!1;if(L){q=f.get(ie),q===void 0&&(q=[],f.set(ie,q));let oe=L.textures;if(q.length!==oe.length||q[0]!==i.COLOR_ATTACHMENT0){for(let j=0,Se=oe.length;j<Se;j++)q[j]=i.COLOR_ATTACHMENT0+j;q.length=oe.length,me=!0}}else q[0]!==i.BACK&&(q[0]=i.BACK,me=!0);me&&i.drawBuffers(q)}function ft(L){return x!==L?(i.useProgram(L),x=L,!0):!1}let Xe={[Si]:i.FUNC_ADD,[Sd]:i.FUNC_SUBTRACT,[wd]:i.FUNC_REVERSE_SUBTRACT};Xe[Ed]=i.MIN,Xe[Td]=i.MAX;let tt={[Ad]:i.ZERO,[Cd]:i.ONE,[Rd]:i.SRC_COLOR,[ko]:i.SRC_ALPHA,[Fd]:i.SRC_ALPHA_SATURATE,[Nd]:i.DST_COLOR,[Id]:i.DST_ALPHA,[Pd]:i.ONE_MINUS_SRC_COLOR,[Oo]:i.ONE_MINUS_SRC_ALPHA,[Dd]:i.ONE_MINUS_DST_COLOR,[Ld]:i.ONE_MINUS_DST_ALPHA,[kd]:i.CONSTANT_COLOR,[Od]:i.ONE_MINUS_CONSTANT_COLOR,[Ud]:i.CONSTANT_ALPHA,[Bd]:i.ONE_MINUS_CONSTANT_ALPHA};function lt(L,ie,q,me,oe,j,Se,Oe,bt,nt){if(L===_n){g===!0&&(Re(i.BLEND),g=!1);return}if(g===!1&&(se(i.BLEND),g=!0),L!==Md){if(L!==p||nt!==P){if((v!==Si||S!==Si)&&(i.blendEquation(i.FUNC_ADD),v=Si,S=Si),nt)switch(L){case Ki:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Mr:i.blendFunc(i.ONE,i.ONE);break;case th:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case nh:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:Pe("WebGLState: Invalid blending: ",L);break}else switch(L){case Ki:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Mr:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case th:Pe("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case nh:Pe("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Pe("WebGLState: Invalid blending: ",L);break}b=null,M=null,w=null,C=null,_.set(0,0,0),A=0,p=L,P=nt}return}oe=oe||ie,j=j||q,Se=Se||me,(ie!==v||oe!==S)&&(i.blendEquationSeparate(Xe[ie],Xe[oe]),v=ie,S=oe),(q!==b||me!==M||j!==w||Se!==C)&&(i.blendFuncSeparate(tt[q],tt[me],tt[j],tt[Se]),b=q,M=me,w=j,C=Se),(Oe.equals(_)===!1||bt!==A)&&(i.blendColor(Oe.r,Oe.g,Oe.b,bt),_.copy(Oe),A=bt),p=L,P=!1}function We(L,ie){L.side===Hn?Re(i.CULL_FACE):se(i.CULL_FACE);let q=L.side===$t;ie&&(q=!q),Et(q),L.blending===Ki&&L.transparent===!1?lt(_n):lt(L.blending,L.blendEquation,L.blendSrc,L.blendDst,L.blendEquationAlpha,L.blendSrcAlpha,L.blendDstAlpha,L.blendColor,L.blendAlpha,L.premultipliedAlpha),o.setFunc(L.depthFunc),o.setTest(L.depthTest),o.setMask(L.depthWrite),r.setMask(L.colorWrite);let me=L.stencilWrite;a.setTest(me),me&&(a.setMask(L.stencilWriteMask),a.setFunc(L.stencilFunc,L.stencilRef,L.stencilFuncMask),a.setOp(L.stencilFail,L.stencilZFail,L.stencilZPass)),D(L.polygonOffset,L.polygonOffsetFactor,L.polygonOffsetUnits),L.alphaToCoverage===!0?se(i.SAMPLE_ALPHA_TO_COVERAGE):Re(i.SAMPLE_ALPHA_TO_COVERAGE)}function Et(L){R!==L&&(L?i.frontFace(i.CW):i.frontFace(i.CCW),R=L)}function pt(L){L!==_d?(se(i.CULL_FACE),L!==I&&(L===eh?i.cullFace(i.BACK):L===yd?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):Re(i.CULL_FACE),I=L}function tn(L){L!==H&&(U&&i.lineWidth(L),H=L)}function D(L,ie,q){L?(se(i.POLYGON_OFFSET_FILL),(W!==ie||F!==q)&&(W=ie,F=q,o.getReversed()&&(ie=-ie),i.polygonOffset(ie,q))):Re(i.POLYGON_OFFSET_FILL)}function Tt(L){L?se(i.SCISSOR_TEST):Re(i.SCISSOR_TEST)}function qe(L){L===void 0&&(L=i.TEXTURE0+O-1),le!==L&&(i.activeTexture(L),le=L)}function ot(L,ie,q){q===void 0&&(le===null?q=i.TEXTURE0+O-1:q=le);let me=ye[q];me===void 0&&(me={type:void 0,texture:void 0},ye[q]=me),(me.type!==L||me.texture!==ie)&&(le!==q&&(i.activeTexture(q),le=q),i.bindTexture(L,ie||fe[L]),me.type=L,me.texture=ie)}function ce(){let L=ye[le];L!==void 0&&L.type!==void 0&&(i.bindTexture(L.type,null),L.type=void 0,L.texture=void 0)}function mt(){try{i.compressedTexImage2D(...arguments)}catch(L){Pe("WebGLState:",L)}}function T(){try{i.compressedTexImage3D(...arguments)}catch(L){Pe("WebGLState:",L)}}function y(){try{i.texSubImage2D(...arguments)}catch(L){Pe("WebGLState:",L)}}function B(){try{i.texSubImage3D(...arguments)}catch(L){Pe("WebGLState:",L)}}function $(){try{i.compressedTexSubImage2D(...arguments)}catch(L){Pe("WebGLState:",L)}}function Q(){try{i.compressedTexSubImage3D(...arguments)}catch(L){Pe("WebGLState:",L)}}function te(){try{i.texStorage2D(...arguments)}catch(L){Pe("WebGLState:",L)}}function ae(){try{i.texStorage3D(...arguments)}catch(L){Pe("WebGLState:",L)}}function X(){try{i.texImage2D(...arguments)}catch(L){Pe("WebGLState:",L)}}function K(){try{i.texImage3D(...arguments)}catch(L){Pe("WebGLState:",L)}}function pe(L){return d[L]!==void 0?d[L]:i.getParameter(L)}function ve(L,ie){d[L]!==ie&&(i.pixelStorei(L,ie),d[L]=ie)}function re(L){Ke.equals(L)===!1&&(i.scissor(L.x,L.y,L.z,L.w),Ke.copy(L))}function ne(L){Fe.equals(L)===!1&&(i.viewport(L.x,L.y,L.z,L.w),Fe.copy(L))}function Ne(L,ie){let q=c.get(ie);q===void 0&&(q=new WeakMap,c.set(ie,q));let me=q.get(L);me===void 0&&(me=i.getUniformBlockIndex(ie,L.name),q.set(L,me))}function Be(L,ie){let me=c.get(ie).get(L);l.get(ie)!==me&&(i.uniformBlockBinding(ie,me,L.__bindingPointIndex),l.set(ie,me))}function Je(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),o.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),i.pixelStorei(i.PACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.BROWSER_DEFAULT_WEBGL),i.pixelStorei(i.PACK_ROW_LENGTH,0),i.pixelStorei(i.PACK_SKIP_PIXELS,0),i.pixelStorei(i.PACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_ROW_LENGTH,0),i.pixelStorei(i.UNPACK_IMAGE_HEIGHT,0),i.pixelStorei(i.UNPACK_SKIP_PIXELS,0),i.pixelStorei(i.UNPACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_SKIP_IMAGES,0),h={},d={},le=null,ye={},u={},f=new WeakMap,m=[],x=null,g=!1,p=null,v=null,b=null,M=null,S=null,w=null,C=null,_=new ge(0,0,0),A=0,P=!1,R=null,I=null,H=null,W=null,F=null,Ke.set(0,0,i.canvas.width,i.canvas.height),Fe.set(0,0,i.canvas.width,i.canvas.height),r.reset(),o.reset(),a.reset()}return{buffers:{color:r,depth:o,stencil:a},enable:se,disable:Re,bindFramebuffer:ke,drawBuffers:Ie,useProgram:ft,setBlending:lt,setMaterial:We,setFlipSided:Et,setCullFace:pt,setLineWidth:tn,setPolygonOffset:D,setScissorTest:Tt,activeTexture:qe,bindTexture:ot,unbindTexture:ce,compressedTexImage2D:mt,compressedTexImage3D:T,texImage2D:X,texImage3D:K,pixelStorei:ve,getParameter:pe,updateUBOMapping:Ne,uniformBlockBinding:Be,texStorage2D:te,texStorage3D:ae,texSubImage2D:y,texSubImage3D:B,compressedTexSubImage2D:$,compressedTexSubImage3D:Q,scissor:re,viewport:ne,reset:Je}}function Ny(i,e,t,n,s,r,o){let a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new 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):lr("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?or: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===Ls?B=i.DEPTH24_STENCIL8:y===Pn?B=i.DEPTH32F_STENCIL8:y===Is&&(B=i.DEPTH24_STENCIL8,Te("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):y===null||y===Rn||y===Ls?B=i.DEPTH_COMPONENT24:y===Pn?B=i.DEPTH_COMPONENT32F:y===Is&&(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<y.__webglFramebuffer[$].length;Q++)i.deleteFramebuffer(y.__webglFramebuffer[$][Q]);else i.deleteFramebuffer(y.__webglFramebuffer[$]);y.__webglDepthbuffer&&i.deleteRenderbuffer(y.__webglDepthbuffer[$])}else{if(Array.isArray(y.__webglFramebuffer))for(let $=0;$<y.__webglFramebuffer.length;$++)i.deleteFramebuffer(y.__webglFramebuffer[$]);else i.deleteFramebuffer(y.__webglFramebuffer);if(y.__webglDepthbuffer&&i.deleteRenderbuffer(y.__webglDepthbuffer),y.__webglMultisampledFramebuffer&&i.deleteFramebuffer(y.__webglMultisampledFramebuffer),y.__webglColorRenderbuffer)for(let $=0;$<y.__webglColorRenderbuffer.length;$++)y.__webglColorRenderbuffer[$]&&i.deleteRenderbuffer(y.__webglColorRenderbuffer[$]);y.__webglDepthRenderbuffer&&i.deleteRenderbuffer(y.__webglDepthRenderbuffer)}let B=T.textures;for(let $=0,Q=B.length;$<Q;$++){let te=n.get(B[$]);te.__webglTexture&&(i.deleteTexture(te.__webglTexture),o.memory.textures--),n.remove(B[$])}n.remove(T)}let I=0;function H(){I=0}function W(){return I}function F(T){I=T}function O(){let T=I;return T>=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{Re(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){Re(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){Re(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={[Xo]:i.REPEAT,[Un]:i.CLAMP_TO_EDGE,[qo]:i.MIRRORED_REPEAT},Ze={[Lt]:i.NEAREST,[Gd]:i.NEAREST_MIPMAP_NEAREST,[Pr]:i.NEAREST_MIPMAP_LINEAR,[Ut]:i.LINEAR,[ba]:i.LINEAR_MIPMAP_NEAREST,[Ni]:i.LINEAR_MIPMAP_LINEAR},Ke={[Xd]:i.NEVER,[Kd]:i.ALWAYS,[qd]:i.LESS,[sl]:i.LEQUAL,[Yd]:i.EQUAL,[rl]: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===ba||y.magFilter===Pr||y.magFilter===Ni||y.minFilter===Ut||y.minFilter===ba||y.minFilter===Pr||y.minFilter===Ni)&&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!==Pr&&y.minFilter!==Ni||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;ve<te.length;ve++){let re=te[ae],ne=te[ve],Ne=re.start+re.count,Be=fe(ne.start,y.width,4),Je=fe(re.start,y.width,4);ne.start<=Ne+1&&Be===Je&&fe(ne.start+ne.count-1,y.width,4)===Be?re.count=Math.max(re.count,ne.start+ne.count-re.start):(++ae,te[ae]=ne)}te.length=ae+1;let X=t.getParameter(i.UNPACK_ROW_LENGTH),K=t.getParameter(i.UNPACK_SKIP_PIXELS),pe=t.getParameter(i.UNPACK_SKIP_ROWS);t.pixelStorei(i.UNPACK_ROW_LENGTH,y.width);for(let ve=0,re=te.length;ve<re;ve++){let ne=te[ve],Ne=Math.floor(ne.start/4),Be=Math.ceil(ne.count/4),Je=Ne%y.width,L=Math.floor(Ne/y.width),ie=Be,q=1;t.pixelStorei(i.UNPACK_SKIP_PIXELS,Je),t.pixelStorei(i.UNPACK_SKIP_ROWS,L),t.texSubImage2D(i.TEXTURE_2D,0,Je,L,ie,q,B,$,y.data)}T.clearUpdateRanges(),t.pixelStorei(i.UNPACK_ROW_LENGTH,X),t.pixelStorei(i.UNPACK_SKIP_PIXELS,K),t.pixelStorei(i.UNPACK_SKIP_ROWS,pe)}}function Re(T,y,B){let $=i.TEXTURE_2D;(y.isDataArrayTexture||y.isCompressedArrayTexture)&&($=i.TEXTURE_2D_ARRAY),y.isData3DTexture&&($=i.TEXTURE_3D);let Q=Z(T,y),te=y.source;t.bindTexture($,T.__webglTexture,i.TEXTURE0+B);let ae=n.get(te);if(te.version!==ae.__version||Q===!0){if(t.activeTexture(i.TEXTURE0+B),(typeof ImageBitmap<"u"&&y.image instanceof ImageBitmap)===!1){let q=Ge.getPrimaries(Ge.workingColorSpace),me=y.colorSpace===li?null:Ge.getPrimaries(y.colorSpace),oe=y.colorSpace===li||q===me?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,y.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,oe)}t.pixelStorei(i.UNPACK_ALIGNMENT,y.unpackAlignment);let K=g(y.image,!1,s.maxTextureSize);K=ce(y,K);let pe=r.convert(y.format,y.colorSpace),ve=r.convert(y.type),re=M(y.internalFormat,pe,ve,y.normalized,y.colorSpace,y.isVideoTexture);Fe($,y);let ne,Ne=y.mipmaps,Be=y.isVideoTexture!==!0,Je=ae.__version===void 0||Q===!0,L=te.dataReady,ie=w(y,K);if(y.isDepthTexture)re=S(y.format===Di,y.type),Je&&(Be?t.texStorage2D(i.TEXTURE_2D,1,re,K.width,K.height):t.texImage2D(i.TEXTURE_2D,0,re,K.width,K.height,0,pe,ve,null));else if(y.isDataTexture)if(Ne.length>0){Be&&Je&&t.texStorage2D(i.TEXTURE_2D,ie,re,Ne[0].width,Ne[0].height);for(let q=0,me=Ne.length;q<me;q++)ne=Ne[q],Be?L&&t.texSubImage2D(i.TEXTURE_2D,q,0,0,ne.width,ne.height,pe,ve,ne.data):t.texImage2D(i.TEXTURE_2D,q,re,ne.width,ne.height,0,pe,ve,ne.data);y.generateMipmaps=!1}else Be?(Je&&t.texStorage2D(i.TEXTURE_2D,ie,re,K.width,K.height),L&&se(y,K,pe,ve)):t.texImage2D(i.TEXTURE_2D,0,re,K.width,K.height,0,pe,ve,K.data);else if(y.isCompressedTexture)if(y.isCompressedArrayTexture){Be&&Je&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ie,re,Ne[0].width,Ne[0].height,K.depth);for(let q=0,me=Ne.length;q<me;q++)if(ne=Ne[q],y.format!==yn)if(pe!==null)if(Be){if(L)if(y.layerUpdates.size>0){let oe=_h(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;q<me;q++)ne=Ne[q],y.format!==yn?pe!==null?Be?L&&t.compressedTexSubImage2D(i.TEXTURE_2D,q,0,0,ne.width,ne.height,pe,ne.data):t.compressedTexImage2D(i.TEXTURE_2D,q,re,ne.width,ne.height,0,ne.data):Te("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Be?L&&t.texSubImage2D(i.TEXTURE_2D,q,0,0,ne.width,ne.height,pe,ve,ne.data):t.texImage2D(i.TEXTURE_2D,q,re,ne.width,ne.height,0,pe,ve,ne.data)}else if(y.isDataArrayTexture)if(Be){if(Je&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ie,re,K.width,K.height,K.depth),L)if(y.layerUpdates.size>0){let q=_h(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<ie;oe++)t.texImage2D(i.TEXTURE_2D,oe,re,q,me,0,pe,ve,null),q>>=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;q<me;q++)ne=Ne[q],Be?L&&t.texSubImage2D(i.TEXTURE_2D,q,0,0,pe,ve,ne):t.texImage2D(i.TEXTURE_2D,q,re,pe,ve,ne);y.generateMipmaps=!1}else if(Be){if(Je){let q=mt(K);t.texStorage2D(i.TEXTURE_2D,ie,re,q.width,q.height)}L&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,pe,ve,K)}else t.texImage2D(i.TEXTURE_2D,0,re,pe,ve,K);p(y)&&v($),ae.__version=te.version,y.onUpdate&&y.onUpdate(y)}T.__version=y.version}function ke(T,y,B){if(y.image.length!==6)return;let $=Z(T,y),Q=y.source;t.bindTexture(i.TEXTURE_CUBE_MAP,T.__webglTexture,i.TEXTURE0+B);let te=n.get(Q);if(Q.version!==te.__version||$===!0){t.activeTexture(i.TEXTURE0+B);let ae=Ge.getPrimaries(Ge.workingColorSpace),X=y.colorSpace===li?null:Ge.getPrimaries(y.colorSpace),K=y.colorSpace===li||ae===X?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,y.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),t.pixelStorei(i.UNPACK_ALIGNMENT,y.unpackAlignment),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,K);let pe=y.isCompressedTexture||y.image[0].isCompressedTexture,ve=y.image[0]&&y.image[0].isDataTexture,re=[];for(let j=0;j<6;j++)!pe&&!ve?re[j]=g(y.image[j],!0,s.maxCubemapSize):re[j]=ve?y.image[j].image:y.image[j],re[j]=ce(y,re[j]);let ne=re[0],Ne=r.convert(y.format,y.colorSpace),Be=r.convert(y.type),Je=M(y.internalFormat,Ne,Be,y.normalized,y.colorSpace),L=y.isVideoTexture!==!0,ie=te.__version===void 0||$===!0,q=Q.dataReady,me=w(y,ne);Fe(i.TEXTURE_CUBE_MAP,y);let oe;if(pe){L&&ie&&t.texStorage2D(i.TEXTURE_CUBE_MAP,me,Je,ne.width,ne.height);for(let j=0;j<6;j++){oe=re[j].mipmaps;for(let Se=0;Se<oe.length;Se++){let Oe=oe[Se];y.format!==yn?Ne!==null?L?q&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Se,0,0,Oe.width,Oe.height,Ne,Oe.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Se,Je,Oe.width,Oe.height,0,Oe.data):Te("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):L?q&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Se,0,0,Oe.width,Oe.height,Ne,Be,Oe.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Se,Je,Oe.width,Oe.height,0,Ne,Be,Oe.data)}}}else{if(oe=y.mipmaps,L&&ie){oe.length>0&&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<oe.length;Se++){let bt=oe[Se].image[j].image;L?q&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Se+1,0,0,bt.width,bt.height,Ne,Be,bt.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Se+1,Je,bt.width,bt.height,0,Ne,Be,bt.data)}}else{L?q&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,0,0,Ne,Be,re[j]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,Je,Ne,Be,re[j]);for(let Se=0;Se<oe.length;Se++){let Oe=oe[Se];L?q&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Se+1,0,0,Ne,Be,Oe.image[j]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Se+1,Je,Ne,Be,Oe.image[j])}}}p(y)&&v(i.TEXTURE_CUBE_MAP),te.__version=Q.version,y.onUpdate&&y.onUpdate(y)}T.__version=y.version}function Ie(T,y,B,$,Q,te){let ae=r.convert(B.format,B.colorSpace),X=r.convert(B.type),K=M(B.internalFormat,ae,X,B.normalized,B.colorSpace),pe=n.get(y),ve=n.get(B);if(ve.__renderTarget=y,!pe.__hasExternalTextures){let re=Math.max(1,y.width>>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===Di&&(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===Di?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===Di)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;K<y.mipmaps.length;K++)B.__webglFramebuffer[X][K]=i.createFramebuffer()}else B.__webglFramebuffer[X]=i.createFramebuffer()}else{if(y.mipmaps&&y.mipmaps.length>0){B.__webglFramebuffer=[];for(let X=0;X<y.mipmaps.length;X++)B.__webglFramebuffer[X]=i.createFramebuffer()}else B.__webglFramebuffer=i.createFramebuffer();if(ae)for(let X=0,K=Q.length;X<K;X++){let pe=n.get(Q[X]);pe.__webglTexture===void 0&&(pe.__webglTexture=i.createTexture(),o.memory.textures++)}if(T.samples>0&&qe(T)===!1){B.__webglMultisampledFramebuffer=i.createFramebuffer(),B.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,B.__webglMultisampledFramebuffer);for(let X=0;X<Q.length;X++){let K=Q[X];B.__webglColorRenderbuffer[X]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,B.__webglColorRenderbuffer[X]);let pe=r.convert(K.format,K.colorSpace),ve=r.convert(K.type),re=M(K.internalFormat,pe,ve,K.normalized,K.colorSpace,T.isXRRenderTarget===!0),ne=Tt(T);i.renderbufferStorageMultisample(i.RENDERBUFFER,ne,re,T.width,T.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+X,i.RENDERBUFFER,B.__webglColorRenderbuffer[X])}i.bindRenderbuffer(i.RENDERBUFFER,null),T.depthBuffer&&(B.__webglDepthRenderbuffer=i.createRenderbuffer(),ft(B.__webglDepthRenderbuffer,T,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(te){t.bindTexture(i.TEXTURE_CUBE_MAP,$.__webglTexture),Fe(i.TEXTURE_CUBE_MAP,y);for(let X=0;X<6;X++)if(y.mipmaps&&y.mipmaps.length>0)for(let K=0;K<y.mipmaps.length;K++)Ie(B.__webglFramebuffer[X][K],T,y,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+X,K);else Ie(B.__webglFramebuffer[X],T,y,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+X,0);p(y)&&v(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ae){for(let X=0,K=Q.length;X<K;X++){let pe=Q[X],ve=n.get(pe),re=i.TEXTURE_2D;(T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(re=T.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(re,ve.__webglTexture),Fe(re,pe),Ie(B.__webglFramebuffer,T,pe,i.COLOR_ATTACHMENT0+X,re,0),p(pe)&&v(re)}t.unbindTexture()}else{let X=i.TEXTURE_2D;if((T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(X=T.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(X,$.__webglTexture),Fe(X,y),y.mipmaps&&y.mipmaps.length>0)for(let K=0;K<y.mipmaps.length;K++)Ie(B.__webglFramebuffer[K],T,y,i.COLOR_ATTACHMENT0,X,K);else Ie(B.__webglFramebuffer,T,y,i.COLOR_ATTACHMENT0,X,0);p(y)&&v(X),t.unbindTexture()}T.depthBuffer&&tt(T)}function Et(T){let y=T.textures;for(let B=0,$=y.length;B<$;B++){let Q=y[B];if(p(Q)){let te=b(T),ae=n.get(Q).__webglTexture;t.bindTexture(te,ae),v(te),t.unbindTexture()}}}let pt=[],tn=[];function D(T){if(T.samples>0){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;pe<y.length;pe++)t.bindFramebuffer(i.FRAMEBUFFER,ae.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+pe,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,ae.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+pe,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,ae.__webglMultisampledFramebuffer);let K=T.texture.mipmaps;K&&K.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ae.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ae.__webglFramebuffer);for(let pe=0;pe<y.length;pe++){if(T.resolveDepthBuffer&&(T.depthBuffer&&(Q|=i.DEPTH_BUFFER_BIT),T.stencilBuffer&&T.resolveStencilBuffer&&(Q|=i.STENCIL_BUFFER_BIT)),X){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,ae.__webglColorRenderbuffer[pe]);let ve=n.get(y[pe]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,ve,0)}i.blitFramebuffer(0,0,B,$,0,0,B,$,Q,i.NEAREST),l===!0&&(pt.length=0,tn.length=0,pt.push(i.COLOR_ATTACHMENT0+pe),T.depthBuffer&&T.resolveDepthBuffer===!1&&(pt.push(te),tn.push(te),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,tn)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,pt))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),X)for(let pe=0;pe<y.length;pe++){t.bindFramebuffer(i.FRAMEBUFFER,ae.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+pe,i.RENDERBUFFER,ae.__webglColorRenderbuffer[pe]);let ve=n.get(y[pe]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,ae.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+pe,i.TEXTURE_2D,ve,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ae.__webglMultisampledFramebuffer)}else if(T.depthBuffer&&T.resolveDepthBuffer===!1&&l){let y=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[y])}}}function Tt(T){return Math.min(s.maxSamples,T.samples)}function qe(T){let y=n.get(T);return T.samples>0&&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!==rr&&B!==li&&(Ge.getTransfer(B)===je?($!==yn||Q!==un)&&Te("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Pe("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===Sa)return i.UNSIGNED_SHORT_4_4_4_4;if(n===wa)return i.UNSIGNED_SHORT_5_5_5_1;if(n===ah)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===lh)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===rh)return i.BYTE;if(n===oh)return i.SHORT;if(n===Is)return i.UNSIGNED_SHORT;if(n===Ma)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===ch)return i.ALPHA;if(n===hh)return i.RGB;if(n===yn)return i.RGBA;if(n===Bn)return i.DEPTH_COMPONENT;if(n===Di)return i.DEPTH_STENCIL;if(n===uh)return i.RED;if(n===Ea)return i.RED_INTEGER;if(n===Fi)return i.RG;if(n===Ta)return i.RG_INTEGER;if(n===Aa)return i.RGBA_INTEGER;if(n===Ir||n===Lr||n===Nr||n===Dr)if(o===je)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Ir)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Lr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Nr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Dr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Ir)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Lr)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Nr)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Dr)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Ca||n===Ra||n===Pa||n===Ia)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Ca)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Ra)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Pa)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Ia)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===La||n===Na||n===Da||n===Fa||n===ka||n===Fr||n===Oa)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===La||n===Na)return o===je?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Da)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===Fa)return r.COMPRESSED_R11_EAC;if(n===ka)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Fr)return r.COMPRESSED_RG11_EAC;if(n===Oa)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Ua||n===Ba||n===za||n===Va||n===Ga||n===Ha||n===Wa||n===Xa||n===qa||n===Ya||n===Za||n===$a||n===Ka||n===Ja)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Ua)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Ba)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===za)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Va)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Ga)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Ha)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Wa)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Xa)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===qa)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Ya)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Za)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===$a)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Ka)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Ja)return o===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===ja||n===Qa||n===el)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===ja)return o===je?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Qa)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===el)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===tl||n===nl||n===kr||n===il)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===tl)return r.COMPRESSED_RED_RGTC1_EXT;if(n===nl)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===kr)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===il)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ls?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;
|
|
|
|
}
|
|
|
|
}`,Uh=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new mr(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 gr(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Bh=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 Uh,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 ga,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 Ts,S[Z]=fe),fe.getTargetRaySpace()},this.getControllerGrip=function(Z){let fe=S[Z];return fe===void 0&&(fe=new Ts,S[Z]=fe),fe.getGripSpace()},this.getHand=function(Z){let fe=S[Z];return fe===void 0&&(fe=new Ts,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<S.length;Z++){let fe=w[Z];fe!==null&&(w[Z]=null,S[Z].disconnect(fe))}H=null,W=null,g.reset();for(let Z in p)delete p[Z];e.setRenderTarget(b),f=null,u=null,d=null,s=null,M=null,Fe.stop(),n.isPresenting=!1,e.setPixelRatio(_),e.setSize(C.width,C.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Z){r=Z,n.isPresenting===!0&&Te("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Z){a=Z,n.isPresenting===!0&&Te("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(Z){c=Z},this.getBaseLayer=function(){return u!==null?u:f},this.getBinding=function(){return d===null&&x&&(d=new XRWebGLBinding(s,t)),d},this.getFrame=function(){return m},this.getSession=function(){return s},this.setSession=async function(Z){if(s=Z,s!==null){if(b=e.getRenderTarget(),s.addEventListener("select",F),s.addEventListener("selectstart",F),s.addEventListener("selectend",F),s.addEventListener("squeeze",F),s.addEventListener("squeezestart",F),s.addEventListener("squeezeend",F),s.addEventListener("end",O),s.addEventListener("inputsourceschange",U),v.xrCompatible!==!0&&await t.makeXRCompatible(),_=e.getPixelRatio(),e.getSize(C),x&&"createProjectionLayer"in XRWebGLBinding.prototype){let se=null,Re=null,ke=null;v.depth&&(ke=v.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,se=v.stencil?Di:Bn,Re=v.stencil?Ls:Rn);let Ie={colorFormat:t.RGBA8,depthFormat:ke,scaleFactor:r};d=this.getBinding(),u=d.createProjectionLayer(Ie),s.updateRenderState({layers:[u]}),e.setPixelRatio(1),e.setSize(u.textureWidth,u.textureHeight,!1),M=new Ct(u.textureWidth,u.textureHeight,{format:yn,type:un,depthTexture:new oi(u.textureWidth,u.textureHeight,Re,void 0,void 0,void 0,void 0,void 0,void 0,se),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:v.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}else{let se={antialias:v.antialias,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(s,t,se),s.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),M=new Ct(f.framebufferWidth,f.framebufferHeight,{format:yn,type:un,colorSpace:e.outputColorSpace,stencilBuffer:v.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}M.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await s.requestReferenceSpace(a),Fe.setContext(s),Fe.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};function U(Z){for(let fe=0;fe<Z.removed.length;fe++){let se=Z.removed[fe],Re=w.indexOf(se);Re>=0&&(w[Re]=null,S[Re].disconnect(se))}for(let fe=0;fe<Z.added.length;fe++){let se=Z.added[fe],Re=w.indexOf(se);if(Re===-1){for(let Ie=0;Ie<S.length;Ie++)if(Ie>=w.length){w.push(se),Re=Ie;break}else if(w[Ie]===null){w[Ie]=se,Re=Ie;break}if(Re===-1)break}let ke=S[Re];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 Re=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=Re/(-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+(Re-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 Re=Z.parent,ke=I.cameras;ye(I,Re);for(let Ie=0;Ie<ke.length;Ie++)ye(ke[Ie],Re);ke.length===2?le(I,A,P):I.projectionMatrix.copy(A.projectionMatrix),Me(Z,I,Re)};function Me(Z,fe,se){se===null?Z.matrix.copy(fe.matrixWorld):(Z.matrix.copy(se.matrixWorld),Z.matrix.invert(),Z.matrix.multiply(fe.matrixWorld)),Z.matrix.decompose(Z.position,Z.quaternion,Z.scale),Z.updateMatrixWorld(!0),Z.projectionMatrix.copy(fe.projectionMatrix),Z.projectionMatrixInverse.copy(fe.projectionMatrixInverse),Z.isPerspectiveCamera&&(Z.fov=ws*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1)}this.getCamera=function(){return I},this.getFoveation=function(){if(!(u===null&&f===null))return l},this.setFoveation=function(Z){l=Z,u!==null&&(u.fixedFoveation=Z),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=Z)},this.hasDepthSensing=function(){return g.texture!==null},this.getDepthSensingMesh=function(){return g.getMesh(I)},this.getCameraTexture=function(Z){return p[Z]};let Ze=null;function Ke(Z,fe){if(h=fe.getViewerPose(c||o),m=fe,h!==null){let se=h.views;f!==null&&(e.setRenderTargetFramebuffer(M,f.framebuffer),e.setRenderTarget(M));let Re=!1;se.length!==I.cameras.length&&(I.cameras.length=0,Re=!0);for(let Xe=0;Xe<se.length;Xe++){let tt=se[Xe],lt=null;if(f!==null)lt=f.getViewport(tt);else{let Et=d.getViewSubImage(u,tt);lt=Et.viewport,Xe===0&&(e.setRenderTargetTextures(M,Et.colorTexture,Et.depthStencilTexture),e.setRenderTarget(M))}let We=R[Xe];We===void 0&&(We=new Ht,We.layers.enable(Xe),We.viewport=new vt,R[Xe]=We),We.matrix.fromArray(tt.transform.matrix),We.matrix.decompose(We.position,We.quaternion,We.scale),We.projectionMatrix.fromArray(tt.projectionMatrix),We.projectionMatrixInverse.copy(We.projectionMatrix).invert(),We.viewport.set(lt.x,lt.y,lt.width,lt.height),Xe===0&&(I.matrix.copy(We.matrix),I.matrix.decompose(I.position,I.quaternion,I.scale)),Re===!0&&I.cameras.push(We)}let ke=s.enabledFeatures;if(ke&&ke.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&x){d=n.getBinding();let Xe=d.getDepthInformation(se[0]);Xe&&Xe.isValid&&Xe.texture&&g.init(Xe,s.renderState)}if(ke&&ke.includes("camera-access")&&x){e.state.unbindTexture(),d=n.getBinding();for(let Xe=0;Xe<se.length;Xe++){let tt=se[Xe].camera;if(tt){let lt=p[tt];lt||(lt=new mr,p[tt]=lt);let We=d.getCameraImage(tt);lt.sourceTexture=We}}}}for(let se=0;se<S.length;se++){let Re=w[se],ke=S[se];Re!==null&&ke!==void 0&&ke.update(Re,fe,c||o)}Ze&&Ze(Z,fe),fe.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:fe}),m=null}let Fe=new Tf;Fe.setAnimationLoop(Ke),this.setAnimationLoop=function(Z){Ze=Z},this.dispose=function(){}}},Oy=new xt,Lf=new De;Lf.set(-1,0,0,0,1,0,0,0,1);function Uy(i,e){function t(g,p){g.matrixAutoUpdate===!0&&g.updateMatrix(),p.value.copy(g.matrix)}function n(g,p){p.color.getRGB(g.fogColor.value,gh(i)),p.isFog?(g.fogNear.value=p.near,g.fogFar.value=p.far):p.isFogExp2&&(g.fogDensity.value=p.density)}function s(g,p,v,b,M){p.isNodeMaterial?p.uniformsNeedUpdate=!1:p.isMeshBasicMaterial?r(g,p):p.isMeshLambertMaterial?(r(g,p),p.envMap&&(g.envMapIntensity.value=p.envMapIntensity)):p.isMeshToonMaterial?(r(g,p),d(g,p)):p.isMeshPhongMaterial?(r(g,p),h(g,p),p.envMap&&(g.envMapIntensity.value=p.envMapIntensity)):p.isMeshStandardMaterial?(r(g,p),u(g,p),p.isMeshPhysicalMaterial&&f(g,p,M)):p.isMeshMatcapMaterial?(r(g,p),m(g,p)):p.isMeshDepthMaterial?r(g,p):p.isMeshDistanceMaterial?(r(g,p),x(g,p)):p.isMeshNormalMaterial?r(g,p):p.isLineBasicMaterial?(o(g,p),p.isLineDashedMaterial&&a(g,p)):p.isPointsMaterial?l(g,p,v,b):p.isSpriteMaterial?c(g,p):p.isShadowMaterial?(g.color.value.copy(p.color),g.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function r(g,p){g.opacity.value=p.opacity,p.color&&g.diffuse.value.copy(p.color),p.emissive&&g.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(g.map.value=p.map,t(p.map,g.mapTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,t(p.alphaMap,g.alphaMapTransform)),p.bumpMap&&(g.bumpMap.value=p.bumpMap,t(p.bumpMap,g.bumpMapTransform),g.bumpScale.value=p.bumpScale,p.side===$t&&(g.bumpScale.value*=-1)),p.normalMap&&(g.normalMap.value=p.normalMap,t(p.normalMap,g.normalMapTransform),g.normalScale.value.copy(p.normalScale),p.side===$t&&g.normalScale.value.negate()),p.displacementMap&&(g.displacementMap.value=p.displacementMap,t(p.displacementMap,g.displacementMapTransform),g.displacementScale.value=p.displacementScale,g.displacementBias.value=p.displacementBias),p.emissiveMap&&(g.emissiveMap.value=p.emissiveMap,t(p.emissiveMap,g.emissiveMapTransform)),p.specularMap&&(g.specularMap.value=p.specularMap,t(p.specularMap,g.specularMapTransform)),p.alphaTest>0&&(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;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return Pe("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(v){let b=s[v.id],M=v.uniforms,S=v.__cache;i.bindBuffer(i.UNIFORM_BUFFER,b);for(let w=0,C=M.length;w<C;w++){let _=Array.isArray(M[w])?M[w]:[M[w]];for(let A=0,P=_.length;A<P;A++){let R=_[A];if(f(R,w,A,S)===!0){let I=R.__offset,H=Array.isArray(R.value)?R.value:[R.value],W=0;for(let F=0;F<H.length;F++){let O=H[F],U=x(O);typeof O=="number"||typeof O=="boolean"?(R.__data[0]=O,i.bufferSubData(i.UNIFORM_BUFFER,I+W,R.__data)):O.isMatrix3?(R.__data[0]=O.elements[0],R.__data[1]=O.elements[1],R.__data[2]=O.elements[2],R.__data[3]=0,R.__data[4]=O.elements[3],R.__data[5]=O.elements[4],R.__data[6]=O.elements[5],R.__data[7]=0,R.__data[8]=O.elements[6],R.__data[9]=O.elements[7],R.__data[10]=O.elements[8],R.__data[11]=0):ArrayBuffer.isView(O)?R.__data.set(new O.constructor(O.buffer,O.byteOffset,R.__data.length)):(O.toArray(R.__data,W),W+=U.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,I,R.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function f(v,b,M,S){let w=v.value,C=b+"_"+M;if(S[C]===void 0)return typeof w=="number"||typeof w=="boolean"?S[C]=w:ArrayBuffer.isView(w)?S[C]=w.slice():S[C]=w.clone(),!0;{let _=S[C];if(typeof w=="number"||typeof w=="boolean"){if(_!==w)return S[C]=w,!0}else{if(ArrayBuffer.isView(w))return!0;if(_.equals(w)===!1)return _.copy(w),!0}}return!1}function m(v){let b=v.uniforms,M=0,S=16;for(let C=0,_=b.length;C<_;C++){let A=Array.isArray(b[C])?b[C]:[b[C]];for(let P=0,R=A.length;P<R;P++){let I=A[P],H=Array.isArray(I.value)?I.value:[I.value];for(let W=0,F=H.length;W<F;W++){let O=H[W],U=x(O),J=M%S,ee=J%U.boundary,le=J+ee;M+=ee,le!==0&&S-le<U.storage&&(M+=S-le),I.__data=new Float32Array(U.storage/Float32Array.BYTES_PER_ELEMENT),I.__offset=M,M+=U.storage}}}let w=M%S;return w>0&&(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 jo(zy,16,16,Fi,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 ks=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([Aa,Ta,Ea]),p=new Set([un,Rn,Is,Ls,Sa,wa]),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),Re=new vt(0,0,Ze,Ke),ke=!1,Ie=new fr,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${va}`),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 Pe("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 Bh(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){Pe("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(E){for(let k=0;k<E.length;k++)if(E[k].isOutputPass===!0){Te("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}A.setEffects(E||[])},this.getCurrentViewport=function(E){return E.copy(J)},this.getViewport=function(E){return E.copy(se)},this.setViewport=function(E,k,G,z){E.isVector4?se.set(E.x,E.y,E.z,E.w):se.set(E,k,G,z),ce.viewport(J.copy(se).multiplyScalar(Fe).round())},this.getScissor=function(E){return E.copy(Re)},this.setScissor=function(E,k,G,z){E.isVector4?Re.set(E.x,E.y,E.z,E.w):Re.set(E,k,G,z),ce.scissor(ee.copy(Re).multiplyScalar(Fe).round())},this.getScissorTest=function(){return ke},this.setScissorTest=function(E){ce.setScissorTest(ke=E)},this.setOpaqueSort=function(E){Z=E},this.setTransparentSort=function(E){fe=E},this.getClearColor=function(E){return E.copy(ne.getClearColor())},this.setClearColor=function(){ne.setClearColor(...arguments)},this.getClearAlpha=function(){return ne.getClearAlpha()},this.setClearAlpha=function(){ne.setClearAlpha(...arguments)},this.clear=function(E=!0,k=!0,G=!0){let z=0;if(E){let V=!1;if(F!==null){let de=F.texture.format;V=g.has(de)}if(V){let de=F.texture.type,_e=p.has(de),ue=ne.getClearColor(),be=ne.getClearAlpha(),we=ue.r,Ue=ue.g,Ve=ue.b;_e?(v[0]=we,v[1]=Ue,v[2]=Ve,v[3]=be,D.clearBufferuiv(D.COLOR,0,v)):(b[0]=we,b[1]=Ue,b[2]=Ve,b[3]=be,D.clearBufferiv(D.COLOR,0,b))}else z|=D.COLOR_BUFFER_BIT}k&&(z|=D.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),G&&(z|=D.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),z!==0&&D.clear(z)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(E){E.setRenderer(this),I=E},this.dispose=function(){t.removeEventListener("webglcontextlost",j,!1),t.removeEventListener("webglcontextrestored",Se,!1),t.removeEventListener("webglcontextcreationerror",Oe,!1),ne.dispose(),K.dispose(),pe.dispose(),T.dispose(),B.dispose(),te.dispose(),ie.dispose(),q.dispose(),ae.dispose(),oe.dispose(),oe.removeEventListener("sessionstart",Fu),oe.removeEventListener("sessionend",ku),Hi.stop()};function j(E){E.preventDefault(),ph("WebGLRenderer: Context Lost."),R=!0}function Se(){ph("WebGLRenderer: Context Restored."),R=!1;let E=mt.autoReset,k=re.enabled,G=re.autoUpdate,z=re.needsUpdate,V=re.type;me(),mt.autoReset=E,re.enabled=k,re.autoUpdate=G,re.needsUpdate=z,re.type=V}function Oe(E){Pe("WebGLRenderer: A WebGL context could not be created. Reason: ",E.statusMessage)}function bt(E){let k=E.target;k.removeEventListener("dispose",bt),nt(k)}function nt(E){qn(E),T.remove(E)}function qn(E){let k=T.get(E).programs;k!==void 0&&(k.forEach(function(G){ae.releaseProgram(G)}),E.isShaderMaterial&&ae.releaseShaderCache(E))}this.renderBufferDirect=function(E,k,G,z,V,de){k===null&&(k=Et);let _e=V.isMesh&&V.matrixWorld.determinant()<0,ue=Gm(E,k,G,z,V);ce.setMaterial(z,_e);let be=G.index,we=1;if(z.wireframe===!0){if(be=Q.getWireframeAttribute(G),be===void 0)return;we=2}let Ue=G.drawRange,Ve=G.attributes.position,Ee=Ue.start*we,it=(Ue.start+Ue.count)*we;de!==null&&(Ee=Math.max(Ee,de.start*we),it=Math.min(it,(de.start+de.count)*we)),be!==null?(Ee=Math.max(Ee,0),it=Math.min(it,be.count)):Ve!=null&&(Ee=Math.max(Ee,0),it=Math.min(it,Ve.count));let Mt=it-Ee;if(Mt<0||Mt===1/0)return;ie.setup(V,z,ue,G,be);let gt,st=Be;if(be!==null&&(gt=$.get(be),st=Je,st.setIndex(gt)),V.isMesh)z.wireframe===!0?(ce.setLineWidth(z.wireframeLinewidth*tn()),st.setMode(D.LINES)):st.setMode(D.TRIANGLES);else if(V.isLine){let zt=z.linewidth;zt===void 0&&(zt=1),ce.setLineWidth(zt*tn()),V.isLineSegments?st.setMode(D.LINES):V.isLineLoop?st.setMode(D.LINE_LOOP):st.setMode(D.LINE_STRIP)}else V.isPoints?st.setMode(D.POINTS):V.isSprite&&st.setMode(D.TRIANGLES);if(V.isBatchedMesh)if(qe.get("WEBGL_multi_draw"))st.renderMultiDraw(V._multiDrawStarts,V._multiDrawCounts,V._multiDrawCount);else{let zt=V._multiDrawStarts,xe=V._multiDrawCounts,nn=V._multiDrawCount,$e=be?$.get(be).bytesPerElement:1,mn=T.get(z).currentProgram.getUniforms();for(let Dn=0;Dn<nn;Dn++)mn.setValue(D,"_gl_DrawID",Dn),st.render(zt[Dn]/$e,xe[Dn])}else if(V.isInstancedMesh)st.renderInstances(Ee,Mt,V.count);else if(G.isInstancedBufferGeometry){let zt=G._maxInstanceCount!==void 0?G._maxInstanceCount:1/0,xe=Math.min(G.instanceCount,zt);st.renderInstances(Ee,Mt,xe)}else st.render(Ee,Mt)};function Nn(E,k,G){E.transparent===!0&&E.side===Hn&&E.forceSinglePass===!1?(E.side=$t,E.needsUpdate=!0,no(E,k,G),E.side=ni,E.needsUpdate=!0,no(E,k,G),E.side=Hn):no(E,k,G)}this.compile=function(E,k,G=null){G===null&&(G=E),w=pe.get(G),w.init(k),_.push(w),G.traverseVisible(function(V){V.isLight&&V.layers.test(k.layers)&&(w.pushLight(V),V.castShadow&&w.pushShadow(V))}),E!==G&&E.traverseVisible(function(V){V.isLight&&V.layers.test(k.layers)&&(w.pushLight(V),V.castShadow&&w.pushShadow(V))}),w.setupLights();let z=new Set;return E.traverse(function(V){if(!(V.isMesh||V.isPoints||V.isLine||V.isSprite))return;let de=V.material;if(de)if(Array.isArray(de))for(let _e=0;_e<de.length;_e++){let ue=de[_e];Nn(ue,G,V),z.add(ue)}else Nn(de,G,V),z.add(de)}),w=_.pop(),z},this.compileAsync=function(E,k,G=null){let z=this.compile(E,k,G);return new Promise(V=>{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 mc=null;function zm(E){mc&&mc(E)}function Fu(){Hi.stop()}function ku(){Hi.start()}let Hi=new Tf;Hi.setAnimationLoop(zm),typeof self<"u"&&Hi.setContext(self),this.setAnimationLoop=function(E){mc=E,oe.setAnimationLoop(E),E===null?Hi.stop():Hi.start()},oe.addEventListener("sessionstart",Fu),oe.addEventListener("sessionend",ku),this.render=function(E,k){if(k!==void 0&&k.isCamera!==!0){Pe("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&&gc(_e,k,-1/0,P.sortObjects)}gc(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;we<Ue;we++){let Ve=be[we];Uu(_e,ue,E,Ve)}pt&&ne.render(E);for(let we=0,Ue=be.length;we<Ue;we++){let Ve=be[we];Ou(S,E,Ve,Ve.viewport)}}else ue.length>0&&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 gc(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;we<Ue;we++){let Ve=be[we],Ee=ue[Ve.materialIndex];Ee&&Ee.visible&&S.push(E,_e,Ee,G,We.z,Ve)}}else ue.visible&&S.push(E,_e,ue,G,We.z,null)}}let de=E.children;for(let _e=0,ue=de.length;_e<ue;_e++)gc(de[_e],k,G,z)}function Ou(E,k,G,z){let{opaque:V,transmissive:de,transparent:_e}=E;w.setupLightsView(G),ft===!0&&ve.setGlobalState(P.clippingPlanes,G),z&&ce.viewport(J.copy(z)),V.length>0&&to(V,k,G),de.length>0&&to(de,k,G),_e.length>0&&to(_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:Ni,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),to(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;it<Mt;it++){let gt=k[it],{object:st,geometry:zt,material:xe,group:nn}=gt;if(xe.side===Hn&&st.layers.test(z.layers)){let $e=xe.side;xe.side=$t,xe.needsUpdate=!0,Bu(st,G,z,zt,xe,nn),xe.side=$e,xe.needsUpdate=!0,Ee=!0}}Ee===!0&&(y.updateMultisampleRenderTarget(de),y.updateRenderTargetMipmap(de))}P.setRenderTarget(ue,be,we),P.setClearColor(ye,Me),Ve!==void 0&&(z.viewport=Ve),P.toneMapping=Ue}function to(E,k,G){let z=k.isScene===!0?k.overrideMaterial:null;for(let V=0,de=E.length;V<de;V++){let _e=E[V],{object:ue,geometry:be,group:we}=_e,Ue=_e.material;Ue.allowOverride===!0&&z!==null&&(Ue=z),ue.layers.test(G.layers)&&Bu(ue,k,G,be,Ue,we)}}function Bu(E,k,G,z,V,de){E.onBeforeRender(P,k,G,z,V,de),E.modelViewMatrix.multiplyMatrices(G.matrixWorldInverse,E.matrixWorld),E.normalMatrix.getNormalMatrix(E.modelViewMatrix),V.onBeforeRender(P,k,G,z,E,de),V.transparent===!0&&V.side===Hn&&V.forceSinglePass===!1?(V.side=$t,V.needsUpdate=!0,P.renderBufferDirect(G,k,z,V,E,de),V.side=ni,V.needsUpdate=!0,P.renderBufferDirect(G,k,z,V,E,de),V.side=Hn):P.renderBufferDirect(G,k,z,V,E,de),E.onAfterRender(P,k,G,z,V,de)}function no(E,k,G){k.isScene!==!0&&(k=Et);let z=T.get(E),V=w.state.lights,de=w.state.shadowsArray,_e=V.state.version,ue=ae.getParameters(E,V.state,de,k,G,w.state.lightProbeGridArray),be=ae.getProgramCacheKey(ue),we=z.programs;z.environment=E.isMeshStandardMaterial||E.isMeshLambertMaterial||E.isMeshPhongMaterial?k.environment:null,z.fog=k.fog;let Ue=E.isMeshStandardMaterial||E.isMeshLambertMaterial&&!E.envMap||E.isMeshPhongMaterial&&!E.envMap;z.envMap=B.get(E.envMap||z.environment,Ue),z.envMapRotation=z.environment!==null&&E.envMap===null?k.environmentRotation:E.envMapRotation,we===void 0&&(E.addEventListener("dispose",bt),we=new Map,z.programs=we);let Ve=we.get(be);if(Ve!==void 0){if(z.currentProgram===Ve&&z.lightsStateVersion===_e)return Vu(E,ue),Ve}else ue.uniforms=ae.getUniforms(E),I!==null&&E.isNodeMaterial&&I.build(E,G,ue),E.onBeforeCompile(ue,P),Ve=ae.acquireProgram(ue,be),we.set(be,Ve),z.uniforms=ue.uniforms;let Ee=z.uniforms;return(!E.isShaderMaterial&&!E.isRawShaderMaterial||E.clipping===!0)&&(Ee.clippingPlanes=ve.uniform),Vu(E,ue),z.needsLights=Wm(E),z.lightsStateVersion=_e,z.needsLights&&(Ee.ambientLightColor.value=V.state.ambient,Ee.lightProbe.value=V.state.probe,Ee.directionalLights.value=V.state.directional,Ee.directionalLightShadows.value=V.state.directionalShadow,Ee.spotLights.value=V.state.spot,Ee.spotLightShadows.value=V.state.spotShadow,Ee.rectAreaLights.value=V.state.rectArea,Ee.ltc_1.value=V.state.rectAreaLTC1,Ee.ltc_2.value=V.state.rectAreaLTC2,Ee.pointLights.value=V.state.point,Ee.pointLightShadows.value=V.state.pointShadow,Ee.hemisphereLights.value=V.state.hemi,Ee.directionalShadowMatrix.value=V.state.directionalShadowMatrix,Ee.spotLightMatrix.value=V.state.spotLightMatrix,Ee.spotLightMap.value=V.state.spotLightMap,Ee.pointShadowMatrix.value=V.state.pointShadowMatrix),z.lightProbeGrid=w.state.lightProbeGridArray.length>0,z.currentProgram=Ve,z.uniformsList=null,Ve}function zu(E){if(E.uniformsList===null){let k=E.currentProgram.getUniforms();E.uniformsList=Fs.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;G<z;G++){let V=E[G];if(V.texture!==null&&V.boundingBox.containsPoint(M))return V}return null}function Gm(E,k,G,z,V){k.isScene!==!0&&(k=Et),y.resetTextureUnits();let de=k.fog,_e=z.isMeshStandardMaterial||z.isMeshLambertMaterial||z.isMeshPhongMaterial?k.environment:null,ue=F===null?P.outputColorSpace:F.isXRRenderTarget===!0?F.texture.colorSpace:Ge.workingColorSpace,be=z.isMeshStandardMaterial||z.isMeshLambertMaterial&&!z.envMap||z.isMeshPhongMaterial&&!z.envMap,we=B.get(z.envMap||_e,be),Ue=z.vertexColors===!0&&!!G.attributes.color&&G.attributes.color.itemSize===4,Ve=!!G.attributes.tangent&&(!!z.normalMap||z.anisotropy>0),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=no(z,k,V),I&&z.isNodeMaterial&&I.onUpdateProgram(z,mn,xe));let Dn=!1,ui=!1,ss=!1,rt=mn.getUniforms(),St=xe.uniforms;if(ce.useProgram(mn.program)&&(Dn=!0,ui=!0,ss=!0),z.id!==O&&(O=z.id,ui=!0),xe.needsLights){let at=Vm(w.state.lightProbeGridArray,V);xe.lightProbeGrid!==at&&(xe.lightProbeGrid=at,ui=!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 fi=rt.map.cameraPosition;fi!==void 0&&fi.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,ui=!0,ss=!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 di=G.morphAttributes;if((di.position!==void 0||di.normal!==void 0||di.color!==void 0)&&Ne.update(V,G,mn),(ui||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()),ui){if(rt.setValue(D,"toneMappingExposure",P.toneMappingExposure),xe.needsLights&&Hm(St,ss),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)}Fs.upload(D,zu(xe),St,y)}if(z.isShaderMaterial&&z.uniformsNeedUpdate===!0&&(Fs.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 fi=0,rs=at.length;fi<rs;fi++){let Gu=at[fi];q.update(Gu,mn),q.bind(Gu,mn)}}return mn}function Hm(E,k){E.ambientLightColor.needsUpdate=k,E.lightProbe.needsUpdate=k,E.directionalLights.needsUpdate=k,E.directionalLightShadows.needsUpdate=k,E.pointLights.needsUpdate=k,E.pointLightShadows.needsUpdate=k,E.spotLights.needsUpdate=k,E.spotLightShadows.needsUpdate=k,E.rectAreaLights.needsUpdate=k,E.hemisphereLights.needsUpdate=k}function Wm(E){return E.isMeshLambertMaterial||E.isMeshToonMaterial||E.isMeshPhongMaterial||E.isMeshStandardMaterial||E.isShadowMaterial||E.isShaderMaterial&&E.lights===!0}this.getActiveCubeFace=function(){return H},this.getActiveMipmapLevel=function(){return W},this.getRenderTarget=function(){return F},this.setRenderTargetTextures=function(E,k,G){let z=T.get(E);z.__autoAllocateDepthBuffer=E.resolveDepthBuffer===!1,z.__autoAllocateDepthBuffer===!1&&(z.__useRenderToTexture=!1),T.get(E.texture).__webglTexture=k,T.get(E.depthTexture).__webglTexture=z.__autoAllocateDepthBuffer?void 0:G,z.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(E,k){let G=T.get(E);G.__webglFramebuffer=k,G.__useDefaultFramebuffer=k===void 0};let Xm=D.createFramebuffer();this.setRenderTarget=function(E,k=0,G=0){F=E,H=k,W=G;let z=null,V=!1,de=!1;if(E){let ue=T.get(E);if(ue.__useDefaultFramebuffer!==void 0){ce.bindFramebuffer(D.FRAMEBUFFER,ue.__webglFramebuffer),J.copy(E.viewport),ee.copy(E.scissor),le=E.scissorTest,ce.viewport(J),ce.scissor(ee),ce.setScissorTest(le),O=-1;return}else if(ue.__webglFramebuffer===void 0)y.setupRenderTarget(E);else if(ue.__hasExternalTextures)y.rebindTextures(E,T.get(E.texture).__webglTexture,T.get(E.depthTexture).__webglTexture);else if(E.depthBuffer){let Ue=E.depthTexture;if(ue.__boundDepthTexture!==Ue){if(Ue!==null&&T.has(Ue)&&(E.width!==Ue.image.width||E.height!==Ue.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");y.setupDepthRenderbuffer(E)}}let be=E.texture;(be.isData3DTexture||be.isDataArrayTexture||be.isCompressedArrayTexture)&&(de=!0);let we=T.get(E).__webglFramebuffer;E.isWebGLCubeRenderTarget?(Array.isArray(we[k])?z=we[k][G]:z=we[k],V=!0):E.samples>0&&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(Re).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;be<E.textures.length;be++){let we=T.get(E.textures[be]);D.framebufferTextureLayer(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0+be,we.__webglTexture,G,ue)}}else if(E!==null&&G!==0){let ue=T.get(E.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,ue.__webglTexture,G)}O=-1},this.readRenderTargetPixels=function(E,k,G,z,V,de,_e,ue=0){if(!(E&&E.isWebGLRenderTarget)){Pe("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let be=T.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&_e!==void 0&&(be=be[_e]),be){ce.bindFramebuffer(D.FRAMEBUFFER,be);try{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)){Pe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!ot.textureTypeReadable(Ve)){Pe("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),ui=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 ss=E.isDataArrayTexture||E.isData3DTexture,rt=k.isDataArrayTexture||k.isData3DTexture;if(E.isDepthTexture){let St=T.get(E),di=T.get(k),at=T.get(St.__renderTarget),fi=T.get(di.__renderTarget);ce.bindFramebuffer(D.READ_FRAMEBUFFER,at.__webglFramebuffer),ce.bindFramebuffer(D.DRAW_FRAMEBUFFER,fi.__webglFramebuffer);for(let rs=0;rs<be;rs++)ss&&(D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,T.get(E).__webglTexture,V,Ve+rs),D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,T.get(k).__webglTexture,de,Mt+rs)),D.blitFramebuffer(we,Ue,_e,ue,Ee,it,_e,ue,D.DEPTH_BUFFER_BIT,D.NEAREST);ce.bindFramebuffer(D.READ_FRAMEBUFFER,null),ce.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else if(V!==0||E.isRenderTargetTexture||T.has(E)){let St=T.get(E),di=T.get(k);ce.bindFramebuffer(D.READ_FRAMEBUFFER,qm),ce.bindFramebuffer(D.DRAW_FRAMEBUFFER,Ym);for(let at=0;at<be;at++)ss?D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,St.__webglTexture,V,Ve+at):D.framebufferTexture2D(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,St.__webglTexture,V),rt?D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,di.__webglTexture,de,Mt+at):D.framebufferTexture2D(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,di.__webglTexture,de),V!==0?D.blitFramebuffer(we,Ue,_e,ue,Ee,it,_e,ue,D.COLOR_BUFFER_BIT,D.NEAREST):rt?D.copyTexSubImage3D(xe,de,Ee,it,Mt+at,we,Ue,_e,ue):D.copyTexSubImage2D(xe,de,Ee,it,we,Ue,_e,ue);ce.bindFramebuffer(D.READ_FRAMEBUFFER,null),ce.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else rt?E.isDataTexture||E.isData3DTexture?D.texSubImage3D(xe,de,Ee,it,Mt,_e,ue,be,st,zt,gt.data):k.isCompressedArrayTexture?D.compressedTexSubImage3D(xe,de,Ee,it,Mt,_e,ue,be,st,gt.data):D.texSubImage3D(xe,de,Ee,it,Mt,_e,ue,be,st,zt,gt):E.isDataTexture?D.texSubImage2D(D.TEXTURE_2D,de,Ee,it,_e,ue,st,zt,gt.data):E.isCompressedTexture?D.compressedTexSubImage2D(D.TEXTURE_2D,de,Ee,it,gt.width,gt.height,st,gt.data):D.texSubImage2D(D.TEXTURE_2D,de,Ee,it,_e,ue,st,zt,gt);ce.pixelStorei(D.UNPACK_ROW_LENGTH,nn),ce.pixelStorei(D.UNPACK_IMAGE_HEIGHT,$e),ce.pixelStorei(D.UNPACK_SKIP_PIXELS,mn),ce.pixelStorei(D.UNPACK_SKIP_ROWS,Dn),ce.pixelStorei(D.UNPACK_SKIP_IMAGES,ui),de===0&&k.generateMipmaps&&D.generateMipmap(xe),ce.unbindTexture()},this.initRenderTarget=function(E){T.get(E).__webglFramebuffer===void 0&&y.setupRenderTarget(E)},this.initTexture=function(E){E.isCubeTexture?y.setTextureCube(E,0):E.isData3DTexture?y.setTexture3D(E,0):E.isDataArrayTexture||E.isCompressedArrayTexture?y.setTexture2DArray(E,0):y.setTexture2D(E,0),ce.unbindTexture()},this.resetState=function(){H=0,W=0,F=null,ce.reset(),ie.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Tn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=Ge._getDrawingBufferColorSpace(e),t.unpackColorSpace=Ge._getUnpackColorSpace()}};var Nf=require("obsidian");async function Df(i){try{let e=(0,Nf.normalizePath)(i.vault.configDir+"/graph.json");if(!await i.vault.adapter.exists(e))return null;let t=JSON.parse(await i.vault.adapter.read(e)),n=[];for(let s of t.colorGroups??[]){let r=typeof s.query=="string"?s.query.trim():"",o=s.color?.rgb;!r||typeof o!="number"||n.push({query:r,color:`#${(o&16777215).toString(16).padStart(6,"0")}`})}return n}catch{return null}}var ml=require("obsidian");function Gy(i){let e=i.indexOf("/");return e===-1?"":i.slice(0,e)}function kf(i,e,t,n){let s=[],r=new Map;for(let d of i)r.set(d.path,s.length),s.push({id:d.path,name:d.basename,folderTop:Gy(d.path),degree:0,inDegree:0,outDegree:0,fileSize:d.size??0,unresolved:!1});let o=[],a=(d,u)=>{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 Vh(i){let e=2166136261;for(let t=0;t<i.length;t++)e^=i.charCodeAt(t),e=Math.imul(e,16777619);return e>>>0}function zh(i){return Vh(i)/4294967295}function Of(i,e){let t=zh(i),n=zh(i+":v"),s=zh(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 fl(i){return 80*Math.cbrt(Math.max(i,1)/1e3)}var pl=class extends ml.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,ml.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=fl(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<o.length)l[h*3]=o[d*3]??0,l[h*3+1]=o[d*3+1]??0,l[h*3+2]=o[d*3+2]??0;else{let[u,f,m]=Of(c.id,a);l[h*3]=u,l[h*3+1]=f,l[h*3+2]=m}}),this.data=s,this.positions=l,this.onChanged?.()}};function Uf(i){let e=+this._x.call(null,i);return Bf(this.cover(e),e,i)}function Bf(i,e,t){if(isNaN(e))return i;var n,s=i._root,r={data:t},o=i._x0,a=i._x1,l,c,h,d,u;if(!s)return i._root=r,i;for(;s.length;)if((h=e>=(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;r<e;++r)isNaN(o=+this._x.call(null,i[r]))||(t[r]=o,o<n&&(n=o),o>s&&(s=o));if(n>s)return this;this.cover(n).cover(s);for(let r=0;r<e;++r)Bf(this,t[r],i[r]);return this}function Vf(i){if(isNaN(i=+i))return this;var e=this._x0,t=this._x1;if(isNaN(e))t=(e=Math.floor(i))+1;else{for(var n=t-e||1,s=this._root,r,o;e>i||i>=t;)switch(o=+(i<e),r=new Array(2),r[o]=s,s=r,n*=2,o){case 0:t=e+n;break;case 1:e=t-n;break}this._root&&this._root.length&&(this._root=s)}return this._x0=e,this._x1=t,this}function Gf(){var i=[];return this.visit(function(e){if(!e.length)do i.push(e.data);while(e=e.next)}),i}function Hf(i){return arguments.length?this.cover(+i[0][0]).cover(+i[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]}function bn(i,e,t){this.node=i,this.x0=e,this.x1=t}function Wf(i,e){var t,n=this._x0,s,r,o=this._x1,a=[],l=this._root,c,h;for(l&&a.push(new bn(l,n,o)),e==null?e=1/0:(n=i-e,o=i+e);c=a.pop();)if(!(!(l=c.node)||(s=c.x0)>o||(r=c.x1)<n))if(l.length){var d=(s+r)/2;a.push(new bn(l[1],d,r),new bn(l[0],s,d)),(h=+(i>=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<e&&(e=u,n=i-u,o=i+u,t=l.data)}return t}function Xf(i){if(isNaN(l=+this._x.call(null,i)))return this;var e,t=this._root,n,s,r,o=this._x0,a=this._x1,l,c,h,d,u;if(!t)return this;if(t.length)for(;;){if((h=l>=(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<t;++e)this.remove(i[e]);return this}function Yf(){return this._root}function Zf(){var i=0;return this.visit(function(e){if(!e.length)do++i;while(e=e.next)}),i}function $f(i){var e=[],t,n=this._root,s,r,o;for(n&&e.push(new bn(n,this._x0,this._x1));t=e.pop();)if(!i(n=t.node,r=t.x0,o=t.x1)&&n.length){var a=(r+o)/2;(s=n[1])&&e.push(new bn(s,a,o)),(s=n[0])&&e.push(new bn(s,r,a))}return this}function Kf(i){var e=[],t=[],n;for(this._root&&e.push(new bn(this._root,this._x0,this._x1));n=e.pop();){var s=n.node;if(s.length){var r,o=n.x0,a=n.x1,l=(o+a)/2;(r=s[0])&&e.push(new bn(r,o,l)),(r=s[1])&&e.push(new bn(r,l,a))}t.push(n)}for(;n=t.pop();)i(n.node,n.x0,n.x1);return this}function Jf(i){return i[0]}function jf(i){return arguments.length?(this._x=i,this):this._x}function zr(i,e){var t=new Gh(e??Jf,NaN,NaN);return i==null?t:t.addAll(i)}function Gh(i,e,t){this._x=i,this._x0=e,this._x1=t,this._root=void 0}function Qf(i){for(var e={data:i.data},t=e;i=i.next;)t=t.next={data:i.data};return e}var en=zr.prototype=Gh.prototype;en.copy=function(){var i=new Gh(this._x,this._x0,this._x1),e=this._root,t,n;if(!e)return i;if(!e.length)return i._root=Qf(e),i;for(t=[{source:e,target:i._root=new Array(2)}];e=t.pop();)for(var s=0;s<2;++s)(n=e.source[s])&&(n.length?t.push({source:n,target:e.target[s]=new Array(2)}):e.target[s]=Qf(n));return i};en.add=Uf;en.addAll=zf;en.cover=Vf;en.data=Gf;en.extent=Hf;en.find=Wf;en.remove=Xf;en.removeAll=qf;en.root=Yf;en.size=Zf;en.visit=$f;en.visitAfter=Kf;en.x=jf;function ep(i){let e=+this._x.call(null,i),t=+this._y.call(null,i);return tp(this.cover(e,t),e,t,i)}function tp(i,e,t,n){if(isNaN(e)||isNaN(t))return i;var s,r=i._root,o={data:n},a=i._x0,l=i._y0,c=i._x1,h=i._y1,d,u,f,m,x,g,p,v;if(!r)return i._root=o,i;for(;r.length;)if((x=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;t<n;++t)isNaN(s=+this._x.call(null,e=i[t]))||isNaN(r=+this._y.call(null,e))||(o[t]=s,a[t]=r,s<l&&(l=s),s>h&&(h=s),r<c&&(c=r),r>d&&(d=r));if(l>h||c>d)return this;for(this.cover(l,c).cover(h,d),t=0;t<n;++t)tp(this,o[t],a[t],i[t]);return this}function ip(i,e){if(isNaN(i=+i)||isNaN(e=+e))return this;var t=this._x0,n=this._y0,s=this._x1,r=this._y1;if(isNaN(t))s=(t=Math.floor(i))+1,r=(n=Math.floor(e))+1;else{for(var o=s-t||1,a=this._root,l,c;t>i||i>=s||n>e||e>=r;)switch(c=(e<n)<<1|i<t,l=new Array(4),l[c]=a,a=l,o*=2,c){case 0:s=t+o,r=n+o;break;case 1:t=s-o,r=n+o;break;case 2:s=t+o,n=r-o;break;case 3:t=s-o,n=r-o;break}this._root&&this._root.length&&(this._root=a)}return this._x0=t,this._y0=n,this._x1=s,this._y1=r,this}function sp(){var i=[];return this.visit(function(e){if(!e.length)do i.push(e.data);while(e=e.next)}),i}function rp(i){return arguments.length?this.cover(+i[0][0],+i[0][1]).cover(+i[1][0],+i[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function Nt(i,e,t,n,s){this.node=i,this.x0=e,this.y0=t,this.x1=n,this.y1=s}function op(i,e,t){var n,s=this._x0,r=this._y0,o,a,l,c,h=this._x1,d=this._y1,u=[],f=this._root,m,x;for(f&&u.push(new Nt(f,s,r,h,d)),t==null?t=1/0:(s=i-t,r=e-t,h=i+t,d=e+t,t*=t);m=u.pop();)if(!(!(f=m.node)||(o=m.x0)>h||(a=m.y0)>d||(l=m.x1)<s||(c=m.y1)<r))if(f.length){var g=(o+l)/2,p=(a+c)/2;u.push(new Nt(f[3],g,p,l,c),new Nt(f[2],o,p,g,c),new Nt(f[1],g,a,l,p),new Nt(f[0],o,a,g,p)),(x=(e>=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<t){var S=Math.sqrt(t=M);s=i-S,r=e-S,h=i+S,d=e+S,n=f.data}}return n}function ap(i){if(isNaN(h=+this._x.call(null,i))||isNaN(d=+this._y.call(null,i)))return this;var e,t=this._root,n,s,r,o=this._x0,a=this._y0,l=this._x1,c=this._y1,h,d,u,f,m,x,g,p;if(!t)return this;if(t.length)for(;;){if((m=h>=(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<t;++e)this.remove(i[e]);return this}function cp(){return this._root}function hp(){var i=0;return this.visit(function(e){if(!e.length)do++i;while(e=e.next)}),i}function up(i){var e=[],t,n=this._root,s,r,o,a,l;for(n&&e.push(new Nt(n,this._x0,this._y0,this._x1,this._y1));t=e.pop();)if(!i(n=t.node,r=t.x0,o=t.y0,a=t.x1,l=t.y1)&&n.length){var c=(r+a)/2,h=(o+l)/2;(s=n[3])&&e.push(new Nt(s,c,h,a,l)),(s=n[2])&&e.push(new Nt(s,r,h,c,l)),(s=n[1])&&e.push(new Nt(s,c,o,a,h)),(s=n[0])&&e.push(new Nt(s,r,o,c,h))}return this}function dp(i){var e=[],t=[],n;for(this._root&&e.push(new Nt(this._root,this._x0,this._y0,this._x1,this._y1));n=e.pop();){var s=n.node;if(s.length){var r,o=n.x0,a=n.y0,l=n.x1,c=n.y1,h=(o+l)/2,d=(a+c)/2;(r=s[0])&&e.push(new Nt(r,o,a,h,d)),(r=s[1])&&e.push(new Nt(r,h,a,l,d)),(r=s[2])&&e.push(new Nt(r,o,d,h,c)),(r=s[3])&&e.push(new Nt(r,h,d,l,c))}t.push(n)}for(;n=t.pop();)i(n.node,n.x0,n.y0,n.x1,n.y1);return this}function fp(i){return i[0]}function pp(i){return arguments.length?(this._x=i,this):this._x}function mp(i){return i[1]}function gp(i){return arguments.length?(this._y=i,this):this._y}function Vr(i,e,t){var n=new Hh(e??fp,t??mp,NaN,NaN,NaN,NaN);return i==null?n:n.addAll(i)}function Hh(i,e,t,n,s,r){this._x=i,this._y=e,this._x0=t,this._y0=n,this._x1=s,this._y1=r,this._root=void 0}function xp(i){for(var e={data:i.data},t=e;i=i.next;)t=t.next={data:i.data};return e}var Kt=Vr.prototype=Hh.prototype;Kt.copy=function(){var i=new Hh(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,t,n;if(!e)return i;if(!e.length)return i._root=xp(e),i;for(t=[{source:e,target:i._root=new Array(4)}];e=t.pop();)for(var s=0;s<4;++s)(n=e.source[s])&&(n.length?t.push({source:n,target:e.target[s]=new Array(4)}):e.target[s]=xp(n));return i};Kt.add=ep;Kt.addAll=np;Kt.cover=ip;Kt.data=sp;Kt.extent=rp;Kt.find=op;Kt.remove=ap;Kt.removeAll=lp;Kt.root=cp;Kt.size=hp;Kt.visit=up;Kt.visitAfter=dp;Kt.x=pp;Kt.y=gp;function vp(i){let e=+this._x.call(null,i),t=+this._y.call(null,i),n=+this._z.call(null,i);return _p(this.cover(e,t,n),e,t,n,i)}function _p(i,e,t,n,s){if(isNaN(e)||isNaN(t)||isNaN(n))return i;var r,o=i._root,a={data:s},l=i._x0,c=i._y0,h=i._z0,d=i._x1,u=i._y1,f=i._z1,m,x,g,p,v,b,M,S,w,C,_;if(!o)return i._root=a,i;for(;o.length;)if((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,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;d<e;++d)isNaN(f=+this._x.call(null,u=i[d]))||isNaN(m=+this._y.call(null,u))||isNaN(x=+this._z.call(null,u))||(t[d]=f,n[d]=m,s[d]=x,f<r&&(r=f),f>l&&(l=f),m<o&&(o=m),m>c&&(c=m),x<a&&(a=x),x>h&&(h=x));if(r>l||o>c||a>h)return this;this.cover(r,o,a).cover(l,c,h);for(let d=0;d<e;++d)_p(this,t[d],n[d],s[d],i[d]);return this}function bp(i,e,t){if(isNaN(i=+i)||isNaN(e=+e)||isNaN(t=+t))return this;var n=this._x0,s=this._y0,r=this._z0,o=this._x1,a=this._y1,l=this._z1;if(isNaN(n))o=(n=Math.floor(i))+1,a=(s=Math.floor(e))+1,l=(r=Math.floor(t))+1;else{for(var c=o-n||1,h=this._root,d,u;n>i||i>=o||s>e||e>=a||r>t||t>=l;)switch(u=(t<r)<<2|(e<s)<<1|i<n,d=new Array(8),d[u]=h,h=d,c*=2,u){case 0:o=n+c,a=s+c,l=r+c;break;case 1:n=o-c,a=s+c,l=r+c;break;case 2:o=n+c,s=a-c,l=r+c;break;case 3:n=o-c,s=a-c,l=r+c;break;case 4:o=n+c,a=s+c,r=l-c;break;case 5:n=o-c,a=s+c,r=l-c;break;case 6:o=n+c,s=a-c,r=l-c;break;case 7:n=o-c,s=a-c,r=l-c;break}this._root&&this._root.length&&(this._root=h)}return this._x0=n,this._y0=s,this._z0=r,this._x1=o,this._y1=a,this._z1=l,this}function Mp(){var i=[];return this.visit(function(e){if(!e.length)do i.push(e.data);while(e=e.next)}),i}function Sp(i){return arguments.length?this.cover(+i[0][0],+i[0][1],+i[0][2]).cover(+i[1][0],+i[1][1],+i[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]}function et(i,e,t,n,s,r,o){this.node=i,this.x0=e,this.y0=t,this.z0=n,this.x1=s,this.y1=r,this.z1=o}function wp(i,e,t,n){var s,r=this._x0,o=this._y0,a=this._z0,l,c,h,d,u,f,m=this._x1,x=this._y1,g=this._z1,p=[],v=this._root,b,M;for(v&&p.push(new et(v,r,o,a,m,x,g)),n==null?n=1/0:(r=i-n,o=e-n,a=t-n,m=i+n,x=e+n,g=t+n,n*=n);b=p.pop();)if(!(!(v=b.node)||(l=b.x0)>m||(c=b.y0)>x||(h=b.z0)>g||(d=b.x1)<r||(u=b.y1)<o||(f=b.z1)<a))if(v.length){var S=(l+d)/2,w=(c+u)/2,C=(h+f)/2;p.push(new et(v[7],S,w,C,d,u,f),new et(v[6],l,w,C,S,u,f),new et(v[5],S,c,C,d,w,f),new et(v[4],l,c,C,S,w,f),new et(v[3],S,w,h,d,u,C),new et(v[2],l,w,h,S,u,C),new et(v[1],S,c,h,d,w,C),new et(v[0],l,c,h,S,w,C)),(M=(t>=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(R<n){var I=Math.sqrt(n=R);r=i-I,o=e-I,a=t-I,m=i+I,x=e+I,g=t+I,s=v.data}}return s}var Hy=(i,e,t,n,s,r)=>Math.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<r||g<o||p<a}),s}function Tp(i){if(isNaN(u=+this._x.call(null,i))||isNaN(f=+this._y.call(null,i))||isNaN(m=+this._z.call(null,i)))return this;var e,t=this._root,n,s,r,o=this._x0,a=this._y0,l=this._z0,c=this._x1,h=this._y1,d=this._z1,u,f,m,x,g,p,v,b,M,S,w;if(!t)return this;if(t.length)for(;;){if((v=u>=(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;e<t;++e)this.remove(i[e]);return this}function Cp(){return this._root}function Rp(){var i=0;return this.visit(function(e){if(!e.length)do++i;while(e=e.next)}),i}function Pp(i){var e=[],t,n=this._root,s,r,o,a,l,c,h;for(n&&e.push(new et(n,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));t=e.pop();)if(!i(n=t.node,r=t.x0,o=t.y0,a=t.z0,l=t.x1,c=t.y1,h=t.z1)&&n.length){var d=(r+l)/2,u=(o+c)/2,f=(a+h)/2;(s=n[7])&&e.push(new et(s,d,u,f,l,c,h)),(s=n[6])&&e.push(new et(s,r,u,f,d,c,h)),(s=n[5])&&e.push(new et(s,d,o,f,l,u,h)),(s=n[4])&&e.push(new et(s,r,o,f,d,u,h)),(s=n[3])&&e.push(new et(s,d,u,a,l,c,f)),(s=n[2])&&e.push(new et(s,r,u,a,d,c,f)),(s=n[1])&&e.push(new et(s,d,o,a,l,u,f)),(s=n[0])&&e.push(new et(s,r,o,a,d,u,f))}return this}function Ip(i){var e=[],t=[],n;for(this._root&&e.push(new et(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));n=e.pop();){var s=n.node;if(s.length){var r,o=n.x0,a=n.y0,l=n.z0,c=n.x1,h=n.y1,d=n.z1,u=(o+c)/2,f=(a+h)/2,m=(l+d)/2;(r=s[0])&&e.push(new et(r,o,a,l,u,f,m)),(r=s[1])&&e.push(new et(r,u,a,l,c,f,m)),(r=s[2])&&e.push(new et(r,o,f,l,u,h,m)),(r=s[3])&&e.push(new et(r,u,f,l,c,h,m)),(r=s[4])&&e.push(new et(r,o,a,m,u,f,d)),(r=s[5])&&e.push(new et(r,u,a,m,c,f,d)),(r=s[6])&&e.push(new et(r,o,f,m,u,h,d)),(r=s[7])&&e.push(new et(r,u,f,m,c,h,d))}t.push(n)}for(;n=t.pop();)i(n.node,n.x0,n.y0,n.z0,n.x1,n.y1,n.z1);return this}function Lp(i){return i[0]}function Np(i){return arguments.length?(this._x=i,this):this._x}function Dp(i){return i[1]}function Fp(i){return arguments.length?(this._y=i,this):this._y}function kp(i){return i[2]}function Op(i){return arguments.length?(this._z=i,this):this._z}function Gr(i,e,t,n){var s=new Wh(e??Lp,t??Dp,n??kp,NaN,NaN,NaN,NaN,NaN,NaN);return i==null?s:s.addAll(i)}function Wh(i,e,t,n,s,r,o,a,l){this._x=i,this._y=e,this._z=t,this._x0=n,this._y0=s,this._z0=r,this._x1=o,this._y1=a,this._z1=l,this._root=void 0}function Up(i){for(var e={data:i.data},t=e;i=i.next;)t=t.next={data:i.data};return e}var Bt=Gr.prototype=Wh.prototype;Bt.copy=function(){var i=new Wh(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),e=this._root,t,n;if(!e)return i;if(!e.length)return i._root=Up(e),i;for(t=[{source:e,target:i._root=new Array(8)}];e=t.pop();)for(var s=0;s<8;++s)(n=e.source[s])&&(n.length?t.push({source:n,target:e.target[s]=new Array(8)}):e.target[s]=Up(n));return i};Bt.add=vp;Bt.addAll=yp;Bt.cover=bp;Bt.data=Mp;Bt.extent=Sp;Bt.find=wp;Bt.findAllWithinRadius=Ep;Bt.remove=Tp;Bt.removeAll=Ap;Bt.root=Cp;Bt.size=Rp;Bt.visit=Pp;Bt.visitAfter=Ip;Bt.x=Np;Bt.y=Fp;Bt.z=Op;function _t(i){return function(){return i}}function In(i){return(i()-.5)*1e-6}function Wy(i){return i.index}function Bp(i,e){var t=i.get(e);if(!t)throw new Error("node not found: "+e);return t}function Xh(i){var e=Wy,t=u,n,s=_t(30),r,o,a,l,c,h,d=1;i==null&&(i=[]);function u(p){return 1/Math.min(l[p.source.index],l[p.target.index])}function f(p){for(var v=0,b=i.length;v<d;++v)for(var M=0,S,w,C,_=0,A=0,P=0,R,I;M<b;++M)S=i[M],w=S.source,C=S.target,_=C.x+C.vx-w.x-w.vx||In(h),a>1&&(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);p<b;++p)S=i[p],S.index=p,typeof S.source!="object"&&(S.source=Bp(M,S.source)),typeof S.target!="object"&&(S.target=Bp(M,S.target)),l[S.source.index]=(l[S.source.index]||0)+1,l[S.target.index]=(l[S.target.index]||0)+1;for(p=0,c=new Array(b);p<b;++p)S=i[p],c[p]=l[S.source.index]/(l[S.source.index]+l[S.target.index]);n=new Array(b),x(),r=new Array(b),g()}}function x(){if(o)for(var p=0,v=i.length;p<v;++p)n[p]=+t(i[p],p,i)}function g(){if(o)for(var p=0,v=i.length;p<v;++p)r[p]=+s(i[p],p,i)}return f.initialize=function(p,...v){o=p,h=v.find(b=>typeof 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<e;++i){if(!(n=arguments[i]+"")||n in t||/[\s.]/.test(n))throw new Error("illegal type: "+n);t[n]=[]}return new gl(t)}function gl(i){this._=i}function qy(i,e){return i.trim().split(/^|\s+/).map(function(t){var n="",s=t.indexOf(".");if(s>=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}})}gl.prototype=Vp.prototype={constructor:gl,on:function(i,e){var t=this._,n=qy(i+"",t),s,r=-1,o=n.length;if(arguments.length<2){for(;++r<o;)if((s=(i=n[r]).type)&&(s=Yy(t[s],i.name)))return s;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++r<o;)if(s=(i=n[r]).type)t[s]=zp(t[s],i.name,e);else if(e==null)for(s in t)t[s]=zp(t[s],i.name,null);return this},copy:function(){var i={},e=this._;for(var t in e)i[t]=e[t].slice();return new gl(i)},call:function(i,e){if((s=arguments.length-2)>0)for(var t=new Array(s),n=0,s,r;n<s;++n)t[n]=arguments[n+2];if(!this._.hasOwnProperty(i))throw new Error("unknown type: "+i);for(r=this._[i],n=0,s=r.length;n<s;++n)r[n].value.apply(e,t)},apply:function(i,e,t){if(!this._.hasOwnProperty(i))throw new Error("unknown type: "+i);for(var n=this._[i],s=0,r=n.length;s<r;++s)n[s].value.apply(e,t)}};function Yy(i,e){for(var t=0,n=i.length,s;t<n;++t)if((s=i[t]).name===e)return s.value}function zp(i,e,t){for(var n=0,s=i.length;n<s;++n)if(i[n].name===e){i[n]=Xy,i=i.slice(0,n).concat(i.slice(n+1));break}return t!=null&&i.push({name:e,value:t}),i}var qh=Vp;var Us=0,Wr=0,Hr=0,Hp=1e3,xl,Xr,vl=0,ns=0,_l=0,qr=typeof performance=="object"&&performance.now?performance:Date,Wp=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(i){setTimeout(i,17)};function $h(){return ns||(Wp(Zy),ns=qr.now()+_l)}function Zy(){ns=0}function Yh(){this._call=this._time=this._next=null}Yh.prototype=yl.prototype={constructor:Yh,restart:function(i,e,t){if(typeof i!="function")throw new TypeError("callback is not a function");t=(t==null?$h():+t)+(e==null?0:+e),!this._next&&Xr!==this&&(Xr?Xr._next=this:xl=this,Xr=this),this._call=i,this._time=t,Zh()},stop:function(){this._call&&(this._call=null,this._time=1/0,Zh())}};function yl(i,e,t){var n=new Yh;return n.restart(i,e,t),n}function Xp(){$h(),++Us;for(var i=xl,e;i;)(e=ns-i._time)>=0&&i._call.call(void 0,e),i=i._next;--Us}function Gp(){ns=(vl=qr.now())+_l,Us=Wr=0;try{Xp()}finally{Us=0,Ky(),ns=0}}function $y(){var i=qr.now(),e=i-vl;e>Hp&&(_l-=e,vl=i)}function Ky(){for(var i,e=xl,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:xl=t);Xr=i,Zh(n)}function Zh(i){if(!Us){Wr&&(Wr=clearTimeout(Wr));var e=i-ns;e>24?(i<1/0&&(Wr=setTimeout(Gp,i-qr.now()-_l)),Hr&&(Hr=clearInterval(Hr))):(Hr||(vl=qr.now(),Hr=setInterval($y,Hp)),Us=1,Wp(Gp))}}function qp(){let i=1;return()=>(i=(1664525*i+1013904223)%4294967296)/4294967296}var Yp=3;function bl(i){return i.x}function Kh(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 Jh(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=yl(f),d=qh("tick","end"),u=qp();i==null&&(i=[]);function f(){m(),d.call("tick",n),s<r&&(h.stop(),d.call("end",n))}function m(p){var v,b=i.length,M;p===void 0&&(p=1);for(var S=0;S<p;++S)for(s+=(a-s)*o,c.forEach(function(w){w(s)}),v=0;v<b;++v)M=i[v],M.fx==null?M.x+=M.vx*=l:(M.x=M.fx,M.vx=0),t>1&&(M.fy==null?M.y+=M.vy*=l:(M.y=M.fy,M.vy=0)),t>2&&(M.fz==null?M.z+=M.vz*=l:(M.z=M.fz,M.vz=0));return n}function x(){for(var p=0,v=i.length,b;p<v;++p){if(b=i[p],b.index=p,b.fx!=null&&(b.x=b.fx),b.fy!=null&&(b.y=b.fy),b.fz!=null&&(b.z=b.fz),isNaN(b.x)||t>1&&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;w<C;++w)I=i[w],_=v-I.x,A=b-(I.y||0),P=M-(I.z||0),R=_*_+A*A+P*P,R<S&&(H=I,S=R);return H},on:function(p,v){return arguments.length>1?(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?zr(i,bl):e===2?Vr(i,bl,Kh):e===3?Gr(i,bl,Kh,Zp):null).visitAfter(u);for(s=m,x=0;x<g;++x)t=i[x],p.visit(f)}function d(){if(i){var m,x=i.length,g;for(o=new Array(x),m=0;m<x;++m)g=i[m],o[g.index]=+r(g,m,i)}}function u(m){var x=0,g,p,v=0,b,M,S,w,C=m.length;if(C){for(b=M=S=w=0;w<C;++w)(g=m[w])&&(p=Math.abs(g.value))&&(x+=g.value,v+=p,b+=p*(g.x||0),M+=p*(g.y||0),S+=p*(g.z||0));x*=Math.sqrt(4/C),m.x=b/v,e>1&&(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 _<l&&(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),_<a&&(_=Math.sqrt(a*_)),t.vx+=M*m.value*s/_,e>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),_<a&&(_=Math.sqrt(a*_)));do m.data!==t&&(C=o[m.data.index]*s/_,t.vx+=M*C,e>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 Qh(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;l<c;++l)h=t[l],h.vx+=(s[l]-h.x)*n[l]*a}function o(){if(t){var a,l=t.length;for(n=new Array(l),s=new Array(l),a=0;a<l;++a)n[a]=isNaN(s[a]=+i(t[a],a,t))?0:+e(t[a],a,t)}}return r.initialize=function(a){t=a,o()},r.strength=function(a){return arguments.length?(e=typeof a=="function"?a:_t(+a),o(),r):e},r.x=function(a){return arguments.length?(i=typeof a=="function"?a:_t(+a),o(),r):i},r}function eu(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;l<c;++l)h=t[l],h.vy+=(s[l]-h.y)*n[l]*a}function o(){if(t){var a,l=t.length;for(n=new Array(l),s=new Array(l),a=0;a<l;++a)n[a]=isNaN(s[a]=+i(t[a],a,t))?0:+e(t[a],a,t)}}return r.initialize=function(a){t=a,o()},r.strength=function(a){return arguments.length?(e=typeof a=="function"?a:_t(+a),o(),r):e},r.y=function(a){return arguments.length?(i=typeof a=="function"?a:_t(+a),o(),r):i},r}function tu(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;l<c;++l)h=t[l],h.vz+=(s[l]-h.z)*n[l]*a}function o(){if(t){var a,l=t.length;for(n=new Array(l),s=new Array(l),a=0;a<l;++a)n[a]=isNaN(s[a]=+i(t[a],a,t))?0:+e(t[a],a,t)}}return r.initialize=function(a){t=a,o()},r.strength=function(a){return arguments.length?(e=typeof a=="function"?a:_t(+a),o(),r):e},r.z=function(a){return arguments.length?(i=typeof a=="function"?a:_t(+a),o(),r):i},r}var Yr=class{constructor(){this.positions=new Float32Array(0);this.sim=null;this.simNodes=[];this.degrees=[];this.settled=!0;this._ticks=0}get ticks(){return this._ticks}init(e,t,n,s=1){this.dispose(),this.positions=t,this.degrees=e.nodes.map(o=>Math.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=Jh(this.simNodes,3).alphaDecay(1-Math.pow(.001,1/300)).velocityDecay(n.velocityDecay).force("link",Xh(r).distance(n.linkDistance).strength(this.linkStrengthFn(n.linkStrength))).force("charge",jh().strength(n.charge).distanceMax(800)).force("x",Qh(0).strength(n.centerPull)).force("y",eu(0).strength(n.centerPull+n.flatten)).force("z",tu(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<n.length;s++){let r=n[s];r&&(t[s*3]=r.x,t[s*3+1]=r.y,t[s*3+2]=r.z)}return e.alpha()<e.alphaMin()&&(this.settled=!0),!this.settled}isSettled(){return this.settled}reheat(e=.3){this.sim&&(this.sim.alpha(Math.max(this.sim.alpha(),e)),this.settled=!1)}dispose(){this.sim?.stop(),this.sim=null,this.simNodes=[],this.settled=!0}};var $p=`"use strict";(()=>{function Nt(t){let e=+this._x.call(null,t);return At(this.cover(e),e,t)}function At(t,e,r){if(isNaN(e))return t;var n,i=t._root,o={data:r},f=t._x0,a=t._x1,s,l,h,c,x;if(!i)return t._root=o,t;for(;i.length;)if((h=e>=(s=(f+a)/2))?f=s:a=s,n=i,!(i=i[c=+h]))return n[c]=o,t;if(l=+t._x.call(null,i.data),e===l)return o.next=i,n?n[c]=o:t._root=o,t;do n=n?n[c]=new Array(2):t._root=new Array(2),(h=e>=(s=(f+a)/2))?f=s:a=s;while((c=+h)==(x=+(l>=s)));return n[x]=i,n[c]=o,t}function Mt(t){Array.isArray(t)||(t=Array.from(t));let e=t.length,r=new Float64Array(e),n=1/0,i=-1/0;for(let o=0,f;o<e;++o)isNaN(f=+this._x.call(null,t[o]))||(r[o]=f,f<n&&(n=f),f>i&&(i=f));if(n>i)return this;this.cover(n).cover(i);for(let o=0;o<e;++o)At(this,r[o],t[o]);return this}function zt(t){if(isNaN(t=+t))return this;var e=this._x0,r=this._x1;if(isNaN(e))r=(e=Math.floor(t))+1;else{for(var n=r-e||1,i=this._root,o,f;e>t||t>=r;)switch(f=+(t<e),o=new Array(2),o[f]=i,i=o,n*=2,f){case 0:r=e+n;break;case 1:e=r-n;break}this._root&&this._root.length&&(this._root=i)}return this._x0=e,this._x1=r,this}function bt(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function kt(t){return arguments.length?this.cover(+t[0][0]).cover(+t[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]}function E(t,e,r){this.node=t,this.x0=e,this.x1=r}function qt(t,e){var r,n=this._x0,i,o,f=this._x1,a=[],s=this._root,l,h;for(s&&a.push(new E(s,n,f)),e==null?e=1/0:(n=t-e,f=t+e);l=a.pop();)if(!(!(s=l.node)||(i=l.x0)>f||(o=l.x1)<n))if(s.length){var c=(i+o)/2;a.push(new E(s[1],c,o),new E(s[0],i,c)),(h=+(t>=c))&&(l=a[a.length-1],a[a.length-1]=a[a.length-1-h],a[a.length-1-h]=l)}else{var x=Math.abs(t-+this._x.call(null,s.data));x<e&&(e=x,n=t-x,f=t+x,r=s.data)}return r}function It(t){if(isNaN(s=+this._x.call(null,t)))return this;var e,r=this._root,n,i,o,f=this._x0,a=this._x1,s,l,h,c,x;if(!r)return this;if(r.length)for(;;){if((h=s>=(l=(f+a)/2))?f=l:a=l,e=r,!(r=r[c=+h]))return this;if(!r.length)break;e[c+1&1]&&(n=e,x=c)}for(;r.data!==t;)if(i=r,!(r=r.next))return this;return(o=r.next)&&delete r.next,i?(o?i.next=o:delete i.next,this):e?(o?e[c]=o:delete e[c],(r=e[0]||e[1])&&r===(e[1]||e[0])&&!r.length&&(n?n[x]=r:this._root=r),this):(this._root=o,this)}function Pt(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this}function Ft(){return this._root}function Wt(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function Dt(t){var e=[],r,n=this._root,i,o,f;for(n&&e.push(new E(n,this._x0,this._x1));r=e.pop();)if(!t(n=r.node,o=r.x0,f=r.x1)&&n.length){var a=(o+f)/2;(i=n[1])&&e.push(new E(i,a,f)),(i=n[0])&&e.push(new E(i,o,a))}return this}function St(t){var e=[],r=[],n;for(this._root&&e.push(new E(this._root,this._x0,this._x1));n=e.pop();){var i=n.node;if(i.length){var o,f=n.x0,a=n.x1,s=(f+a)/2;(o=i[0])&&e.push(new E(o,f,s)),(o=i[1])&&e.push(new E(o,s,a))}r.push(n)}for(;n=r.pop();)t(n.node,n.x0,n.x1);return this}function Bt(t){return t[0]}function Et(t){return arguments.length?(this._x=t,this):this._x}function X(t,e){var r=new nt(e??Bt,NaN,NaN);return t==null?r:r.addAll(t)}function nt(t,e,r){this._x=t,this._x0=e,this._x1=r,this._root=void 0}function jt(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var D=X.prototype=nt.prototype;D.copy=function(){var t=new nt(this._x,this._x0,this._x1),e=this._root,r,n;if(!e)return t;if(!e.length)return t._root=jt(e),t;for(r=[{source:e,target:t._root=new Array(2)}];e=r.pop();)for(var i=0;i<2;++i)(n=e.source[i])&&(n.length?r.push({source:n,target:e.target[i]=new Array(2)}):e.target[i]=jt(n));return t};D.add=Nt;D.addAll=Mt;D.cover=zt;D.data=bt;D.extent=kt;D.find=qt;D.remove=It;D.removeAll=Pt;D.root=Ft;D.size=Wt;D.visit=Dt;D.visitAfter=St;D.x=Et;function Tt(t){let e=+this._x.call(null,t),r=+this._y.call(null,t);return Lt(this.cover(e,r),e,r,t)}function Lt(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var i,o=t._root,f={data:n},a=t._x0,s=t._y0,l=t._x1,h=t._y1,c,x,v,p,w,y,u,m;if(!o)return t._root=f,t;for(;o.length;)if((w=e>=(c=(a+l)/2))?a=c:l=c,(y=r>=(x=(s+h)/2))?s=x:h=x,i=o,!(o=o[u=y<<1|w]))return i[u]=f,t;if(v=+t._x.call(null,o.data),p=+t._y.call(null,o.data),e===v&&r===p)return f.next=o,i?i[u]=f:t._root=f,t;do i=i?i[u]=new Array(4):t._root=new Array(4),(w=e>=(c=(a+l)/2))?a=c:l=c,(y=r>=(x=(s+h)/2))?s=x:h=x;while((u=y<<1|w)===(m=(p>=x)<<1|v>=c));return i[m]=o,i[u]=f,t}function Ot(t){var e,r,n=t.length,i,o,f=new Array(n),a=new Array(n),s=1/0,l=1/0,h=-1/0,c=-1/0;for(r=0;r<n;++r)isNaN(i=+this._x.call(null,e=t[r]))||isNaN(o=+this._y.call(null,e))||(f[r]=i,a[r]=o,i<s&&(s=i),i>h&&(h=i),o<l&&(l=o),o>c&&(c=o));if(s>h||l>c)return this;for(this.cover(s,l).cover(h,c),r=0;r<n;++r)Lt(this,f[r],a[r],t[r]);return this}function Xt(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var r=this._x0,n=this._y0,i=this._x1,o=this._y1;if(isNaN(r))i=(r=Math.floor(t))+1,o=(n=Math.floor(e))+1;else{for(var f=i-r||1,a=this._root,s,l;r>t||t>=i||n>e||e>=o;)switch(l=(e<n)<<1|t<r,s=new Array(4),s[l]=a,a=s,f*=2,l){case 0:i=r+f,o=n+f;break;case 1:r=i-f,o=n+f;break;case 2:i=r+f,n=o-f;break;case 3:r=i-f,n=o-f;break}this._root&&this._root.length&&(this._root=a)}return this._x0=r,this._y0=n,this._x1=i,this._y1=o,this}function Rt(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function Yt(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function I(t,e,r,n,i){this.node=t,this.x0=e,this.y0=r,this.x1=n,this.y1=i}function Ct(t,e,r){var n,i=this._x0,o=this._y0,f,a,s,l,h=this._x1,c=this._y1,x=[],v=this._root,p,w;for(v&&x.push(new I(v,i,o,h,c)),r==null?r=1/0:(i=t-r,o=e-r,h=t+r,c=e+r,r*=r);p=x.pop();)if(!(!(v=p.node)||(f=p.x0)>h||(a=p.y0)>c||(s=p.x1)<i||(l=p.y1)<o))if(v.length){var y=(f+s)/2,u=(a+l)/2;x.push(new I(v[3],y,u,s,l),new I(v[2],f,u,y,l),new I(v[1],y,a,s,u),new I(v[0],f,a,y,u)),(w=(e>=u)<<1|t>=y)&&(p=x[x.length-1],x[x.length-1]=x[x.length-1-w],x[x.length-1-w]=p)}else{var m=t-+this._x.call(null,v.data),d=e-+this._y.call(null,v.data),g=m*m+d*d;if(g<r){var _=Math.sqrt(r=g);i=t-_,o=e-_,h=t+_,c=e+_,n=v.data}}return n}function Ht(t){if(isNaN(h=+this._x.call(null,t))||isNaN(c=+this._y.call(null,t)))return this;var e,r=this._root,n,i,o,f=this._x0,a=this._y0,s=this._x1,l=this._y1,h,c,x,v,p,w,y,u;if(!r)return this;if(r.length)for(;;){if((p=h>=(x=(f+s)/2))?f=x:s=x,(w=c>=(v=(a+l)/2))?a=v:l=v,e=r,!(r=r[y=w<<1|p]))return this;if(!r.length)break;(e[y+1&3]||e[y+2&3]||e[y+3&3])&&(n=e,u=y)}for(;r.data!==t;)if(i=r,!(r=r.next))return this;return(o=r.next)&&delete r.next,i?(o?i.next=o:delete i.next,this):e?(o?e[y]=o:delete e[y],(r=e[0]||e[1]||e[2]||e[3])&&r===(e[3]||e[2]||e[1]||e[0])&&!r.length&&(n?n[u]=r:this._root=r),this):(this._root=o,this)}function Qt(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this}function Zt(){return this._root}function Ut(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function Gt(t){var e=[],r,n=this._root,i,o,f,a,s;for(n&&e.push(new I(n,this._x0,this._y0,this._x1,this._y1));r=e.pop();)if(!t(n=r.node,o=r.x0,f=r.y0,a=r.x1,s=r.y1)&&n.length){var l=(o+a)/2,h=(f+s)/2;(i=n[3])&&e.push(new I(i,l,h,a,s)),(i=n[2])&&e.push(new I(i,o,h,l,s)),(i=n[1])&&e.push(new I(i,l,f,a,h)),(i=n[0])&&e.push(new I(i,o,f,l,h))}return this}function Jt(t){var e=[],r=[],n;for(this._root&&e.push(new I(this._root,this._x0,this._y0,this._x1,this._y1));n=e.pop();){var i=n.node;if(i.length){var o,f=n.x0,a=n.y0,s=n.x1,l=n.y1,h=(f+s)/2,c=(a+l)/2;(o=i[0])&&e.push(new I(o,f,a,h,c)),(o=i[1])&&e.push(new I(o,h,a,s,c)),(o=i[2])&&e.push(new I(o,f,c,h,l)),(o=i[3])&&e.push(new I(o,h,c,s,l))}r.push(n)}for(;n=r.pop();)t(n.node,n.x0,n.y0,n.x1,n.y1);return this}function Kt(t){return t[0]}function Vt(t){return arguments.length?(this._x=t,this):this._x}function $t(t){return t[1]}function te(t){return arguments.length?(this._y=t,this):this._y}function R(t,e,r){var n=new it(e??Kt,r??$t,NaN,NaN,NaN,NaN);return t==null?n:n.addAll(t)}function it(t,e,r,n,i,o){this._x=t,this._y=e,this._x0=r,this._y0=n,this._x1=i,this._y1=o,this._root=void 0}function ee(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var F=R.prototype=it.prototype;F.copy=function(){var t=new it(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,r,n;if(!e)return t;if(!e.length)return t._root=ee(e),t;for(r=[{source:e,target:t._root=new Array(4)}];e=r.pop();)for(var i=0;i<4;++i)(n=e.source[i])&&(n.length?r.push({source:n,target:e.target[i]=new Array(4)}):e.target[i]=ee(n));return t};F.add=Tt;F.addAll=Ot;F.cover=Xt;F.data=Rt;F.extent=Yt;F.find=Ct;F.remove=Ht;F.removeAll=Qt;F.root=Zt;F.size=Ut;F.visit=Gt;F.visitAfter=Jt;F.x=Vt;F.y=te;function re(t){let e=+this._x.call(null,t),r=+this._y.call(null,t),n=+this._z.call(null,t);return ne(this.cover(e,r,n),e,r,n,t)}function ne(t,e,r,n,i){if(isNaN(e)||isNaN(r)||isNaN(n))return t;var o,f=t._root,a={data:i},s=t._x0,l=t._y0,h=t._z0,c=t._x1,x=t._y1,v=t._z1,p,w,y,u,m,d,g,_,N,A,M;if(!f)return t._root=a,t;for(;f.length;)if((g=e>=(p=(s+c)/2))?s=p:c=p,(_=r>=(w=(l+x)/2))?l=w:x=w,(N=n>=(y=(h+v)/2))?h=y:v=y,o=f,!(f=f[A=N<<2|_<<1|g]))return o[A]=a,t;if(u=+t._x.call(null,f.data),m=+t._y.call(null,f.data),d=+t._z.call(null,f.data),e===u&&r===m&&n===d)return a.next=f,o?o[A]=a:t._root=a,t;do o=o?o[A]=new Array(8):t._root=new Array(8),(g=e>=(p=(s+c)/2))?s=p:c=p,(_=r>=(w=(l+x)/2))?l=w:x=w,(N=n>=(y=(h+v)/2))?h=y:v=y;while((A=N<<2|_<<1|g)===(M=(d>=y)<<2|(m>=w)<<1|u>=p));return o[M]=f,o[A]=a,t}function ie(t){Array.isArray(t)||(t=Array.from(t));let e=t.length,r=new Float64Array(e),n=new Float64Array(e),i=new Float64Array(e),o=1/0,f=1/0,a=1/0,s=-1/0,l=-1/0,h=-1/0;for(let c=0,x,v,p,w;c<e;++c)isNaN(v=+this._x.call(null,x=t[c]))||isNaN(p=+this._y.call(null,x))||isNaN(w=+this._z.call(null,x))||(r[c]=v,n[c]=p,i[c]=w,v<o&&(o=v),v>s&&(s=v),p<f&&(f=p),p>l&&(l=p),w<a&&(a=w),w>h&&(h=w));if(o>s||f>l||a>h)return this;this.cover(o,f,a).cover(s,l,h);for(let c=0;c<e;++c)ne(this,r[c],n[c],i[c],t[c]);return this}function oe(t,e,r){if(isNaN(t=+t)||isNaN(e=+e)||isNaN(r=+r))return this;var n=this._x0,i=this._y0,o=this._z0,f=this._x1,a=this._y1,s=this._z1;if(isNaN(n))f=(n=Math.floor(t))+1,a=(i=Math.floor(e))+1,s=(o=Math.floor(r))+1;else{for(var l=f-n||1,h=this._root,c,x;n>t||t>=f||i>e||e>=a||o>r||r>=s;)switch(x=(r<o)<<2|(e<i)<<1|t<n,c=new Array(8),c[x]=h,h=c,l*=2,x){case 0:f=n+l,a=i+l,s=o+l;break;case 1:n=f-l,a=i+l,s=o+l;break;case 2:f=n+l,i=a-l,s=o+l;break;case 3:n=f-l,i=a-l,s=o+l;break;case 4:f=n+l,a=i+l,o=s-l;break;case 5:n=f-l,a=i+l,o=s-l;break;case 6:f=n+l,i=a-l,o=s-l;break;case 7:n=f-l,i=a-l,o=s-l;break}this._root&&this._root.length&&(this._root=h)}return this._x0=n,this._y0=i,this._z0=o,this._x1=f,this._y1=a,this._z1=s,this}function ae(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function fe(t){return arguments.length?this.cover(+t[0][0],+t[0][1],+t[0][2]).cover(+t[1][0],+t[1][1],+t[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]}function z(t,e,r,n,i,o,f){this.node=t,this.x0=e,this.y0=r,this.z0=n,this.x1=i,this.y1=o,this.z1=f}function se(t,e,r,n){var i,o=this._x0,f=this._y0,a=this._z0,s,l,h,c,x,v,p=this._x1,w=this._y1,y=this._z1,u=[],m=this._root,d,g;for(m&&u.push(new z(m,o,f,a,p,w,y)),n==null?n=1/0:(o=t-n,f=e-n,a=r-n,p=t+n,w=e+n,y=r+n,n*=n);d=u.pop();)if(!(!(m=d.node)||(s=d.x0)>p||(l=d.y0)>w||(h=d.z0)>y||(c=d.x1)<o||(x=d.y1)<f||(v=d.z1)<a))if(m.length){var _=(s+c)/2,N=(l+x)/2,A=(h+v)/2;u.push(new z(m[7],_,N,A,c,x,v),new z(m[6],s,N,A,_,x,v),new z(m[5],_,l,A,c,N,v),new z(m[4],s,l,A,_,N,v),new z(m[3],_,N,h,c,x,A),new z(m[2],s,N,h,_,x,A),new z(m[1],_,l,h,c,N,A),new z(m[0],s,l,h,_,N,A)),(g=(r>=A)<<2|(e>=N)<<1|t>=_)&&(d=u[u.length-1],u[u.length-1]=u[u.length-1-g],u[u.length-1-g]=d)}else{var M=t-+this._x.call(null,m.data),S=e-+this._y.call(null,m.data),B=r-+this._z.call(null,m.data),W=M*M+S*S+B*B;if(W<n){var k=Math.sqrt(n=W);o=t-k,f=e-k,a=r-k,p=t+k,w=e+k,y=r+k,i=m.data}}return i}var Ee=(t,e,r,n,i,o)=>Math.sqrt((t-n)**2+(e-i)**2+(r-o)**2);function ue(t,e,r,n){let i=[],o=t-n,f=e-n,a=r-n,s=t+n,l=e+n,h=r+n;return this.visit((c,x,v,p,w,y,u)=>{if(!c.length)do{let m=c.data;Ee(t,e,r,this._x(m),this._y(m),this._z(m))<=n&&i.push(m)}while(c=c.next);return x>s||v>l||p>h||w<o||y<f||u<a}),i}function le(t){if(isNaN(x=+this._x.call(null,t))||isNaN(v=+this._y.call(null,t))||isNaN(p=+this._z.call(null,t)))return this;var e,r=this._root,n,i,o,f=this._x0,a=this._y0,s=this._z0,l=this._x1,h=this._y1,c=this._z1,x,v,p,w,y,u,m,d,g,_,N;if(!r)return this;if(r.length)for(;;){if((m=x>=(w=(f+l)/2))?f=w:l=w,(d=v>=(y=(a+h)/2))?a=y:h=y,(g=p>=(u=(s+c)/2))?s=u:c=u,e=r,!(r=r[_=g<<2|d<<1|m]))return this;if(!r.length)break;(e[_+1&7]||e[_+2&7]||e[_+3&7]||e[_+4&7]||e[_+5&7]||e[_+6&7]||e[_+7&7])&&(n=e,N=_)}for(;r.data!==t;)if(i=r,!(r=r.next))return this;return(o=r.next)&&delete r.next,i?(o?i.next=o:delete i.next,this):e?(o?e[_]=o:delete e[_],(r=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&r===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!r.length&&(n?n[N]=r:this._root=r),this):(this._root=o,this)}function he(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this}function ce(){return this._root}function pe(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function xe(t){var e=[],r,n=this._root,i,o,f,a,s,l,h;for(n&&e.push(new z(n,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));r=e.pop();)if(!t(n=r.node,o=r.x0,f=r.y0,a=r.z0,s=r.x1,l=r.y1,h=r.z1)&&n.length){var c=(o+s)/2,x=(f+l)/2,v=(a+h)/2;(i=n[7])&&e.push(new z(i,c,x,v,s,l,h)),(i=n[6])&&e.push(new z(i,o,x,v,c,l,h)),(i=n[5])&&e.push(new z(i,c,f,v,s,x,h)),(i=n[4])&&e.push(new z(i,o,f,v,c,x,h)),(i=n[3])&&e.push(new z(i,c,x,a,s,l,v)),(i=n[2])&&e.push(new z(i,o,x,a,c,l,v)),(i=n[1])&&e.push(new z(i,c,f,a,s,x,v)),(i=n[0])&&e.push(new z(i,o,f,a,c,x,v))}return this}function _e(t){var e=[],r=[],n;for(this._root&&e.push(new z(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));n=e.pop();){var i=n.node;if(i.length){var o,f=n.x0,a=n.y0,s=n.z0,l=n.x1,h=n.y1,c=n.z1,x=(f+l)/2,v=(a+h)/2,p=(s+c)/2;(o=i[0])&&e.push(new z(o,f,a,s,x,v,p)),(o=i[1])&&e.push(new z(o,x,a,s,l,v,p)),(o=i[2])&&e.push(new z(o,f,v,s,x,h,p)),(o=i[3])&&e.push(new z(o,x,v,s,l,h,p)),(o=i[4])&&e.push(new z(o,f,a,p,x,v,c)),(o=i[5])&&e.push(new z(o,x,a,p,l,v,c)),(o=i[6])&&e.push(new z(o,f,v,p,x,h,c)),(o=i[7])&&e.push(new z(o,x,v,p,l,h,c))}r.push(n)}for(;n=r.pop();)t(n.node,n.x0,n.y0,n.z0,n.x1,n.y1,n.z1);return this}function ve(t){return t[0]}function ye(t){return arguments.length?(this._x=t,this):this._x}function ge(t){return t[1]}function de(t){return arguments.length?(this._y=t,this):this._y}function me(t){return t[2]}function we(t){return arguments.length?(this._z=t,this):this._z}function Y(t,e,r,n){var i=new ot(e??ve,r??ge,n??me,NaN,NaN,NaN,NaN,NaN,NaN);return t==null?i:i.addAll(t)}function ot(t,e,r,n,i,o,f,a,s){this._x=t,this._y=e,this._z=r,this._x0=n,this._y0=i,this._z0=o,this._x1=f,this._y1=a,this._z1=s,this._root=void 0}function Ne(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var P=Y.prototype=ot.prototype;P.copy=function(){var t=new ot(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),e=this._root,r,n;if(!e)return t;if(!e.length)return t._root=Ne(e),t;for(r=[{source:e,target:t._root=new Array(8)}];e=r.pop();)for(var i=0;i<8;++i)(n=e.source[i])&&(n.length?r.push({source:n,target:e.target[i]=new Array(8)}):e.target[i]=Ne(n));return t};P.add=re;P.addAll=ie;P.cover=oe;P.data=ae;P.extent=fe;P.find=se;P.findAllWithinRadius=ue;P.remove=le;P.removeAll=he;P.root=ce;P.size=pe;P.visit=xe;P.visitAfter=_e;P.x=ye;P.y=de;P.z=we;function b(t){return function(){return t}}function j(t){return(t()-.5)*1e-6}function je(t){return t.index}function Ae(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function at(t){var e=je,r=x,n,i=b(30),o,f,a,s,l,h,c=1;t==null&&(t=[]);function x(u){return 1/Math.min(s[u.source.index],s[u.target.index])}function v(u){for(var m=0,d=t.length;m<c;++m)for(var g=0,_,N,A,M=0,S=0,B=0,W,k;g<d;++g)_=t[g],N=_.source,A=_.target,M=A.x+A.vx-N.x-N.vx||j(h),a>1&&(S=A.y+A.vy-N.y-N.vy||j(h)),a>2&&(B=A.z+A.vz-N.z-N.vz||j(h)),W=Math.sqrt(M*M+S*S+B*B),W=(W-o[g])/W*u*n[g],M*=W,S*=W,B*=W,A.vx-=M*(k=l[g]),a>1&&(A.vy-=S*k),a>2&&(A.vz-=B*k),N.vx+=M*(k=1-k),a>1&&(N.vy+=S*k),a>2&&(N.vz+=B*k)}function p(){if(f){var u,m=f.length,d=t.length,g=new Map(f.map((N,A)=>[e(N,A,f),N])),_;for(u=0,s=new Array(m);u<d;++u)_=t[u],_.index=u,typeof _.source!="object"&&(_.source=Ae(g,_.source)),typeof _.target!="object"&&(_.target=Ae(g,_.target)),s[_.source.index]=(s[_.source.index]||0)+1,s[_.target.index]=(s[_.target.index]||0)+1;for(u=0,l=new Array(d);u<d;++u)_=t[u],l[u]=s[_.source.index]/(s[_.source.index]+s[_.target.index]);n=new Array(d),w(),o=new Array(d),y()}}function w(){if(f)for(var u=0,m=t.length;u<m;++u)n[u]=+r(t[u],u,t)}function y(){if(f)for(var u=0,m=t.length;u<m;++u)o[u]=+i(t[u],u,t)}return v.initialize=function(u,...m){f=u,h=m.find(d=>typeof d=="function")||Math.random,a=m.find(d=>[1,2,3].includes(d))||2,p()},v.links=function(u){return arguments.length?(t=u,p(),v):t},v.id=function(u){return arguments.length?(e=u,v):e},v.iterations=function(u){return arguments.length?(c=+u,v):c},v.strength=function(u){return arguments.length?(r=typeof u=="function"?u:b(+u),w(),v):r},v.distance=function(u){return arguments.length?(i=typeof u=="function"?u:b(+u),y(),v):i},v}var Te={value:()=>{}};function ze(){for(var t=0,e=arguments.length,r={},n;t<e;++t){if(!(n=arguments[t]+"")||n in r||/[\\s.]/.test(n))throw new Error("illegal type: "+n);r[n]=[]}return new G(r)}function G(t){this._=t}function Le(t,e){return t.trim().split(/^|\\s+/).map(function(r){var n="",i=r.indexOf(".");if(i>=0&&(n=r.slice(i+1),r=r.slice(0,i)),r&&!e.hasOwnProperty(r))throw new Error("unknown type: "+r);return{type:r,name:n}})}G.prototype=ze.prototype={constructor:G,on:function(t,e){var r=this._,n=Le(t+"",r),i,o=-1,f=n.length;if(arguments.length<2){for(;++o<f;)if((i=(t=n[o]).type)&&(i=Oe(r[i],t.name)))return i;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++o<f;)if(i=(t=n[o]).type)r[i]=Me(r[i],t.name,e);else if(e==null)for(i in r)r[i]=Me(r[i],t.name,null);return this},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new G(t)},call:function(t,e){if((i=arguments.length-2)>0)for(var r=new Array(i),n=0,i,o;n<i;++n)r[n]=arguments[n+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=this._[t],n=0,i=o.length;n<i;++n)o[n].value.apply(e,r)},apply:function(t,e,r){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var n=this._[t],i=0,o=n.length;i<o;++i)n[i].value.apply(e,r)}};function Oe(t,e){for(var r=0,n=t.length,i;r<n;++r)if((i=t[r]).name===e)return i.value}function Me(t,e,r){for(var n=0,i=t.length;n<i;++n)if(t[n].name===e){t[n]=Te,t=t.slice(0,n).concat(t.slice(n+1));break}return r!=null&&t.push({name:e,value:r}),t}var ft=ze;var O=0,H=0,C=0,ke=1e3,J,Q,K=0,L=0,V=0,Z=typeof performance=="object"&&performance.now?performance:Date,qe=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function lt(){return L||(qe(Xe),L=Z.now()+V)}function Xe(){L=0}function st(){this._call=this._time=this._next=null}st.prototype=$.prototype={constructor:st,restart:function(t,e,r){if(typeof t!="function")throw new TypeError("callback is not a function");r=(r==null?lt():+r)+(e==null?0:+e),!this._next&&Q!==this&&(Q?Q._next=this:J=this,Q=this),this._call=t,this._time=r,ut()},stop:function(){this._call&&(this._call=null,this._time=1/0,ut())}};function $(t,e,r){var n=new st;return n.restart(t,e,r),n}function Ie(){lt(),++O;for(var t=J,e;t;)(e=L-t._time)>=0&&t._call.call(void 0,e),t=t._next;--O}function be(){L=(K=Z.now())+V,O=H=0;try{Ie()}finally{O=0,Ye(),L=0}}function Re(){var t=Z.now(),e=t-K;e>ke&&(V-=e,K=t)}function Ye(){for(var t,e=J,r,n=1/0;e;)e._call?(n>e._time&&(n=e._time),t=e,e=e._next):(r=e._next,e._next=null,e=t?t._next=r:J=r);Q=t,ut(n)}function ut(t){if(!O){H&&(H=clearTimeout(H));var e=t-L;e>24?(t<1/0&&(H=setTimeout(be,t-Z.now()-V)),C&&(C=clearInterval(C))):(C||(K=Z.now(),C=setInterval(Re,ke)),O=1,qe(be))}}function Pe(){let t=1;return()=>(t=(1664525*t+1013904223)%4294967296)/4294967296}var Fe=3;function tt(t){return t.x}function ht(t){return t.y}function We(t){return t.z}var Ce=10,He=Math.PI*(3-Math.sqrt(5)),Qe=Math.PI*20/(9+Math.sqrt(221));function ct(t,e){e=e||2;var r=Math.min(Fe,Math.max(1,Math.round(e))),n,i=1,o=.001,f=1-Math.pow(o,1/300),a=0,s=.6,l=new Map,h=$(v),c=ft("tick","end"),x=Pe();t==null&&(t=[]);function v(){p(),c.call("tick",n),i<o&&(h.stop(),c.call("end",n))}function p(u){var m,d=t.length,g;u===void 0&&(u=1);for(var _=0;_<u;++_)for(i+=(a-i)*f,l.forEach(function(N){N(i)}),m=0;m<d;++m)g=t[m],g.fx==null?g.x+=g.vx*=s:(g.x=g.fx,g.vx=0),r>1&&(g.fy==null?g.y+=g.vy*=s:(g.y=g.fy,g.vy=0)),r>2&&(g.fz==null?g.z+=g.vz*=s:(g.z=g.fz,g.vz=0));return n}function w(){for(var u=0,m=t.length,d;u<m;++u){if(d=t[u],d.index=u,d.fx!=null&&(d.x=d.fx),d.fy!=null&&(d.y=d.fy),d.fz!=null&&(d.z=d.fz),isNaN(d.x)||r>1&&isNaN(d.y)||r>2&&isNaN(d.z)){var g=Ce*(r>2?Math.cbrt(.5+u):r>1?Math.sqrt(.5+u):u),_=u*He,N=u*Qe;r===1?d.x=g:r===2?(d.x=g*Math.cos(_),d.y=g*Math.sin(_)):(d.x=g*Math.sin(_)*Math.cos(N),d.y=g*Math.cos(_),d.z=g*Math.sin(_)*Math.sin(N))}(isNaN(d.vx)||r>1&&isNaN(d.vy)||r>2&&isNaN(d.vz))&&(d.vx=0,r>1&&(d.vy=0),r>2&&(d.vz=0))}}function y(u){return u.initialize&&u.initialize(t,x,r),u}return w(),n={tick:p,restart:function(){return h.restart(v),n},stop:function(){return h.stop(),n},numDimensions:function(u){return arguments.length?(r=Math.min(Fe,Math.max(1,Math.round(u))),l.forEach(y),n):r},nodes:function(u){return arguments.length?(t=u,w(),l.forEach(y),n):t},alpha:function(u){return arguments.length?(i=+u,n):i},alphaMin:function(u){return arguments.length?(o=+u,n):o},alphaDecay:function(u){return arguments.length?(f=+u,n):+f},alphaTarget:function(u){return arguments.length?(a=+u,n):a},velocityDecay:function(u){return arguments.length?(s=1-u,n):1-s},randomSource:function(u){return arguments.length?(x=u,l.forEach(y),n):x},force:function(u,m){return arguments.length>1?(m==null?l.delete(u):l.set(u,y(m)),n):l.get(u)},find:function(){var u=Array.prototype.slice.call(arguments),m=u.shift()||0,d=(r>1?u.shift():null)||0,g=(r>2?u.shift():null)||0,_=u.shift()||1/0,N=0,A=t.length,M,S,B,W,k,wt;for(_*=_,N=0;N<A;++N)k=t[N],M=m-k.x,S=d-(k.y||0),B=g-(k.z||0),W=M*M+S*S+B*B,W<_&&(wt=k,_=W);return wt},on:function(u,m){return arguments.length>1?(c.on(u,m),n):c.on(u)}}}function pt(){var t,e,r,n,i,o=b(-30),f,a=1,s=1/0,l=.81;function h(p){var w,y=t.length,u=(e===1?X(t,tt):e===2?R(t,tt,ht):e===3?Y(t,tt,ht,We):null).visitAfter(x);for(i=p,w=0;w<y;++w)r=t[w],u.visit(v)}function c(){if(t){var p,w=t.length,y;for(f=new Array(w),p=0;p<w;++p)y=t[p],f[y.index]=+o(y,p,t)}}function x(p){var w=0,y,u,m=0,d,g,_,N,A=p.length;if(A){for(d=g=_=N=0;N<A;++N)(y=p[N])&&(u=Math.abs(y.value))&&(w+=y.value,m+=u,d+=u*(y.x||0),g+=u*(y.y||0),_+=u*(y.z||0));w*=Math.sqrt(4/A),p.x=d/m,e>1&&(p.y=g/m),e>2&&(p.z=_/m)}else{y=p,y.x=y.data.x,e>1&&(y.y=y.data.y),e>2&&(y.z=y.data.z);do w+=f[y.data.index];while(y=y.next)}p.value=w}function v(p,w,y,u,m){if(!p.value)return!0;var d=[y,u,m][e-1],g=p.x-r.x,_=e>1?p.y-r.y:0,N=e>2?p.z-r.z:0,A=d-w,M=g*g+_*_+N*N;if(A*A/l<M)return M<s&&(g===0&&(g=j(n),M+=g*g),e>1&&_===0&&(_=j(n),M+=_*_),e>2&&N===0&&(N=j(n),M+=N*N),M<a&&(M=Math.sqrt(a*M)),r.vx+=g*p.value*i/M,e>1&&(r.vy+=_*p.value*i/M),e>2&&(r.vz+=N*p.value*i/M)),!0;if(p.length||M>=s)return;(p.data!==r||p.next)&&(g===0&&(g=j(n),M+=g*g),e>1&&_===0&&(_=j(n),M+=_*_),e>2&&N===0&&(N=j(n),M+=N*N),M<a&&(M=Math.sqrt(a*M)));do p.data!==r&&(A=f[p.data.index]*i/M,r.vx+=g*A,e>1&&(r.vy+=_*A),e>2&&(r.vz+=N*A));while(p=p.next)}return h.initialize=function(p,...w){t=p,n=w.find(y=>typeof y=="function")||Math.random,e=w.find(y=>[1,2,3].includes(y))||2,c()},h.strength=function(p){return arguments.length?(o=typeof p=="function"?p:b(+p),c(),h):o},h.distanceMin=function(p){return arguments.length?(a=p*p,h):Math.sqrt(a)},h.distanceMax=function(p){return arguments.length?(s=p*p,h):Math.sqrt(s)},h.theta=function(p){return arguments.length?(l=p*p,h):Math.sqrt(l)},h}function xt(t){var e=b(.1),r,n,i;typeof t!="function"&&(t=b(t==null?0:+t));function o(a){for(var s=0,l=r.length,h;s<l;++s)h=r[s],h.vx+=(i[s]-h.x)*n[s]*a}function f(){if(r){var a,s=r.length;for(n=new Array(s),i=new Array(s),a=0;a<s;++a)n[a]=isNaN(i[a]=+t(r[a],a,r))?0:+e(r[a],a,r)}}return o.initialize=function(a){r=a,f()},o.strength=function(a){return arguments.length?(e=typeof a=="function"?a:b(+a),f(),o):e},o.x=function(a){return arguments.length?(t=typeof a=="function"?a:b(+a),f(),o):t},o}function _t(t){var e=b(.1),r,n,i;typeof t!="function"&&(t=b(t==null?0:+t));function o(a){for(var s=0,l=r.length,h;s<l;++s)h=r[s],h.vy+=(i[s]-h.y)*n[s]*a}function f(){if(r){var a,s=r.length;for(n=new Array(s),i=new Array(s),a=0;a<s;++a)n[a]=isNaN(i[a]=+t(r[a],a,r))?0:+e(r[a],a,r)}}return o.initialize=function(a){r=a,f()},o.strength=function(a){return arguments.length?(e=typeof a=="function"?a:b(+a),f(),o):e},o.y=function(a){return arguments.length?(t=typeof a=="function"?a:b(+a),f(),o):t},o}function vt(t){var e=b(.1),r,n,i;typeof t!="function"&&(t=b(t==null?0:+t));function o(a){for(var s=0,l=r.length,h;s<l;++s)h=r[s],h.vz+=(i[s]-h.z)*n[s]*a}function f(){if(r){var a,s=r.length;for(n=new Array(s),i=new Array(s),a=0;a<s;++a)n[a]=isNaN(i[a]=+t(r[a],a,r))?0:+e(r[a],a,r)}}return o.initialize=function(a){r=a,f()},o.strength=function(a){return arguments.length?(e=typeof a=="function"?a:b(+a),f(),o):e},o.z=function(a){return arguments.length?(t=typeof a=="function"?a:b(+a),f(),o):t},o}var De=self,q=null,U=[],yt=new Float32Array(0),gt=[],T=!0,mt=0,rt=!1,dt=!1;function Se(t){return e=>{let r=typeof e.source=="number"?e.source:e.source.index??0,n=typeof e.target=="number"?e.target:e.target.index??0,i=1/Math.min(yt[r]??1,yt[n]??1);return Math.min(i*t,1)}}function Ze(t){if(!q)return;q.force("charge")?.strength(t.charge);let e=q.force("link");e?.distance(t.linkDistance),e?.strength(Se(t.linkStrength)),q.force("x")?.strength(t.centerPull),q.force("y")?.strength(t.centerPull+t.flatten),q.force("z")?.strength(t.centerPull)}function et(){dt||(dt=!0,self.setTimeout(Ue,0))}function Ue(){dt=!1;let t=q;if(!t||T)return;let e=Date.now();for(;Date.now()-e<12;)if(t.tick(),mt++,t.alpha()<t.alphaMin()){T=!0;break}rt=!0,Be(),T||et()}function Be(){if(!rt||!q)return;let t=gt.pop();if(!t)return;let e=new Float32Array(t);for(let r=0;r<U.length;r++){let n=U[r];n&&(e[r*3]=n.x,e[r*3+1]=n.y,e[r*3+2]=n.z)}rt=!1,De.postMessage({type:"tick",buffer:t,alpha:q.alpha(),settled:T,ticks:mt},[t])}De.onmessage=t=>{let e=t.data;switch(e.type){case"init":{q?.stop();let r=new Float32Array(e.positions);yt=new Float32Array(e.degrees);let n=new Uint32Array(e.links);U=[];for(let o=0;o<e.count;o++)U.push({x:r[o*3]??0,y:r[o*3+1]??0,z:r[o*3+2]??0});let i=[];for(let o=0;o<n.length;o+=2)i.push({source:n[o]??0,target:n[o+1]??0});q=ct(U,3).alphaDecay(1-Math.pow(.001,1/300)).velocityDecay(e.params.velocityDecay).force("link",at(i).distance(e.params.linkDistance).strength(Se(e.params.linkStrength))).force("charge",pt().strength(e.params.charge).distanceMax(800)).force("x",xt(0).strength(e.params.centerPull)).force("y",_t(0).strength(e.params.centerPull+e.params.flatten)).force("z",vt(0).strength(e.params.centerPull)).stop(),q.alpha(e.initialAlpha),gt=[e.bufA,e.bufB],mt=0,T=e.initialAlpha<q.alphaMin(),rt=!1,T||et();break}case"params":Ze(e.params),q&&(q.alpha(Math.max(q.alpha(),.5)),T=!1,et());break;case"reheat":q&&(q.alpha(Math.max(q.alpha(),e.alpha)),T=!1,et());break;case"buffer":gt.push(e.buffer),Be();break}};})();
|
|
`;var Ml=class{constructor(){this.positions=new Float32Array(0);this.worker=null;this.url="";this.dirty=!1;this.settled=!0;this._ticks=0}get ticks(){return this._ticks}init(e,t,n,s=1){this.disposeWorker(),this.positions=t,this._ticks=0,this.dirty=!1,this.url=URL.createObjectURL(new Blob([$p],{type:"text/javascript"})),this.worker=new Worker(this.url),this.worker.onmessage=d=>{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 Bs={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),nu=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 nu,Oi=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 Sl=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 Oi(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 Zr=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)}},wl=class extends dn{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}};var El=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 Sl(Bs),this.copyPass.material.blending=_n,this.timer=new _r}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<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){this.timer.update(),e===void 0&&(e=this.timer.getDelta());let t=this.renderer.getRenderTarget(),n=!1;for(let s=0,r=this.passes.length;s<r;s++){let o=this.passes[s];if(o.enabled!==!1){if(o.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(s),o.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),o.needsSwap){if(n){let a=this.renderer.getContext(),l=this.renderer.state.buffers.stencil;l.setFunc(a.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),l.setFunc(a.EQUAL,1,4294967295)}this.swapBuffers()}Zr!==void 0&&(o instanceof Zr?n=!0:o instanceof wl&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){let t=this.renderer.getSize(new Ae);this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,e=this.renderTarget1.clone(),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(e,t){this._width=e,this._height=t;let n=this._width*this._pixelRatio,s=this._height*this._pixelRatio;this.renderTarget1.setSize(n,s),this.renderTarget2.setSize(n,s);for(let r=0;r<this.passes.length;r++)this.passes[r].setSize(n,s)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}};var Tl=class extends dn{constructor(e,t,n=null,s=null,r=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=s,this.clearAlpha=r,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this.isRenderPass=!0,this._oldClearColor=new ge}render(e,t,n){let s=e.autoClear;e.autoClear=!1;let r,o;this.overrideMaterial!==null&&(o=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(e.getClearColor(this._oldClearColor),e.setClearColor(this.clearColor,e.getClearAlpha())),this.clearAlpha!==null&&(r=e.getClearAlpha(),e.setClearAlpha(this.clearAlpha)),this.clearDepth==!0&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),this.clear===!0&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor!==null&&e.setClearColor(this._oldClearColor),this.clearAlpha!==null&&e.setClearAlpha(r),this.overrideMaterial!==null&&(this.scene.overrideMaterial=o),e.autoClear=s}};var Kp={name:"LuminosityHighPassShader",uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new ge(0)},defaultOpacity:{value:0}},vertexShader:`
|
|
|
|
varying vec2 vUv;
|
|
|
|
void main() {
|
|
|
|
vUv = uv;
|
|
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
|
|
}`,fragmentShader:`
|
|
|
|
uniform sampler2D tDiffuse;
|
|
uniform vec3 defaultColor;
|
|
uniform float defaultOpacity;
|
|
uniform float luminosityThreshold;
|
|
uniform float smoothWidth;
|
|
|
|
varying vec2 vUv;
|
|
|
|
void main() {
|
|
|
|
vec4 texel = texture2D( tDiffuse, vUv );
|
|
|
|
float v = luminance( texel.xyz );
|
|
|
|
vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );
|
|
|
|
float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );
|
|
|
|
gl_FragColor = mix( outputColor, texel, alpha );
|
|
|
|
}`};var zs=class i extends dn{constructor(e,t=1,n,s){super(),this.strength=t,this.radius=n,this.threshold=s,this.resolution=e!==void 0?new Ae(e.x,e.y):new Ae(256,256),this.clearColor=new ge(0,0,0),this.needsSwap=!1,this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let r=Math.round(this.resolution.x/2),o=Math.round(this.resolution.y/2);this.renderTargetBright=new Ct(r,o,{type:Xt}),this.renderTargetBright.texture.name="UnrealBloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(let h=0;h<this.nMips;h++){let d=new Ct(r,o,{type:Xt});d.texture.name="UnrealBloomPass.h"+h,d.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(d);let u=new Ct(r,o,{type:Xt});u.texture.name="UnrealBloomPass.v"+h,u.texture.generateMipmaps=!1,this.renderTargetsVertical.push(u),r=Math.round(r/2),o=Math.round(o/2)}let a=Kp;this.highPassUniforms=ci.clone(a.uniforms),this.highPassUniforms.luminosityThreshold.value=s,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new ut({uniforms:this.highPassUniforms,vertexShader:a.vertexShader,fragmentShader:a.fragmentShader}),this.separableBlurMaterials=[];let l=[6,10,14,18,22];r=Math.round(this.resolution.x/2),o=Math.round(this.resolution.y/2);for(let h=0;h<this.nMips;h++)this.separableBlurMaterials.push(this._getSeparableBlurMaterial(l[h])),this.separableBlurMaterials[h].uniforms.invSize.value=new Ae(1/r,1/o),r=Math.round(r/2),o=Math.round(o/2);this.compositeMaterial=this._getCompositeMaterial(this.nMips),this.compositeMaterial.uniforms.blurTexture1.value=this.renderTargetsVertical[0].texture,this.compositeMaterial.uniforms.blurTexture2.value=this.renderTargetsVertical[1].texture,this.compositeMaterial.uniforms.blurTexture3.value=this.renderTargetsVertical[2].texture,this.compositeMaterial.uniforms.blurTexture4.value=this.renderTargetsVertical[3].texture,this.compositeMaterial.uniforms.blurTexture5.value=this.renderTargetsVertical[4].texture,this.compositeMaterial.uniforms.bloomStrength.value=t,this.compositeMaterial.uniforms.bloomRadius.value=.1;let c=[1,.8,.6,.4,.2];this.compositeMaterial.uniforms.bloomFactors.value=c,this.bloomTintColors=[new N(1,1,1),new N(1,1,1),new N(1,1,1),new N(1,1,1),new N(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,this.copyUniforms=ci.clone(Bs.uniforms),this.blendMaterial=new ut({uniforms:this.copyUniforms,vertexShader:Bs.vertexShader,fragmentShader:Bs.fragmentShader,premultipliedAlpha:!0,blending:Mr,depthTest:!1,depthWrite:!1,transparent:!0}),this._oldClearColor=new ge,this._oldClearAlpha=1,this._basic=new si,this._fsQuad=new Oi(null)}dispose(){for(let e=0;e<this.renderTargetsHorizontal.length;e++)this.renderTargetsHorizontal[e].dispose();for(let e=0;e<this.renderTargetsVertical.length;e++)this.renderTargetsVertical[e].dispose();this.renderTargetBright.dispose();for(let e=0;e<this.separableBlurMaterials.length;e++)this.separableBlurMaterials[e].dispose();this.compositeMaterial.dispose(),this.blendMaterial.dispose(),this._basic.dispose(),this._fsQuad.dispose()}setSize(e,t){let n=Math.round(e/2),s=Math.round(t/2);this.renderTargetBright.setSize(n,s);for(let r=0;r<this.nMips;r++)this.renderTargetsHorizontal[r].setSize(n,s),this.renderTargetsVertical[r].setSize(n,s),this.separableBlurMaterials[r].uniforms.invSize.value=new Ae(1/n,1/s),n=Math.round(n/2),s=Math.round(s/2)}render(e,t,n,s,r){e.getClearColor(this._oldClearColor),this._oldClearAlpha=e.getClearAlpha();let o=e.autoClear;e.autoClear=!1,e.setClearColor(this.clearColor,0),r&&e.state.buffers.stencil.setTest(!1),this.renderToScreen&&(this._fsQuad.material=this._basic,this._basic.map=n.texture,e.setRenderTarget(null),e.clear(),this._fsQuad.render(e)),this.highPassUniforms.tDiffuse.value=n.texture,this.highPassUniforms.luminosityThreshold.value=this.threshold,this._fsQuad.material=this.materialHighPassFilter,e.setRenderTarget(this.renderTargetBright),e.clear(),this._fsQuad.render(e);let a=this.renderTargetBright;for(let l=0;l<this.nMips;l++)this._fsQuad.material=this.separableBlurMaterials[l],this.separableBlurMaterials[l].uniforms.colorTexture.value=a.texture,this.separableBlurMaterials[l].uniforms.direction.value=i.BlurDirectionX,e.setRenderTarget(this.renderTargetsHorizontal[l]),e.clear(),this._fsQuad.render(e),this.separableBlurMaterials[l].uniforms.colorTexture.value=this.renderTargetsHorizontal[l].texture,this.separableBlurMaterials[l].uniforms.direction.value=i.BlurDirectionY,e.setRenderTarget(this.renderTargetsVertical[l]),e.clear(),this._fsQuad.render(e),a=this.renderTargetsVertical[l];this._fsQuad.material=this.compositeMaterial,this.compositeMaterial.uniforms.bloomStrength.value=this.strength,this.compositeMaterial.uniforms.bloomRadius.value=this.radius,this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,e.setRenderTarget(this.renderTargetsHorizontal[0]),e.clear(),this._fsQuad.render(e),this._fsQuad.material=this.blendMaterial,this.copyUniforms.tDiffuse.value=this.renderTargetsHorizontal[0].texture,r&&e.state.buffers.stencil.setTest(!0),this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(n),this._fsQuad.render(e)),e.setClearColor(this._oldClearColor,this._oldClearAlpha),e.autoClear=o}_getSeparableBlurMaterial(e){let t=[],n=e/3;for(let s=0;s<e;s++)t.push(.39894*Math.exp(-.5*s*s/(n*n))/n);return new ut({defines:{KERNEL_RADIUS:e},uniforms:{colorTexture:{value:null},invSize:{value:new Ae(.5,.5)},direction:{value:new Ae(.5,.5)},gaussianCoefficients:{value:t}},vertexShader:`
|
|
|
|
varying vec2 vUv;
|
|
|
|
void main() {
|
|
|
|
vUv = uv;
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
|
|
}`,fragmentShader:`
|
|
|
|
#include <common>
|
|
|
|
varying vec2 vUv;
|
|
|
|
uniform sampler2D colorTexture;
|
|
uniform vec2 invSize;
|
|
uniform vec2 direction;
|
|
uniform float gaussianCoefficients[KERNEL_RADIUS];
|
|
|
|
void main() {
|
|
|
|
float weightSum = gaussianCoefficients[0];
|
|
vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum;
|
|
|
|
for ( int i = 1; i < KERNEL_RADIUS; i ++ ) {
|
|
|
|
float x = float( i );
|
|
float w = gaussianCoefficients[i];
|
|
vec2 uvOffset = direction * invSize * x;
|
|
vec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb;
|
|
vec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb;
|
|
diffuseSum += ( sample1 + sample2 ) * w;
|
|
|
|
}
|
|
|
|
gl_FragColor = vec4( diffuseSum, 1.0 );
|
|
|
|
}`})}_getCompositeMaterial(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 );
|
|
|
|
}`})}};zs.BlurDirectionX=new Ae(1,0);zs.BlurDirectionY=new Ae(0,1);var $r={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:`
|
|
precision highp float;
|
|
|
|
uniform mat4 modelViewMatrix;
|
|
uniform mat4 projectionMatrix;
|
|
|
|
attribute vec3 position;
|
|
attribute vec2 uv;
|
|
|
|
varying vec2 vUv;
|
|
|
|
void main() {
|
|
|
|
vUv = uv;
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
|
|
}`,fragmentShader:`
|
|
|
|
precision highp float;
|
|
|
|
uniform sampler2D tDiffuse;
|
|
|
|
#include <tonemapping_pars_fragment>
|
|
#include <colorspace_pars_fragment>
|
|
|
|
varying vec2 vUv;
|
|
|
|
void main() {
|
|
|
|
gl_FragColor = texture2D( tDiffuse, vUv );
|
|
|
|
// tone mapping
|
|
|
|
#ifdef LINEAR_TONE_MAPPING
|
|
|
|
gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
|
|
|
|
#elif defined( REINHARD_TONE_MAPPING )
|
|
|
|
gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
|
|
|
|
#elif defined( CINEON_TONE_MAPPING )
|
|
|
|
gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
|
|
|
|
#elif defined( ACES_FILMIC_TONE_MAPPING )
|
|
|
|
gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
|
|
|
|
#elif defined( AGX_TONE_MAPPING )
|
|
|
|
gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
|
|
|
|
#elif defined( NEUTRAL_TONE_MAPPING )
|
|
|
|
gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
|
|
|
|
#elif defined( CUSTOM_TONE_MAPPING )
|
|
|
|
gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
|
|
|
|
#endif
|
|
|
|
// color space
|
|
|
|
#ifdef SRGB_TRANSFER
|
|
|
|
gl_FragColor = sRGBTransferOETF( gl_FragColor );
|
|
|
|
#endif
|
|
|
|
}`};var Al=class extends dn{constructor(){super(),this.isOutputPass=!0,this.uniforms=ci.clone($r.uniforms),this.material=new Rs({name:$r.name,uniforms:this.uniforms,vertexShader:$r.vertexShader,fragmentShader:$r.fragmentShader}),this._fsQuad=new Oi(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===Sr?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===wr?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===Er?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===Ii?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===Ar?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===Cr?this.material.defines.NEUTRAL_TONE_MAPPING="":this._toneMapping===Tr&&(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 Cl=`
|
|
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;
|
|
}
|
|
`,Rl=`
|
|
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 Kr(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 Pl=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[Vh(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 iu(i){for(let e of i.children){let t=e;t.geometry.dispose(),t.material.dispose()}}var Il=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 su(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<o.count;u++){let f=2*Math.PI*n(),m=Math.acos(2*n()-1),x=i*(.95+.1*n());a[u*3]=x*Math.sin(m)*Math.cos(f),a[u*3+1]=x*Math.sin(m)*Math.sin(f),a[u*3+2]=x*Math.cos(m);let g=n(),p=g<.85?rb.clone().lerp(ob,n()):g<.95?ab.clone():lb.clone();o.size>=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 Ai({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 Il(c,o.count))}return{group:t,twinkler:s??new Il(new ht().setAttribute("color",new Ye(new Float32Array(3),3)),1)}}var Ll={id:"deep-space",background:3,starfield:!0,motes:!1,bloomEnabled:!0,lightMode:!1,nodeLightness:null,linkInk:null,linkOpacityScale:1,panelClass:"gx-theme-space"},ru={id:"daylight",background:16184559,starfield:!1,motes:!0,bloomEnabled:!1,lightMode:!0,nodeLightness:.44,linkInk:"#2e2a24",linkOpacityScale:.65,panelClass:"gx-theme-light"},ou={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,Nl=class{constructor(e,t){this.scene=new ji;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=Pl;this.tokens=Ll;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 ks({antialias:!1,alpha:!1}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.renderer.toneMapping=Ii,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=su(t*6.5);this.starfield=n.group,this.twinkler=n.twinkler,this.scene.add(this.starfield),this.composer=new El(this.renderer),this.renderPass=new Tl(this.scene,this.camera),this.bloomPass=new zs(new Ae(2,2),io.strength,io.radius,io.threshold),this.outputPass=new Al,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;a<n;a++){let l=e.nodes[a];l&&(o[a]=l.unresolved?1:0,this.sizes[a]=this.computeSize(l))}this.nodeGeometry=new ht,this.nodeGeometry.setAttribute("position",new Ye(r,3)),this.nodeGeometry.setAttribute("color",new Ye(new Float32Array(n*3),3)),this.nodeGeometry.setAttribute("aSize",new Ye(this.sizes,1)),this.nodeGeometry.setAttribute("aGhost",new Ye(o,1)),this.nodeGeometry.setAttribute("aDim",new Ye(this.dimCurrent,1)),this.nodeMaterial=new ut({vertexShader:Cl,fragmentShader:Rl,vertexColors:!0,transparent:!0,depthWrite:!0,uniforms:{uPixelScale:{value:this.pixelScale},uSizeMul:{value:this.nodeScale},uSizeContrast:{value:1},uBasePoint:{value:0},uMinPoint:{value:0},uLightMode:{value:this.tokens.lightMode?1:0},uMaxPoint:{value:110*this.renderer.getPixelRatio()}}}),this.nodePoints=new Vn(this.nodeGeometry,this.nodeMaterial),this.nodePoints.renderOrder=1,this.nodePoints.frustumCulled=!1,this.scene.add(this.nodePoints),this.linkGeometry=new ht,this.linkGeometry.setAttribute("position",new Ye(new Float32Array(s*2*3),3)),this.linkGeometry.setAttribute("color",new Ye(new Float32Array(s*2*3),3)),this.linkMaterial=new zn({vertexColors:!0,transparent:!0,opacity:this.effectiveLinkOpacity(),depthWrite:!1}),this.linkSegments=new ri(this.linkGeometry,this.linkMaterial),this.linkSegments.renderOrder=0,this.linkSegments.frustumCulled=!1,this.scene.add(this.linkSegments),this.recolor(),this.updatePositions(),this.setSelectedLinks(this.selLinkIdx)}computeSize(e){switch(this.sizeMode){case"fileSize":return Math.min(Math.max(Wi*(.7+1.1*Math.cbrt(e.fileSize/4096)),1.6),vc);case"uniform":return Wi*1.3;default:return Math.min(Wi*(1+.5*Math.sqrt(e.degree)),vc)}}setSizeMode(e){if(this.sizeMode=e,!!this.nodeGeometry){for(let t=0;t<this.data.nodes.length;t++){let n=this.data.nodes[t];n&&(this.sizes[t]=this.computeSize(n))}this.nodeGeometry.getAttribute("aSize").needsUpdate=!0}}playReveal(e=2600){let t=this.data.nodes.length;if(t===0)return;let n=1;for(let s=0;s<t;s++){let r=Math.hypot(this.positions[s*3]??0,this.positions[s*3+1]??0,this.positions[s*3+2]??0);r>n&&(n=r)}this.revealBuf.length<t*3&&(this.revealBuf=new Float32Array(t*3)),this.reveal={t0:performance.now(),durMs:e,maxR:n}}stepReveal(e){if(!this.reveal||!this.nodeGeometry||!this.linkGeometry)return;let{t0:t,durMs:n,maxR:s}=this.reveal,r=(e-t)/n;if(r>=1){this.reveal=null,this.updatePositions(),this.linkMaterial&&(this.linkMaterial.opacity=this.effectiveLinkOpacity());return}let o=this.data.nodes.length,a=this.revealBuf,l=this.positions;for(let f=0;f<o;f++){let m=l[f*3]??0,x=l[f*3+1]??0,g=l[f*3+2]??0,p=Math.hypot(m,x,g)/s*.55,v=Math.min(Math.max((r-p)/.45,0),1),b=1-Math.pow(1-v,3);a[f*3]=m*b,a[f*3+1]=x*b,a[f*3+2]=g*b}let c=this.nodeGeometry.getAttribute("position");c.array.set(a.subarray(0,o*3)),c.needsUpdate=!0;let h=this.linkGeometry.getAttribute("position"),d=h.array,u=this.data.links;for(let f=0;f<u.length;f++){let m=u[f];if(!m)continue;let x=m.source*3,g=m.target*3,p=f*6;d[p]=a[x]??0,d[p+1]=a[x+1]??0,d[p+2]=a[x+2]??0,d[p+3]=a[g]??0,d[p+4]=a[g+1]??0,d[p+5]=a[g+2]??0}h.needsUpdate=!0,this.linkMaterial&&(this.linkMaterial.opacity=this.effectiveLinkOpacity()*Math.min(r*1.6,1))}get revealing(){return this.reveal!==null}recolor(){if(!this.nodeGeometry||!this.linkGeometry)return;let e=this.data.nodes.length,t=this.nodeGeometry.getAttribute("color"),n=t.array,s=new Array(e),r={h:0,s:0,l:0};for(let h=0;h<e;h++){let d=this.data.nodes[h];if(!d)continue;let u=this.colorFn(d).clone();this.tokens.nodeLightness!==null&&(u.getHSL(r),u=u.setHSL(r.h,r.s*.95,this.tokens.nodeLightness)),s[h]=u,n[h*3]=u.r,n[h*3+1]=u.g,n[h*3+2]=u.b}t.needsUpdate=!0;let o=this.linkGeometry.getAttribute("color"),a=o.array,l=this.tokens.linkInk?new ge(this.tokens.linkInk):null,c=new ge("#7a87a8");for(let h=0;h<this.data.links.length;h++){let d=this.data.links[h];if(!d)continue;let u=l??tm(s[d.source]??c,s[d.target]??c);for(let f of[0,1])a[(h*2+f)*3]=u.r,a[(h*2+f)*3+1]=u.g,a[(h*2+f)*3+2]=u.b}o.needsUpdate=!0}updatePositions(){if(!this.nodeGeometry||!this.linkGeometry)return;let e=this.data.nodes.length,t=this.nodeGeometry.getAttribute("position");t.array.set(this.positions.subarray(0,e*3)),t.needsUpdate=!0;let n=this.linkGeometry.getAttribute("position"),s=n.array,r=this.positions,o=this.data.links;for(let a=0;a<o.length;a++){let l=o[a];if(!l)continue;let c=l.source*3,h=l.target*3,d=a*6;s[d]=r[c]??0,s[d+1]=r[c+1]??0,s[d+2]=r[c+2]??0,s[d+3]=r[h]??0,s[d+4]=r[h+1]??0,s[d+5]=r[h+2]??0}n.needsUpdate=!0,this.updateSelPositions()}setFocus(e,t){let n=this.data.nodes.length;this.focusActive=t!==null;for(let s=0;s<n;s++)this.dimTarget[s]=!t||t.has(s)||s===e?1:hb;this.dimAnimating=!0,this.linkMaterial&&(this.linkMaterial.opacity=this.effectiveLinkOpacity())}setSelectedLinks(e){if(this.selLinkIdx=e,this.selSegments&&(this.scene.remove(this.selSegments),this.selGeometry?.dispose(),this.selMaterial?.dispose(),this.selSegments=null,this.selGeometry=null,this.selMaterial=null),e.length===0)return;let t=e.length,n=new Float32Array(t*6),s=new Float32Array(t*6),r={h:0,s:0,l:0};for(let o=0;o<t;o++){let a=this.data.links[e[o]??-1];if(!a)continue;let l=this.data.nodes[a.source],c=l?this.colorFn(l).clone():new ge("#9aa4b2");c.getHSL(r),c.setHSL(r.h,Math.min(r.s*1.2,1),this.tokens.id==="daylight"?.42:.62);for(let h of[0,1])s[o*6+h*3]=c.r,s[o*6+h*3+1]=c.g,s[o*6+h*3+2]=c.b}this.selGeometry=new ht,this.selGeometry.setAttribute("position",new Ye(n,3)),this.selGeometry.setAttribute("color",new Ye(s,3)),this.selMaterial=new zn({vertexColors:!0,transparent:!0,opacity:.85,depthWrite:!1}),this.selSegments=new ri(this.selGeometry,this.selMaterial),this.selSegments.renderOrder=2,this.selSegments.frustumCulled=!1,this.scene.add(this.selSegments),this.updateSelPositions()}updateSelPositions(){if(!this.selGeometry||this.selLinkIdx.length===0)return;let e=this.selGeometry.getAttribute("position"),t=e.array,n=this.positions;for(let s=0;s<this.selLinkIdx.length;s++){let r=this.data.links[this.selLinkIdx[s]??-1];if(!r)continue;let o=r.source*3,a=r.target*3;t[s*6]=n[o]??0,t[s*6+1]=n[o+1]??0,t[s*6+2]=n[o+2]??0,t[s*6+3]=n[a]??0,t[s*6+4]=n[a+1]??0,t[s*6+5]=n[a+2]??0}e.needsUpdate=!0}effectiveLinkOpacity(){let e=this.baseLinkOpacity*this.tokens.linkOpacityScale;return this.focusActive?e*.25:e}applyTokens(e,t){this.tokens=e,this.scene.background=new ge(e.background),this.starfield.visible=e.starfield,this.renderer.toneMapping=e.lightMode?hn:Ii,this.nodeMaterial&&(this.nodeMaterial.uniforms.uLightMode.value=e.lightMode?1:0),this.bloomPass.enabled=e.bloomEnabled&&this.tierBloomAllowed&&t>.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 Ai({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+=_c*e,this.starfield.visible&&this.twinkler.update(e,this.twinkleFreq),this.motes?.visible&&(this.motes.rotation.y-=_c*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<this.dimCurrent.length;s++){let r=this.dimCurrent[s]??1,o=this.dimTarget[s]??1,a=r+(o-r)*t;this.dimCurrent[s]=Math.abs(a-o)<.005?o:a,this.dimCurrent[s]!==o&&(n=!0)}this.dimAnimating=n,this.nodeGeometry&&(this.nodeGeometry.getAttribute("aDim").needsUpdate=!0)}get drawCalls(){return this.renderer.info.render.calls}setBloomParams(e){this.bloomPass.strength=e.strength,this.bloomPass.radius=e.radius,this.bloomPass.threshold=e.threshold,this.bloomPass.enabled=this.tokens.bloomEnabled&&this.tierBloomAllowed&&e.strength>.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;iu(this.starfield),this.scene.remove(this.starfield);let r=su(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]??Wi)*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<this.data.nodes.length;d++){let u=this.projectedNodeHit(d,n,s);if(!u.visible)continue;let f=Math.hypot(u.x-e,u.y-t),m=this.nodeScreenRadius(d,u.depth);f<=m?(u.depth<a||u.depth===a&&f<l)&&(a=u.depth,l=f,o=d):f<h&&(h=f,c=d)}return o>=0?o:c}nodeRadius(e){return this.sizes[e]??Wi}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(),iu(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 Dl(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 au={type:"change"},hu={type:"start"},uu={type:"end"},rm=1e-6,Qe={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4},Fl=new Ae,Ui=new Ae,Mb=new N,kl=new N,lu=new N,Vs=new vn,om=new N,Ol=new N,cu=new N,Ul=new N,Bl=class extends yr{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(au),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(au),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(au),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom}_panCamera(){if(Ui.copy(this._panEnd).sub(this._panStart),Ui.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;Ui.x*=e,Ui.y*=t}Ui.multiplyScalar(this._eye.length()*this.panSpeed),kl.copy(this._eye).cross(this.object.up).setLength(Ui.x),kl.add(Mb.copy(this.object.up).setLength(Ui.y)),this.object.position.add(kl),this.target.add(kl),this.staticMoving?this._panStart.copy(this._panEnd):this._panStart.add(Ui.subVectors(this._panEnd,this._panStart).multiplyScalar(this.dynamicDampingFactor))}}_rotateCamera(){Ul.set(this._moveCurr.x-this._movePrev.x,this._moveCurr.y-this._movePrev.y,0);let e=Ul.length();e?(this._eye.copy(this.object.position).sub(this.target),om.copy(this._eye).normalize(),Ol.copy(this.object.up).normalize(),cu.crossVectors(Ol,om).normalize(),Ol.setLength(this._moveCurr.y-this._movePrev.y),cu.setLength(this._moveCurr.x-this._movePrev.x),Ul.copy(Ol.add(cu)),lu.crossVectors(Ul,this._eye).normalize(),e*=this.rotateSpeed,Vs.setFromAxisAngle(lu,e),this._eye.applyQuaternion(Vs),this.object.up.applyQuaternion(Vs),this._lastAxis.copy(lu),this._lastAngle=e):!this.staticMoving&&this._lastAngle&&(this._lastAngle*=Math.sqrt(1-this.dynamicDampingFactor),this._eye.copy(this.object.position).sub(this.target),Vs.setFromAxisAngle(this._lastAxis,this._lastAngle),this._eye.applyQuaternion(Vs),this.object.up.applyQuaternion(Vs)),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=ol.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=ol.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 Fl.set((e-this.screen.left)/this.screen.width,(t-this.screen.top)/this.screen.height),Fl}_getMouseOnCircle(e,t){return Fl.set((e-this.screen.width*.5-this.screen.left)/(this.screen.width*.5),(this.screen.height+2*(this.screen.top-t))/this.screen.width),Fl}_addPointer(e){this._pointers.push(e)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t].pointerId==e.pointerId){this._pointers.splice(t,1);return}}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new Ae,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0].pointerId?this._pointers[1]:this._pointers[0];return this._pointerPositions[t.pointerId]}_checkDistances(){(!this.noZoom||!this.noPan)&&(this._eye.lengthSq()>this.maxDistance*this.maxDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.maxDistance)),this._zoomStart.copy(this._zoomEnd)),this._eye.lengthSq()<this.minDistance*this.minDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.minDistance)),this._zoomStart.copy(this._zoomEnd)))}};function Sb(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i))}function wb(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function Eb(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchEnd(i):this._onMouseUp(),this._removePointer(i),this._pointers.length===0&&(this.domElement.releasePointerCapture(i.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp)))}function Tb(i){this._removePointer(i)}function Ab(){this.enabled!==!1&&(this.keyState=Qe.NONE,window.addEventListener("keydown",this._onKeyDown))}function Cb(i){this.enabled!==!1&&(window.removeEventListener("keydown",this._onKeyDown),this.keyState===Qe.NONE&&(i.code===this.keys[Qe.ROTATE]&&!this.noRotate?this.keyState=Qe.ROTATE:i.code===this.keys[Qe.ZOOM]&&!this.noZoom?this.keyState=Qe.ZOOM:i.code===this.keys[Qe.PAN]&&!this.noPan&&(this.keyState=Qe.PAN)))}function Rb(i){let e;switch(i.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case Cn.DOLLY:this.state=Qe.ZOOM;break;case Cn.ROTATE:this.state=Qe.ROTATE;break;case Cn.PAN:this.state=Qe.PAN;break;default:this.state=Qe.NONE}let t=this.keyState!==Qe.NONE?this.keyState:this.state;t===Qe.ROTATE&&!this.noRotate?(this._moveCurr.copy(this._getMouseOnCircle(i.pageX,i.pageY)),this._movePrev.copy(this._moveCurr)):t===Qe.ZOOM&&!this.noZoom?(this._zoomStart.copy(this._getMouseOnScreen(i.pageX,i.pageY)),this._zoomEnd.copy(this._zoomStart)):t===Qe.PAN&&!this.noPan&&(this._panStart.copy(this._getMouseOnScreen(i.pageX,i.pageY)),this._panEnd.copy(this._panStart)),this.dispatchEvent(hu)}function Pb(i){let e=this.keyState!==Qe.NONE?this.keyState:this.state;e===Qe.ROTATE&&!this.noRotate?(this._movePrev.copy(this._moveCurr),this._moveCurr.copy(this._getMouseOnCircle(i.pageX,i.pageY))):e===Qe.ZOOM&&!this.noZoom?this._zoomEnd.copy(this._getMouseOnScreen(i.pageX,i.pageY)):e===Qe.PAN&&!this.noPan&&this._panEnd.copy(this._getMouseOnScreen(i.pageX,i.pageY))}function Ib(){this.state=Qe.NONE,this.dispatchEvent(uu)}function Lb(i){if(this.enabled!==!1&&this.noZoom!==!0){switch(i.preventDefault(),i.deltaMode){case 2:this._zoomStart.y-=i.deltaY*.025;break;case 1:this._zoomStart.y-=i.deltaY*.01;break;default:this._zoomStart.y-=i.deltaY*25e-5;break}this.dispatchEvent(hu),this.dispatchEvent(uu)}}function Nb(i){this.enabled!==!1&&i.preventDefault()}function Db(i){switch(this._trackPointer(i),this._pointers.length){case 1:this.state=Qe.TOUCH_ROTATE,this._moveCurr.copy(this._getMouseOnCircle(this._pointers[0].pageX,this._pointers[0].pageY)),this._movePrev.copy(this._moveCurr);break;default:this.state=Qe.TOUCH_ZOOM_PAN;let e=this._pointers[0].pageX-this._pointers[1].pageX,t=this._pointers[0].pageY-this._pointers[1].pageY;this._touchZoomDistanceEnd=this._touchZoomDistanceStart=Math.sqrt(e*e+t*t);let n=(this._pointers[0].pageX+this._pointers[1].pageX)/2,s=(this._pointers[0].pageY+this._pointers[1].pageY)/2;this._panStart.copy(this._getMouseOnScreen(n,s)),this._panEnd.copy(this._panStart);break}this.dispatchEvent(hu)}function Fb(i){switch(this._trackPointer(i),this._pointers.length){case 1:this._movePrev.copy(this._moveCurr),this._moveCurr.copy(this._getMouseOnCircle(i.pageX,i.pageY));break;default:let e=this._getSecondPointerPosition(i),t=i.pageX-e.x,n=i.pageY-e.y;this._touchZoomDistanceEnd=Math.sqrt(t*t+n*n);let s=(i.pageX+e.x)/2,r=(i.pageY+e.y)/2;this._panEnd.copy(this._getMouseOnScreen(s,r));break}}function kb(i){switch(this._pointers.length){case 0:this.state=Qe.NONE;break;case 1:this.state=Qe.TOUCH_ROTATE,this._moveCurr.copy(this._getMouseOnCircle(i.pageX,i.pageY)),this._movePrev.copy(this._moveCurr);break;case 2:this.state=Qe.TOUCH_ZOOM_PAN;for(let e=0;e<this._pointers.length;e++)if(this._pointers[e].pointerId!==i.pointerId){let t=this._pointerPositions[this._pointers[e].pointerId];this._moveCurr.copy(this._getMouseOnCircle(t.x,t.y)),this._movePrev.copy(this._moveCurr);break}break}this.dispatchEvent(uu)}function Ob(i){return i<.5?4*i*i*i:1-Math.pow(-2*i+2,3)/2}var Ub=new Set(["w","a","s","d","q","e"]),zl=class{constructor(e,t,n){this.camera=e;this.dom=t;this.hooks=n;this.cruiseEnabled=!0;this.cruiseSpeed=1;this.tween=null;this.lastInputAt=0;this.cruiseAnchor=null;this.cruiseT=0;this.cruiseDir=1;this.pendingDensityDir=null;this.pressed=new Set;this.shiftHeld=!1;this.tmpOffset=new N;this.tmpSph=new Gn;this.tmpDir=new N;this.tmpRight=new N;this.disposeFns=[];this.controls=new Bl(e,t),this.controls.rotateSpeed=1,this.controls.zoomSpeed=1.2,this.controls.panSpeed=.3,this.controls.staticMoving=!0,this.controls.keys=["","",""],this.lastInputAt=performance.now(),t.tabIndex=0,this.bindPointer(),this.bindKeys()}get target(){return this.controls.target}handleResize(){this.controls.handleResize()}markInput(){this.lastInputAt=performance.now(),this.cruiseAnchor=null,this.tween=null}bindPointer(){let e=n=>{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 Vl=[{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)<this.spec.step/2)}};var Gl=class{constructor(e,t,n,s,r="map3d"){this.settings=t;this.language=n;this.cb=s;this.viewMode=r;this.page="view";this.sliders=[];this.cruiseBtn=null;this.presetSelect=null;this.unresolvedBtn=null;this.orphanBtn=null;this.sizeBySelect=null;this.qualityBtn=null;this.styleChips=[];this.root=e.createDiv({cls:"galaxy-panel gx-theme-space mwm-map-panel"});let o=this.root.createDiv({cls:"galaxy-panel-header"});this.statsEl=o.createDiv({cls:"galaxy-panel-stats",text:"\u2026"});let a=o.createEl("button",{cls:"galaxy-panel-collapse",text:"-"});this.body=this.root.createDiv({cls:"galaxy-panel-body"}),a.addEventListener("click",()=>{let l=this.body.hasClass("is-hidden");this.body.toggleClass("is-hidden",!l),a.setText(l?"-":"+")}),this.render()}render(){this.body.empty(),this.sliders=[],this.styleChips=[],this.cruiseBtn=null,this.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,du("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 Vl)a.createEl("option",{text:this.tt(`color.${u.id}`),value:u.id});a.value=Vl.some(u=>u.id===t.colorTheme)?t.colorTheme:"",a.value||(l.selected=!0),a.addEventListener("change",()=>{let u=Vl.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,du("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,du("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:mi(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 du(i){return e=>i==="x1"?`${e.toFixed(1)}x`:`${e.toFixed(2)}x`}var Wl=require("obsidian");var Hl=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 Wl.TFile?r:null;if(o){let h=this.app.metadataCache.getFileCache(o),d=h?(0,Wl.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 Xl=require("obsidian"),Gs=class extends Xl.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,Xl.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 fu=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),l<i)window.requestAnimationFrame(o);else{n.shift();let c=[...n].sort((u,f)=>u-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 pu(i,e){let t=i.vault.adapter,n=(0,fu.normalizePath)(lm);await t.exists(n)||await t.mkdir(n);let s=(0,fu.normalizePath)(`${lm}/${e.scenario}-${Date.now()}.json`);return await t.write(s,JSON.stringify(e,null,2)),s}function mu(i){return new Promise(e=>window.setTimeout(e,i))}var Hs={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,ql=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 Ml;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=Hs.high;this.watchdogTripped=!1;this.lowFpsChecks=0;this.lastWatchdogAt=0;this.onContextLost=null;this.store=new pl(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=fl(this.store.data.nodes.length)*1.6;let s=new Nl(n,this.graphRadius);this.renderer=s,s.setColorFn(this.settings.colorGroups.length>0?Kr(this.settings.colorGroups):Pl),s.setData(this.store.data,this.store.positions),this.initLayout(t?.06:1),this.director=new zl(s.camera,s.renderer.domElement,{onFlyToSelected:()=>this.flyToSelected(),onResetView:()=>this.recenter()}),this.overlay=new Hl(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=Zs(this.settings.physics);try{this.layout.init(this.store.data,this.store.positions,t,e)}catch{if(this.layout instanceof Yr)throw new Error("layout init failed");this.layout.dispose(),this.layout=new Yr,this.layout.init(this.store.data,this.store.positions,t,e),new yt.Notice(this.tt("3d.workerFallback"))}}pickTier(){if(yt.Platform.isMobile)return Hs.mobile;let e=this.settings.qualityOverride;return e==="high"||e==="low"||e==="mobile"?Hs[e]:this.watchdogTripped?Hs.low:Hs.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(Zs(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(Kr(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(Kr(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 Ll;let t=e==="day"?ru:e==="night"?ou:activeDocument.body.hasClass("theme-dark")?ou:ru,n=t.id==="daylight"?"day":"night";return{...t,background:Dl(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(Kr(t)),this.renderer?.recolor(),this.saveSoon(),e&&new yt.Notice(this.tt("3d.importDone",{count:t.length}))}openSearch(){new Gs(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 Gl(this.contentEl,this.settings,this.language,{onViewMode:e=>this.onViewMode?.(e),onBloom:()=>{this.renderer?.setBloomParams(this.settings.bloom),this.saveSoon()},onPhysics:()=>{this.layout.updateParams(Zs(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(Zs(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 ls(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 mu(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 pu(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 mu(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 pu(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 Yl=class extends ql{};var Yt=require("obsidian");var Ce="",gu="Vault";var mm=1160,gm=620,Gb=2800,xm=144,Hb=72,Wb=360;var Zl=.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(Ce)?Ce: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=Kl(0,-Math.PI/2,0,Ws(o.get(d),a,h.incidentPressureByNode.get(d)??0),!1);Su(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($l),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,_u(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($l),M=i.nodes.filter(U=>U.externalProxy).sort($l),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)=>$l(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=Mu(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 Mu(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)??Kl(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<u.length;R++){let I=u[R],H=u.length===1?A:A*((M[R]??1)/S),W=P,F=P+H,O=W+H/2,U=l.get(I),J=Kl(p,O,e+1,Ws(U,d,c.incidentPressureByNode.get(I)??0),!1);Su(J,W,F),a.set(I,J),bm(I,e+1,W,F,O,r,o,a,l,c,h,d),P=F+_}}function Yb(i,e,t,n,s,r){let o=t.length,a=n.get(i)??{count:1,weight:1,maxDepth:e},l=s.incidentPressureByNode.get(i)??0,c=Math.sqrt(Math.max(1,o)),h=Math.log2(Math.max(1,a.count||a.weight||1)),d=Math.sqrt(Math.max(0,l)),u=.48+e*.068+c*.096+h*.062+d*.052;return i===r&&(u*=.96),o<=4&&(u=Math.min(u,i===r?.78:.92)),o>=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:Mu(t.length)},h=Math.max(...t.map(w=>vu(w,e+1,o,a)),1),d=t.reduce((w,C)=>w+vu(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)&&n<Math.PI*1.98?Math.max(.08,n*.985):Jb(i,e,t,n,s,r,o,a),S=t.length<=4?Math.min(M,.08):Math.min(n,M);return Y(v,S,M)}function Kb(i,e){let t=i.length;if(t<=1)return 0;let n=i.map(l=>e.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:Mu(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 vu(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=vu(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<l*1.18?s:s.map((m,x)=>{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 _u(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<f.length;x++){let g=f[x];if(!g)continue;let p=m+x*d,v=jr(p,g.preferred),b=u<Math.PI*1.35?p+v*.55:p,M=Kl(s,b,a||g.node.depth||1,Ws(n.get(g.node.id),c,h.get(g.node.id)??0),l);M.ringRadius=s,M.ringBandMin=s,M.ringBandMax=s,e.set(g.node.id,M)}return s}function eM(i,e,t,n,s){if(i.length<=1)return 0;let r=i.reduce((a,l)=>{let c=Ws(e.get(l.id),n,s.get(l.id)??0);return a+c*2.6+ec(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=xu(r,a,d?1.1:1);if(h&&(c=_u(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?xu(r,a,.58):xu(r,a,1.08));c=_u(e,t,n,s,f,a.nodeGap,-Math.PI/5,o+(h?2:1),!0,l,a.incidentPressureByNode)}return c}function xu(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=Ws(m,s,t.incidentPressureByNode.get(d)??0),g=x*2+Math.max(18,n*.36),p=x*2.55+(m?ec(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=jl(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=Ql(h,d),m=Jl(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 Jl(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 jl(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 Ql(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=Ws(f,r,t.incidentPressureByNode.get(d)??0),g=x*2.4+ec(f)*1.55+Math.max(18,n*.18),p=f.parentId??e.rootId??Ce,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=jl(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=Ql(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=Jl(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=Jr(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;d<o.length;d++)n.set(o[d].id,d%h)}return n}function aM(i){return i==="folder"?-.34:i==="unresolved"?.5:i==="external"?.62:.14}function lM(i,e,t){return Math.max(i.ringGap*(1+t.outerWeight*.22+t.sparseTail*.52),e*(1.12+t.outerWeight*.1+t.sparseTail*.26))}function cM(i,e,t,n,s,r){let o=Y(i.sectorSpan??Math.PI*2,.024,Math.PI*2),a=Y((Math.PI*.9-o)/(Math.PI*.9),0,1),l=Y(s/2.6,0,1)*.08,c=Y(.38+a*.24+Y(n,0,1)*.12+l+r.sparseTail*.48,.36,1.46);return e.ringGap*c+Math.max(12,t*.04)}function hM(i,e,t,n,s,r,o,a){if(i.length===0)return 0;let l=Math.max(...i.map(f=>f.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 Zl;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(Zl+(um-Zl)*a,Zl,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=Jr(e,`depth-${l}-parent-radius`)*(.2-d*.1),x=Jr(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=Jl(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=Jl(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=jl(s),o=0,a=t.ringGap;for(let l of n){let c=e.get(l)??0,h=Ql(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)<n*.44,g=Math.max(l.depth||0,c.depth||0)>=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 Kl(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 Su(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 Ws(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 $l(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 ec(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||Ce,r=Jr(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=Jr(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,jl(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=Ql(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&&u<Math.PI*2?Math.min(u*.04,.035):0,m=c-u/2+f,x=c+u/2-f,g=Math.max(.001,x-m),p=l.length>1?Math.min(.045,Math.max(.003,g/(l.length*18))):0,v=l.map(S=>({...S,angle:yu(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;S<v.length;S++){let w=v[S];if(!w)continue;let C=v.length-S-1,_=M+p,A=x-C*p,P=Y(w.angle,_,Math.max(_,A));bu(w.point,P),M=P}}}function BM(i,e,t,n,s,r=!1){if(i.length<=1)return!1;let o=Math.max(0,(i[i.length-1]?.angle??t)-(i[0]?.angle??t)),a=Math.max(.001,s-n),l=r?zM(i):0,c=Sm(i.length,a),h=wm(i.length,e.depth,a),d=r?Y(Math.max(VM(i.length,a),l*1.02),Math.min(.08,a),Math.min(c,a)):c,u=r?Math.max(d,Math.min(h,Math.max(d,l*1.32+.05),a*.72)):h,f=Y(r?Math.min(o,Math.max(d,l*1.14+.035)):o,d,u);if(Math.abs(f-o)<.018)return!1;let m=Y(t-f/2,n,Math.max(n,s-f)),x=i.length>1?f/(i.length-1):0;for(let g=0;g<i.length;g++){let p=i[g];if(!p)continue;let v=i.length===1?t:m+x*g;bu(p.point,v)}for(let g=1;g<i.length;g++){let p=i[g-1]?.point,v=i[g]?.point;if(!p||!v)continue;let b=yu(p.angle,t);yu(v.angle,t)<=b&&bu(v,b+.003)}return!0}function zM(i){if(i.length<=1)return 0;let e=Math.max(1,WM(i.map(n=>n.point.radius),i[0]?.point.radius??1));return(i.reduce((n,s)=>{let r=s.node?ec(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 yu(i,e){return e+jr(e,i)}function bu(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);Su(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<t.length;s++)n^=t.charCodeAt(s),n=Math.imul(n,16777619);return(n>>>0)/4294967296*Math.PI*2}function Jr(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-5,Mn=6,tc=4.8,wu={day:{bg:"#f8fafc",ring:"#9aa7b5",tree:"#93a3b8",link:"#a2acba",external:"#7b6fd6",externalLink:"#b8752e",unresolved:"#dc4a4a",focus:"#3f7fe8",folder:"#7f92a8",folderMeta:"#4f8ecb",note:"#a2abb7",root:"#3f7fe8",ringOpacity:.22,treeOpacity:.26,linkOpacity:.1,externalLinkOpacity:.14,highlightOpacity:.92,nodeScale:.32,maxLabels:170},night:{bg:"#1e1e1e",ring:"#777b85",tree:"#8a8f9c",link:"#8b8f99",external:"#a78bfa",externalLink:"#d97706",unresolved:"#fb7185",focus:"#8b7cf6",folder:"#d5d8de",folderMeta:"#c4b5fd",note:"#a8adb7",root:"#a99cff",ringOpacity:.22,treeOpacity:.28,linkOpacity:.12,externalLinkOpacity:.14,highlightOpacity:.98,nodeScale:.32,maxLabels:300}};function Ru(i){return wu[i].bg}var nc=class{constructor(e){this.container=e;this.scene=new ji;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=sc();this.width=1;this.height=1;this.centerX=0;this.centerY=0;this.zoom=1;this.scheme="night";this.background=wu.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 ks({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=Ru(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(Ce):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<o.distance)&&(o={id:l.id,distance:h})}if(o)return{nodeId:o.id,edge:null};if(!n)return{nodeId:null,edge:null};let a=null;for(let l of this.edgeVisuals.values()){if(l.edge.type==="hierarchy"||l.edge.type==="external-hierarchy")continue;let c=jM(r,l.points);c<=Math.max(10,8/this.zoom)&&(!a||c<a.distance)&&(a={edge:l.edge,distance:c})}return{nodeId:null,edge:a?.edge??null}}nodePoint(e){return this.layout?.positions.get(e)??null}dispose(){cancelAnimationFrame(this.revealFrame),this.disposeObjects(),this.renderer.dispose(),this.revealOverlay?.remove(),this.domElement.remove(),this.labelRoot.remove()}palette(){return wu[this.scheme]}ensureRevealOverlay(e){if(!this.revealOverlay){this.revealOverlay=this.container.createDiv({cls:"mwm-radial-loading gx-mask-text",text:e});return}this.revealOverlay.removeClass("is-fading"),this.revealOverlay.setText(e)}clearRevealMask(e){if(this.container.removeClass("is-radial-revealing"),this.container.removeClass("is-radial-depth-revealing"),this.container.removeClass("is-radial-preparing"),!!this.revealOverlay){if(!e){this.revealOverlay.remove(),this.revealOverlay=null;return}this.fadeRevealOverlay()}}fadeRevealOverlay(){if(!this.revealOverlay)return;let e=this.revealOverlay;e.addClass("is-fading"),window.setTimeout(()=>{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(Eu(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;d<c.points.length-1;d++){let u=c.points[d],f=c.points[d+1];!u||!f||(s.push(u.x,u.y,n==="hierarchy"?-1:-2),s.push(f.x,f.y,n==="hierarchy"?-1:-2),Qr(r,h,n==="hierarchy"?.46:l.externalCount?.22:.16),Qr(r,h,n==="hierarchy"?.46:l.externalCount?.22:.16))}}let a=new ri(Eu(s,r),new zn({vertexColors:!0,transparent:!0,opacity:n==="hierarchy"?o.treeOpacity:e.some(l=>l.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]=Pu(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:Cl,fragmentShader:Rl,vertexColors:!0,transparent:!0,depthWrite:!1,uniforms:{uPixelScale:{value:1e3*Math.min(window.devicePixelRatio||1,2)},uSizeMul:{value:ic(this.zoom)},uSizeContrast:{value:Tu(this.zoom)},uBasePoint:{value:tc},uMinPoint:{value:Au(this.zoom)*Math.min(window.devicePixelRatio||1,2)},uLightMode:{value:this.scheme==="day"?1:0},uMaxPoint:{value:Cu(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;n<this.nodeIds.length;n++){let s=this.nodeIds[n]??"",r=s===this.active.activeNodeId||this.active.pinnedNodeIds.has(s)||s===this.graph?.focusId,o=this.active.relatedNodes.has(s);t[n]=this.active.dimOthers&&!r&&!o?.23:r?1.12:o?.95:.82}e.needsUpdate=!0}updateNodeScale(){if(!this.nodeMaterial)return;let e=this.nodeMaterial.uniforms.uSizeMul,t=this.nodeMaterial.uniforms.uSizeContrast,n=this.nodeMaterial.uniforms.uMinPoint,s=this.nodeMaterial.uniforms.uMaxPoint,r=Math.min(window.devicePixelRatio||1,2);e&&(e.value=ic(this.zoom)),t&&(t.value=Tu(this.zoom)),n&&(n.value=Au(this.zoom)*r),s&&(s.value=Cu(this.zoom)*r)}rebuildHighlights(){this.highlightSegments&&(this.scene.remove(this.highlightSegments),this.highlightSegments.geometry.dispose(),Array.isArray(this.highlightSegments.material)?this.highlightSegments.material.forEach(o=>o.dispose()):this.highlightSegments.material.dispose(),this.highlightSegments=null);let 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<a.points.length-1;l++){let c=a.points[l],h=a.points[l+1];!c||!h||YM(e,t,s,c,h,eS(a.edge)/r,2)}}this.highlightSegments=new Wt(XM(e,t),new si({vertexColors:!0,transparent:!0,opacity:n.highlightOpacity,depthWrite:!1,depthTest:!1})),this.scene.add(this.highlightSegments)}edgeVisual(e,t){let n=t.positions.get(e.source),s=t.positions.get(e.target);if(!n||!s)return null;let r=t.routes.get(e.id);return{key:e.id,edge:e,points:JM(n,s,r)}}edgeRevealVisible(e,t){let n=t.positions.get(e.source),s=t.positions.get(e.target);return this.pointRevealVisible(n)&&this.pointRevealVisible(s)}pointRevealVisible(e){return!!(e&&e.depth<=this.revealDepthLimit+.001)}updateLabels(e="auto"){if(!this.graph||!this.layout)return;this.labelRoot.empty();let t=new Set,n=h=>{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(Ce),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<s.length;h++){let d=s[h],{node:u,point:f,screen:m}=d,x=t.has(u.id),g=x?1:e==="auto"?nS(u,f,this.zoom,h,r,this.graph,this.width,this.height):0;if(!x){if(g<=.06||c>=l)continue;c++}let p=u.id===this.graph.rootId||u.id===Ce,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 sc(){return{hasActive:!1,dimOthers:!1,activeNodeId:null,activeLinkId:null,relatedNodes:new Set,highlightedEdges:new Set,labelNodes:new Set,pinnedNodeIds:new Set}}function Eu(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=Eu(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<l;d++){if((d+h)%(c*2)>=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),Qr(e,t,1),Qr(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]),Qr(e,t,1)}function Qr(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<e.length-1;n++){let s=e[n],r=e[n+1];!s||!r||(t=Math.min(t,QM(i,s,r)))}return t}function QM(i,e,t){let n=t.x-e.x,s=t.y-e.y,r=n*n+s*s;if(r<=1e-6)return Math.hypot(i.x-e.x,i.y-e.y);let o=Math.max(0,Math.min(1,((i.x-e.x)*n+(i.y-e.y)*s)/r));return Math.hypot(i.x-(e.x+n*o),i.y-(e.y+s*o))}function eS(i){return i.type==="hierarchy"||i.type==="external-hierarchy"?1.8:i.externalCount?2.05:2.35}function tS(i,e,t){let n=Math.max(0,(i.linkCount||0)+(i.backlinkCount||0)),s=Math.max(0,e.nodeRadius||0)*2.8+Math.log1p(n)*13+Math.sqrt(n)*1.4-Math.min(34,(i.depth||0)*3.2);return i.id===t.rootId&&(s+=1e4),i.id===t.focusId&&(s+=9e3),i.type==="folder"?(s+=32+Math.log1p(i.noteCount||i.descendantCount||0)*8,i.representativeFile&&(s+=8)):i.type==="note"?s+=10:i.type==="external"||i.externalProxy?s-=10:i.type==="unresolved"&&(s-=22),s}function nS(i,e,t,n,s,r,o,a){let l=Ft(t,Ln,Mn);if(i.id===r.rootId)return .68+dt(.04,.2,l)*.32;let h=Math.max(0,(i.linkCount||0)+(i.backlinkCount||0)),d=i.type==="folder",u=i.type==="external"||i.externalProxy,f=i.type==="unresolved",m=Ft((e.nodeRadius-4)/42,0,1),x=Ft(Math.log1p(h)/Math.log1p(80),0,1),g=Ft(1-n/Math.max(1,s),0,1),p=Pu(e.nodeRadius,.24)*ic(l),v=Ft((p-2.5)/13,0,1),b=Ft(Math.sqrt(Math.max(1,o*a))/1200,.55,1.45),M=Math.max(1,r.nodes.length||1),S=n<Math.max(10,Math.min(58,Math.ceil(M*.05))),w=n<Math.max(28,Math.min(170,Math.ceil(M*.18))),C=n<Math.max(80,Math.min(520,Math.ceil(M*.38))),_=1.04-v*.5-m*.34-x*.2-g*.3-(b-.55)*.08;S?_-=.24:w?_-=.17:C&&(_-=.08),d?_-=i.representativeFile?.22:.15:u&&(_-=.06),f&&(_+=.18),_=Ft(_,.08,1.22);let A=dt(_-.18,_+.1,l),P=S?dt(.07,.26,l):w?dt(.14,.44,l)*.92:C?dt(.28,.7,l)*.74:0,R=e.nodeRadius>=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 Pu(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,tc,42)}function Em(i,e,t){let n=Pu(i,e),s=tc+Math.max(0,n-tc)*Tu(t);return Ft(s*ic(t),Au(t),Cu(t))}function ic(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 Tu(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 Au(i){let e=Ft(i,Ln,Mn);return 4.6+dt(.02,.22,e)*.2}function Cu(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 hc=require("obsidian");function Cm(i,e,t,n,s=gu){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:Ce,path:Ce,title:s.trim()||gu,type:"folder",parentId:null,depth:0,noteCount:0,linkCount:0,backlinkCount:0,descendantCount:0});let g=b=>{let M=Bi(b);if(!M)return Ce;let S=Ce;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:rc(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=Bi(b.path);if(!M||m(M))continue;if(b.kind==="folder"){g(M);continue}f++;let S=g(Iu(M));x({id:M,path:M,title:b.basename||rc(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),oc(c,b,C),oc(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??Ce,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 ac(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 Bi(i){return String(i||"").trim().replace(/^\/+|\/+$/g,"")}function Iu(i){let e=Bi(i),t=e.lastIndexOf("/");return t===-1?Ce:e.slice(0,t)}function rc(i){let e=Bi(i),t=e.lastIndexOf("/");return t===-1?e:e.slice(t+1)}function Tm(i){let e=Bi(i);return e?e.split("/").filter(Boolean).length:0}function sS(i,e){let t=Bi(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&&oc(t,n.parentId,n);for(let n of i.values()){if(n.type!=="folder"||n.id===Ce)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}),oc(t,n.parentId,n.id));for(let n of t.values())n.sort((s,r)=>ac(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 oc(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:Ce,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:Ce,s=i.nodes.get(n)?.depth??0,r=e.showCompleteRoot?Math.max(80,i.stats.maxDepth-s):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(Ce);if(!h)continue;let u=Math.max(0,h.depth-s)<=r,f=o.length>0&&lc(h,o);if((u||f)&&(a.add(h.id),f&&Xs(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())lc(c,o)&&(a.add(c.id),Xs(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([Ce]),r=At(e.focusSiblingLimit,10,1e3,t.focusSiblingLimit);if(n){s.add(n),Xs(i,n,s,Ce),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),Xs(i,c.source,s,Ce),Xs(i,c.target,s,Ce)}let o=Nu(e.search);if(o)for(let a of i.nodes.values())lc(a,o)&&(s.add(a.id),Xs(i,a.id,s,Ce));return Um(i,s),Om(i,s,Ce,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(ac);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=Ks(t.hoverHighlightMode)||t.pinNeedsHoverLinks,d=t.showExternalLinks&&s!==Ce&&(c||l);if(!o&&!a&&!h&&!d)return{linkEdges:[],hoverLinkEdges:[],externalNodes:[],externalHierarchyEdges:[]};let u=new Map,f=new Map,m=[],x=t.showCompleteRoot?2e4: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=n.showCompleteRoot?2e4: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<n;){let o=s.shift();!o||t.has(o)||(t.add(o),r++,s.push(...i.childrenByParent.get(o)??[]))}}function Xs(i,e,t,n){let s=i.nodes.get(e);for(;s&&s.parentId!==null&&(t.add(s.id),s.id!==n);)s=i.nodes.get(s.parentId);t.add(n||Ce)}function pS(i,e,t,n,s){let r=[],o=n.get(e);for(;o&&!t.has(o.id);)r.push(o.id),o=o.parentId===null?void 0:n.get(o.parentId);for(let a=r.length-1;a>=0&&t.size<s;a--)t.add(r[a]??Ce)}function Rm(i,e,t,n,s){let r=0;for(let o of i.childrenByParent.get(e)??[]){if(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(Ce)?Ce: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??rc(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(ac)}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"?Iu(i.path):i.path,n=t.split("/").filter(Boolean);if(!e)return n[0]??t;let s=e.split("/").filter(Boolean),r=0;for(;r<s.length&&r<n.length&&s[r]===n[r];)r++;return r<s.length?s.slice(0,r+1).join("/"):n.slice(0,r+1).join("/")}function _S(i){return[...i.nodes.values()].find(e=>e.type==="note")?.id??null}function Nu(i){return i.trim().toLowerCase()}function lc(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&&lc(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 cc=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 hc.TFolder){let r=Bi(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 hc.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===Ce)?e.filter(s=>s.path!==Ce):e}};var yS=.22,uc=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 cc(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 nc(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??Ce)){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","complete"].includes(t),o=this.t("loading.radial");if(r&&(this.renderer?.showLoadingMask(o),await Bm(2),this.disposed||n!==this.rebuildToken))return;let a=this.state.showCompleteRoot?{...s,includeUnresolvedLinks:!0}:s;this.index.rebuild(a),this.state.hoverHighlightMode=s.hoverHighlightMode,this.state.labelVisibility=s.labelVisibility,this.state.showCompleteRoot?this.applyCompleteMapState():(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 l=this.shouldPreserveView(t)?this.renderer?.getView():null,c=l?this.graph?.rootId??this.state.rootPath??Ce:null,h=c!==null?this.layout?.positions.get(c)??this.layout?.positions.get(Ce)??null:null,d=this.index.buildVisibleGraph({...this.state}),u=this.index.buildVisibleGraph(this.legendNeutralLayoutState()),f=new Set(this.state.hiddenLegendItems);this.state.showLinkOverlay||f.add("link");let m=SS(d,f);this.graph=m,this.layout=vm(u,{ringSpacing:mm,nodeSpacing:xm,swirlStrength:s.swirlStrength});let x=this.renderer,g=null;x?.beginRenderBatch();try{if(x?.setTheme(this.resolvedCanvasScheme()),x?.setData(m,this.layout,s.labelVisibility,s.showRingGuides),this.resizeRenderer(!l),l){let p=c!==null?this.layout.positions.get(c)??this.layout.positions.get(Ce)??null:null,v=p&&h?p.x-h.x:0,b=p&&h?p.y-h.y:0;x?.setView(l.centerX+v,l.centerY+b,l.zoom)}this.applyActiveState(),r&&(g=m.rootId)}finally{x?.endRenderBatch()}r&&!this.disposed&&n===this.rebuildToken&&(g!==null?x?.playRevealFromRoot(g,o):x?.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 sc();let t=this.hoverNodeId??this.selectedNodeId,n=this.hoverLink??this.selectedLink,s=sc();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),Ks(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,pi(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=as(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,mi(this.settings.language,"radial2d"),"radial2d"),this.modeButton(s,mi(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,attr:{title: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,attr:{title: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;let d=`${h.title} (${c.weight})`;t.createEl("button",{cls:"mwm-link-row",text:d,attr:{title:d}}).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.state.showCompleteRoot),this.button(s,this.t("view.focus"),()=>this.focusActiveNote(),this.state.mode==="focus"),this.button(s,this.t("view.vaultRoot"),()=>this.resetToRoot()),this.button(s,this.t("view.completeMap"),()=>this.showCompleteMap(),this.state.showCompleteRoot),this.select(t,this.t("view.theme"),this.radial().colorScheme,qu(this.settings.language),r=>{this.radial().colorScheme=oo(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===Ce,searchText:[n.title,n.path,n.id]}});new Gs(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=Ce,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.leaveCompleteMap(),this.state.rootPath=n,await this.queueRebuild("root");return}if(this.graph?.nodesById.has(n)){this.applyActiveState(),this.renderPanel();return}this.leaveCompleteMap(),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:Ce}centerCurrentView(){let t=this.graph?.rootId??Ce;this.renderer?.fitToLayout(t)&&(this.needsFit=!1)}showCompleteMap(){this.state.showCompleteRoot=!0,this.applyCompleteMapState(),this.needsFit=!0,this.rebuild("complete")}applyCompleteMapState(){this.state.mode="atlas",this.state.rootPath=Ce,this.state.focusPath=null,this.state.search="",this.state.atlasDepth=80,this.state.nodeLimit=2e4,this.state.linkLimit=3e4,this.state.externalLinkAnchorLimit=2e4,this.state.showLinkOverlay=!0,this.state.showExternalLinks=!0,this.state.externalDetailMode="exact",this.state.hiddenLegendItems=[]}leaveCompleteMap(){if(!this.state.showCompleteRoot)return;let t=this.radial();this.state.showCompleteRoot=!1,this.state.atlasDepth=t.atlasDepth,this.state.nodeLimit=t.renderNodeLimit,this.state.linkLimit=t.linkLimit,this.state.externalLinkAnchorLimit=t.externalLinkAnchorLimit,this.state.showExternalLinks=t.showExternalLinks,this.state.externalDetailMode=t.externalDetailMode,this.state.hiddenLegendItems=t.hiddenLegendItems.slice(),this.state.showLinkOverlay=t.showLinkOverlay||!this.state.hiddenLegendItems.includes("link")}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.leaveCompleteMap(),this.state.atlasDepth=o,this.rebuild("depth")}),this.numberInput(t,this.t("control.nodes"),this.state.nodeLimit,200,2e4,100,o=>{this.leaveCompleteMap(),this.state.nodeLimit=o,this.rebuild("nodes")}),this.numberInput(t,this.t("control.noteLinks"),this.state.linkLimit,0,3e4,50,o=>{this.leaveCompleteMap(),this.state.linkLimit=o,this.rebuild("links")});let s=new Set(this.state.hiddenLegendItems),r=this.state.showLinkOverlay&&!s.has("link");this.toggle(t,this.t("control.showNoteLinks"),r,o=>{this.leaveCompleteMap(),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,ao(this.settings.language,qs),o=>{let a=pi(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,lo(this.settings.language,Ys),o=>{n.hoverTargetMode=as(o),this.clearDisallowedHoverTargets(),this.saveSoon(),this.applyActiveState(),this.renderPanel()}),this.select(t,this.t("control.labels"),n.labelVisibility,co(this.settings.language,so),o=>{n.labelVisibility=$s(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.leaveCompleteMap(),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.leaveCompleteMap(),this.state.externalDetailMode=Mc(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.leaveCompleteMap(),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.state.hiddenLegendItems);for(let[s,r,o,a]of yc){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",()=>{this.leaveCompleteMap();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 ls(this.settings.language))n.addItem(a=>{a.setTitle(o),r===this.settings.language&&a.setIcon("check"),a.onClick(()=>{let l=os(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,attr:{title: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 mwm-panel-field-stack"});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"&&Ks(t.mode)))}pinKindLabel(t){return t.kind==="link"?this.t("inspect.linkOverlay"):this.t(`hover.${pi(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.leaveCompleteMap(),this.state.mode="atlas",this.state.rootPath=this.state.rootPath||Ce,this.state.focusPath=null,this.needsFit=!0,this.rebuild("atlas")}resetToRoot(){this.leaveCompleteMap(),this.state.mode="atlas",this.state.rootPath=Ce,this.state.focusPath=null,this.needsFit=!0,this.rebuild("root")}currentRootParentId(){let t=this.graph?.rootId??this.state.rootPath;if(t===Ce)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):Ce}useAsRoot(t){this.leaveCompleteMap(),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.leaveCompleteMap(),this.state.mode="focus",this.state.focusPath=t,this.state.rootPath=Ce,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=Dl(t,Ru(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=oo(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 Gi=class extends fc.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 Yl(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 uc(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 fc.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 pc=class extends is.Plugin{constructor(){super(...arguments);this.settings=bc(null)}async onload(){console.info("[Mini World Map] loading");let t=await this.loadData();this.settings=Wu(bc(t),t,this.app.vault.configDir),this.registerView(Yn,n=>new Gi(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 Gi&&"rebuild"in(r.controller??{})&&(r.controller.rebuild?.("manual"),n=!0)}new is.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 is.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=ro(t),this.saveSettings();for(let n of this.app.workspace.getLeavesOfType(Yn)){let s=n.view;s instanceof Gi&&s.switchMode(this.settings.viewMode)}}setLanguage(t){this.settings.language=os(t),this.saveSettings();for(let n of this.app.workspace.getLeavesOfType(Yn)){let s=n.view;s instanceof Gi&&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 Gi?n.view:null}},Du=class extends is.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 ls(n))r.addOption(o,a);r.setValue(this.plugin.settings.language).onChange(async o=>{this.plugin.settings.language=os(o),await this.plugin.saveSettings(),this.update()})})}),this.renderSetting(Le(n,"settings.defaultMode"),Le(n,"settings.defaultModeDesc"),s=>{s.addDropdown(r=>r.addOption("radial2d",mi(n,"radial2d")).addOption("map3d",mi(n,"map3d")).setValue(this.plugin.settings.viewMode).onChange(async o=>{this.plugin.settings.viewMode=ro(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 ao(n,qs))r.addOption(o,a);r.setValue(t.hoverHighlightMode).onChange(async o=>{t.hoverHighlightMode=pi(o),await this.plugin.saveSettings()})})}),this.renderSetting(Le(n,"control.hoverTargets"),Le(n,"settings.hoverTargetsDesc"),s=>{s.addDropdown(r=>{for(let[o,a]of lo(n,Ys))r.addOption(o,a);r.setValue(t.hoverTargetMode).onChange(async o=>{t.hoverTargetMode=as(o),await this.plugin.saveSettings()})})}),this.renderSetting(Le(n,"control.labels"),Le(n,"settings.labelsDesc"),s=>{s.addDropdown(r=>{for(let[o,a]of co(n,so))r.addOption(o,a);r.setValue(t.labelVisibility).onChange(async o=>{t.labelVisibility=$s(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
|
|
*)
|
|
*/
|