miro0o_miniWorldMap/main.js

4372 lines
768 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 ec=Object.defineProperty;var pm=Object.getOwnPropertyDescriptor;var mm=Object.getOwnPropertyNames;var gm=Object.prototype.hasOwnProperty;var xm=(i,e)=>{for(var t in e)ec(i,t,{get:e[t],enumerable:!0})},vm=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of mm(e))!gm.call(i,s)&&s!==t&&ec(i,s,{get:()=>e[s],enumerable:!(n=pm(e,s))||n.enumerable});return i};var _m=i=>vm(ec({},"__esModule",{value:!0}),i);var iM={};xm(iM,{default:()=>Jl});module.exports=_m(iM);var Et=require("obsidian");var Wn="mini-world-map-view";var ss=2.2,tc=ss*6;var Jr={strength:.6,radius:.4,threshold:.18};var Dn={angularSpeed:.022,elevationDeg:8,elevationPeriodS:90,radiusBreath:.04,radiusPeriodS:60,resumeDelayMs:1e4,rampUpMs:2e3},Xn={distancePerRadius:12,minDistance:40,maxDistance:140,azimuthOffsetRad:15*Math.PI/180,minMs:800,maxMs:1800,msPerWorldUnit:.45},nc=8e-4;var Hs=[["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"]],jr=[["auto","Auto"],["hover","Hover only"]],Ws=[["nodes","Nodes"],["links","Links"],["both","Nodes + links"]],ic=[["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"]],Ot={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,hiddenLegendItems:[],ignoreFolders:[".git",".obsidian"]},xn={bloom:{strength:.35,radius:.35,threshold:.22},physics:{repel:200,linkDistance:70,linkStrength:1,centerPull:.04,flatten:.3},look:{nodeSize:1,linkOpacity:.14,twinkle:.5,sizeBy:"degree"},cruise:!0,cruiseSpeed:1,showUnresolved:!1,showOrphans:!0,colorTheme:"imported",qualityOverride:"auto",preset:"adaptive",colorGroups:[],positionCache:{}},uu={language:"en",viewMode:"radial2d",radial:Ot,galaxy3d:xn};function sc(i){let e=Fn(i)?i:{},t=Fn(e.radial),n=t?e.radial:e,s=Fn(e.galaxy3d)?e.galaxy3d:e,r=ym(n);return!t&&e.showLinkOverlay===!1&&(r.showLinkOverlay=Ot.showLinkOverlay),{language:rs(e.language??e.locale??e.lang),viewMode:Qr(e.viewMode),radial:r,galaxy3d:bm(s)}}function ym(i){let e=Fn(i)?i:{},t=Ot,n=new Set(ic.map(([r])=>r)),s=e.hoverHighlightMode??(e.enableLinkHover===!0?"note-links":t.hoverHighlightMode);return{atlasDepth:Ct(e.atlasDepth,1,80,t.atlasDepth),focusSiblingLimit:Ct(e.focusSiblingLimit,10,1e3,t.focusSiblingLimit),linkLimit:Ct(e.linkLimit,0,3e4,t.linkLimit),renderNodeLimit:Ct(e.renderNodeLimit,200,2e4,t.renderNodeLimit),externalLinkAnchorLimit:Ct(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:rc(e.externalDetailMode),colorScheme:eo(e.colorScheme),labelVisibility:qs(e.labelVisibility),hoverHighlightMode:zi(s),hoverTargetMode:os(e.hoverTargetMode),swirlStrength:Ct(e.swirlStrength,0,100,t.swirlStrength),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 bm(i){let e=Fn(i)?i:{},t=xn,n=Fn(e.bloom)?e.bloom:{},s=Fn(e.physics)?e.physics:{},r=Fn(e.look)?e.look:{};return{bloom:{strength:on(n.strength,t.bloom.strength),radius:on(n.radius,t.bloom.radius),threshold:on(n.threshold,t.bloom.threshold)},physics:{repel:on(s.repel,t.physics.repel),linkDistance:on(s.linkDistance,t.physics.linkDistance),linkStrength:on(s.linkStrength,t.physics.linkStrength),centerPull:on(s.centerPull,t.physics.centerPull),flatten:on(s.flatten,t.physics.flatten)},look:{nodeSize:on(r.nodeSize,t.look.nodeSize),linkOpacity:on(r.linkOpacity,t.look.linkOpacity),twinkle:on(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:on(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:e.preset==="deep-space"?"deep-space":"adaptive",colorGroups:Array.isArray(e.colorGroups)?e.colorGroups.filter(o=>Fn(o)&&typeof o.query=="string"&&typeof o.color=="string"):[],positionCache:Fn(e.positionCache)&&!Array.isArray(e.positionCache)?e.positionCache:{}}}function Xs(i){return{charge:-i.repel,linkDistance:i.linkDistance,linkStrength:i.linkStrength,centerPull:i.centerPull,flatten:i.flatten,velocityDecay:.6}}function Qr(i){return i==="map3d"||i==="radial2d"?i:uu.viewMode}function rs(i){return i==="zh"?"zh":uu.language}function eo(i){return i==="auto"||i==="day"||i==="night"?i:Ot.colorScheme}function qs(i){return i==="hover"?"hover":Ot.labelVisibility}function zi(i){return Hs.some(([e])=>e===i)?i:Ot.hoverHighlightMode}function os(i){return Ws.some(([e])=>e===i)?i:Ot.hoverTargetMode}function Ys(i){return zi(i)==="note-links"}function rc(i){return i==="selected"||i==="exact"||i==="grouped"?i:Ot.externalDetailMode}function Ct(i,e,t,n){let s=on(i,n);return Math.min(Math.max(s,e),t)}function on(i,e){return typeof i=="number"&&Number.isFinite(i)?i:Number.parseFloat(String(i))||e}function Fn(i){return typeof i=="object"&&i!==null}var Mm=[["en","English"],["zh","\u4E2D\u6587"]],du={language:{en:"Language",zh:"\u8BED\u8A00"},"language.en":{en:"English",zh:"English"},"language.zh":{en:"Chinese",zh:"\u4E2D\u6587"},"mode.radial2d":{en:"2D radial",zh:"2D \u73AF\u5F62\u56FE"},"mode.map3d":{en:"3D map",zh:"3D \u5730\u56FE"},"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.inspect":{en:"Inspect",zh:"\u68C0\u67E5"},"common.open":{en:"Open",zh:"\u6253\u5F00"},"common.focus":{en:"Focus",zh:"\u805A\u7126"},"common.root":{en:"Root",zh:"\u6839\u8282\u70B9"},"common.source":{en:"Source",zh:"\u6765\u6E90"},"common.target":{en:"Target",zh:"\u76EE\u6807"},"common.none":{en:"None",zh:"\u65E0"},"common.default":{en:"Default",zh:"\u9ED8\u8BA4"},"common.resetDefaults":{en:"Reset defaults",zh:"\u91CD\u7F6E\u9ED8\u8BA4"},"view.atlas":{en:"Atlas",zh:"\u56FE\u8C31"},"view.focus":{en:"Focus",zh:"\u805A\u7126"},"view.vaultRoot":{en:"Vault root",zh:"\u5E93\u6839\u76EE\u5F55"},"view.mode":{en:"Map mode",zh:"\u5730\u56FE\u6A21\u5F0F"},"view.theme":{en:"Theme",zh:"\u4E3B\u9898"},"theme.auto":{en:"System",zh:"\u8DDF\u968F\u7CFB\u7EDF"},"theme.radialAuto":{en:"System",zh:"\u8DDF\u968F\u7CFB\u7EDF"},"theme.day":{en:"Light",zh:"\u6D45\u8272"},"theme.night":{en:"Dark",zh:"\u6DF1\u8272"},"theme.deep":{en:"Deep space",zh:"\u6DF1\u7A7A"},"inspect.type":{en:"Type",zh:"\u7C7B\u578B"},"inspect.depth":{en:"Depth",zh:"\u6DF1\u5EA6"},"inspect.notes":{en:"Notes",zh:"\u7B14\u8BB0"},"inspect.out":{en:"Out",zh:"\u51FA\u94FE"},"inspect.in":{en:"In",zh:"\u5165\u94FE"},"inspect.linkOverlay":{en:"Note link",zh:"\u7B14\u8BB0\u94FE\u63A5"},"inspect.weight":{en:"Weight",zh:"\u6743\u91CD"},"inspect.raw":{en:"Raw",zh:"\u539F\u59CB"},"inspect.unresolved":{en:"Unresolved",zh:"\u672A\u89E3\u6790"},"inspect.external":{en:"Outside",zh:"\u5916\u90E8"},"inspect.outgoing":{en:"Outgoing ({count})",zh:"\u51FA\u94FE\uFF08{count}\uFF09"},"inspect.backlinks":{en:"Backlinks ({count})",zh:"\u53CD\u5411\u94FE\u63A5\uFF08{count}\uFF09"},"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"},"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.outsideLinks":{en:"Outside links",zh:"\u5916\u90E8\u94FE\u63A5"},"control.outsideDetail":{en:"Outside detail",zh:"\u5916\u90E8\u7EC6\u8282"},"control.exactOutsideFiles":{en:"Exact outside notes",zh:"\u7CBE\u786E\u5916\u90E8\u7B14\u8BB0"},"control.legend":{en:"Legend",zh:"\u56FE\u4F8B"},"control.defaultDepth":{en:"Default depth",zh:"\u9ED8\u8BA4\u6DF1\u5EA6"},"control.defaultNodes":{en:"Default nodes",zh:"\u9ED8\u8BA4\u8282\u70B9\u6570"},"control.defaultNoteLinks":{en:"Default note links",zh:"\u9ED8\u8BA4\u7B14\u8BB0\u94FE\u63A5"},"control.unresolvedLinks":{en:"Unresolved links",zh:"\u672A\u89E3\u6790\u94FE\u63A5"},"control.ignoredFolders":{en:"Ignored folders",zh:"\u5FFD\u7565\u6587\u4EF6\u5939"},"hover.none":{en:"None",zh:"\u65E0"},"hover.note-links":{en:"Note links",zh:"\u7B14\u8BB0\u94FE\u63A5"},"hover.hierarchy-parents":{en:"Parents",zh:"\u7236\u7EA7"},"hover.hierarchy-direct-children":{en:"Direct children",zh:"\u76F4\u63A5\u5B50\u7EA7"},"hover.hierarchy-descendants":{en:"All children",zh:"\u5168\u90E8\u5B50\u7EA7"},"hover.hierarchy-parents-direct":{en:"Parents + direct children",zh:"\u7236\u7EA7 + \u76F4\u63A5\u5B50\u7EA7"},"hover.hierarchy-all":{en:"Parents + all children",zh:"\u7236\u7EA7 + \u5168\u90E8\u5B50\u7EA7"},"hoverTarget.nodes":{en:"Nodes only",zh:"\u4EC5\u8282\u70B9"},"hoverTarget.links":{en:"Links only",zh:"\u4EC5\u94FE\u63A5"},"hoverTarget.both":{en:"Nodes + links",zh:"\u8282\u70B9 + \u94FE\u63A5"},"labels.auto":{en:"Auto",zh:"\u81EA\u52A8"},"labels.hover":{en:"Hover only",zh:"\u4EC5\u60AC\u505C"},"outside.grouped":{en:"Groups",zh:"\u5206\u7EC4"},"outside.selected":{en:"Selected",zh:"\u9009\u4E2D"},"outside.exact":{en:"Exact",zh:"\u7CBE\u786E"},"legend.root":{en:"Root",zh:"\u6839\u8282\u70B9"},"legend.root.desc":{en:"Current atlas root",zh:"\u5F53\u524D\u56FE\u8C31\u6839\u8282\u70B9"},"legend.folder":{en:"Folders",zh:"\u6587\u4EF6\u5939"},"legend.folder.desc":{en:"Folders without a same-name child note",zh:"\u6CA1\u6709\u540C\u540D\u5B50\u7B14\u8BB0\u7684\u6587\u4EF6\u5939"},"legend.folderMeta":{en:"Folder notes",zh:"\u6587\u4EF6\u5939\u7B14\u8BB0"},"legend.folderMeta.desc":{en:"Folder merged with its same-name child note",zh:"\u4E0E\u540C\u540D\u5B50\u7B14\u8BB0\u5408\u5E76\u7684\u6587\u4EF6\u5939"},"legend.note":{en:"Notes",zh:"\u7B14\u8BB0"},"legend.note.desc":{en:"Markdown notes",zh:"Markdown \u7B14\u8BB0"},"legend.outsideGroup":{en:"Outside groups",zh:"\u5916\u90E8\u5206\u7EC4"},"legend.outsideGroup.desc":{en:"Grouped branches outside the root",zh:"\u6839\u8282\u70B9\u5916\u7684\u5206\u7EC4\u5206\u652F"},"legend.outsideNote":{en:"Outside notes",zh:"\u5916\u90E8\u7B14\u8BB0"},"legend.outsideNote.desc":{en:"Exact linked notes outside the root",zh:"\u6839\u8282\u70B9\u5916\u7684\u7CBE\u786E\u94FE\u63A5\u7B14\u8BB0"},"legend.unresolvedNote":{en:"Unresolved notes",zh:"\u672A\u89E3\u6790\u7B14\u8BB0"},"legend.unresolvedNote.desc":{en:"Unresolved internal link targets",zh:"\u672A\u89E3\u6790\u7684\u5185\u90E8\u94FE\u63A5\u76EE\u6807"},"legend.hierarchy":{en:"Hierarchy",zh:"\u5C42\u7EA7"},"legend.hierarchy.desc":{en:"Parent-child hierarchy edges",zh:"\u7236\u5B50\u5C42\u7EA7\u8FB9"},"legend.noteLinks":{en:"Note links",zh:"\u7B14\u8BB0\u94FE\u63A5"},"legend.noteLinks.desc":{en:"Internal markdown links",zh:"\u5185\u90E8 Markdown \u94FE\u63A5"},"legend.outsideLinks":{en:"Outside links",zh:"\u5916\u90E8\u94FE\u63A5"},"legend.outsideLinks.desc":{en:"Links crossing the current root",zh:"\u8DE8\u51FA\u5F53\u524D\u6839\u8282\u70B9\u7684\u94FE\u63A5"},"legend.unresolvedLinks":{en:"Unresolved links",zh:"\u672A\u89E3\u6790\u94FE\u63A5"},"legend.unresolvedLinks.desc":{en:"Links involving unresolved targets",zh:"\u5305\u542B\u672A\u89E3\u6790\u76EE\u6807\u7684\u94FE\u63A5"},"loading.radial":{en:"Building map\u2026",zh:"\u6784\u5EFA\u5730\u56FE\u2026"},"loading.3d":{en:"Building map\u2026",zh:"\u6784\u5EFA\u5730\u56FE\u2026"},"context.openNote":{en:"Open note",zh:"\u6253\u5F00\u7B14\u8BB0"},"context.focusNote":{en:"Focus note",zh:"\u805A\u7126\u7B14\u8BB0"},"context.useAsRoot":{en:"Use as atlas root",zh:"\u8BBE\u4E3A\u56FE\u8C31\u6839\u8282\u70B9"},"context.openRepresentative":{en:"Open representative note",zh:"\u6253\u5F00\u4EE3\u8868\u7B14\u8BB0"},"context.pinPath":{en:"Pin highlighted path",zh:"\u56FA\u5B9A\u9AD8\u4EAE\u8DEF\u5F84"},"3d.cruiseOn":{en:"Cruise: on",zh:"\u5DE1\u822A\uFF1A\u5F00"},"3d.cruiseOff":{en:"Cruise: off",zh:"\u5DE1\u822A\uFF1A\u5173"},"3d.reveal":{en:"Reveal",zh:"\u521B\u4E16\u52A8\u753B"},"3d.glow":{en:"Glow",zh:"\u8F89\u5149"},"3d.glowStrength":{en:"Strength",zh:"\u5F3A\u5EA6"},"3d.glowRadius":{en:"Radius",zh:"\u6269\u6563"},"3d.glowThreshold":{en:"Threshold",zh:"\u9608\u503C"},"3d.repel":{en:"Repel",zh:"\u65A5\u529B"},"3d.linkDistance":{en:"Link distance",zh:"\u94FE\u63A5\u8DDD\u79BB"},"3d.linkStrength":{en:"Link strength",zh:"\u94FE\u63A5\u5F3A\u5EA6"},"3d.centerPull":{en:"Center pull",zh:"\u5411\u5FC3\u529B"},"3d.flatten":{en:"Flatten",zh:"\u6241\u5E73\u5EA6"},"3d.nodeSize":{en:"Node size",zh:"\u8282\u70B9\u5927\u5C0F"},"3d.linkOpacity":{en:"Link opacity",zh:"\u94FE\u63A5\u900F\u660E\u5EA6"},"3d.twinkle":{en:"Twinkle",zh:"\u661F\u661F\u7728\u773C"},"3d.twinkleOff":{en:"Off",zh:"\u5173"},"3d.size.degree":{en:"Size: links",zh:"\u5927\u5C0F\uFF1A\u94FE\u63A5\u6570"},"3d.size.fileSize":{en:"Size: file size",zh:"\u5927\u5C0F\uFF1A\u6587\u6863\u91CF"},"3d.size.uniform":{en:"Size: uniform",zh:"\u5927\u5C0F\uFF1A\u4E00\u81F4"},"3d.colorTheme":{en:"Color theme\u2026",zh:"\u914D\u8272\u4E3B\u9898\u2026"},"3d.importColors":{en:"Import 2D colors",zh:"\u5BFC\u5165\u4E8C\u7EF4\u914D\u8272"},"3d.shuffleColors":{en:"Shuffle colors",zh:"\u914D\u8272\u6D17\u724C"},"3d.speed":{en:"Speed",zh:"\u901F\u5EA6"},"3d.unresolvedShow":{en:"Unresolved: show",zh:"\u672A\u89E3\u6790\uFF1A\u663E\u793A"},"3d.unresolvedHide":{en:"Unresolved: hide",zh:"\u672A\u89E3\u6790\uFF1A\u9690\u85CF"},"3d.orphansShow":{en:"Orphans: show",zh:"\u5B64\u513F\uFF1A\u663E\u793A"},"3d.orphansHide":{en:"Orphans: hide",zh:"\u5B64\u513F\uFF1A\u9690\u85CF"},"3d.quality.auto":{en:"Quality: auto",zh:"\u753B\u8D28\uFF1A\u81EA\u52A8"},"3d.quality.high":{en:"Quality: high",zh:"\u753B\u8D28\uFF1A\u9AD8"},"3d.quality.low":{en:"Quality: low",zh:"\u753B\u8D28\uFF1A\u4F4E"},"3d.quality.mobile":{en:"Quality: mobile",zh:"\u753B\u8D28\uFF1A\u79FB\u52A8\u6A21\u62DF"},"3d.help.drag":{en:"Left drag = orbit \xB7 wheel = zoom",zh:"\u5DE6\u952E\u62D6 = \u73AF\u7ED5 \xB7 \u6EDA\u8F6E = \u7F29\u653E"},"3d.help.pan":{en:"Right drag / Cmd or Shift + left drag = pan",zh:"\u53F3\u952E\u62D6 / \u2318\u6216\u21E7+\u5DE6\u952E\u62D6 = \u5E73\u79FB"},"3d.help.mac":{en:"macOS treats Ctrl+click as right-click",zh:"macOS \u7684 Ctrl+\u70B9\u51FB\u4F1A\u88AB\u7CFB\u7EDF\u5F53\u53F3\u952E"},"3d.help.fly":{en:"WASD = fly \xB7 Q/E = rise/fall \xB7 Shift = fast",zh:"WASD = \u5E73\u98DE \xB7 Q/E = \u5347\u964D \xB7 Shift = \u52A0\u901F"},"3d.help.pick":{en:"Click node = select and fly \xB7 ESC = clear",zh:"\u70B9\u51FB\u8282\u70B9 = \u9009\u4E2D\u98DE\u884C \xB7 ESC = \u53D6\u6D88"},"3d.help.keys":{en:"F = fly to selected \xB7 R = overview",zh:"F = \u98DE\u5411\u9009\u4E2D \xB7 R = \u56DE\u603B\u89C8"},"3d.help.slider":{en:"Double-click a slider to reset it",zh:"\u53CC\u51FB\u6ED1\u6746 = \u56DE\u9ED8\u8BA4\u503C"},"3d.revealWait":{en:"The map is still settling. Try reveal after it settles.",zh:"\u661F\u7CFB\u8FD8\u5728\u6210\u5F62\u4E2D\uFF0C\u6C89\u964D\u540E\u518D\u8BD5\u3002"},"3d.workerFallback":{en:"Mini World Map 3D: background layout worker is unavailable; using the main thread.",zh:"Mini World Map 3D\uFF1A\u540E\u53F0\u7EBF\u7A0B\u4E0D\u53EF\u7528\uFF0C\u5DF2\u56DE\u9000\u4E3B\u7EBF\u7A0B\u5E03\u5C40\u3002"},"3d.mobileCap":{en:"Mobile quality: showing the top {cap} linked nodes out of {total}.",zh:"\u79FB\u52A8\u6863\uFF1A\u5DF2\u663E\u793A\u94FE\u63A5\u6700\u591A\u7684\u524D {cap} \u4E2A\u8282\u70B9\uFF08\u5171 {total}\uFF09\u3002"},"3d.performanceMode":{en:"Mini World Map 3D switched to performance mode. Change quality in Advanced.",zh:"Mini World Map 3D\uFF1A\u5DF2\u81EA\u52A8\u5207\u6362\u5230\u6027\u80FD\u6A21\u5F0F\uFF0C\u53EF\u5728\u9AD8\u7EA7\u9875\u6539\u56DE\u3002"},"3d.importMissing":{en:"No 2D graph color groups found in graph.json.",zh:"\u672A\u627E\u5230\u81EA\u5E26\u56FE\u8C31\u7684\u989C\u8272\u5206\u7EC4\uFF08graph.json\uFF09\u3002"},"3d.importDone":{en:"Imported {count} 2D color groups.",zh:"\u5DF2\u5BFC\u5165 {count} \u7EC4 2D \u56FE\u8C31\u914D\u8272\u3002"},"3d.shuffleMissing":{en:"Import 2D colors before shuffling.",zh:"\u5148\u5BFC\u5165\u4E8C\u7EF4\u56FE\u8C31\u914D\u8272\uFF0C\u624D\u80FD\u6D17\u724C\u3002"},"3d.contextLost":{en:"Rendering context lost. Click to rebuild.",zh:"\u6E32\u67D3\u4E0A\u4E0B\u6587\u4E22\u5931\uFF0C\u70B9\u51FB\u91CD\u5EFA\u3002"},"3d.searchPlaceholder":{en:"Search notes, press Enter to fly\u2026",zh:"\u641C\u7D22\u7B14\u8BB0\uFF0C\u56DE\u8F66\u98DE\u8FC7\u53BB\u2026"},"3d.searchUnresolved":{en:"Unresolved",zh:"\u672A\u89E3\u6790"},"3d.searchLinks":{en:"{count} links",zh:"{count} \u94FE\u63A5"},"3d.card.unresolved":{en:"Unresolved link (note does not exist)",zh:"\u672A\u89E3\u6790\u94FE\u63A5\uFF08\u7B14\u8BB0\u5C1A\u4E0D\u5B58\u5728\uFF09"},"3d.card.root":{en:"Vault root",zh:"\u6839\u76EE\u5F55"},"3d.card.stats":{en:"\u21A9 {in} backlinks \xB7 \u2192 {out} outgoing",zh:"\u21A9 {in} \u53CD\u94FE \xB7 \u2192 {out} \u51FA\u94FE"},"3d.card.modified":{en:" \xB7 modified {date}",zh:" \xB7 \u6539\u4E8E {date}"},"3d.card.empty":{en:"(empty note)",zh:"\uFF08\u7A7A\u7B14\u8BB0\uFF09"},"3d.bench.wait":{en:"{scenario}: waiting for layout to settle\u2026",zh:"{scenario}\uFF1A\u7B49\u5F85\u5E03\u5C40\u6C89\u964D\u2026"},"3d.bench.orbit":{en:"{scenario}: 20s orbit FPS run\u2026",zh:"{scenario}\uFF1A20s \u73AF\u7ED5\u6D4B\u5E27\u7387\u2026"},"3d.bench.done":{en:"{scenario} done: avg {fps} fps \xB7 {calls} calls",zh:"{scenario} \u5B8C\u6210\uFF1Aavg {fps} fps \xB7 {calls} calls"},"3d.bench.s2Start":{en:"S2: cold layout started. The interface should remain responsive.",zh:"S2\uFF1A\u51B7\u5E03\u5C40\u5F00\u59CB\uFF08\u9884\u7B97\u5316 tick\uFF0C\u671F\u95F4\u754C\u9762\u5E94\u4FDD\u6301\u53EF\u7528\uFF09\u2026"},"3d.bench.s2Done":{en:"S2 done: settled in {seconds}s / {ticks} ticks, longest block {longest}ms",zh:"S2 \u5B8C\u6210\uFF1A\u6C89\u964D {seconds}s / {ticks} ticks\uFF0C\u6700\u957F\u963B\u585E {longest}ms"},"style.galaxy":{en:"Galaxy",zh:"\u94F6\u6CB3"},"style.nebula":{en:"Nebula",zh:"\u661F\u4E91"},"style.minimal":{en:"Minimal",zh:"\u6781\u7B80"},"style.fireworks":{en:"Fireworks",zh:"\u70DF\u706B"},"color.hubble":{en:"Hubble deep field",zh:"\u54C8\u52C3\u6DF1\u7A7A"},"color.tiktok":{en:"Neon pop",zh:"\u6296\u97F3\u9713\u8679"},"color.sunset":{en:"Sunset film",zh:"\u843D\u65E5\u80F6\u7247"},"color.cyber":{en:"Cyber city",zh:"\u8D5B\u535A\u90FD\u5E02"},"color.matrix":{en:"Matrix",zh:"\u9ED1\u5BA2\u5E1D\u56FD"},"color.aurora":{en:"Aurora",zh:"\u6781\u5149"},"settings.title":{en:"Mini World Map",zh:"Mini World Map"},"settings.defaultMode":{en:"Default render mode",zh:"\u9ED8\u8BA4\u6E32\u67D3\u6A21\u5F0F"},"settings.defaultModeDesc":{en:"2D radial rings is the hierarchy-first map. 3D map uses the Galaxy renderer.",zh:"2D \u73AF\u5F62\u56FE\u4EE5\u5C42\u7EA7\u4E3A\u4E3B\uFF1B3D \u5730\u56FE\u4F7F\u7528 Galaxy \u6E32\u67D3\u5668\u3002"},"settings.languageDesc":{en:"Language used by both 2D and 3D panels.",zh:"2D \u4E0E 3D \u9762\u677F\u5171\u540C\u4F7F\u7528\u7684\u8BED\u8A00\u3002"},"settings.depthDesc":{en:"How many hierarchy levels to render before deeper nodes are summarized by budgets.",zh:"\u6E32\u67D3\u591A\u5C11\u5C42\u7EA7\u540E\u7531\u9884\u7B97\u6C47\u603B\u66F4\u6DF1\u8282\u70B9\u3002"},"settings.nodeLimitDesc":{en:"Maximum visible nodes in the 2D radial map.",zh:"2D \u73AF\u5F62\u56FE\u6700\u591A\u663E\u793A\u7684\u8282\u70B9\u6570\u3002"},"settings.linkLimitDesc":{en:"Maximum aggregated note links to draw in 2D.",zh:"2D \u4E2D\u6700\u591A\u7ED8\u5236\u7684\u805A\u5408\u7B14\u8BB0\u94FE\u63A5\u6570\u3002"},"settings.showLinksDesc":{en:"Keeps note-link roads visible. Hover/link pinning still works when this is off.",zh:"\u4FDD\u6301\u7B14\u8BB0\u94FE\u63A5\u53EF\u89C1\uFF1B\u5173\u95ED\u540E\u60AC\u505C\u4E0E\u94FE\u63A5\u56FA\u5B9A\u4ECD\u53EF\u7528\u3002"},"settings.hoverDesc":{en:"Choose what 2D hover highlights.",zh:"\u9009\u62E9 2D \u60AC\u505C\u9AD8\u4EAE\u7684\u5185\u5BB9\u3002"},"settings.hoverTargetsDesc":{en:"Choose whether nodes, note-link roads, or both react to hover and click.",zh:"\u9009\u62E9\u8282\u70B9\u3001\u7B14\u8BB0\u94FE\u63A5\u9053\u8DEF\u6216\u4E24\u8005\u662F\u5426\u54CD\u5E94\u60AC\u505C\u548C\u70B9\u51FB\u3002"},"settings.labelsDesc":{en:"Auto shows important names by zoom; hover only keeps the map quieter.",zh:"\u81EA\u52A8\u6309\u7F29\u653E\u663E\u793A\u91CD\u8981\u540D\u79F0\uFF1B\u4EC5\u60AC\u505C\u4F1A\u66F4\u5B89\u9759\u3002"},"settings.spinDesc":{en:"Optional radial ring motion in the 2D map.",zh:"2D \u73AF\u5F62\u56FE\u4E2D\u7684\u53EF\u9009\u73AF\u5F62\u8FD0\u52A8\u3002"},"settings.unresolvedDesc":{en:"Represent unresolved internal links as temporary nodes.",zh:"\u5C06\u672A\u89E3\u6790\u5185\u90E8\u94FE\u63A5\u663E\u793A\u4E3A\u4E34\u65F6\u8282\u70B9\u3002"},"settings.ignoredDesc":{en:"One folder path per line.",zh:"\u6BCF\u884C\u4E00\u4E2A\u6587\u4EF6\u5939\u8DEF\u5F84\u3002"},"notice.rebuilt":{en:"Mini World Map rebuilt",zh:"Mini World Map \u5DF2\u91CD\u5EFA"},"notice.openToBuild":{en:"Open Mini World Map to build the index",zh:"\u6253\u5F00 Mini World Map \u540E\u624D\u80FD\u6784\u5EFA\u7D22\u5F15"},"notice.switchTo3d":{en:"Switch to 3D map to use fly-to search.",zh:"\u5207\u6362\u5230 3D \u5730\u56FE\u540E\u53EF\u4F7F\u7528\u98DE\u884C\u641C\u7D22\u3002"}};function Ce(i,e,t={}){return(du[e]?.[i]??du[e]?.en??e).replace(/\{(\w+)\}/g,(s,r)=>String(t[r]??`{${r}}`))}function ui(i,e){return Ce(i,`mode.${e}`)}function fu(i){return[["auto",Ce(i,"theme.radialAuto")],["day",Ce(i,"theme.day")],["night",Ce(i,"theme.night")]]}function as(i){return Mm.map(([e])=>[e,Ce(i,`language.${e}`)])}function to(i,e){return e.map(([t])=>[t,Ce(i,`hover.${t}`)])}function no(i,e){return e.map(([t])=>[t,Ce(i,`hoverTarget.${t}`)])}function io(i,e){return e.map(([t])=>[t,Ce(i,`labels.${t}`)])}function pu(i){return[["grouped",Ce(i,"outside.grouped")],["selected",Ce(i,"outside.selected")],["exact",Ce(i,"outside.exact")]]}var rm=require("obsidian");var _t=require("obsidian");var da="184",Cn={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Ri={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},zu=0,Oc=1,Vu=2;var vr=1,Gu=2,Cs=3,Qn=0,$t=1,zn=2,yn=0,qi=1,_r=2,Uc=3,Bc=4,Hu=5;var _i=100,Wu=101,Xu=102,qu=103,Yu=104,Zu=200,$u=201,Ku=202,Ju=203,Po=204,Io=205,ju=206,Qu=207,ed=208,td=209,nd=210,id=211,sd=212,rd=213,od=214,Lo=0,No=1,Do=2,Yi=3,Fo=4,ko=5,Oo=6,Uo=7,zc=0,ad=1,ld=2,fn=0,yr=1,br=2,Mr=3,Pi=4,Sr=5,wr=6,Er=7;var Vc=300,Ii=301,$i=302,fa=303,pa=304,Tr=306,Bo=1e3,On=1001,zo=1002,Dt=1003,cd=1004;var Ar=1005;var Bt=1006,ma=1007;var Li=1008;var pn=1009,Gc=1010,Hc=1011,Rs=1012,ga=1013,Rn=1014,Pn=1015,qt=1016,xa=1017,va=1018,Ps=1020,Wc=35902,Xc=35899,qc=1021,Yc=1022,bn=1023,Un=1026,Ni=1027,Zc=1028,_a=1029,Di=1030,ya=1031;var ba=1033,Cr=33776,Rr=33777,Pr=33778,Ir=33779,Ma=35840,Sa=35841,wa=35842,Ea=35843,Ta=36196,Aa=37492,Ca=37496,Ra=37488,Pa=37489,Lr=37490,Ia=37491,La=37808,Na=37809,Da=37810,Fa=37811,ka=37812,Oa=37813,Ua=37814,Ba=37815,za=37816,Va=37817,Ga=37818,Ha=37819,Wa=37820,Xa=37821,qa=36492,Ya=36494,Za=36495,$a=36283,Ka=36284,Nr=36285,Ja=36286;var tr=2300,Vo=2301,Ro=2302,Cc=2303,Rc=2400,Pc=2401,Ic=2402;var hd=3200;var $c=0,ud=1,ri="",cn="srgb",nr="srgb-linear",ir="linear",Je="srgb";var Xi=7680;var Lc=519,dd=512,fd=513,pd=514,ja=515,md=516,gd=517,Qa=518,xd=519,Nc=35044;var Kc="300 es",Tn=2e3,sr=2001;function Sm(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function wm(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function rr(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function vd(){let i=rr("canvas");return i.style.display="block",i}var mu={},Ms=null;function Jc(...i){let e="THREE."+i.shift();Ms?Ms("log",e,...i):console.log(e,...i)}function _d(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=_d(i);let e="THREE."+i.shift();if(Ms)Ms("warn",e,...i);else{let t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function Re(...i){i=_d(i);let e="THREE."+i.shift();if(Ms)Ms("error",e,...i);else{let t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function Go(...i){let e=i.join(" ");e in mu||(mu[e]=!0,Te(...i))}function yd(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 bd={[Lo]:No,[Do]:Oo,[Fo]:Uo,[Yi]:ko,[No]:Lo,[Oo]:Do,[Uo]:Fo,[ko]:Yi},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}}},Gt=["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"],gu=1234567,Qs=Math.PI/180,Ss=180/Math.PI;function Is(){let i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Gt[i&255]+Gt[i>>8&255]+Gt[i>>16&255]+Gt[i>>24&255]+"-"+Gt[e&255]+Gt[e>>8&255]+"-"+Gt[e>>16&15|64]+Gt[e>>24&255]+"-"+Gt[t&63|128]+Gt[t>>8&255]+"-"+Gt[t>>16&255]+Gt[t>>24&255]+Gt[n&255]+Gt[n>>8&255]+Gt[n>>16&255]+Gt[n>>24&255]).toLowerCase()}function Ve(i,e,t){return Math.max(e,Math.min(t,i))}function jc(i,e){return(i%e+e)%e}function Em(i,e,t,n,s){return n+(i-e)*(s-n)/(t-e)}function Tm(i,e,t){return i!==e?(t-i)/(e-i):0}function er(i,e,t){return(1-t)*i+t*e}function Am(i,e,t,n){return er(i,e,1-Math.exp(-t*n))}function Cm(i,e=1){return e-Math.abs(jc(i,e*2)-e)}function Rm(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function Pm(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function Im(i,e){return i+Math.floor(Math.random()*(e-i+1))}function Lm(i,e){return i+Math.random()*(e-i)}function Nm(i){return i*(.5-Math.random())}function Dm(i){i!==void 0&&(gu=i);let e=gu+=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 Fm(i){return i*Qs}function km(i){return i*Ss}function Om(i){return(i&i-1)===0&&i!==0}function Um(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Bm(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function zm(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),u=o((e+n)/2),d=r((e-n)/2),h=o((e-n)/2),f=r((n-e)/2),g=o((n-e)/2);switch(s){case"XYX":i.set(a*u,l*d,l*h,a*c);break;case"YZY":i.set(l*h,a*u,l*d,a*c);break;case"ZXZ":i.set(l*d,l*h,a*u,a*c);break;case"XZX":i.set(a*u,l*g,l*f,a*c);break;case"YXY":i.set(l*f,a*u,l*g,a*c);break;case"ZYZ":i.set(l*g,l*f,a*u,a*c);break;default:Te("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function ys(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function Zt(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}var Qc={DEG2RAD:Qs,RAD2DEG:Ss,generateUUID:Is,clamp:Ve,euclideanModulo:jc,mapLinear:Em,inverseLerp:Tm,lerp:er,damp:Am,pingpong:Cm,smoothstep:Rm,smootherstep:Pm,randInt:Im,randFloat:Lm,randFloatSpread:Nm,seededRandom:Dm,degToRad:Fm,radToDeg:km,isPowerOfTwo:Om,ceilPowerOfTwo:Um,floorPowerOfTwo:Bm,setQuaternionFromProperEuler:zm,normalize:Zt,denormalize:ys},sh=class sh{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=Ve(this.x,e.x,t.x),this.y=Ve(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Ve(this.x,e,t),this.y=Ve(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ve(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(Ve(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}};sh.prototype.isVector2=!0;var Ee=sh,hn=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],u=n[s+2],d=n[s+3],h=r[o+0],f=r[o+1],g=r[o+2],x=r[o+3];if(d!==x||l!==h||c!==f||u!==g){let m=l*h+c*f+u*g+d*x;m<0&&(h=-h,f=-f,g=-g,x=-x,m=-m);let p=1-a;if(m<.9995){let v=Math.acos(m),b=Math.sin(v);p=Math.sin(p*v)/b,a=Math.sin(a*v)/b,l=l*p+h*a,c=c*p+f*a,u=u*p+g*a,d=d*p+x*a}else{l=l*p+h*a,c=c*p+f*a,u=u*p+g*a,d=d*p+x*a;let v=1/Math.sqrt(l*l+c*c+u*u+d*d);l*=v,c*=v,u*=v,d*=v}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=d}static multiplyQuaternionsFlat(e,t,n,s,r,o){let a=n[s],l=n[s+1],c=n[s+2],u=n[s+3],d=r[o],h=r[o+1],f=r[o+2],g=r[o+3];return e[t]=a*g+u*d+l*f-c*h,e[t+1]=l*g+u*h+c*d-a*f,e[t+2]=c*g+u*f+a*h-l*d,e[t+3]=u*g-a*d-l*h-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),u=a(s/2),d=a(r/2),h=l(n/2),f=l(s/2),g=l(r/2);switch(o){case"XYZ":this._x=h*u*d+c*f*g,this._y=c*f*d-h*u*g,this._z=c*u*g+h*f*d,this._w=c*u*d-h*f*g;break;case"YXZ":this._x=h*u*d+c*f*g,this._y=c*f*d-h*u*g,this._z=c*u*g-h*f*d,this._w=c*u*d+h*f*g;break;case"ZXY":this._x=h*u*d-c*f*g,this._y=c*f*d+h*u*g,this._z=c*u*g+h*f*d,this._w=c*u*d-h*f*g;break;case"ZYX":this._x=h*u*d-c*f*g,this._y=c*f*d+h*u*g,this._z=c*u*g-h*f*d,this._w=c*u*d+h*f*g;break;case"YZX":this._x=h*u*d+c*f*g,this._y=c*f*d+h*u*g,this._z=c*u*g-h*f*d,this._w=c*u*d-h*f*g;break;case"XZY":this._x=h*u*d-c*f*g,this._y=c*f*d-h*u*g,this._z=c*u*g+h*f*d,this._w=c*u*d+h*f*g;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],u=t[6],d=t[10],h=n+a+d;if(h>0){let f=.5/Math.sqrt(h+1);this._w=.25/f,this._x=(u-l)*f,this._y=(r-c)*f,this._z=(o-s)*f}else if(n>a&&n>d){let f=2*Math.sqrt(1+n-a-d);this._w=(u-l)/f,this._x=.25*f,this._y=(s+o)/f,this._z=(r+c)/f}else if(a>d){let f=2*Math.sqrt(1+a-n-d);this._w=(r-c)/f,this._x=(s+o)/f,this._y=.25*f,this._z=(l+u)/f}else{let f=2*Math.sqrt(1+d-n-a);this._w=(o-s)/f,this._x=(r+c)/f,this._y=(l+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(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(Ve(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,u=t._w;return this._x=n*u+o*a+s*c-r*l,this._y=s*u+o*l+r*a-n*c,this._z=r*u+o*c+n*l-s*a,this._w=o*u-n*a-s*l-r*c,this._onChangeCallback(),this}slerp(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),u=Math.sin(c);l=Math.sin(l*c)/u,t=Math.sin(t*c)/u,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}},rh=class rh{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(xu.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(xu.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),u=2*(a*t-r*s),d=2*(r*n-o*t);return this.x=t+l*c+o*d-a*u,this.y=n+l*u+a*c-r*d,this.z=s+l*d+r*u-o*c,this}project(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=Ve(this.x,e.x,t.x),this.y=Ve(this.y,e.y,t.y),this.z=Ve(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Ve(this.x,e,t),this.y=Ve(this.y,e,t),this.z=Ve(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ve(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 oc.copy(this).projectOnVector(e),this.sub(oc)}reflect(e){return this.sub(oc.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(Ve(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}};rh.prototype.isVector3=!0;var N=rh,oc=new N,xu=new hn,oh=class oh{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 u=this.elements;return u[0]=e,u[1]=s,u[2]=a,u[3]=t,u[4]=r,u[5]=l,u[6]=n,u[7]=o,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(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],u=n[4],d=n[7],h=n[2],f=n[5],g=n[8],x=s[0],m=s[3],p=s[6],v=s[1],b=s[4],M=s[7],E=s[2],w=s[5],C=s[8];return r[0]=o*x+a*v+l*E,r[3]=o*m+a*b+l*w,r[6]=o*p+a*M+l*C,r[1]=c*x+u*v+d*E,r[4]=c*m+u*b+d*w,r[7]=c*p+u*M+d*C,r[2]=h*x+f*v+g*E,r[5]=h*m+f*b+g*w,r[8]=h*p+f*M+g*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],u=e[8];return t*o*u-t*a*c-n*r*u+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],u=e[8],d=u*o-a*c,h=a*l-u*r,f=c*r-o*l,g=t*d+n*h+s*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);let x=1/g;return e[0]=d*x,e[1]=(s*c-u*n)*x,e[2]=(a*n-s*o)*x,e[3]=h*x,e[4]=(u*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(ac.makeScale(e,t)),this}rotate(e){return this.premultiply(ac.makeRotation(-e)),this}translate(e,t){return this.premultiply(ac.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)}};oh.prototype.isMatrix3=!0;var Le=oh,ac=new Le,vu=new Le().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),_u=new Le().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Vm(){let i={enabled:!0,workingColorSpace:nr,spaces:{},convert:function(s,r,o){return this.enabled===!1||r===o||!r||!o||(this.spaces[r].transfer===Je&&(s.r=jn(s.r),s.g=jn(s.g),s.b=jn(s.b)),this.spaces[r].primaries!==this.spaces[o].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===Je&&(s.r=bs(s.r),s.g=bs(s.g),s.b=bs(s.b))),s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===ri?ir: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 Go("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Go("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({[nr]:{primaries:e,whitePoint:n,transfer:ir,toXYZ:vu,fromXYZ:_u,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:cn},outputColorSpaceConfig:{drawingBufferColorSpace:cn}},[cn]:{primaries:e,whitePoint:n,transfer:Je,toXYZ:vu,fromXYZ:_u,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:cn}}}),i}var ze=Vm();function jn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function bs(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var ls,Ho=class{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{ls===void 0&&(ls=rr("canvas")),ls.width=e.width,ls.height=e.height;let s=ls.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=ls}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=rr("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]=jn(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(jn(t[n]/255)*255):t[n]=jn(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}},Gm=0,ws=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Gm++}),this.uuid=Is(),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(lc(s[o].image)):r.push(lc(s[o]))}else r=lc(s);n.url=r}return t||(e.images[this.uuid]=n),n}};function lc(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?Ho.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 Hm=0,cc=new N,jt=class i extends An{constructor(e=i.DEFAULT_IMAGE,t=i.DEFAULT_MAPPING,n=On,s=On,r=Bt,o=Li,a=bn,l=pn,c=i.DEFAULT_ANISOTROPY,u=ri){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Hm++}),this.uuid=Is(),this.name="",this.source=new ws(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 Ee(0,0),this.repeat=new Ee(1,1),this.center=new Ee(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Le,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(cc).x}get height(){return this.source.getSize(cc).y}get depth(){return this.source.getSize(cc).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!==Vc)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Bo:e.x=e.x-Math.floor(e.x);break;case On:e.x=e.x<0?0:1;break;case zo: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 Bo:e.y=e.y-Math.floor(e.y);break;case On:e.y=e.y<0?0:1;break;case zo: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=Vc;jt.DEFAULT_ANISOTROPY=1;var ah=class ah{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],u=l[4],d=l[8],h=l[1],f=l[5],g=l[9],x=l[2],m=l[6],p=l[10];if(Math.abs(u-h)<.01&&Math.abs(d-x)<.01&&Math.abs(g-m)<.01){if(Math.abs(u+h)<.1&&Math.abs(d+x)<.1&&Math.abs(g+m)<.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,E=(p+1)/2,w=(u+h)/4,C=(d+x)/4,_=(g+m)/4;return b>M&&b>E?b<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(b),s=w/n,r=C/n):M>E?M<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(M),n=w/s,r=_/s):E<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(E),n=C/r,s=_/r),this.set(n,s,r,t),this}let v=Math.sqrt((m-g)*(m-g)+(d-x)*(d-x)+(h-u)*(h-u));return Math.abs(v)<.001&&(v=1),this.x=(m-g)/v,this.y=(d-x)/v,this.z=(h-u)/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=Ve(this.x,e.x,t.x),this.y=Ve(this.y,e.y,t.y),this.z=Ve(this.z,e.z,t.z),this.w=Ve(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Ve(this.x,e,t),this.y=Ve(this.y,e,t),this.z=Ve(this.z,e,t),this.w=Ve(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ve(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}};ah.prototype.isVector4=!0;var xt=ah,Wo=class extends An{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Bt,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 xt(0,0,e,t),this.scissorTest=!1,this.viewport=new xt(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:Bt,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 ws(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"})}},Rt=class extends Wo{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},or=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=Dt,this.minFilter=Dt,this.wrapR=On,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}};var Xo=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=Dt,this.minFilter=Dt,this.wrapR=On,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var ua=class ua{constructor(e,t,n,s,r,o,a,l,c,u,d,h,f,g,x,m){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,o,a,l,c,u,d,h,f,g,x,m)}set(e,t,n,s,r,o,a,l,c,u,d,h,f,g,x,m){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]=u,p[10]=d,p[14]=h,p[3]=f,p[7]=g,p[11]=x,p[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new ua().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/cs.setFromMatrixColumn(e,0).length(),r=1/cs.setFromMatrixColumn(e,1).length(),o=1/cs.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),u=Math.cos(r),d=Math.sin(r);if(e.order==="XYZ"){let h=o*u,f=o*d,g=a*u,x=a*d;t[0]=l*u,t[4]=-l*d,t[8]=c,t[1]=f+g*c,t[5]=h-x*c,t[9]=-a*l,t[2]=x-h*c,t[6]=g+f*c,t[10]=o*l}else if(e.order==="YXZ"){let h=l*u,f=l*d,g=c*u,x=c*d;t[0]=h+x*a,t[4]=g*a-f,t[8]=o*c,t[1]=o*d,t[5]=o*u,t[9]=-a,t[2]=f*a-g,t[6]=x+h*a,t[10]=o*l}else if(e.order==="ZXY"){let h=l*u,f=l*d,g=c*u,x=c*d;t[0]=h-x*a,t[4]=-o*d,t[8]=g+f*a,t[1]=f+g*a,t[5]=o*u,t[9]=x-h*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){let h=o*u,f=o*d,g=a*u,x=a*d;t[0]=l*u,t[4]=g*c-f,t[8]=h*c+x,t[1]=l*d,t[5]=x*c+h,t[9]=f*c-g,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){let h=o*l,f=o*c,g=a*l,x=a*c;t[0]=l*u,t[4]=x-h*d,t[8]=g*d+f,t[1]=d,t[5]=o*u,t[9]=-a*u,t[2]=-c*u,t[6]=f*d+g,t[10]=h-x*d}else if(e.order==="XZY"){let h=o*l,f=o*c,g=a*l,x=a*c;t[0]=l*u,t[4]=-d,t[8]=c*u,t[1]=h*d+x,t[5]=o*u,t[9]=f*d-g,t[2]=g*d-f,t[6]=a*u,t[10]=x*d+h}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(Wm,e,Xm)}lookAt(e,t,n){let s=this.elements;return an.subVectors(e,t),an.lengthSq()===0&&(an.z=1),an.normalize(),di.crossVectors(n,an),di.lengthSq()===0&&(Math.abs(n.z)===1?an.x+=1e-4:an.z+=1e-4,an.normalize(),di.crossVectors(n,an)),di.normalize(),so.crossVectors(an,di),s[0]=di.x,s[4]=so.x,s[8]=an.x,s[1]=di.y,s[5]=so.y,s[9]=an.y,s[2]=di.z,s[6]=so.z,s[10]=an.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],u=n[1],d=n[5],h=n[9],f=n[13],g=n[2],x=n[6],m=n[10],p=n[14],v=n[3],b=n[7],M=n[11],E=n[15],w=s[0],C=s[4],_=s[8],T=s[12],P=s[1],R=s[5],I=s[9],H=s[13],W=s[2],k=s[6],z=s[10],V=s[14],K=s[3],Q=s[7],ae=s[11],_e=s[15];return r[0]=o*w+a*P+l*W+c*K,r[4]=o*C+a*R+l*k+c*Q,r[8]=o*_+a*I+l*z+c*ae,r[12]=o*T+a*H+l*V+c*_e,r[1]=u*w+d*P+h*W+f*K,r[5]=u*C+d*R+h*k+f*Q,r[9]=u*_+d*I+h*z+f*ae,r[13]=u*T+d*H+h*V+f*_e,r[2]=g*w+x*P+m*W+p*K,r[6]=g*C+x*R+m*k+p*Q,r[10]=g*_+x*I+m*z+p*ae,r[14]=g*T+x*H+m*V+p*_e,r[3]=v*w+b*P+M*W+E*K,r[7]=v*C+b*R+M*k+E*Q,r[11]=v*_+b*I+M*z+E*ae,r[15]=v*T+b*H+M*V+E*_e,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],u=e[2],d=e[6],h=e[10],f=e[14],g=e[3],x=e[7],m=e[11],p=e[15],v=l*f-c*h,b=a*f-c*d,M=a*h-l*d,E=o*f-c*u,w=o*h-l*u,C=o*d-a*u;return t*(x*v-m*b+p*M)-n*(g*v-m*E+p*w)+s*(g*b-x*E+p*C)-r*(g*M-x*w+m*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],u=e[8],d=e[9],h=e[10],f=e[11],g=e[12],x=e[13],m=e[14],p=e[15],v=t*a-n*o,b=t*l-s*o,M=t*c-r*o,E=n*l-s*a,w=n*c-r*a,C=s*c-r*l,_=u*x-d*g,T=u*m-h*g,P=u*p-f*g,R=d*m-h*x,I=d*p-f*x,H=h*p-f*m,W=v*H-b*I+M*R+E*P-w*T+C*_;if(W===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let k=1/W;return e[0]=(a*H-l*I+c*R)*k,e[1]=(s*I-n*H-r*R)*k,e[2]=(x*C-m*w+p*E)*k,e[3]=(h*w-d*C-f*E)*k,e[4]=(l*P-o*H-c*T)*k,e[5]=(t*H-s*P+r*T)*k,e[6]=(m*M-g*C-p*b)*k,e[7]=(u*C-h*M+f*b)*k,e[8]=(o*I-a*P+c*_)*k,e[9]=(n*P-t*I-r*_)*k,e[10]=(g*w-x*M+p*v)*k,e[11]=(d*M-u*w-f*v)*k,e[12]=(a*T-o*R-l*_)*k,e[13]=(t*R-n*T+s*_)*k,e[14]=(x*b-g*E-m*v)*k,e[15]=(u*E-d*b+h*v)*k,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,u=r*a;return this.set(c*o+n,c*a-s*l,c*l+s*a,0,c*a+s*l,u*a+n,u*l-s*o,0,c*l-s*a,u*l+s*o,r*l*l+n,0,0,0,0,1),this}makeScale(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,u=o+o,d=a+a,h=r*c,f=r*u,g=r*d,x=o*u,m=o*d,p=a*d,v=l*c,b=l*u,M=l*d,E=n.x,w=n.y,C=n.z;return s[0]=(1-(x+p))*E,s[1]=(f+M)*E,s[2]=(g-b)*E,s[3]=0,s[4]=(f-M)*w,s[5]=(1-(h+p))*w,s[6]=(m+v)*w,s[7]=0,s[8]=(g+b)*C,s[9]=(m-v)*C,s[10]=(1-(h+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=cs.set(s[0],s[1],s[2]).length(),a=cs.set(s[4],s[5],s[6]).length(),l=cs.set(s[8],s[9],s[10]).length();r<0&&(o=-o),Sn.copy(this);let c=1/o,u=1/a,d=1/l;return Sn.elements[0]*=c,Sn.elements[1]*=c,Sn.elements[2]*=c,Sn.elements[4]*=u,Sn.elements[5]*=u,Sn.elements[6]*=u,Sn.elements[8]*=d,Sn.elements[9]*=d,Sn.elements[10]*=d,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,u=2*r/(t-e),d=2*r/(n-s),h=(t+e)/(t-e),f=(n+s)/(n-s),g,x;if(l)g=r/(o-r),x=o*r/(o-r);else if(a===Tn)g=-(o+r)/(o-r),x=-2*o*r/(o-r);else if(a===sr)g=-o/(o-r),x=-o*r/(o-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=u,c[4]=0,c[8]=h,c[12]=0,c[1]=0,c[5]=d,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=g,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,u=2/(t-e),d=2/(n-s),h=-(t+e)/(t-e),f=-(n+s)/(n-s),g,x;if(l)g=1/(o-r),x=o/(o-r);else if(a===Tn)g=-2/(o-r),x=-(o+r)/(o-r);else if(a===sr)g=-1/(o-r),x=-r/(o-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=u,c[4]=0,c[8]=0,c[12]=h,c[1]=0,c[5]=d,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=g,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}};ua.prototype.isMatrix4=!0;var gt=ua,cs=new N,Sn=new gt,Wm=new N(0,0,0),Xm=new N(1,1,1),di=new N,so=new N,an=new N,yu=new gt,bu=new hn,yi=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],u=s[9],d=s[2],h=s[6],f=s[10];switch(t){case"XYZ":this._y=Math.asin(Ve(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,f),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(h,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Ve(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-d,r),this._z=0);break;case"ZXY":this._x=Math.asin(Ve(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-d,f),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-Ve(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(h,f),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(Ve(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-d,r)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-Ve(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(h,c),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-u,f),this._y=0);break;default:Te("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return yu.makeRotationFromQuaternion(e),this.setFromRotationMatrix(yu,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return bu.setFromEuler(this),this.setFromQuaternion(bu,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}};yi.DEFAULT_ORDER="XYZ";var ar=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}},qm=0,Mu=new N,hs=new hn,qn=new gt,ro=new N,Zs=new N,Ym=new N,Zm=new hn,Su=new N(1,0,0),wu=new N(0,1,0),Eu=new N(0,0,1),Tu={type:"added"},$m={type:"removed"},us={type:"childadded",child:null},hc={type:"childremoved",child:null},Qt=class i extends An{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:qm++}),this.uuid=Is(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=i.DEFAULT_UP.clone();let e=new N,t=new yi,n=new hn,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 gt},normalMatrix:{value:new Le}}),this.matrix=new gt,this.matrixWorld=new gt,this.matrixAutoUpdate=i.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=i.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new ar,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 hs.setFromAxisAngle(e,t),this.quaternion.multiply(hs),this}rotateOnWorldAxis(e,t){return hs.setFromAxisAngle(e,t),this.quaternion.premultiply(hs),this}rotateX(e){return this.rotateOnAxis(Su,e)}rotateY(e){return this.rotateOnAxis(wu,e)}rotateZ(e){return this.rotateOnAxis(Eu,e)}translateOnAxis(e,t){return Mu.copy(e).applyQuaternion(this.quaternion),this.position.add(Mu.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Su,e)}translateY(e){return this.translateOnAxis(wu,e)}translateZ(e){return this.translateOnAxis(Eu,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(qn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?ro.copy(e):ro.set(e,t,n);let s=this.parent;this.updateWorldMatrix(!0,!1),Zs.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?qn.lookAt(Zs,ro,this.up):qn.lookAt(ro,Zs,this.up),this.quaternion.setFromRotationMatrix(qn),s&&(qn.extractRotation(s.matrixWorld),hs.setFromRotationMatrix(qn),this.quaternion.premultiply(hs.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Re("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(Tu),us.child=e,this.dispatchEvent(us),us.child=null):Re("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($m),hc.child=e,this.dispatchEvent(hc),hc.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),qn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),qn.multiply(e.parent.matrixWorld)),e.applyMatrix4(qn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Tu),us.child=e,this.dispatchEvent(us),us.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(Zs,e,Ym),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Zs,Zm,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,u=l.length;c<u;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),u=o(e.images),d=o(e.shapes),h=o(e.skeletons),f=o(e.animations),g=o(e.nodes);a.length>0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),u.length>0&&(n.images=u),d.length>0&&(n.shapes=d),h.length>0&&(n.skeletons=h),f.length>0&&(n.animations=f),g.length>0&&(n.nodes=g)}return n.object=s,n;function o(a){let l=[];for(let c in a){let u=a[c];delete u.metadata,l.push(u)}return l}}clone(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 Jn=class extends Qt{constructor(){super(),this.isGroup=!0,this.type="Group"}},Km={type:"move"},Es=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Jn,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 Jn,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 Jn,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 m=t.getJointPose(x,n),p=this._getHandJoint(c,x);m!==null&&(p.matrix.fromArray(m.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=m.radius),p.visible=m!==null}let u=c.joints["index-finger-tip"],d=c.joints["thumb-tip"],h=u.position.distanceTo(d.position),f=.02,g=.005;c.inputState.pinching&&h>f+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&h<=f-g&&(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(Km)))}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 Jn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},Md={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},fi={h:0,s:0,l:0},oo={h:0,s:0,l:0};function uc(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 me=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=cn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,ze.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=ze.workingColorSpace){return this.r=e,this.g=t,this.b=n,ze.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=ze.workingColorSpace){if(e=jc(e,1),t=Ve(t,0,1),n=Ve(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=uc(o,r,e+1/3),this.g=uc(o,r,e),this.b=uc(o,r,e-1/3)}return ze.colorSpaceToWorking(this,s),this}setStyle(e,t=cn){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=cn){let n=Md[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=jn(e.r),this.g=jn(e.g),this.b=jn(e.b),this}copyLinearToSRGB(e){return this.r=bs(e.r),this.g=bs(e.g),this.b=bs(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=cn){return ze.workingToColorSpace(Ht.copy(this),e),Math.round(Ve(Ht.r*255,0,255))*65536+Math.round(Ve(Ht.g*255,0,255))*256+Math.round(Ve(Ht.b*255,0,255))}getHexString(e=cn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=ze.workingColorSpace){ze.workingToColorSpace(Ht.copy(this),t);let n=Ht.r,s=Ht.g,r=Ht.b,o=Math.max(n,s,r),a=Math.min(n,s,r),l,c,u=(a+o)/2;if(a===o)l=0,c=0;else{let d=o-a;switch(c=u<=.5?d/(o+a):d/(2-o-a),o){case n:l=(s-r)/d+(s<r?6:0);break;case s:l=(r-n)/d+2;break;case r:l=(n-s)/d+4;break}l/=6}return e.h=l,e.s=c,e.l=u,e}getRGB(e,t=ze.workingColorSpace){return ze.workingToColorSpace(Ht.copy(this),t),e.r=Ht.r,e.g=Ht.g,e.b=Ht.b,e}getStyle(e=cn){ze.workingToColorSpace(Ht.copy(this),e);let t=Ht.r,n=Ht.g,s=Ht.b;return e!==cn?`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(fi),this.setHSL(fi.h+e,fi.s+t,fi.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(fi),e.getHSL(oo);let n=er(fi.h,oo.h,t),s=er(fi.s,oo.s,t),r=er(fi.l,oo.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}},Ht=new me;me.NAMES=Md;var Zi=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 yi,this.environmentIntensity=1,this.environmentRotation=new yi,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,Yn=new N,dc=new N,Zn=new N,ds=new N,fs=new N,Au=new N,fc=new N,pc=new N,mc=new N,gc=new xt,xc=new xt,vc=new xt,vi=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),Yn.subVectors(n,t),dc.subVectors(e,t);let o=wn.dot(wn),a=wn.dot(Yn),l=wn.dot(dc),c=Yn.dot(Yn),u=Yn.dot(dc),d=o*c-a*a;if(d===0)return r.set(0,0,0),null;let h=1/d,f=(c*l-a*u)*h,g=(o*u-a*l)*h;return r.set(1-f-g,g,f)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,Zn)===null?!1:Zn.x>=0&&Zn.y>=0&&Zn.x+Zn.y<=1}static getInterpolation(e,t,n,s,r,o,a,l){return this.getBarycoord(e,t,n,s,Zn)===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,Zn.x),l.addScaledVector(o,Zn.y),l.addScaledVector(a,Zn.z),l)}static getInterpolatedAttribute(e,t,n,s,r,o){return gc.setScalar(0),xc.setScalar(0),vc.setScalar(0),gc.fromBufferAttribute(e,t),xc.fromBufferAttribute(e,n),vc.fromBufferAttribute(e,s),o.setScalar(0),o.addScaledVector(gc,r.x),o.addScaledVector(xc,r.y),o.addScaledVector(vc,r.z),o}static isFrontFacing(e,t,n,s){return wn.subVectors(n,t),Yn.subVectors(e,t),wn.cross(Yn).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),Yn.subVectors(this.a,this.b),wn.cross(Yn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return i.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return i.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,r){return i.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}containsPoint(e){return i.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return i.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,s=this.b,r=this.c,o,a;ds.subVectors(s,n),fs.subVectors(r,n),fc.subVectors(e,n);let l=ds.dot(fc),c=fs.dot(fc);if(l<=0&&c<=0)return t.copy(n);pc.subVectors(e,s);let u=ds.dot(pc),d=fs.dot(pc);if(u>=0&&d<=u)return t.copy(s);let h=l*d-u*c;if(h<=0&&l>=0&&u<=0)return o=l/(l-u),t.copy(n).addScaledVector(ds,o);mc.subVectors(e,r);let f=ds.dot(mc),g=fs.dot(mc);if(g>=0&&f<=g)return t.copy(r);let x=f*c-l*g;if(x<=0&&c>=0&&g<=0)return a=c/(c-g),t.copy(n).addScaledVector(fs,a);let m=u*g-f*d;if(m<=0&&d-u>=0&&f-g>=0)return Au.subVectors(r,s),a=(d-u)/(d-u+(f-g)),t.copy(s).addScaledVector(Au,a);let p=1/(m+x+h);return o=x*p,a=h*p,t.copy(n).addScaledVector(ds,o).addScaledVector(fs,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},bi=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(),ao.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),ao.copy(n.boundingBox)),ao.applyMatrix4(e.matrixWorld),this.union(ao)}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($s),lo.subVectors(this.max,$s),ps.subVectors(e.a,$s),ms.subVectors(e.b,$s),gs.subVectors(e.c,$s),pi.subVectors(ms,ps),mi.subVectors(gs,ms),Vi.subVectors(ps,gs);let t=[0,-pi.z,pi.y,0,-mi.z,mi.y,0,-Vi.z,Vi.y,pi.z,0,-pi.x,mi.z,0,-mi.x,Vi.z,0,-Vi.x,-pi.y,pi.x,0,-mi.y,mi.x,0,-Vi.y,Vi.x,0];return!_c(t,ps,ms,gs,lo)||(t=[1,0,0,0,1,0,0,0,1],!_c(t,ps,ms,gs,lo))?!1:(co.crossVectors(pi,mi),t=[co.x,co.y,co.z],_c(t,ps,ms,gs,lo))}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:($n[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),$n[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),$n[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),$n[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),$n[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),$n[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),$n[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),$n[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints($n),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},$n=[new N,new N,new N,new N,new N,new N,new N,new N],En=new N,ao=new bi,ps=new N,ms=new N,gs=new N,pi=new N,mi=new N,Vi=new N,$s=new N,lo=new N,co=new N,Gi=new N;function _c(i,e,t,n,s){for(let r=0,o=i.length-3;r<=o;r+=3){Gi.fromArray(i,r);let a=s.x*Math.abs(Gi.x)+s.y*Math.abs(Gi.y)+s.z*Math.abs(Gi.z),l=e.dot(Gi),c=t.dot(Gi),u=n.dot(Gi);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>a)return!1}return!0}var wt=new N,ho=new Ee,Jm=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:Jm++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Nc,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++)ho.fromBufferAttribute(this,t),ho.applyMatrix3(e),this.setXY(t,ho.x,ho.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=ys(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=ys(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=ys(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=ys(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=ys(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!==Nc&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}};var lr=class extends Ye{constructor(e,t,n){super(new Uint16Array(e),t,n)}};var cr=class extends Ye{constructor(e,t,n){super(new Uint32Array(e),t,n)}};var Ut=class extends Ye{constructor(e,t,n){super(new Float32Array(e),t,n)}},jm=new bi,Ks=new N,yc=new N,Mi=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):jm.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;Ks.subVectors(e,this.center);let t=Ks.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(Ks,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):(yc.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ks.copy(e.center).add(yc)),this.expandByPoint(Ks.copy(e.center).sub(yc))),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}},Qm=0,vn=new gt,bc=new Qt,xs=new N,ln=new bi,Js=new bi,Nt=new N,ht=class i extends An{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Qm++}),this.uuid=Is(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Sm(e)?cr:lr)(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 Le().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 vn.makeRotationFromQuaternion(e),this.applyMatrix4(vn),this}rotateX(e){return vn.makeRotationX(e),this.applyMatrix4(vn),this}rotateY(e){return vn.makeRotationY(e),this.applyMatrix4(vn),this}rotateZ(e){return vn.makeRotationZ(e),this.applyMatrix4(vn),this}translate(e,t,n){return vn.makeTranslation(e,t,n),this.applyMatrix4(vn),this}scale(e,t,n){return vn.makeScale(e,t,n),this.applyMatrix4(vn),this}lookAt(e){return bc.lookAt(e),bc.updateMatrix(),this.applyMatrix4(bc.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(xs).negate(),this.translate(xs.x,xs.y,xs.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let s=0,r=e.length;s<r;s++){let o=e[s];n.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Ut(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 bi);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Re("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new N(-1/0,-1/0,-1/0),new N(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,s=t.length;n<s;n++){let r=t[n];ln.setFromBufferAttribute(r),this.morphTargetsRelative?(Nt.addVectors(this.boundingBox.min,ln.min),this.boundingBox.expandByPoint(Nt),Nt.addVectors(this.boundingBox.max,ln.max),this.boundingBox.expandByPoint(Nt)):(this.boundingBox.expandByPoint(ln.min),this.boundingBox.expandByPoint(ln.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Re('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 Mi);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Re("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(ln.setFromBufferAttribute(e),t)for(let r=0,o=t.length;r<o;r++){let a=t[r];Js.setFromBufferAttribute(a),this.morphTargetsRelative?(Nt.addVectors(ln.min,Js.min),ln.expandByPoint(Nt),Nt.addVectors(ln.max,Js.max),ln.expandByPoint(Nt)):(ln.expandByPoint(Js.min),ln.expandByPoint(Js.max))}ln.getCenter(n);let s=0;for(let r=0,o=e.count;r<o;r++)Nt.fromBufferAttribute(e,r),s=Math.max(s,n.distanceToSquared(Nt));if(t)for(let r=0,o=t.length;r<o;r++){let a=t[r],l=this.morphTargetsRelative;for(let c=0,u=a.count;c<u;c++)Nt.fromBufferAttribute(a,c),l&&(xs.fromBufferAttribute(e,c),Nt.add(xs)),s=Math.max(s,n.distanceToSquared(Nt))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&Re('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){Re("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,u=new N,d=new N,h=new Ee,f=new Ee,g=new Ee,x=new N,m=new N;function p(_,T,P){c.fromBufferAttribute(n,_),u.fromBufferAttribute(n,T),d.fromBufferAttribute(n,P),h.fromBufferAttribute(r,_),f.fromBufferAttribute(r,T),g.fromBufferAttribute(r,P),u.sub(c),d.sub(c),f.sub(h),g.sub(h);let R=1/(f.x*g.y-g.x*f.y);isFinite(R)&&(x.copy(u).multiplyScalar(g.y).addScaledVector(d,-f.y).multiplyScalar(R),m.copy(d).multiplyScalar(f.x).addScaledVector(u,-g.x).multiplyScalar(R),a[_].add(x),a[T].add(x),a[P].add(x),l[_].add(m),l[T].add(m),l[P].add(m))}let v=this.groups;v.length===0&&(v=[{start:0,count:e.count}]);for(let _=0,T=v.length;_<T;++_){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,E=new N,w=new N;function C(_){E.fromBufferAttribute(s,_),w.copy(E);let T=a[_];b.copy(T),b.sub(E.multiplyScalar(E.dot(T))).normalize(),M.crossVectors(w,T);let R=M.dot(l[_])<0?-1:1;o.setXYZW(_,b.x,b.y,b.z,R)}for(let _=0,T=v.length;_<T;++_){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 h=0,f=n.count;h<f;h++)n.setXYZ(h,0,0,0);let s=new N,r=new N,o=new N,a=new N,l=new N,c=new N,u=new N,d=new N;if(e)for(let h=0,f=e.count;h<f;h+=3){let g=e.getX(h+0),x=e.getX(h+1),m=e.getX(h+2);s.fromBufferAttribute(t,g),r.fromBufferAttribute(t,x),o.fromBufferAttribute(t,m),u.subVectors(o,r),d.subVectors(s,r),u.cross(d),a.fromBufferAttribute(n,g),l.fromBufferAttribute(n,x),c.fromBufferAttribute(n,m),a.add(u),l.add(u),c.add(u),n.setXYZ(g,a.x,a.y,a.z),n.setXYZ(x,l.x,l.y,l.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let h=0,f=t.count;h<f;h+=3)s.fromBufferAttribute(t,h+0),r.fromBufferAttribute(t,h+1),o.fromBufferAttribute(t,h+2),u.subVectors(o,r),d.subVectors(s,r),u.cross(d),n.setXYZ(h+0,u.x,u.y,u.z),n.setXYZ(h+1,u.x,u.y,u.z),n.setXYZ(h+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Nt.fromBufferAttribute(e,t),Nt.normalize(),e.setXYZ(t,Nt.x,Nt.y,Nt.z)}toNonIndexed(){function e(a,l){let c=a.array,u=a.itemSize,d=a.normalized,h=new c.constructor(l.length*u),f=0,g=0;for(let x=0,m=l.length;x<m;x++){a.isInterleavedBufferAttribute?f=l[x]*a.data.stride+a.offset:f=l[x]*u;for(let p=0;p<u;p++)h[g++]=c[f++]}return new Ye(h,u,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 u=0,d=c.length;u<d;u++){let h=c[u],f=e(h,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],u=[];for(let d=0,h=c.length;d<h;d++){let f=c[d];u.push(f.toJSON(e.data))}u.length>0&&(s[l]=u,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 u=s[c];this.setAttribute(c,u.clone(t))}let r=e.morphAttributes;for(let c in r){let u=[],d=r[c];for(let h=0,f=d.length;h<f;h++)u.push(d[h].clone(t));this.morphAttributes[c]=u}this.morphTargetsRelative=e.morphTargetsRelative;let o=e.groups;for(let c=0,u=o.length;c<u;c++){let d=o[c];this.addGroup(d.start,d.count,d.materialIndex)}let a=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 eg=0,ei=class extends An{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:eg++}),this.uuid=Is(),this.name="",this.type="Material",this.blending=qi,this.side=Qn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Po,this.blendDst=Io,this.blendEquation=_i,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new me(0,0,0),this.blendAlpha=0,this.depthFunc=Yi,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Lc,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Xi,this.stencilZFail=Xi,this.stencilZPass=Xi,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!==qi&&(n.blending=this.blending),this.side!==Qn&&(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!==Po&&(n.blendSrc=this.blendSrc),this.blendDst!==Io&&(n.blendDst=this.blendDst),this.blendEquation!==_i&&(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!==Yi&&(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!==Lc&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Xi&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Xi&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Xi&&(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 Kn=new N,Mc=new N,uo=new N,gi=new N,Sc=new N,fo=new N,wc=new N,Si=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,Kn)),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=Kn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Kn.copy(this.origin).addScaledVector(this.direction,t),Kn.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){Mc.copy(e).add(t).multiplyScalar(.5),uo.copy(t).sub(e).normalize(),gi.copy(this.origin).sub(Mc);let r=e.distanceTo(t)*.5,o=-this.direction.dot(uo),a=gi.dot(this.direction),l=-gi.dot(uo),c=gi.lengthSq(),u=Math.abs(1-o*o),d,h,f,g;if(u>0)if(d=o*l-a,h=o*a-l,g=r*u,d>=0)if(h>=-g)if(h<=g){let x=1/u;d*=x,h*=x,f=d*(d+o*h+2*a)+h*(o*d+h+2*l)+c}else h=r,d=Math.max(0,-(o*h+a)),f=-d*d+h*(h+2*l)+c;else h=-r,d=Math.max(0,-(o*h+a)),f=-d*d+h*(h+2*l)+c;else h<=-g?(d=Math.max(0,-(-o*r+a)),h=d>0?-r:Math.min(Math.max(-r,-l),r),f=-d*d+h*(h+2*l)+c):h<=g?(d=0,h=Math.min(Math.max(-r,-l),r),f=h*(h+2*l)+c):(d=Math.max(0,-(o*r+a)),h=d>0?r:Math.min(Math.max(-r,-l),r),f=-d*d+h*(h+2*l)+c);else h=o>0?-r:r,d=Math.max(0,-(o*h+a)),f=-d*d+h*(h+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(Mc).addScaledVector(uo,h),f}intersectSphere(e,t){Kn.subVectors(e.center,this.origin);let n=Kn.dot(this.direction),s=Kn.dot(Kn)-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,u=1/this.direction.y,d=1/this.direction.z,h=this.origin;return c>=0?(n=(e.min.x-h.x)*c,s=(e.max.x-h.x)*c):(n=(e.max.x-h.x)*c,s=(e.min.x-h.x)*c),u>=0?(r=(e.min.y-h.y)*u,o=(e.max.y-h.y)*u):(r=(e.max.y-h.y)*u,o=(e.min.y-h.y)*u),n>o||r>s||((r>n||isNaN(n))&&(n=r),(o<s||isNaN(s))&&(s=o),d>=0?(a=(e.min.z-h.z)*d,l=(e.max.z-h.z)*d):(a=(e.max.z-h.z)*d,l=(e.min.z-h.z)*d),n>l||a>s)||((a>n||n!==n)&&(n=a),(l<s||s!==s)&&(s=l),s<0)?null:this.at(n>=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,Kn)!==null}intersectTriangle(e,t,n,s,r){Sc.subVectors(t,e),fo.subVectors(n,e),wc.crossVectors(Sc,fo);let o=this.direction.dot(wc),a;if(o>0){if(s)return null;a=1}else if(o<0)a=-1,o=-o;else return null;gi.subVectors(this.origin,e);let l=a*this.direction.dot(fo.crossVectors(gi,fo));if(l<0)return null;let c=a*this.direction.dot(Sc.cross(gi));if(c<0||l+c>o)return null;let u=-a*gi.dot(wc);return u<0?null:this.at(u/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)}},ti=class extends ei{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new me(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 yi,this.combine=zc,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}},Cu=new gt,Hi=new Si,po=new Mi,Ru=new N,mo=new N,go=new N,xo=new N,Ec=new N,vo=new N,Pu=new N,_o=new N,Xt=class extends Qt{constructor(e=new ht,t=new ti){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){vo.set(0,0,0);for(let l=0,c=r.length;l<c;l++){let u=a[l],d=r[l];u!==0&&(Ec.fromBufferAttribute(d,e),o?vo.addScaledVector(Ec,u):vo.addScaledVector(Ec.sub(t),u))}t.add(vo)}return t}raycast(e,t){let n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),po.copy(n.boundingSphere),po.applyMatrix4(r),Hi.copy(e.ray).recast(e.near),!(po.containsPoint(Hi.origin)===!1&&(Hi.intersectSphere(po,Ru)===null||Hi.origin.distanceToSquared(Ru)>(e.far-e.near)**2))&&(Cu.copy(r).invert(),Hi.copy(e.ray).applyMatrix4(Cu),!(n.boundingBox!==null&&Hi.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Hi)))}_computeIntersections(e,t,n){let s,r=this.geometry,o=this.material,a=r.index,l=r.attributes.position,c=r.attributes.uv,u=r.attributes.uv1,d=r.attributes.normal,h=r.groups,f=r.drawRange;if(a!==null)if(Array.isArray(o))for(let g=0,x=h.length;g<x;g++){let m=h[g],p=o[m.materialIndex],v=Math.max(m.start,f.start),b=Math.min(a.count,Math.min(m.start+m.count,f.start+f.count));for(let M=v,E=b;M<E;M+=3){let w=a.getX(M),C=a.getX(M+1),_=a.getX(M+2);s=yo(this,p,e,n,c,u,d,w,C,_),s&&(s.faceIndex=Math.floor(M/3),s.face.materialIndex=m.materialIndex,t.push(s))}}else{let g=Math.max(0,f.start),x=Math.min(a.count,f.start+f.count);for(let m=g,p=x;m<p;m+=3){let v=a.getX(m),b=a.getX(m+1),M=a.getX(m+2);s=yo(this,o,e,n,c,u,d,v,b,M),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}else if(l!==void 0)if(Array.isArray(o))for(let g=0,x=h.length;g<x;g++){let m=h[g],p=o[m.materialIndex],v=Math.max(m.start,f.start),b=Math.min(l.count,Math.min(m.start+m.count,f.start+f.count));for(let M=v,E=b;M<E;M+=3){let w=M,C=M+1,_=M+2;s=yo(this,p,e,n,c,u,d,w,C,_),s&&(s.faceIndex=Math.floor(M/3),s.face.materialIndex=m.materialIndex,t.push(s))}}else{let g=Math.max(0,f.start),x=Math.min(l.count,f.start+f.count);for(let m=g,p=x;m<p;m+=3){let v=m,b=m+1,M=m+2;s=yo(this,o,e,n,c,u,d,v,b,M),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}}};function tg(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===Qn,a),l===null)return null;_o.copy(a),_o.applyMatrix4(i.matrixWorld);let c=t.ray.origin.distanceTo(_o);return c<t.near||c>t.far?null:{distance:c,point:_o.clone(),object:i}}function yo(i,e,t,n,s,r,o,a,l,c){i.getVertexPosition(a,mo),i.getVertexPosition(l,go),i.getVertexPosition(c,xo);let u=tg(i,e,t,n,mo,go,xo,Pu);if(u){let d=new N;vi.getBarycoord(Pu,mo,go,xo,d),s&&(u.uv=vi.getInterpolatedAttribute(s,a,l,c,d,new Ee)),r&&(u.uv1=vi.getInterpolatedAttribute(r,a,l,c,d,new Ee)),o&&(u.normal=vi.getInterpolatedAttribute(o,a,l,c,d,new N),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));let h={a,b:l,c,normal:new N,materialIndex:0};vi.getNormal(mo,go,xo,h.normal),u.face=h,u.barycoord=d}return u}var qo=class extends jt{constructor(e=null,t=1,n=1,s,r,o,a,l,c=Dt,u=Dt,d,h){super(null,o,a,l,c,u,s,r,d,h),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Tc=new N,ng=new N,ig=new Le,_n=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=Tc.subVectors(n,t).cross(ng.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(Tc),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||ig.getNormalMatrix(e),s=this.coplanarPoint(Tc).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)}},Wi=new Mi,sg=new Ee(.5,.5),bo=new N,hr=class{constructor(e=new _n,t=new _n,n=new _n,s=new _n,r=new _n,o=new _n){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],u=r[4],d=r[5],h=r[6],f=r[7],g=r[8],x=r[9],m=r[10],p=r[11],v=r[12],b=r[13],M=r[14],E=r[15];if(s[0].setComponents(c-o,f-u,p-g,E-v).normalize(),s[1].setComponents(c+o,f+u,p+g,E+v).normalize(),s[2].setComponents(c+a,f+d,p+x,E+b).normalize(),s[3].setComponents(c-a,f-d,p-x,E-b).normalize(),n)s[4].setComponents(l,h,m,M).normalize(),s[5].setComponents(c-l,f-h,p-m,E-M).normalize();else if(s[4].setComponents(c-l,f-h,p-m,E-M).normalize(),t===Tn)s[5].setComponents(c+l,f+h,p+m,E+M).normalize();else if(t===sr)s[5].setComponents(l,h,m,M).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Wi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Wi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Wi)}intersectsSprite(e){Wi.center.set(0,0,0);let t=sg.distanceTo(e.center);return Wi.radius=.7071067811865476+t,Wi.applyMatrix4(e.matrixWorld),this.intersectsSphere(Wi)}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(bo.x=s.normal.x>0?e.max.x:e.min.x,bo.y=s.normal.y>0?e.max.y:e.min.y,bo.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(bo)<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 ni=class extends ei{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new me(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}},Yo=new N,Zo=new N,Iu=new gt,js=new Si,Mo=new Mi,Ac=new N,Lu=new N,$o=class extends Qt{constructor(e=new ht,t=new ni){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++)Yo.fromBufferAttribute(t,s-1),Zo.fromBufferAttribute(t,s),n[s]=n[s-1],n[s]+=Yo.distanceTo(Zo);e.setAttribute("lineDistance",new Ut(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(),Mo.copy(n.boundingSphere),Mo.applyMatrix4(s),Mo.radius+=r,e.ray.intersectsSphere(Mo)===!1)return;Iu.copy(s).invert(),js.copy(e.ray).applyMatrix4(Iu);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=this.isLineSegments?2:1,u=n.index,h=n.attributes.position;if(u!==null){let f=Math.max(0,o.start),g=Math.min(u.count,o.start+o.count);for(let x=f,m=g-1;x<m;x+=c){let p=u.getX(x),v=u.getX(x+1),b=So(this,e,js,l,p,v,x);b&&t.push(b)}if(this.isLineLoop){let x=u.getX(g-1),m=u.getX(f),p=So(this,e,js,l,x,m,g-1);p&&t.push(p)}}else{let f=Math.max(0,o.start),g=Math.min(h.count,o.start+o.count);for(let x=f,m=g-1;x<m;x+=c){let p=So(this,e,js,l,x,x+1,x);p&&t.push(p)}if(this.isLineLoop){let x=So(this,e,js,l,g-1,f,g-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 So(i,e,t,n,s,r,o){let a=i.geometry.attributes.position;if(Yo.fromBufferAttribute(a,s),Zo.fromBufferAttribute(a,r),t.distanceSqToSegment(Yo,Zo,Ac,Lu)>n)return;Ac.applyMatrix4(i.matrixWorld);let c=e.ray.origin.distanceTo(Ac);if(!(c<e.near||c>e.far))return{distance:c,point:Lu.clone().applyMatrix4(i.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:i}}var Nu=new N,Du=new N,wi=class extends $o{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)Nu.fromBufferAttribute(t,s),Du.fromBufferAttribute(t,s+1),n[s]=s===0?0:n[s-1],n[s+1]=n[s]+Nu.distanceTo(Du);e.setAttribute("lineDistance",new Ut(n,1))}else Te("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var Ei=class extends ei{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new me(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}},Fu=new gt,Dc=new Si,wo=new Mi,Eo=new N,Bn=class extends Qt{constructor(e=new ht,t=new Ei){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(),wo.copy(n.boundingSphere),wo.applyMatrix4(s),wo.radius+=r,e.ray.intersectsSphere(wo)===!1)return;Fu.copy(s).invert(),Dc.copy(e.ray).applyMatrix4(Fu);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=a*a,c=n.index,d=n.attributes.position;if(c!==null){let h=Math.max(0,o.start),f=Math.min(c.count,o.start+o.count);for(let g=h,x=f;g<x;g++){let m=c.getX(g);Eo.fromBufferAttribute(d,m),ku(Eo,m,l,s,e,t,this)}}else{let h=Math.max(0,o.start),f=Math.min(d.count,o.start+o.count);for(let g=h,x=f;g<x;g++)Eo.fromBufferAttribute(d,g),ku(Eo,g,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 ku(i,e,t,n,s,r,o){let a=Dc.distanceSqToPoint(i);if(a<t){let l=new N;Dc.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 ur=class extends jt{constructor(e=[],t=Ii,n,s,r,o,a,l,c,u){super(e,t,n,s,r,o,a,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}};var ii=class extends jt{constructor(e,t,n=Rn,s,r,o,a=Dt,l=Dt,c,u=Un,d=1){if(u!==Un&&u!==Ni)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let h={width:e,height:t,depth:d};super(h,s,r,o,a,l,u,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new ws(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},Ko=class extends ii{constructor(e,t=Rn,n=Ii,s,r,o=Dt,a=Dt,l,c=Un){let u={width:e,height:e,depth:1},d=[u,u,u,u,u,u];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}},dr=class extends jt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},Ts=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=[],u=[],d=[],h=0,f=0;g("z","y","x",-1,-1,n,t,e,o,r,0),g("z","y","x",1,-1,n,t,-e,o,r,1),g("x","z","y",1,1,e,n,t,s,o,2),g("x","z","y",1,-1,e,n,-t,s,o,3),g("x","y","z",1,-1,e,t,n,s,r,4),g("x","y","z",-1,-1,e,t,-n,s,r,5),this.setIndex(l),this.setAttribute("position",new Ut(c,3)),this.setAttribute("normal",new Ut(u,3)),this.setAttribute("uv",new Ut(d,2));function g(x,m,p,v,b,M,E,w,C,_,T){let P=M/C,R=E/_,I=M/2,H=E/2,W=w/2,k=C+1,z=_+1,V=0,K=0,Q=new N;for(let ae=0;ae<z;ae++){let _e=ae*R-H;for(let be=0;be<k;be++){let We=be*P-I;Q[x]=We*v,Q[m]=_e*b,Q[p]=W,c.push(Q.x,Q.y,Q.z),Q[x]=0,Q[m]=0,Q[p]=w>0?1:-1,u.push(Q.x,Q.y,Q.z),d.push(be/C),d.push(1-ae/_),V+=1}}for(let ae=0;ae<_;ae++)for(let _e=0;_e<C;_e++){let be=h+_e+k*ae,We=h+_e+k*(ae+1),Qe=h+(_e+1)+k*(ae+1),ke=h+(_e+1)+k*ae;l.push(be,We,ke),l.push(We,Qe,ke),K+=6}a.addGroup(f,K,T),f+=K,h+=V}}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 fr=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,u=l+1,d=e/a,h=t/l,f=[],g=[],x=[],m=[];for(let p=0;p<u;p++){let v=p*h-o;for(let b=0;b<c;b++){let M=b*d-r;g.push(M,-v,0),x.push(0,0,1),m.push(b/a),m.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),E=v+1+c*(p+1),w=v+1+c*p;f.push(b,M,w),f.push(M,E,w)}this.setIndex(f),this.setAttribute("position",new Ut(g,3)),this.setAttribute("normal",new Ut(x,3)),this.setAttribute("uv",new Ut(m,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 Ki(i){let e={};for(let t in i){e[t]={};for(let n in i[t]){let s=i[t][n];if(Ou(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(Ou(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 Yt(i){let e={};for(let t=0;t<i.length;t++){let n=Ki(i[t]);for(let s in n)e[s]=n[s]}return e}function Ou(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function rg(i){let e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function eh(i){let e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:ze.workingColorSpace}var oi={clone:Ki,merge:Yt},og=`void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,ag=`void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`,ut=class extends ei{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=og,this.fragmentShader=ag,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=Ki(e.uniforms),this.uniformsGroups=rg(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}},As=class extends ut{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};var Jo=class extends ei{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}},jo=class extends ei{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 To(i,e){return!i||i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}var Ti=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_(){}},Qo=class extends Ti{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:Rc,endingEnd:Rc}}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 Pc:r=e,a=2*t-n;break;case Ic: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 Pc:o=e,l=2*n-t;break;case Ic:o=1,l=n+s[1]-s[0];break;default:o=e-1,l=t}let c=(n-t)*.5,u=this.valueSize;this._weightPrev=c/(t-a),this._weightNext=c/(l-n),this._offsetPrev=r*u,this._offsetNext=o*u}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,u=this._offsetPrev,d=this._offsetNext,h=this._weightPrev,f=this._weightNext,g=(n-t)/(s-t),x=g*g,m=x*g,p=-h*m+2*h*x-h*g,v=(1+h)*m+(-1.5-2*h)*x+(-.5+h)*g+1,b=(-1-f)*m+(1.5+f)*x+.5*g,M=f*m-f*x;for(let E=0;E!==a;++E)r[E]=p*o[u+E]+v*o[c+E]+b*o[l+E]+M*o[d+E];return r}},ea=class extends Ti{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,u=(n-t)/(s-t),d=1-u;for(let h=0;h!==a;++h)r[h]=o[c+h]*d+o[l+h]*u;return r}},ta=class extends Ti{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e){return this.copySampleValue_(e-1)}},na=class extends Ti{interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=e*a,c=l-a,u=this.settings||this.DefaultSettings_,d=u.inTangents,h=u.outTangents;if(!d||!h){let x=(n-t)/(s-t),m=1-x;for(let p=0;p!==a;++p)r[p]=o[c+p]*m+o[l+p]*x;return r}let f=a*2,g=e-1;for(let x=0;x!==a;++x){let m=o[c+x],p=o[l+x],v=g*f+x*2,b=h[v],M=h[v+1],E=e*f+x*2,w=d[E],C=d[E+1],_=(n-t)/(s-t),T,P,R,I,H;for(let W=0;W<8;W++){T=_*_,P=T*_,R=1-_,I=R*R,H=I*R;let z=H*t+3*I*_*b+3*R*T*w+P*s-n;if(Math.abs(z)<1e-10)break;let V=3*I*(b-t)+6*R*_*(w-b)+3*T*(s-w);if(Math.abs(V)<1e-10)break;_=_-z/V,_=Math.max(0,Math.min(1,_))}r[x]=H*m+3*I*_*M+3*R*T*C+P*p}return r}},un=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=To(t,this.TimeBufferType),this.values=To(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:To(e.times,Array),values:To(e.values,Array)};let s=e.getInterpolation();s!==e.DefaultInterpolation&&(n.interpolation=s)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new ta(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new ea(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Qo(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new na(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.settings=this.settings),t}setInterpolation(e){let t;switch(e){case tr:t=this.InterpolantFactoryMethodDiscrete;break;case Vo:t=this.InterpolantFactoryMethodLinear;break;case Ro:t=this.InterpolantFactoryMethodSmooth;break;case Cc: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 tr;case this.InterpolantFactoryMethodLinear:return Vo;case this.InterpolantFactoryMethodSmooth:return Ro;case this.InterpolantFactoryMethodBezier:return Cc}}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&&(Re("KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,s=this.values,r=n.length;r===0&&(Re("KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==r;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){Re("KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){Re("KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(s!==void 0&&wm(s))for(let a=0,l=s.length;a!==l;++a){let c=s[a];if(isNaN(c)){Re("KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===Ro,r=e.length-1,o=1;for(let a=1;a<r;++a){let l=!1,c=e[a],u=e[a+1];if(c!==u&&(a!==1||c!==e[0]))if(s)l=!0;else{let d=a*n,h=d-n,f=d+n;for(let g=0;g!==n;++g){let x=t[d+g];if(x!==t[h+g]||x!==t[f+g]){l=!0;break}}}if(l){if(a!==o){e[o]=e[a];let d=a*n,h=o*n;for(let f=0;f!==n;++f)t[h+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}};un.prototype.ValueTypeName="";un.prototype.TimeBufferType=Float32Array;un.prototype.ValueBufferType=Float32Array;un.prototype.DefaultInterpolation=Vo;var Ai=class extends un{constructor(e,t,n){super(e,t,n)}};Ai.prototype.ValueTypeName="bool";Ai.prototype.ValueBufferType=Array;Ai.prototype.DefaultInterpolation=tr;Ai.prototype.InterpolantFactoryMethodLinear=void 0;Ai.prototype.InterpolantFactoryMethodSmooth=void 0;var ia=class extends un{constructor(e,t,n,s){super(e,t,n,s)}};ia.prototype.ValueTypeName="color";var sa=class extends un{constructor(e,t,n,s){super(e,t,n,s)}};sa.prototype.ValueTypeName="number";var ra=class extends Ti{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 u=c+a;c!==u;c+=4)hn.slerpFlat(r,0,o,c-a,o,c,l);return r}},pr=class extends un{constructor(e,t,n,s){super(e,t,n,s)}InterpolantFactoryMethodLinear(e){return new ra(this.times,this.values,this.getValueSize(),e)}};pr.prototype.ValueTypeName="quaternion";pr.prototype.InterpolantFactoryMethodSmooth=void 0;var Ci=class extends un{constructor(e,t,n){super(e,t,n)}};Ci.prototype.ValueTypeName="string";Ci.prototype.ValueBufferType=Array;Ci.prototype.DefaultInterpolation=tr;Ci.prototype.InterpolantFactoryMethodLinear=void 0;Ci.prototype.InterpolantFactoryMethodSmooth=void 0;var oa=class extends un{constructor(e,t,n,s){super(e,t,n,s)}};oa.prototype.ValueTypeName="vector";var aa=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(u){a++,r===!1&&s.onStart!==void 0&&s.onStart(u,o,a),r=!0},this.itemEnd=function(u){o++,s.onProgress!==void 0&&s.onProgress(u,o,a),o===a&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(u){s.onError!==void 0&&s.onError(u)},this.resolveURL=function(u){return l?l(u):u},this.setURLModifier=function(u){return l=u,this},this.addHandler=function(u,d){return c.push(u,d),this},this.removeHandler=function(u){let d=c.indexOf(u);return d!==-1&&c.splice(d,2),this},this.getHandler=function(u){for(let d=0,h=c.length;d<h;d+=2){let f=c[d],g=c[d+1];if(f.global&&(f.lastIndex=0),f.test(u))return g}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}},Sd=new aa,la=class{constructor(e){this.manager=e!==void 0?e:Sd,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}};la.DEFAULT_MATERIAL_NAME="__DEFAULT";var Ao=new N,Co=new hn,kn=new N,mr=class extends Qt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new gt,this.projectionMatrix=new gt,this.projectionMatrixInverse=new gt,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(Ao,Co,kn),kn.x===1&&kn.y===1&&kn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Ao,Co,kn.set(1,1,1)).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorld.decompose(Ao,Co,kn),kn.x===1&&kn.y===1&&kn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Ao,Co,kn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}},xi=new N,Uu=new Ee,Bu=new Ee,Wt=class extends mr{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=Ss*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Qs*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Ss*2*Math.atan(Math.tan(Qs*.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){xi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(xi.x,xi.y).multiplyScalar(-e/xi.z),xi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(xi.x,xi.y).multiplyScalar(-e/xi.z)}getViewSize(e,t){return this.getViewBounds(e,Uu,Bu),t.subVectors(Bu,Uu)}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(Qs*.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 si=class extends mr{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,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,o=r+c*this.view.width,a-=u*this.view.offsetY,l=a-u*this.view.height}this.projectionMatrix.makeOrthographic(r,o,a,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(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 vs=-90,_s=1,ca=class extends Qt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let s=new Wt(vs,_s,e,t);s.layers=this.layers,this.add(s);let r=new Wt(vs,_s,e,t);r.layers=this.layers,this.add(r);let o=new Wt(vs,_s,e,t);o.layers=this.layers,this.add(o);let a=new Wt(vs,_s,e,t);a.layers=this.layers,this.add(a);let l=new Wt(vs,_s,e,t);l.layers=this.layers,this.add(l);let c=new Wt(vs,_s,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===sr)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,u]=this.children,d=e.getRenderTarget(),h=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;let x=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(n,0,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,1,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,2,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,3,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(n,4,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),n.texture.generateMipmaps=x,e.setRenderTarget(n,5,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,u),e.setRenderTarget(d,h,f),e.xr.enabled=g,n.texture.needsPMREMUpdate=!0}},ha=class extends Wt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},gr=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=lg.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 lg(){this._document.hidden===!1&&this.reset()}var th="\\[\\]\\.:\\/",cg=new RegExp("["+th+"]","g"),nh="[^"+th+"]",hg="[^"+th.replace("\\.","")+"]",ug=/((?:WC+[\/:])*)/.source.replace("WC",nh),dg=/(WCOD+)?/.source.replace("WCOD",hg),fg=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",nh),pg=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",nh),mg=new RegExp("^"+ug+dg+fg+pg+"$"),gg=["material","materials","bones","map"],Fc=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(cg,"")}static parseTrackName(e){let t=mg.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);gg.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){Re("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Re("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){Re("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===c){c=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Re("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Re("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){Re("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(c!==void 0){if(e[c]===void 0){Re("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;Re("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){Re("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Re("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=Fc;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 lM=new Float32Array(1);var dn=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=Ve(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(Ve(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var lh=class lh{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}};lh.prototype.isMatrix2=!0;var kc=lh;var xr=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 ih(i,e,t,n){let s=xg(n);switch(t){case qc:return i*e;case Zc:return i*e/s.components*s.byteLength;case _a:return i*e/s.components*s.byteLength;case Di:return i*e*2/s.components*s.byteLength;case ya:return i*e*2/s.components*s.byteLength;case Yc:return i*e*3/s.components*s.byteLength;case bn:return i*e*4/s.components*s.byteLength;case ba:return i*e*4/s.components*s.byteLength;case Cr:case Rr:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Pr:case Ir:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Sa:case Ea:return Math.max(i,16)*Math.max(e,8)/4;case Ma:case wa:return Math.max(i,8)*Math.max(e,8)/2;case Ta:case Aa:case Ra:case Pa:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Ca:case Lr:case Ia:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case La:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Na:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case Da:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case Fa:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case ka:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case Oa:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case Ua:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case Ba:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case za:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case Va:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case Ga:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case Ha:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case Wa:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case Xa:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case qa:case Ya:case Za:return Math.ceil(i/4)*Math.ceil(e/4)*16;case $a:case Ka:return Math.ceil(i/4)*Math.ceil(e/4)*8;case Nr:case Ja:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function xg(i){switch(i){case pn:case Gc:return{byteLength:1,components:1};case Rs:case Hc:case qt:return{byteLength:2,components:1};case xa:case va:return{byteLength:2,components:4};case Rn:case ga:case Pn:return{byteLength:4,components:1};case Wc:case Xc:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:da}}));typeof window<"u"&&(window.__THREE__?Te("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=da);function qd(){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 vg(i){let e=new WeakMap;function t(a,l){let c=a.array,u=a.usage,d=c.byteLength,h=i.createBuffer();i.bindBuffer(l,h),i.bufferData(l,c,u),a.onUploadCallback();let f;if(c instanceof Float32Array)f=i.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)f=i.HALF_FLOAT;else if(c instanceof Uint16Array)a.isFloat16BufferAttribute?f=i.HALF_FLOAT:f=i.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=i.SHORT;else if(c instanceof Uint32Array)f=i.UNSIGNED_INT;else if(c instanceof Int32Array)f=i.INT;else if(c instanceof Int8Array)f=i.BYTE;else if(c instanceof Uint8Array)f=i.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:h,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:a.version,size:d}}function n(a,l,c){let u=l.array,d=l.updateRanges;if(i.bindBuffer(c,a),d.length===0)i.bufferSubData(c,0,u);else{d.sort((f,g)=>f.start-g.start);let h=0;for(let f=1;f<d.length;f++){let g=d[h],x=d[f];x.start<=g.start+g.count+1?g.count=Math.max(g.count,x.start+x.count-g.start):(++h,d[h]=x)}d.length=h+1;for(let f=0,g=d.length;f<g;f++){let x=d[f];i.bufferSubData(c,x.start*u.BYTES_PER_ELEMENT,u,x.start,x.count)}l.clearUpdateRanges()}l.onUploadCallback()}function s(a){return a.isInterleavedBufferAttribute&&(a=a.data),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 u=e.get(a);(!u||u.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 _g=`#ifdef USE_ALPHAHASH
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
#endif`,yg=`#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`,bg=`#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
#endif`,Mg=`#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
#endif`,Sg=`#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`,wg=`#ifdef USE_ALPHATEST
uniform float alphaTest;
#endif`,Eg=`#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`,Tg=`#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
#endif`,Ag=`#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`,Cg=`#ifdef USE_BATCHING
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
#endif`,Rg=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
vPosition = vec3( position );
#endif`,Pg=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
#endif`,Ig=`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`,Lg=`#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`,Ng=`#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`,Dg=`#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`,Fg=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`,kg=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
#endif`,Og=`#if NUM_CLIPPING_PLANES > 0
vClipPosition = - mvPosition.xyz;
#endif`,Ug=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
diffuseColor *= vColor;
#endif`,Bg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#endif`,zg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
varying vec4 vColor;
#endif`,Vg=`#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`,Gg=`#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`,Hg=`#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`,Wg=`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`,Xg=`#ifdef USE_DISPLACEMENTMAP
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
#endif`,qg=`#ifdef USE_DISPLACEMENTMAP
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
#endif`,Yg=`#ifdef USE_EMISSIVEMAP
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
emissiveColor = sRGBTransferEOTF( emissiveColor );
#endif
totalEmissiveRadiance *= emissiveColor.rgb;
#endif`,Zg=`#ifdef USE_EMISSIVEMAP
uniform sampler2D emissiveMap;
#endif`,$g="gl_FragColor = linearToOutputTexel( gl_FragColor );",Kg=`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 );
}`,Jg=`#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`,jg=`#ifdef USE_ENVMAP
uniform float envMapIntensity;
uniform mat3 envMapRotation;
#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#else
uniform sampler2D envMap;
#endif
#endif`,Qg=`#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`,e0=`#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`,t0=`#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`,n0=`#ifdef USE_FOG
vFogDepth = - mvPosition.z;
#endif`,i0=`#ifdef USE_FOG
varying float vFogDepth;
#endif`,s0=`#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`,r0=`#ifdef USE_FOG
uniform vec3 fogColor;
varying float vFogDepth;
#ifdef FOG_EXP2
uniform float fogDensity;
#else
uniform float fogNear;
uniform float fogFar;
#endif
#endif`,o0=`#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
}`,a0=`#ifdef USE_LIGHTMAP
uniform sampler2D lightMap;
uniform float lightMapIntensity;
#endif`,l0=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`,c0=`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`,h0=`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>`,u0=`#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`,d0=`ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`,f0=`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`,p0=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`,m0=`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`,g0=`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`,x0=`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 );
}`,v0=`
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`,_0=`#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`,y0=`#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`,b0=`#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`,M0=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`,S0=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
#endif`,w0=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
varying float vFragDepth;
varying float vIsPerspective;
#endif`,E0=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
vFragDepth = 1.0 + gl_Position.w;
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#endif`,T0=`#ifdef USE_MAP
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
#ifdef DECODE_VIDEO_TEXTURE
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
#endif
diffuseColor *= sampledDiffuseColor;
#endif`,A0=`#ifdef USE_MAP
uniform sampler2D map;
#endif`,C0=`#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`,R0=`#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`,P0=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
metalnessFactor *= texelMetalness.b;
#endif`,I0=`#ifdef USE_METALNESSMAP
uniform sampler2D metalnessMap;
#endif`,L0=`#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`,N0=`#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`,D0=`#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`,F0=`#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`,k0=`#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`,O0=`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;`,U0=`#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`,B0=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,z0=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,V0=`#ifndef FLAT_SHADED
vNormal = normalize( transformedNormal );
#ifdef USE_TANGENT
vTangent = normalize( transformedTangent );
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
#endif
#endif`,G0=`#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`,H0=`#ifdef USE_CLEARCOAT
vec3 clearcoatNormal = nonPerturbedNormal;
#endif`,W0=`#ifdef USE_CLEARCOAT_NORMALMAP
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
clearcoatMapN.xy *= clearcoatNormalScale;
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
#endif`,X0=`#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`,q0=`#ifdef USE_IRIDESCENCEMAP
uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform sampler2D iridescenceThicknessMap;
#endif`,Y0=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Z0=`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
}`,$0=`#ifdef PREMULTIPLIED_ALPHA
gl_FragColor.rgb *= gl_FragColor.a;
#endif`,K0=`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;`,J0=`#ifdef DITHERING
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`,j0=`#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`,Q0=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
roughnessFactor *= texelRoughness.g;
#endif`,ex=`#ifdef USE_ROUGHNESSMAP
uniform sampler2D roughnessMap;
#endif`,tx=`#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`,nx=`#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`,ix=`#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`,sx=`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;
}`,rx=`#ifdef USE_SKINNING
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`,ox=`#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`,ax=`#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`,lx=`#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`,cx=`float specularStrength;
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
#endif`,hx=`#ifdef USE_SPECULARMAP
uniform sampler2D specularMap;
#endif`,ux=`#if defined( TONE_MAPPING )
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`,dx=`#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; }`,fx=`#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`,px=`#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`,mx=`#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`,gx=`#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`,xx=`#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`,vx=`#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`,_x=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
gl_Position = vec4( position.xy, 1.0, 1.0 );
}`,yx=`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>
}`,bx=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,Mx=`#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>
}`,Sx=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,wx=`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>
}`,Ex=`#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;
}`,Tx=`#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
}`,Ax=`#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;
}`,Cx=`#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 );
}`,Rx=`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
}`,Px=`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>
}`,Ix=`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>
}`,Lx=`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>
}`,Nx=`#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>
}`,Dx=`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>
}`,Fx=`#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>
}`,kx=`#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>
}`,Ox=`#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;
}`,Ux=`#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>
}`,Bx=`#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
}`,zx=`#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
}`,Vx=`#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>
}`,Gx=`#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>
}`,Hx=`#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
}`,Wx=`#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>
}`,Xx=`#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>
}`,qx=`#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>
}`,Yx=`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>
}`,Zx=`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>
}`,$x=`#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>
}`,Kx=`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>
}`,Jx=`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>
}`,jx=`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>
}`,Ue={alphahash_fragment:_g,alphahash_pars_fragment:yg,alphamap_fragment:bg,alphamap_pars_fragment:Mg,alphatest_fragment:Sg,alphatest_pars_fragment:wg,aomap_fragment:Eg,aomap_pars_fragment:Tg,batching_pars_vertex:Ag,batching_vertex:Cg,begin_vertex:Rg,beginnormal_vertex:Pg,bsdfs:Ig,iridescence_fragment:Lg,bumpmap_pars_fragment:Ng,clipping_planes_fragment:Dg,clipping_planes_pars_fragment:Fg,clipping_planes_pars_vertex:kg,clipping_planes_vertex:Og,color_fragment:Ug,color_pars_fragment:Bg,color_pars_vertex:zg,color_vertex:Vg,common:Gg,cube_uv_reflection_fragment:Hg,defaultnormal_vertex:Wg,displacementmap_pars_vertex:Xg,displacementmap_vertex:qg,emissivemap_fragment:Yg,emissivemap_pars_fragment:Zg,colorspace_fragment:$g,colorspace_pars_fragment:Kg,envmap_fragment:Jg,envmap_common_pars_fragment:jg,envmap_pars_fragment:Qg,envmap_pars_vertex:e0,envmap_physical_pars_fragment:u0,envmap_vertex:t0,fog_vertex:n0,fog_pars_vertex:i0,fog_fragment:s0,fog_pars_fragment:r0,gradientmap_pars_fragment:o0,lightmap_pars_fragment:a0,lights_lambert_fragment:l0,lights_lambert_pars_fragment:c0,lights_pars_begin:h0,lights_toon_fragment:d0,lights_toon_pars_fragment:f0,lights_phong_fragment:p0,lights_phong_pars_fragment:m0,lights_physical_fragment:g0,lights_physical_pars_fragment:x0,lights_fragment_begin:v0,lights_fragment_maps:_0,lights_fragment_end:y0,lightprobes_pars_fragment:b0,logdepthbuf_fragment:M0,logdepthbuf_pars_fragment:S0,logdepthbuf_pars_vertex:w0,logdepthbuf_vertex:E0,map_fragment:T0,map_pars_fragment:A0,map_particle_fragment:C0,map_particle_pars_fragment:R0,metalnessmap_fragment:P0,metalnessmap_pars_fragment:I0,morphinstance_vertex:L0,morphcolor_vertex:N0,morphnormal_vertex:D0,morphtarget_pars_vertex:F0,morphtarget_vertex:k0,normal_fragment_begin:O0,normal_fragment_maps:U0,normal_pars_fragment:B0,normal_pars_vertex:z0,normal_vertex:V0,normalmap_pars_fragment:G0,clearcoat_normal_fragment_begin:H0,clearcoat_normal_fragment_maps:W0,clearcoat_pars_fragment:X0,iridescence_pars_fragment:q0,opaque_fragment:Y0,packing:Z0,premultiplied_alpha_fragment:$0,project_vertex:K0,dithering_fragment:J0,dithering_pars_fragment:j0,roughnessmap_fragment:Q0,roughnessmap_pars_fragment:ex,shadowmap_pars_fragment:tx,shadowmap_pars_vertex:nx,shadowmap_vertex:ix,shadowmask_pars_fragment:sx,skinbase_vertex:rx,skinning_pars_vertex:ox,skinning_vertex:ax,skinnormal_vertex:lx,specularmap_fragment:cx,specularmap_pars_fragment:hx,tonemapping_fragment:ux,tonemapping_pars_fragment:dx,transmission_fragment:fx,transmission_pars_fragment:px,uv_pars_fragment:mx,uv_pars_vertex:gx,uv_vertex:xx,worldpos_vertex:vx,background_vert:_x,background_frag:yx,backgroundCube_vert:bx,backgroundCube_frag:Mx,cube_vert:Sx,cube_frag:wx,depth_vert:Ex,depth_frag:Tx,distance_vert:Ax,distance_frag:Cx,equirect_vert:Rx,equirect_frag:Px,linedashed_vert:Ix,linedashed_frag:Lx,meshbasic_vert:Nx,meshbasic_frag:Dx,meshlambert_vert:Fx,meshlambert_frag:kx,meshmatcap_vert:Ox,meshmatcap_frag:Ux,meshnormal_vert:Bx,meshnormal_frag:zx,meshphong_vert:Vx,meshphong_frag:Gx,meshphysical_vert:Hx,meshphysical_frag:Wx,meshtoon_vert:Xx,meshtoon_frag:qx,points_vert:Yx,points_frag:Zx,shadow_vert:$x,shadow_frag:Kx,sprite_vert:Jx,sprite_frag:jx},ce={common:{diffuse:{value:new me(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Le},alphaMap:{value:null},alphaMapTransform:{value:new Le},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Le}},envmap:{envMap:{value:null},envMapRotation:{value:new Le},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Le}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Le}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Le},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Le},normalScale:{value:new Ee(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Le},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Le}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Le}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Le}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new me(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 me(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Le},alphaTest:{value:0},uvTransform:{value:new Le}},sprite:{diffuse:{value:new me(16777215)},opacity:{value:1},center:{value:new Ee(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Le},alphaMap:{value:null},alphaMapTransform:{value:new Le},alphaTest:{value:0}}},Gn={basic:{uniforms:Yt([ce.common,ce.specularmap,ce.envmap,ce.aomap,ce.lightmap,ce.fog]),vertexShader:Ue.meshbasic_vert,fragmentShader:Ue.meshbasic_frag},lambert:{uniforms:Yt([ce.common,ce.specularmap,ce.envmap,ce.aomap,ce.lightmap,ce.emissivemap,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.fog,ce.lights,{emissive:{value:new me(0)},envMapIntensity:{value:1}}]),vertexShader:Ue.meshlambert_vert,fragmentShader:Ue.meshlambert_frag},phong:{uniforms:Yt([ce.common,ce.specularmap,ce.envmap,ce.aomap,ce.lightmap,ce.emissivemap,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.fog,ce.lights,{emissive:{value:new me(0)},specular:{value:new me(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ue.meshphong_vert,fragmentShader:Ue.meshphong_frag},standard:{uniforms:Yt([ce.common,ce.envmap,ce.aomap,ce.lightmap,ce.emissivemap,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.roughnessmap,ce.metalnessmap,ce.fog,ce.lights,{emissive:{value:new me(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ue.meshphysical_vert,fragmentShader:Ue.meshphysical_frag},toon:{uniforms:Yt([ce.common,ce.aomap,ce.lightmap,ce.emissivemap,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.gradientmap,ce.fog,ce.lights,{emissive:{value:new me(0)}}]),vertexShader:Ue.meshtoon_vert,fragmentShader:Ue.meshtoon_frag},matcap:{uniforms:Yt([ce.common,ce.bumpmap,ce.normalmap,ce.displacementmap,ce.fog,{matcap:{value:null}}]),vertexShader:Ue.meshmatcap_vert,fragmentShader:Ue.meshmatcap_frag},points:{uniforms:Yt([ce.points,ce.fog]),vertexShader:Ue.points_vert,fragmentShader:Ue.points_frag},dashed:{uniforms:Yt([ce.common,ce.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ue.linedashed_vert,fragmentShader:Ue.linedashed_frag},depth:{uniforms:Yt([ce.common,ce.displacementmap]),vertexShader:Ue.depth_vert,fragmentShader:Ue.depth_frag},normal:{uniforms:Yt([ce.common,ce.bumpmap,ce.normalmap,ce.displacementmap,{opacity:{value:1}}]),vertexShader:Ue.meshnormal_vert,fragmentShader:Ue.meshnormal_frag},sprite:{uniforms:Yt([ce.sprite,ce.fog]),vertexShader:Ue.sprite_vert,fragmentShader:Ue.sprite_frag},background:{uniforms:{uvTransform:{value:new Le},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ue.background_vert,fragmentShader:Ue.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Le}},vertexShader:Ue.backgroundCube_vert,fragmentShader:Ue.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ue.cube_vert,fragmentShader:Ue.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ue.equirect_vert,fragmentShader:Ue.equirect_frag},distance:{uniforms:Yt([ce.common,ce.displacementmap,{referencePosition:{value:new N},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ue.distance_vert,fragmentShader:Ue.distance_frag},shadow:{uniforms:Yt([ce.lights,ce.fog,{color:{value:new me(0)},opacity:{value:1}}]),vertexShader:Ue.shadow_vert,fragmentShader:Ue.shadow_frag}};Gn.physical={uniforms:Yt([Gn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Le},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Le},clearcoatNormalScale:{value:new Ee(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Le},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Le},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Le},sheen:{value:0},sheenColor:{value:new me(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Le},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Le},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Le},transmissionSamplerSize:{value:new Ee},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Le},attenuationDistance:{value:0},attenuationColor:{value:new me(0)},specularColor:{value:new me(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Le},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Le},anisotropyVector:{value:new Ee},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Le}}]),vertexShader:Ue.meshphysical_vert,fragmentShader:Ue.meshphysical_frag};var el={r:0,b:0,g:0},Qx=new gt,Yd=new Le;Yd.set(-1,0,0,0,1,0,0,0,1);function ev(i,e,t,n,s,r){let o=new me(0),a=s===!0?0:1,l,c,u=null,d=0,h=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 g(v){let b=!1,M=f(v);M===null?m(o,a):M&&M.isColor&&(m(M,1),b=!0);let E=i.xr.getEnvironmentBlendMode();E==="additive"?t.buffers.color.setClear(0,0,0,1,r):E==="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===Tr)?(c===void 0&&(c=new Xt(new Ts(1,1,1),new ut({name:"BackgroundCubeMaterial",uniforms:Ki(Gn.backgroundCube.uniforms),vertexShader:Gn.backgroundCube.vertexShader,fragmentShader:Gn.backgroundCube.fragmentShader,side:$t,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(E,w,C){this.matrixWorld.copyPosition(C.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=M,c.material.uniforms.backgroundBlurriness.value=b.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Qx.makeRotationFromEuler(b.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(Yd),c.material.toneMapped=ze.getTransfer(M.colorSpace)!==Je,(u!==M||d!==M.version||h!==i.toneMapping)&&(c.material.needsUpdate=!0,u=M,d=M.version,h=i.toneMapping),c.layers.enableAll(),v.unshift(c,c.geometry,c.material,0,0,null)):M&&M.isTexture&&(l===void 0&&(l=new Xt(new fr(2,2),new ut({name:"BackgroundMaterial",uniforms:Ki(Gn.background.uniforms),vertexShader:Gn.background.vertexShader,fragmentShader:Gn.background.fragmentShader,side:Qn,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=ze.getTransfer(M.colorSpace)!==Je,M.matrixAutoUpdate===!0&&M.updateMatrix(),l.material.uniforms.uvTransform.value.copy(M.matrix),(u!==M||d!==M.version||h!==i.toneMapping)&&(l.material.needsUpdate=!0,u=M,d=M.version,h=i.toneMapping),l.layers.enableAll(),v.unshift(l,l.geometry,l.material,0,0,null))}function m(v,b){v.getRGB(el,eh(i)),t.buffers.color.setClear(el.r,el.g,el.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,m(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(v){a=v,m(o,a)},render:g,addToRenderList:x,dispose:p}}function tv(i,e){let t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=h(null),r=s,o=!1;function a(R,I,H,W,k){let z=!1,V=d(R,W,H,I);r!==V&&(r=V,c(r.object)),z=f(R,W,H,k),z&&g(R,W,H,k),k!==null&&e.update(k,i.ELEMENT_ARRAY_BUFFER),(z||o)&&(o=!1,M(R,I,H,W),k!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(k).buffer))}function l(){return i.createVertexArray()}function c(R){return i.bindVertexArray(R)}function u(R){return i.deleteVertexArray(R)}function d(R,I,H,W){let k=W.wireframe===!0,z=n[I.id];z===void 0&&(z={},n[I.id]=z);let V=R.isInstancedMesh===!0?R.id:0,K=z[V];K===void 0&&(K={},z[V]=K);let Q=K[H.id];Q===void 0&&(Q={},K[H.id]=Q);let ae=Q[k];return ae===void 0&&(ae=h(l()),Q[k]=ae),ae}function h(R){let I=[],H=[],W=[];for(let k=0;k<t;k++)I[k]=0,H[k]=0,W[k]=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 k=r.attributes,z=I.attributes,V=0,K=H.getAttributes();for(let Q in K)if(K[Q].location>=0){let _e=k[Q],be=z[Q];if(be===void 0&&(Q==="instanceMatrix"&&R.instanceMatrix&&(be=R.instanceMatrix),Q==="instanceColor"&&R.instanceColor&&(be=R.instanceColor)),_e===void 0||_e.attribute!==be||be&&_e.data!==be.data)return!0;V++}return r.attributesNum!==V||r.index!==W}function g(R,I,H,W){let k={},z=I.attributes,V=0,K=H.getAttributes();for(let Q in K)if(K[Q].location>=0){let _e=z[Q];_e===void 0&&(Q==="instanceMatrix"&&R.instanceMatrix&&(_e=R.instanceMatrix),Q==="instanceColor"&&R.instanceColor&&(_e=R.instanceColor));let be={};be.attribute=_e,_e&&_e.data&&(be.data=_e.data),k[Q]=be,V++}r.attributes=k,r.attributesNum=V,r.index=W}function x(){let R=r.newAttributes;for(let I=0,H=R.length;I<H;I++)R[I]=0}function m(R){p(R,0)}function p(R,I){let H=r.newAttributes,W=r.enabledAttributes,k=r.attributeDivisors;H[R]=1,W[R]===0&&(i.enableVertexAttribArray(R),W[R]=1),k[R]!==I&&(i.vertexAttribDivisor(R,I),k[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,k,z,V){V===!0?i.vertexAttribIPointer(R,I,H,k,z):i.vertexAttribPointer(R,I,H,W,k,z)}function M(R,I,H,W){x();let k=W.attributes,z=H.getAttributes(),V=I.defaultAttributeValues;for(let K in z){let Q=z[K];if(Q.location>=0){let ae=k[K];if(ae===void 0&&(K==="instanceMatrix"&&R.instanceMatrix&&(ae=R.instanceMatrix),K==="instanceColor"&&R.instanceColor&&(ae=R.instanceColor)),ae!==void 0){let _e=ae.normalized,be=ae.itemSize,We=e.get(ae);if(We===void 0)continue;let Qe=We.buffer,ke=We.type,$=We.bytesPerElement,de=ke===i.INT||ke===i.UNSIGNED_INT||ae.gpuType===ga;if(ae.isInterleavedBufferAttribute){let ie=ae.data,Ae=ie.stride,Ne=ae.offset;if(ie.isInstancedInterleavedBuffer){for(let Pe=0;Pe<Q.locationSize;Pe++)p(Q.location+Pe,ie.meshPerAttribute);R.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=ie.meshPerAttribute*ie.count)}else for(let Pe=0;Pe<Q.locationSize;Pe++)m(Q.location+Pe);i.bindBuffer(i.ARRAY_BUFFER,Qe);for(let Pe=0;Pe<Q.locationSize;Pe++)b(Q.location+Pe,be/Q.locationSize,ke,_e,Ae*$,(Ne+be/Q.locationSize*Pe)*$,de)}else{if(ae.isInstancedBufferAttribute){for(let ie=0;ie<Q.locationSize;ie++)p(Q.location+ie,ae.meshPerAttribute);R.isInstancedMesh!==!0&&W._maxInstanceCount===void 0&&(W._maxInstanceCount=ae.meshPerAttribute*ae.count)}else for(let ie=0;ie<Q.locationSize;ie++)m(Q.location+ie);i.bindBuffer(i.ARRAY_BUFFER,Qe);for(let ie=0;ie<Q.locationSize;ie++)b(Q.location+ie,be/Q.locationSize,ke,_e,be*$,be/Q.locationSize*ie*$,de)}}else if(V!==void 0){let _e=V[K];if(_e!==void 0)switch(_e.length){case 2:i.vertexAttrib2fv(Q.location,_e);break;case 3:i.vertexAttrib3fv(Q.location,_e);break;case 4:i.vertexAttrib4fv(Q.location,_e);break;default:i.vertexAttrib1fv(Q.location,_e)}}}}v()}function E(){T();for(let R in n){let I=n[R];for(let H in I){let W=I[H];for(let k in W){let z=W[k];for(let V in z)u(z[V].object),delete z[V];delete W[k]}}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 k in W){let z=W[k];for(let V in z)u(z[V].object),delete z[V];delete W[k]}}delete n[R.id]}function C(R){for(let I in n){let H=n[I];for(let W in H){let k=H[W];if(k[R.id]===void 0)continue;let z=k[R.id];for(let V in z)u(z[V].object),delete z[V];delete k[R.id]}}}function _(R){for(let I in n){let H=n[I],W=R.isInstancedMesh===!0?R.id:0,k=H[W];if(k!==void 0){for(let z in k){let V=k[z];for(let K in V)u(V[K].object),delete V[K];delete k[z]}delete H[W],Object.keys(H).length===0&&delete n[I]}}}function T(){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:T,resetDefaultState:P,dispose:E,releaseStatesOfGeometry:w,releaseStatesOfObject:_,releaseStatesOfProgram:C,initAttributes:x,enableAttribute:m,disableUnusedAttributes:v}}function nv(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,u){u!==0&&(i.drawArraysInstanced(n,l,c,u),t.update(c,n,u))}function a(l,c,u){if(u===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,c,0,u);let h=0;for(let f=0;f<u;f++)h+=c[f];t.update(h,n,1)}this.setMode=s,this.render=r,this.renderInstances=o,this.renderMultiDraw=a}function iv(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!==bn&&n.convert(C)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(C){let _=C===qt&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(C!==pn&&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",u=l(c);u!==c&&(Te("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);let d=t.logarithmicDepthBuffer===!0,h=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&h===!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),g=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=i.getParameter(i.MAX_TEXTURE_SIZE),m=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),E=i.getParameter(i.MAX_SAMPLES),w=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:h,maxTextures:f,maxVertexTextures:g,maxTextureSize:x,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:v,maxVaryings:b,maxFragmentUniforms:M,maxSamples:E,samples:w}}function sv(i){let e=this,t=null,n=0,s=!1,r=!1,o=new _n,a=new Le,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){let f=d.length!==0||h||n!==0||s;return s=h,n=d.length,f},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,h){t=u(d,h,0)},this.setState=function(d,h,f){let g=d.clippingPlanes,x=d.clipIntersection,m=d.clipShadows,p=i.get(d);if(!s||g===null||g.length===0||r&&!m)r?u(null):c();else{let v=r?0:n,b=v*4,M=p.clippingState||null;l.value=M,M=u(g,h,b,f);for(let E=0;E!==b;++E)M[E]=t[E];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 u(d,h,f,g){let x=d!==null?d.length:0,m=null;if(x!==0){if(m=l.value,g!==!0||m===null){let p=f+x*4,v=h.matrixWorldInverse;a.getNormalMatrix(v),(m===null||m.length<p)&&(m=new Float32Array(p));for(let b=0,M=f;b!==x;++b,M+=4)o.copy(d[b]).applyMatrix4(v,a),o.normal.toArray(m,M),m[M+3]=o.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=x,e.numIntersection=0,m}}var Fi=4,wd=[.125,.215,.35,.446,.526,.582],Ji=20,rv=256,Dr=new si,Ed=new me,ch=null,hh=0,uh=0,dh=!1,ov=new N,nl=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=ov}=r;ch=this._renderer.getRenderTarget(),hh=this._renderer.getActiveCubeFace(),uh=this._renderer.getActiveMipmapLevel(),dh=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=Cd(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Ad(),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(ch,hh,uh),this._renderer.xr.enabled=dh,e.scissorTest=!1,Ls(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Ii||e.mapping===$i?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),ch=this._renderer.getRenderTarget(),hh=this._renderer.getActiveCubeFace(),uh=this._renderer.getActiveMipmapLevel(),dh=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:Bt,minFilter:Bt,generateMipmaps:!1,type:qt,format:bn,colorSpace:nr,depthBuffer:!1},s=Td(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Td(e,t,n);let{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=av(r)),this._blurMaterial=cv(r,e,t),this._ggxMaterial=lv(r,e,t)}return s}_compileMaterial(e){let t=new Xt(new ht,e);this._renderer.compile(t,Dr)}_sceneToCubeUV(e,t,n,s,r){let l=new Wt(90,1,t,n),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],d=this._renderer,h=d.autoClear,f=d.toneMapping;d.getClearColor(Ed),d.toneMapping=fn,d.autoClear=!1,d.state.buffers.depth.getReversed()&&(d.setRenderTarget(s),d.clearDepth(),d.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Xt(new Ts,new ti({name:"PMREM.Background",side:$t,depthWrite:!1,depthTest:!1})));let x=this._backgroundBox,m=x.material,p=!1,v=e.background;v?v.isColor&&(m.color.copy(v),e.background=null,p=!0):(m.color.copy(Ed),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+u[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+u[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+u[b]));let E=this._cubeSize;Ls(s,M*E,b>2?E:0,E,E),d.setRenderTarget(s),p&&d.render(x,l),d.render(e,l)}d.toneMapping=f,d.autoClear=h,e.background=v}_textureToCubeUV(e,t){let n=this._renderer,s=e.mapping===Ii||e.mapping===$i;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Cd()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Ad());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;Ls(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(o,Dr)}_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),u=t/(this._lodMeshes.length-1),d=Math.sqrt(c*c-u*u),h=0+c*1.25,f=d*h,{_lodMax:g}=this,x=this._sizeLods[n],m=3*x*(n>g-Fi?n-g+Fi:0),p=4*(this._cubeSize-x);l.envMap.value=e.texture,l.roughness.value=f,l.mipInt.value=g-t,Ls(r,m,p,3*x,2*x),s.setRenderTarget(r),s.render(a,Dr),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=g-n,Ls(e,m,p,3*x,2*x),s.setRenderTarget(e),s.render(a,Dr)}_blur(e,t,n,s,r){let o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,s,"latitudinal",r),this._halfBlur(o,e,n,n,s,"longitudinal",r)}_halfBlur(e,t,n,s,r,o,a){let l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&Re("blur direction must be either latitudinal or longitudinal!");let u=3,d=this._lodMeshes[s];d.material=c;let h=c.uniforms,f=this._sizeLods[n]-1,g=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*Ji-1),x=r/g,m=isFinite(r)?1+Math.floor(u*x):Ji;m>Ji&&Te(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Ji}`);let p=[],v=0;for(let C=0;C<Ji;++C){let _=C/x,T=Math.exp(-_*_/2);p.push(T),C===0?v+=T:C<m&&(v+=2*T)}for(let C=0;C<p.length;C++)p[C]=p[C]/v;h.envMap.value=e.texture,h.samples.value=m,h.weights.value=p,h.latitudinal.value=o==="latitudinal",a&&(h.poleAxis.value=a);let{_lodMax:b}=this;h.dTheta.value=g,h.mipInt.value=b-n;let M=this._sizeLods[s],E=3*M*(s>b-Fi?s-b+Fi:0),w=4*(this._cubeSize-M);Ls(t,E,w,3*M,2*M),l.setRenderTarget(t),l.render(d,Dr)}};function av(i){let e=[],t=[],n=[],s=i,r=i-Fi+1+wd.length;for(let o=0;o<r;o++){let a=Math.pow(2,s);e.push(a);let l=1/a;o>i-Fi?l=wd[o-i+Fi-1]:o===0&&(l=0),t.push(l);let c=1/(a-2),u=-c,d=1+c,h=[u,u,d,u,d,d,u,u,d,d,u,d],f=6,g=6,x=3,m=2,p=1,v=new Float32Array(x*g*f),b=new Float32Array(m*g*f),M=new Float32Array(p*g*f);for(let w=0;w<f;w++){let C=w%3*2/3-1,_=w>2?0:-1,T=[C,_,0,C+2/3,_,0,C+2/3,_+1,0,C,_,0,C+2/3,_+1,0,C,_+1,0];v.set(T,x*g*w),b.set(h,m*g*w);let P=[w,w,w,w,w,w];M.set(P,p*g*w)}let E=new ht;E.setAttribute("position",new Ye(v,x)),E.setAttribute("uv",new Ye(b,m)),E.setAttribute("faceIndex",new Ye(M,p)),n.push(new Xt(E,null)),s>Fi&&s--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function Td(i,e,t){let n=new Rt(i,e,t);return n.texture.mapping=Tr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Ls(i,e,t,n,s){i.viewport.set(e,t,n,s),i.scissor.set(e,t,n,s)}function lv(i,e,t){return new ut({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:rv,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:sl(),fragmentShader:`
precision highp float;
precision highp int;
varying vec3 vOutputDirection;
uniform sampler2D envMap;
uniform float roughness;
uniform float mipInt;
#define ENVMAP_TYPE_CUBE_UV
#include <cube_uv_reflection_fragment>
#define PI 3.14159265359
// Van der Corput radical inverse
float radicalInverse_VdC(uint bits) {
bits = (bits << 16u) | (bits >> 16u);
bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
return float(bits) * 2.3283064365386963e-10; // / 0x100000000
}
// Hammersley sequence
vec2 hammersley(uint i, uint N) {
return vec2(float(i) / float(N), radicalInverse_VdC(i));
}
// GGX VNDF importance sampling (Eric Heitz 2018)
// "Sampling the GGX Distribution of Visible Normals"
// https://jcgt.org/published/0007/04/01/
vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
float alpha = roughness * roughness;
// Section 4.1: Orthonormal basis
vec3 T1 = vec3(1.0, 0.0, 0.0);
vec3 T2 = cross(V, T1);
// Section 4.2: Parameterization of projected area
float r = sqrt(Xi.x);
float phi = 2.0 * PI * Xi.y;
float t1 = r * cos(phi);
float t2 = r * sin(phi);
float s = 0.5 * (1.0 + V.z);
t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
// Section 4.3: Reprojection onto hemisphere
vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V;
// Section 3.4: Transform back to ellipsoid configuration
return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
}
void main() {
vec3 N = normalize(vOutputDirection);
vec3 V = N; // Assume view direction equals normal for pre-filtering
vec3 prefilteredColor = vec3(0.0);
float totalWeight = 0.0;
// For very low roughness, just sample the environment directly
if (roughness < 0.001) {
gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
return;
}
// Tangent space basis for VNDF sampling
vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
vec3 tangent = normalize(cross(up, N));
vec3 bitangent = cross(N, tangent);
for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
// For PMREM, V = N, so in tangent space V is always (0, 0, 1)
vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
// Transform H back to world space
vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
vec3 L = normalize(2.0 * dot(V, H) * H - V);
float NdotL = max(dot(N, L), 0.0);
if(NdotL > 0.0) {
// Sample environment at fixed mip level
// VNDF importance sampling handles the distribution filtering
vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
// Weight by NdotL for the split-sum approximation
// VNDF PDF naturally accounts for the visible microfacet distribution
prefilteredColor += sampleColor * NdotL;
totalWeight += NdotL;
}
}
if (totalWeight > 0.0) {
prefilteredColor = prefilteredColor / totalWeight;
}
gl_FragColor = vec4(prefilteredColor, 1.0);
}
`,blending:yn,depthTest:!1,depthWrite:!1})}function cv(i,e,t){let n=new Float32Array(Ji),s=new N(0,1,0);return new ut({name:"SphericalGaussianBlur",defines:{n:Ji,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:sl(),fragmentShader:`
precision mediump float;
precision mediump int;
varying vec3 vOutputDirection;
uniform sampler2D envMap;
uniform int samples;
uniform float weights[ n ];
uniform bool latitudinal;
uniform float dTheta;
uniform float mipInt;
uniform vec3 poleAxis;
#define ENVMAP_TYPE_CUBE_UV
#include <cube_uv_reflection_fragment>
vec3 getSample( float theta, vec3 axis ) {
float cosTheta = cos( theta );
// Rodrigues' axis-angle rotation
vec3 sampleDirection = vOutputDirection * cosTheta
+ cross( axis, vOutputDirection ) * sin( theta )
+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
return bilinearCubeUV( envMap, sampleDirection, mipInt );
}
void main() {
vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
}
axis = normalize( axis );
gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
for ( int i = 1; i < n; i++ ) {
if ( i >= samples ) {
break;
}
float theta = dTheta * float( i );
gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
}
}
`,blending:yn,depthTest:!1,depthWrite:!1})}function Ad(){return new ut({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:sl(),fragmentShader:`
precision mediump float;
precision mediump int;
varying vec3 vOutputDirection;
uniform sampler2D envMap;
#include <common>
void main() {
vec3 outputDirection = normalize( vOutputDirection );
vec2 uv = equirectUv( outputDirection );
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
}
`,blending:yn,depthTest:!1,depthWrite:!1})}function Cd(){return new ut({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:sl(),fragmentShader:`
precision mediump float;
precision mediump int;
uniform float flipEnvMap;
varying vec3 vOutputDirection;
uniform samplerCube envMap;
void main() {
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
}
`,blending:yn,depthTest:!1,depthWrite:!1})}function sl(){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 il=class extends Rt{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 ur(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 Ts(5,5,5),r=new ut({name:"CubemapFromEquirect",uniforms:Ki(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:$t,blending:yn});r.uniforms.tEquirect.value=t;let o=new Xt(s,r),a=t.minFilter;return t.minFilter===Li&&(t.minFilter=Bt),new ca(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 hv(i){let e=new WeakMap,t=new WeakMap,n=null;function s(h,f=!1){return h==null?null:f?o(h):r(h)}function r(h){if(h&&h.isTexture){let f=h.mapping;if(f===fa||f===pa)if(e.has(h)){let g=e.get(h).texture;return a(g,h.mapping)}else{let g=h.image;if(g&&g.height>0){let x=new il(g.height);return x.fromEquirectangularTexture(i,h),e.set(h,x),h.addEventListener("dispose",c),a(x.texture,h.mapping)}else return null}}return h}function o(h){if(h&&h.isTexture){let f=h.mapping,g=f===fa||f===pa,x=f===Ii||f===$i;if(g||x){let m=t.get(h),p=m!==void 0?m.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==p)return n===null&&(n=new nl(i)),m=g?n.fromEquirectangular(h,m):n.fromCubemap(h,m),m.texture.pmremVersion=h.pmremVersion,t.set(h,m),m.texture;if(m!==void 0)return m.texture;{let v=h.image;return g&&v&&v.height>0||x&&v&&l(v)?(n===null&&(n=new nl(i)),m=g?n.fromEquirectangular(h):n.fromCubemap(h),m.texture.pmremVersion=h.pmremVersion,t.set(h,m),h.addEventListener("dispose",u),m.texture):null}}}return h}function a(h,f){return f===fa?h.mapping=Ii:f===pa&&(h.mapping=$i),h}function l(h){let f=0,g=6;for(let x=0;x<g;x++)h[x]!==void 0&&f++;return f===g}function c(h){let f=h.target;f.removeEventListener("dispose",c);let g=e.get(f);g!==void 0&&(e.delete(f),g.dispose())}function u(h){let f=h.target;f.removeEventListener("dispose",u);let g=t.get(f);g!==void 0&&(t.delete(f),g.dispose())}function d(){e=new WeakMap,t=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:s,dispose:d}}function uv(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&&Go("WebGLRenderer: "+n+" extension not supported."),s}}}function dv(i,e,t,n){let s={},r=new WeakMap;function o(d){let h=d.target;h.index!==null&&e.remove(h.index);for(let g in h.attributes)e.remove(h.attributes[g]);h.removeEventListener("dispose",o),delete s[h.id];let f=r.get(h);f&&(e.remove(f),r.delete(h)),n.releaseStatesOfGeometry(h),h.isInstancedBufferGeometry===!0&&delete h._maxInstanceCount,t.memory.geometries--}function a(d,h){return s[h.id]===!0||(h.addEventListener("dispose",o),s[h.id]=!0,t.memory.geometries++),h}function l(d){let h=d.attributes;for(let f in h)e.update(h[f],i.ARRAY_BUFFER)}function c(d){let h=[],f=d.index,g=d.attributes.position,x=0;if(g===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 E=v[b+0],w=v[b+1],C=v[b+2];h.push(E,w,w,C,C,E)}}else{let v=g.array;x=g.version;for(let b=0,M=v.length/3-1;b<M;b+=3){let E=b+0,w=b+1,C=b+2;h.push(E,w,w,C,C,E)}}let m=new(g.count>=65535?cr:lr)(h,1);m.version=x;let p=r.get(d);p&&e.remove(p),r.set(d,m)}function u(d){let h=r.get(d);if(h){let f=d.index;f!==null&&h.version<f.version&&c(d)}else c(d);return r.get(d)}return{get:a,update:l,getWireframeAttribute:u}}function fv(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,h){i.drawElements(n,h,r,d*o),t.update(h,n,1)}function c(d,h,f){f!==0&&(i.drawElementsInstanced(n,h,r,d*o,f),t.update(h,n,f))}function u(d,h,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,h,0,r,d,0,f);let x=0;for(let m=0;m<f;m++)x+=h[m];t.update(x,n,1)}this.setMode=s,this.setIndex=a,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function pv(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:Re("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 mv(i,e,t){let n=new WeakMap,s=new xt;function r(o,a,l){let c=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,d=u!==void 0?u.length:0,h=n.get(a);if(h===void 0||h.count!==d){let T=function(){C.dispose(),n.delete(a),a.removeEventListener("dispose",T)};h!==void 0&&h.texture.dispose();let f=a.morphAttributes.position!==void 0,g=a.morphAttributes.normal!==void 0,x=a.morphAttributes.color!==void 0,m=a.morphAttributes.position||[],p=a.morphAttributes.normal||[],v=a.morphAttributes.color||[],b=0;f===!0&&(b=1),g===!0&&(b=2),x===!0&&(b=3);let M=a.attributes.position.count*b,E=1;M>e.maxTextureSize&&(E=Math.ceil(M/e.maxTextureSize),M=e.maxTextureSize);let w=new Float32Array(M*E*4*d),C=new or(w,M,E,d);C.type=Pn,C.needsUpdate=!0;let _=b*4;for(let P=0;P<d;P++){let R=m[P],I=p[P],H=v[P],W=M*E*4*P;for(let k=0;k<R.count;k++){let z=k*_;f===!0&&(s.fromBufferAttribute(R,k),w[W+z+0]=s.x,w[W+z+1]=s.y,w[W+z+2]=s.z,w[W+z+3]=0),g===!0&&(s.fromBufferAttribute(I,k),w[W+z+4]=s.x,w[W+z+5]=s.y,w[W+z+6]=s.z,w[W+z+7]=0),x===!0&&(s.fromBufferAttribute(H,k),w[W+z+8]=s.x,w[W+z+9]=s.y,w[W+z+10]=s.z,w[W+z+11]=H.itemSize===4?s.w:1)}}h={count:d,texture:C,size:new Ee(M,E)},n.set(a,h),a.addEventListener("dispose",T)}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 g=a.morphTargetsRelative?1:1-f;l.getUniforms().setValue(i,"morphTargetBaseInfluence",g),l.getUniforms().setValue(i,"morphTargetInfluences",c)}l.getUniforms().setValue(i,"morphTargetsTexture",h.texture,t),l.getUniforms().setValue(i,"morphTargetsTextureSize",h.size)}return{update:r}}function gv(i,e,t,n,s){let r=new WeakMap;function o(c){let u=s.render.frame,d=c.geometry,h=e.get(c,d);if(r.get(h)!==u&&(e.update(h),r.set(h,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),r.get(c)!==u&&(t.update(c.instanceMatrix,i.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,i.ARRAY_BUFFER),r.set(c,u))),c.isSkinnedMesh){let f=c.skeleton;r.get(f)!==u&&(f.update(),r.set(f,u))}return h}function a(){r=new WeakMap}function l(c){let u=c.target;u.removeEventListener("dispose",l),n.releaseStatesOfObject(u),t.remove(u.instanceMatrix),u.instanceColor!==null&&t.remove(u.instanceColor)}return{update:o,dispose:a}}var xv={[yr]:"LINEAR_TONE_MAPPING",[br]:"REINHARD_TONE_MAPPING",[Mr]:"CINEON_TONE_MAPPING",[Pi]:"ACES_FILMIC_TONE_MAPPING",[wr]:"AGX_TONE_MAPPING",[Er]:"NEUTRAL_TONE_MAPPING",[Sr]:"CUSTOM_TONE_MAPPING"};function vv(i,e,t,n,s){let r=new Rt(e,t,{type:i,depthBuffer:n,stencilBuffer:s,depthTexture:n?new ii(e,t):void 0}),o=new Rt(e,t,{type:qt,depthBuffer:!1,stencilBuffer:!1}),a=new ht;a.setAttribute("position",new Ut([-1,3,0,-1,-1,0,3,-1,0],3)),a.setAttribute("uv",new Ut([0,2,0,0,2,0],2));let l=new As({uniforms:{tDiffuse:{value:null}},vertexShader:`
precision highp float;
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
attribute vec3 position;
attribute vec2 uv;
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,fragmentShader:`
precision highp float;
uniform sampler2D tDiffuse;
varying vec2 vUv;
#include <tonemapping_pars_fragment>
#include <colorspace_pars_fragment>
void main() {
gl_FragColor = texture2D( tDiffuse, vUv );
#ifdef LINEAR_TONE_MAPPING
gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
#elif defined( REINHARD_TONE_MAPPING )
gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
#elif defined( CINEON_TONE_MAPPING )
gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
#elif defined( ACES_FILMIC_TONE_MAPPING )
gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
#elif defined( AGX_TONE_MAPPING )
gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
#elif defined( NEUTRAL_TONE_MAPPING )
gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
#elif defined( CUSTOM_TONE_MAPPING )
gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
#endif
#ifdef SRGB_TRANSFER
gl_FragColor = sRGBTransferOETF( gl_FragColor );
#endif
}`,depthTest:!1,depthWrite:!1}),c=new Xt(a,l),u=new si(-1,1,1,-1,0,1),d=null,h=null,f=!1,g,x=null,m=[],p=!1;this.setSize=function(v,b){r.setSize(v,b),o.setSize(v,b);for(let M=0;M<m.length;M++){let E=m[M];E.setSize&&E.setSize(v,b)}},this.setEffects=function(v){m=v,p=m.length>0&&m[0].isRenderPass===!0;let b=r.width,M=r.height;for(let E=0;E<m.length;E++){let w=m[E];w.setSize&&w.setSize(b,M)}},this.begin=function(v,b){if(f||v.toneMapping===fn&&m.length===0)return!1;if(x=b,b!==null){let M=b.width,E=b.height;(r.width!==M||r.height!==E)&&this.setSize(M,E)}return p===!1&&v.setRenderTarget(r),g=v.toneMapping,v.toneMapping=fn,!0},this.hasRenderPass=function(){return p},this.end=function(v,b){v.toneMapping=g,f=!0;let M=r,E=o;for(let w=0;w<m.length;w++){let C=m[w];if(C.enabled!==!1&&(C.render(v,E,M,b),C.needsSwap!==!1)){let _=M;M=E,E=_}}if(d!==v.outputColorSpace||h!==v.toneMapping){d=v.outputColorSpace,h=v.toneMapping,l.defines={},ze.getTransfer(d)===Je&&(l.defines.SRGB_TRANSFER="");let w=xv[h];w&&(l.defines[w]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=M.texture,v.setRenderTarget(x),v.render(c,u),x=null,f=!1},this.isCompositing=function(){return f},this.dispose=function(){r.depthTexture&&r.depthTexture.dispose(),r.dispose(),o.dispose(),a.dispose(),l.dispose()}}var Zd=new jt,mh=new ii(1,1),$d=new or,Kd=new Xo,Jd=new ur,Rd=[],Pd=[],Id=new Float32Array(16),Ld=new Float32Array(9),Nd=new Float32Array(4);function Fs(i,e,t){let n=i[0];if(n<=0||n>0)return i;let s=e*t,r=Rd[s];if(r===void 0&&(r=new Float32Array(s),Rd[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 Pt(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 It(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function rl(i,e){let t=Pd[e];t===void 0&&(t=new Int32Array(e),Pd[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function _v(i,e){let t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function yv(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(Pt(t,e))return;i.uniform2fv(this.addr,e),It(t,e)}}function bv(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(Pt(t,e))return;i.uniform3fv(this.addr,e),It(t,e)}}function Mv(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(Pt(t,e))return;i.uniform4fv(this.addr,e),It(t,e)}}function Sv(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(Pt(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),It(t,e)}else{if(Pt(t,n))return;Nd.set(n),i.uniformMatrix2fv(this.addr,!1,Nd),It(t,n)}}function wv(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(Pt(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),It(t,e)}else{if(Pt(t,n))return;Ld.set(n),i.uniformMatrix3fv(this.addr,!1,Ld),It(t,n)}}function Ev(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(Pt(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),It(t,e)}else{if(Pt(t,n))return;Id.set(n),i.uniformMatrix4fv(this.addr,!1,Id),It(t,n)}}function Tv(i,e){let t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function Av(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(Pt(t,e))return;i.uniform2iv(this.addr,e),It(t,e)}}function Cv(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(Pt(t,e))return;i.uniform3iv(this.addr,e),It(t,e)}}function Rv(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(Pt(t,e))return;i.uniform4iv(this.addr,e),It(t,e)}}function Pv(i,e){let t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function Iv(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(Pt(t,e))return;i.uniform2uiv(this.addr,e),It(t,e)}}function Lv(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(Pt(t,e))return;i.uniform3uiv(this.addr,e),It(t,e)}}function Nv(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(Pt(t,e))return;i.uniform4uiv(this.addr,e),It(t,e)}}function Dv(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?(mh.compareFunction=t.isReversedDepthBuffer()?Qa:ja,r=mh):r=Zd,t.setTexture2D(e||r,s)}function Fv(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture3D(e||Kd,s)}function kv(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTextureCube(e||Jd,s)}function Ov(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture2DArray(e||$d,s)}function Uv(i){switch(i){case 5126:return _v;case 35664:return yv;case 35665:return bv;case 35666:return Mv;case 35674:return Sv;case 35675:return wv;case 35676:return Ev;case 5124:case 35670:return Tv;case 35667:case 35671:return Av;case 35668:case 35672:return Cv;case 35669:case 35673:return Rv;case 5125:return Pv;case 36294:return Iv;case 36295:return Lv;case 36296:return Nv;case 35678:case 36198:case 36298:case 36306:case 35682:return Dv;case 35679:case 36299:case 36307:return Fv;case 35680:case 36300:case 36308:case 36293:return kv;case 36289:case 36303:case 36311:case 36292:return Ov}}function Bv(i,e){i.uniform1fv(this.addr,e)}function zv(i,e){let t=Fs(e,this.size,2);i.uniform2fv(this.addr,t)}function Vv(i,e){let t=Fs(e,this.size,3);i.uniform3fv(this.addr,t)}function Gv(i,e){let t=Fs(e,this.size,4);i.uniform4fv(this.addr,t)}function Hv(i,e){let t=Fs(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function Wv(i,e){let t=Fs(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function Xv(i,e){let t=Fs(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function qv(i,e){i.uniform1iv(this.addr,e)}function Yv(i,e){i.uniform2iv(this.addr,e)}function Zv(i,e){i.uniform3iv(this.addr,e)}function $v(i,e){i.uniform4iv(this.addr,e)}function Kv(i,e){i.uniform1uiv(this.addr,e)}function Jv(i,e){i.uniform2uiv(this.addr,e)}function jv(i,e){i.uniform3uiv(this.addr,e)}function Qv(i,e){i.uniform4uiv(this.addr,e)}function e_(i,e,t){let n=this.cache,s=e.length,r=rl(t,s);Pt(n,r)||(i.uniform1iv(this.addr,r),It(n,r));let o;this.type===i.SAMPLER_2D_SHADOW?o=mh:o=Zd;for(let a=0;a!==s;++a)t.setTexture2D(e[a]||o,r[a])}function t_(i,e,t){let n=this.cache,s=e.length,r=rl(t,s);Pt(n,r)||(i.uniform1iv(this.addr,r),It(n,r));for(let o=0;o!==s;++o)t.setTexture3D(e[o]||Kd,r[o])}function n_(i,e,t){let n=this.cache,s=e.length,r=rl(t,s);Pt(n,r)||(i.uniform1iv(this.addr,r),It(n,r));for(let o=0;o!==s;++o)t.setTextureCube(e[o]||Jd,r[o])}function i_(i,e,t){let n=this.cache,s=e.length,r=rl(t,s);Pt(n,r)||(i.uniform1iv(this.addr,r),It(n,r));for(let o=0;o!==s;++o)t.setTexture2DArray(e[o]||$d,r[o])}function s_(i){switch(i){case 5126:return Bv;case 35664:return zv;case 35665:return Vv;case 35666:return Gv;case 35674:return Hv;case 35675:return Wv;case 35676:return Xv;case 5124:case 35670:return qv;case 35667:case 35671:return Yv;case 35668:case 35672:return Zv;case 35669:case 35673:return $v;case 5125:return Kv;case 36294:return Jv;case 36295:return jv;case 36296:return Qv;case 35678:case 36198:case 36298:case 36306:case 35682:return e_;case 35679:case 36299:case 36307:return t_;case 35680:case 36300:case 36308:case 36293:return n_;case 36289:case 36303:case 36311:case 36292:return i_}}var gh=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=Uv(t.type)}},xh=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=s_(t.type)}},vh=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)}}},fh=/(\w+)(\])?(\[|\.)?/g;function Dd(i,e){i.seq.push(e),i.map[e.id]=e}function r_(i,e,t){let n=i.name,s=n.length;for(fh.lastIndex=0;;){let r=fh.exec(n),o=fh.lastIndex,a=r[1],l=r[2]==="]",c=r[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===s){Dd(t,c===void 0?new gh(a,i,e):new xh(a,i,e));break}else{let d=t.map[a];d===void 0&&(d=new vh(a),Dd(t,d)),t=d}}}var Ns=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);r_(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 Fd(i,e,t){let n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}var o_=37297,a_=0;function l_(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 kd=new Le;function c_(i){ze._getMatrix(kd,ze.workingColorSpace,i);let e=`mat3( ${kd.elements.map(t=>t.toFixed(4))} )`;switch(ze.getTransfer(i)){case ir:return[e,"LinearTransferOETF"];case Je:return[e,"sRGBTransferOETF"];default:return Te("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function Od(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+`
`+l_(i.getShaderSource(e),a)}else return r}function h_(i,e){let t=c_(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
`)}var u_={[yr]:"Linear",[br]:"Reinhard",[Mr]:"Cineon",[Pi]:"ACESFilmic",[wr]:"AgX",[Er]:"Neutral",[Sr]:"Custom"};function d_(i,e){let t=u_[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 tl=new N;function f_(){ze.getLuminanceCoefficients(tl);let i=tl.x.toFixed(4),e=tl.y.toFixed(4),t=tl.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
`)}function p_(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(kr).join(`
`)}function m_(i){let e=[];for(let t in i){let n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
`)}function g_(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 kr(i){return i!==""}function Ud(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 Bd(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var x_=/^[ \t]*#include +<([\w\d./]+)>/gm;function _h(i){return i.replace(x_,__)}var v_=new Map;function __(i,e){let t=Ue[e];if(t===void 0){let n=v_.get(e);if(n!==void 0)t=Ue[n],Te('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return _h(t)}var y_=/#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 zd(i){return i.replace(y_,b_)}function b_(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 Vd(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 M_={[vr]:"SHADOWMAP_TYPE_PCF",[Cs]:"SHADOWMAP_TYPE_VSM"};function S_(i){return M_[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var w_={[Ii]:"ENVMAP_TYPE_CUBE",[$i]:"ENVMAP_TYPE_CUBE",[Tr]:"ENVMAP_TYPE_CUBE_UV"};function E_(i){return i.envMap===!1?"ENVMAP_TYPE_CUBE":w_[i.envMapMode]||"ENVMAP_TYPE_CUBE"}var T_={[$i]:"ENVMAP_MODE_REFRACTION"};function A_(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":T_[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}var C_={[zc]:"ENVMAP_BLENDING_MULTIPLY",[ad]:"ENVMAP_BLENDING_MIX",[ld]:"ENVMAP_BLENDING_ADD"};function R_(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":C_[i.combine]||"ENVMAP_BLENDING_NONE"}function P_(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 I_(i,e,t,n){let s=i.getContext(),r=t.defines,o=t.vertexShader,a=t.fragmentShader,l=S_(t),c=E_(t),u=A_(t),d=R_(t),h=P_(t),f=p_(t),g=m_(r),x=s.createProgram(),m,p,v=t.glslVersion?"#version "+t.glslVersion+`
`:"";t.isRawShaderMaterial?(m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(kr).join(`
`),m.length>0&&(m+=`
`),p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(kr).join(`
`),p.length>0&&(p+=`
`)):(m=[Vd(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",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(kr).join(`
`),p=[Vd(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+d:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",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!==fn?"#define TONE_MAPPING":"",t.toneMapping!==fn?Ue.tonemapping_pars_fragment:"",t.toneMapping!==fn?d_("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ue.colorspace_pars_fragment,h_("linearToOutputTexel",t.outputColorSpace),f_(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
`].filter(kr).join(`
`)),o=_h(o),o=Ud(o,t),o=Bd(o,t),a=_h(a),a=Ud(a,t),a=Bd(a,t),o=zd(o),a=zd(a),t.isRawShaderMaterial!==!0&&(v=`#version 300 es
`,m=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
`+m,p=["#define varying in",t.glslVersion===Kc?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Kc?"":"#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+m+o,M=v+p+a,E=Fd(s,s.VERTEX_SHADER,b),w=Fd(s,s.FRAGMENT_SHADER,M);s.attachShader(x,E),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(E)||"",W=s.getShaderInfoLog(w)||"",k=I.trim(),z=H.trim(),V=W.trim(),K=!0,Q=!0;if(s.getProgramParameter(x,s.LINK_STATUS)===!1)if(K=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,x,E,w);else{let ae=Od(s,E,"vertex"),_e=Od(s,w,"fragment");Re("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(x,s.VALIDATE_STATUS)+`
Material Name: `+R.name+`
Material Type: `+R.type+`
Program Info Log: `+k+`
`+ae+`
`+_e)}else k!==""?Te("WebGLProgram: Program Info Log:",k):(z===""||V==="")&&(Q=!1);Q&&(R.diagnostics={runnable:K,programLog:k,vertexShader:{log:z,prefix:m},fragmentShader:{log:V,prefix:p}})}s.deleteShader(E),s.deleteShader(w),_=new Ns(s,x),T=g_(s,x)}let _;this.getUniforms=function(){return _===void 0&&C(this),_};let T;this.getAttributes=function(){return T===void 0&&C(this),T};let P=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return P===!1&&(P=s.getProgramParameter(x,o_)),P},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(x),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=a_++,this.cacheKey=e,this.usedTimes=1,this.program=x,this.vertexShader=E,this.fragmentShader=w,this}var L_=0,yh=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 bh(e),t.set(e,n)),n}},bh=class{constructor(e){this.id=L_++,this.code=e,this.usedTimes=0}};function N_(i){return i===Di||i===Lr||i===Nr}function D_(i,e,t,n,s,r){let o=new ar,a=new yh,l=new Set,c=[],u=new Map,d=n.logarithmicDepthBuffer,h=n.precision,f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function g(_){return l.add(_),_===0?"uv":`uv${_}`}function x(_,T,P,R,I,H){let W=R.fog,k=I.geometry,z=_.isMeshStandardMaterial||_.isMeshLambertMaterial||_.isMeshPhongMaterial?R.environment:null,V=_.isMeshStandardMaterial||_.isMeshLambertMaterial&&!_.envMap||_.isMeshPhongMaterial&&!_.envMap,K=e.get(_.envMap||z,V),Q=K&&K.mapping===Tr?K.image.height:null,ae=f[_.type];_.precision!==null&&(h=n.getMaxPrecision(_.precision),h!==_.precision&&Te("WebGLProgram.getParameters:",_.precision,"not supported, using",h,"instead."));let _e=k.morphAttributes.position||k.morphAttributes.normal||k.morphAttributes.color,be=_e!==void 0?_e.length:0,We=0;k.morphAttributes.position!==void 0&&(We=1),k.morphAttributes.normal!==void 0&&(We=2),k.morphAttributes.color!==void 0&&(We=3);let Qe,ke,$,de;if(ae){let De=Gn[ae];Qe=De.vertexShader,ke=De.fragmentShader}else Qe=_.vertexShader,ke=_.fragmentShader,a.update(_),$=a.getVertexShaderID(_),de=a.getFragmentShaderID(_);let ie=i.getRenderTarget(),Ae=i.state.buffers.depth.getReversed(),Ne=I.isInstancedMesh===!0,Pe=I.isBatchedMesh===!0,dt=!!_.map,Xe=!!_.matcap,et=!!K,lt=!!_.aoMap,He=!!_.lightMap,Tt=!!_.bumpMap,ft=!!_.normalMap,sn=!!_.displacementMap,D=!!_.emissiveMap,At=!!_.metalnessMap,qe=!!_.roughnessMap,ot=_.anisotropy>0,le=_.clearcoat>0,pt=_.dispersion>0,A=_.iridescence>0,y=_.sheen>0,O=_.transmission>0,Y=ot&&!!_.anisotropyMap,j=le&&!!_.clearcoatMap,ee=le&&!!_.clearcoatNormalMap,oe=le&&!!_.clearcoatRoughnessMap,X=A&&!!_.iridescenceMap,Z=A&&!!_.iridescenceThicknessMap,fe=y&&!!_.sheenColorMap,xe=y&&!!_.sheenRoughnessMap,se=!!_.specularMap,te=!!_.specularColorMap,Ie=!!_.specularIntensityMap,Oe=O&&!!_.transmissionMap,Ke=O&&!!_.thicknessMap,L=!!_.gradientMap,ne=!!_.alphaMap,q=_.alphaTest>0,pe=!!_.alphaHash,re=!!_.extensions,J=fn;_.toneMapped&&(ie===null||ie.isXRRenderTarget===!0)&&(J=i.toneMapping);let Me={shaderID:ae,shaderType:_.type,shaderName:_.name,vertexShader:Qe,fragmentShader:ke,defines:_.defines,customVertexShaderID:$,customFragmentShaderID:de,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:h,batching:Pe,batchingColor:Pe&&I._colorsTexture!==null,instancing:Ne,instancingColor:Ne&&I.instanceColor!==null,instancingMorph:Ne&&I.morphTexture!==null,outputColorSpace:ie===null?i.outputColorSpace:ie.isXRRenderTarget===!0?ie.texture.colorSpace:ze.workingColorSpace,alphaToCoverage:!!_.alphaToCoverage,map:dt,matcap:Xe,envMap:et,envMapMode:et&&K.mapping,envMapCubeUVHeight:Q,aoMap:lt,lightMap:He,bumpMap:Tt,normalMap:ft,displacementMap:sn,emissiveMap:D,normalMapObjectSpace:ft&&_.normalMapType===ud,normalMapTangentSpace:ft&&_.normalMapType===$c,packedNormalMap:ft&&_.normalMapType===$c&&N_(_.normalMap.format),metalnessMap:At,roughnessMap:qe,anisotropy:ot,anisotropyMap:Y,clearcoat:le,clearcoatMap:j,clearcoatNormalMap:ee,clearcoatRoughnessMap:oe,dispersion:pt,iridescence:A,iridescenceMap:X,iridescenceThicknessMap:Z,sheen:y,sheenColorMap:fe,sheenRoughnessMap:xe,specularMap:se,specularColorMap:te,specularIntensityMap:Ie,transmission:O,transmissionMap:Oe,thicknessMap:Ke,gradientMap:L,opaque:_.transparent===!1&&_.blending===qi&&_.alphaToCoverage===!1,alphaMap:ne,alphaTest:q,alphaHash:pe,combine:_.combine,mapUv:dt&&g(_.map.channel),aoMapUv:lt&&g(_.aoMap.channel),lightMapUv:He&&g(_.lightMap.channel),bumpMapUv:Tt&&g(_.bumpMap.channel),normalMapUv:ft&&g(_.normalMap.channel),displacementMapUv:sn&&g(_.displacementMap.channel),emissiveMapUv:D&&g(_.emissiveMap.channel),metalnessMapUv:At&&g(_.metalnessMap.channel),roughnessMapUv:qe&&g(_.roughnessMap.channel),anisotropyMapUv:Y&&g(_.anisotropyMap.channel),clearcoatMapUv:j&&g(_.clearcoatMap.channel),clearcoatNormalMapUv:ee&&g(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:oe&&g(_.clearcoatRoughnessMap.channel),iridescenceMapUv:X&&g(_.iridescenceMap.channel),iridescenceThicknessMapUv:Z&&g(_.iridescenceThicknessMap.channel),sheenColorMapUv:fe&&g(_.sheenColorMap.channel),sheenRoughnessMapUv:xe&&g(_.sheenRoughnessMap.channel),specularMapUv:se&&g(_.specularMap.channel),specularColorMapUv:te&&g(_.specularColorMap.channel),specularIntensityMapUv:Ie&&g(_.specularIntensityMap.channel),transmissionMapUv:Oe&&g(_.transmissionMap.channel),thicknessMapUv:Ke&&g(_.thicknessMap.channel),alphaMapUv:ne&&g(_.alphaMap.channel),vertexTangents:!!k.attributes.tangent&&(ft||ot),vertexNormals:!!k.attributes.normal,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!k.attributes.color&&k.attributes.color.itemSize===4,pointsUvs:I.isPoints===!0&&!!k.attributes.uv&&(dt||ne),fog:!!W,useFog:_.fog===!0,fogExp2:!!W&&W.isFogExp2,flatShading:_.wireframe===!1&&(_.flatShading===!0||k.attributes.normal===void 0&&ft===!1&&(_.isMeshLambertMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isMeshPhysicalMaterial)),sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:Ae,skinning:I.isSkinnedMesh===!0,morphTargets:k.morphAttributes.position!==void 0,morphNormals:k.morphAttributes.normal!==void 0,morphColors:k.morphAttributes.color!==void 0,morphTargetsCount:be,morphTextureStride:We,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numSpotLightShadowsWithMaps:T.numSpotLightShadowsWithMaps,numLightProbes:T.numLightProbes,numLightProbeGrids:H.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:_.dithering,shadowMapEnabled:i.shadowMap.enabled&&P.length>0,shadowMapType:i.shadowMap.type,toneMapping:J,decodeVideoTexture:dt&&_.map.isVideoTexture===!0&&ze.getTransfer(_.map.colorSpace)===Je,decodeVideoTextureEmissive:D&&_.emissiveMap.isVideoTexture===!0&&ze.getTransfer(_.emissiveMap.colorSpace)===Je,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===zn,flipSided:_.side===$t,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:re&&_.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(re&&_.extensions.multiDraw===!0||Pe)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return Me.vertexUv1s=l.has(1),Me.vertexUv2s=l.has(2),Me.vertexUv3s=l.has(3),l.clear(),Me}function m(_){let T=[];if(_.shaderID?T.push(_.shaderID):(T.push(_.customVertexShaderID),T.push(_.customFragmentShaderID)),_.defines!==void 0)for(let P in _.defines)T.push(P),T.push(_.defines[P]);return _.isRawShaderMaterial===!1&&(p(T,_),v(T,_),T.push(i.outputColorSpace)),T.push(_.customProgramCacheKey),T.join()}function p(_,T){_.push(T.precision),_.push(T.outputColorSpace),_.push(T.envMapMode),_.push(T.envMapCubeUVHeight),_.push(T.mapUv),_.push(T.alphaMapUv),_.push(T.lightMapUv),_.push(T.aoMapUv),_.push(T.bumpMapUv),_.push(T.normalMapUv),_.push(T.displacementMapUv),_.push(T.emissiveMapUv),_.push(T.metalnessMapUv),_.push(T.roughnessMapUv),_.push(T.anisotropyMapUv),_.push(T.clearcoatMapUv),_.push(T.clearcoatNormalMapUv),_.push(T.clearcoatRoughnessMapUv),_.push(T.iridescenceMapUv),_.push(T.iridescenceThicknessMapUv),_.push(T.sheenColorMapUv),_.push(T.sheenRoughnessMapUv),_.push(T.specularMapUv),_.push(T.specularColorMapUv),_.push(T.specularIntensityMapUv),_.push(T.transmissionMapUv),_.push(T.thicknessMapUv),_.push(T.combine),_.push(T.fogExp2),_.push(T.sizeAttenuation),_.push(T.morphTargetsCount),_.push(T.morphAttributeCount),_.push(T.numDirLights),_.push(T.numPointLights),_.push(T.numSpotLights),_.push(T.numSpotLightMaps),_.push(T.numHemiLights),_.push(T.numRectAreaLights),_.push(T.numDirLightShadows),_.push(T.numPointLightShadows),_.push(T.numSpotLightShadows),_.push(T.numSpotLightShadowsWithMaps),_.push(T.numLightProbes),_.push(T.shadowMapType),_.push(T.toneMapping),_.push(T.numClippingPlanes),_.push(T.numClipIntersection),_.push(T.depthPacking)}function v(_,T){o.disableAll(),T.instancing&&o.enable(0),T.instancingColor&&o.enable(1),T.instancingMorph&&o.enable(2),T.matcap&&o.enable(3),T.envMap&&o.enable(4),T.normalMapObjectSpace&&o.enable(5),T.normalMapTangentSpace&&o.enable(6),T.clearcoat&&o.enable(7),T.iridescence&&o.enable(8),T.alphaTest&&o.enable(9),T.vertexColors&&o.enable(10),T.vertexAlphas&&o.enable(11),T.vertexUv1s&&o.enable(12),T.vertexUv2s&&o.enable(13),T.vertexUv3s&&o.enable(14),T.vertexTangents&&o.enable(15),T.anisotropy&&o.enable(16),T.alphaHash&&o.enable(17),T.batching&&o.enable(18),T.dispersion&&o.enable(19),T.batchingColor&&o.enable(20),T.gradientMap&&o.enable(21),T.packedNormalMap&&o.enable(22),T.vertexNormals&&o.enable(23),_.push(o.mask),o.disableAll(),T.fog&&o.enable(0),T.useFog&&o.enable(1),T.flatShading&&o.enable(2),T.logarithmicDepthBuffer&&o.enable(3),T.reversedDepthBuffer&&o.enable(4),T.skinning&&o.enable(5),T.morphTargets&&o.enable(6),T.morphNormals&&o.enable(7),T.morphColors&&o.enable(8),T.premultipliedAlpha&&o.enable(9),T.shadowMapEnabled&&o.enable(10),T.doubleSided&&o.enable(11),T.flipSided&&o.enable(12),T.useDepthPacking&&o.enable(13),T.dithering&&o.enable(14),T.transmission&&o.enable(15),T.sheen&&o.enable(16),T.opaque&&o.enable(17),T.pointsUvs&&o.enable(18),T.decodeVideoTexture&&o.enable(19),T.decodeVideoTextureEmissive&&o.enable(20),T.alphaToCoverage&&o.enable(21),T.numLightProbeGrids>0&&o.enable(22),_.push(o.mask)}function b(_){let T=f[_.type],P;if(T){let R=Gn[T];P=oi.clone(R.uniforms)}else P=_.uniforms;return P}function M(_,T){let P=u.get(T);return P!==void 0?++P.usedTimes:(P=new I_(i,T,_,s),c.push(P),u.set(T,P)),P}function E(_){if(--_.usedTimes===0){let T=c.indexOf(_);c[T]=c[c.length-1],c.pop(),u.delete(_.cacheKey),_.destroy()}}function w(_){a.remove(_)}function C(){a.dispose()}return{getParameters:x,getProgramCacheKey:m,getUniforms:b,acquireProgram:M,releaseProgram:E,releaseShaderCache:w,programs:c,dispose:C}}function F_(){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 k_(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 Gd(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 Hd(){let i=[],e=0,t=[],n=[],s=[];function r(){e=0,t.length=0,n.length=0,s.length=0}function o(h){let f=0;return h.isInstancedMesh&&(f+=2),h.isSkinnedMesh&&(f+=1),f}function a(h,f,g,x,m,p){let v=i[e];return v===void 0?(v={id:h.id,object:h,geometry:f,material:g,materialVariant:o(h),groupOrder:x,renderOrder:h.renderOrder,z:m,group:p},i[e]=v):(v.id=h.id,v.object=h,v.geometry=f,v.material=g,v.materialVariant=o(h),v.groupOrder=x,v.renderOrder=h.renderOrder,v.z=m,v.group=p),e++,v}function l(h,f,g,x,m,p){let v=a(h,f,g,x,m,p);g.transmission>0?n.push(v):g.transparent===!0?s.push(v):t.push(v)}function c(h,f,g,x,m,p){let v=a(h,f,g,x,m,p);g.transmission>0?n.unshift(v):g.transparent===!0?s.unshift(v):t.unshift(v)}function u(h,f){t.length>1&&t.sort(h||k_),n.length>1&&n.sort(f||Gd),s.length>1&&s.sort(f||Gd)}function d(){for(let h=e,f=i.length;h<f;h++){let g=i[h];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:t,transmissive:n,transparent:s,init:r,push:l,unshift:c,finish:d,sort:u}}function O_(){let i=new WeakMap;function e(n,s){let r=i.get(n),o;return r===void 0?(o=new Hd,i.set(n,[o])):s>=r.length?(o=new Hd,r.push(o)):o=r[s],o}function t(){i=new WeakMap}return{get:e,dispose:t}}function U_(){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 me};break;case"SpotLight":t={position:new N,direction:new N,color:new me,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new N,color:new me,distance:0,decay:0};break;case"HemisphereLight":t={direction:new N,skyColor:new me,groundColor:new me};break;case"RectAreaLight":t={color:new me,position:new N,halfWidth:new N,halfHeight:new N};break}return i[e.id]=t,t}}}function B_(){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 Ee};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}var z_=0;function V_(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function G_(i){let e=new U_,t=B_(),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 gt,o=new gt;function a(c){let u=0,d=0,h=0;for(let T=0;T<9;T++)n.probe[T].set(0,0,0);let f=0,g=0,x=0,m=0,p=0,v=0,b=0,M=0,E=0,w=0,C=0;c.sort(V_);for(let T=0,P=c.length;T<P;T++){let R=c[T],I=R.color,H=R.intensity,W=R.distance,k=null;if(R.shadow&&R.shadow.map&&(R.shadow.map.texture.format===Di?k=R.shadow.map.texture:k=R.shadow.map.depthTexture||R.shadow.map.texture),R.isAmbientLight)u+=I.r*H,d+=I.g*H,h+=I.b*H;else if(R.isLightProbe){for(let z=0;z<9;z++)n.probe[z].addScaledVector(R.sh.coefficients[z],H);C++}else if(R.isDirectionalLight){let z=e.get(R);if(z.color.copy(R.color).multiplyScalar(R.intensity),R.castShadow){let V=R.shadow,K=t.get(R);K.shadowIntensity=V.intensity,K.shadowBias=V.bias,K.shadowNormalBias=V.normalBias,K.shadowRadius=V.radius,K.shadowMapSize=V.mapSize,n.directionalShadow[f]=K,n.directionalShadowMap[f]=k,n.directionalShadowMatrix[f]=R.shadow.matrix,v++}n.directional[f]=z,f++}else if(R.isSpotLight){let z=e.get(R);z.position.setFromMatrixPosition(R.matrixWorld),z.color.copy(I).multiplyScalar(H),z.distance=W,z.coneCos=Math.cos(R.angle),z.penumbraCos=Math.cos(R.angle*(1-R.penumbra)),z.decay=R.decay,n.spot[x]=z;let V=R.shadow;if(R.map&&(n.spotLightMap[E]=R.map,E++,V.updateMatrices(R),R.castShadow&&w++),n.spotLightMatrix[x]=V.matrix,R.castShadow){let K=t.get(R);K.shadowIntensity=V.intensity,K.shadowBias=V.bias,K.shadowNormalBias=V.normalBias,K.shadowRadius=V.radius,K.shadowMapSize=V.mapSize,n.spotShadow[x]=K,n.spotShadowMap[x]=k,M++}x++}else if(R.isRectAreaLight){let z=e.get(R);z.color.copy(I).multiplyScalar(H),z.halfWidth.set(R.width*.5,0,0),z.halfHeight.set(0,R.height*.5,0),n.rectArea[m]=z,m++}else if(R.isPointLight){let z=e.get(R);if(z.color.copy(R.color).multiplyScalar(R.intensity),z.distance=R.distance,z.decay=R.decay,R.castShadow){let V=R.shadow,K=t.get(R);K.shadowIntensity=V.intensity,K.shadowBias=V.bias,K.shadowNormalBias=V.normalBias,K.shadowRadius=V.radius,K.shadowMapSize=V.mapSize,K.shadowCameraNear=V.camera.near,K.shadowCameraFar=V.camera.far,n.pointShadow[g]=K,n.pointShadowMap[g]=k,n.pointShadowMatrix[g]=R.shadow.matrix,b++}n.point[g]=z,g++}else if(R.isHemisphereLight){let z=e.get(R);z.skyColor.copy(R.color).multiplyScalar(H),z.groundColor.copy(R.groundColor).multiplyScalar(H),n.hemi[p]=z,p++}}m>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=ce.LTC_FLOAT_1,n.rectAreaLTC2=ce.LTC_FLOAT_2):(n.rectAreaLTC1=ce.LTC_HALF_1,n.rectAreaLTC2=ce.LTC_HALF_2)),n.ambient[0]=u,n.ambient[1]=d,n.ambient[2]=h;let _=n.hash;(_.directionalLength!==f||_.pointLength!==g||_.spotLength!==x||_.rectAreaLength!==m||_.hemiLength!==p||_.numDirectionalShadows!==v||_.numPointShadows!==b||_.numSpotShadows!==M||_.numSpotMaps!==E||_.numLightProbes!==C)&&(n.directional.length=f,n.spot.length=x,n.rectArea.length=m,n.point.length=g,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+E-w,n.spotLightMap.length=E,n.numSpotLightShadowsWithMaps=w,n.numLightProbes=C,_.directionalLength=f,_.pointLength=g,_.spotLength=x,_.rectAreaLength=m,_.hemiLength=p,_.numDirectionalShadows=v,_.numPointShadows=b,_.numSpotShadows=M,_.numSpotMaps=E,_.numLightProbes=C,n.version=z_++)}function l(c,u){let d=0,h=0,f=0,g=0,x=0,m=u.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(m),d++}else if(b.isSpotLight){let M=n.spot[f];M.position.setFromMatrixPosition(b.matrixWorld),M.position.applyMatrix4(m),M.direction.setFromMatrixPosition(b.matrixWorld),s.setFromMatrixPosition(b.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(m),f++}else if(b.isRectAreaLight){let M=n.rectArea[g];M.position.setFromMatrixPosition(b.matrixWorld),M.position.applyMatrix4(m),o.identity(),r.copy(b.matrixWorld),r.premultiply(m),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),g++}else if(b.isPointLight){let M=n.point[h];M.position.setFromMatrixPosition(b.matrixWorld),M.position.applyMatrix4(m),h++}else if(b.isHemisphereLight){let M=n.hemi[x];M.direction.setFromMatrixPosition(b.matrixWorld),M.direction.transformDirection(m),x++}}}return{setup:a,setupView:l,state:n}}function Wd(i){let e=new G_(i),t=[],n=[],s=[];function r(h){d.camera=h,t.length=0,n.length=0,s.length=0}function o(h){t.push(h)}function a(h){n.push(h)}function l(h){s.push(h)}function c(){e.setup(t)}function u(h){e.setupView(t,h)}let d={lightsArray:t,shadowsArray:n,lightProbeGridArray:s,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:d,setupLights:c,setupLightsView:u,pushLight:o,pushShadow:a,pushLightProbeGrid:l}}function H_(i){let e=new WeakMap;function t(s,r=0){let o=e.get(s),a;return o===void 0?(a=new Wd(i),e.set(s,[a])):r>=o.length?(a=new Wd(i),o.push(a)):a=o[r],a}function n(){e=new WeakMap}return{get:t,dispose:n}}var W_=`void main() {
gl_Position = vec4( position, 1.0 );
}`,X_=`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 );
}`,q_=[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)],Y_=[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)],Xd=new gt,Fr=new N,ph=new N;function Z_(i,e,t){let n=new hr,s=new Ee,r=new Ee,o=new xt,a=new Jo,l=new jo,c={},u=t.maxTextureSize,d={[Qn]:$t,[$t]:Qn,[zn]:zn},h=new ut({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ee},radius:{value:4}},vertexShader:W_,fragmentShader:X_}),f=h.clone();f.defines.HORIZONTAL_PASS=1;let g=new ht;g.setAttribute("position",new Ye(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let x=new Xt(g,h),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=vr;let p=this.type;this.render=function(w,C,_){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||w.length===0)return;this.type===Gu&&(Te("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=vr);let T=i.getRenderTarget(),P=i.getActiveCubeFace(),R=i.getActiveMipmapLevel(),I=i.state;I.setBlending(yn),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(k=>k.needsUpdate=!0):W.material.needsUpdate=!0)});for(let W=0,k=w.length;W<k;W++){let z=w[W],V=z.shadow;if(V===void 0){Te("WebGLShadowMap:",z,"has no shadow.");continue}if(V.autoUpdate===!1&&V.needsUpdate===!1)continue;s.copy(V.mapSize);let K=V.getFrameExtents();s.multiply(K),r.copy(V.mapSize),(s.x>u||s.y>u)&&(s.x>u&&(r.x=Math.floor(u/K.x),s.x=r.x*K.x,V.mapSize.x=r.x),s.y>u&&(r.y=Math.floor(u/K.y),s.y=r.y*K.y,V.mapSize.y=r.y));let Q=i.state.buffers.depth.getReversed();if(V.camera._reversedDepth=Q,V.map===null||H===!0){if(V.map!==null&&(V.map.depthTexture!==null&&(V.map.depthTexture.dispose(),V.map.depthTexture=null),V.map.dispose()),this.type===Cs){if(z.isPointLight){Te("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}V.map=new Rt(s.x,s.y,{format:Di,type:qt,minFilter:Bt,magFilter:Bt,generateMipmaps:!1}),V.map.texture.name=z.name+".shadowMap",V.map.depthTexture=new ii(s.x,s.y,Pn),V.map.depthTexture.name=z.name+".shadowMapDepth",V.map.depthTexture.format=Un,V.map.depthTexture.compareFunction=null,V.map.depthTexture.minFilter=Dt,V.map.depthTexture.magFilter=Dt}else z.isPointLight?(V.map=new il(s.x),V.map.depthTexture=new Ko(s.x,Rn)):(V.map=new Rt(s.x,s.y),V.map.depthTexture=new ii(s.x,s.y,Rn)),V.map.depthTexture.name=z.name+".shadowMap",V.map.depthTexture.format=Un,this.type===vr?(V.map.depthTexture.compareFunction=Q?Qa:ja,V.map.depthTexture.minFilter=Bt,V.map.depthTexture.magFilter=Bt):(V.map.depthTexture.compareFunction=null,V.map.depthTexture.minFilter=Dt,V.map.depthTexture.magFilter=Dt);V.camera.updateProjectionMatrix()}let ae=V.map.isWebGLCubeRenderTarget?6:1;for(let _e=0;_e<ae;_e++){if(V.map.isWebGLCubeRenderTarget)i.setRenderTarget(V.map,_e),i.clear();else{_e===0&&(i.setRenderTarget(V.map),i.clear());let be=V.getViewport(_e);o.set(r.x*be.x,r.y*be.y,r.x*be.z,r.y*be.w),I.viewport(o)}if(z.isPointLight){let be=V.camera,We=V.matrix,Qe=z.distance||be.far;Qe!==be.far&&(be.far=Qe,be.updateProjectionMatrix()),Fr.setFromMatrixPosition(z.matrixWorld),be.position.copy(Fr),ph.copy(be.position),ph.add(q_[_e]),be.up.copy(Y_[_e]),be.lookAt(ph),be.updateMatrixWorld(),We.makeTranslation(-Fr.x,-Fr.y,-Fr.z),Xd.multiplyMatrices(be.projectionMatrix,be.matrixWorldInverse),V._frustum.setFromProjectionMatrix(Xd,be.coordinateSystem,be.reversedDepth)}else V.updateMatrices(z);n=V.getFrustum(),M(C,_,V.camera,z,this.type)}V.isPointLightShadow!==!0&&this.type===Cs&&v(V,_),V.needsUpdate=!1}p=this.type,m.needsUpdate=!1,i.setRenderTarget(T,P,R)};function v(w,C){let _=e.update(x);h.defines.VSM_SAMPLES!==w.blurSamples&&(h.defines.VSM_SAMPLES=w.blurSamples,f.defines.VSM_SAMPLES=w.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new Rt(s.x,s.y,{format:Di,type:qt})),h.uniforms.shadow_pass.value=w.map.depthTexture,h.uniforms.resolution.value=w.mapSize,h.uniforms.radius.value=w.radius,i.setRenderTarget(w.mapPass),i.clear(),i.renderBufferDirect(C,null,_,h,x,null),f.uniforms.shadow_pass.value=w.mapPass.texture,f.uniforms.resolution.value=w.mapSize,f.uniforms.radius.value=w.radius,i.setRenderTarget(w.map),i.clear(),i.renderBufferDirect(C,null,_,f,x,null)}function b(w,C,_,T){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 k=W[H];k===void 0&&(k=P.clone(),W[H]=k,C.addEventListener("dispose",E)),P=k}if(P.visible=C.visible,P.wireframe=C.wireframe,T===Cs?P.side=C.shadowSide!==null?C.shadowSide:C.side:P.side=C.shadowSide!==null?C.shadowSide:d[C.side],P.alphaMap=C.alphaMap,P.alphaTest=C.alphaToCoverage===!0?.5:C.alphaTest,P.map=C.map,P.clipShadows=C.clipShadows,P.clippingPlanes=C.clippingPlanes,P.clipIntersection=C.clipIntersection,P.displacementMap=C.displacementMap,P.displacementScale=C.displacementScale,P.displacementBias=C.displacementBias,P.wireframeLinewidth=C.wireframeLinewidth,P.linewidth=C.linewidth,_.isPointLight===!0&&P.isMeshDistanceMaterial===!0){let I=i.properties.get(P);I.light=_}return P}function M(w,C,_,T,P){if(w.visible===!1)return;if(w.layers.test(C.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&P===Cs)&&(!w.frustumCulled||n.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,w.matrixWorld);let H=e.update(w),W=w.material;if(Array.isArray(W)){let k=H.groups;for(let z=0,V=k.length;z<V;z++){let K=k[z],Q=W[K.materialIndex];if(Q&&Q.visible){let ae=b(w,Q,T,P);w.onBeforeShadow(i,w,C,_,H,ae,K),i.renderBufferDirect(_,null,H,ae,w,K),w.onAfterShadow(i,w,C,_,H,ae,K)}}}else if(W.visible){let k=b(w,W,T,P);w.onBeforeShadow(i,w,C,_,H,k,null),i.renderBufferDirect(_,null,H,k,w,null),w.onAfterShadow(i,w,C,_,H,k,null)}}let I=w.children;for(let H=0,W=I.length;H<W;H++)M(I[H],C,_,T,P)}function E(w){w.target.removeEventListener("dispose",E);for(let _ in c){let T=c[_],P=w.target.uuid;P in T&&(T[P].dispose(),delete T[P])}}}function $_(i,e){function t(){let L=!1,ne=new xt,q=null,pe=new xt(0,0,0,0);return{setMask:function(re){q!==re&&!L&&(i.colorMask(re,re,re,re),q=re)},setLocked:function(re){L=re},setClear:function(re,J,Me,De,yt){yt===!0&&(re*=De,J*=De,Me*=De),ne.set(re,J,Me,De),pe.equals(ne)===!1&&(i.clearColor(re,J,Me,De),pe.copy(ne))},reset:function(){L=!1,q=null,pe.set(-1,0,0,0)}}}function n(){let L=!1,ne=!1,q=null,pe=null,re=null;return{setReversed:function(J){if(ne!==J){let Me=e.get("EXT_clip_control");J?Me.clipControlEXT(Me.LOWER_LEFT_EXT,Me.ZERO_TO_ONE_EXT):Me.clipControlEXT(Me.LOWER_LEFT_EXT,Me.NEGATIVE_ONE_TO_ONE_EXT),ne=J;let De=re;re=null,this.setClear(De)}},getReversed:function(){return ne},setTest:function(J){J?ie(i.DEPTH_TEST):Ae(i.DEPTH_TEST)},setMask:function(J){q!==J&&!L&&(i.depthMask(J),q=J)},setFunc:function(J){if(ne&&(J=bd[J]),pe!==J){switch(J){case Lo:i.depthFunc(i.NEVER);break;case No:i.depthFunc(i.ALWAYS);break;case Do:i.depthFunc(i.LESS);break;case Yi:i.depthFunc(i.LEQUAL);break;case Fo:i.depthFunc(i.EQUAL);break;case ko:i.depthFunc(i.GEQUAL);break;case Oo:i.depthFunc(i.GREATER);break;case Uo:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}pe=J}},setLocked:function(J){L=J},setClear:function(J){re!==J&&(re=J,ne&&(J=1-J),i.clearDepth(J))},reset:function(){L=!1,q=null,pe=null,re=null,ne=!1}}}function s(){let L=!1,ne=null,q=null,pe=null,re=null,J=null,Me=null,De=null,yt=null;return{setTest:function(tt){L||(tt?ie(i.STENCIL_TEST):Ae(i.STENCIL_TEST))},setMask:function(tt){ne!==tt&&!L&&(i.stencilMask(tt),ne=tt)},setFunc:function(tt,Hn,Ln){(q!==tt||pe!==Hn||re!==Ln)&&(i.stencilFunc(tt,Hn,Ln),q=tt,pe=Hn,re=Ln)},setOp:function(tt,Hn,Ln){(J!==tt||Me!==Hn||De!==Ln)&&(i.stencilOp(tt,Hn,Ln),J=tt,Me=Hn,De=Ln)},setLocked:function(tt){L=tt},setClear:function(tt){yt!==tt&&(i.clearStencil(tt),yt=tt)},reset:function(){L=!1,ne=null,q=null,pe=null,re=null,J=null,Me=null,De=null,yt=null}}}let r=new t,o=new n,a=new s,l=new WeakMap,c=new WeakMap,u={},d={},h={},f=new WeakMap,g=[],x=null,m=!1,p=null,v=null,b=null,M=null,E=null,w=null,C=null,_=new me(0,0,0),T=0,P=!1,R=null,I=null,H=null,W=null,k=null,z=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS),V=!1,K=0,Q=i.getParameter(i.VERSION);Q.indexOf("WebGL")!==-1?(K=parseFloat(/^WebGL (\d)/.exec(Q)[1]),V=K>=1):Q.indexOf("OpenGL ES")!==-1&&(K=parseFloat(/^OpenGL ES (\d)/.exec(Q)[1]),V=K>=2);let ae=null,_e={},be=i.getParameter(i.SCISSOR_BOX),We=i.getParameter(i.VIEWPORT),Qe=new xt().fromArray(be),ke=new xt().fromArray(We);function $(L,ne,q,pe){let re=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 Me=0;Me<q;Me++)L===i.TEXTURE_3D||L===i.TEXTURE_2D_ARRAY?i.texImage3D(ne,0,i.RGBA,1,1,pe,0,i.RGBA,i.UNSIGNED_BYTE,re):i.texImage2D(ne+Me,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,re);return J}let de={};de[i.TEXTURE_2D]=$(i.TEXTURE_2D,i.TEXTURE_2D,1),de[i.TEXTURE_CUBE_MAP]=$(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),de[i.TEXTURE_2D_ARRAY]=$(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),de[i.TEXTURE_3D]=$(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),o.setClear(1),a.setClear(0),ie(i.DEPTH_TEST),o.setFunc(Yi),Tt(!1),ft(Oc),ie(i.CULL_FACE),lt(yn);function ie(L){u[L]!==!0&&(i.enable(L),u[L]=!0)}function Ae(L){u[L]!==!1&&(i.disable(L),u[L]=!1)}function Ne(L,ne){return h[L]!==ne?(i.bindFramebuffer(L,ne),h[L]=ne,L===i.DRAW_FRAMEBUFFER&&(h[i.FRAMEBUFFER]=ne),L===i.FRAMEBUFFER&&(h[i.DRAW_FRAMEBUFFER]=ne),!0):!1}function Pe(L,ne){let q=g,pe=!1;if(L){q=f.get(ne),q===void 0&&(q=[],f.set(ne,q));let re=L.textures;if(q.length!==re.length||q[0]!==i.COLOR_ATTACHMENT0){for(let J=0,Me=re.length;J<Me;J++)q[J]=i.COLOR_ATTACHMENT0+J;q.length=re.length,pe=!0}}else q[0]!==i.BACK&&(q[0]=i.BACK,pe=!0);pe&&i.drawBuffers(q)}function dt(L){return x!==L?(i.useProgram(L),x=L,!0):!1}let Xe={[_i]:i.FUNC_ADD,[Wu]:i.FUNC_SUBTRACT,[Xu]:i.FUNC_REVERSE_SUBTRACT};Xe[qu]=i.MIN,Xe[Yu]=i.MAX;let et={[Zu]:i.ZERO,[$u]:i.ONE,[Ku]:i.SRC_COLOR,[Po]:i.SRC_ALPHA,[nd]:i.SRC_ALPHA_SATURATE,[ed]:i.DST_COLOR,[ju]:i.DST_ALPHA,[Ju]:i.ONE_MINUS_SRC_COLOR,[Io]:i.ONE_MINUS_SRC_ALPHA,[td]:i.ONE_MINUS_DST_COLOR,[Qu]:i.ONE_MINUS_DST_ALPHA,[id]:i.CONSTANT_COLOR,[sd]:i.ONE_MINUS_CONSTANT_COLOR,[rd]:i.CONSTANT_ALPHA,[od]:i.ONE_MINUS_CONSTANT_ALPHA};function lt(L,ne,q,pe,re,J,Me,De,yt,tt){if(L===yn){m===!0&&(Ae(i.BLEND),m=!1);return}if(m===!1&&(ie(i.BLEND),m=!0),L!==Hu){if(L!==p||tt!==P){if((v!==_i||E!==_i)&&(i.blendEquation(i.FUNC_ADD),v=_i,E=_i),tt)switch(L){case qi:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case _r:i.blendFunc(i.ONE,i.ONE);break;case Uc:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Bc:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:Re("WebGLState: Invalid blending: ",L);break}else switch(L){case qi:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case _r:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case Uc:Re("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Bc:Re("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Re("WebGLState: Invalid blending: ",L);break}b=null,M=null,w=null,C=null,_.set(0,0,0),T=0,p=L,P=tt}return}re=re||ne,J=J||q,Me=Me||pe,(ne!==v||re!==E)&&(i.blendEquationSeparate(Xe[ne],Xe[re]),v=ne,E=re),(q!==b||pe!==M||J!==w||Me!==C)&&(i.blendFuncSeparate(et[q],et[pe],et[J],et[Me]),b=q,M=pe,w=J,C=Me),(De.equals(_)===!1||yt!==T)&&(i.blendColor(De.r,De.g,De.b,yt),_.copy(De),T=yt),p=L,P=!1}function He(L,ne){L.side===zn?Ae(i.CULL_FACE):ie(i.CULL_FACE);let q=L.side===$t;ne&&(q=!q),Tt(q),L.blending===qi&&L.transparent===!1?lt(yn):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 pe=L.stencilWrite;a.setTest(pe),pe&&(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?ie(i.SAMPLE_ALPHA_TO_COVERAGE):Ae(i.SAMPLE_ALPHA_TO_COVERAGE)}function Tt(L){R!==L&&(L?i.frontFace(i.CW):i.frontFace(i.CCW),R=L)}function ft(L){L!==zu?(ie(i.CULL_FACE),L!==I&&(L===Oc?i.cullFace(i.BACK):L===Vu?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):Ae(i.CULL_FACE),I=L}function sn(L){L!==H&&(V&&i.lineWidth(L),H=L)}function D(L,ne,q){L?(ie(i.POLYGON_OFFSET_FILL),(W!==ne||k!==q)&&(W=ne,k=q,o.getReversed()&&(ne=-ne),i.polygonOffset(ne,q))):Ae(i.POLYGON_OFFSET_FILL)}function At(L){L?ie(i.SCISSOR_TEST):Ae(i.SCISSOR_TEST)}function qe(L){L===void 0&&(L=i.TEXTURE0+z-1),ae!==L&&(i.activeTexture(L),ae=L)}function ot(L,ne,q){q===void 0&&(ae===null?q=i.TEXTURE0+z-1:q=ae);let pe=_e[q];pe===void 0&&(pe={type:void 0,texture:void 0},_e[q]=pe),(pe.type!==L||pe.texture!==ne)&&(ae!==q&&(i.activeTexture(q),ae=q),i.bindTexture(L,ne||de[L]),pe.type=L,pe.texture=ne)}function le(){let L=_e[ae];L!==void 0&&L.type!==void 0&&(i.bindTexture(L.type,null),L.type=void 0,L.texture=void 0)}function pt(){try{i.compressedTexImage2D(...arguments)}catch(L){Re("WebGLState:",L)}}function A(){try{i.compressedTexImage3D(...arguments)}catch(L){Re("WebGLState:",L)}}function y(){try{i.texSubImage2D(...arguments)}catch(L){Re("WebGLState:",L)}}function O(){try{i.texSubImage3D(...arguments)}catch(L){Re("WebGLState:",L)}}function Y(){try{i.compressedTexSubImage2D(...arguments)}catch(L){Re("WebGLState:",L)}}function j(){try{i.compressedTexSubImage3D(...arguments)}catch(L){Re("WebGLState:",L)}}function ee(){try{i.texStorage2D(...arguments)}catch(L){Re("WebGLState:",L)}}function oe(){try{i.texStorage3D(...arguments)}catch(L){Re("WebGLState:",L)}}function X(){try{i.texImage2D(...arguments)}catch(L){Re("WebGLState:",L)}}function Z(){try{i.texImage3D(...arguments)}catch(L){Re("WebGLState:",L)}}function fe(L){return d[L]!==void 0?d[L]:i.getParameter(L)}function xe(L,ne){d[L]!==ne&&(i.pixelStorei(L,ne),d[L]=ne)}function se(L){Qe.equals(L)===!1&&(i.scissor(L.x,L.y,L.z,L.w),Qe.copy(L))}function te(L){ke.equals(L)===!1&&(i.viewport(L.x,L.y,L.z,L.w),ke.copy(L))}function Ie(L,ne){let q=c.get(ne);q===void 0&&(q=new WeakMap,c.set(ne,q));let pe=q.get(L);pe===void 0&&(pe=i.getUniformBlockIndex(ne,L.name),q.set(L,pe))}function Oe(L,ne){let pe=c.get(ne).get(L);l.get(ne)!==pe&&(i.uniformBlockBinding(ne,pe,L.__bindingPointIndex),l.set(ne,pe))}function Ke(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),o.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),i.pixelStorei(i.PACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.BROWSER_DEFAULT_WEBGL),i.pixelStorei(i.PACK_ROW_LENGTH,0),i.pixelStorei(i.PACK_SKIP_PIXELS,0),i.pixelStorei(i.PACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_ROW_LENGTH,0),i.pixelStorei(i.UNPACK_IMAGE_HEIGHT,0),i.pixelStorei(i.UNPACK_SKIP_PIXELS,0),i.pixelStorei(i.UNPACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_SKIP_IMAGES,0),u={},d={},ae=null,_e={},h={},f=new WeakMap,g=[],x=null,m=!1,p=null,v=null,b=null,M=null,E=null,w=null,C=null,_=new me(0,0,0),T=0,P=!1,R=null,I=null,H=null,W=null,k=null,Qe.set(0,0,i.canvas.width,i.canvas.height),ke.set(0,0,i.canvas.width,i.canvas.height),r.reset(),o.reset(),a.reset()}return{buffers:{color:r,depth:o,stencil:a},enable:ie,disable:Ae,bindFramebuffer:Ne,drawBuffers:Pe,useProgram:dt,setBlending:lt,setMaterial:He,setFlipSided:Tt,setCullFace:ft,setLineWidth:sn,setPolygonOffset:D,setScissorTest:At,activeTexture:qe,bindTexture:ot,unbindTexture:le,compressedTexImage2D:pt,compressedTexImage3D:A,texImage2D:X,texImage3D:Z,pixelStorei:xe,getParameter:fe,updateUBOMapping:Ie,uniformBlockBinding:Oe,texStorage2D:ee,texStorage3D:oe,texSubImage2D:y,texSubImage3D:O,compressedTexSubImage2D:Y,compressedTexSubImage3D:j,scissor:se,viewport:te,reset:Ke}}function K_(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 Ee,u=new WeakMap,d=new Set,h,f=new WeakMap,g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(A,y){return g?new OffscreenCanvas(A,y):rr("canvas")}function m(A,y,O){let Y=1,j=pt(A);if((j.width>O||j.height>O)&&(Y=O/Math.max(j.width,j.height)),Y<1)if(typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&A instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&A instanceof ImageBitmap||typeof VideoFrame<"u"&&A instanceof VideoFrame){let ee=Math.floor(Y*j.width),oe=Math.floor(Y*j.height);h===void 0&&(h=x(ee,oe));let X=y?x(ee,oe):h;return X.width=ee,X.height=oe,X.getContext("2d").drawImage(A,0,0,ee,oe),Te("WebGLRenderer: Texture has been resized from ("+j.width+"x"+j.height+") to ("+ee+"x"+oe+")."),X}else return"data"in A&&Te("WebGLRenderer: Image in DataTexture is too big ("+j.width+"x"+j.height+")."),A;return A}function p(A){return A.generateMipmaps}function v(A){i.generateMipmap(A)}function b(A){return A.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:A.isWebGL3DRenderTarget?i.TEXTURE_3D:A.isWebGLArrayRenderTarget||A.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function M(A,y,O,Y,j,ee=!1){if(A!==null){if(i[A]!==void 0)return i[A];Te("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+A+"'")}let oe;Y&&(oe=e.get("EXT_texture_norm16"),oe||Te("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let X=y;if(y===i.RED&&(O===i.FLOAT&&(X=i.R32F),O===i.HALF_FLOAT&&(X=i.R16F),O===i.UNSIGNED_BYTE&&(X=i.R8),O===i.UNSIGNED_SHORT&&oe&&(X=oe.R16_EXT),O===i.SHORT&&oe&&(X=oe.R16_SNORM_EXT)),y===i.RED_INTEGER&&(O===i.UNSIGNED_BYTE&&(X=i.R8UI),O===i.UNSIGNED_SHORT&&(X=i.R16UI),O===i.UNSIGNED_INT&&(X=i.R32UI),O===i.BYTE&&(X=i.R8I),O===i.SHORT&&(X=i.R16I),O===i.INT&&(X=i.R32I)),y===i.RG&&(O===i.FLOAT&&(X=i.RG32F),O===i.HALF_FLOAT&&(X=i.RG16F),O===i.UNSIGNED_BYTE&&(X=i.RG8),O===i.UNSIGNED_SHORT&&oe&&(X=oe.RG16_EXT),O===i.SHORT&&oe&&(X=oe.RG16_SNORM_EXT)),y===i.RG_INTEGER&&(O===i.UNSIGNED_BYTE&&(X=i.RG8UI),O===i.UNSIGNED_SHORT&&(X=i.RG16UI),O===i.UNSIGNED_INT&&(X=i.RG32UI),O===i.BYTE&&(X=i.RG8I),O===i.SHORT&&(X=i.RG16I),O===i.INT&&(X=i.RG32I)),y===i.RGB_INTEGER&&(O===i.UNSIGNED_BYTE&&(X=i.RGB8UI),O===i.UNSIGNED_SHORT&&(X=i.RGB16UI),O===i.UNSIGNED_INT&&(X=i.RGB32UI),O===i.BYTE&&(X=i.RGB8I),O===i.SHORT&&(X=i.RGB16I),O===i.INT&&(X=i.RGB32I)),y===i.RGBA_INTEGER&&(O===i.UNSIGNED_BYTE&&(X=i.RGBA8UI),O===i.UNSIGNED_SHORT&&(X=i.RGBA16UI),O===i.UNSIGNED_INT&&(X=i.RGBA32UI),O===i.BYTE&&(X=i.RGBA8I),O===i.SHORT&&(X=i.RGBA16I),O===i.INT&&(X=i.RGBA32I)),y===i.RGB&&(O===i.UNSIGNED_SHORT&&oe&&(X=oe.RGB16_EXT),O===i.SHORT&&oe&&(X=oe.RGB16_SNORM_EXT),O===i.UNSIGNED_INT_5_9_9_9_REV&&(X=i.RGB9_E5),O===i.UNSIGNED_INT_10F_11F_11F_REV&&(X=i.R11F_G11F_B10F)),y===i.RGBA){let Z=ee?ir:ze.getTransfer(j);O===i.FLOAT&&(X=i.RGBA32F),O===i.HALF_FLOAT&&(X=i.RGBA16F),O===i.UNSIGNED_BYTE&&(X=Z===Je?i.SRGB8_ALPHA8:i.RGBA8),O===i.UNSIGNED_SHORT&&oe&&(X=oe.RGBA16_EXT),O===i.SHORT&&oe&&(X=oe.RGBA16_SNORM_EXT),O===i.UNSIGNED_SHORT_4_4_4_4&&(X=i.RGBA4),O===i.UNSIGNED_SHORT_5_5_5_1&&(X=i.RGB5_A1)}return(X===i.R16F||X===i.R32F||X===i.RG16F||X===i.RG32F||X===i.RGBA16F||X===i.RGBA32F)&&e.get("EXT_color_buffer_float"),X}function E(A,y){let O;return A?y===null||y===Rn||y===Ps?O=i.DEPTH24_STENCIL8:y===Pn?O=i.DEPTH32F_STENCIL8:y===Rs&&(O=i.DEPTH24_STENCIL8,Te("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):y===null||y===Rn||y===Ps?O=i.DEPTH_COMPONENT24:y===Pn?O=i.DEPTH_COMPONENT32F:y===Rs&&(O=i.DEPTH_COMPONENT16),O}function w(A,y){return p(A)===!0||A.isFramebufferTexture&&A.minFilter!==Dt&&A.minFilter!==Bt?Math.log2(Math.max(y.width,y.height))+1:A.mipmaps!==void 0&&A.mipmaps.length>0?A.mipmaps.length:A.isCompressedTexture&&Array.isArray(A.image)?y.mipmaps.length:1}function C(A){let y=A.target;y.removeEventListener("dispose",C),T(y),y.isVideoTexture&&u.delete(y),y.isHTMLTexture&&d.delete(y)}function _(A){let y=A.target;y.removeEventListener("dispose",_),R(y)}function T(A){let y=n.get(A);if(y.__webglInit===void 0)return;let O=A.source,Y=f.get(O);if(Y){let j=Y[y.__cacheKey];j.usedTimes--,j.usedTimes===0&&P(A),Object.keys(Y).length===0&&f.delete(O)}n.remove(A)}function P(A){let y=n.get(A);i.deleteTexture(y.__webglTexture);let O=A.source,Y=f.get(O);delete Y[y.__cacheKey],o.memory.textures--}function R(A){let y=n.get(A);if(A.depthTexture&&(A.depthTexture.dispose(),n.remove(A.depthTexture)),A.isWebGLCubeRenderTarget)for(let Y=0;Y<6;Y++){if(Array.isArray(y.__webglFramebuffer[Y]))for(let j=0;j<y.__webglFramebuffer[Y].length;j++)i.deleteFramebuffer(y.__webglFramebuffer[Y][j]);else i.deleteFramebuffer(y.__webglFramebuffer[Y]);y.__webglDepthbuffer&&i.deleteRenderbuffer(y.__webglDepthbuffer[Y])}else{if(Array.isArray(y.__webglFramebuffer))for(let Y=0;Y<y.__webglFramebuffer.length;Y++)i.deleteFramebuffer(y.__webglFramebuffer[Y]);else i.deleteFramebuffer(y.__webglFramebuffer);if(y.__webglDepthbuffer&&i.deleteRenderbuffer(y.__webglDepthbuffer),y.__webglMultisampledFramebuffer&&i.deleteFramebuffer(y.__webglMultisampledFramebuffer),y.__webglColorRenderbuffer)for(let Y=0;Y<y.__webglColorRenderbuffer.length;Y++)y.__webglColorRenderbuffer[Y]&&i.deleteRenderbuffer(y.__webglColorRenderbuffer[Y]);y.__webglDepthRenderbuffer&&i.deleteRenderbuffer(y.__webglDepthRenderbuffer)}let O=A.textures;for(let Y=0,j=O.length;Y<j;Y++){let ee=n.get(O[Y]);ee.__webglTexture&&(i.deleteTexture(ee.__webglTexture),o.memory.textures--),n.remove(O[Y])}n.remove(A)}let I=0;function H(){I=0}function W(){return I}function k(A){I=A}function z(){let A=I;return A>=s.maxTextures&&Te("WebGLTextures: Trying to use "+A+" texture units while this GPU supports only "+s.maxTextures),I+=1,A}function V(A){let y=[];return y.push(A.wrapS),y.push(A.wrapT),y.push(A.wrapR||0),y.push(A.magFilter),y.push(A.minFilter),y.push(A.anisotropy),y.push(A.internalFormat),y.push(A.format),y.push(A.type),y.push(A.generateMipmaps),y.push(A.premultiplyAlpha),y.push(A.flipY),y.push(A.unpackAlignment),y.push(A.colorSpace),y.join()}function K(A,y){let O=n.get(A);if(A.isVideoTexture&&ot(A),A.isRenderTargetTexture===!1&&A.isExternalTexture!==!0&&A.version>0&&O.__version!==A.version){let Y=A.image;if(Y===null)Te("WebGLRenderer: Texture marked for update but no image data found.");else if(Y.complete===!1)Te("WebGLRenderer: Texture marked for update but image is incomplete");else{Ae(O,A,y);return}}else A.isExternalTexture&&(O.__webglTexture=A.sourceTexture?A.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,O.__webglTexture,i.TEXTURE0+y)}function Q(A,y){let O=n.get(A);if(A.isRenderTargetTexture===!1&&A.version>0&&O.__version!==A.version){Ae(O,A,y);return}else A.isExternalTexture&&(O.__webglTexture=A.sourceTexture?A.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,O.__webglTexture,i.TEXTURE0+y)}function ae(A,y){let O=n.get(A);if(A.isRenderTargetTexture===!1&&A.version>0&&O.__version!==A.version){Ae(O,A,y);return}t.bindTexture(i.TEXTURE_3D,O.__webglTexture,i.TEXTURE0+y)}function _e(A,y){let O=n.get(A);if(A.isCubeDepthTexture!==!0&&A.version>0&&O.__version!==A.version){Ne(O,A,y);return}t.bindTexture(i.TEXTURE_CUBE_MAP,O.__webglTexture,i.TEXTURE0+y)}let be={[Bo]:i.REPEAT,[On]:i.CLAMP_TO_EDGE,[zo]:i.MIRRORED_REPEAT},We={[Dt]:i.NEAREST,[cd]:i.NEAREST_MIPMAP_NEAREST,[Ar]:i.NEAREST_MIPMAP_LINEAR,[Bt]:i.LINEAR,[ma]:i.LINEAR_MIPMAP_NEAREST,[Li]:i.LINEAR_MIPMAP_LINEAR},Qe={[dd]:i.NEVER,[xd]:i.ALWAYS,[fd]:i.LESS,[ja]:i.LEQUAL,[pd]:i.EQUAL,[Qa]:i.GEQUAL,[md]:i.GREATER,[gd]:i.NOTEQUAL};function ke(A,y){if(y.type===Pn&&e.has("OES_texture_float_linear")===!1&&(y.magFilter===Bt||y.magFilter===ma||y.magFilter===Ar||y.magFilter===Li||y.minFilter===Bt||y.minFilter===ma||y.minFilter===Ar||y.minFilter===Li)&&Te("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(A,i.TEXTURE_WRAP_S,be[y.wrapS]),i.texParameteri(A,i.TEXTURE_WRAP_T,be[y.wrapT]),(A===i.TEXTURE_3D||A===i.TEXTURE_2D_ARRAY)&&i.texParameteri(A,i.TEXTURE_WRAP_R,be[y.wrapR]),i.texParameteri(A,i.TEXTURE_MAG_FILTER,We[y.magFilter]),i.texParameteri(A,i.TEXTURE_MIN_FILTER,We[y.minFilter]),y.compareFunction&&(i.texParameteri(A,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(A,i.TEXTURE_COMPARE_FUNC,Qe[y.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(y.magFilter===Dt||y.minFilter!==Ar&&y.minFilter!==Li||y.type===Pn&&e.has("OES_texture_float_linear")===!1)return;if(y.anisotropy>1||n.get(y).__currentAnisotropy){let O=e.get("EXT_texture_filter_anisotropic");i.texParameterf(A,O.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(y.anisotropy,s.getMaxAnisotropy())),n.get(y).__currentAnisotropy=y.anisotropy}}}function $(A,y){let O=!1;A.__webglInit===void 0&&(A.__webglInit=!0,y.addEventListener("dispose",C));let Y=y.source,j=f.get(Y);j===void 0&&(j={},f.set(Y,j));let ee=V(y);if(ee!==A.__cacheKey){j[ee]===void 0&&(j[ee]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,O=!0),j[ee].usedTimes++;let oe=j[A.__cacheKey];oe!==void 0&&(j[A.__cacheKey].usedTimes--,oe.usedTimes===0&&P(y)),A.__cacheKey=ee,A.__webglTexture=j[ee].texture}return O}function de(A,y,O){return Math.floor(Math.floor(A/O)/y)}function ie(A,y,O,Y){let ee=A.updateRanges;if(ee.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,y.width,y.height,O,Y,y.data);else{ee.sort((xe,se)=>xe.start-se.start);let oe=0;for(let xe=1;xe<ee.length;xe++){let se=ee[oe],te=ee[xe],Ie=se.start+se.count,Oe=de(te.start,y.width,4),Ke=de(se.start,y.width,4);te.start<=Ie+1&&Oe===Ke&&de(te.start+te.count-1,y.width,4)===Oe?se.count=Math.max(se.count,te.start+te.count-se.start):(++oe,ee[oe]=te)}ee.length=oe+1;let X=t.getParameter(i.UNPACK_ROW_LENGTH),Z=t.getParameter(i.UNPACK_SKIP_PIXELS),fe=t.getParameter(i.UNPACK_SKIP_ROWS);t.pixelStorei(i.UNPACK_ROW_LENGTH,y.width);for(let xe=0,se=ee.length;xe<se;xe++){let te=ee[xe],Ie=Math.floor(te.start/4),Oe=Math.ceil(te.count/4),Ke=Ie%y.width,L=Math.floor(Ie/y.width),ne=Oe,q=1;t.pixelStorei(i.UNPACK_SKIP_PIXELS,Ke),t.pixelStorei(i.UNPACK_SKIP_ROWS,L),t.texSubImage2D(i.TEXTURE_2D,0,Ke,L,ne,q,O,Y,y.data)}A.clearUpdateRanges(),t.pixelStorei(i.UNPACK_ROW_LENGTH,X),t.pixelStorei(i.UNPACK_SKIP_PIXELS,Z),t.pixelStorei(i.UNPACK_SKIP_ROWS,fe)}}function Ae(A,y,O){let Y=i.TEXTURE_2D;(y.isDataArrayTexture||y.isCompressedArrayTexture)&&(Y=i.TEXTURE_2D_ARRAY),y.isData3DTexture&&(Y=i.TEXTURE_3D);let j=$(A,y),ee=y.source;t.bindTexture(Y,A.__webglTexture,i.TEXTURE0+O);let oe=n.get(ee);if(ee.version!==oe.__version||j===!0){if(t.activeTexture(i.TEXTURE0+O),(typeof ImageBitmap<"u"&&y.image instanceof ImageBitmap)===!1){let q=ze.getPrimaries(ze.workingColorSpace),pe=y.colorSpace===ri?null:ze.getPrimaries(y.colorSpace),re=y.colorSpace===ri||q===pe?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,re)}t.pixelStorei(i.UNPACK_ALIGNMENT,y.unpackAlignment);let Z=m(y.image,!1,s.maxTextureSize);Z=le(y,Z);let fe=r.convert(y.format,y.colorSpace),xe=r.convert(y.type),se=M(y.internalFormat,fe,xe,y.normalized,y.colorSpace,y.isVideoTexture);ke(Y,y);let te,Ie=y.mipmaps,Oe=y.isVideoTexture!==!0,Ke=oe.__version===void 0||j===!0,L=ee.dataReady,ne=w(y,Z);if(y.isDepthTexture)se=E(y.format===Ni,y.type),Ke&&(Oe?t.texStorage2D(i.TEXTURE_2D,1,se,Z.width,Z.height):t.texImage2D(i.TEXTURE_2D,0,se,Z.width,Z.height,0,fe,xe,null));else if(y.isDataTexture)if(Ie.length>0){Oe&&Ke&&t.texStorage2D(i.TEXTURE_2D,ne,se,Ie[0].width,Ie[0].height);for(let q=0,pe=Ie.length;q<pe;q++)te=Ie[q],Oe?L&&t.texSubImage2D(i.TEXTURE_2D,q,0,0,te.width,te.height,fe,xe,te.data):t.texImage2D(i.TEXTURE_2D,q,se,te.width,te.height,0,fe,xe,te.data);y.generateMipmaps=!1}else Oe?(Ke&&t.texStorage2D(i.TEXTURE_2D,ne,se,Z.width,Z.height),L&&ie(y,Z,fe,xe)):t.texImage2D(i.TEXTURE_2D,0,se,Z.width,Z.height,0,fe,xe,Z.data);else if(y.isCompressedTexture)if(y.isCompressedArrayTexture){Oe&&Ke&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ne,se,Ie[0].width,Ie[0].height,Z.depth);for(let q=0,pe=Ie.length;q<pe;q++)if(te=Ie[q],y.format!==bn)if(fe!==null)if(Oe){if(L)if(y.layerUpdates.size>0){let re=ih(te.width,te.height,y.format,y.type);for(let J of y.layerUpdates){let Me=te.data.subarray(J*re/te.data.BYTES_PER_ELEMENT,(J+1)*re/te.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,q,0,0,J,te.width,te.height,1,fe,Me)}y.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,q,0,0,0,te.width,te.height,Z.depth,fe,te.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,q,se,te.width,te.height,Z.depth,0,te.data,0,0);else Te("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Oe?L&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,q,0,0,0,te.width,te.height,Z.depth,fe,xe,te.data):t.texImage3D(i.TEXTURE_2D_ARRAY,q,se,te.width,te.height,Z.depth,0,fe,xe,te.data)}else{Oe&&Ke&&t.texStorage2D(i.TEXTURE_2D,ne,se,Ie[0].width,Ie[0].height);for(let q=0,pe=Ie.length;q<pe;q++)te=Ie[q],y.format!==bn?fe!==null?Oe?L&&t.compressedTexSubImage2D(i.TEXTURE_2D,q,0,0,te.width,te.height,fe,te.data):t.compressedTexImage2D(i.TEXTURE_2D,q,se,te.width,te.height,0,te.data):Te("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Oe?L&&t.texSubImage2D(i.TEXTURE_2D,q,0,0,te.width,te.height,fe,xe,te.data):t.texImage2D(i.TEXTURE_2D,q,se,te.width,te.height,0,fe,xe,te.data)}else if(y.isDataArrayTexture)if(Oe){if(Ke&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ne,se,Z.width,Z.height,Z.depth),L)if(y.layerUpdates.size>0){let q=ih(Z.width,Z.height,y.format,y.type);for(let pe of y.layerUpdates){let re=Z.data.subarray(pe*q/Z.data.BYTES_PER_ELEMENT,(pe+1)*q/Z.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,pe,Z.width,Z.height,1,fe,xe,re)}y.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,Z.width,Z.height,Z.depth,fe,xe,Z.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,se,Z.width,Z.height,Z.depth,0,fe,xe,Z.data);else if(y.isData3DTexture)Oe?(Ke&&t.texStorage3D(i.TEXTURE_3D,ne,se,Z.width,Z.height,Z.depth),L&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,Z.width,Z.height,Z.depth,fe,xe,Z.data)):t.texImage3D(i.TEXTURE_3D,0,se,Z.width,Z.height,Z.depth,0,fe,xe,Z.data);else if(y.isFramebufferTexture){if(Ke)if(Oe)t.texStorage2D(i.TEXTURE_2D,ne,se,Z.width,Z.height);else{let q=Z.width,pe=Z.height;for(let re=0;re<ne;re++)t.texImage2D(i.TEXTURE_2D,re,se,q,pe,0,fe,xe,null),q>>=1,pe>>=1}}else if(y.isHTMLTexture){if("texElementImage2D"in i){let q=i.canvas;if(q.hasAttribute("layoutsubtree")||q.setAttribute("layoutsubtree","true"),Z.parentNode!==q){q.appendChild(Z),d.add(y),q.onpaint=De=>{let yt=De.changedElements;for(let tt of d)yt.includes(tt.image)&&(tt.needsUpdate=!0)},q.requestPaint();return}let pe=0,re=i.RGBA,J=i.RGBA,Me=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,pe,re,J,Me,Z),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)}}else if(Ie.length>0){if(Oe&&Ke){let q=pt(Ie[0]);t.texStorage2D(i.TEXTURE_2D,ne,se,q.width,q.height)}for(let q=0,pe=Ie.length;q<pe;q++)te=Ie[q],Oe?L&&t.texSubImage2D(i.TEXTURE_2D,q,0,0,fe,xe,te):t.texImage2D(i.TEXTURE_2D,q,se,fe,xe,te);y.generateMipmaps=!1}else if(Oe){if(Ke){let q=pt(Z);t.texStorage2D(i.TEXTURE_2D,ne,se,q.width,q.height)}L&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,fe,xe,Z)}else t.texImage2D(i.TEXTURE_2D,0,se,fe,xe,Z);p(y)&&v(Y),oe.__version=ee.version,y.onUpdate&&y.onUpdate(y)}A.__version=y.version}function Ne(A,y,O){if(y.image.length!==6)return;let Y=$(A,y),j=y.source;t.bindTexture(i.TEXTURE_CUBE_MAP,A.__webglTexture,i.TEXTURE0+O);let ee=n.get(j);if(j.version!==ee.__version||Y===!0){t.activeTexture(i.TEXTURE0+O);let oe=ze.getPrimaries(ze.workingColorSpace),X=y.colorSpace===ri?null:ze.getPrimaries(y.colorSpace),Z=y.colorSpace===ri||oe===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,Z);let fe=y.isCompressedTexture||y.image[0].isCompressedTexture,xe=y.image[0]&&y.image[0].isDataTexture,se=[];for(let J=0;J<6;J++)!fe&&!xe?se[J]=m(y.image[J],!0,s.maxCubemapSize):se[J]=xe?y.image[J].image:y.image[J],se[J]=le(y,se[J]);let te=se[0],Ie=r.convert(y.format,y.colorSpace),Oe=r.convert(y.type),Ke=M(y.internalFormat,Ie,Oe,y.normalized,y.colorSpace),L=y.isVideoTexture!==!0,ne=ee.__version===void 0||Y===!0,q=j.dataReady,pe=w(y,te);ke(i.TEXTURE_CUBE_MAP,y);let re;if(fe){L&&ne&&t.texStorage2D(i.TEXTURE_CUBE_MAP,pe,Ke,te.width,te.height);for(let J=0;J<6;J++){re=se[J].mipmaps;for(let Me=0;Me<re.length;Me++){let De=re[Me];y.format!==bn?Ie!==null?L?q&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,Me,0,0,De.width,De.height,Ie,De.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,Me,Ke,De.width,De.height,0,De.data):Te("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):L?q&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,Me,0,0,De.width,De.height,Ie,Oe,De.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,Me,Ke,De.width,De.height,0,Ie,Oe,De.data)}}}else{if(re=y.mipmaps,L&&ne){re.length>0&&pe++;let J=pt(se[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,pe,Ke,J.width,J.height)}for(let J=0;J<6;J++)if(xe){L?q&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,0,0,se[J].width,se[J].height,Ie,Oe,se[J].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,Ke,se[J].width,se[J].height,0,Ie,Oe,se[J].data);for(let Me=0;Me<re.length;Me++){let yt=re[Me].image[J].image;L?q&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,Me+1,0,0,yt.width,yt.height,Ie,Oe,yt.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,Me+1,Ke,yt.width,yt.height,0,Ie,Oe,yt.data)}}else{L?q&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,0,0,Ie,Oe,se[J]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,Ke,Ie,Oe,se[J]);for(let Me=0;Me<re.length;Me++){let De=re[Me];L?q&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,Me+1,0,0,Ie,Oe,De.image[J]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+J,Me+1,Ke,Ie,Oe,De.image[J])}}}p(y)&&v(i.TEXTURE_CUBE_MAP),ee.__version=j.version,y.onUpdate&&y.onUpdate(y)}A.__version=y.version}function Pe(A,y,O,Y,j,ee){let oe=r.convert(O.format,O.colorSpace),X=r.convert(O.type),Z=M(O.internalFormat,oe,X,O.normalized,O.colorSpace),fe=n.get(y),xe=n.get(O);if(xe.__renderTarget=y,!fe.__hasExternalTextures){let se=Math.max(1,y.width>>ee),te=Math.max(1,y.height>>ee);j===i.TEXTURE_3D||j===i.TEXTURE_2D_ARRAY?t.texImage3D(j,ee,Z,se,te,y.depth,0,oe,X,null):t.texImage2D(j,ee,Z,se,te,0,oe,X,null)}t.bindFramebuffer(i.FRAMEBUFFER,A),qe(y)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Y,j,xe.__webglTexture,0,At(y)):(j===i.TEXTURE_2D||j>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&j<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,Y,j,xe.__webglTexture,ee),t.bindFramebuffer(i.FRAMEBUFFER,null)}function dt(A,y,O){if(i.bindRenderbuffer(i.RENDERBUFFER,A),y.depthBuffer){let Y=y.depthTexture,j=Y&&Y.isDepthTexture?Y.type:null,ee=E(y.stencilBuffer,j),oe=y.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;qe(y)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,At(y),ee,y.width,y.height):O?i.renderbufferStorageMultisample(i.RENDERBUFFER,At(y),ee,y.width,y.height):i.renderbufferStorage(i.RENDERBUFFER,ee,y.width,y.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,oe,i.RENDERBUFFER,A)}else{let Y=y.textures;for(let j=0;j<Y.length;j++){let ee=Y[j],oe=r.convert(ee.format,ee.colorSpace),X=r.convert(ee.type),Z=M(ee.internalFormat,oe,X,ee.normalized,ee.colorSpace);qe(y)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,At(y),Z,y.width,y.height):O?i.renderbufferStorageMultisample(i.RENDERBUFFER,At(y),Z,y.width,y.height):i.renderbufferStorage(i.RENDERBUFFER,Z,y.width,y.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Xe(A,y,O){let Y=y.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(i.FRAMEBUFFER,A),!(y.depthTexture&&y.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");let j=n.get(y.depthTexture);if(j.__renderTarget=y,(!j.__webglTexture||y.depthTexture.image.width!==y.width||y.depthTexture.image.height!==y.height)&&(y.depthTexture.image.width=y.width,y.depthTexture.image.height=y.height,y.depthTexture.needsUpdate=!0),Y){if(j.__webglInit===void 0&&(j.__webglInit=!0,y.depthTexture.addEventListener("dispose",C)),j.__webglTexture===void 0){j.__webglTexture=i.createTexture(),t.bindTexture(i.TEXTURE_CUBE_MAP,j.__webglTexture),ke(i.TEXTURE_CUBE_MAP,y.depthTexture);let fe=r.convert(y.depthTexture.format),xe=r.convert(y.depthTexture.type),se;y.depthTexture.format===Un?se=i.DEPTH_COMPONENT24:y.depthTexture.format===Ni&&(se=i.DEPTH24_STENCIL8);for(let te=0;te<6;te++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,se,y.width,y.height,0,fe,xe,null)}}else K(y.depthTexture,0);let ee=j.__webglTexture,oe=At(y),X=Y?i.TEXTURE_CUBE_MAP_POSITIVE_X+O:i.TEXTURE_2D,Z=y.depthTexture.format===Ni?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(y.depthTexture.format===Un)qe(y)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Z,X,ee,0,oe):i.framebufferTexture2D(i.FRAMEBUFFER,Z,X,ee,0);else if(y.depthTexture.format===Ni)qe(y)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Z,X,ee,0,oe):i.framebufferTexture2D(i.FRAMEBUFFER,Z,X,ee,0);else throw new Error("Unknown depthTexture format")}function et(A){let y=n.get(A),O=A.isWebGLCubeRenderTarget===!0;if(y.__boundDepthTexture!==A.depthTexture){let Y=A.depthTexture;if(y.__depthDisposeCallback&&y.__depthDisposeCallback(),Y){let j=()=>{delete y.__boundDepthTexture,delete y.__depthDisposeCallback,Y.removeEventListener("dispose",j)};Y.addEventListener("dispose",j),y.__depthDisposeCallback=j}y.__boundDepthTexture=Y}if(A.depthTexture&&!y.__autoAllocateDepthBuffer)if(O)for(let Y=0;Y<6;Y++)Xe(y.__webglFramebuffer[Y],A,Y);else{let Y=A.texture.mipmaps;Y&&Y.length>0?Xe(y.__webglFramebuffer[0],A,0):Xe(y.__webglFramebuffer,A,0)}else if(O){y.__webglDepthbuffer=[];for(let Y=0;Y<6;Y++)if(t.bindFramebuffer(i.FRAMEBUFFER,y.__webglFramebuffer[Y]),y.__webglDepthbuffer[Y]===void 0)y.__webglDepthbuffer[Y]=i.createRenderbuffer(),dt(y.__webglDepthbuffer[Y],A,!1);else{let j=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ee=y.__webglDepthbuffer[Y];i.bindRenderbuffer(i.RENDERBUFFER,ee),i.framebufferRenderbuffer(i.FRAMEBUFFER,j,i.RENDERBUFFER,ee)}}else{let Y=A.texture.mipmaps;if(Y&&Y.length>0?t.bindFramebuffer(i.FRAMEBUFFER,y.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,y.__webglFramebuffer),y.__webglDepthbuffer===void 0)y.__webglDepthbuffer=i.createRenderbuffer(),dt(y.__webglDepthbuffer,A,!1);else{let j=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ee=y.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,ee),i.framebufferRenderbuffer(i.FRAMEBUFFER,j,i.RENDERBUFFER,ee)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function lt(A,y,O){let Y=n.get(A);y!==void 0&&Pe(Y.__webglFramebuffer,A,A.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),O!==void 0&&et(A)}function He(A){let y=A.texture,O=n.get(A),Y=n.get(y);A.addEventListener("dispose",_);let j=A.textures,ee=A.isWebGLCubeRenderTarget===!0,oe=j.length>1;if(oe||(Y.__webglTexture===void 0&&(Y.__webglTexture=i.createTexture()),Y.__version=y.version,o.memory.textures++),ee){O.__webglFramebuffer=[];for(let X=0;X<6;X++)if(y.mipmaps&&y.mipmaps.length>0){O.__webglFramebuffer[X]=[];for(let Z=0;Z<y.mipmaps.length;Z++)O.__webglFramebuffer[X][Z]=i.createFramebuffer()}else O.__webglFramebuffer[X]=i.createFramebuffer()}else{if(y.mipmaps&&y.mipmaps.length>0){O.__webglFramebuffer=[];for(let X=0;X<y.mipmaps.length;X++)O.__webglFramebuffer[X]=i.createFramebuffer()}else O.__webglFramebuffer=i.createFramebuffer();if(oe)for(let X=0,Z=j.length;X<Z;X++){let fe=n.get(j[X]);fe.__webglTexture===void 0&&(fe.__webglTexture=i.createTexture(),o.memory.textures++)}if(A.samples>0&&qe(A)===!1){O.__webglMultisampledFramebuffer=i.createFramebuffer(),O.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,O.__webglMultisampledFramebuffer);for(let X=0;X<j.length;X++){let Z=j[X];O.__webglColorRenderbuffer[X]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,O.__webglColorRenderbuffer[X]);let fe=r.convert(Z.format,Z.colorSpace),xe=r.convert(Z.type),se=M(Z.internalFormat,fe,xe,Z.normalized,Z.colorSpace,A.isXRRenderTarget===!0),te=At(A);i.renderbufferStorageMultisample(i.RENDERBUFFER,te,se,A.width,A.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+X,i.RENDERBUFFER,O.__webglColorRenderbuffer[X])}i.bindRenderbuffer(i.RENDERBUFFER,null),A.depthBuffer&&(O.__webglDepthRenderbuffer=i.createRenderbuffer(),dt(O.__webglDepthRenderbuffer,A,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(ee){t.bindTexture(i.TEXTURE_CUBE_MAP,Y.__webglTexture),ke(i.TEXTURE_CUBE_MAP,y);for(let X=0;X<6;X++)if(y.mipmaps&&y.mipmaps.length>0)for(let Z=0;Z<y.mipmaps.length;Z++)Pe(O.__webglFramebuffer[X][Z],A,y,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+X,Z);else Pe(O.__webglFramebuffer[X],A,y,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+X,0);p(y)&&v(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(oe){for(let X=0,Z=j.length;X<Z;X++){let fe=j[X],xe=n.get(fe),se=i.TEXTURE_2D;(A.isWebGL3DRenderTarget||A.isWebGLArrayRenderTarget)&&(se=A.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(se,xe.__webglTexture),ke(se,fe),Pe(O.__webglFramebuffer,A,fe,i.COLOR_ATTACHMENT0+X,se,0),p(fe)&&v(se)}t.unbindTexture()}else{let X=i.TEXTURE_2D;if((A.isWebGL3DRenderTarget||A.isWebGLArrayRenderTarget)&&(X=A.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(X,Y.__webglTexture),ke(X,y),y.mipmaps&&y.mipmaps.length>0)for(let Z=0;Z<y.mipmaps.length;Z++)Pe(O.__webglFramebuffer[Z],A,y,i.COLOR_ATTACHMENT0,X,Z);else Pe(O.__webglFramebuffer,A,y,i.COLOR_ATTACHMENT0,X,0);p(y)&&v(X),t.unbindTexture()}A.depthBuffer&&et(A)}function Tt(A){let y=A.textures;for(let O=0,Y=y.length;O<Y;O++){let j=y[O];if(p(j)){let ee=b(A),oe=n.get(j).__webglTexture;t.bindTexture(ee,oe),v(ee),t.unbindTexture()}}}let ft=[],sn=[];function D(A){if(A.samples>0){if(qe(A)===!1){let y=A.textures,O=A.width,Y=A.height,j=i.COLOR_BUFFER_BIT,ee=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,oe=n.get(A),X=y.length>1;if(X)for(let fe=0;fe<y.length;fe++)t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+fe,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+fe,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,oe.__webglMultisampledFramebuffer);let Z=A.texture.mipmaps;Z&&Z.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,oe.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,oe.__webglFramebuffer);for(let fe=0;fe<y.length;fe++){if(A.resolveDepthBuffer&&(A.depthBuffer&&(j|=i.DEPTH_BUFFER_BIT),A.stencilBuffer&&A.resolveStencilBuffer&&(j|=i.STENCIL_BUFFER_BIT)),X){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,oe.__webglColorRenderbuffer[fe]);let xe=n.get(y[fe]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,xe,0)}i.blitFramebuffer(0,0,O,Y,0,0,O,Y,j,i.NEAREST),l===!0&&(ft.length=0,sn.length=0,ft.push(i.COLOR_ATTACHMENT0+fe),A.depthBuffer&&A.resolveDepthBuffer===!1&&(ft.push(ee),sn.push(ee),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,sn)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,ft))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),X)for(let fe=0;fe<y.length;fe++){t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+fe,i.RENDERBUFFER,oe.__webglColorRenderbuffer[fe]);let xe=n.get(y[fe]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+fe,i.TEXTURE_2D,xe,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,oe.__webglMultisampledFramebuffer)}else if(A.depthBuffer&&A.resolveDepthBuffer===!1&&l){let y=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[y])}}}function At(A){return Math.min(s.maxSamples,A.samples)}function qe(A){let y=n.get(A);return A.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&y.__useRenderToTexture!==!1}function ot(A){let y=o.render.frame;u.get(A)!==y&&(u.set(A,y),A.update())}function le(A,y){let O=A.colorSpace,Y=A.format,j=A.type;return A.isCompressedTexture===!0||A.isVideoTexture===!0||O!==nr&&O!==ri&&(ze.getTransfer(O)===Je?(Y!==bn||j!==pn)&&Te("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Re("WebGLTextures: Unsupported texture color space:",O)),y}function pt(A){return typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement?(c.width=A.naturalWidth||A.width,c.height=A.naturalHeight||A.height):typeof VideoFrame<"u"&&A instanceof VideoFrame?(c.width=A.displayWidth,c.height=A.displayHeight):(c.width=A.width,c.height=A.height),c}this.allocateTextureUnit=z,this.resetTextureUnits=H,this.getTextureUnits=W,this.setTextureUnits=k,this.setTexture2D=K,this.setTexture2DArray=Q,this.setTexture3D=ae,this.setTextureCube=_e,this.rebindTextures=lt,this.setupRenderTarget=He,this.updateRenderTargetMipmap=Tt,this.updateMultisampleRenderTarget=D,this.setupDepthRenderbuffer=et,this.setupFrameBufferTexture=Pe,this.useMultisampledRTT=qe,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function J_(i,e){function t(n,s=ri){let r,o=ze.getTransfer(s);if(n===pn)return i.UNSIGNED_BYTE;if(n===xa)return i.UNSIGNED_SHORT_4_4_4_4;if(n===va)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Wc)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Xc)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===Gc)return i.BYTE;if(n===Hc)return i.SHORT;if(n===Rs)return i.UNSIGNED_SHORT;if(n===ga)return i.INT;if(n===Rn)return i.UNSIGNED_INT;if(n===Pn)return i.FLOAT;if(n===qt)return i.HALF_FLOAT;if(n===qc)return i.ALPHA;if(n===Yc)return i.RGB;if(n===bn)return i.RGBA;if(n===Un)return i.DEPTH_COMPONENT;if(n===Ni)return i.DEPTH_STENCIL;if(n===Zc)return i.RED;if(n===_a)return i.RED_INTEGER;if(n===Di)return i.RG;if(n===ya)return i.RG_INTEGER;if(n===ba)return i.RGBA_INTEGER;if(n===Cr||n===Rr||n===Pr||n===Ir)if(o===Je)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Cr)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Rr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Pr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Ir)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Cr)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Rr)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Pr)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Ir)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Ma||n===Sa||n===wa||n===Ea)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Ma)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Sa)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===wa)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Ea)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Ta||n===Aa||n===Ca||n===Ra||n===Pa||n===Lr||n===Ia)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Ta||n===Aa)return o===Je?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Ca)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===Ra)return r.COMPRESSED_R11_EAC;if(n===Pa)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Lr)return r.COMPRESSED_RG11_EAC;if(n===Ia)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===La||n===Na||n===Da||n===Fa||n===ka||n===Oa||n===Ua||n===Ba||n===za||n===Va||n===Ga||n===Ha||n===Wa||n===Xa)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===La)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Na)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Da)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Fa)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===ka)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Oa)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Ua)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Ba)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===za)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Va)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Ga)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Ha)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Wa)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Xa)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===qa||n===Ya||n===Za)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===qa)return o===Je?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Ya)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Za)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===$a||n===Ka||n===Nr||n===Ja)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===$a)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Ka)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Nr)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Ja)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ps?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}var j_=`
void main() {
gl_Position = vec4( position, 1.0 );
}`,Q_=`
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;
}
}`,Mh=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new dr(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:j_,fragmentShader:Q_,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Xt(new fr(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Sh=class extends An{constructor(e,t){super();let n=this,s=null,r=1,o=null,a="local-floor",l=1,c=null,u=null,d=null,h=null,f=null,g=null,x=typeof XRWebGLBinding<"u",m=new Mh,p={},v=t.getContextAttributes(),b=null,M=null,E=[],w=[],C=new Ee,_=null,T=new Wt;T.viewport=new xt;let P=new Wt;P.viewport=new xt;let R=[T,P],I=new ha,H=null,W=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function($){let de=E[$];return de===void 0&&(de=new Es,E[$]=de),de.getTargetRaySpace()},this.getControllerGrip=function($){let de=E[$];return de===void 0&&(de=new Es,E[$]=de),de.getGripSpace()},this.getHand=function($){let de=E[$];return de===void 0&&(de=new Es,E[$]=de),de.getHandSpace()};function k($){let de=w.indexOf($.inputSource);if(de===-1)return;let ie=E[de];ie!==void 0&&(ie.update($.inputSource,$.frame,c||o),ie.dispatchEvent({type:$.type,data:$.inputSource}))}function z(){s.removeEventListener("select",k),s.removeEventListener("selectstart",k),s.removeEventListener("selectend",k),s.removeEventListener("squeeze",k),s.removeEventListener("squeezestart",k),s.removeEventListener("squeezeend",k),s.removeEventListener("end",z),s.removeEventListener("inputsourceschange",V);for(let $=0;$<E.length;$++){let de=w[$];de!==null&&(w[$]=null,E[$].disconnect(de))}H=null,W=null,m.reset();for(let $ in p)delete p[$];e.setRenderTarget(b),f=null,h=null,d=null,s=null,M=null,ke.stop(),n.isPresenting=!1,e.setPixelRatio(_),e.setSize(C.width,C.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function($){r=$,n.isPresenting===!0&&Te("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function($){a=$,n.isPresenting===!0&&Te("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function($){c=$},this.getBaseLayer=function(){return h!==null?h:f},this.getBinding=function(){return d===null&&x&&(d=new XRWebGLBinding(s,t)),d},this.getFrame=function(){return g},this.getSession=function(){return s},this.setSession=async function($){if(s=$,s!==null){if(b=e.getRenderTarget(),s.addEventListener("select",k),s.addEventListener("selectstart",k),s.addEventListener("selectend",k),s.addEventListener("squeeze",k),s.addEventListener("squeezestart",k),s.addEventListener("squeezeend",k),s.addEventListener("end",z),s.addEventListener("inputsourceschange",V),v.xrCompatible!==!0&&await t.makeXRCompatible(),_=e.getPixelRatio(),e.getSize(C),x&&"createProjectionLayer"in XRWebGLBinding.prototype){let ie=null,Ae=null,Ne=null;v.depth&&(Ne=v.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ie=v.stencil?Ni:Un,Ae=v.stencil?Ps:Rn);let Pe={colorFormat:t.RGBA8,depthFormat:Ne,scaleFactor:r};d=this.getBinding(),h=d.createProjectionLayer(Pe),s.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),M=new Rt(h.textureWidth,h.textureHeight,{format:bn,type:pn,depthTexture:new ii(h.textureWidth,h.textureHeight,Ae,void 0,void 0,void 0,void 0,void 0,void 0,ie),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:v.antialias?4:0,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1})}else{let ie={antialias:v.antialias,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(s,t,ie),s.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),M=new Rt(f.framebufferWidth,f.framebufferHeight,{format:bn,type:pn,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),ke.setContext(s),ke.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function V($){for(let de=0;de<$.removed.length;de++){let ie=$.removed[de],Ae=w.indexOf(ie);Ae>=0&&(w[Ae]=null,E[Ae].disconnect(ie))}for(let de=0;de<$.added.length;de++){let ie=$.added[de],Ae=w.indexOf(ie);if(Ae===-1){for(let Pe=0;Pe<E.length;Pe++)if(Pe>=w.length){w.push(ie),Ae=Pe;break}else if(w[Pe]===null){w[Pe]=ie,Ae=Pe;break}if(Ae===-1)break}let Ne=E[Ae];Ne&&Ne.connect(ie)}}let K=new N,Q=new N;function ae($,de,ie){K.setFromMatrixPosition(de.matrixWorld),Q.setFromMatrixPosition(ie.matrixWorld);let Ae=K.distanceTo(Q),Ne=de.projectionMatrix.elements,Pe=ie.projectionMatrix.elements,dt=Ne[14]/(Ne[10]-1),Xe=Ne[14]/(Ne[10]+1),et=(Ne[9]+1)/Ne[5],lt=(Ne[9]-1)/Ne[5],He=(Ne[8]-1)/Ne[0],Tt=(Pe[8]+1)/Pe[0],ft=dt*He,sn=dt*Tt,D=Ae/(-He+Tt),At=D*-He;if(de.matrixWorld.decompose($.position,$.quaternion,$.scale),$.translateX(At),$.translateZ(D),$.matrixWorld.compose($.position,$.quaternion,$.scale),$.matrixWorldInverse.copy($.matrixWorld).invert(),Ne[10]===-1)$.projectionMatrix.copy(de.projectionMatrix),$.projectionMatrixInverse.copy(de.projectionMatrixInverse);else{let qe=dt+D,ot=Xe+D,le=ft-At,pt=sn+(Ae-At),A=et*Xe/ot*qe,y=lt*Xe/ot*qe;$.projectionMatrix.makePerspective(le,pt,A,y,qe,ot),$.projectionMatrixInverse.copy($.projectionMatrix).invert()}}function _e($,de){de===null?$.matrixWorld.copy($.matrix):$.matrixWorld.multiplyMatrices(de.matrixWorld,$.matrix),$.matrixWorldInverse.copy($.matrixWorld).invert()}this.updateCamera=function($){if(s===null)return;let de=$.near,ie=$.far;m.texture!==null&&(m.depthNear>0&&(de=m.depthNear),m.depthFar>0&&(ie=m.depthFar)),I.near=P.near=T.near=de,I.far=P.far=T.far=ie,(H!==I.near||W!==I.far)&&(s.updateRenderState({depthNear:I.near,depthFar:I.far}),H=I.near,W=I.far),I.layers.mask=$.layers.mask|6,T.layers.mask=I.layers.mask&-5,P.layers.mask=I.layers.mask&-3;let Ae=$.parent,Ne=I.cameras;_e(I,Ae);for(let Pe=0;Pe<Ne.length;Pe++)_e(Ne[Pe],Ae);Ne.length===2?ae(I,T,P):I.projectionMatrix.copy(T.projectionMatrix),be($,I,Ae)};function be($,de,ie){ie===null?$.matrix.copy(de.matrixWorld):($.matrix.copy(ie.matrixWorld),$.matrix.invert(),$.matrix.multiply(de.matrixWorld)),$.matrix.decompose($.position,$.quaternion,$.scale),$.updateMatrixWorld(!0),$.projectionMatrix.copy(de.projectionMatrix),$.projectionMatrixInverse.copy(de.projectionMatrixInverse),$.isPerspectiveCamera&&($.fov=Ss*2*Math.atan(1/$.projectionMatrix.elements[5]),$.zoom=1)}this.getCamera=function(){return I},this.getFoveation=function(){if(!(h===null&&f===null))return l},this.setFoveation=function($){l=$,h!==null&&(h.fixedFoveation=$),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=$)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(I)},this.getCameraTexture=function($){return p[$]};let We=null;function Qe($,de){if(u=de.getViewerPose(c||o),g=de,u!==null){let ie=u.views;f!==null&&(e.setRenderTargetFramebuffer(M,f.framebuffer),e.setRenderTarget(M));let Ae=!1;ie.length!==I.cameras.length&&(I.cameras.length=0,Ae=!0);for(let Xe=0;Xe<ie.length;Xe++){let et=ie[Xe],lt=null;if(f!==null)lt=f.getViewport(et);else{let Tt=d.getViewSubImage(h,et);lt=Tt.viewport,Xe===0&&(e.setRenderTargetTextures(M,Tt.colorTexture,Tt.depthStencilTexture),e.setRenderTarget(M))}let He=R[Xe];He===void 0&&(He=new Wt,He.layers.enable(Xe),He.viewport=new xt,R[Xe]=He),He.matrix.fromArray(et.transform.matrix),He.matrix.decompose(He.position,He.quaternion,He.scale),He.projectionMatrix.fromArray(et.projectionMatrix),He.projectionMatrixInverse.copy(He.projectionMatrix).invert(),He.viewport.set(lt.x,lt.y,lt.width,lt.height),Xe===0&&(I.matrix.copy(He.matrix),I.matrix.decompose(I.position,I.quaternion,I.scale)),Ae===!0&&I.cameras.push(He)}let Ne=s.enabledFeatures;if(Ne&&Ne.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&x){d=n.getBinding();let Xe=d.getDepthInformation(ie[0]);Xe&&Xe.isValid&&Xe.texture&&m.init(Xe,s.renderState)}if(Ne&&Ne.includes("camera-access")&&x){e.state.unbindTexture(),d=n.getBinding();for(let Xe=0;Xe<ie.length;Xe++){let et=ie[Xe].camera;if(et){let lt=p[et];lt||(lt=new dr,p[et]=lt);let He=d.getCameraImage(et);lt.sourceTexture=He}}}}for(let ie=0;ie<E.length;ie++){let Ae=w[ie],Ne=E[ie];Ae!==null&&Ne!==void 0&&Ne.update(Ae,de,c||o)}We&&We($,de),de.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:de}),g=null}let ke=new qd;ke.setAnimationLoop(Qe),this.setAnimationLoop=function($){We=$},this.dispose=function(){}}},ey=new gt,jd=new Le;jd.set(-1,0,0,0,1,0,0,0,1);function ty(i,e){function t(m,p){m.matrixAutoUpdate===!0&&m.updateMatrix(),p.value.copy(m.matrix)}function n(m,p){p.color.getRGB(m.fogColor.value,eh(i)),p.isFog?(m.fogNear.value=p.near,m.fogFar.value=p.far):p.isFogExp2&&(m.fogDensity.value=p.density)}function s(m,p,v,b,M){p.isNodeMaterial?p.uniformsNeedUpdate=!1:p.isMeshBasicMaterial?r(m,p):p.isMeshLambertMaterial?(r(m,p),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)):p.isMeshToonMaterial?(r(m,p),d(m,p)):p.isMeshPhongMaterial?(r(m,p),u(m,p),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)):p.isMeshStandardMaterial?(r(m,p),h(m,p),p.isMeshPhysicalMaterial&&f(m,p,M)):p.isMeshMatcapMaterial?(r(m,p),g(m,p)):p.isMeshDepthMaterial?r(m,p):p.isMeshDistanceMaterial?(r(m,p),x(m,p)):p.isMeshNormalMaterial?r(m,p):p.isLineBasicMaterial?(o(m,p),p.isLineDashedMaterial&&a(m,p)):p.isPointsMaterial?l(m,p,v,b):p.isSpriteMaterial?c(m,p):p.isShadowMaterial?(m.color.value.copy(p.color),m.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function r(m,p){m.opacity.value=p.opacity,p.color&&m.diffuse.value.copy(p.color),p.emissive&&m.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.bumpMap&&(m.bumpMap.value=p.bumpMap,t(p.bumpMap,m.bumpMapTransform),m.bumpScale.value=p.bumpScale,p.side===$t&&(m.bumpScale.value*=-1)),p.normalMap&&(m.normalMap.value=p.normalMap,t(p.normalMap,m.normalMapTransform),m.normalScale.value.copy(p.normalScale),p.side===$t&&m.normalScale.value.negate()),p.displacementMap&&(m.displacementMap.value=p.displacementMap,t(p.displacementMap,m.displacementMapTransform),m.displacementScale.value=p.displacementScale,m.displacementBias.value=p.displacementBias),p.emissiveMap&&(m.emissiveMap.value=p.emissiveMap,t(p.emissiveMap,m.emissiveMapTransform)),p.specularMap&&(m.specularMap.value=p.specularMap,t(p.specularMap,m.specularMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest);let v=e.get(p),b=v.envMap,M=v.envMapRotation;b&&(m.envMap.value=b,m.envMapRotation.value.setFromMatrix4(ey.makeRotationFromEuler(M)).transpose(),b.isCubeTexture&&b.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(jd),m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio),p.lightMap&&(m.lightMap.value=p.lightMap,m.lightMapIntensity.value=p.lightMapIntensity,t(p.lightMap,m.lightMapTransform)),p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,m.aoMapTransform))}function o(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform))}function a(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function l(m,p,v,b){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*v,m.scale.value=b*.5,p.map&&(m.map.value=p.map,t(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function c(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.rotation.value=p.rotation,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function u(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,1e-4)}function d(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function h(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,m.roughnessMapTransform)),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function f(m,p,v){m.ior.value=p.ior,p.sheen>0&&(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(m.sheenColorMap.value=p.sheenColorMap,t(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===$t&&m.clearcoatNormalScale.value.negate())),p.dispersion>0&&(m.dispersion.value=p.dispersion),p.iridescence>0&&(m.iridescence.value=p.iridescence,m.iridescenceIOR.value=p.iridescenceIOR,m.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(m.iridescenceMap.value=p.iridescenceMap,t(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=v.texture,m.transmissionSamplerSize.value.set(v.width,v.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,t(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,t(p.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=p.attenuationDistance,m.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(m.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(m.anisotropyMap.value=p.anisotropyMap,t(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,p){p.matcap&&(m.matcap.value=p.matcap)}function x(m,p){let v=e.get(p).light;m.referencePosition.value.setFromMatrixPosition(v.matrixWorld),m.nearDistance.value=v.shadow.camera.near,m.farDistance.value=v.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function ny(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&&(g(v),M=u(v),s[v.id]=M,v.addEventListener("dispose",m));let E=b.program;n.updateUBOMapping(v,E);let w=e.render.frame;r[v.id]!==w&&(h(v),r[v.id]=w)}function u(v){let b=d();v.__bindingPointIndex=b;let M=i.createBuffer(),E=v.__size,w=v.usage;return i.bindBuffer(i.UNIFORM_BUFFER,M),i.bufferData(i.UNIFORM_BUFFER,E,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 Re("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function h(v){let b=s[v.id],M=v.uniforms,E=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 T=0,P=_.length;T<P;T++){let R=_[T];if(f(R,w,T,E)===!0){let I=R.__offset,H=Array.isArray(R.value)?R.value:[R.value],W=0;for(let k=0;k<H.length;k++){let z=H[k],V=x(z);typeof z=="number"||typeof z=="boolean"?(R.__data[0]=z,i.bufferSubData(i.UNIFORM_BUFFER,I+W,R.__data)):z.isMatrix3?(R.__data[0]=z.elements[0],R.__data[1]=z.elements[1],R.__data[2]=z.elements[2],R.__data[3]=0,R.__data[4]=z.elements[3],R.__data[5]=z.elements[4],R.__data[6]=z.elements[5],R.__data[7]=0,R.__data[8]=z.elements[6],R.__data[9]=z.elements[7],R.__data[10]=z.elements[8],R.__data[11]=0):ArrayBuffer.isView(z)?R.__data.set(new z.constructor(z.buffer,z.byteOffset,R.__data.length)):(z.toArray(R.__data,W),W+=V.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,I,R.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function f(v,b,M,E){let w=v.value,C=b+"_"+M;if(E[C]===void 0)return typeof w=="number"||typeof w=="boolean"?E[C]=w:ArrayBuffer.isView(w)?E[C]=w.slice():E[C]=w.clone(),!0;{let _=E[C];if(typeof w=="number"||typeof w=="boolean"){if(_!==w)return E[C]=w,!0}else{if(ArrayBuffer.isView(w))return!0;if(_.equals(w)===!1)return _.copy(w),!0}}return!1}function g(v){let b=v.uniforms,M=0,E=16;for(let C=0,_=b.length;C<_;C++){let T=Array.isArray(b[C])?b[C]:[b[C]];for(let P=0,R=T.length;P<R;P++){let I=T[P],H=Array.isArray(I.value)?I.value:[I.value];for(let W=0,k=H.length;W<k;W++){let z=H[W],V=x(z),K=M%E,Q=K%V.boundary,ae=K+Q;M+=Q,ae!==0&&E-ae<V.storage&&(M+=E-ae),I.__data=new Float32Array(V.storage/Float32Array.BYTES_PER_ELEMENT),I.__offset=M,M+=V.storage}}}let w=M%E;return w>0&&(M+=E-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 m(v){let b=v.target;b.removeEventListener("dispose",m);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 iy=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]),Vn=null;function sy(){return Vn===null&&(Vn=new qo(iy,16,16,Di,qt),Vn.name="DFG_LUT",Vn.minFilter=Bt,Vn.magFilter=Bt,Vn.wrapS=On,Vn.wrapT=On,Vn.generateMipmaps=!1,Vn.needsUpdate=!0),Vn}var Ds=class{constructor(e={}){let{canvas:t=vd(),context:n=null,depth:s=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:h=!1,outputBufferType:f=pn}=e;this.isWebGLRenderer=!0;let g;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=n.getContextAttributes().alpha}else g=o;let x=f,m=new Set([ba,ya,_a]),p=new Set([pn,Rn,Rs,Ps,xa,va]),v=new Uint32Array(4),b=new Int32Array(4),M=new N,E=null,w=null,C=[],_=[],T=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=fn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let P=this,R=!1,I=null;this._outputColorSpace=cn;let H=0,W=0,k=null,z=-1,V=null,K=new xt,Q=new xt,ae=null,_e=new me(0),be=0,We=t.width,Qe=t.height,ke=1,$=null,de=null,ie=new xt(0,0,We,Qe),Ae=new xt(0,0,We,Qe),Ne=!1,Pe=new hr,dt=!1,Xe=!1,et=new gt,lt=new N,He=new xt,Tt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},ft=!1;function sn(){return k===null?ke:1}let D=n;function At(S,F){return t.getContext(S,F)}try{let S={alpha:!0,depth:s,stencil:r,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${da}`),t.addEventListener("webglcontextlost",J,!1),t.addEventListener("webglcontextrestored",Me,!1),t.addEventListener("webglcontextcreationerror",De,!1),D===null){let F="webgl2";if(D=At(F,S),D===null)throw At(F)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(S){throw Re("WebGLRenderer: "+S.message),S}let qe,ot,le,pt,A,y,O,Y,j,ee,oe,X,Z,fe,xe,se,te,Ie,Oe,Ke,L,ne,q;function pe(){qe=new uv(D),qe.init(),L=new J_(D,qe),ot=new iv(D,qe,e,L),le=new $_(D,qe),ot.reversedDepthBuffer&&h&&le.buffers.depth.setReversed(!0),pt=new pv(D),A=new F_,y=new K_(D,qe,le,A,ot,L,pt),O=new hv(P),Y=new vg(D),ne=new tv(D,Y),j=new dv(D,Y,pt,ne),ee=new gv(D,j,Y,ne,pt),Ie=new mv(D,ot,y),xe=new sv(A),oe=new D_(P,O,qe,ot,ne,xe),X=new ty(P,A),Z=new O_,fe=new H_(qe),te=new ev(P,O,le,ee,g,l),se=new Z_(P,ee,ot),q=new ny(D,pt,ot,le),Oe=new nv(D,qe,pt),Ke=new fv(D,qe,pt),pt.programs=oe.programs,P.capabilities=ot,P.extensions=qe,P.properties=A,P.renderLists=Z,P.shadowMap=se,P.state=le,P.info=pt}pe(),x!==pn&&(T=new vv(x,t.width,t.height,s,r));let re=new Sh(P,D);this.xr=re,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){let S=qe.get("WEBGL_lose_context");S&&S.loseContext()},this.forceContextRestore=function(){let S=qe.get("WEBGL_lose_context");S&&S.restoreContext()},this.getPixelRatio=function(){return ke},this.setPixelRatio=function(S){S!==void 0&&(ke=S,this.setSize(We,Qe,!1))},this.getSize=function(S){return S.set(We,Qe)},this.setSize=function(S,F,G=!0){if(re.isPresenting){Te("WebGLRenderer: Can't change size while VR device is presenting.");return}We=S,Qe=F,t.width=Math.floor(S*ke),t.height=Math.floor(F*ke),G===!0&&(t.style.width=S+"px",t.style.height=F+"px"),T!==null&&T.setSize(t.width,t.height),this.setViewport(0,0,S,F)},this.getDrawingBufferSize=function(S){return S.set(We*ke,Qe*ke).floor()},this.setDrawingBufferSize=function(S,F,G){We=S,Qe=F,ke=G,t.width=Math.floor(S*G),t.height=Math.floor(F*G),this.setViewport(0,0,S,F)},this.setEffects=function(S){if(x===pn){Re("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(S){for(let F=0;F<S.length;F++)if(S[F].isOutputPass===!0){Te("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}T.setEffects(S||[])},this.getCurrentViewport=function(S){return S.copy(K)},this.getViewport=function(S){return S.copy(ie)},this.setViewport=function(S,F,G,U){S.isVector4?ie.set(S.x,S.y,S.z,S.w):ie.set(S,F,G,U),le.viewport(K.copy(ie).multiplyScalar(ke).round())},this.getScissor=function(S){return S.copy(Ae)},this.setScissor=function(S,F,G,U){S.isVector4?Ae.set(S.x,S.y,S.z,S.w):Ae.set(S,F,G,U),le.scissor(Q.copy(Ae).multiplyScalar(ke).round())},this.getScissorTest=function(){return Ne},this.setScissorTest=function(S){le.setScissorTest(Ne=S)},this.setOpaqueSort=function(S){$=S},this.setTransparentSort=function(S){de=S},this.getClearColor=function(S){return S.copy(te.getClearColor())},this.setClearColor=function(){te.setClearColor(...arguments)},this.getClearAlpha=function(){return te.getClearAlpha()},this.setClearAlpha=function(){te.setClearAlpha(...arguments)},this.clear=function(S=!0,F=!0,G=!0){let U=0;if(S){let B=!1;if(k!==null){let ue=k.texture.format;B=m.has(ue)}if(B){let ue=k.texture.type,ve=p.has(ue),he=te.getClearColor(),ye=te.getClearAlpha(),Se=he.r,Fe=he.g,Be=he.b;ve?(v[0]=Se,v[1]=Fe,v[2]=Be,v[3]=ye,D.clearBufferuiv(D.COLOR,0,v)):(b[0]=Se,b[1]=Fe,b[2]=Be,b[3]=ye,D.clearBufferiv(D.COLOR,0,b))}else U|=D.COLOR_BUFFER_BIT}F&&(U|=D.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),G&&(U|=D.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),U!==0&&D.clear(U)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(S){S.setRenderer(this),I=S},this.dispose=function(){t.removeEventListener("webglcontextlost",J,!1),t.removeEventListener("webglcontextrestored",Me,!1),t.removeEventListener("webglcontextcreationerror",De,!1),te.dispose(),Z.dispose(),fe.dispose(),A.dispose(),O.dispose(),ee.dispose(),ne.dispose(),q.dispose(),oe.dispose(),re.dispose(),re.removeEventListener("sessionstart",iu),re.removeEventListener("sessionend",su),Bi.stop()};function J(S){S.preventDefault(),Jc("WebGLRenderer: Context Lost."),R=!0}function Me(){Jc("WebGLRenderer: Context Restored."),R=!1;let S=pt.autoReset,F=se.enabled,G=se.autoUpdate,U=se.needsUpdate,B=se.type;pe(),pt.autoReset=S,se.enabled=F,se.autoUpdate=G,se.needsUpdate=U,se.type=B}function De(S){Re("WebGLRenderer: A WebGL context could not be created. Reason: ",S.statusMessage)}function yt(S){let F=S.target;F.removeEventListener("dispose",yt),tt(F)}function tt(S){Hn(S),A.remove(S)}function Hn(S){let F=A.get(S).programs;F!==void 0&&(F.forEach(function(G){oe.releaseProgram(G)}),S.isShaderMaterial&&oe.releaseShaderCache(S))}this.renderBufferDirect=function(S,F,G,U,B,ue){F===null&&(F=Tt);let ve=B.isMesh&&B.matrixWorld.determinant()<0,he=lm(S,F,G,U,B);le.setMaterial(U,ve);let ye=G.index,Se=1;if(U.wireframe===!0){if(ye=j.getWireframeAttribute(G),ye===void 0)return;Se=2}let Fe=G.drawRange,Be=G.attributes.position,we=Fe.start*Se,nt=(Fe.start+Fe.count)*Se;ue!==null&&(we=Math.max(we,ue.start*Se),nt=Math.min(nt,(ue.start+ue.count)*Se)),ye!==null?(we=Math.max(we,0),nt=Math.min(nt,ye.count)):Be!=null&&(we=Math.max(we,0),nt=Math.min(nt,Be.count));let bt=nt-we;if(bt<0||bt===1/0)return;ne.setup(B,U,he,G,ye);let mt,st=Oe;if(ye!==null&&(mt=Y.get(ye),st=Ke,st.setIndex(mt)),B.isMesh)U.wireframe===!0?(le.setLineWidth(U.wireframeLinewidth*sn()),st.setMode(D.LINES)):st.setMode(D.TRIANGLES);else if(B.isLine){let Vt=U.linewidth;Vt===void 0&&(Vt=1),le.setLineWidth(Vt*sn()),B.isLineSegments?st.setMode(D.LINES):B.isLineLoop?st.setMode(D.LINE_LOOP):st.setMode(D.LINE_STRIP)}else B.isPoints?st.setMode(D.POINTS):B.isSprite&&st.setMode(D.TRIANGLES);if(B.isBatchedMesh)if(qe.get("WEBGL_multi_draw"))st.renderMultiDraw(B._multiDrawStarts,B._multiDrawCounts,B._multiDrawCount);else{let Vt=B._multiDrawStarts,ge=B._multiDrawCounts,rn=B._multiDrawCount,$e=ye?Y.get(ye).bytesPerElement:1,gn=A.get(U).currentProgram.getUniforms();for(let Nn=0;Nn<rn;Nn++)gn.setValue(D,"_gl_DrawID",Nn),st.render(Vt[Nn]/$e,ge[Nn])}else if(B.isInstancedMesh)st.renderInstances(we,bt,B.count);else if(G.isInstancedBufferGeometry){let Vt=G._maxInstanceCount!==void 0?G._maxInstanceCount:1/0,ge=Math.min(G.instanceCount,Vt);st.renderInstances(we,bt,ge)}else st.render(we,bt)};function Ln(S,F,G){S.transparent===!0&&S.side===zn&&S.forceSinglePass===!1?(S.side=$t,S.needsUpdate=!0,Kr(S,F,G),S.side=Qn,S.needsUpdate=!0,Kr(S,F,G),S.side=zn):Kr(S,F,G)}this.compile=function(S,F,G=null){G===null&&(G=S),w=fe.get(G),w.init(F),_.push(w),G.traverseVisible(function(B){B.isLight&&B.layers.test(F.layers)&&(w.pushLight(B),B.castShadow&&w.pushShadow(B))}),S!==G&&S.traverseVisible(function(B){B.isLight&&B.layers.test(F.layers)&&(w.pushLight(B),B.castShadow&&w.pushShadow(B))}),w.setupLights();let U=new Set;return S.traverse(function(B){if(!(B.isMesh||B.isPoints||B.isLine||B.isSprite))return;let ue=B.material;if(ue)if(Array.isArray(ue))for(let ve=0;ve<ue.length;ve++){let he=ue[ve];Ln(he,G,B),U.add(he)}else Ln(ue,G,B),U.add(ue)}),w=_.pop(),U},this.compileAsync=function(S,F,G=null){let U=this.compile(S,F,G);return new Promise(B=>{function ue(){if(U.forEach(function(ve){A.get(ve).currentProgram.isReady()&&U.delete(ve)}),U.size===0){B(S);return}setTimeout(ue,10)}qe.get("KHR_parallel_shader_compile")!==null?ue():setTimeout(ue,10)})};let jl=null;function om(S){jl&&jl(S)}function iu(){Bi.stop()}function su(){Bi.start()}let Bi=new qd;Bi.setAnimationLoop(om),typeof self<"u"&&Bi.setContext(self),this.setAnimationLoop=function(S){jl=S,re.setAnimationLoop(S),S===null?Bi.stop():Bi.start()},re.addEventListener("sessionstart",iu),re.addEventListener("sessionend",su),this.render=function(S,F){if(F!==void 0&&F.isCamera!==!0){Re("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(R===!0)return;I!==null&&I.renderStart(S,F);let G=re.enabled===!0&&re.isPresenting===!0,U=T!==null&&(k===null||G)&&T.begin(P,k);if(S.matrixWorldAutoUpdate===!0&&S.updateMatrixWorld(),F.parent===null&&F.matrixWorldAutoUpdate===!0&&F.updateMatrixWorld(),re.enabled===!0&&re.isPresenting===!0&&(T===null||T.isCompositing()===!1)&&(re.cameraAutoUpdate===!0&&re.updateCamera(F),F=re.getCamera()),S.isScene===!0&&S.onBeforeRender(P,S,F,k),w=fe.get(S,_.length),w.init(F),w.state.textureUnits=y.getTextureUnits(),_.push(w),et.multiplyMatrices(F.projectionMatrix,F.matrixWorldInverse),Pe.setFromProjectionMatrix(et,Tn,F.reversedDepth),Xe=this.localClippingEnabled,dt=xe.init(this.clippingPlanes,Xe),E=Z.get(S,C.length),E.init(),C.push(E),re.enabled===!0&&re.isPresenting===!0){let ve=P.xr.getDepthSensingMesh();ve!==null&&Ql(ve,F,-1/0,P.sortObjects)}Ql(S,F,0,P.sortObjects),E.finish(),P.sortObjects===!0&&E.sort($,de),ft=re.enabled===!1||re.isPresenting===!1||re.hasDepthSensing()===!1,ft&&te.addToRenderList(E,S),this.info.render.frame++,dt===!0&&xe.beginShadows();let B=w.state.shadowsArray;if(se.render(B,S,F),dt===!0&&xe.endShadows(),this.info.autoReset===!0&&this.info.reset(),(U&&T.hasRenderPass())===!1){let ve=E.opaque,he=E.transmissive;if(w.setupLights(),F.isArrayCamera){let ye=F.cameras;if(he.length>0)for(let Se=0,Fe=ye.length;Se<Fe;Se++){let Be=ye[Se];ou(ve,he,S,Be)}ft&&te.render(S);for(let Se=0,Fe=ye.length;Se<Fe;Se++){let Be=ye[Se];ru(E,S,Be,Be.viewport)}}else he.length>0&&ou(ve,he,S,F),ft&&te.render(S),ru(E,S,F)}k!==null&&W===0&&(y.updateMultisampleRenderTarget(k),y.updateRenderTargetMipmap(k)),U&&T.end(P),S.isScene===!0&&S.onAfterRender(P,S,F),ne.resetDefaultState(),z=-1,V=null,_.pop(),_.length>0?(w=_[_.length-1],y.setTextureUnits(w.state.textureUnits),dt===!0&&xe.setGlobalState(P.clippingPlanes,w.state.camera)):w=null,C.pop(),C.length>0?E=C[C.length-1]:E=null,I!==null&&I.renderEnd()};function Ql(S,F,G,U){if(S.visible===!1)return;if(S.layers.test(F.layers)){if(S.isGroup)G=S.renderOrder;else if(S.isLOD)S.autoUpdate===!0&&S.update(F);else if(S.isLightProbeGrid)w.pushLightProbeGrid(S);else if(S.isLight)w.pushLight(S),S.castShadow&&w.pushShadow(S);else if(S.isSprite){if(!S.frustumCulled||Pe.intersectsSprite(S)){U&&He.setFromMatrixPosition(S.matrixWorld).applyMatrix4(et);let ve=ee.update(S),he=S.material;he.visible&&E.push(S,ve,he,G,He.z,null)}}else if((S.isMesh||S.isLine||S.isPoints)&&(!S.frustumCulled||Pe.intersectsObject(S))){let ve=ee.update(S),he=S.material;if(U&&(S.boundingSphere!==void 0?(S.boundingSphere===null&&S.computeBoundingSphere(),He.copy(S.boundingSphere.center)):(ve.boundingSphere===null&&ve.computeBoundingSphere(),He.copy(ve.boundingSphere.center)),He.applyMatrix4(S.matrixWorld).applyMatrix4(et)),Array.isArray(he)){let ye=ve.groups;for(let Se=0,Fe=ye.length;Se<Fe;Se++){let Be=ye[Se],we=he[Be.materialIndex];we&&we.visible&&E.push(S,ve,we,G,He.z,Be)}}else he.visible&&E.push(S,ve,he,G,He.z,null)}}let ue=S.children;for(let ve=0,he=ue.length;ve<he;ve++)Ql(ue[ve],F,G,U)}function ru(S,F,G,U){let{opaque:B,transmissive:ue,transparent:ve}=S;w.setupLightsView(G),dt===!0&&xe.setGlobalState(P.clippingPlanes,G),U&&le.viewport(K.copy(U)),B.length>0&&$r(B,F,G),ue.length>0&&$r(ue,F,G),ve.length>0&&$r(ve,F,G),le.buffers.depth.setTest(!0),le.buffers.depth.setMask(!0),le.buffers.color.setMask(!0),le.setPolygonOffset(!1)}function ou(S,F,G,U){if((G.isScene===!0?G.overrideMaterial:null)!==null)return;if(w.state.transmissionRenderTarget[U.id]===void 0){let we=qe.has("EXT_color_buffer_half_float")||qe.has("EXT_color_buffer_float");w.state.transmissionRenderTarget[U.id]=new Rt(1,1,{generateMipmaps:!0,type:we?qt:pn,minFilter:Li,samples:Math.max(4,ot.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ze.workingColorSpace})}let ue=w.state.transmissionRenderTarget[U.id],ve=U.viewport||K;ue.setSize(ve.z*P.transmissionResolutionScale,ve.w*P.transmissionResolutionScale);let he=P.getRenderTarget(),ye=P.getActiveCubeFace(),Se=P.getActiveMipmapLevel();P.setRenderTarget(ue),P.getClearColor(_e),be=P.getClearAlpha(),be<1&&P.setClearColor(16777215,.5),P.clear(),ft&&te.render(G);let Fe=P.toneMapping;P.toneMapping=fn;let Be=U.viewport;if(U.viewport!==void 0&&(U.viewport=void 0),w.setupLightsView(U),dt===!0&&xe.setGlobalState(P.clippingPlanes,U),$r(S,G,U),y.updateMultisampleRenderTarget(ue),y.updateRenderTargetMipmap(ue),qe.has("WEBGL_multisampled_render_to_texture")===!1){let we=!1;for(let nt=0,bt=F.length;nt<bt;nt++){let mt=F[nt],{object:st,geometry:Vt,material:ge,group:rn}=mt;if(ge.side===zn&&st.layers.test(U.layers)){let $e=ge.side;ge.side=$t,ge.needsUpdate=!0,au(st,G,U,Vt,ge,rn),ge.side=$e,ge.needsUpdate=!0,we=!0}}we===!0&&(y.updateMultisampleRenderTarget(ue),y.updateRenderTargetMipmap(ue))}P.setRenderTarget(he,ye,Se),P.setClearColor(_e,be),Be!==void 0&&(U.viewport=Be),P.toneMapping=Fe}function $r(S,F,G){let U=F.isScene===!0?F.overrideMaterial:null;for(let B=0,ue=S.length;B<ue;B++){let ve=S[B],{object:he,geometry:ye,group:Se}=ve,Fe=ve.material;Fe.allowOverride===!0&&U!==null&&(Fe=U),he.layers.test(G.layers)&&au(he,F,G,ye,Fe,Se)}}function au(S,F,G,U,B,ue){S.onBeforeRender(P,F,G,U,B,ue),S.modelViewMatrix.multiplyMatrices(G.matrixWorldInverse,S.matrixWorld),S.normalMatrix.getNormalMatrix(S.modelViewMatrix),B.onBeforeRender(P,F,G,U,S,ue),B.transparent===!0&&B.side===zn&&B.forceSinglePass===!1?(B.side=$t,B.needsUpdate=!0,P.renderBufferDirect(G,F,U,B,S,ue),B.side=Qn,B.needsUpdate=!0,P.renderBufferDirect(G,F,U,B,S,ue),B.side=zn):P.renderBufferDirect(G,F,U,B,S,ue),S.onAfterRender(P,F,G,U,B,ue)}function Kr(S,F,G){F.isScene!==!0&&(F=Tt);let U=A.get(S),B=w.state.lights,ue=w.state.shadowsArray,ve=B.state.version,he=oe.getParameters(S,B.state,ue,F,G,w.state.lightProbeGridArray),ye=oe.getProgramCacheKey(he),Se=U.programs;U.environment=S.isMeshStandardMaterial||S.isMeshLambertMaterial||S.isMeshPhongMaterial?F.environment:null,U.fog=F.fog;let Fe=S.isMeshStandardMaterial||S.isMeshLambertMaterial&&!S.envMap||S.isMeshPhongMaterial&&!S.envMap;U.envMap=O.get(S.envMap||U.environment,Fe),U.envMapRotation=U.environment!==null&&S.envMap===null?F.environmentRotation:S.envMapRotation,Se===void 0&&(S.addEventListener("dispose",yt),Se=new Map,U.programs=Se);let Be=Se.get(ye);if(Be!==void 0){if(U.currentProgram===Be&&U.lightsStateVersion===ve)return cu(S,he),Be}else he.uniforms=oe.getUniforms(S),I!==null&&S.isNodeMaterial&&I.build(S,G,he),S.onBeforeCompile(he,P),Be=oe.acquireProgram(he,ye),Se.set(ye,Be),U.uniforms=he.uniforms;let we=U.uniforms;return(!S.isShaderMaterial&&!S.isRawShaderMaterial||S.clipping===!0)&&(we.clippingPlanes=xe.uniform),cu(S,he),U.needsLights=hm(S),U.lightsStateVersion=ve,U.needsLights&&(we.ambientLightColor.value=B.state.ambient,we.lightProbe.value=B.state.probe,we.directionalLights.value=B.state.directional,we.directionalLightShadows.value=B.state.directionalShadow,we.spotLights.value=B.state.spot,we.spotLightShadows.value=B.state.spotShadow,we.rectAreaLights.value=B.state.rectArea,we.ltc_1.value=B.state.rectAreaLTC1,we.ltc_2.value=B.state.rectAreaLTC2,we.pointLights.value=B.state.point,we.pointLightShadows.value=B.state.pointShadow,we.hemisphereLights.value=B.state.hemi,we.directionalShadowMatrix.value=B.state.directionalShadowMatrix,we.spotLightMatrix.value=B.state.spotLightMatrix,we.spotLightMap.value=B.state.spotLightMap,we.pointShadowMatrix.value=B.state.pointShadowMatrix),U.lightProbeGrid=w.state.lightProbeGridArray.length>0,U.currentProgram=Be,U.uniformsList=null,Be}function lu(S){if(S.uniformsList===null){let F=S.currentProgram.getUniforms();S.uniformsList=Ns.seqWithValue(F.seq,S.uniforms)}return S.uniformsList}function cu(S,F){let G=A.get(S);G.outputColorSpace=F.outputColorSpace,G.batching=F.batching,G.batchingColor=F.batchingColor,G.instancing=F.instancing,G.instancingColor=F.instancingColor,G.instancingMorph=F.instancingMorph,G.skinning=F.skinning,G.morphTargets=F.morphTargets,G.morphNormals=F.morphNormals,G.morphColors=F.morphColors,G.morphTargetsCount=F.morphTargetsCount,G.numClippingPlanes=F.numClippingPlanes,G.numIntersection=F.numClipIntersection,G.vertexAlphas=F.vertexAlphas,G.vertexTangents=F.vertexTangents,G.toneMapping=F.toneMapping}function am(S,F){if(S.length===0)return null;if(S.length===1)return S[0].texture!==null?S[0]:null;M.setFromMatrixPosition(F.matrixWorld);for(let G=0,U=S.length;G<U;G++){let B=S[G];if(B.texture!==null&&B.boundingBox.containsPoint(M))return B}return null}function lm(S,F,G,U,B){F.isScene!==!0&&(F=Tt),y.resetTextureUnits();let ue=F.fog,ve=U.isMeshStandardMaterial||U.isMeshLambertMaterial||U.isMeshPhongMaterial?F.environment:null,he=k===null?P.outputColorSpace:k.isXRRenderTarget===!0?k.texture.colorSpace:ze.workingColorSpace,ye=U.isMeshStandardMaterial||U.isMeshLambertMaterial&&!U.envMap||U.isMeshPhongMaterial&&!U.envMap,Se=O.get(U.envMap||ve,ye),Fe=U.vertexColors===!0&&!!G.attributes.color&&G.attributes.color.itemSize===4,Be=!!G.attributes.tangent&&(!!U.normalMap||U.anisotropy>0),we=!!G.morphAttributes.position,nt=!!G.morphAttributes.normal,bt=!!G.morphAttributes.color,mt=fn;U.toneMapped&&(k===null||k.isXRRenderTarget===!0)&&(mt=P.toneMapping);let st=G.morphAttributes.position||G.morphAttributes.normal||G.morphAttributes.color,Vt=st!==void 0?st.length:0,ge=A.get(U),rn=w.state.lights;if(dt===!0&&(Xe===!0||S!==V)){let at=S===V&&U.id===z;xe.setState(U,S,at)}let $e=!1;U.version===ge.__version?(ge.needsLights&&ge.lightsStateVersion!==rn.state.version||ge.outputColorSpace!==he||B.isBatchedMesh&&ge.batching===!1||!B.isBatchedMesh&&ge.batching===!0||B.isBatchedMesh&&ge.batchingColor===!0&&B.colorTexture===null||B.isBatchedMesh&&ge.batchingColor===!1&&B.colorTexture!==null||B.isInstancedMesh&&ge.instancing===!1||!B.isInstancedMesh&&ge.instancing===!0||B.isSkinnedMesh&&ge.skinning===!1||!B.isSkinnedMesh&&ge.skinning===!0||B.isInstancedMesh&&ge.instancingColor===!0&&B.instanceColor===null||B.isInstancedMesh&&ge.instancingColor===!1&&B.instanceColor!==null||B.isInstancedMesh&&ge.instancingMorph===!0&&B.morphTexture===null||B.isInstancedMesh&&ge.instancingMorph===!1&&B.morphTexture!==null||ge.envMap!==Se||U.fog===!0&&ge.fog!==ue||ge.numClippingPlanes!==void 0&&(ge.numClippingPlanes!==xe.numPlanes||ge.numIntersection!==xe.numIntersection)||ge.vertexAlphas!==Fe||ge.vertexTangents!==Be||ge.morphTargets!==we||ge.morphNormals!==nt||ge.morphColors!==bt||ge.toneMapping!==mt||ge.morphTargetsCount!==Vt||!!ge.lightProbeGrid!=w.state.lightProbeGridArray.length>0)&&($e=!0):($e=!0,ge.__version=U.version);let gn=ge.currentProgram;$e===!0&&(gn=Kr(U,F,B),I&&U.isNodeMaterial&&I.onUpdateProgram(U,gn,ge));let Nn=!1,li=!1,ns=!1,rt=gn.getUniforms(),Mt=ge.uniforms;if(le.useProgram(gn.program)&&(Nn=!0,li=!0,ns=!0),U.id!==z&&(z=U.id,li=!0),ge.needsLights){let at=am(w.state.lightProbeGridArray,B);ge.lightProbeGrid!==at&&(ge.lightProbeGrid=at,li=!0)}if(Nn||V!==S){le.buffers.depth.getReversed()&&S.reversedDepth!==!0&&(S._reversedDepth=!0,S.updateProjectionMatrix()),rt.setValue(D,"projectionMatrix",S.projectionMatrix),rt.setValue(D,"viewMatrix",S.matrixWorldInverse);let hi=rt.map.cameraPosition;hi!==void 0&&hi.setValue(D,lt.setFromMatrixPosition(S.matrixWorld)),ot.logarithmicDepthBuffer&&rt.setValue(D,"logDepthBufFC",2/(Math.log(S.far+1)/Math.LN2)),(U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshLambertMaterial||U.isMeshBasicMaterial||U.isMeshStandardMaterial||U.isShaderMaterial)&&rt.setValue(D,"isOrthographic",S.isOrthographicCamera===!0),V!==S&&(V=S,li=!0,ns=!0)}if(ge.needsLights&&(rn.state.directionalShadowMap.length>0&&rt.setValue(D,"directionalShadowMap",rn.state.directionalShadowMap,y),rn.state.spotShadowMap.length>0&&rt.setValue(D,"spotShadowMap",rn.state.spotShadowMap,y),rn.state.pointShadowMap.length>0&&rt.setValue(D,"pointShadowMap",rn.state.pointShadowMap,y)),B.isSkinnedMesh){rt.setOptional(D,B,"bindMatrix"),rt.setOptional(D,B,"bindMatrixInverse");let at=B.skeleton;at&&(at.boneTexture===null&&at.computeBoneTexture(),rt.setValue(D,"boneTexture",at.boneTexture,y))}B.isBatchedMesh&&(rt.setOptional(D,B,"batchingTexture"),rt.setValue(D,"batchingTexture",B._matricesTexture,y),rt.setOptional(D,B,"batchingIdTexture"),rt.setValue(D,"batchingIdTexture",B._indirectTexture,y),rt.setOptional(D,B,"batchingColorTexture"),B._colorsTexture!==null&&rt.setValue(D,"batchingColorTexture",B._colorsTexture,y));let ci=G.morphAttributes;if((ci.position!==void 0||ci.normal!==void 0||ci.color!==void 0)&&Ie.update(B,G,gn),(li||ge.receiveShadow!==B.receiveShadow)&&(ge.receiveShadow=B.receiveShadow,rt.setValue(D,"receiveShadow",B.receiveShadow)),(U.isMeshStandardMaterial||U.isMeshLambertMaterial||U.isMeshPhongMaterial)&&U.envMap===null&&F.environment!==null&&(Mt.envMapIntensity.value=F.environmentIntensity),Mt.dfgLUT!==void 0&&(Mt.dfgLUT.value=sy()),li){if(rt.setValue(D,"toneMappingExposure",P.toneMappingExposure),ge.needsLights&&cm(Mt,ns),ue&&U.fog===!0&&X.refreshFogUniforms(Mt,ue),X.refreshMaterialUniforms(Mt,U,ke,Qe,w.state.transmissionRenderTarget[S.id]),ge.needsLights&&ge.lightProbeGrid){let at=ge.lightProbeGrid;Mt.probesSH.value=at.texture,Mt.probesMin.value.copy(at.boundingBox.min),Mt.probesMax.value.copy(at.boundingBox.max),Mt.probesResolution.value.copy(at.resolution)}Ns.upload(D,lu(ge),Mt,y)}if(U.isShaderMaterial&&U.uniformsNeedUpdate===!0&&(Ns.upload(D,lu(ge),Mt,y),U.uniformsNeedUpdate=!1),U.isSpriteMaterial&&rt.setValue(D,"center",B.center),rt.setValue(D,"modelViewMatrix",B.modelViewMatrix),rt.setValue(D,"normalMatrix",B.normalMatrix),rt.setValue(D,"modelMatrix",B.matrixWorld),U.uniformsGroups!==void 0){let at=U.uniformsGroups;for(let hi=0,is=at.length;hi<is;hi++){let hu=at[hi];q.update(hu,gn),q.bind(hu,gn)}}return gn}function cm(S,F){S.ambientLightColor.needsUpdate=F,S.lightProbe.needsUpdate=F,S.directionalLights.needsUpdate=F,S.directionalLightShadows.needsUpdate=F,S.pointLights.needsUpdate=F,S.pointLightShadows.needsUpdate=F,S.spotLights.needsUpdate=F,S.spotLightShadows.needsUpdate=F,S.rectAreaLights.needsUpdate=F,S.hemisphereLights.needsUpdate=F}function hm(S){return S.isMeshLambertMaterial||S.isMeshToonMaterial||S.isMeshPhongMaterial||S.isMeshStandardMaterial||S.isShadowMaterial||S.isShaderMaterial&&S.lights===!0}this.getActiveCubeFace=function(){return H},this.getActiveMipmapLevel=function(){return W},this.getRenderTarget=function(){return k},this.setRenderTargetTextures=function(S,F,G){let U=A.get(S);U.__autoAllocateDepthBuffer=S.resolveDepthBuffer===!1,U.__autoAllocateDepthBuffer===!1&&(U.__useRenderToTexture=!1),A.get(S.texture).__webglTexture=F,A.get(S.depthTexture).__webglTexture=U.__autoAllocateDepthBuffer?void 0:G,U.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(S,F){let G=A.get(S);G.__webglFramebuffer=F,G.__useDefaultFramebuffer=F===void 0};let um=D.createFramebuffer();this.setRenderTarget=function(S,F=0,G=0){k=S,H=F,W=G;let U=null,B=!1,ue=!1;if(S){let he=A.get(S);if(he.__useDefaultFramebuffer!==void 0){le.bindFramebuffer(D.FRAMEBUFFER,he.__webglFramebuffer),K.copy(S.viewport),Q.copy(S.scissor),ae=S.scissorTest,le.viewport(K),le.scissor(Q),le.setScissorTest(ae),z=-1;return}else if(he.__webglFramebuffer===void 0)y.setupRenderTarget(S);else if(he.__hasExternalTextures)y.rebindTextures(S,A.get(S.texture).__webglTexture,A.get(S.depthTexture).__webglTexture);else if(S.depthBuffer){let Fe=S.depthTexture;if(he.__boundDepthTexture!==Fe){if(Fe!==null&&A.has(Fe)&&(S.width!==Fe.image.width||S.height!==Fe.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");y.setupDepthRenderbuffer(S)}}let ye=S.texture;(ye.isData3DTexture||ye.isDataArrayTexture||ye.isCompressedArrayTexture)&&(ue=!0);let Se=A.get(S).__webglFramebuffer;S.isWebGLCubeRenderTarget?(Array.isArray(Se[F])?U=Se[F][G]:U=Se[F],B=!0):S.samples>0&&y.useMultisampledRTT(S)===!1?U=A.get(S).__webglMultisampledFramebuffer:Array.isArray(Se)?U=Se[G]:U=Se,K.copy(S.viewport),Q.copy(S.scissor),ae=S.scissorTest}else K.copy(ie).multiplyScalar(ke).floor(),Q.copy(Ae).multiplyScalar(ke).floor(),ae=Ne;if(G!==0&&(U=um),le.bindFramebuffer(D.FRAMEBUFFER,U)&&le.drawBuffers(S,U),le.viewport(K),le.scissor(Q),le.setScissorTest(ae),B){let he=A.get(S.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+F,he.__webglTexture,G)}else if(ue){let he=F;for(let ye=0;ye<S.textures.length;ye++){let Se=A.get(S.textures[ye]);D.framebufferTextureLayer(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0+ye,Se.__webglTexture,G,he)}}else if(S!==null&&G!==0){let he=A.get(S.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,he.__webglTexture,G)}z=-1},this.readRenderTargetPixels=function(S,F,G,U,B,ue,ve,he=0){if(!(S&&S.isWebGLRenderTarget)){Re("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ye=A.get(S).__webglFramebuffer;if(S.isWebGLCubeRenderTarget&&ve!==void 0&&(ye=ye[ve]),ye){le.bindFramebuffer(D.FRAMEBUFFER,ye);try{let Se=S.textures[he],Fe=Se.format,Be=Se.type;if(S.textures.length>1&&D.readBuffer(D.COLOR_ATTACHMENT0+he),!ot.textureFormatReadable(Fe)){Re("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!ot.textureTypeReadable(Be)){Re("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}F>=0&&F<=S.width-U&&G>=0&&G<=S.height-B&&D.readPixels(F,G,U,B,L.convert(Fe),L.convert(Be),ue)}finally{let Se=k!==null?A.get(k).__webglFramebuffer:null;le.bindFramebuffer(D.FRAMEBUFFER,Se)}}},this.readRenderTargetPixelsAsync=async function(S,F,G,U,B,ue,ve,he=0){if(!(S&&S.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ye=A.get(S).__webglFramebuffer;if(S.isWebGLCubeRenderTarget&&ve!==void 0&&(ye=ye[ve]),ye)if(F>=0&&F<=S.width-U&&G>=0&&G<=S.height-B){le.bindFramebuffer(D.FRAMEBUFFER,ye);let Se=S.textures[he],Fe=Se.format,Be=Se.type;if(S.textures.length>1&&D.readBuffer(D.COLOR_ATTACHMENT0+he),!ot.textureFormatReadable(Fe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!ot.textureTypeReadable(Be))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let we=D.createBuffer();D.bindBuffer(D.PIXEL_PACK_BUFFER,we),D.bufferData(D.PIXEL_PACK_BUFFER,ue.byteLength,D.STREAM_READ),D.readPixels(F,G,U,B,L.convert(Fe),L.convert(Be),0);let nt=k!==null?A.get(k).__webglFramebuffer:null;le.bindFramebuffer(D.FRAMEBUFFER,nt);let bt=D.fenceSync(D.SYNC_GPU_COMMANDS_COMPLETE,0);return D.flush(),await yd(D,bt,4),D.bindBuffer(D.PIXEL_PACK_BUFFER,we),D.getBufferSubData(D.PIXEL_PACK_BUFFER,0,ue),D.deleteBuffer(we),D.deleteSync(bt),ue}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(S,F=null,G=0){let U=Math.pow(2,-G),B=Math.floor(S.image.width*U),ue=Math.floor(S.image.height*U),ve=F!==null?F.x:0,he=F!==null?F.y:0;y.setTexture2D(S,0),D.copyTexSubImage2D(D.TEXTURE_2D,G,0,0,ve,he,B,ue),le.unbindTexture()};let dm=D.createFramebuffer(),fm=D.createFramebuffer();this.copyTextureToTexture=function(S,F,G=null,U=null,B=0,ue=0){let ve,he,ye,Se,Fe,Be,we,nt,bt,mt=S.isCompressedTexture?S.mipmaps[ue]:S.image;if(G!==null)ve=G.max.x-G.min.x,he=G.max.y-G.min.y,ye=G.isBox3?G.max.z-G.min.z:1,Se=G.min.x,Fe=G.min.y,Be=G.isBox3?G.min.z:0;else{let Mt=Math.pow(2,-B);ve=Math.floor(mt.width*Mt),he=Math.floor(mt.height*Mt),S.isDataArrayTexture?ye=mt.depth:S.isData3DTexture?ye=Math.floor(mt.depth*Mt):ye=1,Se=0,Fe=0,Be=0}U!==null?(we=U.x,nt=U.y,bt=U.z):(we=0,nt=0,bt=0);let st=L.convert(F.format),Vt=L.convert(F.type),ge;F.isData3DTexture?(y.setTexture3D(F,0),ge=D.TEXTURE_3D):F.isDataArrayTexture||F.isCompressedArrayTexture?(y.setTexture2DArray(F,0),ge=D.TEXTURE_2D_ARRAY):(y.setTexture2D(F,0),ge=D.TEXTURE_2D),le.activeTexture(D.TEXTURE0),le.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,F.flipY),le.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,F.premultiplyAlpha),le.pixelStorei(D.UNPACK_ALIGNMENT,F.unpackAlignment);let rn=le.getParameter(D.UNPACK_ROW_LENGTH),$e=le.getParameter(D.UNPACK_IMAGE_HEIGHT),gn=le.getParameter(D.UNPACK_SKIP_PIXELS),Nn=le.getParameter(D.UNPACK_SKIP_ROWS),li=le.getParameter(D.UNPACK_SKIP_IMAGES);le.pixelStorei(D.UNPACK_ROW_LENGTH,mt.width),le.pixelStorei(D.UNPACK_IMAGE_HEIGHT,mt.height),le.pixelStorei(D.UNPACK_SKIP_PIXELS,Se),le.pixelStorei(D.UNPACK_SKIP_ROWS,Fe),le.pixelStorei(D.UNPACK_SKIP_IMAGES,Be);let ns=S.isDataArrayTexture||S.isData3DTexture,rt=F.isDataArrayTexture||F.isData3DTexture;if(S.isDepthTexture){let Mt=A.get(S),ci=A.get(F),at=A.get(Mt.__renderTarget),hi=A.get(ci.__renderTarget);le.bindFramebuffer(D.READ_FRAMEBUFFER,at.__webglFramebuffer),le.bindFramebuffer(D.DRAW_FRAMEBUFFER,hi.__webglFramebuffer);for(let is=0;is<ye;is++)ns&&(D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,A.get(S).__webglTexture,B,Be+is),D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,A.get(F).__webglTexture,ue,bt+is)),D.blitFramebuffer(Se,Fe,ve,he,we,nt,ve,he,D.DEPTH_BUFFER_BIT,D.NEAREST);le.bindFramebuffer(D.READ_FRAMEBUFFER,null),le.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else if(B!==0||S.isRenderTargetTexture||A.has(S)){let Mt=A.get(S),ci=A.get(F);le.bindFramebuffer(D.READ_FRAMEBUFFER,dm),le.bindFramebuffer(D.DRAW_FRAMEBUFFER,fm);for(let at=0;at<ye;at++)ns?D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,Mt.__webglTexture,B,Be+at):D.framebufferTexture2D(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,Mt.__webglTexture,B),rt?D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,ci.__webglTexture,ue,bt+at):D.framebufferTexture2D(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_2D,ci.__webglTexture,ue),B!==0?D.blitFramebuffer(Se,Fe,ve,he,we,nt,ve,he,D.COLOR_BUFFER_BIT,D.NEAREST):rt?D.copyTexSubImage3D(ge,ue,we,nt,bt+at,Se,Fe,ve,he):D.copyTexSubImage2D(ge,ue,we,nt,Se,Fe,ve,he);le.bindFramebuffer(D.READ_FRAMEBUFFER,null),le.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else rt?S.isDataTexture||S.isData3DTexture?D.texSubImage3D(ge,ue,we,nt,bt,ve,he,ye,st,Vt,mt.data):F.isCompressedArrayTexture?D.compressedTexSubImage3D(ge,ue,we,nt,bt,ve,he,ye,st,mt.data):D.texSubImage3D(ge,ue,we,nt,bt,ve,he,ye,st,Vt,mt):S.isDataTexture?D.texSubImage2D(D.TEXTURE_2D,ue,we,nt,ve,he,st,Vt,mt.data):S.isCompressedTexture?D.compressedTexSubImage2D(D.TEXTURE_2D,ue,we,nt,mt.width,mt.height,st,mt.data):D.texSubImage2D(D.TEXTURE_2D,ue,we,nt,ve,he,st,Vt,mt);le.pixelStorei(D.UNPACK_ROW_LENGTH,rn),le.pixelStorei(D.UNPACK_IMAGE_HEIGHT,$e),le.pixelStorei(D.UNPACK_SKIP_PIXELS,gn),le.pixelStorei(D.UNPACK_SKIP_ROWS,Nn),le.pixelStorei(D.UNPACK_SKIP_IMAGES,li),ue===0&&F.generateMipmaps&&D.generateMipmap(ge),le.unbindTexture()},this.initRenderTarget=function(S){A.get(S).__webglFramebuffer===void 0&&y.setupRenderTarget(S)},this.initTexture=function(S){S.isCubeTexture?y.setTextureCube(S,0):S.isData3DTexture?y.setTexture3D(S,0):S.isDataArrayTexture||S.isCompressedArrayTexture?y.setTexture2DArray(S,0):y.setTexture2D(S,0),le.unbindTexture()},this.resetState=function(){H=0,W=0,k=null,le.reset(),ne.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=ze._getDrawingBufferColorSpace(e),t.unpackColorSpace=ze._getUnpackColorSpace()}};var Qd=require("obsidian");async function ef(i){try{let e=(0,Qd.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 ll=require("obsidian");function ry(i){let e=i.indexOf("/");return e===-1?"":i.slice(0,e)}function nf(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:ry(d.path),degree:0,inDegree:0,outDegree:0,fileSize:d.size??0,unresolved:!1});let o=[],a=(d,h)=>{o.push({source:d,target:h});let f=s[d],g=s[h];f&&(f.degree++,f.outDegree++),g&&(g.degree++,g.inDegree++)};for(let d of Object.keys(e)){let h=r.get(d);if(h===void 0)continue;let f=e[d]??{};for(let g of Object.keys(f)){let x=r.get(g);x!==void 0&&a(h,x)}}if(n.includeUnresolved)for(let d of Object.keys(t)){let h=r.get(d);if(h===void 0)continue;let f=t[d]??{};for(let g of Object.keys(f)){let x=`unresolved:${g}`,m=r.get(x);m===void 0&&(m=s.length,r.set(x,m),s.push({id:x,name:g,folderTop:"__unresolved__",degree:0,inDegree:0,outDegree:0,fileSize:0,unresolved:!0})),a(h,m)}}let l={nodes:s,links:o};n.includeOrphans||(l=tf(l,d=>d.degree>0));let c=n.nodeCap??null;if(c!==null&&l.nodes.length>c){let d=[...l.nodes.entries()].sort((f,g)=>g[1].degree-f[1].degree||f[0]-g[0]),h=new Set(d.slice(0,c).map(([f])=>f));l=tf(l,(f,g)=>h.has(g))}let u=n.linkCap??null;if(u!==null&&l.links.length>u){let d=h=>l.nodes[h]?.degree??0;l={nodes:l.nodes,links:[...l.links.entries()].sort((h,f)=>Math.min(d(f[1].source),d(f[1].target))-Math.min(d(h[1].source),d(h[1].target))||h[0]-f[0]).slice(0,u).map(([,h])=>h)}}return l}function tf(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 Eh(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 wh(i){return Eh(i)/4294967295}function sf(i,e){let t=wh(i),n=wh(i+":v"),s=wh(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 ol(i){return 80*Math.cbrt(Math.max(i,1)/1e3)}var al=class extends ll.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,ll.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=nf(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,u)=>r.set(c.id,u));let o=this.positions,a=ol(s.nodes.length),l=new Float32Array(s.nodes.length*3);s.nodes.forEach((c,u)=>{let d=r.get(c.id);if(d!==void 0&&d*3+2<o.length)l[u*3]=o[d*3]??0,l[u*3+1]=o[d*3+1]??0,l[u*3+2]=o[d*3+2]??0;else{let[h,f,g]=sf(c.id,a);l[u*3]=h,l[u*3+1]=f,l[u*3+2]=g}}),this.data=s,this.positions=l,this.onChanged?.()}};function rf(i){let e=+this._x.call(null,i);return of(this.cover(e),e,i)}function of(i,e,t){if(isNaN(e))return i;var n,s=i._root,r={data:t},o=i._x0,a=i._x1,l,c,u,d,h;if(!s)return i._root=r,i;for(;s.length;)if((u=e>=(l=(o+a)/2))?o=l:a=l,n=s,!(s=s[d=+u]))return n[d]=r,i;if(c=+i._x.call(null,s.data),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),(u=e>=(l=(o+a)/2))?o=l:a=l;while((d=+u)==(h=+(c>=l)));return n[h]=s,n[d]=r,i}function af(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)of(this,t[r],i[r]);return this}function lf(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 cf(){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 Mn(i,e,t){this.node=i,this.x0=e,this.x1=t}function uf(i,e){var t,n=this._x0,s,r,o=this._x1,a=[],l=this._root,c,u;for(l&&a.push(new Mn(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 Mn(l[1],d,r),new Mn(l[0],s,d)),(u=+(i>=d))&&(c=a[a.length-1],a[a.length-1]=a[a.length-1-u],a[a.length-1-u]=c)}else{var h=Math.abs(i-+this._x.call(null,l.data));h<e&&(e=h,n=i-h,o=i+h,t=l.data)}return t}function df(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,u,d,h;if(!t)return this;if(t.length)for(;;){if((u=l>=(c=(o+a)/2))?o=c:a=c,e=t,!(t=t[d=+u]))return this;if(!t.length)break;e[d+1&1]&&(n=e,h=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[h]=t:this._root=t),this):(this._root=r,this)}function ff(i){for(var e=0,t=i.length;e<t;++e)this.remove(i[e]);return this}function pf(){return this._root}function mf(){var i=0;return this.visit(function(e){if(!e.length)do++i;while(e=e.next)}),i}function gf(i){var e=[],t,n=this._root,s,r,o;for(n&&e.push(new Mn(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 Mn(s,a,o)),(s=n[0])&&e.push(new Mn(s,r,a))}return this}function xf(i){var e=[],t=[],n;for(this._root&&e.push(new Mn(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 Mn(r,o,l)),(r=s[1])&&e.push(new Mn(r,l,a))}t.push(n)}for(;n=t.pop();)i(n.node,n.x0,n.x1);return this}function vf(i){return i[0]}function _f(i){return arguments.length?(this._x=i,this):this._x}function Or(i,e){var t=new Th(e??vf,NaN,NaN);return i==null?t:t.addAll(i)}function Th(i,e,t){this._x=i,this._x0=e,this._x1=t,this._root=void 0}function yf(i){for(var e={data:i.data},t=e;i=i.next;)t=t.next={data:i.data};return e}var en=Or.prototype=Th.prototype;en.copy=function(){var i=new Th(this._x,this._x0,this._x1),e=this._root,t,n;if(!e)return i;if(!e.length)return i._root=yf(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]=yf(n));return i};en.add=rf;en.addAll=af;en.cover=lf;en.data=cf;en.extent=hf;en.find=uf;en.remove=df;en.removeAll=ff;en.root=pf;en.size=mf;en.visit=gf;en.visitAfter=xf;en.x=_f;function bf(i){let e=+this._x.call(null,i),t=+this._y.call(null,i);return Mf(this.cover(e,t),e,t,i)}function Mf(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,u=i._y1,d,h,f,g,x,m,p,v;if(!r)return i._root=o,i;for(;r.length;)if((x=e>=(d=(a+c)/2))?a=d:c=d,(m=t>=(h=(l+u)/2))?l=h:u=h,s=r,!(r=r[p=m<<1|x]))return s[p]=o,i;if(f=+i._x.call(null,r.data),g=+i._y.call(null,r.data),e===f&&t===g)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,(m=t>=(h=(l+u)/2))?l=h:u=h;while((p=m<<1|x)===(v=(g>=h)<<1|f>=d));return s[v]=r,s[p]=o,i}function Sf(i){var e,t,n=i.length,s,r,o=new Array(n),a=new Array(n),l=1/0,c=1/0,u=-1/0,d=-1/0;for(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>u&&(u=s),r<c&&(c=r),r>d&&(d=r));if(l>u||c>d)return this;for(this.cover(l,c).cover(u,d),t=0;t<n;++t)Mf(this,o[t],a[t],i[t]);return this}function wf(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 Ef(){var i=[];return this.visit(function(e){if(!e.length)do i.push(e.data);while(e=e.next)}),i}function Tf(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 Ft(i,e,t,n,s){this.node=i,this.x0=e,this.y0=t,this.x1=n,this.y1=s}function Af(i,e,t){var n,s=this._x0,r=this._y0,o,a,l,c,u=this._x1,d=this._y1,h=[],f=this._root,g,x;for(f&&h.push(new Ft(f,s,r,u,d)),t==null?t=1/0:(s=i-t,r=e-t,u=i+t,d=e+t,t*=t);g=h.pop();)if(!(!(f=g.node)||(o=g.x0)>u||(a=g.y0)>d||(l=g.x1)<s||(c=g.y1)<r))if(f.length){var m=(o+l)/2,p=(a+c)/2;h.push(new Ft(f[3],m,p,l,c),new Ft(f[2],o,p,m,c),new Ft(f[1],m,a,l,p),new Ft(f[0],o,a,m,p)),(x=(e>=p)<<1|i>=m)&&(g=h[h.length-1],h[h.length-1]=h[h.length-1-x],h[h.length-1-x]=g)}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 E=Math.sqrt(t=M);s=i-E,r=e-E,u=i+E,d=e+E,n=f.data}}return n}function Cf(i){if(isNaN(u=+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,u,d,h,f,g,x,m,p;if(!t)return this;if(t.length)for(;;){if((g=u>=(h=(o+l)/2))?o=h:l=h,(x=d>=(f=(a+c)/2))?a=f:c=f,e=t,!(t=t[m=x<<1|g]))return this;if(!t.length)break;(e[m+1&3]||e[m+2&3]||e[m+3&3])&&(n=e,p=m)}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[m]=r:delete e[m],(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 Rf(i){for(var e=0,t=i.length;e<t;++e)this.remove(i[e]);return this}function Pf(){return this._root}function If(){var i=0;return this.visit(function(e){if(!e.length)do++i;while(e=e.next)}),i}function Lf(i){var e=[],t,n=this._root,s,r,o,a,l;for(n&&e.push(new Ft(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,u=(o+l)/2;(s=n[3])&&e.push(new Ft(s,c,u,a,l)),(s=n[2])&&e.push(new Ft(s,r,u,c,l)),(s=n[1])&&e.push(new Ft(s,c,o,a,u)),(s=n[0])&&e.push(new Ft(s,r,o,c,u))}return this}function Nf(i){var e=[],t=[],n;for(this._root&&e.push(new Ft(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,u=(o+l)/2,d=(a+c)/2;(r=s[0])&&e.push(new Ft(r,o,a,u,d)),(r=s[1])&&e.push(new Ft(r,u,a,l,d)),(r=s[2])&&e.push(new Ft(r,o,d,u,c)),(r=s[3])&&e.push(new Ft(r,u,d,l,c))}t.push(n)}for(;n=t.pop();)i(n.node,n.x0,n.y0,n.x1,n.y1);return this}function Df(i){return i[0]}function Ff(i){return arguments.length?(this._x=i,this):this._x}function kf(i){return i[1]}function Of(i){return arguments.length?(this._y=i,this):this._y}function Ur(i,e,t){var n=new Ah(e??Df,t??kf,NaN,NaN,NaN,NaN);return i==null?n:n.addAll(i)}function Ah(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 Uf(i){for(var e={data:i.data},t=e;i=i.next;)t=t.next={data:i.data};return e}var Kt=Ur.prototype=Ah.prototype;Kt.copy=function(){var i=new Ah(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=Uf(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]=Uf(n));return i};Kt.add=bf;Kt.addAll=Sf;Kt.cover=wf;Kt.data=Ef;Kt.extent=Tf;Kt.find=Af;Kt.remove=Cf;Kt.removeAll=Rf;Kt.root=Pf;Kt.size=If;Kt.visit=Lf;Kt.visitAfter=Nf;Kt.x=Ff;Kt.y=Of;function Bf(i){let e=+this._x.call(null,i),t=+this._y.call(null,i),n=+this._z.call(null,i);return zf(this.cover(e,t,n),e,t,n,i)}function zf(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,u=i._z0,d=i._x1,h=i._y1,f=i._z1,g,x,m,p,v,b,M,E,w,C,_;if(!o)return i._root=a,i;for(;o.length;)if((M=e>=(g=(l+d)/2))?l=g:d=g,(E=t>=(x=(c+h)/2))?c=x:h=x,(w=n>=(m=(u+f)/2))?u=m:f=m,r=o,!(o=o[C=w<<2|E<<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>=(g=(l+d)/2))?l=g:d=g,(E=t>=(x=(c+h)/2))?c=x:h=x,(w=n>=(m=(u+f)/2))?u=m:f=m;while((C=w<<2|E<<1|M)===(_=(b>=m)<<2|(v>=x)<<1|p>=g));return r[_]=o,r[C]=a,i}function Vf(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,u=-1/0;for(let d=0,h,f,g,x;d<e;++d)isNaN(f=+this._x.call(null,h=i[d]))||isNaN(g=+this._y.call(null,h))||isNaN(x=+this._z.call(null,h))||(t[d]=f,n[d]=g,s[d]=x,f<r&&(r=f),f>l&&(l=f),g<o&&(o=g),g>c&&(c=g),x<a&&(a=x),x>u&&(u=x));if(r>l||o>c||a>u)return this;this.cover(r,o,a).cover(l,c,u);for(let d=0;d<e;++d)zf(this,t[d],n[d],s[d],i[d]);return this}function Gf(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,u=this._root,d,h;n>i||i>=o||s>e||e>=a||r>t||t>=l;)switch(h=(t<r)<<2|(e<s)<<1|i<n,d=new Array(8),d[h]=u,u=d,c*=2,h){case 0:o=n+c,a=s+c,l=r+c;break;case 1:n=o-c,a=s+c,l=r+c;break;case 2:o=n+c,s=a-c,l=r+c;break;case 3:n=o-c,s=a-c,l=r+c;break;case 4:o=n+c,a=s+c,r=l-c;break;case 5:n=o-c,a=s+c,r=l-c;break;case 6:o=n+c,s=a-c,r=l-c;break;case 7:n=o-c,s=a-c,r=l-c;break}this._root&&this._root.length&&(this._root=u)}return this._x0=n,this._y0=s,this._z0=r,this._x1=o,this._y1=a,this._z1=l,this}function Hf(){var i=[];return this.visit(function(e){if(!e.length)do i.push(e.data);while(e=e.next)}),i}function Wf(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 je(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 Xf(i,e,t,n){var s,r=this._x0,o=this._y0,a=this._z0,l,c,u,d,h,f,g=this._x1,x=this._y1,m=this._z1,p=[],v=this._root,b,M;for(v&&p.push(new je(v,r,o,a,g,x,m)),n==null?n=1/0:(r=i-n,o=e-n,a=t-n,g=i+n,x=e+n,m=t+n,n*=n);b=p.pop();)if(!(!(v=b.node)||(l=b.x0)>g||(c=b.y0)>x||(u=b.z0)>m||(d=b.x1)<r||(h=b.y1)<o||(f=b.z1)<a))if(v.length){var E=(l+d)/2,w=(c+h)/2,C=(u+f)/2;p.push(new je(v[7],E,w,C,d,h,f),new je(v[6],l,w,C,E,h,f),new je(v[5],E,c,C,d,w,f),new je(v[4],l,c,C,E,w,f),new je(v[3],E,w,u,d,h,C),new je(v[2],l,w,u,E,h,C),new je(v[1],E,c,u,d,w,C),new je(v[0],l,c,u,E,w,C)),(M=(t>=C)<<2|(e>=w)<<1|i>=E)&&(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),T=e-+this._y.call(null,v.data),P=t-+this._z.call(null,v.data),R=_*_+T*T+P*P;if(R<n){var I=Math.sqrt(n=R);r=i-I,o=e-I,a=t-I,g=i+I,x=e+I,m=t+I,s=v.data}}return s}var oy=(i,e,t,n,s,r)=>Math.sqrt((i-n)**2+(e-s)**2+(t-r)**2);function qf(i,e,t,n){let s=[],r=i-n,o=e-n,a=t-n,l=i+n,c=e+n,u=t+n;return this.visit((d,h,f,g,x,m,p)=>{if(!d.length)do{let v=d.data;oy(i,e,t,this._x(v),this._y(v),this._z(v))<=n&&s.push(v)}while(d=d.next);return h>l||f>c||g>u||x<r||m<o||p<a}),s}function Yf(i){if(isNaN(h=+this._x.call(null,i))||isNaN(f=+this._y.call(null,i))||isNaN(g=+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,u=this._y1,d=this._z1,h,f,g,x,m,p,v,b,M,E,w;if(!t)return this;if(t.length)for(;;){if((v=h>=(x=(o+c)/2))?o=x:c=x,(b=f>=(m=(a+u)/2))?a=m:u=m,(M=g>=(p=(l+d)/2))?l=p:d=p,e=t,!(t=t[E=M<<2|b<<1|v]))return this;if(!t.length)break;(e[E+1&7]||e[E+2&7]||e[E+3&7]||e[E+4&7]||e[E+5&7]||e[E+6&7]||e[E+7&7])&&(n=e,w=E)}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[E]=r:delete e[E],(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 Zf(i){for(var e=0,t=i.length;e<t;++e)this.remove(i[e]);return this}function $f(){return this._root}function Kf(){var i=0;return this.visit(function(e){if(!e.length)do++i;while(e=e.next)}),i}function Jf(i){var e=[],t,n=this._root,s,r,o,a,l,c,u;for(n&&e.push(new je(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,u=t.z1)&&n.length){var d=(r+l)/2,h=(o+c)/2,f=(a+u)/2;(s=n[7])&&e.push(new je(s,d,h,f,l,c,u)),(s=n[6])&&e.push(new je(s,r,h,f,d,c,u)),(s=n[5])&&e.push(new je(s,d,o,f,l,h,u)),(s=n[4])&&e.push(new je(s,r,o,f,d,h,u)),(s=n[3])&&e.push(new je(s,d,h,a,l,c,f)),(s=n[2])&&e.push(new je(s,r,h,a,d,c,f)),(s=n[1])&&e.push(new je(s,d,o,a,l,h,f)),(s=n[0])&&e.push(new je(s,r,o,a,d,h,f))}return this}function jf(i){var e=[],t=[],n;for(this._root&&e.push(new je(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,u=n.y1,d=n.z1,h=(o+c)/2,f=(a+u)/2,g=(l+d)/2;(r=s[0])&&e.push(new je(r,o,a,l,h,f,g)),(r=s[1])&&e.push(new je(r,h,a,l,c,f,g)),(r=s[2])&&e.push(new je(r,o,f,l,h,u,g)),(r=s[3])&&e.push(new je(r,h,f,l,c,u,g)),(r=s[4])&&e.push(new je(r,o,a,g,h,f,d)),(r=s[5])&&e.push(new je(r,h,a,g,c,f,d)),(r=s[6])&&e.push(new je(r,o,f,g,h,u,d)),(r=s[7])&&e.push(new je(r,h,f,g,c,u,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 Qf(i){return i[0]}function ep(i){return arguments.length?(this._x=i,this):this._x}function tp(i){return i[1]}function np(i){return arguments.length?(this._y=i,this):this._y}function ip(i){return i[2]}function sp(i){return arguments.length?(this._z=i,this):this._z}function Br(i,e,t,n){var s=new Ch(e??Qf,t??tp,n??ip,NaN,NaN,NaN,NaN,NaN,NaN);return i==null?s:s.addAll(i)}function Ch(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 rp(i){for(var e={data:i.data},t=e;i=i.next;)t=t.next={data:i.data};return e}var zt=Br.prototype=Ch.prototype;zt.copy=function(){var i=new Ch(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=rp(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]=rp(n));return i};zt.add=Bf;zt.addAll=Vf;zt.cover=Gf;zt.data=Hf;zt.extent=Wf;zt.find=Xf;zt.findAllWithinRadius=qf;zt.remove=Yf;zt.removeAll=Zf;zt.root=$f;zt.size=Kf;zt.visit=Jf;zt.visitAfter=jf;zt.x=ep;zt.y=np;zt.z=sp;function vt(i){return function(){return i}}function In(i){return(i()-.5)*1e-6}function ay(i){return i.index}function op(i,e){var t=i.get(e);if(!t)throw new Error("node not found: "+e);return t}function Rh(i){var e=ay,t=h,n,s=vt(30),r,o,a,l,c,u,d=1;i==null&&(i=[]);function h(p){return 1/Math.min(l[p.source.index],l[p.target.index])}function f(p){for(var v=0,b=i.length;v<d;++v)for(var M=0,E,w,C,_=0,T=0,P=0,R,I;M<b;++M)E=i[M],w=E.source,C=E.target,_=C.x+C.vx-w.x-w.vx||In(u),a>1&&(T=C.y+C.vy-w.y-w.vy||In(u)),a>2&&(P=C.z+C.vz-w.z-w.vz||In(u)),R=Math.sqrt(_*_+T*T+P*P),R=(R-r[M])/R*p*n[M],_*=R,T*=R,P*=R,C.vx-=_*(I=c[M]),a>1&&(C.vy-=T*I),a>2&&(C.vz-=P*I),w.vx+=_*(I=1-I),a>1&&(w.vy+=T*I),a>2&&(w.vz+=P*I)}function g(){if(o){var p,v=o.length,b=i.length,M=new Map(o.map((w,C)=>[e(w,C,o),w])),E;for(p=0,l=new Array(v);p<b;++p)E=i[p],E.index=p,typeof E.source!="object"&&(E.source=op(M,E.source)),typeof E.target!="object"&&(E.target=op(M,E.target)),l[E.source.index]=(l[E.source.index]||0)+1,l[E.target.index]=(l[E.target.index]||0)+1;for(p=0,c=new Array(b);p<b;++p)E=i[p],c[p]=l[E.source.index]/(l[E.source.index]+l[E.target.index]);n=new Array(b),x(),r=new Array(b),m()}}function x(){if(o)for(var p=0,v=i.length;p<v;++p)n[p]=+t(i[p],p,i)}function m(){if(o)for(var p=0,v=i.length;p<v;++p)r[p]=+s(i[p],p,i)}return f.initialize=function(p,...v){o=p,u=v.find(b=>typeof b=="function")||Math.random,a=v.find(b=>[1,2,3].includes(b))||2,g()},f.links=function(p){return arguments.length?(i=p,g(),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:vt(+p),x(),f):t},f.distance=function(p){return arguments.length?(s=typeof p=="function"?p:vt(+p),m(),f):s},f}var ly={value:()=>{}};function lp(){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 cl(t)}function cl(i){this._=i}function cy(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}})}cl.prototype=lp.prototype={constructor:cl,on:function(i,e){var t=this._,n=cy(i+"",t),s,r=-1,o=n.length;if(arguments.length<2){for(;++r<o;)if((s=(i=n[r]).type)&&(s=hy(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]=ap(t[s],i.name,e);else if(e==null)for(s in t)t[s]=ap(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 cl(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 hy(i,e){for(var t=0,n=i.length,s;t<n;++t)if((s=i[t]).name===e)return s.value}function ap(i,e,t){for(var n=0,s=i.length;n<s;++n)if(i[n].name===e){i[n]=ly,i=i.slice(0,n).concat(i.slice(n+1));break}return t!=null&&i.push({name:e,value:t}),i}var Ph=lp;var ks=0,Vr=0,zr=0,hp=1e3,hl,Gr,ul=0,ji=0,dl=0,Hr=typeof performance=="object"&&performance.now?performance:Date,up=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(i){setTimeout(i,17)};function Nh(){return ji||(up(uy),ji=Hr.now()+dl)}function uy(){ji=0}function Ih(){this._call=this._time=this._next=null}Ih.prototype=fl.prototype={constructor:Ih,restart:function(i,e,t){if(typeof i!="function")throw new TypeError("callback is not a function");t=(t==null?Nh():+t)+(e==null?0:+e),!this._next&&Gr!==this&&(Gr?Gr._next=this:hl=this,Gr=this),this._call=i,this._time=t,Lh()},stop:function(){this._call&&(this._call=null,this._time=1/0,Lh())}};function fl(i,e,t){var n=new Ih;return n.restart(i,e,t),n}function dp(){Nh(),++ks;for(var i=hl,e;i;)(e=ji-i._time)>=0&&i._call.call(void 0,e),i=i._next;--ks}function cp(){ji=(ul=Hr.now())+dl,ks=Vr=0;try{dp()}finally{ks=0,fy(),ji=0}}function dy(){var i=Hr.now(),e=i-ul;e>hp&&(dl-=e,ul=i)}function fy(){for(var i,e=hl,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:hl=t);Gr=i,Lh(n)}function Lh(i){if(!ks){Vr&&(Vr=clearTimeout(Vr));var e=i-ji;e>24?(i<1/0&&(Vr=setTimeout(cp,i-Hr.now()-dl)),zr&&(zr=clearInterval(zr))):(zr||(ul=Hr.now(),zr=setInterval(dy,hp)),ks=1,up(cp))}}function fp(){let i=1;return()=>(i=(1664525*i+1013904223)%4294967296)/4294967296}var pp=3;function pl(i){return i.x}function Dh(i){return i.y}function mp(i){return i.z}var py=10,my=Math.PI*(3-Math.sqrt(5)),gy=Math.PI*20/(9+Math.sqrt(221));function Fh(i,e){e=e||2;var t=Math.min(pp,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,u=fl(f),d=Ph("tick","end"),h=fp();i==null&&(i=[]);function f(){g(),d.call("tick",n),s<r&&(u.stop(),d.call("end",n))}function g(p){var v,b=i.length,M;p===void 0&&(p=1);for(var E=0;E<p;++E)for(s+=(a-s)*o,c.forEach(function(w){w(s)}),v=0;v<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=py*(t>2?Math.cbrt(.5+p):t>1?Math.sqrt(.5+p):p),E=p*my,w=p*gy;t===1?b.x=M:t===2?(b.x=M*Math.cos(E),b.y=M*Math.sin(E)):(b.x=M*Math.sin(E)*Math.cos(w),b.y=M*Math.cos(E),b.z=M*Math.sin(E)*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 m(p){return p.initialize&&p.initialize(i,h,t),p}return x(),n={tick:g,restart:function(){return u.restart(f),n},stop:function(){return u.stop(),n},numDimensions:function(p){return arguments.length?(t=Math.min(pp,Math.max(1,Math.round(p))),c.forEach(m),n):t},nodes:function(p){return arguments.length?(i=p,x(),c.forEach(m),n):i},alpha:function(p){return arguments.length?(s=+p,n):s},alphaMin:function(p){return arguments.length?(r=+p,n):r},alphaDecay:function(p){return arguments.length?(o=+p,n):+o},alphaTarget:function(p){return arguments.length?(a=+p,n):a},velocityDecay:function(p){return arguments.length?(l=1-p,n):1-l},randomSource:function(p){return arguments.length?(h=p,c.forEach(m),n):h},force:function(p,v){return arguments.length>1?(v==null?c.delete(p):c.set(p,m(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,E=p.shift()||1/0,w=0,C=i.length,_,T,P,R,I,H;for(E*=E,w=0;w<C;++w)I=i[w],_=v-I.x,T=b-(I.y||0),P=M-(I.z||0),R=_*_+T*T+P*P,R<E&&(H=I,E=R);return H},on:function(p,v){return arguments.length>1?(d.on(p,v),n):d.on(p)}}}function kh(){var i,e,t,n,s,r=vt(-30),o,a=1,l=1/0,c=.81;function u(g){var x,m=i.length,p=(e===1?Or(i,pl):e===2?Ur(i,pl,Dh):e===3?Br(i,pl,Dh,mp):null).visitAfter(h);for(s=g,x=0;x<m;++x)t=i[x],p.visit(f)}function d(){if(i){var g,x=i.length,m;for(o=new Array(x),g=0;g<x;++g)m=i[g],o[m.index]=+r(m,g,i)}}function h(g){var x=0,m,p,v=0,b,M,E,w,C=g.length;if(C){for(b=M=E=w=0;w<C;++w)(m=g[w])&&(p=Math.abs(m.value))&&(x+=m.value,v+=p,b+=p*(m.x||0),M+=p*(m.y||0),E+=p*(m.z||0));x*=Math.sqrt(4/C),g.x=b/v,e>1&&(g.y=M/v),e>2&&(g.z=E/v)}else{m=g,m.x=m.data.x,e>1&&(m.y=m.data.y),e>2&&(m.z=m.data.z);do x+=o[m.data.index];while(m=m.next)}g.value=x}function f(g,x,m,p,v){if(!g.value)return!0;var b=[m,p,v][e-1],M=g.x-t.x,E=e>1?g.y-t.y:0,w=e>2?g.z-t.z:0,C=b-x,_=M*M+E*E+w*w;if(C*C/c<_)return _<l&&(M===0&&(M=In(n),_+=M*M),e>1&&E===0&&(E=In(n),_+=E*E),e>2&&w===0&&(w=In(n),_+=w*w),_<a&&(_=Math.sqrt(a*_)),t.vx+=M*g.value*s/_,e>1&&(t.vy+=E*g.value*s/_),e>2&&(t.vz+=w*g.value*s/_)),!0;if(g.length||_>=l)return;(g.data!==t||g.next)&&(M===0&&(M=In(n),_+=M*M),e>1&&E===0&&(E=In(n),_+=E*E),e>2&&w===0&&(w=In(n),_+=w*w),_<a&&(_=Math.sqrt(a*_)));do g.data!==t&&(C=o[g.data.index]*s/_,t.vx+=M*C,e>1&&(t.vy+=E*C),e>2&&(t.vz+=w*C));while(g=g.next)}return u.initialize=function(g,...x){i=g,n=x.find(m=>typeof m=="function")||Math.random,e=x.find(m=>[1,2,3].includes(m))||2,d()},u.strength=function(g){return arguments.length?(r=typeof g=="function"?g:vt(+g),d(),u):r},u.distanceMin=function(g){return arguments.length?(a=g*g,u):Math.sqrt(a)},u.distanceMax=function(g){return arguments.length?(l=g*g,u):Math.sqrt(l)},u.theta=function(g){return arguments.length?(c=g*g,u):Math.sqrt(c)},u}function Oh(i){var e=vt(.1),t,n,s;typeof i!="function"&&(i=vt(i==null?0:+i));function r(a){for(var l=0,c=t.length,u;l<c;++l)u=t[l],u.vx+=(s[l]-u.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:vt(+a),o(),r):e},r.x=function(a){return arguments.length?(i=typeof a=="function"?a:vt(+a),o(),r):i},r}function Uh(i){var e=vt(.1),t,n,s;typeof i!="function"&&(i=vt(i==null?0:+i));function r(a){for(var l=0,c=t.length,u;l<c;++l)u=t[l],u.vy+=(s[l]-u.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:vt(+a),o(),r):e},r.y=function(a){return arguments.length?(i=typeof a=="function"?a:vt(+a),o(),r):i},r}function Bh(i){var e=vt(.1),t,n,s;typeof i!="function"&&(i=vt(i==null?0:+i));function r(a){for(var l=0,c=t.length,u;l<c;++l)u=t[l],u.vz+=(s[l]-u.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:vt(+a),o(),r):e},r.z=function(a){return arguments.length?(i=typeof a=="function"?a:vt(+a),o(),r):i},r}var Wr=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=Fh(this.simNodes,3).alphaDecay(1-Math.pow(.001,1/300)).velocityDecay(n.velocityDecay).force("link",Rh(r).distance(n.linkDistance).strength(this.linkStrengthFn(n.linkStrength))).force("charge",kh().strength(n.charge).distanceMax(800)).force("x",Oh(0).strength(n.centerPull)).force("y",Uh(0).strength(n.centerPull+n.flatten)).force("z",Bh(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 gp=`"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([gp],{type:"text/javascript"})),this.worker=new Worker(this.url),this.worker.onmessage=d=>{let h=d.data;if(h.type!=="tick")return;let f=new Float32Array(h.buffer);this.positions.set(f.subarray(0,this.positions.length)),this._ticks=h.ticks,this.settled=h.settled,this.dirty=!0,this.worker?.postMessage({type:"buffer",buffer:h.buffer},[h.buffer])};let r=e.nodes.length,o=new Float32Array(t),a=new Uint32Array(e.links.length*2);e.links.forEach((d,h)=>{a[h*2]=d.source,a[h*2+1]=d.target});let l=new Float32Array(r);e.nodes.forEach((d,h)=>l[h]=Math.max(d.degree,1));let c=new ArrayBuffer(r*3*4),u=new ArrayBuffer(r*3*4);this.settled=s<.001,this.worker.postMessage({type:"init",count:r,positions:o.buffer,links:a.buffer,degrees:l.buffer,params:n,initialAlpha:s,bufA:c,bufB:u},[o.buffer,a.buffer,l.buffer,c,u])}step(){let 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 Os={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,fragmentShader:`
uniform float opacity;
uniform sampler2D tDiffuse;
varying vec2 vUv;
void main() {
vec4 texel = texture2D( tDiffuse, vUv );
gl_FragColor = opacity * texel;
}`};var mn=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(){}},vy=new si(-1,1,1,-1,0,1),zh=class extends ht{constructor(){super(),this.setAttribute("position",new Ut([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Ut([0,2,0,0,2,0],2))}},_y=new zh,ki=class{constructor(e){this._mesh=new Xt(_y,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,vy)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}};var gl=class extends mn{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=oi.clone(e.uniforms),this.material=new ut({name:e.name!==void 0?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this._fsQuad=new ki(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this._fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}};var Xr=class extends mn{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)}},xl=class extends mn{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}};var vl=class{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){let n=e.getSize(new Ee);this._width=n.width,this._height=n.height,t=new Rt(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:qt}),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 gl(Os),this.copyPass.material.blending=yn,this.timer=new gr}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()}Xr!==void 0&&(o instanceof Xr?n=!0:o instanceof xl&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){let t=this.renderer.getSize(new Ee);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 _l=class extends mn{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 me}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 xp={name:"LuminosityHighPassShader",uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new me(0)},defaultOpacity:{value:0}},vertexShader:`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,fragmentShader:`
uniform sampler2D tDiffuse;
uniform vec3 defaultColor;
uniform float defaultOpacity;
uniform float luminosityThreshold;
uniform float smoothWidth;
varying vec2 vUv;
void main() {
vec4 texel = texture2D( tDiffuse, vUv );
float v = luminance( texel.xyz );
vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );
float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );
gl_FragColor = mix( outputColor, texel, alpha );
}`};var Us=class i extends mn{constructor(e,t=1,n,s){super(),this.strength=t,this.radius=n,this.threshold=s,this.resolution=e!==void 0?new Ee(e.x,e.y):new Ee(256,256),this.clearColor=new me(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 Rt(r,o,{type:qt}),this.renderTargetBright.texture.name="UnrealBloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(let u=0;u<this.nMips;u++){let d=new Rt(r,o,{type:qt});d.texture.name="UnrealBloomPass.h"+u,d.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(d);let h=new Rt(r,o,{type:qt});h.texture.name="UnrealBloomPass.v"+u,h.texture.generateMipmaps=!1,this.renderTargetsVertical.push(h),r=Math.round(r/2),o=Math.round(o/2)}let a=xp;this.highPassUniforms=oi.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 u=0;u<this.nMips;u++)this.separableBlurMaterials.push(this._getSeparableBlurMaterial(l[u])),this.separableBlurMaterials[u].uniforms.invSize.value=new Ee(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=oi.clone(Os.uniforms),this.blendMaterial=new ut({uniforms:this.copyUniforms,vertexShader:Os.vertexShader,fragmentShader:Os.fragmentShader,premultipliedAlpha:!0,blending:_r,depthTest:!1,depthWrite:!1,transparent:!0}),this._oldClearColor=new me,this._oldClearAlpha=1,this._basic=new ti,this._fsQuad=new ki(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 Ee(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 Ee(.5,.5)},direction:{value:new Ee(.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 );
}`})}};Us.BlurDirectionX=new Ee(1,0);Us.BlurDirectionY=new Ee(0,1);var qr={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 yl=class extends mn{constructor(){super(),this.isOutputPass=!0,this.uniforms=oi.clone(qr.uniforms),this.material=new As({name:qr.name,uniforms:this.uniforms,vertexShader:qr.vertexShader,fragmentShader:qr.fragmentShader}),this._fsQuad=new ki(this.material),this._outputColorSpace=null,this._toneMapping=null}render(e,t,n){this.uniforms.tDiffuse.value=n.texture,this.uniforms.toneMappingExposure.value=e.toneMappingExposure,(this._outputColorSpace!==e.outputColorSpace||this._toneMapping!==e.toneMapping)&&(this._outputColorSpace=e.outputColorSpace,this._toneMapping=e.toneMapping,this.material.defines={},ze.getTransfer(this._outputColorSpace)===Je&&(this.material.defines.SRGB_TRANSFER=""),this._toneMapping===yr?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===br?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===Mr?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===Pi?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===wr?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===Er?this.material.defines.NEUTRAL_TONE_MAPPING="":this._toneMapping===Sr&&(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 bl=`
attribute float aSize;
attribute float aGhost;
attribute float aDim;
varying vec3 vColor;
varying float vGhost;
varying float vDim;
uniform float uPixelScale; // drawingBufferHeight / (2\xB7tan(fov/2))
uniform float uSizeMul; // \u63A7\u5236\u9762\u677F\u300C\u8282\u70B9\u5927\u5C0F\u300D\u500D\u7387
uniform float uMaxPoint; // \u8BBE\u5907\u50CF\u7D20\u94B3\u5236\uFF1A\u7A7F\u884C\u661F\u56E2\u65F6\u9632\u6EE1\u5C4F\u5927\u7CBE\u7075\u6253\u7206\u586B\u5145\u7387\uFF08M3\uFF09
void main() {
vColor = color;
vGhost = aGhost;
vDim = aDim;
vec4 mv = modelViewMatrix * vec4(position, 1.0);
gl_PointSize = min(aSize * uSizeMul * uPixelScale / max(-mv.z, 1.0), uMaxPoint);
gl_Position = projectionMatrix * mv;
}
`,Ml=`
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.18, 0.0, d) * 0.55 * (1.0 - vGhost) * (1.0 - uLightMode);
vec3 col = mix(vColor, vec3(1.0), core);
// \u6668\u663C\uFF1A\u5916\u7F18 1px \u6DF1\u8272 rim\uFF0C\u8BA9\u8282\u70B9\u300C\u5750\u5728\u7EB8\u4E0A\u300D
float rim = smoothstep(0.40, 0.46, d) * smoothstep(0.50, 0.46, d);
col = mix(col, col * 0.72, rim * uLightMode);
float alpha = smoothstep(0.5, 0.42, d) * mix(1.0, 0.45, vGhost) * vDim;
if (alpha < 0.01) discard;
gl_FragColor = vec4(col, alpha);
}
`;function Yr(i){let e=i.map(t=>({prefix:t.query.startsWith("path:")?t.query.slice(5).trim():null,raw:t.query,color:new me(t.color)}));return t=>{if(t.unresolved)return yp;for(let n of e)if(n.prefix!==null?t.id.startsWith(n.prefix):t.id.includes(n.raw))return n.color;return bp(t.folderTop,!1)}}var Sl=i=>bp(i.folderTop,i.unresolved),vp=[0,40,80,120,160,200,240,280,320],yy=new me("#9aa4b2"),yp=new me("#7a8499"),_p=new Map;function bp(i,e){if(e)return yp;if(i==="")return yy;let t=_p.get(i);if(!t){let n=vp[Eh(i)%vp.length]??0;t=new me().setHSL(n/360,.6,.6),_p.set(i,t)}return t}function Mp(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 by=[{count:2600,size:1.2},{count:900,size:2},{count:250,size:3}],My=new me("#9da8c4"),Sy=new me("#ffffff"),wy=new me("#ffe9c9"),Ey=new me("#bfd3ff");function Ty(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 Vh(i){for(let e of i.children){let t=e;t.geometry.dispose(),t.material.dispose()}}var wl=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 Gh(i,e=1){let t=new Jn,n=Ty(5340353),s=null;for(let r of by){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 h=0;h<o.count;h++){let f=2*Math.PI*n(),g=Math.acos(2*n()-1),x=i*(.95+.1*n());a[h*3]=x*Math.sin(g)*Math.cos(f),a[h*3+1]=x*Math.sin(g)*Math.sin(f),a[h*3+2]=x*Math.cos(g);let m=n(),p=m<.85?My.clone().lerp(Sy,n()):m<.95?wy.clone():Ey.clone();o.size>=3&&n()<.03&&p.multiplyScalar(1.8),l[h*3]=p.r,l[h*3+1]=p.g,l[h*3+2]=p.b}let c=new ht;c.setAttribute("position",new Ye(a,3)),c.setAttribute("color",new Ye(l,3));let u=new Ei({size:o.size,sizeAttenuation:!1,vertexColors:!0,transparent:!0,opacity:.55,depthWrite:!1}),d=new Bn(c,u);d.renderOrder=-1,t.add(d),o.size>=3&&(s=new wl(c,o.count))}return{group:t,twinkler:s??new wl(new ht().setAttribute("color",new Ye(new Float32Array(3),3)),1)}}var El={id:"deep-space",background:3,starfield:!0,motes:!1,bloomEnabled:!0,lightMode:!1,nodeLightness:null,linkInk:null,linkOpacityScale:1,panelClass:"gx-theme-dark"},Sp={id:"daylight",background:16184559,starfield:!1,motes:!0,bloomEnabled:!1,lightMode:!0,nodeLightness:.44,linkInk:"#2e2a24",linkOpacityScale:.65,panelClass:"gx-theme-light"};var Ay=.12,Cy=.28,Tl=class{constructor(e,t){this.scene=new Zi;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=Sl;this.tokens=El;this.tierBloomAllowed=!0;this.lastW=2;this.lastH=2;this.baseLinkOpacity=.16;this.focusActive=!1;this.projVec=new N;this.pixelScale=1;this.nodeScale=1;this.sizeMode="degree";this.graphRadiusEstimate=t,this.renderer=new Ds({antialias:!1,alpha:!1}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.renderer.toneMapping=Pi,this.renderer.toneMappingExposure=1.05,this.renderer.info.autoReset=!1,e.appendChild(this.renderer.domElement),this.scene.background=new me(this.tokens.background),this.camera=new Wt(60,1,.5,5e4);let n=Gh(t*6.5);this.starfield=n.group,this.twinkler=n.twinkler,this.scene.add(this.starfield),this.composer=new vl(this.renderer),this.renderPass=new _l(this.scene,this.camera),this.bloomPass=new Us(new Ee(2,2),Jr.strength,Jr.radius,Jr.threshold),this.outputPass=new yl,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:bl,fragmentShader:Ml,vertexColors:!0,transparent:!0,depthWrite:!1,uniforms:{uPixelScale:{value:this.pixelScale},uSizeMul:{value:this.nodeScale},uLightMode:{value:this.tokens.lightMode?1:0},uMaxPoint:{value:110*this.renderer.getPixelRatio()}}}),this.nodePoints=new Bn(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 ni({vertexColors:!0,transparent:!0,opacity:this.effectiveLinkOpacity(),depthWrite:!1}),this.linkSegments=new wi(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(ss*(.7+1.1*Math.cbrt(e.fileSize/4096)),1.6),tc);case"uniform":return ss*1.3;default:return Math.min(ss*(1+.5*Math.sqrt(e.degree)),tc)}}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 g=l[f*3]??0,x=l[f*3+1]??0,m=l[f*3+2]??0,p=Math.hypot(g,x,m)/s*.55,v=Math.min(Math.max((r-p)/.45,0),1),b=1-Math.pow(1-v,3);a[f*3]=g*b,a[f*3+1]=x*b,a[f*3+2]=m*b}let c=this.nodeGeometry.getAttribute("position");c.array.set(a.subarray(0,o*3)),c.needsUpdate=!0;let u=this.linkGeometry.getAttribute("position"),d=u.array,h=this.data.links;for(let f=0;f<h.length;f++){let g=h[f];if(!g)continue;let x=g.source*3,m=g.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[m]??0,d[p+4]=a[m+1]??0,d[p+5]=a[m+2]??0}u.needsUpdate=!0,this.linkMaterial&&(this.linkMaterial.opacity=this.effectiveLinkOpacity()*Math.min(r*1.6,1))}get revealing(){return this.reveal!==null}recolor(){if(!this.nodeGeometry||!this.linkGeometry)return;let 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 u=0;u<e;u++){let d=this.data.nodes[u];if(!d)continue;let h=this.colorFn(d).clone();this.tokens.nodeLightness!==null&&(h.getHSL(r),h=h.setHSL(r.h,r.s*.95,this.tokens.nodeLightness)),s[u]=h,n[u*3]=h.r,n[u*3+1]=h.g,n[u*3+2]=h.b}t.needsUpdate=!0;let o=this.linkGeometry.getAttribute("color"),a=o.array,l=this.tokens.linkInk?new me(this.tokens.linkInk):null,c=new me("#7a87a8");for(let u=0;u<this.data.links.length;u++){let d=this.data.links[u];if(!d)continue;let h=l??Mp(s[d.source]??c,s[d.target]??c);for(let f of[0,1])a[(u*2+f)*3]=h.r,a[(u*2+f)*3+1]=h.g,a[(u*2+f)*3+2]=h.b}o.needsUpdate=!0}updatePositions(){if(!this.nodeGeometry||!this.linkGeometry)return;let 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,u=l.target*3,d=a*6;s[d]=r[c]??0,s[d+1]=r[c+1]??0,s[d+2]=r[c+2]??0,s[d+3]=r[u]??0,s[d+4]=r[u+1]??0,s[d+5]=r[u+2]??0}n.needsUpdate=!0,this.updateSelPositions()}setFocus(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:Ay;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 me("#9aa4b2");c.getHSL(r),c.setHSL(r.h,Math.min(r.s*1.2,1),this.tokens.lightMode?.42:.62);for(let u of[0,1])s[o*6+u*3]=c.r,s[o*6+u*3+1]=c.g,s[o*6+u*3+2]=c.b}this.selGeometry=new ht,this.selGeometry.setAttribute("position",new Ye(n,3)),this.selGeometry.setAttribute("color",new Ye(s,3)),this.selMaterial=new ni({vertexColors:!0,transparent:!0,opacity:.85,depthWrite:!1}),this.selSegments=new wi(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 me(e.background),this.starfield.visible=e.starfield,this.renderer.toneMapping=e.lightMode?fn:Pi,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 Ei({color:new me("#d8d4cb"),size:1.6,sizeAttenuation:!0,transparent:!0,opacity:.5,depthWrite:!1});this.motes=new Bn(s,r),this.motes.renderOrder=-1,this.scene.add(this.motes)}render(e){this.starfield.rotation.y+=nc*e,this.starfield.visible&&this.twinkler.update(e,this.twinkleFreq),this.motes?.visible&&(this.motes.rotation.y-=nc*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/Cy,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;Vh(this.starfield),this.scene.remove(this.starfield);let r=Gh(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){return this.projVec.set(this.positions[e*3]??0,this.positions[e*3+1]??0,this.positions[e*3+2]??0),this.projVec.project(this.camera),{x:(this.projVec.x+1)/2*t,y:(1-this.projVec.y)/2*n,behind:this.projVec.z>1}}pickNearest(e,t,n,s,r){let o=-1,a=r;for(let l=0;l<this.data.nodes.length;l++){let c=this.projectNode(l,n,s);if(c.behind)continue;let u=Math.hypot(c.x-e,c.y-t);u<a&&(a=u,o=l)}return o}nodeRadius(e){return this.sizes[e]??ss}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(),Vh(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 wp={type:"change"},Wh={type:"start"},Tp={type:"end"},Al=new Si,Ep=new _n,Ry=Math.cos(70*Qc.DEG2RAD),Lt=new N,tn=2*Math.PI,it={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Hh=1e-6,Cl=class extends xr{constructor(e,t=null){super(e,t),this.state=it.NONE,this.target=new N,this.cursor=new N,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Cn.ROTATE,MIDDLE:Cn.DOLLY,RIGHT:Cn.PAN},this.touches={ONE:Ri.ROTATE,TWO:Ri.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new N,this._lastQuaternion=new hn,this._lastTargetPosition=new N,this._quat=new hn().setFromUnitVectors(e.up,new N(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new dn,this._sphericalDelta=new dn,this._scale=1,this._panOffset=new N,this._rotateStart=new Ee,this._rotateEnd=new Ee,this._rotateDelta=new Ee,this._panStart=new Ee,this._panEnd=new Ee,this._panDelta=new Ee,this._dollyStart=new Ee,this._dollyEnd=new Ee,this._dollyDelta=new Ee,this._dollyDirection=new N,this._mouse=new Ee,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Iy.bind(this),this._onPointerDown=Py.bind(this),this._onPointerUp=Ly.bind(this),this._onContextMenu=By.bind(this),this._onMouseWheel=Fy.bind(this),this._onKeyDown=ky.bind(this),this._onTouchStart=Oy.bind(this),this._onTouchMove=Uy.bind(this),this._onMouseDown=Ny.bind(this),this._onMouseMove=Dy.bind(this),this._interceptControlDown=zy.bind(this),this._interceptControlUp=Vy.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction=""}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(wp),this.update(),this.state=it.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;Lt.copy(t).sub(this.target),Lt.applyQuaternion(this._quat),this._spherical.setFromVector3(Lt),this.autoRotate&&this.state===it.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(n)&&isFinite(s)&&(n<-Math.PI?n+=tn:n>Math.PI&&(n-=tn),s<-Math.PI?s+=tn:s>Math.PI&&(s-=tn),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=o!=this._spherical.radius}if(Lt.setFromSpherical(this._spherical),Lt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Lt),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){let a=Lt.length();o=this._clampDistance(a*this._scale);let l=a-o;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){let a=new N(this._mouse.x,this._mouse.y,0);a.unproject(this.object);let l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;let c=new N(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),o=Lt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(Al.origin.copy(this.object.position),Al.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Al.direction))<Ry?this.object.lookAt(this.target):(Ep.setFromNormalAndCoplanarPoint(this.object.up,this.target),Al.intersectPlane(Ep,this.target))))}else if(this.object.isOrthographicCamera){let o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>Hh||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Hh||this._lastTargetPosition.distanceToSquared(this.target)>Hh?(this.dispatchEvent(wp),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?tn/60*this.autoRotateSpeed*e:tn/60/60*this.autoRotateSpeed}_getZoomScale(e){let t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Lt.setFromMatrixColumn(t,0),Lt.multiplyScalar(-e),this._panOffset.add(Lt)}_panUp(e,t){this.screenSpacePanning===!0?Lt.setFromMatrixColumn(t,1):(Lt.setFromMatrixColumn(t,0),Lt.crossVectors(this.object.up,Lt)),Lt.multiplyScalar(e),this._panOffset.add(Lt)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let s=this.object.position;Lt.copy(s).sub(this.target);let r=Lt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),s=e-n.left,r=t-n.top,o=n.width,a=n.height;this._mouse.x=s/o*2-1,this._mouse.y=-(r/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(tn*this._rotateDelta.x/t.clientHeight),this._rotateUp(tn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(tn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-tn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(tn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-tn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(n,s)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(n*n+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let n=this._getSecondPointerPosition(e),s=.5*(e.pageX+n.x),r=.5*(e.pageY+n.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(tn*this._rotateDelta.x/t.clientHeight),this._rotateUp(tn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new Ee,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}};function Py(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function Iy(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function Ly(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Tp),this.state=it.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:let e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function Ny(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:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=it.DOLLY;break;case Cn.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=it.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=it.ROTATE}break;case Cn.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=it.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=it.PAN}break;default:this.state=it.NONE}this.state!==it.NONE&&this.dispatchEvent(Wh)}function Dy(i){switch(this.state){case it.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case it.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case it.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function Fy(i){this.enabled===!1||this.enableZoom===!1||this.state!==it.NONE||(i.preventDefault(),this.dispatchEvent(Wh),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(Tp))}function ky(i){this.enabled!==!1&&this._handleKeyDown(i)}function Oy(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case Ri.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=it.TOUCH_ROTATE;break;case Ri.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=it.TOUCH_PAN;break;default:this.state=it.NONE}break;case 2:switch(this.touches.TWO){case Ri.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=it.TOUCH_DOLLY_PAN;break;case Ri.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=it.TOUCH_DOLLY_ROTATE;break;default:this.state=it.NONE}break;default:this.state=it.NONE}this.state!==it.NONE&&this.dispatchEvent(Wh)}function Uy(i){switch(this._trackPointer(i),this.state){case it.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case it.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case it.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case it.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=it.NONE}}function By(i){this.enabled!==!1&&i.preventDefault()}function zy(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Vy(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Gy(i){return i<.5?4*i*i*i:1-Math.pow(-2*i+2,3)/2}var Hy=new Set(["w","a","s","d","q","e"]),Rl=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 dn;this.tmpDir=new N;this.tmpRight=new N;this.disposeFns=[];this.controls=new Cl(e,t),this.controls.enableDamping=!0,this.controls.dampingFactor=.08,this.lastInputAt=performance.now(),t.tabIndex=0,this.bindPointer(),this.bindKeys()}get target(){return this.controls.target}markInput(){this.lastInputAt=performance.now(),this.cruiseAnchor=null,this.tween=null}bindPointer(){let 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,Hy.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()-Dn.resumeDelayMs-1}flyTo(e,t,n){let s=Math.min(Math.max(t*Xn.distancePerRadius,Xn.minDistance),Xn.maxDistance),r=this.camera.position.clone().sub(e);r.lengthSq()<1e-6&&r.set(0,0,1),this.tmpSph.setFromVector3(r),this.tmpSph.theta+=Xn.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(Xn.minMs+Xn.msPerWorldUnit*a,Xn.minMs),Xn.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=Gy(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>Dn.resumeDelayMs){let r=Math.min((s-Dn.resumeDelayMs)/Dn.rampUpMs,1);if(!this.cruiseAnchor){if(this.cruiseAnchor=new dn().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 dn().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=Dn.elevationDeg*Math.PI/180*Math.sin(2*Math.PI*o/Dn.elevationPeriodS),c=1+Dn.radiusBreath*Math.sin(2*Math.PI*o/Dn.radiusPeriodS);return this.tmpSph.radius=a.radius*c,this.tmpSph.theta=a.theta+this.cruiseDir*Dn.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 Ap=[{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 Pl=[{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 Il=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.presetBtn=null;this.unresolvedBtn=null;this.orphanBtn=null;this.sizeByBtn=null;this.qualityBtn=null;this.styleChips=[];this.root=e.createDiv({cls:"galaxy-panel gx-theme-dark mwm-map-panel"});let o=this.root.createDiv({cls:"galaxy-panel-header"});this.statsEl=o.createDiv({cls:"galaxy-panel-stats",text:"\u2026"});let a=o.createEl("button",{cls:"galaxy-panel-collapse",text:"-"});this.body=this.root.createDiv({cls:"galaxy-panel-body"}),a.addEventListener("click",()=>{let l=this.body.hasClass("is-hidden");this.body.toggleClass("is-hidden",!l),a.setText(l?"-":"+")}),this.render()}render(){this.body.empty(),this.sliders=[],this.styleChips=[],this.cruiseBtn=null,this.presetBtn=null,this.unresolvedBtn=null,this.orphanBtn=null,this.sizeByBtn=null,this.qualityBtn=null;let 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=xn,s=e.createDiv({cls:"galaxy-panel-row"});this.presetBtn=s.createEl("button",{text:this.presetLabel()}),this.presetBtn.addEventListener("click",()=>{t.preset=t.preset==="deep-space"?"adaptive":"deep-space",this.presetBtn?.setText(this.presetLabel()),this.cb.onPreset()});let r=e.createDiv({cls:"gx-chips"});for(let h of Ap){let f=r.createEl("button",{cls:"gx-chip",text:this.tt(`style.${h.id}`)});f.addEventListener("click",()=>{this.cb.onStylePreset(h),this.refreshAll(),this.markActiveChip(h.id)}),f.dataset.presetId=h.id,this.styleChips.push(f)}this.sliders.push(new Jt(e,this.slider("3d.nodeSize",.3,2.5,.05,n.look.nodeSize,()=>t.look.nodeSize,h=>t.look.nodeSize=h,Xh("x"),this.cb.onLook)),new Jt(e,this.slider("3d.linkOpacity",0,.6,.01,n.look.linkOpacity,()=>t.look.linkOpacity,h=>t.look.linkOpacity=h,void 0,this.cb.onLook)),new Jt(e,this.slider("3d.twinkle",0,2,.1,n.look.twinkle,()=>t.look.twinkle,h=>t.look.twinkle=h,h=>h<.05?this.tt("3d.twinkleOff"):h.toFixed(1),this.cb.onLook)),new Jt(e,this.slider("3d.glowStrength",0,2.5,.05,n.bloom.strength,()=>t.bloom.strength,h=>t.bloom.strength=h,void 0,this.cb.onBloom)),new Jt(e,this.slider("3d.glowRadius",0,1.2,.05,n.bloom.radius,()=>t.bloom.radius,h=>t.bloom.radius=h,void 0,this.cb.onBloom)),new Jt(e,this.slider("3d.glowThreshold",0,1,.05,n.bloom.threshold,()=>t.bloom.threshold,h=>t.bloom.threshold=h,void 0,this.cb.onBloom)));let o=e.createDiv({cls:"galaxy-panel-row"});this.sizeByBtn=o.createEl("button",{text:this.sizeByLabel()}),this.sizeByBtn.addEventListener("click",()=>{let h=["degree","fileSize","uniform"];t.look.sizeBy=h[(h.indexOf(t.look.sizeBy)+1)%h.length]??"degree",this.sizeByBtn?.setText(this.sizeByLabel()),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 h of Pl)a.createEl("option",{text:this.tt(`color.${h.id}`),value:h.id});a.value=Pl.some(h=>h.id===t.colorTheme)?t.colorTheme:"",a.value||(l.selected=!0),a.addEventListener("change",()=>{let h=Pl.find(f=>f.id===a.value);h&&this.cb.onColorTheme(h)});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=xn;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,Xh("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=xn,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,Xh("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:ui(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")}}presetLabel(){return`${this.tt("view.theme")}: ${this.settings.preset==="deep-space"?this.tt("theme.deep"):this.tt("theme.auto")}`}cruiseLabel(){return this.settings.cruise?this.tt("3d.cruiseOn"):this.tt("3d.cruiseOff")}unresolvedLabel(){return this.settings.showUnresolved?this.tt("3d.unresolvedShow"):this.tt("3d.unresolvedHide")}orphanLabel(){return this.settings.showOrphans?this.tt("3d.orphansShow"):this.tt("3d.orphansHide")}sizeByLabel(){return this.tt(`3d.size.${this.settings.look.sizeBy}`)}qualityLabel(){return this.tt(`3d.quality.${this.settings.qualityOverride}`)}markActiveChip(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.presetBtn?.setText(this.presetLabel()),this.unresolvedBtn?.setText(this.unresolvedLabel()),this.orphanBtn?.setText(this.orphanLabel()),this.sizeByBtn?.setText(this.sizeByLabel()),this.qualityBtn?.setText(this.qualityLabel())}setLanguage(e){this.language=e,this.render()}setPanelTheme(e){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 Ce(this.language,e,t)}};function Xh(i){return e=>i==="x1"?`${e.toFixed(1)}x`:`${e.toFixed(2)}x`}var Nl=require("obsidian");var Ll=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 Nl.TFile?r:null;if(o){let u=this.app.metadataCache.getFileCache(o),d=u?(0,Nl.getAllTags)(u)??[]:[];if(d.length>0){let h=this.card.createDiv({cls:"gx-card-tags"});for(let f of d.slice(0,5))h.createSpan({cls:"gx-card-tag",text:f})}}if(this.card.createDiv({cls:"gx-card-stats"}).setText(this.tt("3d.card.stats",{in: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 u=this.card.createDiv({cls:"gx-card-snippet",text:"\u2026"}),d=++this.snippetToken;this.app.vault.cachedRead(o).then(h=>{d===this.snippetToken&&u.setText(Wy(h).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 Ce(this.language,e,t)}};function Wy(i){return i.replace(/^---\n[\s\S]*?\n---\n?/,"").replace(/!?\[\[([^\]|]+)(\|[^\]]+)?\]\]/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/[#*`>~_]|---/g,"").replace(/\s+/g," ").trim()}var Fl=require("obsidian");var Dl=class extends Fl.SuggestModal{constructor(t,n,s,r="en"){super(t);this.nodes=n;this.onPick=s;this.language=r;this.setPlaceholder(this.tt("3d.searchPlaceholder"))}getSuggestions(t){let n=t.trim();if(!n)return[...this.nodes.entries()].filter(([,o])=>!o.unresolved).sort((o,a)=>a[1].degree-o[1].degree).slice(0,20).map(([o,a])=>({index:o,node:a,score:0}));let s=(0,Fl.prepareFuzzySearch)(n),r=[];for(let o=0;o<this.nodes.length;o++){let a=this.nodes[o];if(!a)continue;let l=s(a.name)??s(a.id);l&&r.push({index:o,node:a,score:l.score})}return r.sort((o,a)=>a.score-o.score||a.node.degree-o.node.degree).slice(0,50)}renderSuggestion(t,n){n.createDiv({text:t.node.name}),n.createDiv({cls:"gx-search-path",text:`${t.node.unresolved?this.tt("3d.searchUnresolved"):t.node.id} \xB7 ${this.tt("3d.searchLinks",{count:t.node.degree})}`})}onChooseSuggestion(t){this.onPick(t.index)}tt(t,n={}){return Ce(this.language,t,n)}};var qh=require("obsidian"),Cp="_galaxy_bench";function Rp(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((h,f)=>h-f),u=n.reduce((h,f)=>h+f,0),d=c[Math.min(Math.floor(c.length*.95),c.length-1)]??0;t({frames:n.length,avgFps:n.length>0?1e3/(u/n.length):0,p95FrameMs:d,worstFrameMs:c[c.length-1]??0,durationMs:u})}};window.requestAnimationFrame(o)})}function Pp(){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 Yh(i,e){let t=i.vault.adapter,n=(0,qh.normalizePath)(Cp);await t.exists(n)||await t.mkdir(n);let s=(0,qh.normalizePath)(`${Cp}/${e.scenario}-${Date.now()}.json`);return await t.write(s,JSON.stringify(e,null,2)),s}function Zh(i){return new Promise(e=>window.setTimeout(e,i))}var Bs={high:{id:"high",pixelRatioCap:2,bloomAllowed:!0,starScale:1,nodeCap:null,linkCap:null,hubLabels:14,neighborLabels:20,hoverThrottleMs:30},low:{id:"low",pixelRatioCap:1,bloomAllowed:!0,starScale:.4,nodeCap:null,linkCap:null,hubLabels:8,neighborLabels:12,hoverThrottleMs:80},mobile:{id:"mobile",pixelRatioCap:1.5,bloomAllowed:!1,starScale:.32,nodeCap:1500,linkCap:12e3,hubLabels:6,neighborLabels:8,hoverThrottleMs:null}};var Xy=.8,qy=3200,kl=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=Bs.high;this.watchdogTripped=!1;this.lowFpsChecks=0;this.lastWatchdogAt=0;this.onContextLost=null;this.store=new al(e),this.saveSoon=(0,_t.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()>=Xy,n=this.contentEl.createDiv({cls:"galaxy-view-canvas"});this.graphRadius=ol(this.store.data.nodes.length)*1.6;let s=new Tl(n,this.graphRadius);this.renderer=s,s.setColorFn(this.settings.colorGroups.length>0?Yr(this.settings.colorGroups):Sl),s.setData(this.store.data,this.store.positions),this.initLayout(t?.06:1),this.director=new Rl(s.camera,s.renderer.domElement,{onFlyToSelected:()=>this.flyToSelected(),onResetView:()=>this.recenter()}),this.overlay=new Ll(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)}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:qy,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=Xs(this.settings.physics);try{this.layout.init(this.store.data,this.store.positions,t,e)}catch{if(this.layout instanceof Wr)throw new Error("layout init failed");this.layout.dispose(),this.layout=new Wr,this.layout.init(this.store.data,this.store.positions,t,e),new _t.Notice(this.tt("3d.workerFallback"))}}pickTier(){if(_t.Platform.isMobile)return Bs.mobile;let e=this.settings.qualityOverride;return e==="high"||e==="low"||e==="mobile"?Bs[e]:this.watchdogTripped?Bs.low:Bs.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 _t.Notice(this.tt("3d.mobileCap",{cap:this.tier.nodeCap,total:t}))}watchdog(e){this.watchdogTripped||_t.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 _t.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(Xs(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(Yr(t)),this.renderer?.recolor(),this.saveSoon()}playRevealManually(){if(!this.layout.isSettled()){new _t.Notice(this.tt("3d.revealWait"));return}this.renderer?.playReveal()}shuffleColors(){let e=this.settings.colorGroups;if(e.length<2){new _t.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(Yr(e)),this.renderer?.recolor(),this.saveSoon()}applyPreset(){if(!this.renderer)return;let e=activeDocument.body.hasClass("theme-dark"),t=this.settings.preset==="deep-space"||e?El:Sp;this.renderer.applyTokens(t,this.settings.bloom.strength),this.panel?.setPanelTheme(t.id==="daylight"?"gx-theme-light":"gx-theme-dark"),this.contentEl.toggleClass("gx-daylight",t.id==="daylight")}onCssChange(){this.settings.preset==="adaptive"&&this.applyPreset()}async importColors(e){let t=await ef(this.app);if(!t||t.length===0){e&&new _t.Notice(this.tt("3d.importMissing"));return}this.settings.colorGroups=t,this.renderer?.setColorFn(Yr(t)),this.renderer?.recolor(),this.saveSoon(),e&&new _t.Notice(this.tt("3d.importDone",{count:t.length}))}openSearch(){new Dl(this.app,this.store.data.nodes,e=>this.selectNode(e,!0),this.language).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,u=new N;for(let h of r)h!==e&&(l.add(n.nodePosition(h,u)),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 u=e.getBoundingClientRect(),d=this.renderer?.pickNearest(c.clientX-u.left,c.clientY-u.top,u.width,u.height,14)??-1;d>=0?this.selectNode(d,!0):this.clearSelection()},o=!1,a=c=>{let u=this.tier.hoverThrottleMs;u===null||o||(o=!0,window.setTimeout(()=>{o=!1;let d=this.renderer;if(!d)return;let h=e.getBoundingClientRect(),f=d.pickNearest(c.clientX-h.left,c.clientY-h.top,h.width,h.height,10);this.overlay?.setHover(f),e.style.cursor=f>=0?"pointer":"default"},u))},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 Il(this.contentEl,this.settings,this.language,{onViewMode:e=>this.onViewMode?.(e),onBloom:()=>{this.renderer?.setBloomParams(this.settings.bloom),this.saveSoon()},onPhysics:()=>{this.layout.updateParams(Xs(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,xn.bloom),Object.assign(this.settings.physics,xn.physics),Object.assign(this.settings.look,xn.look),this.settings.cruise=xn.cruise,this.settings.cruiseSpeed=xn.cruiseSpeed,this.applySettings(),this.layout.updateParams(Xs(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,_t.setIcon)(t,"languages"),t.addEventListener("click",n=>{n.preventDefault(),n.stopPropagation(),this.openLanguageMenu(t)}),this.disposeFns.push(()=>e.remove())}openLanguageMenu(e){let t=new _t.Menu;for(let[s,r]of as(this.language))t.addItem(o=>{o.setTitle(r),s===this.language&&o.setIcon("check"),o.onClick(()=>{s!==this.language&&(this.language=s,this.overlay?.setLanguage(s),this.panel?.setLanguage(s),this.onLanguage?.(s))})});let n=e.getBoundingClientRect();t.showAtPosition({x:n.right,y:n.bottom})}updateHud(e){for(this.hudFrames.push(e);this.hudFrames.length>0&&e-(this.hudFrames[0]??0)>1e3;)this.hudFrames.shift();let t=this.panel?.statsEl;if(!t||e%500>250)return;let n=this.counts;t.setText(this.tt("stats.3d",{fps:this.hudFrames.length,calls:this.renderer?.drawCalls??0,nodes:n.nodes,links:n.links,state:this.layout.isSettled()?this.tt("state.settled"):this.tt("state.layout")}))}tt(e,t={}){return Ce(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 _t.Notice(this.tt("3d.bench.wait",{scenario:e})),await this.waitSettle(),t.getBloomStrength()<.01&&t.setBloomStrength(.9),await Zh(300),this.benchMode=!0;let r=n.target.clone(),o=new dn().setFromVector3(t.camera.position.clone().sub(r));new _t.Notice(this.tt("3d.bench.orbit",{scenario:e}));let a=await Rp(2e4,c=>{let u=o.theta+c/2e4*Math.PI*2;t.camera.position.setFromSpherical(new dn(o.radius,o.phi,u)).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 Yh(this.app,l),new _t.Notice(this.tt("3d.bench.done",{scenario:e,fps:a.avgFps.toFixed(1),calls:t.drawCalls})),l}async benchColdLayout(){new _t.Notice(this.tt("3d.bench.s2Start")),this.store.getIncludeUnresolved()&&this.store.setIncludeUnresolved(!1),await Zh(300);let e=Pp(),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 Yh(this.app,o),new _t.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 zs=class extends kl{};var kt=require("obsidian");var Ze="",Ip="Vault";var Lp=960,Np=720,Yy=2800,Dp=126,Zy=72,$y=360,Ky=.36,Fp=.28;function kp(i,e){let t=Ge(e.ringSpacing,Np,Yy),n=Ge(e.nodeSpacing,Zy,$y),s=new Map,r=i.nodesById,o=ub(i.nodes),a=i.nodes.filter(T=>!T.externalProxy&&T.type!=="external"),l=new Set(a.map(T=>T.id)),c=sb(i,l,t,n),u=Jy(i,l,r),d=jy(u,r,c),h=l.has(i.rootId)?i.rootId:l.has(Ze)?Ze:a[0]?.id??null;if(h!==null){let T=Ul(0,-Math.PI/2,0,Vs(r.get(h),o),!1);s.set(h,T),Op(h,0,-Math.PI/2,-Math.PI/2+Math.PI*2,-Math.PI/2,u,d,s,r,c,h,o)}let f=new Set(s.keys()),g=a.filter(T=>T.id!==h&&!f.has(T.id)).sort(Ol),x=h!==null?d.get(h):null,m=Math.max(0,x?.maxDepth??0),p=Math.max(db(s),c.ringGap);g.length>0&&(p=Math.max(p,$h(g,s,i,r,p+c.ringGap*.72,c.nodeGap,-Math.PI/2,m+1,!1,o)));let v=i.nodes.filter(T=>T.type==="external"&&!T.externalProxy).sort(Ol);v.length>0&&(p=Math.max(p,$h(v,s,i,r,p+c.ringGap*.62,c.nodeGap*1.15,-Math.PI/3,m+1,!0,o)));let b=i.nodes.filter(T=>T.externalProxy).sort(Ol);b.length>0&&$h(b,s,i,r,p+Math.max(220,c.ringGap*.52),c.nodeGap,-Math.PI/5,m+2,!0,o);let M=tb(s,i,c,c.nodeGap,o);nb(s,i,c,c.nodeGap,M,o),ib(s,i,c,c.nodeGap,M,o),c.radiusExpansion>1.001&&ob(s,M,c),ab(s,u,i,c),e.swirlStrength>.001&&wb(s,i,c,e.swirlStrength/100),Eb(s);let E=cb(s,M),w=m+(v.length||b.length?2:g.length?1:0),C=lb(i.linkEdges,s,w,c.ringGap),_=hb(s,C);return{positions:s,rings:E,routes:C,bounds:_,width:_.maxX-_.minX,height:_.maxY-_.minY,centerX:0,centerY:0,ringSpacing:c.ringGap,nodeSpacing:c.nodeGap}}function Jy(i,e,t){let n=new Map;for(let s of i.hierarchyEdges){if(!e.has(s.source)||!e.has(s.target))continue;let r=n.get(s.source);r?r.push(s.target):n.set(s.source,[s.target])}for(let s of n.values())s.sort((r,o)=>Ol(t.get(r),t.get(o)));return n}function jy(i,e,t){let n=new Map,s=(r,o,a=new Set)=>{let l=n.get(r);if(l)return l;if(a.has(r))return{weight:1,count:1,maxDepth:o};a.add(r);let c=t.incidentPressureByNode.get(r)??0,u=Math.min(9,c*.24),d=1,h=o;for(let g of i.get(r)??[]){let x=s(g,o+1,a);u+=x.weight,d+=x.count,h=Math.max(h,x.maxDepth)}a.delete(r);let f={weight:Math.max(1,u||1),count:d,maxDepth:h};return n.set(r,f),f};for(let r of i.keys())s(r,0);return n}function Op(i,e,t,n,s,r,o,a,l,c,u,d){let h=r.get(i)??[];if(h.length===0)return;let f=t,g=n,x=Math.max(.001,g-f),m=a.get(i)??Ul(0,s,e,5,!1),p=m.radius+Qy(i,e,h,o,c,u),v=eb(i,h,o,c,u);if(h.length===1&&i===u){let C=Math.max(Math.PI*.36,c.branchFanSpan*.82);f=s-C/2,g=s+C/2,x=C}else if(i!==u){let C=h.length>1?(h.length-1)*v/p+.08:Math.max(Math.PI*.24,c.branchFanSpan*.62),_=Math.min(x,c.branchFanSpan),T=Math.min(x,Math.max(_,C));f=s-T/2,g=s+T/2,x=T}if(h.length>1){let C=(h.length-1)*v/Math.max(.16,x*.64),_=c.ringGap*(i===u?1.8:2.8);p=Math.max(p,Math.min(m.radius+_,C))}let b=Math.max(1,h.reduce((C,_)=>C+(o.get(_)?.weight??1),0)),M=h.length>1?Math.min(v/p,x*.38/(h.length-1)):0,E=Math.max(.001,x-M*Math.max(0,h.length-1)),w=f;for(let C of h){let _=h.length===1?E:E*((o.get(C)?.weight??1)/b),T=w,P=w+_,R=T+_/2,I=l.get(C);a.set(C,Ul(p,R,e+1,Vs(I,d),!1)),Op(C,e+1,T,P,R,r,o,a,l,c,u,d),w=P+M}}function Qy(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)),u=Math.log2(Math.max(1,a.count||a.weight||1)),d=Math.sqrt(Math.max(0,l)),h=.62+e*.105+c*.135+u*.094+d*.086;return i===r&&(h*=.96),o<=4&&(h=Math.min(h,i===r?.94:1.12)),o>=14&&(h=Math.max(h,1.24+Math.min(1.1,c*.09))),o>=40&&(h=Math.max(h,1.56+Math.min(1.34,c*.084))),Ge(s.baseRingGap*h,i===r?260:300,4400)}function eb(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=Ge(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)),Ge(n.baseNodeGap*c,132,920)}function $h(i,e,t,n,s,r,o,a,l,c){if(i.length===0)return s;let u=Math.PI*2/i.length,d=i.length*(r/Math.max(1,s)),h=i.map((g,x)=>({node:g,preferred:fb(g,t,e,o+x*u)})).sort((g,x)=>St(g.preferred)-St(x.preferred)),f=h[0]?h[0].preferred-u*.5:o;for(let g=0;g<h.length;g++){let x=h[g];if(!x)continue;let m=f+g*u,p=Qi(m,x.preferred),v=d<Math.PI*1.35?m+p*.55:m;e.set(x.node.id,Ul(s,v,a||x.node.depth||1,Vs(n.get(x.node.id),c),l))}return s}function tb(i,e,t,n,s){let r=new Map([[0,0]]),o=new Map;for(let[h,f]of i.entries()){let g=Math.max(0,Math.round(f.depth||0)),x=e.nodesById.get(h),p=Vs(x,s)*2+Math.max(18,n*.36),v=o.get(g)??{count:0,diameterTotal:0,maxDiameter:0,external:0,linkPressure:0};v.count++,v.diameterTotal+=p,v.maxDiameter=Math.max(v.maxDiameter,p),v.linkPressure+=t.incidentPressureByNode.get(h)??0,(f.external||x?.externalProxy||x?.type==="external")&&v.external++,o.set(g,v)}let a=0,l=[...o.keys()].filter(h=>h>0).sort((h,f)=>h-f),c=Math.max(...l,1),u=[...o.values()].reduce((h,f)=>h+f.count,0),d=Ge(1-Math.log10(Math.max(1,u))*.085,.58,.9);for(let h of l){let f=o.get(h);if(!f)continue;let g=f.diameterTotal/Math.max(1,f.count),x=f.count>1?f.count*g/(Math.PI*2):0,m=x>0?Math.pow(x,.64)*Math.pow(t.ringGap,.36):0,p=h/Math.max(1,c),v=1+Math.pow(p,1.35)*.34,b=1+Math.min(.28,Math.sqrt(f.linkPressure/Math.max(1,f.count))*.036),M=Ge(1-p*.1,.84,.98),E=h*t.ringGap*d*M*v*b,w=a+t.ringGap*(f.external?.54:.62),C=m*d*v*b+f.maxDiameter*1.45,_=a+t.ringGap*(f.external?1.45:1.72)*v,T=Math.min(_,Math.max(E,w,C));r.set(h,T),a=T}for(let h of i.values()){let f=Math.max(0,Math.round(h.depth||0)),g=r.get(f);if(!Number.isFinite(g))continue;let x=g,m=Number.isFinite(h.angle)?h.angle:Math.atan2(h.y,h.x);if(h.ringRadius=x,f===0){h.x=0,h.y=0,h.radius=0,h.angle=-Math.PI/2;continue}h.x=Math.cos(m)*x,h.y=Math.sin(m)*x,h.radius=x,h.angle=St(m)}return r}function nb(i,e,t,n,s,r){if(i.size<2)return;let o=Ge(n*1.12,54,280),a=[],l=1;for(let[f,g]of i.entries()){let x=e.nodesById.get(f);if(!x)continue;let m=Vs(x,r)*1.72,p=Math.min(320,o+Gp(x)),v=m+p,b=Math.max(0,Math.round(g.depth||0)),M=Number.isFinite(g.ringRadius)?g.ringRadius:s.get(b);l=Math.max(l,v),a.push({id:f,node:x,point:g,visualRadius:m,collisionRadius:v,gravity:Ge(Math.sqrt(Math.max(1,m))/3.1,.85,2.55),fixed:f===e.rootId,anchorAngle:Number.isFinite(g.angle)?g.angle:Math.atan2(g.y,g.x),ringRadius:Number.isFinite(M)?M:null})}if(a.length<2)return;let c=a.length>3500?9:a.length>1200?11:16,u=Math.max(112,l*2.48),d=(f,g)=>{let x=!1,m=new Map;for(let p=0;p<a.length;p++){let v=a[p],b=Math.floor(v.point.x/u),M=Math.floor(v.point.y/u),E=`${b},${M}`,w=m.get(E);w?w.push(p):m.set(E,[p])}for(let p=0;p<a.length;p++){let v=a[p],b=Math.floor(v.point.x/u),M=Math.floor(v.point.y/u);for(let E=b-1;E<=b+1;E++)for(let w=M-1;w<=M+1;w++){let C=m.get(`${E},${w}`);if(C)for(let _ of C){if(_<=p)continue;let T=a[_];if(v.fixed&&T.fixed)continue;let P=v.point.x-T.point.x,R=v.point.y-T.point.y,I=Math.hypot(P,R);if(I<.001){let We=Wp(v.id,T.id);P=Math.cos(We),R=Math.sin(We),I=1}let H=v.collisionRadius+T.collisionRadius,W=Math.sqrt(v.gravity*T.gravity),k=H+(v.visualRadius+T.visualRadius)*1.75*W;if(I>=k)continue;let z=I<H?(H-I)*f:0,V=I>=H?(k-I)*g:(k-H)*g*.35,K=(z+V)*W+.01,Q=P/I,ae=R/I,_e=v.fixed?0:T.fixed?1:.5,be=T.fixed?0:v.fixed?1:.5;v.point.x+=Q*K*_e,v.point.y+=ae*K*_e,T.point.x-=Q*K*be,T.point.y-=ae*K*be,x=!0}}}return x},h=f=>{for(let g of a){if(g.fixed||!Number.isFinite(g.ringRadius))continue;let x=Math.max(.001,Math.hypot(g.point.x,g.point.y)),m=Math.atan2(g.point.y,g.point.x),p=g.node.externalProxy||g.node.type==="external",v=p?.016:.024,b=Math.max(g.visualRadius*(p?1.9:1.45),t.ringGap*(p?.15:.105)),M=m+Qi(m,g.anchorAngle)*v,E=x+(g.ringRadius-x)*f,w=Ge(E,Math.max(0,g.ringRadius-b),g.ringRadius+b);g.point.x=Math.cos(M)*w,g.point.y=Math.sin(M)*w}};for(let f=0;f<c;f++)d(f===0?.9:.72,f<3?.22:.13),h(f<3?.42:.28);for(let f=0;f<5&&(h(f===0?.18:.1),!!d(f===0?1:.82,.05));f++);for(let f of a){let g=Math.hypot(f.point.x,f.point.y);g<.001||(f.point.radius=g,f.point.angle=Math.atan2(f.point.y,f.point.x))}}function ib(i,e,t,n,s,r){let o=new Map;for(let[u,d]of i.entries()){let h=e.nodesById.get(u);if(!h)continue;let f=Math.max(0,Math.round(d.depth||0));if(f===0){d.x=0,d.y=0,d.radius=0,d.angle=-Math.PI/2;continue}let g=Vs(h,r),x=Gp(h)+Hp(h)*Ge(.58+Math.min(1,f/4)*.42,.58,1),m=g*2.75+x*2.7+Math.max(22,n*.22),p=St(Number.isFinite(d.angle)?d.angle:Math.atan2(d.y,d.x)),v=h.parentId?i.get(h.parentId):null,b=v&&Number.isFinite(v.angle)?St(v.angle):p,M=v?Tb(p,b,.68):p,E=o.get(f)??[];E.push({id:u,node:h,point:d,depth:f,parentId:h.parentId??null,parentAngle:b,visualRadius:g,arcDemand:m,preferred:M}),o.set(f,E)}let a=0,l=[...o.keys()].sort((u,d)=>u-d),c=Math.max(...l,1);for(let u of l){let d=o.get(u);if(!d?.length)continue;let h=d.reduce((P,R)=>P+R.arcDemand,0),f=Math.max(...d.map(P=>P.visualRadius),4),g=s.get(u)??Math.max(t.ringGap*u,a+t.ringGap*.62),x=Ge((u-1)/Math.max(1,c-1),0,1),m=Math.pow(x,1.35),p=Ge(.72-m*.16-Math.min(.1,d.length/4200),.5,.72),v=Math.max(1,Math.PI*2*g*p),b=Ge(Math.ceil(h/v),1,pb(d.length,x)),M=Math.max(f*(2.45+m*.7)+Math.max(12,n*(.13+m*.04)),t.ringGap*(.11+m*.045)),E=yb(u,g,t.ringGap,d.length,h),w=Math.max(g-M*(b-1)*.5,a+M*.86),C=Array.from({length:b},()=>[]);for(let P of zp(d)){let R=Bp(P.items);b===1?C[0]?.push(...R):C[mb(C,R,P.parentAngle)]?.push(...R)}let _=[],T=[];for(let P=0;P<C.length;P++){let R=gb(C[P]??[]);if(!R.length)continue;let I=w+P*M,H=R.reduce((Q,ae)=>Q+ae.arcDemand,0),W=H/(Math.PI*2*p);I=Math.max(I,W,a+M*.72);let k=E*bb(R.length,Mb(R),H,I),z=Math.min(t.ringGap*Ky*k,I*Fp*Math.min(1.35,k));I=Math.max(I,a+z*.56+M*.68);let V=Math.min(z,Math.max(0,I-a-f*2.2-Math.max(12,n*.08))),K=H/Math.max(1,Math.PI*2*I);xb(R,I,{jitterBand:V,preservePreferred:R.length<90||K<.38||m<.28}),_.push(I),T.push(I+V)}_.length&&(s.set(u,Ab(_,g)),a=Math.max(...T)+f*1.55+Math.max(12,n*.08))}}function sb(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)),T=Math.min(6,Math.log2((C.rawCount||C.weight||1)+1)),P=.75+_*.62+T*.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=rb(i,e),u=r/l,d=i.linkEdges.length/l,h=a/Math.max(1,Math.sqrt(l)*1.65),f=u+Math.sqrt(Math.max(0,h))*.58+Math.min(1.6,d)*.3+o/l*.32,g=Math.sqrt(Math.max(0,f)),x=Ge(1.2+g*.92+Math.min(.86,u*.105),1.2,5.8),m=Ge(1.08+g*.34+Math.min(.34,u*.044),1.08,2.15),p=Ge(.62+g*.24+Math.min(.3,d*.17),.62,1.35),v=Ge(.9+g*.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,E=Math.max(0,Math.sqrt(c.averageRingCount/64)-1)*.1,w=Math.max(0,g-.75)*.028;return{baseRingGap:t,baseNodeGap:n,ringGap:Ge(t*m,Np,4200),nodeGap:Ge(n*x,86,860),branchFanSpan:Math.PI*p,routeGapFactor:v,radiusExpansion:Ge(1+b+M+E+w,1,1.56),ringCountsByDepth:c.countsByDepth,maxDensityDepth:c.maxDepth,incidentPressureByNode:s}}function rb(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 ob(i,e,t){let n=Ge(t.radiusExpansion,1,1.65);if(n<=1.001)return;let s=Math.max(1,t.maxDensityDepth,...e.keys()),r=o=>{if(o<=0)return 1;let a=Ge((o-1)/Math.max(1,s-1),0,1),l=Math.pow(a,1.42),c=t.ringCountsByDepth.get(Math.round(o))??0,u=Math.max(0,Math.sqrt(c/72)-1)*.13*l,d=(1-l)*Math.min(.08,(n-1)*.42),h=(n-1)*(.04+l*1.06);return Ge(1-d+h+u,.93,1.68)};for(let[o,a]of[...e.entries()])o>0&&e.set(o,a*r(o));for(let o of i.values()){if(o.radius<=.001)continue;let a=Math.max(0,Math.round(o.depth||0)),l=r(a),c=Number.isFinite(o.angle)?o.angle:Math.atan2(o.y,o.x),u=o.radius*l;o.radius=u,o.x=Math.cos(c)*u,o.y=Math.sin(c)*u,o.angle=c,Number.isFinite(o.ringRadius)&&(o.ringRadius=o.ringRadius*l),Number.isFinite(o.ringBandMin)&&(o.ringBandMin=o.ringBandMin*l),Number.isFinite(o.ringBandMax)&&(o.ringBandMax=o.ringBandMax*l)}}function ab(i,e,t,n){for(let[s,r]of e.entries()){let o=i.get(s);if(!o||o.radius<=.001||r.length===0)continue;let a=Number.isFinite(o.angle)?o.angle:Math.atan2(o.y,o.x),l=r.map(m=>{let p=i.get(m),v=t.nodesById.get(m);return p&&v&&!p.external?{id:m,point:p,node:v,delta:Qi(a,p.angle)}:null}).filter(m=>!!m).sort((m,p)=>m.delta-p.delta);if(l.length===0)continue;let c=l.reduce((m,p)=>m+Math.max(1,p.point.radius),0)/l.length,u=l.reduce((m,p)=>m+p.point.nodeRadius*2.25+Hp(p.node)*.76,0),d=Math.min(Math.PI*1.1,u/Math.max(1,c)),h=l.length>1?Math.max(...l.map(m=>m.delta))-Math.min(...l.map(m=>m.delta)):0,f=Ge(Math.max(d,h*.58),l.length===1?0:.035,Math.PI*.86),g=Math.min(Math.PI*.18,Math.max(.03,n.branchFanSpan*.08)),x=l.length<=2?.54:l.length<=8?.46:.34;for(let m=0;m<l.length;m++){let p=l[m],v=l.length===1?0:-f/2+f*m/Math.max(1,l.length-1),b=St(a+v),M=St(p.point.angle),E=Ge(Qi(M,b)*x,-g,g),w=St(M+E),C=p.point.radius;p.point.x=Math.cos(w)*C,p.point.y=Math.sin(w)*C,p.point.angle=w}}}function lb(i,e,t,n){let s=new Map;for(let r of i){let o=e.get(r.source),a=e.get(r.target);if(!o||!a)continue;let l=Math.abs(o.depth-a.depth),c=Number.isFinite(o.radius)?o.radius:0,u=Number.isFinite(a.radius)?a.radius:0,d=Number.isFinite(o.angle)?o.angle:Math.atan2(a.y-o.y,a.x-o.x),h=Number.isFinite(a.angle)?a.angle:d,f=Math.abs(Qi(d,h)),g=Math.abs(c-u)<n*.44,x=Math.max(o.depth||0,a.depth||0)>=Math.max(1,t-1),m=!!(o.external||a.external||r.externalCount);(m||g||l<=1&&x&&f>.34||f>Math.PI*.42)&&s.set(r.id,{kind:"curve",centerX:0,centerY:0,radius:Math.max(c,u),sourceAngle:d,targetAngle:h,curveStrength:m?.3:g?.22:f>Math.PI*.72?.2:.15})}return s}function cb(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 hb(i,e){let t=-500,n=-500,s=500,r=500;for(let o of i.values()){let a=o.nodeRadius+180;t=Math.min(t,o.x-a),n=Math.min(n,o.y-a),s=Math.max(s,o.x+a),r=Math.max(r,o.y+a)}for(let o of e.values())o.kind==="outer"&&(t=Math.min(t,-o.radius-160),n=Math.min(n,-o.radius-160),s=Math.max(s,o.radius+160),r=Math.max(r,o.radius+160));return{minX:t,minY:n,maxX:s,maxY:r}}function Ul(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 Vs(i,e){if(!i)return 3.6;let t=Math.max(0,(i.linkCount||0)+(i.backlinkCount||0)),n=Math.log1p(t)/Math.max(1,Math.log1p(e||1)),s=Ge(n,0,1),r=Math.pow(s,.48),o=Math.pow(s,1.32),a=r*19+o*20+Math.log2(t+1)*1.35+Math.sqrt(t)*.32;if(i.externalProxy)return i.type==="unresolved"?5.4:Math.min(27,5.8+a*.62);if(i.type==="folder"){let l=Math.log2((i.noteCount||i.descendantCount||1)+1);return Math.min(66,7+l*1.05+a*1.18)}if(i.type==="external"){let l=Math.log2((i.noteCount||1)+1);return Math.min(38,5.8+l*.72+a*.9)}return i.type==="unresolved"?Math.min(16,4.2+a*.5):Math.min(58,3.6+a*1.05)}function ub(i){let e=1;for(let t of i)e=Math.max(e,(t.linkCount||0)+(t.backlinkCount||0));return e}function Ol(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 db(i){let e=0;for(let t of i.values())e=Math.max(e,t.radius);return e}function fb(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 Up(s,n)}function Up(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 Bp(i){let e=i.slice().sort((r,o)=>St(r.preferred)-St(o.preferred));if(e.length<=2)return e;let t=-1,n=0;for(let r=0;r<e.length;r++){let o=St(e[r]?.preferred??0),l=St(e[(r+1)%e.length]?.preferred??0)+(r===e.length-1?Math.PI*2:0)-o;l>t&&(t=l,n=r)}let s=(n+1)%e.length;return e.slice(s).concat(e.slice(0,s))}function pb(i,e){let t=Math.max(0,i||0),n=Ge(e,0,1),s=t>1600?14:t>900?12:t>420?10:t>180?8:t>80?6:4,r=n>.72?3:n>.48?2:n>.28?1:0;return Ge(s+r,4,16)}function zp(i){let e=new Map;for(let t of i){let n=t.parentId??t.id,s=e.get(n)??{parentId:n,parentAngle:t.parentAngle,arcDemand:0,items:[]};s.items.push(t),s.arcDemand+=t.arcDemand||0,s.parentAngle=Up(s.items.map(r=>r.parentAngle),s.parentAngle),e.set(n,s)}return[...e.values()].sort((t,n)=>St(t.parentAngle)-St(n.parentAngle))}function mb(i,e,t){let n=0,s=1/0,r=e.reduce((o,a)=>o+(a.arcDemand||0),0);for(let o=0;o<i.length;o++){let a=i[o]??[],l=a.reduce((h,f)=>h+(f.arcDemand||0),0),c=a[a.length-1],u=c?Math.abs(Qi(c.parentAngle||c.preferred,t)):0,d=l+r*.18+u*180;d<s&&(s=d,n=o)}return n}function gb(i){let e=[];for(let t of zp(i))e.push(...Bp(t.items));return e}function xb(i,e,t){if(!i.length||!Number.isFinite(e)||e<=0)return;let n=Math.PI*2,s=i.map(f=>Math.max(.003,f.arcDemand/e)),r=s.reduce((f,g)=>f+g,0),o=Ge(t.jitterBand,0,Math.max(0,e*Fp)),a=_b(i,o),l=Math.min(.11,Math.max(.012,r/Math.max(1,i.length)*.18)),c=r+l*Math.max(0,i.length-1);if(t.preservePreferred&&i.length<=640&&c<n*.9&&vb(i,s,e,o,a,l))return;let d=Math.max(0,(n-r)/i.length),h=St(i[0]?.preferred??0)-((s[0]??0)+d)*.5;for(let f=0;f<i.length;f++){let g=(s[f]??0)+d,x=h+g*.5,m=i[f];m&&Vp(m,e,x,o,a),h+=g}}function vb(i,e,t,n,s,r){if(!i.length)return!0;let o=Math.PI*2,a=i.map((x,m)=>({item:x,arc:e[m]??.003,preferred:St(x.preferred)})).sort((x,m)=>x.preferred-m.preferred);if(a.length>1){let x=-1,m=0;for(let v=0;v<a.length;v++){let b=a[v]?.preferred??0,E=(a[(v+1)%a.length]?.preferred??0)+(v===a.length-1?o:0)-b;E>x&&(x=E,m=v)}let p=(m+1)%a.length;a=a.slice(p).concat(a.slice(0,p))}let l=[],c=0,u=a[0]?.preferred??0;l[0]=u;for(let x=1;x<a.length;x++){let m=(a[x]?.preferred??0)+c;for(;m<=u;)c+=o,m=(a[x]?.preferred??0)+c;l[x]=m,u=m}let d=((l[0]??0)+(l[l.length-1]??0))*.5;for(let x=0;x<3;x++)for(let m=1;m<a.length;m++){let p=((a[m-1]?.arc??0)+(a[m]?.arc??0))*.5+r;(l[m]??0)-(l[m-1]??0)<p&&(l[m]=(l[m-1]??0)+p)}if((l[l.length-1]??0)+(a[a.length-1]?.arc??0)*.5-((l[0]??0)-(a[0]?.arc??0)*.5)>o-r)return!1;let f=((l[0]??0)+(l[l.length-1]??0))*.5,g=d-f;for(let x=0;x<a.length;x++)Vp(a[x].item,t,St((l[x]??0)+g),n,s);return!0}function Vp(i,e,t,n,s){let r=Sb(i,e,n,s),o=i.point;o.x=Math.cos(t)*r,o.y=Math.sin(t)*r,o.radius=r,o.ringRadius=e,o.ringBandMin=e-n,o.ringBandMax=e+n,o.angle=t}function _b(i,e){let t=new Map;if(!i.length||e<=0)return t;let n=[],s=new Set;for(let o of i){let a=Kh(o);s.has(a)||(s.add(a),n.push(a))}let r=[0,-.96,.96,-.54,.54,-.78,.78,-.28,.28];for(let o=0;o<n.length;o++){let a=n[o]??"",l=r[o%r.length]??0,c=Zr(a,"ring-parent-variation")*.12;t.set(a,Ge(l+c,-1,1)*e)}return t}function yb(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=Ge(.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 Ge(l*c,.42,1.72)}function bb(i,e,t,n){let s=Math.max(0,i||0),r=Math.max(1,e||1),o=Number.isFinite(n)&&n>0?t/Math.max(1,Math.PI*2*n):0,a=s<=3?.42:s<=7?.66:s<=14?.86:1.05,l=r<=1?.52:r<=2?.72:r<=4?.92:1.08,c=o<.1?.56:o<.2?.78:o>.55?1.14:1;return Ge(a*l*c,.32,1.22)}function Mb(i){return new Set(i.map(Kh)).size}function Sb(i,e,t,n){if(t<=0)return e;let s=Kh(i),r=n.get(s)??Zr(s,"ring-parent")*t*.92,o=Zr(i.id,"ring-node")*t*.08;return e+Ge(r+o,-t,t)}function Kh(i){return i.parentId??i.id}function Gp(i){let e=Array.from(String(i.title||"")).length,t=i.type==="folder"?13:i.type==="external"||i.externalProxy?9:5;return Ge(Math.sqrt(Math.max(1,e))*4.2+t,10,60)}function Hp(i){let e=Array.from(String(i.title||"")).length,t=i.type==="folder"?14:0,n=i.type==="external"||i.externalProxy?9:0;return Ge(Math.sqrt(Math.max(1,e))*7.5+Math.min(110,e*1.25)+t+n,24,150)}function wb(i,e,t,n){let s=e.rootId||Ze,r=Zr(s||"vault","swirl-direction")>=0?1:-1;for(let[o,a]of i.entries()){if(a.radius<=.001)continue;let l=Math.max(0,a.depth||0),c=Number.isFinite(a.angle)?a.angle:Math.atan2(a.y,a.x),u=Math.sqrt(Math.max(0,a.radius)/Math.max(1,t.ringGap)),d=Zr(o,"swirl-arm")*.16,h=Math.sin(c*2.35+l*.78)*.11,f=r*n*(l*.32+u*.22+d+h),g=St(c+f);a.x=Math.cos(g)*a.radius,a.y=Math.sin(g)*a.radius,a.angle=g}}function Eb(i){for(let e of i.values())e.homeX=e.x,e.homeY=e.y,e.homeRadius=e.radius,e.homeAngle=e.angle}function Tb(i,e,t){return St(i+Qi(i,e)*Ge(t,0,1))}function St(i){let e=Number.isFinite(i)?i:0;return e%=Math.PI*2,e<0&&(e+=Math.PI*2),e}function Qi(i,e){let t=St(e)-St(i);return t>Math.PI&&(t-=Math.PI*2),t<-Math.PI&&(t+=Math.PI*2),t}function Wp(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 Zr(i,e){return Math.sin(Wp(String(i||""),String(e||"")))}function Ab(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 Ge(i,e,t){return Math.min(Math.max(Number.isFinite(i)?i:e,e),t)}var Cb={day:{bg:"#f7f8fb",ring:"#94a3b8",tree:"#5b677a",link:"#525e70",external:"#5b5fe0",externalLink:"#cb7622",unresolved:"#dc2626",focus:"#5368ee",folder:"#3f4a5a",folderMeta:"#4f5ee8",note:"#536073",root:"#4f5ee8",ringOpacity:.16,treeOpacity:.17,linkOpacity:.06,externalLinkOpacity:.08,highlightOpacity:.9,nodeScale:.19,maxLabels:140},night:{bg:"#0f1117",ring:"#818cf8",tree:"#818cf8",link:"#94a3b8",external:"#c4b5fd",externalLink:"#fb923c",unresolved:"#fb7185",focus:"#aab6ff",folder:"#d7dae2",folderMeta:"#f59e0b",note:"#a1a8b5",root:"#7c9cff",ringOpacity:.15,treeOpacity:.18,linkOpacity:.065,externalLinkOpacity:.09,highlightOpacity:.98,nodeScale:.2,maxLabels:140}},zl=class{constructor(e){this.container=e;this.scene=new Zi;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=Vl();this.width=1;this.height=1;this.centerX=0;this.centerY=0;this.zoom=1;this.scheme="night";this.revealFrame=0;this.revealOverlay=null;this.renderer=new Ds({antialias:!0,alpha:!1}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),this.renderer.setClearColor(this.palette().bg,1),this.domElement=this.renderer.domElement,this.domElement.classList.add("mwm-radial-canvas"),this.domElement.tabIndex=0,e.appendChild(this.domElement),this.labelRoot=e.createDiv({cls:"mwm-radial-labels"}),this.camera=new si(-1,1,1,-1,.1,5e3),this.camera.position.set(0,0,1e3),this.camera.lookAt(0,0,0)}setTheme(e){if(this.scheme===e)return!1;if(this.scheme=e,this.renderer.setClearColor(this.palette().bg,1),this.nodeMaterial){let t=this.nodeMaterial.uniforms.uLightMode,n=this.nodeMaterial.uniforms.uPixelScale;t&&(t.value=e==="day"?1:0),n&&(n.value=1e3*Math.min(window.devicePixelRatio||1,2)),this.updateNodeScale()}return this.render(),!0}setData(e,t,n){this.graph=e,this.layout=t,this.edgeVisuals.clear(),this.disposeObjects(),this.buildRings(),this.buildEdges(e.hierarchyEdges,t,"hierarchy"),this.buildEdges(e.linkEdges,t,"links");for(let s of e.hoverLinkEdges){if(this.edgeVisuals.has(s.id))continue;let r=this.edgeVisual(s,t);r&&this.edgeVisuals.set(r.key,r)}this.buildNodes(e,t),this.setActive(this.active,n),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,.003),6),this.updateNodeScale(),this.applyCamera();let s=this.active.highlightedEdges.size>0;s&&this.rebuildHighlights(),this.updateLabels(),s&&this.render()}getView(){return{centerX:this.centerX,centerY:this.centerY,zoom:this.zoom}}fitToLayout(){if(!this.layout)return;let e=160,t=Math.max(1,this.layout.bounds.maxX-this.layout.bounds.minX+e*2),n=Math.max(1,this.layout.bounds.maxY-this.layout.bounds.minY+e*2),s=Math.min(this.width/t,this.height/n,1.2)*.92;this.setView((this.layout.bounds.minX+this.layout.bounds.maxX)/2,(this.layout.bounds.minY+this.layout.bounds.maxY)/2,s)}playRevealFromRoot(e,t,n=1200){if(!this.layout||this.width<2||this.height<2)return;cancelAnimationFrame(this.revealFrame),this.revealOverlay?.remove();let s=this.layout.positions.get(e)??{x:0,y:0},r=this.worldToScreen(s.x,s.y),o=Math.hypot(Math.max(r.x,this.width-r.x),Math.max(r.y,this.height-r.y))+120,a=performance.now();this.container.style.setProperty("--mwm-reveal-x",`${r.x.toFixed(1)}px`),this.container.style.setProperty("--mwm-reveal-y",`${r.y.toFixed(1)}px`),this.container.style.setProperty("--mwm-reveal-radius","0px"),this.container.addClass("is-radial-revealing"),this.revealOverlay=this.container.createDiv({cls:"mwm-radial-loading gx-mask-text",text:t});let l=c=>{let u=Math.min(Math.max((c-a)/n,0),1),d=1-Math.pow(1-u,3);if(this.container.style.setProperty("--mwm-reveal-radius",`${(o*d).toFixed(1)}px`),u<1){this.revealFrame=window.requestAnimationFrame(l);return}this.container.removeClass("is-radial-revealing"),this.revealOverlay?.addClass("is-fading"),window.setTimeout(()=>{this.revealOverlay?.remove(),this.revealOverlay=null},220)};this.revealFrame=window.requestAnimationFrame(l)}setActive(e,t){this.active=e,this.updateNodeDim(),this.rebuildHighlights(),this.updateLabels(t),this.render()}render(){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(!c)continue;let u=Math.hypot(r.x-c.x,r.y-c.y),d=Math.max(4,c.nodeRadius*this.palette().nodeScale*Bl(this.zoom)*.55),h=Math.max(c.nodeRadius*.36,d/Math.max(.003,this.zoom))+Math.max(5,6/this.zoom);u<=h&&(!o||u<o.distance)&&(o={id:l.id,distance:u})}if(o)return{nodeId:o.id,edge:null};if(!n)return{nodeId:null,edge:null};let a=null;for(let l of this.edgeVisuals.values()){if(l.edge.type==="hierarchy"||l.edge.type==="external-hierarchy")continue;let c=Db(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 Cb[this.scheme]}applyCamera(){this.camera.position.set(this.centerX,this.centerY,1e3),this.camera.zoom=this.zoom,this.camera.updateProjectionMatrix(),this.render()}buildRings(){this.ringSegments=null}buildEdges(e,t,n){let s=[],r=[],o=this.palette();for(let l of e){let c=this.edgeVisual(l,t);if(!c)continue;this.edgeVisuals.set(c.key,c);let u=Lb(l,n,o);for(let d=0;d<c.points.length-1;d++){let h=c.points[d],f=c.points[d+1];!h||!f||(s.push(h.x,h.y,n==="hierarchy"?-1:-2),s.push(f.x,f.y,n==="hierarchy"?-1:-2),Jh(r,u,n==="hierarchy"?.46:l.externalCount?.22:.16),Jh(r,u,n==="hierarchy"?.46:l.externalCount?.22:.16))}}let a=new wi(Xp(s,r),new ni({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=new Float32Array(e.nodes.length*3),r=new Float32Array(e.nodes.length*3),o=new Float32Array(e.nodes.length),a=new Float32Array(e.nodes.length),l=new Float32Array(e.nodes.length).fill(1);this.nodeIds=e.nodes.map(c=>c.id),e.nodes.forEach((c,u)=>{let d=t.positions.get(c.id),h=Ib(c,e.rootId,n);s[u*3]=d?.x??0,s[u*3+1]=d?.y??0,s[u*3+2]=1,r[u*3]=h.r,r[u*3+1]=h.g,r[u*3+2]=h.b,o[u]=Math.max(2.1,(d?.nodeRadius??8)*n.nodeScale),a[u]=c.type==="unresolved"||c.type==="external"||c.externalProxy?1:0}),this.nodeGeometry=new ht,this.nodeGeometry.setAttribute("position",new Ye(s,3)),this.nodeGeometry.setAttribute("color",new Ye(r,3)),this.nodeGeometry.setAttribute("aSize",new Ye(o,1)),this.nodeGeometry.setAttribute("aGhost",new Ye(a,1)),this.nodeGeometry.setAttribute("aDim",new Ye(l,1)),this.nodeMaterial=new ut({vertexShader:bl,fragmentShader:Ml,vertexColors:!0,transparent:!0,depthWrite:!1,uniforms:{uPixelScale:{value:1e3*Math.min(window.devicePixelRatio||1,2)},uSizeMul:{value:Bl(this.zoom)},uLightMode:{value:this.scheme==="day"?1:0},uMaxPoint:{value:58*Math.min(window.devicePixelRatio||1,2)}}}),this.nodePoints=new Bn(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.uMaxPoint;e&&(e.value=Bl(this.zoom)),t&&(t.value=58*Math.min(window.devicePixelRatio||1,2))}rebuildHighlights(){this.highlightSegments&&(this.scene.remove(this.highlightSegments),this.highlightSegments.geometry.dispose(),Array.isArray(this.highlightSegments.material)?this.highlightSegments.material.forEach(o=>o.dispose()):this.highlightSegments.material.dispose(),this.highlightSegments=null);let e=[],t=[],n=this.palette(),s=new me(n.focus),r=Math.max(.003,this.zoom||1);for(let o of this.active.highlightedEdges){let a=this.edgeVisuals.get(o);if(a)for(let l=0;l<a.points.length-1;l++){let c=a.points[l],u=a.points[l+1];!c||!u||Pb(e,t,s,c,u,kb(a.edge)/r,2)}}this.highlightSegments=new Xt(Rb(e,t),new ti({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:Nb(n,s,r)}}updateLabels(e="auto"){if(!this.graph||!this.layout)return;this.labelRoot.empty();let t=new Set([...this.active.labelNodes,...this.active.pinnedNodeIds,this.active.activeNodeId??"",this.graph.rootId,this.graph.focusId??""]);t.delete("");let n=this.graph.nodes.map(a=>{let l=this.layout?.positions.get(a.id)??null;return l?{node:a,point:l,score:Ob(a,l,this.graph)}:null}).filter(a=>!!a).sort((a,l)=>l.score-a.score),s=Math.max(1,n.length-1),r=e==="auto"&&this.zoom>=.08?Math.round(Math.min(this.palette().maxLabels,Math.max(0,(this.zoom-.08)*84+Math.sqrt(this.zoom)*18))):0,o=0;for(let a=0;a<n.length;a++){let l=n[a],{node:c,point:u}=l,d=t.has(c.id),h=d?1:e==="auto"?Ub(c,u,this.zoom,a,s,this.graph):0;if(!d){if(h<=.08||o>=r)continue;o++}let f=this.worldToScreen(u.x,u.y);if(f.x<-160||f.y<-80||f.x>this.width+160||f.y>this.height+120)continue;let g=this.labelRoot.createDiv({cls:c.id===this.graph.rootId?"mwm-radial-label is-root":"mwm-radial-label"});g.setText(c.title);let x=Bb(this.zoom)*(c.id===this.graph.rootId?1.18:u.nodeRadius>=24?1.1:u.nodeRadius>=15?1.04:1),m=Math.max(c.id===this.graph.rootId?12:9.5,12*x);g.style.fontSize=`${m.toFixed(2)}px`,g.style.maxWidth=`${Math.round((c.id===this.graph.rootId?190:c.type==="folder"?156:u.nodeRadius>=18?146:124)*x)}px`,g.style.opacity=String(d?.96:Math.min(.9,.22+h*.68));let p=Math.max(5,u.nodeRadius*this.palette().nodeScale*Bl(this.zoom)*.62),v=Math.max(9,p+6*x);g.style.transform=`translate3d(${f.x.toFixed(1)}px, ${(f.y+v).toFixed(1)}px, 0)`,this.active.dimOthers&&!t.has(c.id)&&!this.active.relatedNodes.has(c.id)&&(g.style.opacity=String(Math.min(Number(g.style.opacity)||1,.34)),g.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 Vl(){return{hasActive:!1,dimOthers:!1,activeNodeId:null,activeLinkId:null,relatedNodes:new Set,highlightedEdges:new Set,labelNodes:new Set,pinnedNodeIds:new Set}}function Xp(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 Rb(i,e){let t=Xp(i,e);return t.computeBoundingSphere(),t}function Pb(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 u=Math.max(.1,r*.5),d=-l/c*u,h=a/c*u,f=[[n.x+d,n.y+h,o],[n.x-d,n.y-h,o],[s.x-d,s.y-h,o],[n.x+d,n.y+h,o],[s.x-d,s.y-h,o],[s.x+d,s.y+h,o]];for(let g of f)i.push(g[0],g[1],g[2]),Jh(e,t,1)}function Jh(i,e,t){i.push(e.r,e.g,e.b)}function Ib(i,e,t){return i.id===e?new me(t.root):i.type==="unresolved"?new me(t.unresolved):i.type==="external"||i.externalProxy?new me(t.external):i.type==="folder"&&i.representativeFile?new me(t.folderMeta):i.type==="folder"?new me(t.folder):new me(t.note)}function Lb(i,e,t){return i.unresolvedCount?new me(t.unresolved):i.externalCount?new me(e==="links"?t.externalLink:t.external):new me(e==="hierarchy"?t.tree:t.link)}function Nb(i,e,t){if(!t)return[i,e];if(t.kind==="outer"){let l=[i],c=t.sourceAngle,u=t.endAngle??t.targetAngle,d=u-c;Math.abs(d)>Math.PI&&(d+=d>0?-Math.PI*2:Math.PI*2),u=c+d;let h=Math.max(8,Math.ceil(Math.abs(d)/.18));for(let f=0;f<=h;f++){let g=c+d*f/h;l.push({x:t.centerX+Math.cos(g)*t.radius,y:t.centerY+Math.sin(g)*t.radius})}return l.push(e),l}let n=(i.x+e.x)/2,s=(i.y+e.y)/2,r=t.curveStrength??.16,o={x:n-n*r,y:s-s*r},a=[];for(let l=0;l<=12;l++){let c=l/12,u=(1-c)*(1-c),d=2*(1-c)*c,h=c*c;a.push({x:u*i.x+d*o.x+h*e.x,y:u*i.y+d*o.y+h*e.y})}return a}function Db(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,Fb(i,s,r)))}return t}function Fb(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 kb(i){return i.type==="hierarchy"||i.type==="external-hierarchy"?3.1:i.externalCount?3.6:4.1}function Ob(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 Ub(i,e,t,n,s,r){let o=ai(t,.003,6);if(i.id===r.rootId)return .68+nn(.04,.2,o)*.32;let l=Math.max(0,(i.linkCount||0)+(i.backlinkCount||0)),c=i.type==="folder",u=i.type==="external"||i.externalProxy,d=i.type==="unresolved",h=ai((e.nodeRadius-4)/42,0,1),f=ai(Math.log1p(l)/Math.log1p(80),0,1),g=ai(1-n/Math.max(1,s),0,1),x=Math.max(1,r.nodes.length||1),m=n<Math.max(10,Math.min(58,Math.ceil(x*.05))),p=n<Math.max(28,Math.min(170,Math.ceil(x*.18))),v=n<Math.max(80,Math.min(520,Math.ceil(x*.38))),b=1.24-h*.64-f*.22-g*.42;m?b-=.28:p?b-=.2:v&&(b-=.08),c?b-=i.representativeFile?.18:.12:u&&(b-=.04),d&&(b+=.18),b=ai(b,.16,1.38);let M=nn(b-.14,b+.1,o),E=m?nn(.12,.38,o):p?nn(.22,.62,o)*.9:v?nn(.46,.96,o)*.7:0,w=e.nodeRadius>=24?nn(.22,.56,o)*.96:e.nodeRadius>=15?nn(.42,.86,o)*.78:0,C=d?0:nn(.86,1.28,o)*.82,_=d?0:nn(1.12,1.46,o)*.98;return ai(Math.max(M,E,w,C,_),0,1)}function Bb(i){let e=ai(i,.003,6);return .62+nn(.06,1.48,e)*.88}function Bl(i){let e=ai(i,.003,6);return .7+nn(.07,.36,e)*.36+nn(.36,1.32,e)*.82+nn(1.32,3.2,e)*.72+nn(3.2,6,e)*.28}function nn(i,e,t){if(i===e)return t>=e?1:0;let n=ai((t-i)/(e-i),0,1);return n*n*(3-2*n)}function ai(i,e,t){return Number.isFinite(i)?Math.min(t,Math.max(e,i)):e}var Yl=require("obsidian");function Zp(i,e,t,n){let s=new Map,r=[],o=[],a=new Map,l=new Map,c=new Map,u=new Map,d=0,h=0,f=v=>zb(v,n.ignoreFolders),g=v=>{s.has(v.id)||f(v.id)||s.set(v.id,v)};g({id:Ze,path:Ze,title:Ip,type:"folder",parentId:null,depth:0,noteCount:0,linkCount:0,backlinkCount:0,descendantCount:0});let x=v=>{let b=Oi(v);if(!b)return Ze;let M=Ze;for(let E of b.split("/").filter(Boolean)){let w=M?`${M}/${E}`:E;if(f(w))return M;s.has(w)||g({id:w,path:w,title:Gl(w),type:"folder",parentId:M,depth:qp(w),noteCount:0,linkCount:0,backlinkCount:0,descendantCount:0}),M=w}return M};for(let v of i){d++;let b=Oi(v.path);if(!b||f(b))continue;if(v.kind==="folder"){x(b);continue}h++;let M=x(jh(b));g({id:b,path:b,title:v.basename||Gl(b).replace(/\.md$/i,""),type:"note",parentId:M,depth:qp(b),noteCount:1,linkCount:0,backlinkCount:0,descendantCount:0})}Vb(s,u);let m=(v,b,M,E)=>{if(v===b||!s.has(v)||!s.has(b))return;let w={id:`${E}:${v}->${b}:${o.length}`,type:E,source:v,target:b,weight:M};o.push(w);let C=s.get(v),_=s.get(b);C&&(C.linkCount+=M),_&&(_.backlinkCount+=M),Hl(l,v,w),Hl(c,b,w)};for(let[v,b]of Object.entries(e))if(!(!s.has(v)||f(v)))for(let[M,E]of Object.entries(b??{}))!s.has(M)||f(M)||m(v,M,Math.max(1,Number(E)||1),"link");if(n.includeUnresolvedLinks){for(let[v,b]of Object.entries(t))if(!(!s.has(v)||f(v)))for(let[M,E]of Object.entries(b??{})){let w=`unresolved:${v}:${M}`;if(!s.has(w)){let C=s.get(v);g({id:w,path:M,title:M,type:"unresolved",parentId:C?.parentId??Ze,depth:(C?.depth??0)+1,noteCount:0,linkCount:0,backlinkCount:0,descendantCount:0})}m(v,w,Math.max(1,Number(E)||1),"unresolved-link")}}Gb(s,r,a),Hb(s);let p={loadedEntries:d,scannedMarkdown:h,folders:[...s.values()].filter(v=>v.type==="folder").length,notes:[...s.values()].filter(v=>v.type==="note").length,unresolved:[...s.values()].filter(v=>v.type==="unresolved").length,hierarchyEdges:r.length,linkEdges:o.length,maxDepth:Math.max(0,...[...s.values()].map(v=>v.depth))};return{nodes:s,hierarchyEdges:r,linkEdges:o,childrenByParent:a,linkEdgesBySource:l,linkEdgesByTarget:c,folderRepresentatives:u,stats:p}}function Wl(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 Oi(i){return String(i||"").trim().replace(/^\/+|\/+$/g,"")}function jh(i){let e=Oi(i),t=e.lastIndexOf("/");return t===-1?Ze:e.slice(0,t)}function Gl(i){let e=Oi(i),t=e.lastIndexOf("/");return t===-1?e:e.slice(t+1)}function qp(i){let e=Oi(i);return e?e.split("/").filter(Boolean).length:0}function zb(i,e){let t=Oi(i);return t?e.some(n=>t===n||t.startsWith(`${n}/`)):!1}function Vb(i,e){let t=new Map;for(let n of i.values())n.type==="note"&&n.parentId!==null&&Hl(t,n.parentId,n);for(let n of i.values()){if(n.type!=="folder"||n.id===Ze)continue;let s=Yp(n.title),r=(t.get(n.id)??[]).find(o=>Yp(o.title)===s);r&&(n.representativeFile=r.id,r.isRepresentativeFile=!0,r.representativeFor=n.id,e.set(n.id,r.id))}}function Gb(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}),Hl(t,n.parentId,n.id));for(let n of t.values())n.sort((s,r)=>Wl(i.get(s),i.get(r)))}function Hb(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 Yp(i){return i.replace(/\.md$/i,"").trim().toLowerCase()}function Hl(i,e,t){let n=i.get(e);n?n.push(t):i.set(e,[t])}function tm(i){let e=i.hiddenLegendItems.slice(),t=new Set(e);return{mode:"atlas",rootPath:Ze,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 nm(i,e,t=Ot){return e.mode==="focus"?Xb(i,e,t):Wb(i,e,t)}function eu(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 Wb(i,e,t){let n=i.nodes.has(e.rootPath)?e.rootPath:Ze,s=i.nodes.get(n)?.depth??0,r=Ct(e.atlasDepth,1,80,t.atlasDepth),o=tu(e.search),a=new Set,l=[n];for(;l.length>0;){let c=l.pop(),u=c?i.nodes.get(c):i.nodes.get(Ze);if(!u)continue;let h=Math.max(0,u.depth-s)<=r,f=o.length>0&&Xl(u,o);if((h||f)&&(a.add(u.id),f&&Gs(i,u.id,a,n)),h||f)for(let g of[...i.childrenByParent.get(u.id)??[]].reverse())l.push(g)}if(o)for(let c of i.nodes.values())Xl(c,o)&&(a.add(c.id),Gs(i,c.id,a,n));return sm(i,a),im(i,a,n,e,t,null)}function Xb(i,e,t){let n=e.focusPath&&i.nodes.has(e.focusPath)?e.focusPath:eM(i),s=new Set([Ze]),r=Ct(e.focusSiblingLimit,10,1e3,t.focusSiblingLimit);if(n){s.add(n),Gs(i,n,s,Ze);let a=i.nodes.get(n);if(a?.parentId)for(let c of(i.childrenByParent.get(a.parentId)??[]).slice(0,r))s.add(c);let l=[...i.linkEdgesBySource.get(n)??[],...i.linkEdgesByTarget.get(n)??[]].sort((c,u)=>u.weight-c.weight);for(let c of l.slice(0,Math.max(30,r)))s.add(c.source),s.add(c.target),Gs(i,c.source,s,Ze),Gs(i,c.target,s,Ze)}let o=tu(e.search);if(o)for(let a of i.nodes.values())Xl(a,o)&&(s.add(a.id),Gs(i,a.id,s,Ze));return sm(i,s),im(i,s,Ze,e,t,n)}function im(i,e,t,n,s,r){let o=[...e].map(h=>i.nodes.get(h)).filter(h=>!!h);o.sort(Wl);let a=Yb(i,o,t,n,s,r);o=Zb(i,a.nodes);let l=new Set(o.map(h=>h.id)),c=i.hierarchyEdges.filter(h=>l.has(h.source)&&l.has(h.target)),u=qb(i,l,n,s,t);o=o.concat(u.externalNodes);let d=new Map(o.map(h=>[h.id,h]));return{nodes:o,nodesById:d,hierarchyEdges:c.concat(u.externalHierarchyEdges),linkEdges:u.linkEdges,hoverLinkEdges:u.hoverLinkEdges,rootId:t,focusId:eu(i,r),hiddenNodeCount:a.hiddenNodeCount,externalNodeCount:u.externalNodes.length,externalFileCount:u.externalNodes.filter(h=>h.externalProxy).length,externalGroupCount:u.externalNodes.filter(h=>h.type==="external"&&!h.externalProxy).length}}function qb(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"),u=Ys(t.hoverHighlightMode)||t.pinNeedsHoverLinks,d=t.showExternalLinks&&s!==Ze&&(c||l);if(!o&&!a&&!u&&!d)return{linkEdges:[],hoverLinkEdges:[],externalNodes:[],externalHierarchyEdges:[]};let h=new Map,f=new Map,g=[],x=Ct(t.externalLinkAnchorLimit,0,2e4,n.externalLinkAnchorLimit),m={fileCount:0,overflowId:null};for(let T of i.linkEdges){let P=Kp(i,T.source,e,s),R=Kp(i,T.target,e,s),I=0;if(d&&(!P&&R&&(P=Jp(i,T.source,s,f,g,x,m,jp(T,t,R)),P&&(I=1)),P&&!R&&(R=Jp(i,T.target,s,f,g,x,m,jp(T,t,P)),R&&(I=1))),!P||!R||P===R)continue;let H=`${P}->${R}`,W=h.get(H)??{id:`visible-link:${H}`,type:"visible-link",source:P,target:R,weight:0,rawCount:0,unresolvedCount:0,externalCount:0};W.weight+=T.weight,W.rawCount=(W.rawCount??0)+1,T.type==="unresolved-link"&&(W.unresolvedCount=(W.unresolvedCount??0)+1),W.externalCount=(W.externalCount??0)+I,h.set(H,W)}let p=[...h.values()].sort((T,P)=>em(P)-em(T)),v=T=>T.externalCount?l&&(!T.unresolvedCount||a):T.unresolvedCount?a:o,b=T=>T.externalCount?d&&l&&(!T.unresolvedCount||!r.has("dashed-link")):T.unresolvedCount?!r.has("dashed-link"):!r.has("link"),M=t.showCompleteRoot?3e4:Ct(t.linkLimit,0,3e4,n.linkLimit),E=p.filter(v).slice(0,M),w=t.showCompleteRoot?E:p.filter(b),C=new Set;for(let T of d?p.filter(P=>P.externalCount):u?w:[])f.has(T.source)&&C.add(T.source),f.has(T.target)&&C.add(T.target);let _=jb(C,f);return{linkEdges:E,hoverLinkEdges:w,externalNodes:_,externalHierarchyEdges:g.filter(T=>C.has(T.target))}}function Yb(i,e,t,n,s,r){if(n.showCompleteRoot&&e.length<=2e4)return{nodes:e,hiddenNodeCount:0};let o=Ct(n.nodeLimit,200,2e4,s.renderNodeLimit);if(e.length<=o)return{nodes:e,hiddenNodeCount:0};let a=e.slice().sort((d,h)=>Qp(h,t,r,n.search)-Qp(d,t,r,n.search)),l=new Map(e.map(d=>[d.id,d])),c=new Set([t,r].filter(d=>d!=null));$p(i,t,c,o,n.showCompleteRoot?128:64);for(let d of a){if(c.size>=o)break;$b(i,d.id,c,l,o),d.type==="folder"&&$p(i,d.id,c,o,n.showCompleteRoot?18:8)}let u=e.filter(d=>c.has(d.id));return{nodes:u,hiddenNodeCount:Math.max(0,e.length-u.length)}}function Zb(i,e){let t=new Set(e.map(n=>n.id));return e.filter(n=>!n.isRepresentativeFile||!n.representativeFor||!t.has(n.representativeFor))}function sm(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 Gs(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||Ze)}function $b(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]??Ze)}function $p(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 Kp(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(Ze)?Ze:null}function Jp(i,e,t,n,s,r,o,a){let l=i.nodes.get(e);if(!l)return null;let c=Qb(l,t);if(!c)return null;let u=Kb(i,c,t,n);return!a||l.type!=="note"&&l.type!=="unresolved"?u:n.has(l.id)?l.id:o.fileCount>=r?Jb(t,u,n,s,o):(n.set(l.id,{...l,externalProxy:!0,externalParentId:u,externalAnchorPath:c}),o.fileCount++,s.push({id:`external-hierarchy:${u}->${l.id}`,type:"external-hierarchy",source:u,target:l.id,weight:1}),l.id)}function Kb(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??Gl(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 Jb(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 jb(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(Wl)}function jp(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 Qb(i,e){let t=i.type==="unresolved"?jh(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 eM(i){return[...i.nodes.values()].find(e=>e.type==="note")?.id??null}function tu(i){return i.trim().toLowerCase()}function Xl(i,e){return i.title.toLowerCase().includes(e)||i.path.toLowerCase().includes(e)}function Qp(i,e,t,n){let s=0;return i.id===e&&(s+=1e6),i.id===t&&(s+=9e5),n&&Xl(i,tu(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 em(i){return(i.weight||1)*10+(i.rawCount||0)*4+(i.externalCount||0)*25+(i.unresolvedCount||0)*8}var ql=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=Zp(this.collectVaultEntries(),this.app.metadataCache.resolvedLinks,this.app.metadataCache.unresolvedLinks,e)}buildVisibleGraph(e){return this.model||this.rebuild(),nm(this.model,e,this.settings)}visualNodeId(e){return this.model?eu(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 Yl.TFolder){let r=Oi(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 Yl.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===Ze)?e.filter(s=>s.path!==Ze):e}};var $l=class extends kt.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="inspect";this.selectedNodeId=null;this.selectedLink=null;this.hoverNodeId=null;this.hoverLink=null;this.pinnedPaths=[];this.pinGroups=[];this.selectedPinIds=new Set;this.nextPinId=1;this.nextPinGroupId=1;this.pinGroupName="";this.drag=null;this.needsFit=!0;this.index=new ql(t,s.radial),this.state=tm(s.radial),this.saveSoon=(0,kt.debounce)(r,500,!0),this.redrawSoon=(0,kt.debounce)(()=>this.rebuild("metadata"),600,!0)}get counts(){return{nodes:this.graph?.nodes.length??0,links:this.graph?.linkEdges.length??0}}async start(){this.contentEl.addClass("mwm-radial-mode"),this.canvasHost=this.contentEl.createDiv({cls:"mwm-radial-host"}),this.renderer=new zl(this.canvasHost),this.syncThemeClass(),this.buildPanel(),this.buildFloatingControls(),this.bindRendererEvents(),this.registerVaultEvents(),this.rebuild("start")}resize(){!this.renderer||!this.canvasHost||(this.renderer.resize(this.canvasHost.clientWidth,this.canvasHost.clientHeight),this.needsFit&&(this.renderer.fitToLayout(),this.needsFit=!1),this.renderer.render())}onCssChange(){this.syncThemeClass()}rebuild(t){let n=this.radial();this.index.rebuild(n),this.state.hoverHighlightMode=n.hoverHighlightMode,this.state.labelVisibility=n.labelVisibility,this.state.hiddenLegendItems=n.hiddenLegendItems.slice(),this.state.pinNeedsHoverLinks=this.pinnedPathsNeedHoverLinks(),this.state.selectedNodeId=this.selectedNodeId,this.state.selectedLink=this.selectedLink;let s=this.index.buildVisibleGraph({...this.state,showLinkOverlay:!0,hiddenLegendItems:[],pinNeedsHoverLinks:!0}),r=new Set(this.state.hiddenLegendItems);this.state.showLinkOverlay||r.add("link");let o=nM(s,r);this.graph=o,this.layout=kp(s,{ringSpacing:Lp,nodeSpacing:Dp,swirlStrength:n.swirlStrength}),this.renderer?.setTheme(this.resolvedCanvasScheme()),this.renderer?.setData(o,this.layout,n.labelVisibility),this.resize(),this.applyActiveState(),this.renderPanel(),["start","manual","root","focus","atlas"].includes(t)&&this.renderer?.playRevealFromRoot(o.rootId,this.t("loading.radial"))}radial(){return this.settings.radial}registerVaultEvents(){this.registerEvent(this.app.metadataCache.on("resolved",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 kt.TFile&&t.extension==="md"&&this.redrawSoon()}))}bindRendererEvents(){let t=this.renderer?.domElement;if(!t)return;let n=u=>{u.preventDefault();let d=this.renderer;if(!d)return;let h=t.getBoundingClientRect(),f=d.screenToWorld(u.clientX-h.left,u.clientY-h.top),g=d.getView(),x=Math.pow(1.45,-u.deltaY/120),m=Math.min(Math.max(g.zoom*x,.003),6),p=f.x-(u.clientX-h.left-h.width/2)/m,v=f.y+(u.clientY-h.top-h.height/2)/m;d.setView(p,v,m)},s=u=>{if(u.button!==0)return;t.focus();let d=this.renderer?.getView();d&&(this.drag={pointerId:u.pointerId,startX:u.clientX,startY:u.clientY,centerX:d.centerX,centerY:d.centerY,moved:!1},t.setPointerCapture?.(u.pointerId))},r=u=>{let d=t.getBoundingClientRect();if(this.drag){let h=this.renderer;if(!h)return;let f=u.clientX-this.drag.startX,g=u.clientY-this.drag.startY;this.drag.moved=this.drag.moved||Math.hypot(f,g)>3;let x=h.getView();h.setView(this.drag.centerX-f/x.zoom,this.drag.centerY+g/x.zoom,x.zoom);return}this.updateHover(u.clientX-d.left,u.clientY-d.top)},o=u=>{let d=this.drag?.moved??!1;if(this.drag=null,t.releasePointerCapture?.(u.pointerId),d)return;let h=t.getBoundingClientRect();this.activateAt(u.clientX-h.left,u.clientY-h.top,u)},a=()=>{this.drag||(this.hoverNodeId=null,this.hoverLink=null,this.applyActiveState())},l=u=>{let d=t.getBoundingClientRect(),h=this.renderer?.hitTest(u.clientX-d.left,u.clientY-d.top,!1,this.hoverTargets().nodes);if(!h?.nodeId||!this.graph)return;let f=this.graph.nodesById.get(h.nodeId);f&&(u.preventDefault(),f.type==="note"?this.openNode(f.id,u):f.type==="folder"&&this.useAsRoot(f.id))},c=u=>{let d=t.getBoundingClientRect(),h=this.renderer?.hitTest(u.clientX-d.left,u.clientY-d.top,!1,this.hoverTargets().nodes);if(!h?.nodeId||!this.graph)return;let f=this.graph.nodesById.get(h.nodeId);f&&(u.preventDefault(),this.showNodeMenu(u,f))};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 Vl();let t=this.hoverNodeId??this.selectedNodeId,n=this.hoverLink??this.selectedLink,s=Vl();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),Ys(l))for(let u of[...this.graph.linkEdges,...this.graph.hoverLinkEdges])u.source!==a&&u.target!==a||(s.highlightedEdges.add(u.id),s.relatedNodes.add(u.source),s.relatedNodes.add(u.target),s.labelNodes.add(u.source),s.labelNodes.add(u.target));tM(this.graph,a,zi(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.kind==="node"?r(a.nodeId,a.mode,!0):o(this.findGraphEdgeForPin(a),!0);return s.hasActive=!!(t||n||this.pinnedPaths.length),s.dimOthers=!!(t||n),s}hoverTargets(){let t=os(this.radial().hoverTargetMode);return{nodes:t!=="links",links:t!=="nodes"}}buildPanel(){this.panel=this.contentEl.createDiv({cls:"galaxy-panel mwm-radial-panel mwm-map-panel"}),this.syncThemeClass();let t=this.panel.createDiv({cls:"galaxy-panel-header"});this.statsEl=t.createDiv({cls:"galaxy-panel-stats",text:"Mini World Map"});let n=t.createEl("button",{cls:"galaxy-panel-collapse",text:"-"});this.panelBody=this.panel.createDiv({cls:"galaxy-panel-body"}),n.addEventListener("click",()=>{let s=this.panelBody?.hasClass("is-hidden")??!1;this.panelBody?.toggleClass("is-hidden",!s),n.setText(s?"-":"+")}),this.renderPanel()}renderPanel(){if(!this.panelBody)return;let t=this.graph;this.panelBody.empty(),this.statsEl&&this.statsEl.setText(this.t("stats.counts",{nodes:t?.nodes.length??0,links:t?.linkEdges.length??0}));let n=this.panelBody.createDiv({cls:"mwm-mode-switch"});n.createDiv({cls:"mwm-mode-switch-label",text:this.t("view.mode")});let s=n.createDiv({cls:"galaxy-mode-row mwm-mode-row"});this.modeButton(s,ui(this.settings.language,"radial2d"),"radial2d"),this.modeButton(s,ui(this.settings.language,"map3d"),"map3d");let r=this.panelBody.createDiv({cls:"mwm-panel-settings mwm-radial-settings"}),o=r.createDiv({cls:"mwm-panel-tabs"});for(let[l,c]of[["inspect",this.t("tab.inspect")],["pins",this.t("tab.pins")],["view",this.t("tab.view")],["controls",this.t("tab.controls")],["defaults",this.t("tab.defaults")]])o.createEl("button",{cls:this.activePanelPage===l?"is-active":"",text:c}).addEventListener("click",()=>{this.activePanelPage=l,this.renderPanel()});let a=r.createDiv({cls:"mwm-panel-page"});this.activePanelPage==="pins"?this.renderPinsPage(a):this.activePanelPage==="view"?this.renderViewPage(a):this.activePanelPage==="controls"?this.renderControlsPage(a):this.activePanelPage==="defaults"?this.renderDefaultsPage(a):this.renderInspectPage(a)}modeButton(t,n,s){let r=this.settings.viewMode===s;t.createEl("button",{cls:r?"is-active":"",text:n}).addEventListener("click",()=>this.onViewMode(s))}renderInspectPage(t){if(!this.graph)return;if(this.selectedLink){this.renderLinkInspect(t,this.selectedLink);return}let n=this.graph.nodesById.get(this.selectedNodeId??this.graph.focusId??this.graph.rootId);if(t.createDiv({cls:"mwm-side-title",text:n?.title??"Mini World Map"}),!n)return;t.createDiv({cls:"mwm-side-path",text:n.path||"/"});let s=t.createDiv({cls:"mwm-facts"});for(let[o,a]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:o}),s.createSpan({text:a});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)),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 u=this.index.nodes.get(c[l]);if(!u)continue;t.createEl("button",{cls:"mwm-link-row",text:`${u.title} (${c.weight})`}).addEventListener("click",()=>this.inspectNode(u.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}for(let o of this.pinnedPaths){let a=t.createDiv({cls:"mwm-pin-row"}),l=a.createEl("input",{attr:{type:"checkbox"}});l.checked=this.selectedPinIds.has(o.id),l.addEventListener("change",()=>{l.checked?this.selectedPinIds.add(o.id):this.selectedPinIds.delete(o.id),this.renderPanel()}),a.createEl("button",{cls:"mwm-pin-main",text:o.title}).addEventListener("click",()=>this.locatePin(o)),this.button(a,this.t("common.inspect"),()=>this.inspectPin(o)),this.button(a,"X",()=>this.removePin(o.id))}}renderViewPage(t){this.textInput(t,this.t("common.search"),this.state.search,r=>{this.state.search=r.trim(),this.needsFit=!0,this.rebuild("search")}),this.select(t,this.t("view.theme"),this.radial().colorScheme,fu(this.settings.language),r=>{this.radial().colorScheme=eo(r),this.saveSoon(),this.syncThemeClass()});let n=t.createDiv({cls:"galaxy-panel-row"});this.button(n,this.t("view.atlas"),()=>this.resetToAtlas(),this.state.mode==="atlas"),this.button(n,this.t("view.focus"),()=>this.focusActiveNote(),this.state.mode==="focus"),this.button(n,this.t("view.vaultRoot"),()=>this.resetToRoot());let s=t.createDiv({cls:"galaxy-panel-row"});this.button(s,this.t("common.fit"),()=>this.renderer?.fitToLayout()),this.button(s,this.t("common.rebuild"),()=>this.rebuild("manual"))}renderControlsPage(t){let n=this.radial();this.numberInput(t,this.t("control.depth"),this.state.atlasDepth,1,80,1,o=>{this.state.atlasDepth=o,this.rebuild("depth")}),this.numberInput(t,this.t("control.nodes"),this.state.nodeLimit,200,2e4,100,o=>{this.state.nodeLimit=o,this.rebuild("nodes")}),this.numberInput(t,this.t("control.noteLinks"),this.state.linkLimit,0,3e4,50,o=>{this.state.linkLimit=o,this.rebuild("links")});let s=new Set(n.hiddenLegendItems),r=this.state.showLinkOverlay&&!s.has("link");this.toggle(t,this.t("control.showNoteLinks"),r,o=>{n.showLinkOverlay=o,this.state.showLinkOverlay=o,this.setLegendHidden("link",!o),this.saveSoon(),this.rebuild("link-overlay")}),this.select(t,this.t("control.hover"),this.state.hoverHighlightMode,to(this.settings.language,Hs),o=>{let a=zi(o);this.state.hoverHighlightMode=a,n.hoverHighlightMode=a,this.saveSoon(),this.rebuild("hover")}),this.select(t,this.t("control.hoverTargets"),n.hoverTargetMode,no(this.settings.language,Ws),o=>{n.hoverTargetMode=os(o),this.clearDisallowedHoverTargets(),this.saveSoon(),this.applyActiveState(),this.renderPanel()}),this.select(t,this.t("control.labels"),n.labelVisibility,io(this.settings.language,jr),o=>{n.labelVisibility=qs(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.outsideLinks"),this.state.showExternalLinks,o=>{this.state.showExternalLinks=o,n.showExternalLinks=o,this.saveSoon(),this.rebuild("external")}),this.select(t,this.t("control.outsideDetail"),this.state.externalDetailMode,pu(this.settings.language),o=>{this.state.externalDetailMode=rc(o),n.externalDetailMode=this.state.externalDetailMode,this.saveSoon(),this.rebuild("external-mode")}),this.numberInput(t,this.t("control.exactOutsideFiles"),this.state.externalLinkAnchorLimit,0,2e4,50,o=>{this.state.externalLinkAnchorLimit=o,n.externalLinkAnchorLimit=o,this.saveSoon(),this.rebuild("external-limit")}),this.renderLegend(t)}renderDefaultsPage(t){let n=this.radial();this.numberInput(t,this.t("control.defaultDepth"),n.atlasDepth,1,80,1,s=>{n.atlasDepth=s,this.state.atlasDepth=s,this.saveSoon()}),this.numberInput(t,this.t("control.defaultNodes"),n.renderNodeLimit,200,2e4,100,s=>{n.renderNodeLimit=s,this.state.nodeLimit=s,this.saveSoon()}),this.numberInput(t,this.t("control.defaultNoteLinks"),n.linkLimit,0,3e4,50,s=>{n.linkLimit=s,this.state.linkLimit=s,this.saveSoon()}),this.toggle(t,this.t("control.unresolvedLinks"),n.includeUnresolvedLinks,s=>{n.includeUnresolvedLinks=s,this.saveSoon(),this.rebuild("unresolved")}),this.textArea(t,this.t("control.ignoredFolders"),n.ignoreFolders.join(`
`),s=>{n.ignoreFolders=s.split(`
`).map(r=>r.trim()).filter(Boolean),this.saveSoon(),this.rebuild("ignored")})}renderLegend(t){t.createDiv({cls:"mwm-side-heading",text:this.t("control.legend")});let n=new Set(this.radial().hiddenLegendItems);for(let[s,r,o,a]of ic){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 u=l.createSpan({cls:"mwm-legend-copy"});u.createSpan({cls:"mwm-legend-label",text:this.t(r)}),u.createSpan({cls:"mwm-legend-desc",text:this.t(o)}),c.addEventListener("change",()=>{let d=c.checked;d?n.delete(s):n.add(s),this.radial().hiddenLegendItems=[...n],this.state.hiddenLegendItems=[...n],s==="link"&&(this.radial().showLinkOverlay=d,this.state.showLinkOverlay=d),this.saveSoon(),this.rebuild("legend")})}}setLegendHidden(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 n=t.createDiv({cls:"mwm-floating-controls"}),s=n.createEl("button",{cls:"mwm-floating-button",attr:{type:"button",title:this.t("language"),"aria-label":this.t("language")}});(0,kt.setIcon)(s,"languages"),s.addEventListener("click",r=>{r.preventDefault(),r.stopPropagation(),this.openLanguageMenu(s)}),this.iconButton(n,"home",this.t("view.vaultRoot"),()=>this.resetToRoot()),this.iconButton(n,"pin",this.t("common.pinCurrent"),()=>this.pinCurrent()),this.iconButton(n,"maximize",this.t("common.fit"),()=>this.renderer?.fitToLayout()),this.iconButton(n,"refresh-cw",this.t("common.rebuild"),()=>this.rebuild("manual"))}openLanguageMenu(t){let n=new kt.Menu;for(let[r,o]of as(this.settings.language))n.addItem(a=>{a.setTitle(o),r===this.settings.language&&a.setIcon("check"),a.onClick(()=>{let l=rs(r);l!==this.settings.language&&(this.settings.language=l,this.onLanguage(l),this.renderPanel())})});let s=t.getBoundingClientRect();n.showAtPosition({x:s.right,y:s.bottom})}iconButton(t,n,s,r){let o=t.createEl("button",{cls:"mwm-floating-button",attr:{type:"button",title:s,"aria-label":s}});return(0,kt.setIcon)(o,n),o.addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),r()}),o}button(t,n,s,r=!1){let o=t.createEl("button",{cls:r?"is-active":"",text:n});return o.addEventListener("click",s),o}textInput(t,n,s,r){let o=t.createEl("label",{cls:"mwm-panel-field"});o.createSpan({text:n});let a=o.createEl("input",{attr:{value:s,type:"search"}});a.addEventListener("change",()=>r(a.value))}numberInput(t,n,s,r,o,a,l){let c=t.createEl("label",{cls:"mwm-panel-field"});c.createSpan({text:n});let u=c.createEl("input",{attr:{value:String(s),type:"number",min:String(r),max:String(o),step:String(a)}});u.addEventListener("change",()=>l(Ct(u.value,r,o,s)))}textArea(t,n,s,r){let o=t.createEl("label",{cls:"mwm-panel-field"});o.createSpan({text:n});let a=o.createEl("textarea");a.value=s,a.addEventListener("change",()=>r(a.value))}toggle(t,n,s,r,o){let a=t.createEl("label",{cls:"mwm-panel-toggle",attr:{title:o??n}}),l=a.createEl("input",{attr:{type:"checkbox"}});l.checked=s,a.createSpan({text:n}),l.addEventListener("change",()=>r(l.checked))}select(t,n,s,r,o){let a=t.createEl("label",{cls:"mwm-panel-field"});a.createSpan({text:n});let l=a.createEl("select");for(let[c,u]of r)l.createEl("option",{attr:{value:c},text:u});l.value=s,l.addEventListener("change",()=>o(l.value))}pinCurrent(){this.selectedLink?this.pinLink(this.selectedLink):this.selectedNodeId&&this.graph?.nodesById.has(this.selectedNodeId)?this.pinNode(this.graph.nodesById.get(this.selectedNodeId)):this.hoverLink?this.pinLink(this.hoverLink):this.hoverNodeId&&this.graph?.nodesById.has(this.hoverNodeId)?this.pinNode(this.graph.nodesById.get(this.hoverNodeId)):new kt.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=this.pinnedPaths.find(o=>o.key===n);if(s){this.selectedPinIds.add(s.id),new kt.Notice(this.t("pins.already")),this.renderPanel();return}let r={...t,id:`pin-${this.nextPinId++}`,key:n,groupId:null};this.pinnedPaths.push(r),this.selectedPinIds.add(r.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.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 kt.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.pinGroupName="",this.selectedPinIds.clear(),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.kind==="link"||t.kind==="node"&&Ys(t.mode))}clearDisallowedHoverTargets(){let t=this.hoverTargets();t.nodes||(this.hoverNodeId=null),t.links||(this.hoverLink=null),this.canvasHost?.toggleClass("is-pointing",!!(t.nodes&&this.hoverNodeId||t.links&&this.hoverLink))}inspectNode(t){this.selectedNodeId=t,this.selectedLink=null,this.applyActiveState(),this.renderPanel()}resetToAtlas(){this.state.mode="atlas",this.state.rootPath=this.state.rootPath||Ze,this.state.focusPath=null,this.needsFit=!0,this.rebuild("atlas")}resetToRoot(){this.state.mode="atlas",this.state.rootPath=Ze,this.state.focusPath=null,this.needsFit=!0,this.rebuild("root")}useAsRoot(t){this.state.mode="atlas",this.state.rootPath=t,this.state.focusPath=null,this.needsFit=!0,this.rebuild("root")}focusActiveNote(){let t=this.index.getActiveNotePath();t&&this.focusNote(t)}focusNote(t){this.state.mode="focus",this.state.focusPath=t,this.state.rootPath=Ze,this.needsFit=!0,this.rebuild("focus")}showNodeMenu(t,n){let s=new kt.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 kt.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();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"),(this.renderer?.setTheme(t)??!1)&&this.graph&&this.layout&&this.renderer?.setData(this.graph,this.layout,this.radial().labelVisibility)}resolvedCanvasScheme(){let t=eo(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 Ce(this.settings.language,t,n)}dispose(){this.unload(),this.renderer?.dispose(),this.renderer=null,this.contentEl.removeClass("mwm-radial-mode"),this.contentEl.empty()}};function tM(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 nM(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),u=i.hoverLinkEdges.filter(l);return{...i,nodes:n,nodesById:new Map(n.map(d=>[d.id,d])),hierarchyEdges:o,linkEdges:c,hoverLinkEdges:u}}var Ui=class extends rm.ItemView{constructor(t,n){super(t);this.host=n;this.navigation=!0;this.controller=null}getViewType(){return Wn}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.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))if(this.host.settings.viewMode==="map3d"){let s=new zs(this.app,this.contentEl,this.host.settings.galaxy3d,()=>void this.host.saveSettings(),r=>this.switchMode(r),this.host.settings.language,r=>this.host.setLanguage(r));s.onContextLost=()=>this.rebuild(),this.controller=s,this.addChild(s.store),s.start()}else{let s=new $l(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),s.start()}}rebuild(){this.controller?.dispose(),this.controller=null,this.contentEl.empty(),this.tryInit()}async onClose(){this.controller?.dispose(),this.controller=null,this.contentEl.empty()}};var Jl=class extends Et.Plugin{constructor(){super(...arguments);this.settings=sc(null)}async onload(){this.settings=sc(await this.loadData()),this.registerView(Wn,t=>new Ui(t,this)),this.addRibbonIcon("network","Open Mini World Map",()=>{this.activateView()}),this.addCommand({id:"open-map",name:"Open Mini World Map",callback:()=>void this.activateView()}),this.addCommand({id:"toggle-render-mode",name:"Toggle Mini World Map render mode",callback:()=>{this.setViewMode(this.settings.viewMode==="radial2d"?"map3d":"radial2d"),this.activateView()}}),this.addCommand({id:"rebuild-index",name:"Rebuild Mini World Map index",callback:()=>{let t=!1;for(let n of this.app.workspace.getLeavesOfType(Wn)){let s=n.view;s instanceof Ui&&"rebuild"in(s.controller??{})&&(s.controller.rebuild?.("manual"),t=!0)}new Et.Notice(Ce(this.settings.language,t?"notice.rebuilt":"notice.openToBuild"))}}),this.addCommand({id:"search-3d",name:"Search 3D map node and fly",callback:()=>{this.activateView().then(t=>{t?.controller instanceof zs?t.controller.openSearch():new Et.Notice(Ce(this.settings.language,"notice.switchTo3d"))})}}),this.addSettingTab(new nu(this.app,this))}async saveSettings(){await this.saveData(this.settings)}setViewMode(t){this.settings.viewMode=Qr(t),this.saveSettings();for(let n of this.app.workspace.getLeavesOfType(Wn)){let s=n.view;s instanceof Ui&&s.switchMode(this.settings.viewMode)}}setLanguage(t){this.settings.language=rs(t),this.saveSettings();for(let n of this.app.workspace.getLeavesOfType(Wn)){let s=n.view;s instanceof Ui&&s.switchMode(this.settings.viewMode)}}async activateView(){let{workspace:t}=this.app,n=t.getLeavesOfType(Wn)[0]??null;return n||(n=t.getLeaf(!0),await n.setViewState({type:Wn,active:!0})),n.isDeferred&&await n.loadIfDeferred(),await t.revealLeaf(n),n.view instanceof Ui?n.view:null}},nu=class extends Et.PluginSettingTab{constructor(t,n){super(t,n);this.plugin=n}display(){let{containerEl:t}=this,n=this.plugin.settings.radial,s=this.plugin.settings.language;t.empty(),t.createEl("h2",{text:Ce(s,"settings.title")}),new Et.Setting(t).setName(Ce(s,"language")).setDesc(Ce(s,"settings.languageDesc")).addDropdown(r=>{for(let[o,a]of as(s))r.addOption(o,a);r.setValue(this.plugin.settings.language).onChange(async o=>{this.plugin.settings.language=rs(o),await this.plugin.saveSettings(),this.display()})}),new Et.Setting(t).setName(Ce(s,"settings.defaultMode")).setDesc(Ce(s,"settings.defaultModeDesc")).addDropdown(r=>r.addOption("radial2d",ui(s,"radial2d")).addOption("map3d",ui(s,"map3d")).setValue(this.plugin.settings.viewMode).onChange(async o=>{this.plugin.settings.viewMode=Qr(o),await this.plugin.saveSettings()})),new Et.Setting(t).setName(Ce(s,"control.defaultDepth")).setDesc(Ce(s,"settings.depthDesc")).addSlider(r=>r.setLimits(1,20,1).setValue(n.atlasDepth).setDynamicTooltip().onChange(async o=>{n.atlasDepth=Ct(o,1,80,Ot.atlasDepth),await this.plugin.saveSettings()})),new Et.Setting(t).setName(Ce(s,"control.defaultNodes")).setDesc(Ce(s,"settings.nodeLimitDesc")).addText(r=>r.setPlaceholder(String(Ot.renderNodeLimit)).setValue(String(n.renderNodeLimit)).onChange(async o=>{n.renderNodeLimit=Ct(o,200,2e4,Ot.renderNodeLimit),await this.plugin.saveSettings()})),new Et.Setting(t).setName(Ce(s,"control.defaultNoteLinks")).setDesc(Ce(s,"settings.linkLimitDesc")).addText(r=>r.setPlaceholder(String(Ot.linkLimit)).setValue(String(n.linkLimit)).onChange(async o=>{n.linkLimit=Ct(o,0,3e4,Ot.linkLimit),await this.plugin.saveSettings()})),new Et.Setting(t).setName(Ce(s,"control.showNoteLinks")).setDesc(Ce(s,"settings.showLinksDesc")).addToggle(r=>r.setValue(n.showLinkOverlay&&!n.hiddenLegendItems.includes("link")).onChange(async o=>{n.showLinkOverlay=o;let a=new Set(n.hiddenLegendItems);o?a.delete("link"):a.add("link"),n.hiddenLegendItems=[...a],await this.plugin.saveSettings()})),new Et.Setting(t).setName(Ce(s,"control.hover")).setDesc(Ce(s,"settings.hoverDesc")).addDropdown(r=>{for(let[o,a]of to(s,Hs))r.addOption(o,a);r.setValue(n.hoverHighlightMode).onChange(async o=>{n.hoverHighlightMode=zi(o),await this.plugin.saveSettings()})}),new Et.Setting(t).setName(Ce(s,"control.hoverTargets")).setDesc(Ce(s,"settings.hoverTargetsDesc")).addDropdown(r=>{for(let[o,a]of no(s,Ws))r.addOption(o,a);r.setValue(n.hoverTargetMode).onChange(async o=>{n.hoverTargetMode=os(o),await this.plugin.saveSettings()})}),new Et.Setting(t).setName(Ce(s,"control.labels")).setDesc(Ce(s,"settings.labelsDesc")).addDropdown(r=>{for(let[o,a]of io(s,jr))r.addOption(o,a);r.setValue(n.labelVisibility).onChange(async o=>{n.labelVisibility=qs(o),await this.plugin.saveSettings()})}),new Et.Setting(t).setName(Ce(s,"control.spin")).setDesc(Ce(s,"settings.spinDesc")).addSlider(r=>r.setLimits(0,100,1).setValue(n.swirlStrength).setDynamicTooltip().onChange(async o=>{n.swirlStrength=Ct(o,0,100,Ot.swirlStrength),await this.plugin.saveSettings()})),new Et.Setting(t).setName(Ce(s,"control.unresolvedLinks")).setDesc(Ce(s,"settings.unresolvedDesc")).addToggle(r=>r.setValue(n.includeUnresolvedLinks).onChange(async o=>{n.includeUnresolvedLinks=o,await this.plugin.saveSettings()})),new Et.Setting(t).setName(Ce(s,"control.ignoredFolders")).setDesc(Ce(s,"settings.ignoredDesc")).addTextArea(r=>r.setValue(n.ignoreFolders.join(`
`)).onChange(async o=>{n.ignoreFolders=o.split(`
`).map(a=>a.trim()).filter(Boolean),await this.plugin.saveSettings()}))}};
/*! Bundled license information:
three/build/three.core.js:
three/build/three.module.js:
(**
* @license
* Copyright 2010-2026 Three.js Authors
* SPDX-License-Identifier: MIT
*)
*/