@kineviz/gl 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -7969,6 +7969,9 @@ var WebGPUForceLayoutController = class {
7969
7969
  sn.fx = ln.position.x;
7970
7970
  sn.fy = ln.position.y;
7971
7971
  sn.fz = ln.position.z;
7972
+ sn.x = ln.position.x;
7973
+ sn.y = ln.position.y;
7974
+ sn.z = ln.position.z;
7972
7975
  } else if (useRandom3D) {
7973
7976
  const u = Math.random(), v = Math.random(), w = Math.random();
7974
7977
  const theta = 2 * Math.PI * u;
@@ -8252,6 +8255,9 @@ var WebGPUForceLayoutController = class {
8252
8255
  sn.fx = node.position.x;
8253
8256
  sn.fy = node.position.y;
8254
8257
  sn.fz = node.position.z;
8258
+ sn.x = node.position.x;
8259
+ sn.y = node.position.y;
8260
+ sn.z = node.position.z;
8255
8261
  this.simulation.uploadPosition(idx, node.position.x, node.position.y, node.position.z);
8256
8262
  this.simulation.uploadPinned(idx, true);
8257
8263
  } else {
@@ -14503,10 +14509,10 @@ import * as THREE14 from "three";
14503
14509
  var node_vert_default = 'precision highp float;\nconst float HALO_EXPAND = 2.2; // quad expansion when halo active\n\n// Position texture (from GPU layout controller)\nuniform sampler2D positionTexture;\nuniform float textureSize;\nuniform float spaceSize;\nuniform float fixedSize;\nuniform float nodeSizeScale;\nuniform float mapMode;\nuniform float mapDamping; // 0.0 = constant screen size, 1.0 = full perspective (used when mapMode > 0.5)\nuniform float mapMaxGrowth; // default 4.0; -1.0 sentinel \u21D2 Infinity / unbounded\nuniform float pixelRatio;\nuniform float sphereRadius;\nuniform vec2 resolution;\n\n// Animation\nuniform float animate;\nuniform float t;\n\n// Per-vertex attributes\nattribute float nodeIndex;\nattribute vec3 nodeColor;\nattribute float nodeSize;\nattribute float nodeOpacity;\nattribute float nodeIcon;\nattribute vec4 nodeIconUV;\nattribute vec4 nodeImageUV;\nattribute float nodeFlags;\nattribute float aNodeCollect;\nattribute vec3 toPosition;\nattribute vec3 nodeEffects;\nattribute vec2 corner; // [-0.5, 0.5]\xB2 quad corner offset\n\n// Time uniform for shader-driven effects\nuniform float time;\n// Hover-neighbor-highlight: current frame timestamp (ms, mod 2^19 = 524288)\n// + ramp duration. Lets each instance fade independently when hover-move\n// in Steady state diffs only a subset of instances.\nuniform float u_hoverTime;\nuniform float u_hoverDuration;\n\n// Varyings\nvarying vec3 vColor;\nvarying float vOpacity;\nvarying float vIcon;\nvarying vec4 vIconUV;\nvarying vec4 vImageUV;\nvarying float vSelected;\nvarying float vHighlighted;\nvarying float vPinned;\nvarying float vNodeCollect;\nvarying float vHidden;\nvarying float vHoverDim;\nvarying float vRipple;\nvarying float vBreathe;\nvarying float vHalo;\nvarying vec2 vUv; // [0,1]\xB2 fragment-local coordinate (replaces gl_PointCoord)\n\nvec3 samplePosition(float idx) {\n float texX = mod(idx, textureSize) + 0.5;\n float texY = floor(idx / textureSize) + 0.5;\n vec2 texCoord = vec2(texX, texY) / textureSize;\n vec4 posData = texture2D(positionTexture, texCoord);\n return posData.xyz;\n}\n\nvoid main() {\n // Unpack nodeFlags. Low 5 bits = flag bits (sel/hi/pin/hid/hoverDim);\n // upper 19 bits = the timestamp (ms mod 2^19) when the hoverDim bit last\n // flipped. The flag-bit unpack lines below keep working because the\n // timestamp portion is always a multiple of 32 (= 2^5) \u2192 even when\n // divided by 16, so it doesn\'t pollute the 0/1 result of `mod ... 2`.\n vSelected = mod(nodeFlags, 2.0);\n vHighlighted = mod(floor(nodeFlags / 2.0), 2.0);\n vPinned = mod(floor(nodeFlags / 4.0), 2.0);\n vHidden = mod(floor(nodeFlags / 8.0), 2.0);\n float _hoverTarget = mod(floor(nodeFlags / 16.0), 2.0);\n // Per-instance fade. `_hoverStart` is 0 for instances that have never\n // flipped (sentinel: skip animation, render at the target value).\n // For instances that have flipped, modular ms arithmetic gives\n // `diff = (u_hoverTime - start) mod 524288`. When diff > duration the\n // ramp is done; when 0 \u2264 diff < duration the instance is mid-fade.\n float _hoverStart = floor(nodeFlags / 32.0);\n float _hoverDiff = u_hoverTime - _hoverStart;\n if (_hoverDiff < 0.0) _hoverDiff += 524288.0;\n float _hoverT = _hoverStart < 0.5\n ? 1.0 // never animated \u2192 snap to target\n : clamp(_hoverDiff / max(u_hoverDuration, 1.0), 0.0, 1.0);\n float _hoverEased = _hoverT < 0.5\n ? 4.0 * _hoverT * _hoverT * _hoverT\n : 1.0 - pow(-2.0 * _hoverT + 2.0, 3.0) / 2.0;\n vHoverDim = mix(1.0 - _hoverTarget, _hoverTarget, _hoverEased);\n vColor = nodeColor;\n vOpacity = nodeOpacity;\n vIcon = nodeIcon;\n vIconUV = nodeIconUV;\n vNodeCollect = aNodeCollect;\n vImageUV = nodeImageUV;\n vRipple = nodeEffects.x;\n vBreathe = nodeEffects.y;\n vHalo = nodeEffects.z;\n\n vec3 sampledPos = samplePosition(nodeIndex);\n\n vec3 finalPosition = sampledPos;\n if (animate > 0.5) {\n finalPosition = mix(sampledPos, toPosition, t);\n }\n\n vec4 mvCenter = modelViewMatrix * vec4(finalPosition, 1.0);\n\n // Per-node perspective sizing (matches legacy nodeVertex.glsl).\n // `pixelSize` is the on-screen diameter of the node in physical pixels.\n float scaledSize = nodeSize * nodeSizeScale;\n if (vBreathe > 0.0) {\n scaledSize *= 1.0 + vBreathe * 0.15 * sin(time * 3.0);\n }\n float viewDepth = max(-mvCenter.z, 0.001);\n float baseSize;\n if (mapMode > 0.5) {\n // Map mode: damped scaling so nodes stay roughly constant screen size.\n // refDepth=10 is the anchor depth where sizes match the designed CSS px.\n // damping=0 \u2192 constant size, damping=1 \u2192 full perspective (same as normal).\n float refDepth = 10.0;\n float refSize = scaledSize * (50.0 / refDepth);\n // `growth` is the inverse-zoom multiplier vs the refDepth baseline.\n // Soft-cap curve to prevent nodes from covering the map at deep zoom while\n // keeping the "still growing" feel users expect when they zoom in:\n // - Below softKnee: pass through (full damped growth).\n // - Above softKnee: rational asymptote A\xB7t/(A+t) toward mapMaxGrowth.\n // The curve is C\xB9-continuous at the knee (matches derivative, no kink).\n // Curve MUST stay in sync with picking.vert.glsl, badge.vert.glsl, and\n // tag.vert.glsl so hitbox and decorations freeze in lockstep with the bubble.\n float raw = pow(refDepth / viewDepth, mapDamping);\n float growth;\n if (mapMaxGrowth < 0.0) {\n // Sentinel: caller requested Infinity \u2192 bypass soft-knee, raw growth\n growth = raw;\n } else {\n // softKnee derived from mapMaxGrowth (= maxGrowth \xD7 0.5, preserves 4:2 ratio)\n float softKnee = mapMaxGrowth * 0.5;\n float overflow = max(raw - softKnee, 0.0);\n float A = mapMaxGrowth - softKnee;\n growth = min(raw, softKnee) + (A * overflow) / (A + overflow);\n }\n baseSize = refSize * growth;\n } else {\n baseSize = scaledSize * (50.0 / viewDepth);\n }\n float sizeMultiplier = (vSelected > 0.5 || vHighlighted > 0.5) ? 1.5 : 1.0;\n float rippleExpand = vRipple > 0.0 ? 3.0 : 1.0;\n float expand = max(rippleExpand, nodeEffects.z > 0.0 ? HALO_EXPAND : 1.0);\n // pixelSize is the on-screen diameter in CSS pixels. Do NOT multiply by pixelRatio:\n // resolution is in CSS px (container.clientWidth/Height), and gl_PointSize in the\n // legacy Point pipeline included pixelRatio only because gl_PointSize is in physical\n // pixels \u2014 the browser then halved it for display, cancelling out. Quads work in CSS\n // px directly, so multiplying by pixelRatio would double-scale on Retina.\n float pixelSize = baseSize * sizeMultiplier * expand;\n\n // Clamp pixelSize to a sane range:\n // - Lower bound 1.5 px: WebGL does not anti-alias triangle edges below ~1 px\n // without MSAA, so very small quads alias badly. Floor restores the visual\n // stability point primitives provided implicitly.\n // - Upper bound 4096 px: nodes very near the camera otherwise produce\n // screen-spanning quads with extreme fragment cost. Replaces the implicit\n // hardware \u2264255 px cap that gl_PointSize used to enforce.\n pixelSize = clamp(pixelSize, 1.5, 4096.0);\n\n // Project the center to clip space, then offset by corner * pixelSize / viewport.\n // Multiplying by gl_Position.w preserves the offset after perspective divide.\n vec4 clipCenter = projectionMatrix * mvCenter;\n vec2 offsetClip = corner * pixelSize / resolution * 2.0 * clipCenter.w;\n gl_Position = clipCenter + vec4(offsetClip, 0.0, 0.0);\n\n // Fragment-local UV: [0,1]\xB2 with (0.5, 0.5) at the node center, matching gl_PointCoord.\n // gl_PointCoord is Y-DOWN (origin at top-left), but clip-space Y is Y-UP (top corners have\n // corner.y = +0.5). We invert Y here so vUv.y = 0 at the visual top of the node \u2014 keeps\n // icon/image atlas UVs (which are Y-down via Three.js flipY=true) right-side up.\n vUv = vec2(corner.x + 0.5, 0.5 - corner.y);\n // Globe mode: vertex-level back-face culling.\n // depthTest is disabled in globe mode to prevent billboard clipping against\n // the occlusion sphere. Instead, we hide back-facing nodes here.\n if (sphereRadius > 0.001) {\n vec3 wN = normalize(mat3(modelMatrix) * normalize(finalPosition));\n vec3 wP = (modelMatrix * vec4(finalPosition, 1.0)).xyz;\n if (dot(wN, normalize(cameraPosition - wP)) < 0.0) {\n // Push the quad off-screen (NDC outside [-1,1]) so all 4 corners are clipped.\n gl_Position = vec4(2.0, 2.0, 2.0, 1.0);\n }\n }\n}\n';
14504
14510
 
14505
14511
  // src/shaders/node.frag.glsl
14506
- var node_frag_default = "precision highp float;\n\nconst float HALO_EXPAND = 2.2; // MUST match node.vert.glsl\nconst float HALO_EDGE = 1.7; // outer radius (in node-radius units) where halo fades to 0\nconst float HALO_GAIN = 0.9; // (unused after translucent-disk rewrite \u2014 kept to minimize churn)\nconst float HALO_ALPHA = 0.35; // halo alpha ceiling\n\n// Uniforms\nuniform float hideRing;\nuniform float useCircle;\nuniform float lightMode;\nuniform sampler2D iconSdfAtlas;\nuniform float hasIconSdfAtlas;\nuniform sampler2D imageAtlas;\nuniform float hasImageAtlas;\nuniform float iconDisplayMode;\n\n// Pin icon (push-pin texture overlay). When vPinned > 0.5 and hidePin == 0,\n// the pinTexture is sampled in the upper-right quadrant of the node sprite\n// (matches legacy nodeImageFragment.glsl renderPin pattern).\nuniform sampler2D pinTexture;\nuniform float hidePin;\n\n// Time uniform for shader-driven effects\nuniform float time;\n// Ripple effect configuration\nuniform vec3 uRippleColor;\nuniform float uRippleSpeed;\nuniform float uRippleRings;\n\n// Hover dim: when a node is hovered, non-neighbor nodes fade to u_hoverDimOpacity.\n// u_hoverProgress animates 0\u21921 over the hover-in duration (driven by HoverApi).\nuniform float u_hoverProgress;\nuniform float u_hoverDimOpacity;\n\n// Varyings\nvarying vec3 vColor;\nvarying float vOpacity;\nvarying float vIcon;\nvarying vec4 vIconUV;\nvarying vec4 vImageUV;\nvarying float vSelected;\nvarying float vHighlighted;\nvarying float vPinned;\nvarying float vNodeCollect;\nvarying float vHidden;\nvarying float vHoverDim;\nvarying float vRipple;\nvarying float vBreathe;\nvarying float vHalo;\nvarying vec2 vUv;\n\nvoid main() {\n // Discard hidden nodes\n if (vHidden > 0.5) discard;\n\n // When ripple is active, the billboard quad is 3x larger (rippleExpand in node.vert.glsl).\n // Remap coordinates so the node draws at its normal size in the center. Ripples use raw coords.\n float rippleExpand = vRipple > 0.0 ? 3.0 : 1.0;\n float expand = max(rippleExpand, vHalo > 0.0 ? HALO_EXPAND : 1.0);\n vec2 nodeCoord = (vUv - 0.5) * expand + 0.5;\n vec2 center = nodeCoord - vec2(0.5);\n float dist = length(center);\n\n // Discard pixels outside the expanded area that are also outside the node\n // (when ripple is off, this has no effect since rippleExpand = 1)\n if (vRipple > 0.0 && dist > 0.5) {\n // Outside node circle \u2014 only keep if a ripple ring will draw here\n float rawDist = length(vUv - vec2(0.5)) * 2.0;\n if (rawDist > 1.0) discard;\n }\n\n // Circle mode\n // Circle clip: discard pixels outside node radius.\n // When ripple is active, keep outer pixels alive for the ripple rings.\n if (useCircle > 0.5 && dist > 0.5 && vRipple <= 0.0 && vHalo <= 0.0) discard;\n // For ripple nodes: pixels outside the node circle start fully transparent\n // (the ripple code below will add ring color to them).\n bool outsideNodeCircle = (dist > 0.5);\n\n // Check if node has an SDF icon (and no image override)\n bool hasIcon = hasIconSdfAtlas > 0.5 && vIconUV.x >= 0.0 && !(hasImageAtlas > 0.5 && vImageUV.x >= 0.0);\n bool transparentBg = hasIcon && iconDisplayMode > 0.5;\n\n // Base color: transparent for ring/plain icon modes, solid for filled mode\n if (transparentBg) {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n } else {\n gl_FragColor = vec4(vColor, vOpacity);\n }\n\n // Soft edge for circle (skip for transparent bg modes)\n if (useCircle > 0.5 && !transparentBg) {\n float edgeOuter = 0.5;\n if (vSelected > 0.5) edgeOuter = 0.38;\n else if (vHighlighted > 0.5) edgeOuter = 0.40;\n float alpha = 1.0 - smoothstep(edgeOuter - 0.02, edgeOuter, dist);\n gl_FragColor.a *= alpha;\n }\n\n // Image overlay: photo inside node circle\n if (hasImageAtlas > 0.5 && vImageUV.x >= 0.0) {\n float imgSize = 0.88;\n vec2 imgLocal = (nodeCoord - 0.5) / imgSize + 0.5;\n float imgInBounds = step(0.0, imgLocal.x) * step(imgLocal.x, 1.0)\n * step(0.0, imgLocal.y) * step(imgLocal.y, 1.0);\n if (imgInBounds > 0.5) {\n vec2 imgUV = mix(vImageUV.xy, vImageUV.zw, clamp(imgLocal, 0.0, 1.0));\n vec4 imgColor = texture2D(imageAtlas, imgUV);\n float imgAlpha = imgColor.a * (1.0 - smoothstep(0.42, 0.48, dist));\n gl_FragColor.rgb = mix(gl_FragColor.rgb, imgColor.rgb, imgAlpha);\n gl_FragColor.a = max(gl_FragColor.a, imgAlpha * vOpacity);\n }\n }\n\n // Icon SDF overlay \u2014 mode-aware rendering\n // Skip icon when image is present \u2014 image takes priority.\n if (hasIcon) {\n // Plain mode uses larger icon since there's no ring\n float iconSize = (iconDisplayMode > 1.5) ? 0.80 : 0.70;\n vec2 local = (nodeCoord - 0.5) / iconSize + 0.5;\n float inBounds = step(0.0, local.x) * step(local.x, 1.0)\n * step(0.0, local.y) * step(local.y, 1.0);\n if (inBounds > 0.5) {\n vec2 iconUV = mix(vIconUV.xy, vIconUV.zw, clamp(local, 0.0, 1.0));\n float sdf = texture2D(iconSdfAtlas, iconUV).r;\n float fw = fwidth(sdf);\n // SDF_EDGE = 1.0 - TinySDF cutoff (0.25) = 0.75. Using 0.5 dilates the\n // glyph by ~radius*0.25 px, which fills small interior holes (e.g.\n // bomb sparkle gap) and bloats fine details. Tag/badge/text shaders\n // already use 0.75 \u2014 node icon was the outlier.\n const float SDF_EDGE = 0.75;\n float iconAlpha = smoothstep(SDF_EDGE - fw, SDF_EDGE + fw, sdf);\n // Soft circular clip: fade out near circle edge\n float clipEdge = transparentBg ? 0.40 : 0.42;\n iconAlpha *= 1.0 - smoothstep(clipEdge, clipEdge + 0.06, dist);\n // Icon color: dark gray for filled, node color for ring/plain\n vec3 iconCol;\n if (iconDisplayMode < 0.5) {\n iconCol = vColor * 0.3;\n } else {\n iconCol = vColor;\n }\n gl_FragColor.rgb = mix(gl_FragColor.rgb, iconCol, iconAlpha);\n if (transparentBg) gl_FragColor.a = max(gl_FragColor.a, iconAlpha * vOpacity);\n }\n }\n\n // --- Border ring / Selection ring ---\n if (useCircle > 0.5) {\n // Ring-only mode: always draw colored ring first (underneath sel/hl).\n // Pin state has no ring treatment \u2014 the push-pin texture overlay\n // below is the sole pin indicator (matches legacy GraphXR).\n if (transparentBg && iconDisplayMode < 1.5) {\n float ringOuter = 0.50;\n float ringInner = 0.43;\n float ring = smoothstep(ringInner - 0.02, ringInner, dist)\n * (1.0 - smoothstep(ringOuter - 0.02, ringOuter, dist));\n float boost = lightMode > 0.5 ? 0.85 : 1.2;\n vec3 ringCol = vColor * boost;\n gl_FragColor.rgb = mix(gl_FragColor.rgb, ringCol, ring);\n gl_FragColor.a = max(gl_FragColor.a, ring * vOpacity);\n }\n // Selection/highlight rings (all modes)\n if (vSelected > 0.5) {\n vec3 selColor = lightMode > 0.5 ? vec3(0.40, 0.42, 0.48) : vec3(1.0, 1.0, 1.0);\n float selRing = smoothstep(0.41, 0.42, dist) * (1.0 - smoothstep(0.48, 0.50, dist));\n gl_FragColor.rgb = mix(gl_FragColor.rgb, selColor, selRing);\n gl_FragColor.a = max(gl_FragColor.a, selRing * vOpacity);\n } else if (vHighlighted > 0.5) {\n vec3 hlColor = lightMode > 0.5 ? vec3(0.55, 0.57, 0.62) : vec3(0.85, 0.85, 0.85);\n float hlRing = smoothstep(0.42, 0.43, dist) * (1.0 - smoothstep(0.48, 0.50, dist));\n gl_FragColor.rgb = mix(gl_FragColor.rgb, hlColor, hlRing * 0.9);\n gl_FragColor.a = max(gl_FragColor.a, hlRing * 0.9 * vOpacity);\n } else if (!transparentBg && hideRing < 0.5) {\n // Normal filled mode: border ring on node edge.\n // Pin state has no ring treatment \u2014 the push-pin texture overlay\n // below is the sole pin indicator (matches legacy GraphXR).\n float ring = smoothstep(0.42, 0.44, dist) * (1.0 - smoothstep(0.48, 0.50, dist));\n float boost = lightMode > 0.5 ? 0.76 : 1.3;\n vec3 ringColor = vColor * boost;\n gl_FragColor.rgb = mix(gl_FragColor.rgb, ringColor, ring * 0.5);\n }\n }\n\n // Collect indicator: legacy-style overlay \u2014 4 corner balls + center circle, NO digits.\n // Pulled inward vs. legacy so a visible gap separates the inner symbol from the outer ring;\n // the count display is delegated to BadgeCloud (top-right anchor by convention).\n //\n // Layout (in node-local coords, node center at 0.5, node radius at 0.5):\n // 4 balls \u2014 centers at (0.32, 0.32) / (0.32, 0.68) / (0.68, 0.32) / (0.68, 0.68), r=0.13\n // \u2192 ball outer edge reaches dist \u2248 0.385 from node center\n // center \u2014 circle at (0.5, 0.5), r=0.10 with thin darker border (mirrors legacy badge,\n // digits removed per Phase-5 redesign)\n // gap \u2014 interior gate at dist < 0.40 leaves dist \u2208 [0.40, 0.50] as deadband + ring,\n // giving ~0.035 of clear space between symbol and outer ring (\u22487% of diameter)\n // ring \u2014 drawn by the base shader's selection/highlight/normal ring code below\n if (useCircle > 0.5 && vNodeCollect > 0.5) {\n float ballR = 0.13;\n vec2 c0 = vec2(0.32, 0.32);\n vec2 c1 = vec2(0.32, 0.68);\n vec2 c2 = vec2(0.68, 0.32);\n vec2 c3 = vec2(0.68, 0.68);\n float d0 = length(nodeCoord - c0);\n float d1 = length(nodeCoord - c1);\n float d2 = length(nodeCoord - c2);\n float d3 = length(nodeCoord - c3);\n float minBallDist = min(min(d0, d1), min(d2, d3));\n\n // Center circle (no digits)\n float centerR = 0.10;\n float centerDist = length(nodeCoord - vec2(0.5));\n\n // Interior zone \u2014 anything outside is left to base shader (preserves outer ring zone).\n bool inInterior = dist < 0.40;\n if (inInterior) {\n if (minBallDist < ballR) {\n // Inside a corner ball \u2014 node color with soft AA edge.\n float ballAlpha = 1.0 - smoothstep(ballR - 0.015, ballR, minBallDist);\n gl_FragColor = vec4(vColor, vOpacity * ballAlpha);\n } else if (centerDist < centerR) {\n // Center circle \u2014 node color with thin darker border (legacy badge look, no digit).\n float centerAlpha = 1.0 - smoothstep(centerR - 0.015, centerR, centerDist);\n float borderW = 0.015;\n float innerMask = 1.0 - smoothstep(centerR - borderW - 0.008, centerR - borderW, centerDist);\n vec3 borderColor = vColor * (lightMode > 0.5 ? 0.6 : 1.4);\n vec3 fillColor = mix(borderColor, vColor, innerMask);\n gl_FragColor = vec4(fillColor, vOpacity * centerAlpha);\n } else {\n // Between elements \u2014 clear so background shows through (creates the visible gap).\n gl_FragColor.a = 0.0;\n }\n }\n }\n\n // Ripple effect: concentric rings expanding OUTSIDE the node.\n // The billboard quad was expanded 3x (rippleExpand) for ripple nodes \u2014 the node occupies\n // the inner 1/3. 'dist' uses nodeCoord (remapped to node space). Raw vUv covers the full area.\n if (vRipple > 0.0) {\n // Use raw vUv for ripple (covers the full 3x expanded area)\n float rawDist = length(vUv - vec2(0.5)) * 2.0;\n float nodeEdge = 1.0 / 3.0;\n float speed = uRippleSpeed > 0.0 ? uRippleSpeed : 0.5;\n float rings = uRippleRings > 0.0 ? uRippleRings : 3.0;\n float rippleAlphaSum = 0.0;\n vec3 rColor = uRippleColor.r + uRippleColor.g + uRippleColor.b > 0.01 ? uRippleColor : vec3(0.0, 0.9, 1.0);\n for (float i = 0.0; i < 4.0; i++) {\n if (i >= rings) break;\n float phase = fract(time * speed + i / rings);\n // Ring starts at node edge and expands to the full area\n float ringRadius = nodeEdge + phase * (1.0 - nodeEdge);\n float ringWidth = 0.03;\n float ringDist = abs(rawDist - ringRadius) / ringWidth;\n if (ringDist < 1.0 && rawDist > nodeEdge * 0.9) {\n float alpha = (1.0 - phase) * (1.0 - ringDist * ringDist) * vRipple;\n rippleAlphaSum += alpha;\n }\n }\n if (rippleAlphaSum > 0.0) {\n if (outsideNodeCircle) {\n // Outside node: paint the ring on transparent background\n gl_FragColor = vec4(rColor * rippleAlphaSum, rippleAlphaSum * 0.7);\n } else {\n // Inside node: additive blend over existing node color\n gl_FragColor.rgb += rColor * rippleAlphaSum * 0.3;\n }\n } else if (outsideNodeCircle && vHalo <= 0.0) {\n // Outside node and no ripple ring here \u2014 fully transparent\n discard;\n }\n }\n\n // \u2500\u2500 Pin icon overlay (push-pin texture) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n // Render the pin icon last so it sits above ring + icon, like the legacy\n // GraphXR nodeImageFragment.glsl renderPin() pattern. Sized so the pin\n // appears in the upper-right quadrant of the node sprite. The pulsing\n // blue ring above is the secondary \"anchored\" indicator; this is the\n // primary one (matches user expectation from legacy).\n if (vPinned > 0.5 && hidePin < 0.5) {\n float pinScale = (vSelected > 0.5 || vHighlighted > 0.5) ? 6.0 : 4.0;\n float pinAngle = 0.7853981633974483; // PI / 4\n float c = cos(pinAngle);\n float s = sin(pinAngle);\n // Flip y so coords match the pin PNG orientation (matches legacy\n // `normalCoord = vec2(gl_PointCoord.s, 1.0 - gl_PointCoord.t)`).\n vec2 normalCoord = vec2(vUv.x, 1.0 - vUv.y);\n // Rotate + scale around (0.5, 0.5), no extra translation.\n vec2 centered = normalCoord - vec2(0.5);\n vec2 pinUV = vec2(\n pinScale * (c * centered.x - s * centered.y) + 0.5,\n pinScale * (s * centered.x + c * centered.y) + 0.5\n );\n if (pinUV.x >= 0.0 && pinUV.x <= 1.0 && pinUV.y >= 0.0 && pinUV.y <= 1.0) {\n vec4 pinSample = texture2D(pinTexture, pinUV);\n // Selected/highlighted nodes get a slightly stronger pin overlay so\n // it stays visible above selection rings.\n float pinStrength = (vSelected > 0.5 || vHighlighted > 0.5) ? 0.95 : 0.85;\n pinSample.a *= pinStrength;\n gl_FragColor.rgb = mix(gl_FragColor.rgb, pinSample.rgb, pinSample.a);\n gl_FragColor.a = max(gl_FragColor.a, pinSample.a * vOpacity);\n }\n }\n\n // Node halo: a soft SEMI-TRANSPARENT disk in the node's OWN color (no\n // brightening \u2014 a brightened/additive halo reads as a glow/bloom). Pure\n // translucency via alpha under NormalBlending.\n if (vHalo > 0.0 && outsideNodeCircle) {\n float rr = length(nodeCoord - vec2(0.5)) * 2.0; // 1.0 at circle edge, grows outward\n // Flat disk: uniform alpha from the node edge out to (HALO_EDGE - edge band),\n // then a thin soft cutoff \u2014 reads as a pure-color translucent disk, not a glow.\n float falloff = 1.0 - smoothstep(HALO_EDGE - 0.15, HALO_EDGE, rr);\n gl_FragColor.rgb = vColor; // node's own color, NOT brightened\n gl_FragColor.a = max(gl_FragColor.a, falloff * vHalo * HALO_ALPHA);\n }\n\n // Hover dim: dim non-neighbor nodes when a hover is active.\n float hoverDimMul = mix(1.0, u_hoverDimOpacity, vHoverDim * u_hoverProgress);\n gl_FragColor.a *= hoverDimMul;\n\n // Alpha test\n if (gl_FragColor.a < 0.01) discard;\n}\n";
14512
+ var node_frag_default = "precision highp float;\n\nconst float HALO_EXPAND = 2.2; // MUST match node.vert.glsl\nconst float HALO_EDGE = 1.7; // outer radius (in node-radius units) where halo fades to 0\nconst float HALO_GAIN = 0.9; // (unused after translucent-disk rewrite \u2014 kept to minimize churn)\nconst float HALO_ALPHA = 0.35; // halo alpha ceiling\n\n// Uniforms\nuniform float hideRing;\nuniform float useCircle;\nuniform float lightMode;\nuniform sampler2D iconSdfAtlas;\nuniform float hasIconSdfAtlas;\nuniform sampler2D imageAtlas;\nuniform float hasImageAtlas;\nuniform float iconDisplayMode;\n\n// Pin icon (push-pin texture overlay). When vPinned > 0.5 and hidePin == 0,\n// the pinTexture is sampled in the upper-right quadrant of the node sprite\n// (matches legacy nodeImageFragment.glsl renderPin pattern).\nuniform sampler2D pinTexture;\nuniform float hidePin;\n\n// Time uniform for shader-driven effects\nuniform float time;\n// Ripple effect configuration\nuniform vec3 uRippleColor;\nuniform float uRippleSpeed;\nuniform float uRippleRings;\n\n// Hover dim: when a node is hovered, non-neighbor nodes fade to u_hoverDimOpacity.\n// u_hoverProgress animates 0\u21921 over the hover-in duration (driven by HoverApi).\nuniform float u_hoverProgress;\nuniform float u_hoverDimOpacity;\n\n// Varyings\nvarying vec3 vColor;\nvarying float vOpacity;\nvarying float vIcon;\nvarying vec4 vIconUV;\nvarying vec4 vImageUV;\nvarying float vSelected;\nvarying float vHighlighted;\nvarying float vPinned;\nvarying float vNodeCollect;\nvarying float vHidden;\nvarying float vHoverDim;\nvarying float vRipple;\nvarying float vBreathe;\nvarying float vHalo;\nvarying vec2 vUv;\n\nvoid main() {\n // Discard hidden nodes\n if (vHidden > 0.5) discard;\n\n // When ripple is active, the billboard quad is 3x larger (rippleExpand in node.vert.glsl).\n // Remap coordinates so the node draws at its normal size in the center. Ripples use raw coords.\n float rippleExpand = vRipple > 0.0 ? 3.0 : 1.0;\n float expand = max(rippleExpand, vHalo > 0.0 ? HALO_EXPAND : 1.0);\n vec2 nodeCoord = (vUv - 0.5) * expand + 0.5;\n vec2 center = nodeCoord - vec2(0.5);\n float dist = length(center);\n\n // Discard pixels outside the expanded area that are also outside the node\n // (when ripple is off, this has no effect since rippleExpand = 1)\n if (vRipple > 0.0 && dist > 0.5) {\n // Outside node circle \u2014 only keep if a ripple ring will draw here\n float rawDist = length(vUv - vec2(0.5)) * 2.0;\n if (rawDist > 1.0) discard;\n }\n\n // Circle mode\n // Circle clip: discard pixels outside node radius.\n // When ripple is active, keep outer pixels alive for the ripple rings.\n if (useCircle > 0.5 && dist > 0.5 && vRipple <= 0.0 && vHalo <= 0.0) discard;\n // For ripple nodes: pixels outside the node circle start fully transparent\n // (the ripple code below will add ring color to them).\n bool outsideNodeCircle = (dist > 0.5);\n\n // Check if node has an SDF icon (and no image override)\n bool hasIcon = hasIconSdfAtlas > 0.5 && vIconUV.x >= 0.0 && !(hasImageAtlas > 0.5 && vImageUV.x >= 0.0);\n bool transparentBg = hasIcon && iconDisplayMode > 0.5;\n\n // Base color: transparent for ring/plain icon modes, solid for filled mode\n if (transparentBg) {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n } else {\n gl_FragColor = vec4(vColor, vOpacity);\n }\n\n // Soft edge for circle (skip for transparent bg modes)\n if (useCircle > 0.5 && !transparentBg) {\n float edgeOuter = 0.5;\n if (vSelected > 0.5) edgeOuter = 0.38;\n else if (vHighlighted > 0.5) edgeOuter = 0.40;\n float alpha = 1.0 - smoothstep(edgeOuter - 0.02, edgeOuter, dist);\n gl_FragColor.a *= alpha;\n }\n\n // Image overlay: photo inside node circle\n if (hasImageAtlas > 0.5 && vImageUV.x >= 0.0) {\n float imgSize = 0.88;\n vec2 imgLocal = (nodeCoord - 0.5) / imgSize + 0.5;\n float imgInBounds = step(0.0, imgLocal.x) * step(imgLocal.x, 1.0)\n * step(0.0, imgLocal.y) * step(imgLocal.y, 1.0);\n if (imgInBounds > 0.5) {\n vec2 imgUV = mix(vImageUV.xy, vImageUV.zw, clamp(imgLocal, 0.0, 1.0));\n vec4 imgColor = texture2D(imageAtlas, imgUV);\n float imgAlpha = imgColor.a * (1.0 - smoothstep(0.42, 0.48, dist));\n gl_FragColor.rgb = mix(gl_FragColor.rgb, imgColor.rgb, imgAlpha);\n gl_FragColor.a = max(gl_FragColor.a, imgAlpha * vOpacity);\n }\n }\n\n // Icon SDF overlay \u2014 mode-aware rendering\n // Skip icon when image is present \u2014 image takes priority.\n if (hasIcon) {\n // Plain mode uses larger icon since there's no ring\n float iconSize = (iconDisplayMode > 1.5) ? 0.80 : 0.70;\n vec2 local = (nodeCoord - 0.5) / iconSize + 0.5;\n float inBounds = step(0.0, local.x) * step(local.x, 1.0)\n * step(0.0, local.y) * step(local.y, 1.0);\n if (inBounds > 0.5) {\n vec2 iconUV = mix(vIconUV.xy, vIconUV.zw, clamp(local, 0.0, 1.0));\n float sdf = texture2D(iconSdfAtlas, iconUV).r;\n float fw = fwidth(sdf);\n // SDF_EDGE = 1.0 - TinySDF cutoff (0.25) = 0.75. Using 0.5 dilates the\n // glyph by ~radius*0.25 px, which fills small interior holes (e.g.\n // bomb sparkle gap) and bloats fine details. Tag/badge/text shaders\n // already use 0.75 \u2014 node icon was the outlier.\n const float SDF_EDGE = 0.75;\n float iconAlpha = smoothstep(SDF_EDGE - fw, SDF_EDGE + fw, sdf);\n // Soft circular clip: fade out near circle edge\n float clipEdge = transparentBg ? 0.40 : 0.42;\n iconAlpha *= 1.0 - smoothstep(clipEdge, clipEdge + 0.06, dist);\n // Icon color: dark gray for filled, node color for ring/plain\n vec3 iconCol;\n if (iconDisplayMode < 0.5) {\n iconCol = vColor * 0.3;\n } else {\n iconCol = vColor;\n }\n gl_FragColor.rgb = mix(gl_FragColor.rgb, iconCol, iconAlpha);\n if (transparentBg) gl_FragColor.a = max(gl_FragColor.a, iconAlpha * vOpacity);\n }\n }\n\n // --- Border ring / Selection ring ---\n if (useCircle > 0.5) {\n // Ring-only mode: always draw colored ring first (underneath sel/hl).\n // Pin state has no ring treatment \u2014 the push-pin texture overlay\n // below is the sole pin indicator (matches legacy GraphXR).\n if (transparentBg && iconDisplayMode < 1.5) {\n float ringOuter = 0.50;\n float ringInner = 0.43;\n float ring = smoothstep(ringInner - 0.02, ringInner, dist)\n * (1.0 - smoothstep(ringOuter - 0.02, ringOuter, dist));\n float boost = lightMode > 0.5 ? 0.85 : 1.2;\n vec3 ringCol = vColor * boost;\n gl_FragColor.rgb = mix(gl_FragColor.rgb, ringCol, ring);\n gl_FragColor.a = max(gl_FragColor.a, ring * vOpacity);\n }\n // Selection/highlight rings (all modes)\n if (vSelected > 0.5) {\n vec3 selColor = lightMode > 0.5 ? vec3(0.40, 0.42, 0.48) : vec3(1.0, 1.0, 1.0);\n float selRing = smoothstep(0.41, 0.42, dist) * (1.0 - smoothstep(0.48, 0.50, dist));\n gl_FragColor.rgb = mix(gl_FragColor.rgb, selColor, selRing);\n gl_FragColor.a = max(gl_FragColor.a, selRing * vOpacity);\n } else if (vHighlighted > 0.5) {\n vec3 hlColor = lightMode > 0.5 ? vec3(0.55, 0.57, 0.62) : vec3(0.85, 0.85, 0.85);\n float hlRing = smoothstep(0.42, 0.43, dist) * (1.0 - smoothstep(0.48, 0.50, dist));\n gl_FragColor.rgb = mix(gl_FragColor.rgb, hlColor, hlRing * 0.9);\n gl_FragColor.a = max(gl_FragColor.a, hlRing * 0.9 * vOpacity);\n } else if (!transparentBg && hideRing < 0.5) {\n // Normal filled mode: border ring on node edge.\n // Pin state has no ring treatment \u2014 the push-pin texture overlay\n // below is the sole pin indicator (matches legacy GraphXR).\n float ring = smoothstep(0.42, 0.44, dist) * (1.0 - smoothstep(0.48, 0.50, dist));\n float boost = lightMode > 0.5 ? 0.76 : 1.3;\n vec3 ringColor = vColor * boost;\n gl_FragColor.rgb = mix(gl_FragColor.rgb, ringColor, ring * 0.5);\n }\n }\n\n // Collect indicator: legacy-style overlay \u2014 4 corner balls + center circle, NO digits.\n // Pulled inward vs. legacy so a visible gap separates the inner symbol from the outer ring;\n // the count display is delegated to BadgeCloud (top-right anchor by convention).\n //\n // Layout (in node-local coords, node center at 0.5, node radius at 0.5):\n // 4 balls \u2014 centers at (0.32, 0.32) / (0.32, 0.68) / (0.68, 0.32) / (0.68, 0.68), r=0.13\n // \u2192 ball outer edge reaches dist \u2248 0.385 from node center\n // center \u2014 circle at (0.5, 0.5), r=0.10 with thin darker border (mirrors legacy badge,\n // digits removed per Phase-5 redesign)\n // gap \u2014 interior gate at dist < 0.40 leaves dist \u2208 [0.40, 0.50] as deadband + ring,\n // giving ~0.035 of clear space between symbol and outer ring (\u22487% of diameter)\n // ring \u2014 drawn by the base shader's selection/highlight/normal ring code below\n if (useCircle > 0.5 && vNodeCollect > 0.5) {\n float ballR = 0.13;\n vec2 c0 = vec2(0.32, 0.32);\n vec2 c1 = vec2(0.32, 0.68);\n vec2 c2 = vec2(0.68, 0.32);\n vec2 c3 = vec2(0.68, 0.68);\n float d0 = length(nodeCoord - c0);\n float d1 = length(nodeCoord - c1);\n float d2 = length(nodeCoord - c2);\n float d3 = length(nodeCoord - c3);\n float minBallDist = min(min(d0, d1), min(d2, d3));\n\n // Center circle (no digits)\n float centerR = 0.10;\n float centerDist = length(nodeCoord - vec2(0.5));\n\n // Interior zone \u2014 anything outside is left to base shader (preserves outer ring zone).\n bool inInterior = dist < 0.40;\n if (inInterior) {\n if (minBallDist < ballR) {\n // Inside a corner ball \u2014 node color with soft AA edge.\n float ballAlpha = 1.0 - smoothstep(ballR - 0.015, ballR, minBallDist);\n gl_FragColor = vec4(vColor, vOpacity * ballAlpha);\n } else if (centerDist < centerR) {\n // Center circle \u2014 node color with thin darker border (legacy badge look, no digit).\n float centerAlpha = 1.0 - smoothstep(centerR - 0.015, centerR, centerDist);\n float borderW = 0.015;\n float innerMask = 1.0 - smoothstep(centerR - borderW - 0.008, centerR - borderW, centerDist);\n vec3 borderColor = vColor * (lightMode > 0.5 ? 0.6 : 1.4);\n vec3 fillColor = mix(borderColor, vColor, innerMask);\n gl_FragColor = vec4(fillColor, vOpacity * centerAlpha);\n } else {\n // Between elements \u2014 clear so background shows through (creates the visible gap).\n gl_FragColor.a = 0.0;\n }\n }\n }\n\n // Ripple effect: concentric rings expanding OUTSIDE the node.\n // The billboard quad was expanded 3x (rippleExpand) for ripple nodes \u2014 the node occupies\n // the inner 1/3. 'dist' uses nodeCoord (remapped to node space). Raw vUv covers the full area.\n if (vRipple > 0.0) {\n // Use raw vUv for ripple (covers the full 3x expanded area)\n float rawDist = length(vUv - vec2(0.5)) * 2.0;\n float nodeEdge = 1.0 / 3.0;\n float speed = uRippleSpeed > 0.0 ? uRippleSpeed : 0.5;\n float rings = uRippleRings > 0.0 ? uRippleRings : 3.0;\n float rippleAlphaSum = 0.0;\n vec3 rColor = uRippleColor.r + uRippleColor.g + uRippleColor.b > 0.01 ? uRippleColor : vec3(0.0, 0.9, 1.0);\n for (float i = 0.0; i < 4.0; i++) {\n if (i >= rings) break;\n float phase = fract(time * speed + i / rings);\n // Ring starts at node edge and expands to the full area\n float ringRadius = nodeEdge + phase * (1.0 - nodeEdge);\n float ringWidth = 0.03;\n float ringDist = abs(rawDist - ringRadius) / ringWidth;\n if (ringDist < 1.0 && rawDist > nodeEdge * 0.9) {\n float alpha = (1.0 - phase) * (1.0 - ringDist * ringDist) * vRipple;\n rippleAlphaSum += alpha;\n }\n }\n if (rippleAlphaSum > 0.0) {\n if (outsideNodeCircle) {\n // Outside node: paint the ring on transparent background\n gl_FragColor = vec4(rColor * rippleAlphaSum, rippleAlphaSum * 0.7);\n } else {\n // Inside node: additive blend over existing node color\n gl_FragColor.rgb += rColor * rippleAlphaSum * 0.3;\n }\n } else if (outsideNodeCircle && vHalo <= 0.0) {\n // Outside node and no ripple ring here \u2014 fully transparent\n discard;\n }\n }\n\n // \u2500\u2500 Pin icon overlay (push-pin texture) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n // Render the pin icon last so it sits above ring + icon, like the legacy\n // GraphXR nodeImageFragment.glsl renderPin() pattern. Sized so the pin\n // appears in the upper-right quadrant of the node sprite. The pulsing\n // blue ring above is the secondary \"anchored\" indicator; this is the\n // primary one (matches user expectation from legacy).\n if (vPinned > 0.5 && hidePin < 0.5) {\n float pinScale = (vSelected > 0.5 || vHighlighted > 0.5) ? 6.0 : 4.0;\n float pinAngle = 0.7853981633974483; // PI / 4\n float c = cos(pinAngle);\n float s = sin(pinAngle);\n // Flip y so coords match the pin PNG orientation (matches legacy\n // `normalCoord = vec2(gl_PointCoord.s, 1.0 - gl_PointCoord.t)`).\n vec2 normalCoord = vec2(vUv.x, 1.0 - vUv.y);\n // Rotate + scale around (0.5, 0.5), no extra translation.\n vec2 centered = normalCoord - vec2(0.5);\n vec2 pinUV = vec2(\n pinScale * (c * centered.x - s * centered.y) + 0.5,\n pinScale * (s * centered.x + c * centered.y) + 0.5\n );\n if (pinUV.x >= 0.0 && pinUV.x <= 1.0 && pinUV.y >= 0.0 && pinUV.y <= 1.0) {\n vec4 pinSample = texture2D(pinTexture, pinUV);\n // Selected/highlighted nodes get a slightly stronger pin overlay so\n // it stays visible above selection rings.\n float pinStrength = (vSelected > 0.5 || vHighlighted > 0.5) ? 0.95 : 0.85;\n pinSample.a *= pinStrength;\n gl_FragColor.rgb = mix(gl_FragColor.rgb, pinSample.rgb, pinSample.a);\n gl_FragColor.a = max(gl_FragColor.a, pinSample.a * vOpacity);\n }\n }\n\n // Node halo: a soft SEMI-TRANSPARENT disk in the node's OWN color (no\n // brightening \u2014 a brightened/additive halo reads as a glow/bloom). Pure\n // translucency via alpha under NormalBlending.\n if (vHalo > 0.0 && outsideNodeCircle) {\n float rr = length(nodeCoord - vec2(0.5)) * 2.0; // 1.0 at circle edge, grows outward\n // Pure-color flat disk: UNIFORM alpha all the way to HALO_EDGE, then a\n // crisp ~1px anti-aliased cutoff (fwidth \u2014 resolution independent, same as\n // the icon/text shaders). No gradient band \u2192 reads as a solid colored\n // disk, not a glow/bloom. (Previously a 0.15-wide smoothstep band made the\n // edge fade over ~15% of the node radius, which read as a soft glow.)\n float aa = fwidth(rr);\n float falloff = 1.0 - smoothstep(HALO_EDGE - aa, HALO_EDGE, rr);\n gl_FragColor.rgb = vColor; // node's own color, NOT brightened\n gl_FragColor.a = max(gl_FragColor.a, falloff * vHalo * HALO_ALPHA);\n }\n\n // Hover dim: dim non-neighbor nodes when a hover is active.\n float hoverDimMul = mix(1.0, u_hoverDimOpacity, vHoverDim * u_hoverProgress);\n gl_FragColor.a *= hoverDimMul;\n\n // Alpha test\n if (gl_FragColor.a < 0.01) discard;\n}\n";
14507
14513
 
14508
14514
  // src/shaders/edge.vert.glsl
14509
- var edge_vert_default = "precision highp float;\nconst float GLOW_WIDEN_K = 3.0; // max strip widen = 1 + strength*K (strength 1 \u2192 4x)\n\nuniform sampler2D positionTexture;\nuniform float textureSize;\nuniform float spaceSize;\nuniform vec2 resolution;\nuniform float sizeAttenuation;\nuniform float lineWidthScale;\nuniform float nodeSizeScale;\nuniform float fixedSize;\nuniform float mapMode;\nuniform float mapDamping;\nuniform float mapMaxGrowth; // shared semantics with node.vert.glsl; -1.0 = Infinity sentinel\nuniform float sphereRadius;\nuniform float arrowLengthWorld;\nuniform float defaultEdgeShape;\nuniform float radialAxis;\n // Projection-consistent formula computes node world radius from shader size\n\nattribute float sourceIndex;\nattribute float targetIndex;\nattribute float side;\nattribute float along;\nattribute float counters;\nattribute vec3 edgeColor;\nattribute float edgeWidth;\nattribute float edgeOpacity;\nattribute float edgeSelected;\nattribute float edgeHighlighted;\nattribute vec3 controlOffset;\nattribute vec2 nodeSizes;\nattribute float edgeFlags;\n\n// Time uniform for shader-driven effects\nuniform float time;\n// Hover-neighbor-highlight: per-instance fade driven by edgeFlags upper bits\n// (the timestamp, ms mod 2^19) compared against u_hoverTime.\nuniform float u_hoverTime;\nuniform float u_hoverDuration;\n\nvarying vec4 vColor;\nvarying float vCounters;\nvarying float vOpacity;\nvarying float vUseDash;\nvarying float vSelected;\nvarying float vFlow;\nvarying float vGlow;\nvarying float vSide;\nvarying float vTubeGlow;\nvarying float vHoverDim;\n\nvec3 samplePosition(float idx) {\n float texX = mod(idx, textureSize) + 0.5;\n float texY = floor(idx / textureSize) + 0.5;\n vec2 texCoord = vec2(texX, texY) / textureSize;\n return texture2D(positionTexture, texCoord).xyz;\n}\n\nvec3 bezier(vec3 p0, vec3 p1, vec3 p2, float t) {\n float t1 = 1.0 - t;\n return t1 * t1 * p0 + 2.0 * t1 * t * p1 + t * t * p2;\n}\n\n// Spherical linear interpolation between two unit vectors `a` and `b`.\n// Used by globe-mode edges to ride the great-circle arc instead of a\n// chord-proportional bezier bulge. Falls back to straight `mix` when the\n// endpoints are near-coincident (sinOmega \u2248 0) to avoid divide-by-zero.\nvec3 slerp(vec3 a, vec3 b, float t) {\n float cosOmega = clamp(dot(a, b), -1.0, 1.0);\n float omega = acos(cosOmega);\n float sinOmega = sin(omega);\n if (sinOmega < 1e-5) return normalize(mix(a, b, t));\n return (sin((1.0 - t) * omega) * a + sin(t * omega) * b) / sinOmega;\n}\n\nvec2 fix(vec4 pos, float aspect) {\n vec2 res = pos.xy / pos.w;\n res.x *= aspect;\n return res;\n}\n\nvec3 rotateAroundAxis(vec3 v, vec3 axis, float angle) {\n float c = cos(angle);\n float s = sin(angle);\n return v * c + cross(axis, v) * s + axis * dot(axis, v) * (1.0 - c);\n}\n\nvec3 computePerpendicular(vec3 dir) {\n // Modified: Use Z-axis as reference for vertical plane curves\n vec3 ref = abs(dir.z) < 0.99 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\n return normalize(cross(dir, ref));\n}\n\n// Cubic bezier for S-curve tree edges\nvec3 cubicBezier(vec3 p0, vec3 p1, vec3 p2, vec3 p3, float t) {\n float t1 = 1.0 - t;\n return t1*t1*t1*p0 + 3.0*t1*t1*t*p1 + 3.0*t1*t*t*p2 + t*t*t*p3;\n}\n\n// Radial S-curve: smooth tree edge using cubic bezier\n// P0=src, P1=(src.x, midY), P2=(tgt.x, midY), P3=tgt (vertical routing)\n// Creates smooth S-curve that exits parent vertically and arrives at child vertically\nvec3 radialInterpolate(vec3 src, vec3 tgt, vec3 dir, float t, float axisMode) {\n bool useVertical;\n if (axisMode > 1.5) { useVertical = false; }\n else if (axisMode > 0.5) { useVertical = true; }\n else { useVertical = abs(dir.y) >= abs(dir.x); }\n vec3 cp1, cp2;\n if (useVertical) {\n float midY = (src.y + tgt.y) * 0.5;\n cp1 = vec3(src.x, midY, src.z);\n cp2 = vec3(tgt.x, midY, tgt.z);\n } else {\n float midX = (src.x + tgt.x) * 0.5;\n cp1 = vec3(midX, src.y, src.z);\n cp2 = vec3(midX, tgt.y, tgt.z);\n }\n return cubicBezier(src, cp1, cp2, tgt, t);\n}\n\nvoid main() {\n float aspect = resolution.x / resolution.y;\n\n vColor = vec4(edgeColor, edgeOpacity);\n vCounters = counters;\n vOpacity = edgeOpacity;\n // Unpack edgeFlags. Low 5 bits = flag bits (dashed/flow/glow/hoverDim);\n // upper 19 bits = hoverDim flip timestamp (ms mod 2^19). The flag-bit\n // unpacks below stay correct because timestamp*32 is always even when\n // divided by {2,4,8,16}.\n vUseDash = mod(edgeFlags, 2.0);\n vSelected = edgeSelected;\n vFlow = mod(floor(edgeFlags / 2.0), 2.0);\n vGlow = mod(floor(edgeFlags / 4.0), 2.0);\n vTubeGlow = mod(floor(edgeFlags / 8.0), 2.0);\n float _hoverTarget = mod(floor(edgeFlags / 16.0), 2.0);\n float _hoverStart = floor(edgeFlags / 32.0);\n float _hoverDiff = u_hoverTime - _hoverStart;\n if (_hoverDiff < 0.0) _hoverDiff += 524288.0;\n float _hoverT = _hoverStart < 0.5\n ? 1.0\n : clamp(_hoverDiff / max(u_hoverDuration, 1.0), 0.0, 1.0);\n float _hoverEased = _hoverT < 0.5\n ? 4.0 * _hoverT * _hoverT * _hoverT\n : 1.0 - pow(-2.0 * _hoverT + 2.0, 3.0) / 2.0;\n vHoverDim = mix(1.0 - _hoverTarget, _hoverTarget, _hoverEased);\n vSide = side;\n\n // Self-loops are drawn by SelfLoopCloud. Eject this vertex outside clip\n // space so the GPU never rasterizes it (CPU-side zeroing can leave a\n // black phantom in some drivers \u2014 see arrow.vert.glsl for the same pattern).\n if (sourceIndex == targetIndex) {\n gl_Position = vec4(2.0, 2.0, 2.0, 1.0);\n return;\n }\n\n vec3 srcPos = samplePosition(sourceIndex);\n vec3 tgtPos = samplePosition(targetIndex);\n\n vec3 edgeDir = tgtPos - srcPos;\n float edgeLength = length(edgeDir);\n // Threshold for the degenerate (overlapping endpoints) fallback. Was 0.001\n // \u2014 far too coarse for map mode, where world-coord positions are tiny\n // (lat/lng-derived ~0.06) and typical inter-station chords sit around\n // 1e-4..1e-3. Under the old threshold ~76% of metro edges fell back to\n // (0,1,0), causing arrows to point straight up and edge geometry to\n // mis-orient. The fallback is only needed for true self-overlap, so we\n // drop to 1e-9 (well above f32 division underflow) to keep the\n // degenerate guard without ever firing for distinct nodes.\n vec3 edgeNorm = edgeLength > 1e-9 ? edgeDir / edgeLength : vec3(0.0, 1.0, 0.0);\n\n float curvature = controlOffset.x;\n float planeRotation = controlOffset.y;\n\n // Node world radius per endpoint \u2014 perspective-correct with screen-pixel clamp.\n // Node shader (node.vert.glsl): pixelSize = nodeSize * 50.0 / viewDist * pixelRatio (clamped to [1.5, 4096]).\n // We replicate the formula, clamp to the same 4096 physical-pixel cap, then convert back to\n // world-space radius. The legacy 256 cap was a gl_PointSize hardware limit and no longer applies\n // to quad billboards; the previous detachment at high zoom is resolved by matching the node cap.\n float srcViewZ = abs((modelViewMatrix * vec4(srcPos, 1.0)).z);\n float tgtViewZ = abs((modelViewMatrix * vec4(tgtPos, 1.0)).z);\n float maxPS = 4096.0;\n float srcPixDiam, tgtPixDiam;\n if (mapMode > 0.5) {\n // MUST mirror node.vert.glsl's soft-asymptote curve so the edge endpoint\n // lands on the actual visible bubble boundary. Without this, edges stop\n // short of (or punch through) the bubble at deep zoom.\n // MUST stay in sync with node.vert.glsl / picking.vert.glsl.\n float refDepth = 10.0;\n float srcRef = nodeSizes.x * nodeSizeScale * (50.0 / refDepth);\n float tgtRef = nodeSizes.y * nodeSizeScale * (50.0 / refDepth);\n float srcRaw = pow(refDepth / srcViewZ, mapDamping);\n float tgtRaw = pow(refDepth / tgtViewZ, mapDamping);\n float srcGrowth, tgtGrowth;\n if (mapMaxGrowth < 0.0) {\n // Sentinel: Infinity \u2192 use raw values as-is (no cap)\n srcGrowth = srcRaw;\n tgtGrowth = tgtRaw;\n } else {\n // softKnee derived from mapMaxGrowth (= maxGrowth \xD7 0.5, preserves 4:2 ratio)\n float softKnee = mapMaxGrowth * 0.5;\n float A = mapMaxGrowth - softKnee;\n float srcOverflow = max(srcRaw - softKnee, 0.0);\n float tgtOverflow = max(tgtRaw - softKnee, 0.0);\n srcGrowth = min(srcRaw, softKnee) + (A * srcOverflow) / (A + srcOverflow);\n tgtGrowth = min(tgtRaw, softKnee) + (A * tgtOverflow) / (A + tgtOverflow);\n }\n srcPixDiam = min(srcRef * srcGrowth, maxPS);\n tgtPixDiam = min(tgtRef * tgtGrowth, maxPS);\n } else {\n srcPixDiam = min(nodeSizes.x * nodeSizeScale * 50.0 / srcViewZ, maxPS);\n tgtPixDiam = min(nodeSizes.y * nodeSizeScale * 50.0 / tgtViewZ, maxPS);\n }\n // Shrink offset by 4% so edge overlaps with node ring instead of ending\n // at the transparent outer edge (ring fades at dist 0.48-0.50).\n float srcOffset = srcPixDiam * srcViewZ / (projectionMatrix[1][1] * resolution.y) * 0.96;\n float tgtOffset = tgtPixDiam * tgtViewZ / (projectionMatrix[1][1] * resolution.y) * 0.96;\n // Clamp offsets so they don't exceed the edge length\n float totalOffset = srcOffset + tgtOffset;\n float clampFactor = totalOffset > edgeLength * 0.9 ? (edgeLength * 0.9) / totalOffset : 1.0;\n srcOffset *= clampFactor;\n tgtOffset *= clampFactor;\n // Arrow cone clearance \u2014 used below to cap the rendered range of `along`\n // (see drawT_max). Bezier geometry is NOT shifted; only the visible\n // segment is shortened. Computed POST-clamp so the value matches the\n // post-clamp `tgtWorldRadius` arrow.vert.glsl uses to size the cone \u2014\n // otherwise edge and cone disagree on length when the clamp kicks in for\n // short edges. Mirrors arrow.vert.glsl: cone height (4) * arrowScale.y\n // (0.035) * regime factor (tgtWorldRadius*3 screen-constant, 0.3 world).\n float coneLen = 0.0;\n if (arrowLengthWorld > 0.5) {\n coneLen = (mapMode > 0.5 || fixedSize > 0.5)\n ? 4.0 * 0.035 * tgtOffset * 4.0\n : 4.0 * 0.035 * 0.3;\n }\n float shape = controlOffset.z >= 0.0 ? controlOffset.z : defaultEdgeShape;\n // Radial: skip srcOffset (edges overlap at parent) and offset tgt along curve tangent\n vec3 tgtOffsetDir = edgeNorm;\n if (shape > 1.5) {\n srcOffset = 0.0;\n // Cubic bezier tangent at t=1 is (P3-P2) direction\n bool ev; vec3 ecp2;\n if (radialAxis > 1.5) { ev = false; }\n else if (radialAxis > 0.5) { ev = true; }\n else { ev = abs(edgeDir.y) >= abs(edgeDir.x); }\n if (ev) { float my = (srcPos.y+tgtPos.y)*0.5; ecp2 = vec3(tgtPos.x,my,tgtPos.z); }\n else { float mx = (srcPos.x+tgtPos.x)*0.5; ecp2 = vec3(mx,tgtPos.y,tgtPos.z); }\n vec3 tang = tgtPos - ecp2;\n tgtOffsetDir = length(tang) > 0.0001 ? normalize(tang) : edgeNorm;\n }\n vec3 adjustedSrc = srcPos + edgeNorm * srcOffset;\n vec3 adjustedTgt = tgtPos - tgtOffsetDir * tgtOffset;\n float effectiveCurvature = curvature;\n if (shape > 0.5 && shape < 1.5 && abs(curvature) < 0.001) { effectiveCurvature = 0.15; }\n vec3 adjustedDir = adjustedTgt - adjustedSrc;\n\n // Globe mode: regular edges (shape < 1.5, excluding radial S-curves) ride\n // the great-circle arc via slerp instead of a chord-proportional bezier\n // bulge. Multi-edge fan separation is layered on as a perpendicular offset\n // scaled by sin(omega/2), so short Paris-internal edges collapse to near-\n // straight while cross-continent edges spread visibly. Per the design spec\n // (2026-05-25-globe-edge-greatcircle-design.md \xA76) this branch ignores the\n // legacy `effectiveCurvature` / `isGlobeStraight` synthesis.\n bool isSphereEdge = sphereRadius > 0.001 && shape < 1.5;\n\n // Globe straight edges (legacy): only used when sphere mode is OFF (above\n // branch already handles the on-sphere case) \u2014 kept here as a guard so\n // future planar-globe-emulation modes still compile.\n bool isGlobeStraight = !isSphereEdge && sphereRadius > 0.001 && abs(effectiveCurvature) < 0.001 && shape < 0.5;\n bool isCurveBranch = !isSphereEdge && (isGlobeStraight || shape > 0.5 || abs(effectiveCurvature) > 0.001);\n\n // Sphere-edge precomputed quantities (only meaningful when isSphereEdge).\n // Kept at outer scope so prev/next sampling can reuse without recomputing.\n vec3 dirSrcS, dirTgtS, planeNormalS, arcMidDirS, perpMidS;\n float omegaS = 0.0;\n if (isSphereEdge) {\n dirSrcS = normalize(adjustedSrc);\n dirTgtS = normalize(adjustedTgt);\n float cosO = clamp(dot(dirSrcS, dirTgtS), -1.0, 1.0);\n omegaS = acos(cosO);\n float sinO = sin(omegaS);\n // Plane normal of the great circle; degenerate (near-coincident\n // endpoints) falls back to world +Y to avoid NaN perp downstream.\n planeNormalS = sinO < 1e-5 ? vec3(0.0, 1.0, 0.0) : normalize(cross(dirSrcS, dirTgtS));\n }\n\n // Compute controlPoint once (shared by drawT_max + position + prev/next).\n // For straight edges controlPoint is unused; reference distance falls back\n // to chord length.\n vec3 controlPoint;\n if (isCurveBranch) {\n vec3 midPoint = (adjustedSrc + adjustedTgt) * 0.5;\n // Bulge direction (issue: edge arc top up after 3D pitch).\n //\n // Goal: in map mode the arc crest must always face the viewport's top,\n // regardless of edge direction or scene pitch. The most robust reference\n // for \"up in viewport\" inside a vertex shader is the camera's local +Y\n // expressed in model space \u2014 derived as the first row of the upper-3x3\n // of `modelViewMatrix`, which is equivalent to `transpose(mat3(mvm)) *\n // (0,1,0)`. For pitched planar maps this resolves to a direction that\n // rotates back to world +Y after the scene's X rotation; for pitched\n // (camera-orbit) spherical maps it resolves to whatever world direction\n // the orbiting camera now treats as \"up.\" Either way, after the full\n // model\u2192view transform the perpendicular ends up aligned with viewport +Y.\n //\n // Replaces both (a) the great-circle approximation used previously for\n // globeStraight edges (which produced direction-dependent bulges that\n // flipped above/below the horizon under pitch) and (b) the surface-normal\n // approach used in the prior fix (which only solved the planar case).\n //\n // Outside map mode the legacy lateral `cross(edgeNorm, +Z)` is kept so\n // non-map graphs retain their existing look.\n vec3 perp;\n if (mapMode > 0.5) {\n vec3 camUpInModel = vec3(\n modelViewMatrix[0][1],\n modelViewMatrix[1][1],\n modelViewMatrix[2][1]\n );\n vec3 proj = camUpInModel - dot(camUpInModel, edgeNorm) * edgeNorm;\n float l = length(proj);\n perp = l > 0.001 ? proj / l : computePerpendicular(edgeNorm);\n } else {\n perp = computePerpendicular(edgeNorm);\n }\n if (abs(planeRotation) > 0.001) {\n perp = rotateAroundAxis(perp, edgeNorm, planeRotation);\n }\n // Bulge magnitude: for explicitly curved edges use effectiveCurvature *\n // edgeLength (legacy). For globeStraight (sphere mode, curvature=0,\n // shape<0.5) synthesize a magnitude proportional to chord length so the\n // arc has visible height \u2014 tuned to roughly match the previous\n // great-circle crest height for typical inter-city edges.\n float bulgeMag = isGlobeStraight\n ? edgeLength * 0.15\n : effectiveCurvature * edgeLength;\n controlPoint = midPoint + perp * bulgeMag;\n }\n\n // Cap the rendered range of `along` so the visible edge stops at the cone\n // base while the bezier geometry stays anchored at adjustedTgt (cone apex\n // position). For a quadratic bezier the tangent at t=1 is 2*(P2 - P1), so\n // near t=1 the curve advances ~ 2*|P2 - P1| world units per unit of t. That\n // makes 2*|P2 - P1| the right reference length to convert coneLen into a\n // parametric back-off \u2014 using chord length over-retracts on curves because\n // the curve's tangent at the endpoint is longer than the chord direction.\n // For straight edges controlPoint is the chord midpoint, so 2*|P2 - P1|\n // collapses back to chord length and the formula stays exact.\n float adjustedChordLen = length(adjustedDir);\n // Reference length used to convert world-space `coneLen` into a parametric\n // back-off (drawT_max). For straight edges it's the chord; for bezier\n // curves it's 2*|P2-P1| (tangent speed at t=1); for slerp arcs it's the\n // arc length omega*R (slerp has constant speed = omega*R per unit t).\n float refLen = isSphereEdge\n ? omegaS * sphereRadius\n : (isCurveBranch ? 2.0 * length(adjustedTgt - controlPoint) : adjustedChordLen);\n float drawT_max = refLen > 0.001\n ? clamp(1.0 - coneLen / refLen, 0.001, 1.0)\n : 1.0;\n float effAlong = along * drawT_max;\n\n vec3 edgePosition;\n if (isSphereEdge) {\n // Great-circle arc on the sphere surface, plus a perpendicular fan\n // offset for multi-edges. Fan magnitude `controlOffset.x * sin(omega/2)\n // * sphereRadius` is the design's \u03B8-scaled separation rule \u2014 see\n // sphereMath.fanOffsetMag for the CPU mirror.\n vec3 arcDir = slerp(dirSrcS, dirTgtS, effAlong);\n vec3 arcPos = arcDir * sphereRadius;\n vec3 perpOnSphere = normalize(cross(arcDir, planeNormalS));\n float offsetMag = controlOffset.x * sin(omegaS * 0.5) * sphereRadius;\n edgePosition = arcPos + perpOnSphere * offsetMag;\n } else if (shape > 1.5) {\n edgePosition = radialInterpolate(adjustedSrc, adjustedTgt, adjustedDir, effAlong, radialAxis);\n } else if (isCurveBranch) {\n // Straighten last 15% of curve into a straight line toward target.\n // This ensures the edge connects cleanly to the arrow at the node boundary.\n float blendStart = 0.85;\n vec3 bAtBlend = bezier(adjustedSrc, controlPoint, adjustedTgt, blendStart);\n if (effAlong > blendStart) {\n edgePosition = mix(bAtBlend, adjustedTgt, (effAlong - blendStart) / (1.0 - blendStart));\n } else {\n edgePosition = bezier(adjustedSrc, controlPoint, adjustedTgt, effAlong);\n }\n } else {\n edgePosition = mix(adjustedSrc, adjustedTgt, effAlong);\n }\n\n mat4 mvp = projectionMatrix * modelViewMatrix;\n vec4 currentClip = mvp * vec4(edgePosition, 1.0);\n\n // Prev/next sample neighbors on the rendered (capped) curve so the line\n // direction at the visible endpoint reflects the cone-aligned tangent.\n float prevEff = max(0.0, effAlong - 0.01);\n float nextEff = min(drawT_max, effAlong + 0.01);\n\n vec3 prevPos, nextPos;\n if (isSphereEdge) {\n vec3 prevArcDir = slerp(dirSrcS, dirTgtS, prevEff);\n vec3 nextArcDir = slerp(dirSrcS, dirTgtS, nextEff);\n vec3 prevArcPos = prevArcDir * sphereRadius;\n vec3 nextArcPos = nextArcDir * sphereRadius;\n vec3 prevPerp = normalize(cross(prevArcDir, planeNormalS));\n vec3 nextPerp = normalize(cross(nextArcDir, planeNormalS));\n float prevOff = controlOffset.x * sin(omegaS * 0.5) * sphereRadius;\n float nextOff = controlOffset.x * sin(omegaS * 0.5) * sphereRadius;\n prevPos = prevArcPos + prevPerp * prevOff;\n nextPos = nextArcPos + nextPerp * nextOff;\n } else if (shape > 1.5) {\n prevPos = radialInterpolate(adjustedSrc, adjustedTgt, adjustedDir, prevEff, radialAxis);\n nextPos = radialInterpolate(adjustedSrc, adjustedTgt, adjustedDir, nextEff, radialAxis);\n } else if (isCurveBranch) {\n float blendStart = 0.85;\n vec3 bAtBlend = bezier(adjustedSrc, controlPoint, adjustedTgt, blendStart);\n prevPos = prevEff > blendStart\n ? mix(bAtBlend, adjustedTgt, (prevEff - blendStart) / (1.0 - blendStart))\n : bezier(adjustedSrc, controlPoint, adjustedTgt, prevEff);\n nextPos = nextEff > blendStart\n ? mix(bAtBlend, adjustedTgt, (nextEff - blendStart) / (1.0 - blendStart))\n : bezier(adjustedSrc, controlPoint, adjustedTgt, nextEff);\n } else {\n prevPos = mix(adjustedSrc, adjustedTgt, prevEff);\n nextPos = mix(adjustedSrc, adjustedTgt, nextEff);\n }\n\n vec4 prevClip = mvp * vec4(prevPos, 1.0);\n vec4 nextClip = mvp * vec4(nextPos, 1.0);\n\n vec2 currentP = fix(currentClip, aspect);\n vec2 prevP = fix(prevClip, aspect);\n vec2 nextP = fix(nextClip, aspect);\n\n float baseWidth = edgeWidth * lineWidthScale;\n if (edgeSelected > 0.5) baseWidth += 2.0 * lineWidthScale;\n\n float pixelWidth = currentClip.w;\n float w;\n\n // Two width regimes (mirrored in arrow.vert.glsl):\n // - World-scaled (legacy parity, default): w is clip-space constant, so\n // screen size = w/clip.w shrinks with distance \u2014 edges visibly grow on\n // zoom-in / shrink on zoom-out like legacy.\n // - Screen-constant: multiply by clip.w so it cancels in the perspective\n // divide. Used when nodes are at fixed screen size (fixedSize), and in\n // mapMode where camera-z range is huge (city-street \u2194 continent) and a\n // world-scaled line would either vanish or blow up.\n //\n // edgeScale = base screen-pixel thickness for the screen-constant regime\n // (fixedSize bumps it to 0.15 to match larger fixedSize nodes).\n // worldScale = 0.16 matches legacy clip-space width: legacy used 0.008\n // directly, new engine multiplies through lineWidthScale (default 0.05),\n // so 0.008 / 0.05 = 0.16 gives a default edge the same legacy look.\n float edgeScale = 1.0 / 15.0;\n float worldScale = 0.16;\n if (mapMode > 0.5 || fixedSize > 0.5) {\n float k = fixedSize > 0.5 ? 0.15 : edgeScale;\n w = 1.8 * pixelWidth * baseWidth * k;\n } else {\n w = 1.8 * baseWidth * worldScale;\n }\n\n vec2 dir;\n if (nextP == currentP) dir = normalize(currentP - prevP);\n else if (prevP == currentP) dir = normalize(nextP - currentP);\n else dir = normalize(normalize(currentP - prevP) + normalize(nextP - currentP));\n\n vec2 normal = vec2(-dir.y, dir.x);\n normal.x /= aspect;\n // Tube glow: widen the strip so the soft halo has room outside the solid core.\n // The visible solid core stays at the original width (the fragment uses coreFrac).\n w *= 1.0 + vTubeGlow * GLOW_WIDEN_K;\n normal *= 0.5 * w;\n\n vec4 finalPosition = currentClip;\n finalPosition.xy += normal * side;\n\n // Globe mode: per-vertex back-face culling (same approach as nodes).\n // depthTest is disabled in globe mode, so we hide back-facing edges here.\n // Each vertex along the edge is checked individually using its actual\n // position on the great-circle arc \u2014 not just the midpoint.\n // This correctly hides the portion of an edge that crosses the globe horizon.\n if (sphereRadius > 0.001) {\n vec3 wN = normalize(mat3(modelMatrix) * normalize(edgePosition));\n vec3 wP = (modelMatrix * vec4(edgePosition, 1.0)).xyz;\n if (dot(wN, normalize(cameraPosition - wP)) < 0.0) {\n vOpacity = 0.0;\n }\n }\n\n gl_Position = finalPosition;\n}\n";
14515
+ var edge_vert_default = "precision highp float;\nconst float GLOW_WIDEN_K = 3.0; // max strip widen = 1 + strength*K (strength 1 \u2192 4x)\n\nuniform sampler2D positionTexture;\nuniform float textureSize;\nuniform float spaceSize;\nuniform vec2 resolution;\nuniform float sizeAttenuation;\nuniform float lineWidthScale;\nuniform float nodeSizeScale;\nuniform float fixedSize;\nuniform float mapMode;\nuniform float mapDamping;\nuniform float mapMaxGrowth; // shared semantics with node.vert.glsl; -1.0 = Infinity sentinel\nuniform float sphereRadius;\nuniform float arrowLengthWorld;\nuniform float defaultEdgeShape;\nuniform float radialAxis;\n // Projection-consistent formula computes node world radius from shader size\n\nattribute float sourceIndex;\nattribute float targetIndex;\nattribute float side;\nattribute float along;\nattribute float counters;\nattribute vec3 edgeColor;\nattribute float edgeWidth;\nattribute float edgeOpacity;\nattribute float edgeSelected;\nattribute float edgeHighlighted;\nattribute vec3 controlOffset;\nattribute vec2 nodeSizes;\nattribute float edgeFlags;\n\n// Time uniform for shader-driven effects\nuniform float time;\n// Hover-neighbor-highlight: per-instance fade driven by edgeFlags upper bits\n// (the timestamp, ms mod 2^19) compared against u_hoverTime.\nuniform float u_hoverTime;\nuniform float u_hoverDuration;\n\nvarying vec4 vColor;\nvarying float vCounters;\nvarying float vOpacity;\nvarying float vUseDash;\nvarying float vSelected;\nvarying float vFlow;\nvarying float vGlow;\nvarying float vSide;\nvarying float vTubeGlow;\nvarying float vHoverDim;\n\nvec3 samplePosition(float idx) {\n float texX = mod(idx, textureSize) + 0.5;\n float texY = floor(idx / textureSize) + 0.5;\n vec2 texCoord = vec2(texX, texY) / textureSize;\n return texture2D(positionTexture, texCoord).xyz;\n}\n\nvec3 bezier(vec3 p0, vec3 p1, vec3 p2, float t) {\n float t1 = 1.0 - t;\n return t1 * t1 * p0 + 2.0 * t1 * t * p1 + t * t * p2;\n}\n\n// Spherical linear interpolation between two unit vectors `a` and `b`.\n// Used by globe-mode edges to ride the great-circle arc instead of a\n// chord-proportional bezier bulge. Falls back to straight `mix` when the\n// endpoints are near-coincident (sinOmega \u2248 0) to avoid divide-by-zero.\nvec3 slerp(vec3 a, vec3 b, float t) {\n float cosOmega = clamp(dot(a, b), -1.0, 1.0);\n float omega = acos(cosOmega);\n float sinOmega = sin(omega);\n if (sinOmega < 1e-5) return normalize(mix(a, b, t));\n return (sin((1.0 - t) * omega) * a + sin(t * omega) * b) / sinOmega;\n}\n\nvec2 fix(vec4 pos, float aspect) {\n vec2 res = pos.xy / pos.w;\n res.x *= aspect;\n return res;\n}\n\nvec3 rotateAroundAxis(vec3 v, vec3 axis, float angle) {\n float c = cos(angle);\n float s = sin(angle);\n return v * c + cross(axis, v) * s + axis * dot(axis, v) * (1.0 - c);\n}\n\nvec3 computePerpendicular(vec3 dir) {\n // Modified: Use Z-axis as reference for vertical plane curves\n vec3 ref = abs(dir.z) < 0.99 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\n return normalize(cross(dir, ref));\n}\n\n// Cubic bezier for S-curve tree edges\nvec3 cubicBezier(vec3 p0, vec3 p1, vec3 p2, vec3 p3, float t) {\n float t1 = 1.0 - t;\n return t1*t1*t1*p0 + 3.0*t1*t1*t*p1 + 3.0*t1*t*t*p2 + t*t*t*p3;\n}\n\n// Radial S-curve: smooth tree edge using cubic bezier\n// P0=src, P1=(src.x, midY), P2=(tgt.x, midY), P3=tgt (vertical routing)\n// Creates smooth S-curve that exits parent vertically and arrives at child vertically\nvec3 radialInterpolate(vec3 src, vec3 tgt, vec3 dir, float t, float axisMode) {\n bool useVertical;\n if (axisMode > 1.5) { useVertical = false; }\n else if (axisMode > 0.5) { useVertical = true; }\n else { useVertical = abs(dir.y) >= abs(dir.x); }\n vec3 cp1, cp2;\n if (useVertical) {\n float midY = (src.y + tgt.y) * 0.5;\n cp1 = vec3(src.x, midY, src.z);\n cp2 = vec3(tgt.x, midY, tgt.z);\n } else {\n float midX = (src.x + tgt.x) * 0.5;\n cp1 = vec3(midX, src.y, src.z);\n cp2 = vec3(midX, tgt.y, tgt.z);\n }\n return cubicBezier(src, cp1, cp2, tgt, t);\n}\n\nvoid main() {\n float aspect = resolution.x / resolution.y;\n\n vColor = vec4(edgeColor, edgeOpacity);\n vCounters = counters;\n vOpacity = edgeOpacity;\n // Unpack edgeFlags. Low 5 bits = flag bits (dashed/flow/glow/hoverDim);\n // upper 19 bits = hoverDim flip timestamp (ms mod 2^19). The flag-bit\n // unpacks below stay correct because timestamp*32 is always even when\n // divided by {2,4,8,16}.\n vUseDash = mod(edgeFlags, 2.0);\n vSelected = edgeSelected;\n vFlow = mod(floor(edgeFlags / 2.0), 2.0);\n vGlow = mod(floor(edgeFlags / 4.0), 2.0);\n vTubeGlow = mod(floor(edgeFlags / 8.0), 2.0);\n float _hoverTarget = mod(floor(edgeFlags / 16.0), 2.0);\n float _hoverStart = floor(edgeFlags / 32.0);\n float _hoverDiff = u_hoverTime - _hoverStart;\n if (_hoverDiff < 0.0) _hoverDiff += 524288.0;\n float _hoverT = _hoverStart < 0.5\n ? 1.0\n : clamp(_hoverDiff / max(u_hoverDuration, 1.0), 0.0, 1.0);\n float _hoverEased = _hoverT < 0.5\n ? 4.0 * _hoverT * _hoverT * _hoverT\n : 1.0 - pow(-2.0 * _hoverT + 2.0, 3.0) / 2.0;\n vHoverDim = mix(1.0 - _hoverTarget, _hoverTarget, _hoverEased);\n vSide = side;\n\n // Self-loops are drawn by SelfLoopCloud. Eject this vertex outside clip\n // space so the GPU never rasterizes it (CPU-side zeroing can leave a\n // black phantom in some drivers \u2014 see arrow.vert.glsl for the same pattern).\n if (sourceIndex == targetIndex) {\n gl_Position = vec4(2.0, 2.0, 2.0, 1.0);\n return;\n }\n\n vec3 srcPos = samplePosition(sourceIndex);\n vec3 tgtPos = samplePosition(targetIndex);\n\n vec3 edgeDir = tgtPos - srcPos;\n float edgeLength = length(edgeDir);\n // Threshold for the degenerate (overlapping endpoints) fallback. Was 0.001\n // \u2014 far too coarse for map mode, where world-coord positions are tiny\n // (lat/lng-derived ~0.06) and typical inter-station chords sit around\n // 1e-4..1e-3. Under the old threshold ~76% of metro edges fell back to\n // (0,1,0), causing arrows to point straight up and edge geometry to\n // mis-orient. The fallback is only needed for true self-overlap, so we\n // drop to 1e-9 (well above f32 division underflow) to keep the\n // degenerate guard without ever firing for distinct nodes.\n vec3 edgeNorm = edgeLength > 1e-9 ? edgeDir / edgeLength : vec3(0.0, 1.0, 0.0);\n\n float curvature = controlOffset.x;\n float planeRotation = controlOffset.y;\n\n // Node world radius per endpoint \u2014 perspective-correct with screen-pixel clamp.\n // Node shader (node.vert.glsl): pixelSize = nodeSize * 50.0 / viewDist * pixelRatio (clamped to [1.5, 4096]).\n // We replicate the formula, clamp to the same 4096 physical-pixel cap, then convert back to\n // world-space radius. The legacy 256 cap was a gl_PointSize hardware limit and no longer applies\n // to quad billboards; the previous detachment at high zoom is resolved by matching the node cap.\n float srcViewZ = abs((modelViewMatrix * vec4(srcPos, 1.0)).z);\n float tgtViewZ = abs((modelViewMatrix * vec4(tgtPos, 1.0)).z);\n float maxPS = 4096.0;\n float srcPixDiam, tgtPixDiam;\n if (mapMode > 0.5) {\n // MUST mirror node.vert.glsl's soft-asymptote curve so the edge endpoint\n // lands on the actual visible bubble boundary. Without this, edges stop\n // short of (or punch through) the bubble at deep zoom.\n // MUST stay in sync with node.vert.glsl / picking.vert.glsl.\n float refDepth = 10.0;\n float srcRef = nodeSizes.x * nodeSizeScale * (50.0 / refDepth);\n float tgtRef = nodeSizes.y * nodeSizeScale * (50.0 / refDepth);\n float srcRaw = pow(refDepth / srcViewZ, mapDamping);\n float tgtRaw = pow(refDepth / tgtViewZ, mapDamping);\n float srcGrowth, tgtGrowth;\n if (mapMaxGrowth < 0.0) {\n // Sentinel: Infinity \u2192 use raw values as-is (no cap)\n srcGrowth = srcRaw;\n tgtGrowth = tgtRaw;\n } else {\n // softKnee derived from mapMaxGrowth (= maxGrowth \xD7 0.5, preserves 4:2 ratio)\n float softKnee = mapMaxGrowth * 0.5;\n float A = mapMaxGrowth - softKnee;\n float srcOverflow = max(srcRaw - softKnee, 0.0);\n float tgtOverflow = max(tgtRaw - softKnee, 0.0);\n srcGrowth = min(srcRaw, softKnee) + (A * srcOverflow) / (A + srcOverflow);\n tgtGrowth = min(tgtRaw, softKnee) + (A * tgtOverflow) / (A + tgtOverflow);\n }\n srcPixDiam = min(srcRef * srcGrowth, maxPS);\n tgtPixDiam = min(tgtRef * tgtGrowth, maxPS);\n } else {\n srcPixDiam = min(nodeSizes.x * nodeSizeScale * 50.0 / srcViewZ, maxPS);\n tgtPixDiam = min(nodeSizes.y * nodeSizeScale * 50.0 / tgtViewZ, maxPS);\n }\n // Shrink offset by 4% so edge overlaps with node ring instead of ending\n // at the transparent outer edge (ring fades at dist 0.48-0.50).\n float srcOffset = srcPixDiam * srcViewZ / (projectionMatrix[1][1] * resolution.y) * 0.96;\n float tgtOffset = tgtPixDiam * tgtViewZ / (projectionMatrix[1][1] * resolution.y) * 0.96;\n // Clamp offsets so they don't exceed the edge length\n float totalOffset = srcOffset + tgtOffset;\n float clampFactor = totalOffset > edgeLength * 0.9 ? (edgeLength * 0.9) / totalOffset : 1.0;\n srcOffset *= clampFactor;\n tgtOffset *= clampFactor;\n // Arrow cone clearance \u2014 used below to cap the rendered range of `along`\n // (see drawT_max). Bezier geometry is NOT shifted; only the visible\n // segment is shortened. Computed POST-clamp so the value matches the\n // post-clamp `tgtWorldRadius` arrow.vert.glsl uses to size the cone \u2014\n // otherwise edge and cone disagree on length when the clamp kicks in for\n // short edges. Mirrors arrow.vert.glsl: cone height (4) * arrowScale.y\n // (0.035) * regime factor (tgtWorldRadius*3 screen-constant, 0.3 world).\n float coneLen = 0.0;\n if (arrowLengthWorld > 0.5) {\n coneLen = (mapMode > 0.5 || fixedSize > 0.5)\n ? 4.0 * 0.035 * tgtOffset * 4.0\n : 4.0 * 0.035 * 0.3;\n }\n float shape = controlOffset.z >= 0.0 ? controlOffset.z : defaultEdgeShape;\n // Radial: skip srcOffset (edges overlap at parent) and offset tgt along curve tangent\n vec3 tgtOffsetDir = edgeNorm;\n if (shape > 1.5) {\n srcOffset = 0.0;\n // Cubic bezier tangent at t=1 is (P3-P2) direction\n bool ev; vec3 ecp2;\n if (radialAxis > 1.5) { ev = false; }\n else if (radialAxis > 0.5) { ev = true; }\n else { ev = abs(edgeDir.y) >= abs(edgeDir.x); }\n if (ev) { float my = (srcPos.y+tgtPos.y)*0.5; ecp2 = vec3(tgtPos.x,my,tgtPos.z); }\n else { float mx = (srcPos.x+tgtPos.x)*0.5; ecp2 = vec3(mx,tgtPos.y,tgtPos.z); }\n vec3 tang = tgtPos - ecp2;\n tgtOffsetDir = length(tang) > 0.0001 ? normalize(tang) : edgeNorm;\n }\n vec3 adjustedSrc = srcPos + edgeNorm * srcOffset;\n vec3 adjustedTgt = tgtPos - tgtOffsetDir * tgtOffset;\n float effectiveCurvature = curvature;\n if (shape > 0.5 && shape < 1.5 && abs(curvature) < 0.001) { effectiveCurvature = 0.15; }\n vec3 adjustedDir = adjustedTgt - adjustedSrc;\n\n // Globe mode: regular edges (shape < 1.5, excluding radial S-curves) ride\n // the great-circle arc via slerp instead of a chord-proportional bezier\n // bulge. Multi-edge fan separation is layered on as a perpendicular offset\n // scaled by sin(omega/2), so short Paris-internal edges collapse to near-\n // straight while cross-continent edges spread visibly. Per the design spec\n // (2026-05-25-globe-edge-greatcircle-design.md \xA76) this branch ignores the\n // legacy `effectiveCurvature` / `isGlobeStraight` synthesis.\n // Only ride the great-circle arc when BOTH endpoints are actually pinned on\n // the sphere surface (geo nodes: |pos| ~= sphereRadius). Non-geo (force-\n // layout) nodes sit at arbitrary radii near the origin; projecting their\n // edges onto the sphere (slerp(normalize(pos)) * sphereRadius) makes the\n // edge radiate off the node toward the silhouette. Those fall through to the\n // chord/curve branch so the edge connects the two real node positions.\n // Geo nodes land exactly on the radius; force clusters sit well inside it,\n // so a 10% band cleanly separates the two. MUST match arrow.vert.glsl.\n float srcSphereDist = length(srcPos);\n float tgtSphereDist = length(tgtPos);\n float sphereBand = sphereRadius * 0.1;\n bool bothOnSphere = abs(srcSphereDist - sphereRadius) < sphereBand\n && abs(tgtSphereDist - sphereRadius) < sphereBand;\n bool isSphereEdge = sphereRadius > 0.001 && shape < 1.5 && bothOnSphere;\n\n // Globe straight edges: DISABLED. The old behavior synthesized a 0.15*len\n // bulge for every straight edge in globe mode \u2014 but non-geo edges (now that\n // isSphereEdge is gated to geo-on-sphere endpoints) must look exactly like\n // 2D straight edges: dead straight unless the user actually enabled curve.\n // Keeping this true added an unwanted arc to non-geo edges even with curve\n // off. Geo edges ride isSphereEdge; curved edges ride shape/curvature below.\n bool isGlobeStraight = false;\n bool isCurveBranch = !isSphereEdge && (shape > 0.5 || abs(effectiveCurvature) > 0.001);\n\n // Sphere-edge precomputed quantities (only meaningful when isSphereEdge).\n // Kept at outer scope so prev/next sampling can reuse without recomputing.\n vec3 dirSrcS, dirTgtS, planeNormalS, arcMidDirS, perpMidS;\n float omegaS = 0.0;\n if (isSphereEdge) {\n dirSrcS = normalize(adjustedSrc);\n dirTgtS = normalize(adjustedTgt);\n float cosO = clamp(dot(dirSrcS, dirTgtS), -1.0, 1.0);\n omegaS = acos(cosO);\n float sinO = sin(omegaS);\n // Plane normal of the great circle; degenerate (near-coincident\n // endpoints) falls back to world +Y to avoid NaN perp downstream.\n planeNormalS = sinO < 1e-5 ? vec3(0.0, 1.0, 0.0) : normalize(cross(dirSrcS, dirTgtS));\n }\n\n // Compute controlPoint once (shared by drawT_max + position + prev/next).\n // For straight edges controlPoint is unused; reference distance falls back\n // to chord length.\n vec3 controlPoint;\n if (isCurveBranch) {\n vec3 midPoint = (adjustedSrc + adjustedTgt) * 0.5;\n // Bulge direction (issue: edge arc top up after 3D pitch).\n //\n // Goal: in map mode the arc crest must always face the viewport's top,\n // regardless of edge direction or scene pitch. The most robust reference\n // for \"up in viewport\" inside a vertex shader is the camera's local +Y\n // expressed in model space \u2014 derived as the first row of the upper-3x3\n // of `modelViewMatrix`, which is equivalent to `transpose(mat3(mvm)) *\n // (0,1,0)`. For pitched planar maps this resolves to a direction that\n // rotates back to world +Y after the scene's X rotation; for pitched\n // (camera-orbit) spherical maps it resolves to whatever world direction\n // the orbiting camera now treats as \"up.\" Either way, after the full\n // model\u2192view transform the perpendicular ends up aligned with viewport +Y.\n //\n // Replaces both (a) the great-circle approximation used previously for\n // globeStraight edges (which produced direction-dependent bulges that\n // flipped above/below the horizon under pitch) and (b) the surface-normal\n // approach used in the prior fix (which only solved the planar case).\n //\n // Outside map mode the legacy lateral `cross(edgeNorm, +Z)` is kept so\n // non-map graphs retain their existing look.\n vec3 perp;\n if (mapMode > 0.5) {\n vec3 camUpInModel = vec3(\n modelViewMatrix[0][1],\n modelViewMatrix[1][1],\n modelViewMatrix[2][1]\n );\n vec3 proj = camUpInModel - dot(camUpInModel, edgeNorm) * edgeNorm;\n float l = length(proj);\n perp = l > 0.001 ? proj / l : computePerpendicular(edgeNorm);\n } else {\n perp = computePerpendicular(edgeNorm);\n }\n if (abs(planeRotation) > 0.001) {\n perp = rotateAroundAxis(perp, edgeNorm, planeRotation);\n }\n // Bulge magnitude: for explicitly curved edges use effectiveCurvature *\n // edgeLength (legacy). For globeStraight (sphere mode, curvature=0,\n // shape<0.5) synthesize a magnitude proportional to chord length so the\n // arc has visible height \u2014 tuned to roughly match the previous\n // great-circle crest height for typical inter-city edges.\n float bulgeMag = isGlobeStraight\n ? edgeLength * 0.15\n : effectiveCurvature * edgeLength;\n controlPoint = midPoint + perp * bulgeMag;\n }\n\n // Cap the rendered range of `along` so the visible edge stops at the cone\n // base while the bezier geometry stays anchored at adjustedTgt (cone apex\n // position). For a quadratic bezier the tangent at t=1 is 2*(P2 - P1), so\n // near t=1 the curve advances ~ 2*|P2 - P1| world units per unit of t. That\n // makes 2*|P2 - P1| the right reference length to convert coneLen into a\n // parametric back-off \u2014 using chord length over-retracts on curves because\n // the curve's tangent at the endpoint is longer than the chord direction.\n // For straight edges controlPoint is the chord midpoint, so 2*|P2 - P1|\n // collapses back to chord length and the formula stays exact.\n float adjustedChordLen = length(adjustedDir);\n // Reference length used to convert world-space `coneLen` into a parametric\n // back-off (drawT_max). For straight edges it's the chord; for bezier\n // curves it's 2*|P2-P1| (tangent speed at t=1); for slerp arcs it's the\n // arc length omega*R (slerp has constant speed = omega*R per unit t).\n float refLen = isSphereEdge\n ? omegaS * sphereRadius\n : (isCurveBranch ? 2.0 * length(adjustedTgt - controlPoint) : adjustedChordLen);\n float drawT_max = refLen > 0.001\n ? clamp(1.0 - coneLen / refLen, 0.001, 1.0)\n : 1.0;\n float effAlong = along * drawT_max;\n\n vec3 edgePosition;\n if (isSphereEdge) {\n // Great-circle arc on the sphere surface, plus a perpendicular fan\n // offset for multi-edges. Fan magnitude `controlOffset.x * sin(omega/2)\n // * sphereRadius` is the design's \u03B8-scaled separation rule \u2014 see\n // sphereMath.fanOffsetMag for the CPU mirror.\n vec3 arcDir = slerp(dirSrcS, dirTgtS, effAlong);\n vec3 arcPos = arcDir * sphereRadius;\n vec3 perpOnSphere = normalize(cross(arcDir, planeNormalS));\n float offsetMag = controlOffset.x * sin(omegaS * 0.5) * sphereRadius;\n edgePosition = arcPos + perpOnSphere * offsetMag;\n } else if (shape > 1.5) {\n edgePosition = radialInterpolate(adjustedSrc, adjustedTgt, adjustedDir, effAlong, radialAxis);\n } else if (isCurveBranch) {\n // Straighten last 15% of curve into a straight line toward target.\n // This ensures the edge connects cleanly to the arrow at the node boundary.\n float blendStart = 0.85;\n vec3 bAtBlend = bezier(adjustedSrc, controlPoint, adjustedTgt, blendStart);\n if (effAlong > blendStart) {\n edgePosition = mix(bAtBlend, adjustedTgt, (effAlong - blendStart) / (1.0 - blendStart));\n } else {\n edgePosition = bezier(adjustedSrc, controlPoint, adjustedTgt, effAlong);\n }\n } else {\n edgePosition = mix(adjustedSrc, adjustedTgt, effAlong);\n }\n\n mat4 mvp = projectionMatrix * modelViewMatrix;\n vec4 currentClip = mvp * vec4(edgePosition, 1.0);\n\n // Prev/next sample neighbors on the rendered (capped) curve so the line\n // direction at the visible endpoint reflects the cone-aligned tangent.\n float prevEff = max(0.0, effAlong - 0.01);\n float nextEff = min(drawT_max, effAlong + 0.01);\n\n vec3 prevPos, nextPos;\n if (isSphereEdge) {\n vec3 prevArcDir = slerp(dirSrcS, dirTgtS, prevEff);\n vec3 nextArcDir = slerp(dirSrcS, dirTgtS, nextEff);\n vec3 prevArcPos = prevArcDir * sphereRadius;\n vec3 nextArcPos = nextArcDir * sphereRadius;\n vec3 prevPerp = normalize(cross(prevArcDir, planeNormalS));\n vec3 nextPerp = normalize(cross(nextArcDir, planeNormalS));\n float prevOff = controlOffset.x * sin(omegaS * 0.5) * sphereRadius;\n float nextOff = controlOffset.x * sin(omegaS * 0.5) * sphereRadius;\n prevPos = prevArcPos + prevPerp * prevOff;\n nextPos = nextArcPos + nextPerp * nextOff;\n } else if (shape > 1.5) {\n prevPos = radialInterpolate(adjustedSrc, adjustedTgt, adjustedDir, prevEff, radialAxis);\n nextPos = radialInterpolate(adjustedSrc, adjustedTgt, adjustedDir, nextEff, radialAxis);\n } else if (isCurveBranch) {\n float blendStart = 0.85;\n vec3 bAtBlend = bezier(adjustedSrc, controlPoint, adjustedTgt, blendStart);\n prevPos = prevEff > blendStart\n ? mix(bAtBlend, adjustedTgt, (prevEff - blendStart) / (1.0 - blendStart))\n : bezier(adjustedSrc, controlPoint, adjustedTgt, prevEff);\n nextPos = nextEff > blendStart\n ? mix(bAtBlend, adjustedTgt, (nextEff - blendStart) / (1.0 - blendStart))\n : bezier(adjustedSrc, controlPoint, adjustedTgt, nextEff);\n } else {\n prevPos = mix(adjustedSrc, adjustedTgt, prevEff);\n nextPos = mix(adjustedSrc, adjustedTgt, nextEff);\n }\n\n vec4 prevClip = mvp * vec4(prevPos, 1.0);\n vec4 nextClip = mvp * vec4(nextPos, 1.0);\n\n vec2 currentP = fix(currentClip, aspect);\n vec2 prevP = fix(prevClip, aspect);\n vec2 nextP = fix(nextClip, aspect);\n\n float baseWidth = edgeWidth * lineWidthScale;\n if (edgeSelected > 0.5) baseWidth += 2.0 * lineWidthScale;\n\n float pixelWidth = currentClip.w;\n float w;\n\n // Two width regimes (mirrored in arrow.vert.glsl):\n // - World-scaled (legacy parity, default): w is clip-space constant, so\n // screen size = w/clip.w shrinks with distance \u2014 edges visibly grow on\n // zoom-in / shrink on zoom-out like legacy.\n // - Screen-constant: multiply by clip.w so it cancels in the perspective\n // divide. Used when nodes are at fixed screen size (fixedSize), and in\n // mapMode where camera-z range is huge (city-street \u2194 continent) and a\n // world-scaled line would either vanish or blow up.\n //\n // edgeScale = base screen-pixel thickness for the screen-constant regime\n // (fixedSize bumps it to 0.15 to match larger fixedSize nodes).\n // worldScale = 0.16 matches legacy clip-space width: legacy used 0.008\n // directly, new engine multiplies through lineWidthScale (default 0.05),\n // so 0.008 / 0.05 = 0.16 gives a default edge the same legacy look.\n float edgeScale = 1.0 / 15.0;\n float worldScale = 0.16;\n if (mapMode > 0.5 || fixedSize > 0.5) {\n float k = fixedSize > 0.5 ? 0.15 : edgeScale;\n w = 1.8 * pixelWidth * baseWidth * k;\n } else {\n w = 1.8 * baseWidth * worldScale;\n }\n\n vec2 dir;\n if (nextP == currentP) dir = normalize(currentP - prevP);\n else if (prevP == currentP) dir = normalize(nextP - currentP);\n else dir = normalize(normalize(currentP - prevP) + normalize(nextP - currentP));\n\n vec2 normal = vec2(-dir.y, dir.x);\n normal.x /= aspect;\n // Tube glow: widen the strip so the soft halo has room outside the solid core.\n // The visible solid core stays at the original width (the fragment uses coreFrac).\n w *= 1.0 + vTubeGlow * GLOW_WIDEN_K;\n normal *= 0.5 * w;\n\n vec4 finalPosition = currentClip;\n finalPosition.xy += normal * side;\n\n // Globe mode: per-vertex back-face culling (same approach as nodes).\n // depthTest is disabled in globe mode, so we hide back-facing edges here.\n // Each vertex along the edge is checked individually using its actual\n // position on the great-circle arc \u2014 not just the midpoint.\n // This correctly hides the portion of an edge that crosses the globe horizon.\n if (sphereRadius > 0.001) {\n vec3 wN = normalize(mat3(modelMatrix) * normalize(edgePosition));\n vec3 wP = (modelMatrix * vec4(edgePosition, 1.0)).xyz;\n if (dot(wN, normalize(cameraPosition - wP)) < 0.0) {\n vOpacity = 0.0;\n }\n }\n\n gl_Position = finalPosition;\n}\n";
14510
14516
 
14511
14517
  // src/shaders/edge.frag.glsl
14512
14518
  var edge_frag_default = "precision highp float;\n\nconst float GLOW_WIDEN_K = 3.0; // MUST match edge.vert.glsl\nconst float GLOW_GAIN = 1.2; // additive rgb gain\nconst float GLOW_ALPHA = 0.6; // halo alpha ceiling\n\nuniform float globalUseDash;\nuniform float globalDashArray;\nuniform float globalDashOffset;\nuniform float globalDashRatio;\nuniform float visibility;\nuniform float alphaTest;\n\n// Time uniform for shader-driven effects\nuniform float time;\n\n// Hover dim: when a node/edge is hovered, non-neighbor edges fade to\n// u_hoverDimOpacity. u_hoverProgress animates 0\u21921 over the hover-in duration.\nuniform float u_hoverProgress;\nuniform float u_hoverDimOpacity;\n\nvarying vec4 vColor;\nvarying float vCounters;\nvarying float vOpacity;\nvarying float vUseDash;\nvarying float vSelected;\nvarying float vFlow;\nvarying float vGlow;\nvarying float vHoverDim;\nvarying float vSide;\nvarying float vTubeGlow;\n\nvoid main() {\n vec4 c = vColor;\n\n if (c.a < alphaTest) discard;\n\n if (vUseDash > 0.5) {\n c.a *= ceil(mod(vCounters, 0.05) - 0.025);\n } else if (globalUseDash > 0.5) {\n c.a *= ceil(mod(vCounters - globalDashOffset, globalDashArray) - (globalDashArray * globalDashRatio));\n }\n\n gl_FragColor = c;\n gl_FragColor.a *= vOpacity * step(vCounters, visibility);\n\n if (vSelected > 0.5) {\n gl_FragColor.rgb = gl_FragColor.rgb * 1.2 + vec3(0.0, 0.2, 0.5) * 0.3;\n }\n\n // Flow particles: dots moving along edge (speed controlled by vFlow value)\n if (vFlow > 0.0) {\n float flowSpeed = 0.8;\n float gap = 0.08;\n float dotSize = 0.015;\n float phase = mod(vCounters - time * flowSpeed, gap);\n float dist = abs(phase - gap * 0.5) / dotSize;\n if (dist < 1.0) {\n float flowGlow = (1.0 - dist * dist) * vFlow;\n gl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(0.2, 1.0, 0.5), flowGlow * 0.9);\n gl_FragColor.a = max(gl_FragColor.a, flowGlow * 0.8);\n }\n }\n\n // Glow stream: traveling light along edge\n if (vGlow > 0.0) {\n float glowSpeed = 0.5;\n float tailLen = 0.15;\n float headPos = fract(time * glowSpeed);\n float d = vCounters - headPos;\n if (d < 0.0) d += 1.0;\n if (d < tailLen) {\n float intensity = (1.0 - d / tailLen);\n intensity = intensity * intensity * vGlow;\n gl_FragColor.rgb += vec3(0.3, 0.6, 1.0) * intensity * 1.5;\n gl_FragColor.a = max(gl_FragColor.a, intensity * 0.7);\n }\n }\n\n // Tube glow \u2192 additive light (premultiplied-alpha pipeline). In the halo\n // region we KILL the solid base (a=0) and emit additive glow instead; the\n // solid core (|vSide| < coreFrac) is left untouched.\n vec3 glowAdd = vec3(0.0);\n if (vTubeGlow > 0.0) {\n float coreFrac = 1.0 / (1.0 + vTubeGlow * GLOW_WIDEN_K);\n float a = abs(vSide);\n if (a > coreFrac) {\n float preA = gl_FragColor.a; // dash/visibility/opacity mask\n float edgeDist = (a - coreFrac) / max(1.0 - coreFrac, 1e-3);\n float falloff = 1.0 - smoothstep(0.0, 1.0, edgeDist);\n gl_FragColor.a = 0.0; // no solid fill in the halo region\n glowAdd = vColor.rgb * falloff * GLOW_GAIN * step(0.0001, preA);\n }\n }\n\n // Hover dim (straight alpha) \u2014 also dims residual glow.\n float hoverDimMul = mix(1.0, u_hoverDimOpacity, vHoverDim * u_hoverProgress);\n gl_FragColor.a *= hoverDimMul;\n glowAdd *= hoverDimMul;\n\n // Premultiplied-alpha output: premultiply the solid part, then add additive glow.\n gl_FragColor.rgb *= gl_FragColor.a;\n gl_FragColor.rgb += glowAdd;\n\n // Keep additive-only pixels (a\u22480 but glow present).\n if (gl_FragColor.a < 0.01 && dot(glowAdd, glowAdd) < 1e-8) discard;\n}\n";
@@ -14518,7 +14524,7 @@ var picking_vert_default = "// Mirrors node.vert.glsl billboard math. Intentiona
14518
14524
  var picking_frag_default = "precision highp float;\n\nvarying vec3 vIdColor;\nvarying float vHidden;\nvarying vec2 vUv;\n\nuniform float useCircle;\n\nvoid main() {\n if (vHidden > 0.5) discard;\n\n if (useCircle > 0.5) {\n float r = length(vUv - vec2(0.5));\n if (r > 0.5) discard;\n }\n\n gl_FragColor = vec4(vIdColor, 1.0);\n}\n";
14519
14525
 
14520
14526
  // src/shaders/arrow.vert.glsl
14521
- var arrow_vert_default = "precision highp float;\n\nuniform sampler2D positionTexture;\nuniform float textureSize;\nuniform float spaceSize;\nuniform float useCurve;\nuniform vec2 resolution;\nuniform float fixedSize;\nuniform float nodeSizeScale;\nuniform float mapMode;\nuniform float mapDamping;\nuniform float mapMaxGrowth; // shared semantics with node.vert.glsl; -1.0 = Infinity sentinel\nuniform float sphereRadius;\n\n// Per-instance attributes\nattribute float sourceIndex;\nattribute float targetIndex;\nattribute vec3 arrowColor;\nattribute float arrowOpacity;\nattribute vec3 arrowScale;\nattribute float arrowRotation;\nattribute float targetSize;\nattribute float sourceSize;\nattribute vec3 controlOffset;\nattribute float edgeSelected;\n// Hover-neighbor-highlight: packed `target + start_ts * 2`. Low bit = the\n// target dim state (0/1); upper 23 bits = ms-since-epoch (mod 2^19) when\n// the target last flipped. Start = 0 is a sentinel: never animated \u2192 no\n// fade, render at target.\nattribute float aHoverDim;\n\nuniform float u_hoverTime;\nuniform float u_hoverDuration;\n\nuniform float defaultEdgeShape;\nuniform float radialAxis;\n\nvarying vec3 vColor;\nvarying float vOpacity;\nvarying float vSelected;\nvarying float vHoverDim;\n\nvec3 samplePosition(float idx) {\n float texX = mod(idx, textureSize) + 0.5;\n float texY = floor(idx / textureSize) + 0.5;\n vec2 texCoord = vec2(texX, texY) / textureSize;\n return texture2D(positionTexture, texCoord).xyz;\n}\n\n// Apply quaternion rotation to position (matches CPU quaternion() helper)\nvec3 applyQuaternion(vec3 pos, vec4 q) {\n return pos + 2.0 * cross(q.xyz, cross(q.xyz, pos) + q.w * pos);\n}\n\n// Build rotation matrix around axis - matches lineCloud.js rotationMatrix()\nmat4 rotationMatrix(vec3 axis, float angle) {\n axis = normalize(axis);\n float s = sin(angle);\n float c = cos(angle);\n float oc = 1.0 - c;\n return mat4(\n oc*axis.x*axis.x+c, oc*axis.x*axis.y-axis.z*s, oc*axis.z*axis.x+axis.y*s, 0.0,\n oc*axis.x*axis.y+axis.z*s, oc*axis.y*axis.y+c, oc*axis.y*axis.z-axis.x*s, 0.0,\n oc*axis.z*axis.x-axis.y*s, oc*axis.y*axis.z+axis.x*s, oc*axis.z*axis.z+c, 0.0,\n 0.0, 0.0, 0.0, 1.0);\n}\n\n// Compute direction quaternion - matches lineCloud.js getDirection()\nvec4 getDirectionQuaternion(vec3 dir) {\n vec4 q;\n if (dir.y > 0.99999) {\n q = vec4(0.0, 0.0, 0.0, 1.0);\n } else if (dir.y < -0.99999) {\n q = vec4(1.0, 0.0, 0.0, 0.0);\n } else {\n vec3 axis = normalize(vec3(dir.z, 0.0, -dir.x));\n float angle = acos(dir.y);\n float s = sin(angle * 0.5);\n float c = cos(angle * 0.5);\n q = vec4(axis * s, c);\n }\n return q;\n}\n\n// Compute perpendicular vector to a direction (matches edge shader)\nvec3 computePerpendicular(vec3 dir) {\n vec3 ref = abs(dir.z) < 0.99 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\n return normalize(cross(dir, ref));\n}\n\n// Rotate vector around axis by angle (matches edge shader)\nvec3 rotateAroundAxis(vec3 v, vec3 axis, float angle) {\n float c = cos(angle);\n float s = sin(angle);\n return v * c + cross(axis, v) * s + axis * dot(axis, v) * (1.0 - c);\n}\n\n// Quadratic bezier evaluation\nvec3 bezier(vec3 p0, vec3 p1, vec3 p2, float t) {\n float t1 = 1.0 - t;\n return t1 * t1 * p0 + 2.0 * t1 * t * p1 + t * t * p2;\n}\n\n// Quadratic bezier tangent (derivative): B'(t) = 2(1-t)(P1-P0) + 2t(P2-P1)\nvec3 bezierTangent(vec3 p0, vec3 p1, vec3 p2, float t) {\n return 2.0 * (1.0 - t) * (p1 - p0) + 2.0 * t * (p2 - p1);\n}\n\n// Great-circle slerp + tangent-at-endpoint helpers. MUST stay in sync with\n// edge.vert.glsl `slerp` so the arrow tip sits exactly on the arc geometry\n// the edge shader rendered. See sphereMath.ts for the CPU mirror used by\n// EdgeTextCloud and the acceptance probes.\nvec3 slerp(vec3 a, vec3 b, float t) {\n float cosOmega = clamp(dot(a, b), -1.0, 1.0);\n float omega = acos(cosOmega);\n float sinOmega = sin(omega);\n if (sinOmega < 1e-5) return normalize(mix(a, b, t));\n return (sin((1.0 - t) * omega) * a + sin(t * omega) * b) / sinOmega;\n}\n\n// Unit tangent at the slerp endpoint (t = 1). Used to orient the arrowhead\n// along the arc rather than along the chord \u2014 without this, arrowheads for\n// long-arc edges (e.g. Paris\u2192Tokyo) point in the wrong direction at the\n// target node.\nvec3 arcTangentAtEnd(vec3 a, vec3 b) {\n float cosOmega = clamp(dot(a, b), -1.0, 1.0);\n float omega = acos(cosOmega);\n float sinOmega = sin(omega);\n if (sinOmega < 1e-5) return normalize(b - a);\n return normalize((cosOmega * b - a) * (omega / sinOmega));\n}\n\nvoid main() {\n vColor = arrowColor;\n vOpacity = arrowOpacity;\n vSelected = edgeSelected;\n // Unpack hoverDim: low bit = target, upper bits = start timestamp.\n float _hoverTarget = mod(aHoverDim, 2.0);\n float _hoverStart = floor(aHoverDim / 2.0);\n float _hoverDiff = u_hoverTime - _hoverStart;\n if (_hoverDiff < 0.0) _hoverDiff += 524288.0;\n float _hoverT = _hoverStart < 0.5\n ? 1.0\n : clamp(_hoverDiff / max(u_hoverDuration, 1.0), 0.0, 1.0);\n float _hoverEased = _hoverT < 0.5\n ? 4.0 * _hoverT * _hoverT * _hoverT\n : 1.0 - pow(-2.0 * _hoverT + 2.0, 3.0) / 2.0;\n vHoverDim = mix(1.0 - _hoverTarget, _hoverTarget, _hoverEased);\n\n // Self-loops are drawn by SelfLoopCloud, not here. The CPU side zeros all\n // attributes (arrowScale, arrowOpacity, etc.) hoping the cone collapses to a\n // point, but that left a visible black phantom in some drivers (degenerate\n // triangles aren't reliably culled, or pos*scale=0 hits FP edge cases).\n // Ejecting the vertex outside clip space is the only deterministic discard.\n if (sourceIndex == targetIndex) {\n gl_Position = vec4(2.0, 2.0, 2.0, 1.0);\n return;\n }\n\n vec3 srcPos = samplePosition(sourceIndex);\n vec3 tgtPos = samplePosition(targetIndex);\n\n vec3 edgeDir = tgtPos - srcPos;\n float edgeLength = length(edgeDir);\n // Degenerate-fallback threshold MUST match edge.vert.glsl. Old 0.001 was\n // too coarse for map mode (positions ~0.06, typical chords ~1e-4..1e-3)\n // and caused arrows to flip to (0,1,0) \u2014 visible as \"arrows pointing\n // straight up\" in dense metro clusters. 1e-9 keeps the guard against\n // true zero-length self-overlap without false positives.\n vec3 edgeNorm = edgeLength > 1e-9 ? edgeDir / edgeLength : vec3(0.0, 1.0, 0.0);\n\n // Node world radius \u2014 MUST mirror node.vert.glsl pixelSize formula so the\n // arrow tip lands exactly on the visible bubble edge. In map mode this means\n // using the SAME soft-asymptote growth curve driven by the `mapMaxGrowth`\n // uniform; otherwise the arrow shader thinks the bubble is bigger than it\n // actually renders, and the arrow floats away from the bubble edge at deep\n // zoom. MUST stay in sync with node.vert.glsl / picking.vert.glsl.\n float srcViewZ = abs((modelViewMatrix * vec4(srcPos, 1.0)).z);\n float tgtViewZ = abs((modelViewMatrix * vec4(tgtPos, 1.0)).z);\n float maxPS = 4096.0;\n float srcPixDiam, tgtPixDiam;\n float srcScaled = sourceSize * nodeSizeScale;\n float tgtScaled = targetSize * nodeSizeScale;\n if (mapMode > 0.5) {\n float refDepth = 10.0;\n float srcRaw = pow(refDepth / srcViewZ, mapDamping);\n float tgtRaw = pow(refDepth / tgtViewZ, mapDamping);\n float srcGrowth, tgtGrowth;\n if (mapMaxGrowth < 0.0) {\n // Sentinel: Infinity \u2192 use raw values as-is (no cap)\n srcGrowth = srcRaw;\n tgtGrowth = tgtRaw;\n } else {\n // softKnee derived from mapMaxGrowth (= maxGrowth \xD7 0.5, preserves 4:2 ratio)\n float softKnee = mapMaxGrowth * 0.5;\n float A = mapMaxGrowth - softKnee;\n float srcOverflow = max(srcRaw - softKnee, 0.0);\n float tgtOverflow = max(tgtRaw - softKnee, 0.0);\n srcGrowth = min(srcRaw, softKnee) + (A * srcOverflow) / (A + srcOverflow);\n tgtGrowth = min(tgtRaw, softKnee) + (A * tgtOverflow) / (A + tgtOverflow);\n }\n srcPixDiam = min((srcScaled * 50.0 / refDepth) * srcGrowth, maxPS);\n tgtPixDiam = min((tgtScaled * 50.0 / refDepth) * tgtGrowth, maxPS);\n } else {\n srcPixDiam = min(srcScaled * 50.0 / srcViewZ, maxPS);\n tgtPixDiam = min(tgtScaled * 50.0 / tgtViewZ, maxPS);\n }\n // 0.96 factor matches edge.vert.glsl so both shaders build the same bezier\n // (cone apex at adjustedTgt = edge bezier endpoint). The edge shader caps\n // its rendered range so the visible line stops at the cone base; the\n // bezier itself still runs all the way to adjustedTgt, keeping the curve's\n // end-tangent identical to the arrow direction we derive here.\n float srcWorldRadius = srcPixDiam * srcViewZ / (projectionMatrix[1][1] * resolution.y) * 0.96;\n float tgtWorldRadius = tgtPixDiam * tgtViewZ / (projectionMatrix[1][1] * resolution.y) * 0.96;\n // Clamp offsets so they don't exceed 90% of edge length (must match edge shader).\n float totalOff = srcWorldRadius + tgtWorldRadius;\n float clampFac = totalOff > edgeLength * 0.9 ? (edgeLength * 0.9) / totalOff : 1.0;\n srcWorldRadius *= clampFac;\n tgtWorldRadius *= clampFac;\n float arrowLength = 4.0 * arrowScale.y; // Cone height * Y scale\n\n float curvature = controlOffset.x;\n float planeRotation = controlOffset.y;\n\n vec3 dir;\n vec3 arrowPos;\n\n float shape = controlOffset.z >= 0.0 ? controlOffset.z : defaultEdgeShape;\n\n // Globe-mode regular edges (shape < 1.5) ride a true great-circle arc;\n // arrowhead orientation = arc tangent at the target end. MUST stay in sync\n // with edge.vert.glsl's `isSphereEdge` branch.\n bool isSphereArrow = sphereRadius > 0.001 && shape < 1.5;\n\n if (shape > 1.5) {\n // --- Radial S-curve: arrow direction = cubic bezier tangent at t=1 ---\n // Tangent at t=1 of cubic bezier = 3*(P3-P2), where P2=(tgt.x, midY)\n vec3 eDir = tgtPos - srcPos;\n bool useVert;\n if (radialAxis > 1.5) { useVert = false; }\n else if (radialAxis > 0.5) { useVert = true; }\n else { useVert = abs(eDir.y) >= abs(eDir.x); }\n\n vec3 cp2;\n if (useVert) {\n float midY = (srcPos.y + tgtPos.y) * 0.5;\n cp2 = vec3(tgtPos.x, midY, tgtPos.z);\n } else {\n float midX = (srcPos.x + tgtPos.x) * 0.5;\n cp2 = vec3(midX, tgtPos.y, tgtPos.z);\n }\n vec3 tangent = tgtPos - cp2;\n dir = length(tangent) > 0.0001 ? normalize(tangent) : edgeNorm;\n arrowPos = tgtPos - dir * tgtWorldRadius;\n } else if (isSphereArrow) {\n // --- Globe great-circle arrow ---\n // Mirror edge.vert.glsl: arc end position = dirTgt * R + perp * fanOff.\n // Tangent at the arc endpoint (used to orient the cone) = arcTangentAtEnd.\n vec3 edgeSrc = srcPos + edgeNorm * srcWorldRadius;\n vec3 edgeTgt = tgtPos - edgeNorm * tgtWorldRadius;\n vec3 dirSrcS = normalize(edgeSrc);\n vec3 dirTgtS = normalize(edgeTgt);\n float cosO = clamp(dot(dirSrcS, dirTgtS), -1.0, 1.0);\n float omegaS = acos(cosO);\n float sinO = sin(omegaS);\n vec3 planeNormalS = sinO < 1e-5\n ? vec3(0.0, 1.0, 0.0)\n : normalize(cross(dirSrcS, dirTgtS));\n vec3 perpAtTgt = normalize(cross(dirTgtS, planeNormalS));\n float fanOff = curvature * sin(omegaS * 0.5) * sphereRadius;\n dir = arcTangentAtEnd(dirSrcS, dirTgtS);\n arrowPos = dirTgtS * sphereRadius + perpAtTgt * fanOff;\n } else if ((sphereRadius > 0.001 && abs(curvature) < 0.001 && shape < 0.5) || shape > 0.5 || abs(curvature) > 0.001) {\n // --- Curve / Globe arc: unified bezier arrow alignment ---\n // Control point math MUST mirror edge.vert.glsl exactly so the arrow's\n // tangent direction lands on the actual rendered curve. Any divergence\n // here makes the arrow head point along a different bezier and visibly\n // floats off the curve at the node boundary.\n bool isGlobe = sphereRadius > 0.001 && abs(curvature) < 0.001 && shape < 0.5;\n float effCurvature = curvature;\n if (shape > 0.5 && shape < 1.5 && abs(curvature) < 0.001) { effCurvature = 0.15; }\n vec3 edgeSrc = srcPos + edgeNorm * srcWorldRadius;\n vec3 edgeTgt = tgtPos - edgeNorm * tgtWorldRadius;\n vec3 midPoint = (edgeSrc + edgeTgt) * 0.5;\n\n // Bulge direction (matches edge.vert.glsl): in map mode use the camera's\n // up-in-model derived from modelViewMatrix so the bezier always bulges\n // toward viewport up; outside map mode fall back to the legacy lateral\n // cross-product perpendicular.\n vec3 perp;\n if (mapMode > 0.5) {\n vec3 camUpInModel = vec3(\n modelViewMatrix[0][1],\n modelViewMatrix[1][1],\n modelViewMatrix[2][1]\n );\n vec3 proj = camUpInModel - dot(camUpInModel, edgeNorm) * edgeNorm;\n float l = length(proj);\n perp = l > 0.001 ? proj / l : computePerpendicular(edgeNorm);\n } else {\n perp = computePerpendicular(edgeNorm);\n }\n if (abs(planeRotation) > 0.001) {\n perp = rotateAroundAxis(perp, edgeNorm, planeRotation);\n }\n\n // Bulge magnitude: same regime as edge.vert.glsl \u2014 synthesized for\n // globeStraight, effCurvature \xD7 edgeLength otherwise.\n float bulgeMag = isGlobe\n ? edgeLength * 0.15\n : effCurvature * edgeLength;\n vec3 controlPoint = midPoint + perp * bulgeMag;\n\n // Arrow direction from bezier tangent near endpoint (matches edge straightening)\n vec3 bAt85 = bezier(edgeSrc, controlPoint, edgeTgt, 0.85);\n dir = normalize(edgeTgt - bAt85);\n arrowPos = edgeTgt;\n } else {\n // --- Straight edge mode ---\n dir = edgeNorm;\n arrowPos = tgtPos - dir * tgtWorldRadius;\n }\n\n // Compute direction quaternion from arrow direction\n vec4 qDirection = getDirectionQuaternion(dir);\n\n // Transform vertex:\n // 1. Scale\n // 2. Apply direction quaternion\n // 3. Translate to arrow position\n vec3 pos = position;\n vec3 scale = arrowScale;\n if (edgeSelected > 0.5) { scale.x *= 3.0; scale.z *= 3.0; }\n // Two arrow sizing regimes (must match edge.vert.glsl width regimes):\n // - World-scaled (legacy parity, default): arrowScale buffer values are\n // interpreted as world-space scale of the cone geometry; perspective\n // does the rest, so arrows shrink/grow with zoom like edges.\n // - Screen-constant: multiply by tgtWorldRadius so the arrow size tracks\n // the node's projected on-screen radius \u2014 necessary in mapMode where\n // camera-z range is too large for world units to look right, and in\n // fixedSize mode where nodes are already screen-constant.\n //\n // X/Z (base width) and Y (length) take DIFFERENT multipliers because the\n // base arrowScale buffer (0.012, 0.035, 0.012) bakes in a ~2.92\xD7 ratio of\n // height-multiplier to radius-multiplier; with three.js cone geometry\n // (height=4 along Y, base radius=1 at scale 1) a uniform per-axis \xD7 3.0\n // would render an 11.7:1 height-to-base-radius needle \u2014 visually a line\n // extension rather than a recognizable arrow. Non-map mode fixes that by\n // `scale.y *= 0.3` AFTER the 1:1 buffer scale, landing on a 3.5:1 cone.\n // Mirror that proportion here by giving the width axes a larger multiplier\n // so the rendered aspect (X:Y of final scale \xD7 geometry aspect) lands\n // around 3:1.\n if (mapMode > 0.5 || fixedSize > 0.5) {\n scale.x *= tgtWorldRadius * 18.0;\n scale.y *= tgtWorldRadius * 4.0;\n scale.z *= tgtWorldRadius * 18.0;\n } else {\n // arrowScale.y default (0.035) was tuned for the screen-constant path\n // where it gets multiplied by tgtWorldRadius * 3. In the world-scaled\n // path that multiplier is gone, so the cone would render ~3.5x longer\n // than legacy. Bring length back to legacy proportions (~3x cone radius).\n scale.y *= 0.3;\n // Floor against node radius: world-scaled cone is constant in world units\n // (lineWidth-driven), so on hubs sized by sizeByDegree / per-node setSize\n // the arrow:radius ratio collapses and the cone gets swallowed by the\n // node's soft edge. Mirror the screen-constant ratio (X/Z = radius * 0.216,\n // Y = radius * 0.14) as a lower bound \u2014 small nodes pass through\n // unchanged because their radius-derived size is below the lineWidth\n // baseline; only big nodes get bumped up to a visible cone.\n float growX = tgtWorldRadius * 0.216;\n float growY = tgtWorldRadius * 0.140;\n scale.x = max(scale.x, growX);\n scale.y = max(scale.y, growY);\n scale.z = max(scale.z, growX);\n }\n pos *= scale;\n pos = applyQuaternion(pos, qDirection);\n pos += arrowPos;\n\n vec4 mvPosition = modelViewMatrix * vec4(pos, 1.0);\n gl_Position = projectionMatrix * mvPosition;\n\n // Globe mode: vertex-level back-face culling.\n // depthTest is disabled in globe mode, so we hide back-facing arrows here.\n if (sphereRadius > 0.001) {\n vec3 wN = normalize(mat3(modelMatrix) * normalize(arrowPos));\n vec3 wP = (modelMatrix * vec4(arrowPos, 1.0)).xyz;\n if (dot(wN, normalize(cameraPosition - wP)) < 0.0) {\n vOpacity = 0.0;\n }\n }\n}\n";
14527
+ var arrow_vert_default = "precision highp float;\n\nuniform sampler2D positionTexture;\nuniform float textureSize;\nuniform float spaceSize;\nuniform float useCurve;\nuniform vec2 resolution;\nuniform float fixedSize;\nuniform float nodeSizeScale;\nuniform float mapMode;\nuniform float mapDamping;\nuniform float mapMaxGrowth; // shared semantics with node.vert.glsl; -1.0 = Infinity sentinel\nuniform float sphereRadius;\n\n// Per-instance attributes\nattribute float sourceIndex;\nattribute float targetIndex;\nattribute vec3 arrowColor;\nattribute float arrowOpacity;\nattribute vec3 arrowScale;\nattribute float arrowRotation;\nattribute float targetSize;\nattribute float sourceSize;\nattribute vec3 controlOffset;\nattribute float edgeSelected;\n// Hover-neighbor-highlight: packed `target + start_ts * 2`. Low bit = the\n// target dim state (0/1); upper 23 bits = ms-since-epoch (mod 2^19) when\n// the target last flipped. Start = 0 is a sentinel: never animated \u2192 no\n// fade, render at target.\nattribute float aHoverDim;\n\nuniform float u_hoverTime;\nuniform float u_hoverDuration;\n\nuniform float defaultEdgeShape;\nuniform float radialAxis;\n\nvarying vec3 vColor;\nvarying float vOpacity;\nvarying float vSelected;\nvarying float vHoverDim;\n\nvec3 samplePosition(float idx) {\n float texX = mod(idx, textureSize) + 0.5;\n float texY = floor(idx / textureSize) + 0.5;\n vec2 texCoord = vec2(texX, texY) / textureSize;\n return texture2D(positionTexture, texCoord).xyz;\n}\n\n// Apply quaternion rotation to position (matches CPU quaternion() helper)\nvec3 applyQuaternion(vec3 pos, vec4 q) {\n return pos + 2.0 * cross(q.xyz, cross(q.xyz, pos) + q.w * pos);\n}\n\n// Build rotation matrix around axis - matches lineCloud.js rotationMatrix()\nmat4 rotationMatrix(vec3 axis, float angle) {\n axis = normalize(axis);\n float s = sin(angle);\n float c = cos(angle);\n float oc = 1.0 - c;\n return mat4(\n oc*axis.x*axis.x+c, oc*axis.x*axis.y-axis.z*s, oc*axis.z*axis.x+axis.y*s, 0.0,\n oc*axis.x*axis.y+axis.z*s, oc*axis.y*axis.y+c, oc*axis.y*axis.z-axis.x*s, 0.0,\n oc*axis.z*axis.x-axis.y*s, oc*axis.y*axis.z+axis.x*s, oc*axis.z*axis.z+c, 0.0,\n 0.0, 0.0, 0.0, 1.0);\n}\n\n// Compute direction quaternion - matches lineCloud.js getDirection()\nvec4 getDirectionQuaternion(vec3 dir) {\n vec4 q;\n if (dir.y > 0.99999) {\n q = vec4(0.0, 0.0, 0.0, 1.0);\n } else if (dir.y < -0.99999) {\n q = vec4(1.0, 0.0, 0.0, 0.0);\n } else {\n vec3 axis = normalize(vec3(dir.z, 0.0, -dir.x));\n float angle = acos(dir.y);\n float s = sin(angle * 0.5);\n float c = cos(angle * 0.5);\n q = vec4(axis * s, c);\n }\n return q;\n}\n\n// Compute perpendicular vector to a direction (matches edge shader)\nvec3 computePerpendicular(vec3 dir) {\n vec3 ref = abs(dir.z) < 0.99 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\n return normalize(cross(dir, ref));\n}\n\n// Rotate vector around axis by angle (matches edge shader)\nvec3 rotateAroundAxis(vec3 v, vec3 axis, float angle) {\n float c = cos(angle);\n float s = sin(angle);\n return v * c + cross(axis, v) * s + axis * dot(axis, v) * (1.0 - c);\n}\n\n// Quadratic bezier evaluation\nvec3 bezier(vec3 p0, vec3 p1, vec3 p2, float t) {\n float t1 = 1.0 - t;\n return t1 * t1 * p0 + 2.0 * t1 * t * p1 + t * t * p2;\n}\n\n// Quadratic bezier tangent (derivative): B'(t) = 2(1-t)(P1-P0) + 2t(P2-P1)\nvec3 bezierTangent(vec3 p0, vec3 p1, vec3 p2, float t) {\n return 2.0 * (1.0 - t) * (p1 - p0) + 2.0 * t * (p2 - p1);\n}\n\n// Great-circle slerp + tangent-at-endpoint helpers. MUST stay in sync with\n// edge.vert.glsl `slerp` so the arrow tip sits exactly on the arc geometry\n// the edge shader rendered. See sphereMath.ts for the CPU mirror used by\n// EdgeTextCloud and the acceptance probes.\nvec3 slerp(vec3 a, vec3 b, float t) {\n float cosOmega = clamp(dot(a, b), -1.0, 1.0);\n float omega = acos(cosOmega);\n float sinOmega = sin(omega);\n if (sinOmega < 1e-5) return normalize(mix(a, b, t));\n return (sin((1.0 - t) * omega) * a + sin(t * omega) * b) / sinOmega;\n}\n\n// Unit tangent at the slerp endpoint (t = 1). Used to orient the arrowhead\n// along the arc rather than along the chord \u2014 without this, arrowheads for\n// long-arc edges (e.g. Paris\u2192Tokyo) point in the wrong direction at the\n// target node.\nvec3 arcTangentAtEnd(vec3 a, vec3 b) {\n float cosOmega = clamp(dot(a, b), -1.0, 1.0);\n float omega = acos(cosOmega);\n float sinOmega = sin(omega);\n if (sinOmega < 1e-5) return normalize(b - a);\n return normalize((cosOmega * b - a) * (omega / sinOmega));\n}\n\nvoid main() {\n vColor = arrowColor;\n vOpacity = arrowOpacity;\n vSelected = edgeSelected;\n // Unpack hoverDim: low bit = target, upper bits = start timestamp.\n float _hoverTarget = mod(aHoverDim, 2.0);\n float _hoverStart = floor(aHoverDim / 2.0);\n float _hoverDiff = u_hoverTime - _hoverStart;\n if (_hoverDiff < 0.0) _hoverDiff += 524288.0;\n float _hoverT = _hoverStart < 0.5\n ? 1.0\n : clamp(_hoverDiff / max(u_hoverDuration, 1.0), 0.0, 1.0);\n float _hoverEased = _hoverT < 0.5\n ? 4.0 * _hoverT * _hoverT * _hoverT\n : 1.0 - pow(-2.0 * _hoverT + 2.0, 3.0) / 2.0;\n vHoverDim = mix(1.0 - _hoverTarget, _hoverTarget, _hoverEased);\n\n // Self-loops are drawn by SelfLoopCloud, not here. The CPU side zeros all\n // attributes (arrowScale, arrowOpacity, etc.) hoping the cone collapses to a\n // point, but that left a visible black phantom in some drivers (degenerate\n // triangles aren't reliably culled, or pos*scale=0 hits FP edge cases).\n // Ejecting the vertex outside clip space is the only deterministic discard.\n if (sourceIndex == targetIndex) {\n gl_Position = vec4(2.0, 2.0, 2.0, 1.0);\n return;\n }\n\n vec3 srcPos = samplePosition(sourceIndex);\n vec3 tgtPos = samplePosition(targetIndex);\n\n vec3 edgeDir = tgtPos - srcPos;\n float edgeLength = length(edgeDir);\n // Degenerate-fallback threshold MUST match edge.vert.glsl. Old 0.001 was\n // too coarse for map mode (positions ~0.06, typical chords ~1e-4..1e-3)\n // and caused arrows to flip to (0,1,0) \u2014 visible as \"arrows pointing\n // straight up\" in dense metro clusters. 1e-9 keeps the guard against\n // true zero-length self-overlap without false positives.\n vec3 edgeNorm = edgeLength > 1e-9 ? edgeDir / edgeLength : vec3(0.0, 1.0, 0.0);\n\n // Node world radius \u2014 MUST mirror node.vert.glsl pixelSize formula so the\n // arrow tip lands exactly on the visible bubble edge. In map mode this means\n // using the SAME soft-asymptote growth curve driven by the `mapMaxGrowth`\n // uniform; otherwise the arrow shader thinks the bubble is bigger than it\n // actually renders, and the arrow floats away from the bubble edge at deep\n // zoom. MUST stay in sync with node.vert.glsl / picking.vert.glsl.\n float srcViewZ = abs((modelViewMatrix * vec4(srcPos, 1.0)).z);\n float tgtViewZ = abs((modelViewMatrix * vec4(tgtPos, 1.0)).z);\n float maxPS = 4096.0;\n float srcPixDiam, tgtPixDiam;\n float srcScaled = sourceSize * nodeSizeScale;\n float tgtScaled = targetSize * nodeSizeScale;\n if (mapMode > 0.5) {\n float refDepth = 10.0;\n float srcRaw = pow(refDepth / srcViewZ, mapDamping);\n float tgtRaw = pow(refDepth / tgtViewZ, mapDamping);\n float srcGrowth, tgtGrowth;\n if (mapMaxGrowth < 0.0) {\n // Sentinel: Infinity \u2192 use raw values as-is (no cap)\n srcGrowth = srcRaw;\n tgtGrowth = tgtRaw;\n } else {\n // softKnee derived from mapMaxGrowth (= maxGrowth \xD7 0.5, preserves 4:2 ratio)\n float softKnee = mapMaxGrowth * 0.5;\n float A = mapMaxGrowth - softKnee;\n float srcOverflow = max(srcRaw - softKnee, 0.0);\n float tgtOverflow = max(tgtRaw - softKnee, 0.0);\n srcGrowth = min(srcRaw, softKnee) + (A * srcOverflow) / (A + srcOverflow);\n tgtGrowth = min(tgtRaw, softKnee) + (A * tgtOverflow) / (A + tgtOverflow);\n }\n srcPixDiam = min((srcScaled * 50.0 / refDepth) * srcGrowth, maxPS);\n tgtPixDiam = min((tgtScaled * 50.0 / refDepth) * tgtGrowth, maxPS);\n } else {\n srcPixDiam = min(srcScaled * 50.0 / srcViewZ, maxPS);\n tgtPixDiam = min(tgtScaled * 50.0 / tgtViewZ, maxPS);\n }\n // 0.96 factor matches edge.vert.glsl so both shaders build the same bezier\n // (cone apex at adjustedTgt = edge bezier endpoint). The edge shader caps\n // its rendered range so the visible line stops at the cone base; the\n // bezier itself still runs all the way to adjustedTgt, keeping the curve's\n // end-tangent identical to the arrow direction we derive here.\n float srcWorldRadius = srcPixDiam * srcViewZ / (projectionMatrix[1][1] * resolution.y) * 0.96;\n float tgtWorldRadius = tgtPixDiam * tgtViewZ / (projectionMatrix[1][1] * resolution.y) * 0.96;\n // Clamp offsets so they don't exceed 90% of edge length (must match edge shader).\n float totalOff = srcWorldRadius + tgtWorldRadius;\n float clampFac = totalOff > edgeLength * 0.9 ? (edgeLength * 0.9) / totalOff : 1.0;\n srcWorldRadius *= clampFac;\n tgtWorldRadius *= clampFac;\n float arrowLength = 4.0 * arrowScale.y; // Cone height * Y scale\n\n float curvature = controlOffset.x;\n float planeRotation = controlOffset.y;\n\n vec3 dir;\n vec3 arrowPos;\n\n float shape = controlOffset.z >= 0.0 ? controlOffset.z : defaultEdgeShape;\n\n // Globe-mode regular edges (shape < 1.5) ride a true great-circle arc;\n // arrowhead orientation = arc tangent at the target end. MUST stay in sync\n // with edge.vert.glsl's `isSphereEdge` branch.\n // MUST match edge.vert.glsl isSphereEdge gating: only geo endpoints (on the\n // sphere, |pos| ~= sphereRadius) ride the great-circle arrow. Non-geo (force)\n // arrows fall through to the curve branch so the arrowhead sits on the actual\n // rendered edge instead of radiating onto the sphere.\n float srcSphereDist = length(srcPos);\n float tgtSphereDist = length(tgtPos);\n float sphereBand = sphereRadius * 0.1;\n bool bothOnSphere = abs(srcSphereDist - sphereRadius) < sphereBand\n && abs(tgtSphereDist - sphereRadius) < sphereBand;\n bool isSphereArrow = sphereRadius > 0.001 && shape < 1.5 && bothOnSphere;\n\n if (shape > 1.5) {\n // --- Radial S-curve: arrow direction = cubic bezier tangent at t=1 ---\n // Tangent at t=1 of cubic bezier = 3*(P3-P2), where P2=(tgt.x, midY)\n vec3 eDir = tgtPos - srcPos;\n bool useVert;\n if (radialAxis > 1.5) { useVert = false; }\n else if (radialAxis > 0.5) { useVert = true; }\n else { useVert = abs(eDir.y) >= abs(eDir.x); }\n\n vec3 cp2;\n if (useVert) {\n float midY = (srcPos.y + tgtPos.y) * 0.5;\n cp2 = vec3(tgtPos.x, midY, tgtPos.z);\n } else {\n float midX = (srcPos.x + tgtPos.x) * 0.5;\n cp2 = vec3(midX, tgtPos.y, tgtPos.z);\n }\n vec3 tangent = tgtPos - cp2;\n dir = length(tangent) > 0.0001 ? normalize(tangent) : edgeNorm;\n arrowPos = tgtPos - dir * tgtWorldRadius;\n } else if (isSphereArrow) {\n // --- Globe great-circle arrow ---\n // Mirror edge.vert.glsl: arc end position = dirTgt * R + perp * fanOff.\n // Tangent at the arc endpoint (used to orient the cone) = arcTangentAtEnd.\n vec3 edgeSrc = srcPos + edgeNorm * srcWorldRadius;\n vec3 edgeTgt = tgtPos - edgeNorm * tgtWorldRadius;\n vec3 dirSrcS = normalize(edgeSrc);\n vec3 dirTgtS = normalize(edgeTgt);\n float cosO = clamp(dot(dirSrcS, dirTgtS), -1.0, 1.0);\n float omegaS = acos(cosO);\n float sinO = sin(omegaS);\n vec3 planeNormalS = sinO < 1e-5\n ? vec3(0.0, 1.0, 0.0)\n : normalize(cross(dirSrcS, dirTgtS));\n vec3 perpAtTgt = normalize(cross(dirTgtS, planeNormalS));\n float fanOff = curvature * sin(omegaS * 0.5) * sphereRadius;\n dir = arcTangentAtEnd(dirSrcS, dirTgtS);\n arrowPos = dirTgtS * sphereRadius + perpAtTgt * fanOff;\n } else if (shape > 0.5 || abs(curvature) > 0.001) {\n // --- Curve arrow: unified bezier arrow alignment ---\n // Control point math MUST mirror edge.vert.glsl exactly so the arrow's\n // tangent direction lands on the actual rendered curve. Any divergence\n // here makes the arrow head point along a different bezier and visibly\n // floats off the curve at the node boundary.\n // Globe-straight synthesis removed (mirror edge.vert.glsl isGlobeStraight=false):\n // non-geo straight arrows fall through to the plain straight branch below.\n bool isGlobe = false;\n float effCurvature = curvature;\n if (shape > 0.5 && shape < 1.5 && abs(curvature) < 0.001) { effCurvature = 0.15; }\n vec3 edgeSrc = srcPos + edgeNorm * srcWorldRadius;\n vec3 edgeTgt = tgtPos - edgeNorm * tgtWorldRadius;\n vec3 midPoint = (edgeSrc + edgeTgt) * 0.5;\n\n // Bulge direction (matches edge.vert.glsl): in map mode use the camera's\n // up-in-model derived from modelViewMatrix so the bezier always bulges\n // toward viewport up; outside map mode fall back to the legacy lateral\n // cross-product perpendicular.\n vec3 perp;\n if (mapMode > 0.5) {\n vec3 camUpInModel = vec3(\n modelViewMatrix[0][1],\n modelViewMatrix[1][1],\n modelViewMatrix[2][1]\n );\n vec3 proj = camUpInModel - dot(camUpInModel, edgeNorm) * edgeNorm;\n float l = length(proj);\n perp = l > 0.001 ? proj / l : computePerpendicular(edgeNorm);\n } else {\n perp = computePerpendicular(edgeNorm);\n }\n if (abs(planeRotation) > 0.001) {\n perp = rotateAroundAxis(perp, edgeNorm, planeRotation);\n }\n\n // Bulge magnitude: same regime as edge.vert.glsl \u2014 synthesized for\n // globeStraight, effCurvature \xD7 edgeLength otherwise.\n float bulgeMag = isGlobe\n ? edgeLength * 0.15\n : effCurvature * edgeLength;\n vec3 controlPoint = midPoint + perp * bulgeMag;\n\n // Arrow direction from bezier tangent near endpoint (matches edge straightening)\n vec3 bAt85 = bezier(edgeSrc, controlPoint, edgeTgt, 0.85);\n dir = normalize(edgeTgt - bAt85);\n arrowPos = edgeTgt;\n } else {\n // --- Straight edge mode ---\n dir = edgeNorm;\n arrowPos = tgtPos - dir * tgtWorldRadius;\n }\n\n // Compute direction quaternion from arrow direction\n vec4 qDirection = getDirectionQuaternion(dir);\n\n // Transform vertex:\n // 1. Scale\n // 2. Apply direction quaternion\n // 3. Translate to arrow position\n vec3 pos = position;\n vec3 scale = arrowScale;\n if (edgeSelected > 0.5) { scale.x *= 3.0; scale.z *= 3.0; }\n // Two arrow sizing regimes (must match edge.vert.glsl width regimes):\n // - World-scaled (legacy parity, default): arrowScale buffer values are\n // interpreted as world-space scale of the cone geometry; perspective\n // does the rest, so arrows shrink/grow with zoom like edges.\n // - Screen-constant: multiply by tgtWorldRadius so the arrow size tracks\n // the node's projected on-screen radius \u2014 necessary in mapMode where\n // camera-z range is too large for world units to look right, and in\n // fixedSize mode where nodes are already screen-constant.\n //\n // X/Z (base width) and Y (length) take DIFFERENT multipliers because the\n // base arrowScale buffer (0.012, 0.035, 0.012) bakes in a ~2.92\xD7 ratio of\n // height-multiplier to radius-multiplier; with three.js cone geometry\n // (height=4 along Y, base radius=1 at scale 1) a uniform per-axis \xD7 3.0\n // would render an 11.7:1 height-to-base-radius needle \u2014 visually a line\n // extension rather than a recognizable arrow. Non-map mode fixes that by\n // `scale.y *= 0.3` AFTER the 1:1 buffer scale, landing on a 3.5:1 cone.\n // Mirror that proportion here by giving the width axes a larger multiplier\n // so the rendered aspect (X:Y of final scale \xD7 geometry aspect) lands\n // around 3:1.\n if (mapMode > 0.5 || fixedSize > 0.5) {\n scale.x *= tgtWorldRadius * 18.0;\n scale.y *= tgtWorldRadius * 4.0;\n scale.z *= tgtWorldRadius * 18.0;\n } else {\n // arrowScale.y default (0.035) was tuned for the screen-constant path\n // where it gets multiplied by tgtWorldRadius * 3. In the world-scaled\n // path that multiplier is gone, so the cone would render ~3.5x longer\n // than legacy. Bring length back to legacy proportions (~3x cone radius).\n scale.y *= 0.3;\n // Floor against node radius: world-scaled cone is constant in world units\n // (lineWidth-driven), so on hubs sized by sizeByDegree / per-node setSize\n // the arrow:radius ratio collapses and the cone gets swallowed by the\n // node's soft edge. Mirror the screen-constant ratio (X/Z = radius * 0.216,\n // Y = radius * 0.14) as a lower bound \u2014 small nodes pass through\n // unchanged because their radius-derived size is below the lineWidth\n // baseline; only big nodes get bumped up to a visible cone.\n float growX = tgtWorldRadius * 0.216;\n float growY = tgtWorldRadius * 0.140;\n scale.x = max(scale.x, growX);\n scale.y = max(scale.y, growY);\n scale.z = max(scale.z, growX);\n }\n pos *= scale;\n pos = applyQuaternion(pos, qDirection);\n pos += arrowPos;\n\n vec4 mvPosition = modelViewMatrix * vec4(pos, 1.0);\n gl_Position = projectionMatrix * mvPosition;\n\n // Globe mode: vertex-level back-face culling.\n // depthTest is disabled in globe mode, so we hide back-facing arrows here.\n if (sphereRadius > 0.001) {\n vec3 wN = normalize(mat3(modelMatrix) * normalize(arrowPos));\n vec3 wP = (modelMatrix * vec4(arrowPos, 1.0)).xyz;\n if (dot(wN, normalize(cameraPosition - wP)) < 0.0) {\n vOpacity = 0.0;\n }\n }\n}\n";
14522
14528
 
14523
14529
  // src/shaders/arrow.frag.glsl
14524
14530
  var arrow_frag_default = "precision highp float;\n\nuniform float u_hoverProgress;\nuniform float u_hoverDimOpacity;\n\nvarying vec3 vColor;\nvarying float vOpacity;\nvarying float vSelected;\nvarying float vHoverDim;\n\nvoid main() {\n gl_FragColor = vec4(vColor, vOpacity);\n if (vSelected > 0.5) {\n gl_FragColor.rgb = gl_FragColor.rgb * 1.2 + vec3(0.0, 0.2, 0.5) * 0.3;\n }\n // Hover-neighbor-highlight: dim 2-hop arrows along with their edge lines.\n float hoverDimMul = mix(1.0, u_hoverDimOpacity, vHoverDim * u_hoverProgress);\n gl_FragColor.a *= hoverDimMul;\n if (gl_FragColor.a < 0.01) discard;\n}\n";
@@ -17351,7 +17357,7 @@ var GPUEdgeRenderer = class {
17351
17357
  };
17352
17358
 
17353
17359
  // src/react/GraphContext.tsx
17354
- import React30, { createContext as createContext2, useContext as useContext4, useState as useState23, useEffect as useEffect26, useRef as useRef22, useCallback as useCallback18 } from "react";
17360
+ import React30, { createContext as createContext2, useContext as useContext4, useState as useState23, useEffect as useEffect26, useRef as useRef22, useCallback as useCallback17 } from "react";
17355
17361
  import * as THREE46 from "three";
17356
17362
 
17357
17363
  // src/interaction/GraphControl.ts
@@ -19675,6 +19681,10 @@ var InteractionCoordinator = class {
19675
19681
  // Original enabled states (for restoration)
19676
19682
  this.graphControlWasEnabled = true;
19677
19683
  this.dragHandlerWasEnabled = true;
19684
+ // When true, GlobeControl (or another external control) owns background
19685
+ // pan/rotate gestures; coordinator skips them so the DragHandler stays
19686
+ // enabled and node-drag keeps working in globe mode.
19687
+ this._bgGestureExternal = false;
19678
19688
  this.picker = picker;
19679
19689
  this.dragHandler = dragHandler;
19680
19690
  this.graphControl = graphControl;
@@ -19693,6 +19703,16 @@ var InteractionCoordinator = class {
19693
19703
  get globeMode() {
19694
19704
  return this.config.globeMode;
19695
19705
  }
19706
+ /**
19707
+ * When true, an external control (GlobeControl) owns background pan/rotate
19708
+ * gestures, so the coordinator skips enterPanMode/enterRotateMode on
19709
+ * background mousedown. This keeps the DragHandler enabled so node-drag still
19710
+ * works in globe mode (otherwise enterPanMode disables it). Set by GlobeLayer
19711
+ * on mount, cleared on unmount. Node/group drags are unaffected.
19712
+ */
19713
+ setBackgroundGestureExternal(enabled) {
19714
+ this._bgGestureExternal = enabled;
19715
+ }
19696
19716
  /**
19697
19717
  * Set the PathSelectHandler for Shift+drag path selection.
19698
19718
  */
@@ -19772,12 +19792,14 @@ var InteractionCoordinator = class {
19772
19792
  return;
19773
19793
  }
19774
19794
  }
19795
+ if (this._bgGestureExternal) return;
19775
19796
  this.enterPanMode();
19776
19797
  }
19777
19798
  } else if (event.button === 2) {
19778
19799
  if (pickResult.type === "node" && pickResult.picked) {
19779
19800
  this.debug("Right click on node - context menu territory");
19780
19801
  } else {
19802
+ if (this._bgGestureExternal) return;
19781
19803
  this.enterRotateMode();
19782
19804
  }
19783
19805
  }
@@ -19801,6 +19823,10 @@ var InteractionCoordinator = class {
19801
19823
  case "rotate":
19802
19824
  return false;
19803
19825
  case "idle":
19826
+ if (!this.isEventOverCanvas(event)) {
19827
+ this.hoverHandler.onMouseLeave();
19828
+ return false;
19829
+ }
19804
19830
  this.hoverHandler.onMouseMove(screenX, screenY);
19805
19831
  return false;
19806
19832
  default:
@@ -19927,6 +19953,19 @@ var InteractionCoordinator = class {
19927
19953
  this.debug("Reset to idle state");
19928
19954
  }
19929
19955
  // ==================== Utilities ====================
19956
+ /**
19957
+ * True when the event originated on the renderer canvas itself, not on an
19958
+ * overlay element (panel / toolbar / legend) layered inside the container.
19959
+ * Mirrors the `event.target === renderer.domElement` guard used for
19960
+ * mousedown / click / contextmenu in InteractionManager. When the canvas
19961
+ * element is unavailable we fail open (treat as over-canvas) to avoid
19962
+ * silently disabling hover.
19963
+ */
19964
+ isEventOverCanvas(event) {
19965
+ const canvas = this.dragHandler.getRendererElement?.();
19966
+ if (!canvas) return true;
19967
+ return event.target === canvas;
19968
+ }
19930
19969
  debug(message) {
19931
19970
  if (this.config.debug) {
19932
19971
  console.log(`[InteractionCoordinator] ${message}`);
@@ -21569,7 +21608,11 @@ var _InteractionManager = class _InteractionManager {
21569
21608
  }
21570
21609
  }
21571
21610
  if (!this.drag.isDragging) {
21572
- this.hover.onMouseMove(x3, y3);
21611
+ if (event.target === this.renderer.domElement) {
21612
+ this.hover.onMouseMove(x3, y3);
21613
+ } else {
21614
+ this.hover.onMouseLeave();
21615
+ }
21573
21616
  }
21574
21617
  }
21575
21618
  handleMouseUp(event) {
@@ -25822,7 +25865,7 @@ function findFirstImage(properties) {
25822
25865
  }
25823
25866
 
25824
25867
  // src/react/layers/NodeInfoPanel.tsx
25825
- import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
25868
+ import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
25826
25869
  function useBlockNativeSceneEvents2(ref) {
25827
25870
  useEffect5(() => {
25828
25871
  const el = ref.current;
@@ -25835,7 +25878,17 @@ function useBlockNativeSceneEvents2(ref) {
25835
25878
  };
25836
25879
  }, [ref]);
25837
25880
  }
25838
- function NodeInfoPanel({ manager, store, container }) {
25881
+ function nodeColor(store, nodeId) {
25882
+ const idx = store.index.getNodeIndex(nodeId);
25883
+ const ns = store.nodeState;
25884
+ if (idx === void 0 || !ns) return "var(--gxr-accent)";
25885
+ const c2 = ns.colors;
25886
+ const r = Math.round((c2[idx * 3] ?? 0) * 255);
25887
+ const g = Math.round((c2[idx * 3 + 1] ?? 0) * 255);
25888
+ const b = Math.round((c2[idx * 3 + 2] ?? 0) * 255);
25889
+ return `rgb(${r}, ${g}, ${b})`;
25890
+ }
25891
+ function NodeInfoPanel({ manager, store, container, showExpandNeighbors, onExpandNeighbors }) {
25839
25892
  const [state, setState] = useState3(manager.state);
25840
25893
  const hasDraggedRef = useRef5(false);
25841
25894
  useEffect5(() => {
@@ -25850,7 +25903,9 @@ function NodeInfoPanel({ manager, store, container }) {
25850
25903
  store,
25851
25904
  container,
25852
25905
  manager,
25853
- hasDraggedRef
25906
+ hasDraggedRef,
25907
+ showExpandNeighbors,
25908
+ onExpandNeighbors
25854
25909
  }
25855
25910
  );
25856
25911
  }
@@ -25860,7 +25915,9 @@ function NodeInfoPanelInner({
25860
25915
  store,
25861
25916
  container,
25862
25917
  manager,
25863
- hasDraggedRef
25918
+ hasDraggedRef,
25919
+ showExpandNeighbors,
25920
+ onExpandNeighbors
25864
25921
  }) {
25865
25922
  const panelRef = useRef5(null);
25866
25923
  const dragTransformRef = useRef5({ x: 0, y: 0 });
@@ -25913,6 +25970,7 @@ function NodeInfoPanelInner({
25913
25970
  const header = headerRef.current;
25914
25971
  if (!header) return;
25915
25972
  const onMouseDown = (e) => {
25973
+ if (e.target.closest("[data-no-drag]")) return;
25916
25974
  e.preventDefault();
25917
25975
  hasDraggedRef.current = false;
25918
25976
  const startX = e.clientX;
@@ -25942,9 +26000,34 @@ function NodeInfoPanelInner({
25942
26000
  const title = resolveNodeTitle(node);
25943
26001
  const imageResult = findFirstImage(node.properties);
25944
26002
  const showImage = imageResult && !imageError;
25945
- const properties = node.properties;
25946
- const propEntries = Object.entries(properties);
25947
- const propCount = propEntries.length;
26003
+ const avatarColor = nodeColor(store, nodeId);
26004
+ const sourceRaw = node.properties["_source"];
26005
+ const sourceStr = sourceRaw === void 0 || sourceRaw === null ? "" : String(sourceRaw);
26006
+ const propEntries = Object.entries(node.properties).filter(([key, value]) => {
26007
+ if (key.startsWith("_")) return false;
26008
+ if (imageResult && key === imageResult.key) return false;
26009
+ if (String(value ?? "") === title) return false;
26010
+ return true;
26011
+ });
26012
+ const seen = /* @__PURE__ */ new Set();
26013
+ const relations = [];
26014
+ for (const n of store.queries.getNeighbors(nodeId)) {
26015
+ if (seen.has(n.nodeId)) continue;
26016
+ const neighbor = store.queries.getNode(n.nodeId);
26017
+ if (!neighbor) continue;
26018
+ seen.add(n.nodeId);
26019
+ relations.push({
26020
+ id: n.nodeId,
26021
+ title: resolveNodeTitle(neighbor),
26022
+ category: neighbor.category,
26023
+ color: nodeColor(store, n.nodeId)
26024
+ });
26025
+ }
26026
+ const navigateTo = (id) => {
26027
+ store.selectNodes([id]);
26028
+ manager.show(id, rawPosition);
26029
+ };
26030
+ const SECTION_PAD = "14px 16px";
25948
26031
  return /* @__PURE__ */ jsxs3(
25949
26032
  "div",
25950
26033
  {
@@ -25956,9 +26039,12 @@ function NodeInfoPanelInner({
25956
26039
  top: clampedPos.top,
25957
26040
  zIndex: 1e4,
25958
26041
  width: 320,
26042
+ maxHeight: "82vh",
26043
+ display: "flex",
26044
+ flexDirection: "column",
25959
26045
  background: "var(--gxr-panel-bg)",
25960
26046
  border: `1px solid var(--gxr-panel-border)`,
25961
- borderRadius: 8,
26047
+ borderRadius: 12,
25962
26048
  boxShadow: "var(--gxr-shadow)",
25963
26049
  overflow: "hidden",
25964
26050
  fontFamily: "system-ui, -apple-system, sans-serif",
@@ -25971,137 +26057,224 @@ function NodeInfoPanelInner({
25971
26057
  {
25972
26058
  ref: headerRef,
25973
26059
  style: {
25974
- padding: "10px 14px",
25975
- background: "var(--gxr-panel-header-bg)",
25976
- borderBottom: `1px solid var(--gxr-panel-border)`,
26060
+ padding: SECTION_PAD,
25977
26061
  display: "flex",
25978
- justifyContent: "space-between",
25979
- alignItems: "center",
26062
+ alignItems: "flex-start",
26063
+ gap: 14,
25980
26064
  cursor: "move",
25981
26065
  userSelect: "none"
25982
26066
  },
25983
26067
  children: [
25984
- /* @__PURE__ */ jsx4("span", { style: { color: "var(--gxr-accent)", fontWeight: 600 }, children: node.category }),
25985
- /* @__PURE__ */ jsx4(
25986
- "span",
25987
- {
25988
- onClick: () => manager.hide(),
25989
- style: { fontSize: 18, color: "var(--gxr-text-muted)", cursor: "pointer", lineHeight: 1 },
25990
- children: "\xD7"
25991
- }
25992
- )
25993
- ]
25994
- }
25995
- ),
25996
- showImage ? /* @__PURE__ */ jsxs3(
25997
- "div",
25998
- {
25999
- style: {
26000
- display: "flex",
26001
- padding: 14,
26002
- borderBottom: `1px solid var(--gxr-panel-border)`
26003
- },
26004
- children: [
26005
- /* @__PURE__ */ jsx4(
26068
+ showImage ? /* @__PURE__ */ jsx4(
26006
26069
  "img",
26007
26070
  {
26008
26071
  src: imageResult.url,
26009
26072
  onError: () => setImageError(true),
26073
+ style: { width: 52, height: 52, borderRadius: 12, objectFit: "cover", flexShrink: 0 }
26074
+ }
26075
+ ) : /* @__PURE__ */ jsx4(
26076
+ "div",
26077
+ {
26010
26078
  style: {
26011
- width: 88,
26012
- height: 108,
26013
- borderRadius: 6,
26014
- objectFit: "cover",
26079
+ width: 52,
26080
+ height: 52,
26081
+ borderRadius: 12,
26015
26082
  flexShrink: 0,
26016
- // Image content drop-shadow, not panel chrome — intentionally not tokenized.
26017
- boxShadow: "0 2px 8px rgba(0,0,0,0.3)"
26083
+ background: avatarColor,
26084
+ boxShadow: `0 0 18px ${avatarColor}55`
26018
26085
  }
26019
26086
  }
26020
26087
  ),
26021
- /* @__PURE__ */ jsxs3("div", { style: { marginLeft: 14, flex: 1, display: "flex", flexDirection: "column", justifyContent: "center" }, children: [
26022
- /* @__PURE__ */ jsx4("div", { style: { color: "var(--gxr-text-primary)", fontSize: 15, fontWeight: 600, marginBottom: 6 }, children: title }),
26088
+ /* @__PURE__ */ jsxs3("div", { style: { flex: 1, minWidth: 0 }, children: [
26023
26089
  /* @__PURE__ */ jsx4(
26024
26090
  "div",
26025
26091
  {
26026
26092
  style: {
26027
- color: "var(--gxr-accent)",
26028
- fontSize: 11,
26029
- background: "var(--gxr-accent-soft)",
26030
- display: "inline-block",
26031
- padding: "2px 8px",
26032
- borderRadius: 4,
26033
- width: "fit-content",
26034
- marginBottom: 8
26093
+ color: "var(--gxr-text-primary)",
26094
+ fontSize: 20,
26095
+ fontWeight: 700,
26096
+ lineHeight: 1.2,
26097
+ overflow: "hidden",
26098
+ textOverflow: "ellipsis",
26099
+ whiteSpace: "nowrap"
26035
26100
  },
26036
- children: node.category
26101
+ children: title
26037
26102
  }
26038
26103
  ),
26039
- /* @__PURE__ */ jsxs3("div", { style: { color: "var(--gxr-text-muted)", fontSize: 11 }, children: [
26040
- propCount,
26041
- " properties"
26104
+ /* @__PURE__ */ jsxs3("div", { style: { color: "var(--gxr-text-secondary)", fontSize: 13, marginTop: 4 }, children: [
26105
+ node.category,
26106
+ sourceStr && /* @__PURE__ */ jsxs3(Fragment2, { children: [
26107
+ " \xB7 ",
26108
+ /* @__PURE__ */ jsxs3("span", { style: { color: "var(--gxr-text-muted)" }, children: [
26109
+ "_source: ",
26110
+ sourceStr
26111
+ ] })
26112
+ ] })
26042
26113
  ] })
26043
- ] })
26114
+ ] }),
26115
+ /* @__PURE__ */ jsx4(
26116
+ "span",
26117
+ {
26118
+ "data-no-drag": true,
26119
+ onClick: () => manager.hide(),
26120
+ style: { fontSize: 20, color: "var(--gxr-text-muted)", cursor: "pointer", lineHeight: 1, flexShrink: 0 },
26121
+ children: "\xD7"
26122
+ }
26123
+ )
26044
26124
  ]
26045
26125
  }
26046
- ) : (
26047
- /* Title only (no image) */
26048
- /* @__PURE__ */ jsxs3("div", { style: { padding: "12px 14px", borderBottom: `1px solid var(--gxr-panel-border)` }, children: [
26049
- /* @__PURE__ */ jsx4("div", { style: { color: "var(--gxr-text-primary)", fontSize: 15, fontWeight: 600, marginBottom: 4 }, children: title }),
26126
+ ),
26127
+ /* @__PURE__ */ jsxs3("div", { style: { overflowY: "auto", flex: 1 }, children: [
26128
+ propEntries.length > 0 && /* @__PURE__ */ jsxs3("div", { style: { padding: SECTION_PAD, borderTop: `1px solid var(--gxr-panel-divider)` }, children: [
26050
26129
  /* @__PURE__ */ jsx4(
26051
26130
  "div",
26052
26131
  {
26053
26132
  style: {
26054
- color: "var(--gxr-accent)",
26055
- fontSize: 11,
26056
- background: "var(--gxr-accent-soft)",
26057
- display: "inline-block",
26058
- padding: "2px 8px",
26059
- borderRadius: 4
26133
+ color: "var(--gxr-text-secondary)",
26134
+ fontSize: 13,
26135
+ marginBottom: 10,
26136
+ letterSpacing: 0.5
26060
26137
  },
26061
- children: node.category
26138
+ children: "\u5C5E\u6027"
26062
26139
  }
26063
- )
26064
- ] })
26065
- ),
26066
- /* @__PURE__ */ jsx4("div", { style: { maxHeight: 240, overflowY: "auto" }, children: /* @__PURE__ */ jsx4("table", { style: { width: "100%", borderCollapse: "collapse" }, children: /* @__PURE__ */ jsx4("tbody", { children: propEntries.map(([key, value], i) => /* @__PURE__ */ jsxs3("tr", { style: { borderBottom: i < propCount - 1 ? `1px solid var(--gxr-panel-border)` : void 0 }, children: [
26067
- /* @__PURE__ */ jsx4(
26068
- "td",
26069
- {
26070
- style: {
26071
- padding: "6px 14px",
26072
- color: "var(--gxr-text-secondary)",
26073
- width: "35%",
26074
- fontSize: 12,
26075
- verticalAlign: "top",
26076
- overflow: "hidden",
26077
- textOverflow: "ellipsis",
26078
- maxWidth: 0
26140
+ ),
26141
+ propEntries.map(([key, value], i) => /* @__PURE__ */ jsxs3(
26142
+ "div",
26143
+ {
26144
+ style: {
26145
+ display: "flex",
26146
+ justifyContent: "space-between",
26147
+ alignItems: "baseline",
26148
+ gap: 12,
26149
+ padding: "9px 0",
26150
+ borderBottom: i < propEntries.length - 1 ? `1px solid var(--gxr-panel-divider)` : void 0
26151
+ },
26152
+ children: [
26153
+ /* @__PURE__ */ jsx4("span", { style: { color: "var(--gxr-text-secondary)", fontSize: 13, flexShrink: 0 }, children: key }),
26154
+ /* @__PURE__ */ jsx4(
26155
+ "span",
26156
+ {
26157
+ style: {
26158
+ color: "var(--gxr-text-primary)",
26159
+ fontSize: 13,
26160
+ fontWeight: 500,
26161
+ textAlign: "right",
26162
+ wordBreak: "break-word"
26163
+ },
26164
+ children: String(value ?? "")
26165
+ }
26166
+ )
26167
+ ]
26079
26168
  },
26080
- children: key
26081
- }
26082
- ),
26083
- /* @__PURE__ */ jsx4(
26084
- "td",
26085
- {
26086
- style: {
26087
- padding: "6px 14px",
26088
- color: "var(--gxr-text-primary)",
26089
- fontSize: 12,
26090
- wordBreak: "break-word",
26091
- maxHeight: 60,
26092
- overflow: "hidden"
26169
+ key
26170
+ ))
26171
+ ] }),
26172
+ relations.length > 0 && /* @__PURE__ */ jsxs3("div", { style: { padding: SECTION_PAD, borderTop: `1px solid var(--gxr-panel-divider)` }, children: [
26173
+ /* @__PURE__ */ jsxs3(
26174
+ "div",
26175
+ {
26176
+ style: {
26177
+ display: "flex",
26178
+ justifyContent: "space-between",
26179
+ alignItems: "center",
26180
+ color: "var(--gxr-text-secondary)",
26181
+ fontSize: 13,
26182
+ marginBottom: 10,
26183
+ letterSpacing: 0.5
26184
+ },
26185
+ children: [
26186
+ /* @__PURE__ */ jsx4("span", { children: "\u5173\u7CFB" }),
26187
+ /* @__PURE__ */ jsx4("span", { style: { color: "var(--gxr-text-muted)" }, children: relations.length })
26188
+ ]
26189
+ }
26190
+ ),
26191
+ /* @__PURE__ */ jsx4("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: relations.map((rel) => /* @__PURE__ */ jsxs3(
26192
+ "div",
26193
+ {
26194
+ onClick: () => navigateTo(rel.id),
26195
+ title: rel.title,
26196
+ style: {
26197
+ display: "flex",
26198
+ alignItems: "center",
26199
+ gap: 10,
26200
+ padding: "11px 14px",
26201
+ borderRadius: 10,
26202
+ border: `1px solid var(--gxr-panel-border)`,
26203
+ background: "var(--gxr-hover-bg)",
26204
+ cursor: "pointer"
26205
+ },
26206
+ onMouseEnter: (e) => {
26207
+ e.currentTarget.style.borderColor = "var(--gxr-text-muted)";
26208
+ },
26209
+ onMouseLeave: (e) => {
26210
+ e.currentTarget.style.borderColor = "var(--gxr-panel-border)";
26211
+ },
26212
+ children: [
26213
+ /* @__PURE__ */ jsx4(
26214
+ "span",
26215
+ {
26216
+ style: {
26217
+ width: 9,
26218
+ height: 9,
26219
+ borderRadius: "50%",
26220
+ background: rel.color,
26221
+ flexShrink: 0
26222
+ }
26223
+ }
26224
+ ),
26225
+ /* @__PURE__ */ jsx4(
26226
+ "span",
26227
+ {
26228
+ style: {
26229
+ flex: 1,
26230
+ minWidth: 0,
26231
+ color: "var(--gxr-text-primary)",
26232
+ fontSize: 14,
26233
+ overflow: "hidden",
26234
+ textOverflow: "ellipsis",
26235
+ whiteSpace: "nowrap"
26236
+ },
26237
+ children: rel.title
26238
+ }
26239
+ ),
26240
+ /* @__PURE__ */ jsx4("span", { style: { color: "var(--gxr-text-muted)", fontSize: 12, flexShrink: 0 }, children: rel.category })
26241
+ ]
26093
26242
  },
26094
- children: String(value ?? "")
26095
- }
26096
- )
26097
- ] }, key)) }) }) })
26243
+ rel.id
26244
+ )) })
26245
+ ] })
26246
+ ] }),
26247
+ showExpandNeighbors && /* @__PURE__ */ jsx4("div", { style: { padding: SECTION_PAD, borderTop: `1px solid var(--gxr-panel-divider)` }, children: /* @__PURE__ */ jsx4(
26248
+ "button",
26249
+ {
26250
+ "data-no-drag": true,
26251
+ onClick: () => onExpandNeighbors?.(nodeId),
26252
+ style: {
26253
+ width: "100%",
26254
+ padding: "10px 14px",
26255
+ borderRadius: 10,
26256
+ border: `1px solid var(--gxr-panel-border)`,
26257
+ background: "transparent",
26258
+ color: "var(--gxr-text-secondary)",
26259
+ fontSize: 13,
26260
+ cursor: "pointer"
26261
+ },
26262
+ onMouseEnter: (e) => {
26263
+ e.currentTarget.style.background = "var(--gxr-hover-bg)";
26264
+ },
26265
+ onMouseLeave: (e) => {
26266
+ e.currentTarget.style.background = "transparent";
26267
+ },
26268
+ children: "\u2197 \u6269\u5C55\u90BB\u5C45"
26269
+ }
26270
+ ) })
26098
26271
  ]
26099
26272
  }
26100
26273
  );
26101
26274
  }
26102
26275
 
26103
26276
  // src/react/layers/minimap/MinimapLayer.tsx
26104
- import { useEffect as useEffect7, useRef as useRef7, useState as useState5, useCallback as useCallback5 } from "react";
26277
+ import { useEffect as useEffect7, useRef as useRef7, useState as useState5, useCallback as useCallback4 } from "react";
26105
26278
 
26106
26279
  // src/react/layers/minimap/MinimapRenderer.ts
26107
26280
  import * as THREE33 from "three";
@@ -26361,7 +26534,7 @@ var _MinimapRenderer = class _MinimapRenderer {
26361
26534
  this.cloudScene.updateMatrixWorld(true);
26362
26535
  const savedClearColor = this.renderer.getClearColor().clone();
26363
26536
  const savedClearAlpha = this.renderer.getClearAlpha();
26364
- const minimapBg = this.config.isDark ? 986910 : 16316666;
26537
+ const minimapBg = this.config.isDark ? 1315860 : 16316666;
26365
26538
  this.renderer.setClearColor(minimapBg, 1);
26366
26539
  this.renderer.setRenderTarget(this.renderTarget);
26367
26540
  this.renderer.clear();
@@ -26545,7 +26718,7 @@ var MinimapRenderer = _MinimapRenderer;
26545
26718
 
26546
26719
  // src/react/layers/minimap/MinimapOverlay.tsx
26547
26720
  import { useRef as useRef6, useEffect as useEffect6 } from "react";
26548
- import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
26721
+ import { Fragment as Fragment3, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
26549
26722
  function MinimapOverlay({
26550
26723
  width,
26551
26724
  height,
@@ -26560,6 +26733,7 @@ function MinimapOverlay({
26560
26733
  onToggleCollapse,
26561
26734
  zoomPercent,
26562
26735
  onFitToScreen,
26736
+ onResetZoom,
26563
26737
  cameraZ
26564
26738
  }) {
26565
26739
  const containerRef = useRef6(null);
@@ -26652,7 +26826,7 @@ function MinimapOverlay({
26652
26826
  document.removeEventListener("mouseup", onMouseUp);
26653
26827
  };
26654
26828
  }, [width, height]);
26655
- return /* @__PURE__ */ jsxs4(Fragment2, { children: [
26829
+ return /* @__PURE__ */ jsxs4(Fragment3, { children: [
26656
26830
  /* @__PURE__ */ jsx5(
26657
26831
  "div",
26658
26832
  {
@@ -26714,7 +26888,7 @@ function MinimapOverlay({
26714
26888
  className: "minimap-ctrl-zoom",
26715
26889
  title: "Reset zoom to 100%",
26716
26890
  onMouseDown: (e) => e.stopPropagation(),
26717
- onClick: () => control.reset(),
26891
+ onClick: () => onResetZoom(),
26718
26892
  children: [
26719
26893
  Math.round(zoomPercent),
26720
26894
  "%"
@@ -26815,7 +26989,7 @@ function MinimapLayer({
26815
26989
  const viewportFrameRef = useRef7({ x: 0, y: 0, w: 0, h: 0 });
26816
26990
  const [viewportFrame, setViewportFrame] = useState5({ x: 0, y: 0, w: 0, h: 0 });
26817
26991
  const [zoomPercent, setZoomPercent] = useState5(100);
26818
- const DEFAULT_ZOOM = -15;
26992
+ const baselineZoomRef = useRef7(null);
26819
26993
  const dpr = Math.min(window.devicePixelRatio, 2);
26820
26994
  const pixelWidth = Math.round(width * dpr);
26821
26995
  const pixelHeight = Math.round(height * dpr);
@@ -26872,7 +27046,11 @@ function MinimapLayer({
26872
27046
  const frame2 = mr.mapper.computeViewportFrame(viewport);
26873
27047
  if (control) {
26874
27048
  const currentZ = control.getZoom();
26875
- const pct = Math.round(DEFAULT_ZOOM / Math.min(currentZ, -0.1) * 100);
27049
+ if (baselineZoomRef.current === null && currentZ <= -0.1) {
27050
+ baselineZoomRef.current = currentZ;
27051
+ }
27052
+ const baseline = baselineZoomRef.current ?? currentZ;
27053
+ const pct = Math.round(baseline / Math.min(currentZ, -0.1) * 100);
26876
27054
  setZoomPercent(Math.max(1, pct));
26877
27055
  }
26878
27056
  const prev = viewportFrameRef.current;
@@ -26903,7 +27081,7 @@ function MinimapLayer({
26903
27081
  document.addEventListener("keydown", handleKeyDown);
26904
27082
  return () => document.removeEventListener("keydown", handleKeyDown);
26905
27083
  }, []);
26906
- const handleFitToScreen = useCallback5(() => {
27084
+ const handleFitToScreen = useCallback4(() => {
26907
27085
  if (!control) return;
26908
27086
  const provider = minimapRendererRef.current ? minimapRendererRef.current._positionProvider ?? store.positionProvider : store.positionProvider;
26909
27087
  const positions = provider?.getPositions?.();
@@ -26912,6 +27090,11 @@ function MinimapLayer({
26912
27090
  control.setPosition(target[0], target[1]);
26913
27091
  control.setZoom(target[2]);
26914
27092
  }, [control, store, camera]);
27093
+ const handleResetZoom = useCallback4(() => {
27094
+ if (!control) return;
27095
+ control.setPosition(0, 0);
27096
+ control.setZoom(baselineZoomRef.current ?? control.getZoom());
27097
+ }, [control]);
26915
27098
  if (isMapMode) return null;
26916
27099
  if (!control) return null;
26917
27100
  return /* @__PURE__ */ jsx6(
@@ -26930,6 +27113,7 @@ function MinimapLayer({
26930
27113
  onToggleCollapse: () => setCollapsed((c2) => !c2),
26931
27114
  zoomPercent,
26932
27115
  onFitToScreen: handleFitToScreen,
27116
+ onResetZoom: handleResetZoom,
26933
27117
  cameraZ: camera.position.z
26934
27118
  }
26935
27119
  );
@@ -28629,7 +28813,8 @@ var DEFAULT_CONFIG7 = {
28629
28813
  maxPitch: 88,
28630
28814
  dragThreshold: 3,
28631
28815
  zoomToCursor: false,
28632
- onPitchDelta: void 0
28816
+ onPitchDelta: void 0,
28817
+ shouldSkipDrag: void 0
28633
28818
  };
28634
28819
  var _euler = new THREE39.Euler(0, 0, 0, "YXZ");
28635
28820
  var _quatY = new THREE39.Quaternion();
@@ -28804,6 +28989,7 @@ var GlobeControl = class {
28804
28989
  window.addEventListener("mouseup", this._onMouseUp);
28805
28990
  return;
28806
28991
  }
28992
+ if (this.config.shouldSkipDrag && this.config.shouldSkipDrag(e)) return;
28807
28993
  this.isDragging = true;
28808
28994
  this.dragConfirmed = false;
28809
28995
  this.downX = e.clientX;
@@ -28982,6 +29168,10 @@ function GlobeLayer({
28982
29168
  cloudScene.add(globe);
28983
29169
  setMapMode(true, radius, 0.3);
28984
29170
  if (graphControl) graphControl.enabled = false;
29171
+ if (interaction) {
29172
+ interaction.drag.enabled = true;
29173
+ interaction.coordinator?.setBackgroundGestureExternal(true);
29174
+ }
28985
29175
  if (container) {
28986
29176
  const control = new GlobeControl(cloudScene, container, {
28987
29177
  zoomMin: -100,
@@ -28993,6 +29183,16 @@ function GlobeLayer({
28993
29183
  if (api?.map) {
28994
29184
  api.map.setPitch(api.map.getPitch() + delta);
28995
29185
  }
29186
+ },
29187
+ // Let node drags win over globe orbit: if a node is under the cursor on
29188
+ // mousedown, skip the GlobeControl orbit so the InteractionManager's
29189
+ // DragHandler moves the node instead. Background mousedowns still rotate.
29190
+ shouldSkipDrag: (e) => {
29191
+ const picker = interaction?.picker;
29192
+ if (!picker?.pick || !container) return false;
29193
+ const rect = container.getBoundingClientRect();
29194
+ const res = picker.pick(e.clientX - rect.left, e.clientY - rect.top);
29195
+ return !!(res && res.type === "node" && res.picked);
28996
29196
  }
28997
29197
  });
28998
29198
  control.onChange(() => {
@@ -29035,6 +29235,7 @@ function GlobeLayer({
29035
29235
  cloudScene.position.copy(savedPosition);
29036
29236
  cloudScene.quaternion.copy(savedQuaternion);
29037
29237
  if (graphControl) graphControl.enabled = true;
29238
+ interaction?.coordinator?.setBackgroundGestureExternal(false);
29038
29239
  invalidate();
29039
29240
  };
29040
29241
  }, [radius, minLevel, maxLevel, mercatorProjection]);
@@ -29058,7 +29259,7 @@ function GlobeLayer({
29058
29259
  import { useMemo as useMemo5 } from "react";
29059
29260
 
29060
29261
  // src/react/toolbar/Toolbar.tsx
29061
- import { useCallback as useCallback8, useEffect as useEffect18, useMemo as useMemo4, useReducer, useRef as useRef15, useState as useState12, useSyncExternalStore } from "react";
29262
+ import { useCallback as useCallback7, useEffect as useEffect18, useMemo as useMemo4, useReducer, useRef as useRef15, useState as useState12, useSyncExternalStore } from "react";
29062
29263
  import * as Tooltip2 from "@radix-ui/react-tooltip";
29063
29264
 
29064
29265
  // src/react/toolbar/docks/FloatingDock.tsx
@@ -29179,12 +29380,12 @@ function DockCollapseButton({ collapsed, onClick, orientation }) {
29179
29380
  }
29180
29381
 
29181
29382
  // src/react/toolbar/popover/ToolPopover.tsx
29182
- import { useCallback as useCallback7, useState as useState9 } from "react";
29383
+ import { useCallback as useCallback6, useState as useState9 } from "react";
29183
29384
  import * as Popover2 from "@radix-ui/react-popover";
29184
29385
  import clsx2 from "clsx";
29185
29386
 
29186
29387
  // src/react/toolbar/popover/LayoutSettingsView.tsx
29187
- import { useState as useState8, useCallback as useCallback6, useEffect as useEffect14 } from "react";
29388
+ import { useState as useState8, useCallback as useCallback5, useEffect as useEffect14 } from "react";
29188
29389
  import { jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
29189
29390
  function getDefaults(params) {
29190
29391
  const d = {};
@@ -29199,17 +29400,17 @@ function LayoutSettingsView({ item, ctx, onBack, onApply }) {
29199
29400
  useEffect14(() => {
29200
29401
  if (stored) setValues((v) => ({ ...defaults, ...stored, ...v }));
29201
29402
  }, [stored]);
29202
- const setValue = useCallback6((key, val) => {
29403
+ const setValue = useCallback5((key, val) => {
29203
29404
  setValues((prev) => {
29204
29405
  const next = { ...prev, [key]: val };
29205
29406
  ctx.dispatch({ type: "SET_LAYOUT_PARAMS", toolId: item.id, params: next });
29206
29407
  return next;
29207
29408
  });
29208
29409
  }, [ctx, item.id]);
29209
- const handleApply = useCallback6(() => {
29410
+ const handleApply = useCallback5(() => {
29210
29411
  onApply(item);
29211
29412
  }, [item, onApply]);
29212
- const handleReset = useCallback6(() => {
29413
+ const handleReset = useCallback5(() => {
29213
29414
  const d = getDefaults(params);
29214
29415
  setValues(d);
29215
29416
  ctx.dispatch({ type: "SET_LAYOUT_PARAMS", toolId: item.id, params: d });
@@ -29292,7 +29493,7 @@ function ToolPopover({
29292
29493
  }) {
29293
29494
  const layout = parent.popoverLayout ?? "list";
29294
29495
  const [settingsItem, setSettingsItem] = useState9(null);
29295
- const handleLeafClick = useCallback7(
29496
+ const handleLeafClick = useCallback6(
29296
29497
  (item) => {
29297
29498
  if (item.kind === "separator") return;
29298
29499
  onInvoke(item);
@@ -29300,7 +29501,7 @@ function ToolPopover({
29300
29501
  },
29301
29502
  [onInvoke, onOpenChange, layout, parent.keepOpen]
29302
29503
  );
29303
- const handleOpenChange = useCallback7((next) => {
29504
+ const handleOpenChange = useCallback6((next) => {
29304
29505
  if (!next) setSettingsItem(null);
29305
29506
  onOpenChange(next);
29306
29507
  }, [onOpenChange]);
@@ -30189,7 +30390,7 @@ function ToolbarInner({
30189
30390
  const id = setInterval(check, 50);
30190
30391
  return () => clearInterval(id);
30191
30392
  }, [api]);
30192
- const dispatch2 = useCallback8(
30393
+ const dispatch2 = useCallback7(
30193
30394
  (action) => {
30194
30395
  switch (action.type) {
30195
30396
  case "SET_DOCK_POSITION":
@@ -30248,7 +30449,7 @@ function ToolbarInner({
30248
30449
  const [popoverState, localDispatch] = useReducer(popoverReducer, initialPopoverState);
30249
30450
  const zIndexMap = useRef15(/* @__PURE__ */ new Map());
30250
30451
  const zCounter = useRef15(1);
30251
- const bringToFront = useCallback8((toolId) => {
30452
+ const bringToFront = useCallback7((toolId) => {
30252
30453
  zCounter.current += 1;
30253
30454
  zIndexMap.current.set(toolId, zCounter.current);
30254
30455
  }, []);
@@ -30269,7 +30470,7 @@ function ToolbarInner({
30269
30470
  document.addEventListener("keydown", onKey);
30270
30471
  return () => document.removeEventListener("keydown", onKey);
30271
30472
  }, [pinnedTools, popoverState.status, dispatch2]);
30272
- const handleInvoke = useCallback8(
30473
+ const handleInvoke = useCallback7(
30273
30474
  (item) => {
30274
30475
  if (item.kind === "action") {
30275
30476
  void item.onInvoke(ctx);
@@ -30291,7 +30492,7 @@ function ToolbarInner({
30291
30492
  },
30292
30493
  [ctx, activeToggles, dispatch2, pinnedTools]
30293
30494
  );
30294
- const findParentItem = useCallback8(
30495
+ const findParentItem = useCallback7(
30295
30496
  (toolId) => {
30296
30497
  for (const dock of docks) {
30297
30498
  for (const it of dock.items) {
@@ -31268,13 +31469,13 @@ function ToolbarAutoMount({ config }) {
31268
31469
  }
31269
31470
 
31270
31471
  // src/react/legend/LegendPanel.tsx
31271
- import { useState as useState21, useCallback as useCallback17, useMemo as useMemo9, useRef as useRef18, useEffect as useEffect22 } from "react";
31472
+ import { useState as useState21, useCallback as useCallback16, useMemo as useMemo9, useRef as useRef18, useEffect as useEffect22 } from "react";
31272
31473
 
31273
31474
  // src/react/legend/hooks/useLegendData.ts
31274
- import { useState as useState14, useEffect as useEffect19, useCallback as useCallback9 } from "react";
31475
+ import { useState as useState14, useEffect as useEffect19, useCallback as useCallback8 } from "react";
31275
31476
  function useLegendData(store, api) {
31276
31477
  const [, setVersion] = useState14(0);
31277
- const bump = useCallback9(() => setVersion((v) => v + 1), []);
31478
+ const bump = useCallback8(() => setVersion((v) => v + 1), []);
31278
31479
  useEffect19(() => {
31279
31480
  const unsubs = [
31280
31481
  api.events.on("nodes:added", bump),
@@ -31331,7 +31532,7 @@ function useLegendData(store, api) {
31331
31532
  }
31332
31533
 
31333
31534
  // src/react/legend/hooks/usePopover.ts
31334
- import { useState as useState15, useCallback as useCallback10, useEffect as useEffect20, useRef as useRef16 } from "react";
31535
+ import { useState as useState15, useCallback as useCallback9, useEffect as useEffect20, useRef as useRef16 } from "react";
31335
31536
  function usePopover() {
31336
31537
  const [state, setState] = useState15({
31337
31538
  isOpen: false,
@@ -31341,7 +31542,7 @@ function usePopover() {
31341
31542
  });
31342
31543
  const popoverRef = useRef16(null);
31343
31544
  const hasDraggedRef = useRef16(false);
31344
- const open = useCallback10((key, anchorEl) => {
31545
+ const open = useCallback9((key, anchorEl) => {
31345
31546
  const rect = anchorEl.getBoundingClientRect();
31346
31547
  const popoverWidth = 250;
31347
31548
  const spaceLeft = rect.left;
@@ -31349,10 +31550,10 @@ function usePopover() {
31349
31550
  const position = flipped ? { top: rect.bottom + 8, left: rect.right - popoverWidth } : { top: rect.top, left: rect.left - popoverWidth - 12 };
31350
31551
  setState({ isOpen: true, targetKey: key, position, flipped });
31351
31552
  }, []);
31352
- const close = useCallback10(() => {
31553
+ const close = useCallback9(() => {
31353
31554
  setState({ isOpen: false, targetKey: null, position: null, flipped: false });
31354
31555
  }, []);
31355
- const toggle = useCallback10(
31556
+ const toggle = useCallback9(
31356
31557
  (key, anchorEl) => {
31357
31558
  if (state.isOpen && state.targetKey === key) {
31358
31559
  close();
@@ -31388,7 +31589,7 @@ function usePopover() {
31388
31589
  }
31389
31590
 
31390
31591
  // src/react/legend/CategoryPill.tsx
31391
- import { useCallback as useCallback11 } from "react";
31592
+ import { useCallback as useCallback10 } from "react";
31392
31593
 
31393
31594
  // src/react/legend/colorPalettes.ts
31394
31595
  var COLOR_PALETTES = [
@@ -31508,14 +31709,14 @@ function contrastText(hex) {
31508
31709
  }
31509
31710
 
31510
31711
  // src/react/legend/CategoryPill.tsx
31511
- import { Fragment as Fragment3, jsx as jsx21, jsxs as jsxs12 } from "react/jsx-runtime";
31712
+ import { Fragment as Fragment4, jsx as jsx21, jsxs as jsxs12 } from "react/jsx-runtime";
31512
31713
  function CategoryPill({ entry, onSelect, onEditClick }) {
31513
31714
  const { name, count: count2, color, isSelected, isHidden, colorMapping } = entry;
31514
31715
  const textColor = contrastText(color);
31515
- const handleClick = useCallback11(() => {
31716
+ const handleClick = useCallback10(() => {
31516
31717
  onSelect(name);
31517
31718
  }, [onSelect, name]);
31518
- const handleKeyDown = useCallback11(
31719
+ const handleKeyDown = useCallback10(
31519
31720
  (e) => {
31520
31721
  if (e.key === "Enter" || e.key === " ") {
31521
31722
  e.preventDefault();
@@ -31524,14 +31725,14 @@ function CategoryPill({ entry, onSelect, onEditClick }) {
31524
31725
  },
31525
31726
  [onSelect, name]
31526
31727
  );
31527
- const handleBrushClick = useCallback11(
31728
+ const handleBrushClick = useCallback10(
31528
31729
  (e) => {
31529
31730
  e.stopPropagation();
31530
31731
  onEditClick(name, e.currentTarget);
31531
31732
  },
31532
31733
  [onEditClick, name]
31533
31734
  );
31534
- const handleBrushKeyDown = useCallback11(
31735
+ const handleBrushKeyDown = useCallback10(
31535
31736
  (e) => {
31536
31737
  if (e.key === "Enter" || e.key === " ") {
31537
31738
  e.preventDefault();
@@ -31563,7 +31764,7 @@ function CategoryPill({ entry, onSelect, onEditClick }) {
31563
31764
  children: [
31564
31765
  /* @__PURE__ */ jsx21("span", { className: "legend-pill__dot" }),
31565
31766
  /* @__PURE__ */ jsx21("span", { className: "legend-pill__name", children: name }),
31566
- colorMapping ? /* @__PURE__ */ jsxs12(Fragment3, { children: [
31767
+ colorMapping ? /* @__PURE__ */ jsxs12(Fragment4, { children: [
31567
31768
  colorMapping.type === "sequential" || colorMapping.type === "diverging" ? /* @__PURE__ */ jsx21(
31568
31769
  "span",
31569
31770
  {
@@ -31597,15 +31798,15 @@ function CategoryPill({ entry, onSelect, onEditClick }) {
31597
31798
  }
31598
31799
 
31599
31800
  // src/react/legend/RelationshipPill.tsx
31600
- import { useCallback as useCallback12 } from "react";
31801
+ import { useCallback as useCallback11 } from "react";
31601
31802
  import { jsx as jsx22, jsxs as jsxs13 } from "react/jsx-runtime";
31602
31803
  function RelationshipPill({ entry, onSelect, onEditClick }) {
31603
31804
  const { name, count: count2, color, isSelected } = entry;
31604
31805
  const textColor = contrastText(color);
31605
- const handleClick = useCallback12(() => {
31806
+ const handleClick = useCallback11(() => {
31606
31807
  onSelect(name);
31607
31808
  }, [onSelect, name]);
31608
- const handleKeyDown = useCallback12(
31809
+ const handleKeyDown = useCallback11(
31609
31810
  (e) => {
31610
31811
  if (e.key === "Enter" || e.key === " ") {
31611
31812
  e.preventDefault();
@@ -31614,14 +31815,14 @@ function RelationshipPill({ entry, onSelect, onEditClick }) {
31614
31815
  },
31615
31816
  [onSelect, name]
31616
31817
  );
31617
- const handleBrushClick = useCallback12(
31818
+ const handleBrushClick = useCallback11(
31618
31819
  (e) => {
31619
31820
  e.stopPropagation();
31620
31821
  onEditClick(name, e.currentTarget);
31621
31822
  },
31622
31823
  [onEditClick, name]
31623
31824
  );
31624
- const handleBrushKeyDown = useCallback12(
31825
+ const handleBrushKeyDown = useCallback11(
31625
31826
  (e) => {
31626
31827
  if (e.key === "Enter" || e.key === " ") {
31627
31828
  e.preventDefault();
@@ -31671,7 +31872,7 @@ function RelationshipPill({ entry, onSelect, onEditClick }) {
31671
31872
  import { useState as useState20, useEffect as useEffect21, useRef as useRef17 } from "react";
31672
31873
 
31673
31874
  // src/react/legend/popover/ColorTab.tsx
31674
- import { useState as useState16, useMemo as useMemo6, useCallback as useCallback13 } from "react";
31875
+ import { useState as useState16, useMemo as useMemo6, useCallback as useCallback12 } from "react";
31675
31876
 
31676
31877
  // src/react/legend/popover/SwatchGrid.tsx
31677
31878
  import { jsx as jsx23 } from "react/jsx-runtime";
@@ -31893,7 +32094,7 @@ function ColorTab({ targetKey, isCategory, store, api }) {
31893
32094
  const max = Math.max(...numericValues);
31894
32095
  return [min, max === min ? min + 1 : max];
31895
32096
  }, [activeProperty, isCategory, targetKey, store]);
31896
- const handleSwatchSelect = useCallback13(
32097
+ const handleSwatchSelect = useCallback12(
31897
32098
  (color) => {
31898
32099
  if (isCategory) {
31899
32100
  api.style.setCategoryColor(targetKey, color);
@@ -31903,15 +32104,15 @@ function ColorTab({ targetKey, isCategory, store, api }) {
31903
32104
  },
31904
32105
  [api, targetKey, isCategory]
31905
32106
  );
31906
- const handlePaletteChange = useCallback13((e) => {
32107
+ const handlePaletteChange = useCallback12((e) => {
31907
32108
  const name = e.target.value;
31908
32109
  setSelectedPalette(name);
31909
32110
  setStoredPalette(name);
31910
32111
  }, []);
31911
- const handlePropertyChange = useCallback13((e) => {
32112
+ const handlePropertyChange = useCallback12((e) => {
31912
32113
  setSelectedProperty(e.target.value);
31913
32114
  }, []);
31914
- const handleApplyDiscrete = useCallback13(() => {
32115
+ const handleApplyDiscrete = useCallback12(() => {
31915
32116
  if (!activeProperty) return;
31916
32117
  const colorMap = {};
31917
32118
  for (const entry of propertyValues) {
@@ -31923,7 +32124,7 @@ function ColorTab({ targetKey, isCategory, store, api }) {
31923
32124
  api.style.colorEdgesByProperty(activeProperty, { mode: "ordinal", relationship: targetKey, colorMap });
31924
32125
  }
31925
32126
  }, [activeProperty, propertyValues, isCategory, targetKey, api]);
31926
- const handleApplyGradient = useCallback13(() => {
32127
+ const handleApplyGradient = useCallback12(() => {
31927
32128
  if (!activeProperty) return;
31928
32129
  const { colorFrom, colorTo } = getGradientColors(gradientScheme);
31929
32130
  if (isCategory) {
@@ -32062,7 +32263,7 @@ function ColorTab({ targetKey, isCategory, store, api }) {
32062
32263
  }
32063
32264
 
32064
32265
  // src/react/legend/popover/SizeTab.tsx
32065
- import { useState as useState17, useMemo as useMemo7, useCallback as useCallback14 } from "react";
32266
+ import { useState as useState17, useMemo as useMemo7, useCallback as useCallback13 } from "react";
32066
32267
  import { jsx as jsx27, jsxs as jsxs17 } from "react/jsx-runtime";
32067
32268
  var DEFAULT_SIZE = 10;
32068
32269
  var DEFAULT_MIN_SIZE = 5;
@@ -32081,7 +32282,7 @@ function SizeTab({ targetKey, store, api }) {
32081
32282
  if (selectedProperty && propertyKeys.includes(selectedProperty)) return selectedProperty;
32082
32283
  return propertyKeys[0] ?? "";
32083
32284
  }, [selectedProperty, propertyKeys]);
32084
- const handleDefaultSizeChange = useCallback14(
32285
+ const handleDefaultSizeChange = useCallback13(
32085
32286
  (e) => {
32086
32287
  const size = Number(e.target.value);
32087
32288
  setDefaultSize(size);
@@ -32092,7 +32293,7 @@ function SizeTab({ targetKey, store, api }) {
32092
32293
  },
32093
32294
  [api, store, targetKey]
32094
32295
  );
32095
- const handleApplySizeByProperty = useCallback14(() => {
32296
+ const handleApplySizeByProperty = useCallback13(() => {
32096
32297
  if (!activeProperty) return;
32097
32298
  api.style.sizeNodesByProperty(activeProperty, {
32098
32299
  minSize,
@@ -32198,7 +32399,7 @@ function SizeTab({ targetKey, store, api }) {
32198
32399
  }
32199
32400
 
32200
32401
  // src/react/legend/popover/WidthTab.tsx
32201
- import { useState as useState18, useCallback as useCallback15 } from "react";
32402
+ import { useState as useState18, useCallback as useCallback14 } from "react";
32202
32403
  import { jsx as jsx28, jsxs as jsxs18 } from "react/jsx-runtime";
32203
32404
  var DEFAULT_WIDTH = 1;
32204
32405
  function WidthTab({ targetKey, store, api }) {
@@ -32207,7 +32408,7 @@ function WidthTab({ targetKey, store, api }) {
32207
32408
  const config = store.visualMapper.getRelationshipConfig(targetKey);
32208
32409
  return config?.defaultWidth ?? DEFAULT_WIDTH;
32209
32410
  });
32210
- const handleDefaultWidthChange = useCallback15(
32411
+ const handleDefaultWidthChange = useCallback14(
32211
32412
  (e) => {
32212
32413
  const width = Number(e.target.value);
32213
32414
  setDefaultWidth(width);
@@ -32236,7 +32437,7 @@ function WidthTab({ targetKey, store, api }) {
32236
32437
  }
32237
32438
 
32238
32439
  // src/react/legend/popover/CaptionTab.tsx
32239
- import { useState as useState19, useMemo as useMemo8, useCallback as useCallback16 } from "react";
32440
+ import { useState as useState19, useMemo as useMemo8, useCallback as useCallback15 } from "react";
32240
32441
  import { jsx as jsx29, jsxs as jsxs19 } from "react/jsx-runtime";
32241
32442
  function CaptionTab({ targetKey, isCategory, store, api }) {
32242
32443
  const { t } = useLegendIntl();
@@ -32266,7 +32467,7 @@ function CaptionTab({ targetKey, isCategory, store, api }) {
32266
32467
  if (selectedProperty && availableProperties.includes(selectedProperty)) return selectedProperty;
32267
32468
  return availableProperties[0] ?? "";
32268
32469
  }, [selectedProperty, availableProperties]);
32269
- const applyToStore = useCallback16(
32470
+ const applyToStore = useCallback15(
32270
32471
  (newCaptions) => {
32271
32472
  if (isCategory) {
32272
32473
  const existing = store.visualMapper.getCategoryConfig(targetKey);
@@ -32295,7 +32496,7 @@ function CaptionTab({ targetKey, isCategory, store, api }) {
32295
32496
  },
32296
32497
  [store, targetKey, isCategory]
32297
32498
  );
32298
- const handleAddProperty = useCallback16(() => {
32499
+ const handleAddProperty = useCallback15(() => {
32299
32500
  if (!activeProperty) return;
32300
32501
  const newDef = {
32301
32502
  source: `property:${activeProperty}`,
@@ -32306,7 +32507,7 @@ function CaptionTab({ targetKey, isCategory, store, api }) {
32306
32507
  setSelectedProperty("");
32307
32508
  applyToStore(updated);
32308
32509
  }, [activeProperty, captions, applyToStore]);
32309
- const handleRemoveCaption = useCallback16(
32510
+ const handleRemoveCaption = useCallback15(
32310
32511
  (index2) => {
32311
32512
  const updated = captions.filter((_2, i) => i !== index2);
32312
32513
  setCaptions(updated);
@@ -32314,7 +32515,7 @@ function CaptionTab({ targetKey, isCategory, store, api }) {
32314
32515
  },
32315
32516
  [captions, applyToStore]
32316
32517
  );
32317
- const handleClearAll = useCallback16(() => {
32518
+ const handleClearAll = useCallback15(() => {
32318
32519
  setCaptions([]);
32319
32520
  applyToStore([]);
32320
32521
  }, [applyToStore]);
@@ -32526,7 +32727,7 @@ function StylePopover({
32526
32727
  import { jsx as jsx31, jsxs as jsxs21 } from "react/jsx-runtime";
32527
32728
  var OVERFLOW_THRESHOLD = 20;
32528
32729
  function LegendPanel({ store, api, visible = true, messages, minimapVisible = false, iconAtlasManager }) {
32529
- const t = useCallback17(
32730
+ const t = useCallback16(
32530
32731
  (key, params) => getMessage(messages, key, params),
32531
32732
  [messages]
32532
32733
  );
@@ -32535,7 +32736,7 @@ function LegendPanel({ store, api, visible = true, messages, minimapVisible = fa
32535
32736
  const popover = usePopover();
32536
32737
  const [expandedCategories, setExpandedCategories] = useState21(false);
32537
32738
  const [expandedRelationships, setExpandedRelationships] = useState21(false);
32538
- const handleCategorySelect = useCallback17(
32739
+ const handleCategorySelect = useCallback16(
32539
32740
  (name) => {
32540
32741
  const nodes = store.queries.getNodesByCategory(name);
32541
32742
  const ids = nodes.map((n) => n.id);
@@ -32543,7 +32744,7 @@ function LegendPanel({ store, api, visible = true, messages, minimapVisible = fa
32543
32744
  },
32544
32745
  [store, api]
32545
32746
  );
32546
- const handleRelationshipSelect = useCallback17(
32747
+ const handleRelationshipSelect = useCallback16(
32547
32748
  (name) => {
32548
32749
  const edges = store.queries.getEdgesByRelationship(name);
32549
32750
  const ids = edges.map((e) => e.id);
@@ -32551,7 +32752,7 @@ function LegendPanel({ store, api, visible = true, messages, minimapVisible = fa
32551
32752
  },
32552
32753
  [store, api]
32553
32754
  );
32554
- const handleEditClick = useCallback17(
32755
+ const handleEditClick = useCallback16(
32555
32756
  (key, anchorEl) => {
32556
32757
  popover.toggle(key, anchorEl);
32557
32758
  },
@@ -40861,18 +41062,34 @@ var EmphasisApi = class {
40861
41062
  this.effectManager.stopAll(type);
40862
41063
  }
40863
41064
  /**
40864
- * Enable or disable the hover-neighbor-highlight emphasis effect.
41065
+ * Enable or disable the hover-DIM feature (fade everything outside the
41066
+ * hovered node's 1-hop neighborhood).
41067
+ *
41068
+ * **Independent of the hover ring.** The ring/halo is governed by
41069
+ * {@link setEmphasisGlowEnabled} (on by default); this switch only controls
41070
+ * the dimming of non-neighbors. Default `false` — dim is opt-in.
40865
41071
  *
40866
- * When enabled (default), hovering a node dims all other nodes and edges
40867
- * except the hovered node, its 1-hop neighbors, and the connecting edges.
40868
- * When disabled, hover events do not trigger any dim ramp.
41072
+ * When enabled, hovering a node dims all other nodes and edges except the
41073
+ * hovered node, its 1-hop neighbors, and the connecting edges. When
41074
+ * disabled, hovering still shows the ring (if glow is on) but fades nothing.
40869
41075
  *
40870
41076
  * Not undoable. Not recorded in history.
40871
41077
  *
40872
41078
  * @param enabled - `true` to enable hover dimming, `false` to disable.
40873
41079
  */
41080
+ setHoverDimEnabled(enabled) {
41081
+ this.hoverEmphasis?.setDimEnabled(enabled);
41082
+ }
41083
+ /**
41084
+ * @deprecated Legacy name for {@link setHoverDimEnabled} — historically this
41085
+ * was the single master switch that coupled dim and glow. It now controls
41086
+ * only the dim feature (the ring is governed by
41087
+ * {@link setEmphasisGlowEnabled}). Prefer `setHoverDimEnabled`.
41088
+ *
41089
+ * @param enabled - `true` to enable hover dimming, `false` to disable.
41090
+ */
40874
41091
  setHoverEnabled(enabled) {
40875
- this.hoverEmphasis?.setEnabled(enabled);
41092
+ this.hoverEmphasis?.setDimEnabled(enabled);
40876
41093
  }
40877
41094
  /**
40878
41095
  * Set the opacity of dimmed nodes and edges during hover emphasis.
@@ -40905,13 +41122,18 @@ var EmphasisApi = class {
40905
41122
  this.hoverEmphasis?.setConfig({ duration: ms });
40906
41123
  }
40907
41124
  /**
40908
- * Enable or disable the positive emphasis (tube glow on kept edges + halo
40909
- * on kept nodes) that accompanies hover/dim. Default `true`. Does not
40910
- * affect the opacity dim controlled by {@link setHoverDimOpacity}.
41125
+ * Enable or disable the hover RING (node halo + edge tube glow). Default
41126
+ * `true` — the ring shows on hover out of the box.
41127
+ *
41128
+ * **Independent of the dim feature** ({@link setHoverDimEnabled}). In
41129
+ * glow-only mode (dim off) the ring is drawn on the hovered node alone; when
41130
+ * dim is also on, it extends to the kept set (1-hop neighbors), the same way
41131
+ * trace emphasis lights up its whole keep set. Does not affect the dim
41132
+ * opacity controlled by {@link setHoverDimOpacity}.
40911
41133
  *
40912
41134
  * Not undoable. Not recorded in history.
40913
41135
  *
40914
- * @param enabled - `true` to enable glow+halo, `false` to disable.
41136
+ * @param enabled - `true` to enable the ring, `false` to disable.
40915
41137
  */
40916
41138
  setEmphasisGlowEnabled(enabled) {
40917
41139
  this.hoverEmphasis?.setConfig({ glowEnabled: enabled });
@@ -40941,14 +41163,15 @@ var EmphasisApi = class {
40941
41163
  this.hoverEmphasis?.setConfig({ haloStrength: Math.max(0, strength) });
40942
41164
  }
40943
41165
  /**
40944
- * Returns whether the hover-neighbor-highlight emphasis effect is enabled.
41166
+ * Returns whether the hover-DIM feature is enabled.
40945
41167
  *
40946
41168
  * @returns `true` if hover dimming will fire on hover-enter; `false`
40947
- * otherwise. Also returns `false` when no {@link HoverEmphasisController}
40948
- * is wired (the API was constructed without a controller).
41169
+ * otherwise (the ring may still show — see {@link setEmphasisGlowEnabled}).
41170
+ * Also returns `false` when no {@link HoverEmphasisController} is wired
41171
+ * (the API was constructed without a controller).
40949
41172
  */
40950
41173
  isHoverEnabled() {
40951
- return this.hoverEmphasis?.isEnabled() ?? false;
41174
+ return this.hoverEmphasis?.isDimEnabled() ?? false;
40952
41175
  }
40953
41176
  /**
40954
41177
  * Programmatic dim. Apply an arbitrary keep set — every node / edge
@@ -44593,6 +44816,18 @@ var _MapApi = class _MapApi {
44593
44816
  this._autoFitDebounceMs = 200;
44594
44817
  // Whether a mode transition is in progress
44595
44818
  this._transitioning = false;
44819
+ // Set by GraphContext right before it swaps the auto map layer
44820
+ // (FlatLayer↔GlobeLayer) for a 2D↔3D change while the map stays active.
44821
+ // Suppresses the teardown in the single disableMap() that the outgoing
44822
+ // layer's unmount cleanup fires — see disableMap() / beginLayerSwap().
44823
+ this._inLayerSwap = false;
44824
+ // Wall-clock (ms) when beginLayerSwap last armed the flag. The suppression is
44825
+ // only honored within LAYER_SWAP_SUPPRESS_WINDOW_MS of arming: a real swap's
44826
+ // outgoing disableMap fires within one render commit, but if the flag is
44827
+ // armed and never consumed (e.g. the layer updates in place instead of
44828
+ // unmount→remount), a STALE flag must not swallow a genuine user "Hide Map"
44829
+ // seconds later. See disableMap().
44830
+ this._layerSwapArmedAt = 0;
44596
44831
  // Per-node elevation offsets above the map surface (cleared on disableMap)
44597
44832
  this._elevation = /* @__PURE__ */ new Map();
44598
44833
  // Currently baked-in elevation offset (tracks what is already in the position buffer)
@@ -44917,8 +45152,9 @@ var _MapApi = class _MapApi {
44917
45152
  * Phase 1: records state and emits event. Scene wiring is Phase 2/3.
44918
45153
  */
44919
45154
  async enableMap(options) {
45155
+ this._inLayerSwap = false;
44920
45156
  if (this._enabled) return;
44921
- const mode = options?.mode ?? "planar";
45157
+ const mode = options?.mode ?? (this._is3D ? "spherical" : "planar");
44922
45158
  const providerKey = options?.provider ?? "cartoDark";
44923
45159
  this._enabled = true;
44924
45160
  this._mode = mode;
@@ -44930,6 +45166,24 @@ var _MapApi = class _MapApi {
44930
45166
  this._reapplyElevationFor(Array.from(this._elevation.keys()));
44931
45167
  this.events.emit("map:enabled", { mode, provider: providerKey });
44932
45168
  }
45169
+ /**
45170
+ * Mark that the NEXT `disableMap()` is part of a 2D↔3D layer swap
45171
+ * (FlatLayer↔GlobeLayer), not a real map-off, so that single call skips its
45172
+ * teardown (and crucially its geo unpin). Call this immediately before
45173
+ * swapping the auto map layer while the map stays active.
45174
+ *
45175
+ * Self-limiting: the flag is consumed by the next `disableMap()`, cleared by
45176
+ * any `enableMap()` (the incoming layer's mount), AND time-boxed — see
45177
+ * `LAYER_SWAP_SUPPRESS_WINDOW_MS`. The time box guarantees a flag that was
45178
+ * armed but never consumed (layer updated in place rather than
45179
+ * unmount→remount) cannot linger to swallow a later genuine "Hide Map".
45180
+ *
45181
+ * @internal — used by GraphContext's auto-map-layer effect.
45182
+ */
45183
+ beginLayerSwap() {
45184
+ this._inLayerSwap = true;
45185
+ this._layerSwapArmedAt = typeof performance !== "undefined" ? performance.now() : Date.now();
45186
+ }
44933
45187
  /**
44934
45188
  * Disable map mode and restore the scene to its pre-map state.
44935
45189
  *
@@ -44938,6 +45192,13 @@ var _MapApi = class _MapApi {
44938
45192
  * Emits `"map:disabled"`.
44939
45193
  */
44940
45194
  disableMap() {
45195
+ if (this._inLayerSwap) {
45196
+ this._inLayerSwap = false;
45197
+ const now2 = typeof performance !== "undefined" ? performance.now() : Date.now();
45198
+ if (now2 - this._layerSwapArmedAt < _MapApi.LAYER_SWAP_SUPPRESS_WINDOW_MS) {
45199
+ return;
45200
+ }
45201
+ }
44941
45202
  this._elevation.clear();
44942
45203
  this._appliedElevation.clear();
44943
45204
  if (this._geoPinnedIds.size > 0) {
@@ -44961,8 +45222,37 @@ var _MapApi = class _MapApi {
44961
45222
  this._lastAppliedScenePosZ = null;
44962
45223
  this._lastAppliedPitchRad = null;
44963
45224
  if (this._cloudScene) this._cloudScene.rotation.x = 0;
45225
+ this._reheatLayout();
44964
45226
  this.events.emit("map:disabled", {});
44965
45227
  }
45228
+ /**
45229
+ * Re-enable + reheat the live force layout so released nodes re-flow.
45230
+ *
45231
+ * Show Map's `stopLayout()` left the controller's `_enable=false`, and
45232
+ * `restartLayout()` early-returns while disabled — so we must RE-ENABLE
45233
+ * first. Critically we use `restartLayout()` (reheat the EXISTING sim in
45234
+ * place), NOT `startLayout()`: startLayout does a full dispose+buildSimulation
45235
+ * that re-seeds pin state from the stale `graph.layoutNodes[].pinned` mirror
45236
+ * (which is never set for geo), which would UNPIN geo and break the map
45237
+ * projection. Routed through the provider's layoutController (the WebGPU /
45238
+ * CPU-adapter wiring); falls back to the legacy `_layoutRuntime` sim handle
45239
+ * for the d3 engine.
45240
+ */
45241
+ _reheatLayout() {
45242
+ const lc = this.store.positionProvider?.layoutController;
45243
+ if (lc) {
45244
+ if (lc.c) lc.c._enable = true;
45245
+ if (typeof lc.restart === "function") {
45246
+ lc.restart();
45247
+ return;
45248
+ }
45249
+ }
45250
+ const sim = this.store._layoutRuntime?.engine?.controller?.simulation;
45251
+ if (sim && typeof sim.alpha === "function") {
45252
+ sim.alpha(0.5);
45253
+ sim.restart?.();
45254
+ }
45255
+ }
44966
45256
  /**
44967
45257
  * Whether map mode is currently active.
44968
45258
  */
@@ -45967,10 +46257,10 @@ var _MapApi = class _MapApi {
45967
46257
  for (const id of geoNodeIds) {
45968
46258
  if (!this.store.isPinned(id)) newlyPinnedGeoIds.push(id);
45969
46259
  }
45970
- if (newlyPinnedGeoIds.length > 0) {
45971
- this.store.pinNodes(newlyPinnedGeoIds);
45972
- for (const id of newlyPinnedGeoIds) this._geoPinnedIds.add(id);
46260
+ if (geoNodeIds.length > 0) {
46261
+ this.store.pinNodes(geoNodeIds);
45973
46262
  }
46263
+ for (const id of newlyPinnedGeoIds) this._geoPinnedIds.add(id);
45974
46264
  const alphaBump = options.alphaBump ?? 0.5;
45975
46265
  if (alphaBump > 0) {
45976
46266
  const sim = this.store._layoutRuntime?.engine?.controller?.simulation;
@@ -46337,6 +46627,7 @@ var _MapApi = class _MapApi {
46337
46627
  return this.flyTo(center, { duration, mode, zoomLevel });
46338
46628
  }
46339
46629
  };
46630
+ _MapApi.LAYER_SWAP_SUPPRESS_WINDOW_MS = 1e3;
46340
46631
  // ── View Control (Phase 2) ─────────────────────────────────────────────────
46341
46632
  // Zoom math constants (shared by getZoomLevel / setZoomLevel)
46342
46633
  _MapApi.VIEWPORT_H = 800;
@@ -48258,6 +48549,12 @@ var RenderEngineApi = class {
48258
48549
  lc.transitionDimensions(targetDim);
48259
48550
  }
48260
48551
  this.renderer.setMode(targetDim === 2 ? "2D" : "3D");
48552
+ if (this.map.isEnabled()) {
48553
+ const targetMode = targetDim === 3 ? "spherical" : "planar";
48554
+ if (this.map.getMode() !== targetMode) {
48555
+ void this.map.transition(targetMode);
48556
+ }
48557
+ }
48261
48558
  }
48262
48559
  /**
48263
48560
  * Return the currently active dimension (2 or 3).
@@ -48292,7 +48589,7 @@ var RenderEngineApi = class {
48292
48589
 
48293
48590
  // src/interaction/hover/HoverEmphasisController.ts
48294
48591
  var FRAME_KEY = "hoverDimAnim";
48295
- var DEFAULTS2 = { duration: 200, dimOpacity: 0.15, enabled: false, glowEnabled: true, glowStrength: 1, haloStrength: 1 };
48592
+ var DEFAULTS2 = { duration: 200, dimOpacity: 0.15, dimEnabled: false, glowEnabled: true, glowStrength: 1, haloStrength: 1 };
48296
48593
  var INSTANT_THRESHOLD_MS = 1;
48297
48594
  function easeInOutCubic2(x3) {
48298
48595
  return x3 < 0.5 ? 4 * x3 * x3 * x3 : 1 - Math.pow(-2 * x3 + 2, 3) / 2;
@@ -48311,7 +48608,7 @@ var HoverEmphasisController = class {
48311
48608
  // the dim state is fully driven by whoever called setExternalKeepSet
48312
48609
  // (typically the trace-neighbors toolbar handler or another host UI).
48313
48610
  this._externalKeep = null;
48314
- // _config.enabled snapshot taken on the first setExternalKeepSet call.
48611
+ // _config.dimEnabled snapshot taken on the first setExternalKeepSet call.
48315
48612
  // clearExternalKeepSet uses it to restore the host's pre-external intent
48316
48613
  // synchronously, so a trace started with hover-dim disabled returns
48317
48614
  // to enabled=false IMMEDIATELY (not after the ramp). The synchronous
@@ -48358,6 +48655,31 @@ var HoverEmphasisController = class {
48358
48655
  }
48359
48656
  return { nodes, edges: /* @__PURE__ */ new Set([target.index]) };
48360
48657
  }
48658
+ /**
48659
+ * Glow-only keep set: just the hovered target, no neighbors. Used when
48660
+ * `dimEnabled` is false — the hover ring is drawn on the node/edge under
48661
+ * the cursor and nothing else lights up or dims.
48662
+ */
48663
+ _singletonKeepSet(target) {
48664
+ if (target == null) return null;
48665
+ if (target.kind === "node") {
48666
+ return { nodes: /* @__PURE__ */ new Set([target.index]), edges: /* @__PURE__ */ new Set() };
48667
+ }
48668
+ return { nodes: /* @__PURE__ */ new Set(), edges: /* @__PURE__ */ new Set([target.index]) };
48669
+ }
48670
+ /**
48671
+ * Pick the keep set for a hover target by feature mode. Dim on → the full
48672
+ * 1-hop neighborhood (so neighbors stay bright); dim off (glow-only) → just
48673
+ * the hovered target so the ring is scoped to that node/edge.
48674
+ */
48675
+ _keepSetFor(target) {
48676
+ return this._config.dimEnabled ? this._computeKeepSet(target) : this._singletonKeepSet(target);
48677
+ }
48678
+ /** True when at least one hover feature (glow ring or dim) is active, i.e.
48679
+ * hover events should be processed. */
48680
+ _wantsHover() {
48681
+ return this._config.glowEnabled !== false || this._config.dimEnabled === true;
48682
+ }
48361
48683
  /**
48362
48684
  * Diff writer: drives the GPU-side bit 16 (hoverDim) on nodes/edges.
48363
48685
  * - next == null → hover-leave: clear all bits, drop keep-set.
@@ -48373,6 +48695,7 @@ var HoverEmphasisController = class {
48373
48695
  this.deps.setHoverTimeUniform(Math.floor(now2) % 524288);
48374
48696
  const g = this._config.glowEnabled === false ? 0 : this._config.glowStrength ?? 1;
48375
48697
  const h = this._config.glowEnabled === false ? 0 : this._config.haloStrength ?? 1;
48698
+ const dim = this._config.dimEnabled === true;
48376
48699
  if (next == null) {
48377
48700
  this.deps.clearAllHoverDimBits();
48378
48701
  this.deps.clearAllEmphasisGlow();
@@ -48380,11 +48703,13 @@ var HoverEmphasisController = class {
48380
48703
  return;
48381
48704
  }
48382
48705
  if (prev == null) {
48383
- for (let i = 0; i < this.deps.nodeCount; i++) {
48384
- if (!next.nodes.has(i)) this.deps.setNodeHoverDimBit(i, 1);
48385
- }
48386
- for (let i = 0; i < this.deps.edgeCount; i++) {
48387
- if (!next.edges.has(i)) this.deps.setEdgeHoverDimBit(i, 1);
48706
+ if (dim) {
48707
+ for (let i = 0; i < this.deps.nodeCount; i++) {
48708
+ if (!next.nodes.has(i)) this.deps.setNodeHoverDimBit(i, 1);
48709
+ }
48710
+ for (let i = 0; i < this.deps.edgeCount; i++) {
48711
+ if (!next.edges.has(i)) this.deps.setEdgeHoverDimBit(i, 1);
48712
+ }
48388
48713
  }
48389
48714
  for (const idx of next.nodes) this.deps.setNodeHalo(idx, h);
48390
48715
  for (const idx of next.edges) this.deps.setEdgeTubeGlow(idx, g);
@@ -48392,19 +48717,19 @@ var HoverEmphasisController = class {
48392
48717
  return;
48393
48718
  }
48394
48719
  for (const idx of prev.nodes) if (!next.nodes.has(idx)) {
48395
- this.deps.setNodeHoverDimBit(idx, 1);
48720
+ if (dim) this.deps.setNodeHoverDimBit(idx, 1);
48396
48721
  this.deps.setNodeHalo(idx, 0);
48397
48722
  }
48398
48723
  for (const idx of next.nodes) if (!prev.nodes.has(idx)) {
48399
- this.deps.setNodeHoverDimBit(idx, 0);
48724
+ if (dim) this.deps.setNodeHoverDimBit(idx, 0);
48400
48725
  this.deps.setNodeHalo(idx, h);
48401
48726
  }
48402
48727
  for (const idx of prev.edges) if (!next.edges.has(idx)) {
48403
- this.deps.setEdgeHoverDimBit(idx, 1);
48728
+ if (dim) this.deps.setEdgeHoverDimBit(idx, 1);
48404
48729
  this.deps.setEdgeTubeGlow(idx, 0);
48405
48730
  }
48406
48731
  for (const idx of next.edges) if (!prev.edges.has(idx)) {
48407
- this.deps.setEdgeHoverDimBit(idx, 0);
48732
+ if (dim) this.deps.setEdgeHoverDimBit(idx, 0);
48408
48733
  this.deps.setEdgeTubeGlow(idx, g);
48409
48734
  }
48410
48735
  this._keep = next;
@@ -48432,38 +48757,63 @@ var HoverEmphasisController = class {
48432
48757
  this.deps.clearAllEmphasisGlow();
48433
48758
  this.deps.requestRender();
48434
48759
  }
48760
+ this._reconcile();
48435
48761
  }
48436
- if (partial.enabled != null) this.setEnabled(partial.enabled);
48762
+ if (partial.dimEnabled != null) this.setDimEnabled(partial.dimEnabled);
48763
+ if (partial.enabled != null) this.setDimEnabled(partial.enabled);
48437
48764
  }
48438
- setEnabled(enabled) {
48439
- this._config.enabled = enabled;
48765
+ /** Enable/disable the dim feature (fade everything outside the kept set).
48766
+ * Independent of the glow ring. */
48767
+ setDimEnabled(enabled) {
48768
+ this._config.dimEnabled = enabled;
48440
48769
  if (!enabled) {
48770
+ this.deps.clearAllHoverDimBits();
48771
+ this.deps.requestRender();
48772
+ }
48773
+ this._reconcile();
48774
+ }
48775
+ /** @deprecated Legacy master switch. Maps to {@link setDimEnabled} — the
48776
+ * hover ring is governed independently by `glowEnabled`. */
48777
+ setEnabled(enabled) {
48778
+ this.setDimEnabled(enabled);
48779
+ }
48780
+ /** Reconcile the Disabled state with the two feature flags: the controller
48781
+ * is hard-disabled only when NEITHER glow nor dim wants to act. */
48782
+ _reconcile() {
48783
+ if (!this._wantsHover()) {
48441
48784
  this._enterDisabled();
48442
48785
  } else if (this._state === "Disabled") {
48443
48786
  this._state = "Idle";
48444
48787
  }
48445
48788
  }
48789
+ /** @deprecated Returns whether the DIM feature is enabled (legacy name). */
48446
48790
  isEnabled() {
48447
- return this._config.enabled;
48791
+ return this._config.dimEnabled;
48792
+ }
48793
+ isDimEnabled() {
48794
+ return this._config.dimEnabled;
48795
+ }
48796
+ isGlowEnabled() {
48797
+ return this._config.glowEnabled !== false;
48448
48798
  }
48449
48799
  getConfig() {
48450
48800
  return { ...this._config };
48451
48801
  }
48452
48802
  onHoverEnter(target) {
48453
- if (!this._config.enabled) return;
48803
+ if (!this._wantsHover()) return;
48454
48804
  if (this._state === "Disabled" || this._state === "Suppressed") return;
48455
48805
  if (this._externalKeep) return;
48456
- const next = this._computeKeepSet(target);
48806
+ const next = this._keepSetFor(target);
48457
48807
  this._applyKeepSet(this._keep, next);
48458
48808
  this._goRampingUp();
48459
48809
  this.deps.requestRender();
48460
48810
  }
48461
48811
  onHoverMove(target) {
48462
- if (!this._config.enabled) return;
48812
+ if (!this._wantsHover()) return;
48463
48813
  if (this._state === "Disabled" || this._state === "Suppressed") return;
48464
48814
  if (this._externalKeep) return;
48465
48815
  if (this._state === "Idle") return this.onHoverEnter(target);
48466
- const next = this._computeKeepSet(target);
48816
+ const next = this._keepSetFor(target);
48467
48817
  this._applyKeepSet(this._keep, next);
48468
48818
  this.deps.requestRender();
48469
48819
  }
@@ -48497,10 +48847,10 @@ var HoverEmphasisController = class {
48497
48847
  }
48498
48848
  const next = { nodes, edges };
48499
48849
  if (this._externalEnabledBefore === null) {
48500
- this._externalEnabledBefore = this._config.enabled;
48850
+ this._externalEnabledBefore = this._config.dimEnabled;
48501
48851
  }
48502
- if (!this._config.enabled) {
48503
- this._config.enabled = true;
48852
+ if (!this._config.dimEnabled) {
48853
+ this._config.dimEnabled = true;
48504
48854
  this.deps.setHoverProgressUniform(1);
48505
48855
  }
48506
48856
  this._applyKeepSet(this._externalKeep ?? this._keep, next);
@@ -48510,22 +48860,22 @@ var HoverEmphasisController = class {
48510
48860
  this.deps.requestRender();
48511
48861
  }
48512
48862
  /** Cancel the programmatic dim. Per-instance un-dim ramps fire smoothly.
48513
- * Restores the pre-external `_config.enabled` so a trace started with
48863
+ * Restores the pre-external `_config.dimEnabled` so a trace started with
48514
48864
  * hover-dim disabled stays off — even if a click happens MID-ramp.
48515
- * We set `_config.enabled` synchronously (rather than deferring to
48865
+ * We set `_config.dimEnabled` synchronously (rather than deferring to
48516
48866
  * `_enterIdle`) because `onMouseDown` unregisters the ramp frame
48517
48867
  * callback as part of Suppressed-state housekeeping; without an
48518
48868
  * immediate flip, click→mouseup leaves the controller in Idle with
48519
- * `enabled === true`, and the next hover re-triggers dim. The state
48869
+ * `dimEnabled === true`, and the next hover re-triggers dim. The state
48520
48870
  * machine still cycles through RampingDown→Idle to play the visual
48521
- * un-dim animation; `onHoverEnter`/`onHoverMove` gate on `_config.enabled`
48522
- * directly so the intermediate states don't admit hover events. */
48871
+ * un-dim animation; `onHoverEnter`/`onHoverMove` scope the kept set by
48872
+ * `dimEnabled` so the intermediate states draw the ring without dimming. */
48523
48873
  clearExternalKeepSet() {
48524
48874
  if (!this._externalKeep) return;
48525
48875
  this._applyKeepSet(this._externalKeep, null);
48526
48876
  this._externalKeep = null;
48527
48877
  if (this._externalEnabledBefore === false) {
48528
- this._config.enabled = false;
48878
+ this._config.dimEnabled = false;
48529
48879
  }
48530
48880
  this._externalEnabledBefore = null;
48531
48881
  this._goRampingDown();
@@ -50256,7 +50606,7 @@ function useControlledHover(api, controlled, onChange) {
50256
50606
  }
50257
50607
 
50258
50608
  // src/react/GraphContext.tsx
50259
- import { Fragment as Fragment4, jsx as jsx32, jsxs as jsxs22 } from "react/jsx-runtime";
50609
+ import { Fragment as Fragment5, jsx as jsx32, jsxs as jsxs22 } from "react/jsx-runtime";
50260
50610
  var _aliasWarnCache = /* @__PURE__ */ new Set();
50261
50611
  function resolveAliasProp(newName, oldName, newVal, oldVal, defaultVal) {
50262
50612
  if (newVal === void 0 && oldVal === void 0) return defaultVal;
@@ -50390,7 +50740,9 @@ function useIs3D() {
50390
50740
  return { is3D, setIs3D };
50391
50741
  }
50392
50742
  var GraphThemes = {
50393
- dark: { background: 1710638, isDark: true },
50743
+ // Neutral charcoal (no blue tint) — matches the UI chrome dark base
50744
+ // (--gxr-panel-bg #1c1c1c in tokens.css) so canvas and panels agree.
50745
+ dark: { background: 1842204, isDark: true },
50394
50746
  light: { background: 16119285, isDark: false },
50395
50747
  midnight: { background: 858922, isDark: true },
50396
50748
  forest: { background: 1715738, isDark: true },
@@ -50450,7 +50802,7 @@ function GraphRenderer({
50450
50802
  data: dataProp,
50451
50803
  minimap: minimapProp = true,
50452
50804
  map: mapProp,
50453
- toolbar: toolbarProp = true,
50805
+ toolbar: toolbarProp = false,
50454
50806
  legend: legendProp,
50455
50807
  layoutController,
50456
50808
  forceLayout,
@@ -50465,7 +50817,7 @@ function GraphRenderer({
50465
50817
  mapProjection: mapProjectionProp,
50466
50818
  onThemeChange,
50467
50819
  onViewChange,
50468
- hoverDim = true,
50820
+ hoverDim = false,
50469
50821
  // Phase 2 — interaction callbacks
50470
50822
  onNodeClick,
50471
50823
  onNodeDoubleClick,
@@ -50610,6 +50962,7 @@ function GraphRenderer({
50610
50962
  const glyphAtlasManagerRef = useRef22(null);
50611
50963
  const imageSyncRequestRef = useRef22(0);
50612
50964
  const pendingStructureChangeRef = useRef22(false);
50965
+ const geoSettleSigRef = useRef22("");
50613
50966
  const layoutAdapterRef = useRef22(null);
50614
50967
  const layoutControllerRef = useRef22(layoutController);
50615
50968
  const forceWasFinishedRef = useRef22(void 0);
@@ -50769,12 +51122,16 @@ function GraphRenderer({
50769
51122
  if (api2?.map) {
50770
51123
  const mode = is3D ? "spherical" : "planar";
50771
51124
  const provider = effectiveMap.tileProvider;
50772
- void api2.map.enableMap({
50773
- mode,
50774
- ...typeof provider === "string" && provider.length > 0 ? { provider } : {},
50775
- ...effectiveMap.mapSize !== void 0 ? { mapSize: effectiveMap.mapSize } : {},
50776
- ...effectiveMap.globeRadius !== void 0 ? { globeRadius: effectiveMap.globeRadius } : {}
50777
- });
51125
+ if (api2.map.isEnabled()) {
51126
+ if (api2.map.getMode() !== mode) void api2.map.transition(mode);
51127
+ } else {
51128
+ void api2.map.enableMap({
51129
+ mode,
51130
+ ...typeof provider === "string" && provider.length > 0 ? { provider } : {},
51131
+ ...effectiveMap.mapSize !== void 0 ? { mapSize: effectiveMap.mapSize } : {},
51132
+ ...effectiveMap.globeRadius !== void 0 ? { globeRadius: effectiveMap.globeRadius } : {}
51133
+ });
51134
+ }
50778
51135
  }
50779
51136
  }, [effectiveMap, is3D, contextValue]);
50780
51137
  React30.useEffect(() => {
@@ -50789,8 +51146,12 @@ function GraphRenderer({
50789
51146
  setAutoMapLayerType(null);
50790
51147
  return;
50791
51148
  }
50792
- setAutoMapLayerType(is3D ? "globe" : "flat");
50793
- }, [effectiveMap, is3D, children]);
51149
+ const nextType = is3D ? "globe" : "flat";
51150
+ if (autoMapLayerType && autoMapLayerType !== nextType) {
51151
+ apiInstanceRef.current?.map.beginLayerSwap();
51152
+ }
51153
+ setAutoMapLayerType(nextType);
51154
+ }, [effectiveMap, is3D, children, autoMapLayerType]);
50794
51155
  React30.useEffect(() => {
50795
51156
  const api2 = apiInstanceRef.current;
50796
51157
  if (!api2) return;
@@ -51020,6 +51381,7 @@ function GraphRenderer({
51020
51381
  if (!container.style.position || container.style.position === "static") {
51021
51382
  container.style.position = "relative";
51022
51383
  }
51384
+ container.style.backgroundColor = "#" + effectiveBackground.toString(16).padStart(6, "0");
51023
51385
  const canvas = renderer.domElement;
51024
51386
  canvas.style.position = "absolute";
51025
51387
  canvas.style.top = "0";
@@ -51309,8 +51671,8 @@ function GraphRenderer({
51309
51671
  edgeR?.setSphereRadius(sphereRadius ?? 0);
51310
51672
  interaction?.picker?.setMapMode(enabled, sphereRadius, damping);
51311
51673
  control?.setMapMode(enabled);
51312
- if (interaction) {
51313
- interaction.drag.enabled = !enabled;
51674
+ if (interaction && !enabled) {
51675
+ interaction.drag.enabled = true;
51314
51676
  }
51315
51677
  mapModeCallbacksRef.current.forEach((cb) => cb(enabled, sphereRadius, damping));
51316
51678
  mapDampingRef.current = damping ?? 0.3;
@@ -51600,21 +51962,21 @@ function GraphRenderer({
51600
51962
  if (lc?.graph) {
51601
51963
  const storeNodes = store.data.nodes;
51602
51964
  const storeEdges = store.data.edges;
51965
+ const livePositions = store.getAllPositions();
51603
51966
  const oldPositions = /* @__PURE__ */ new Map();
51604
51967
  for (const ln of lc.graph.layoutNodes || []) {
51605
- oldPositions.set(ln.id, {
51606
- x: ln.position.x,
51607
- y: ln.position.y,
51608
- z: ln.position.z,
51609
- pinned: ln.pinned
51610
- });
51968
+ oldPositions.set(ln.id, { x: ln.position.x, y: ln.position.y, z: ln.position.z, pinned: ln.pinned });
51611
51969
  }
51612
51970
  lc.graph.layoutNodes = storeNodes.map((node) => {
51613
- const old = oldPositions.get(node.id);
51971
+ const live = livePositions.get(node.id);
51972
+ const old = live ? void 0 : oldPositions.get(node.id);
51973
+ const px = live ? live[0] : old ? old.x : Math.random() * 2 - 1;
51974
+ const py = live ? live[1] : old ? old.y : Math.random() * 2 - 1;
51975
+ const pz = live ? live[2] : old ? old.z : 0;
51614
51976
  return {
51615
51977
  id: node.id,
51616
- position: old ? new THREE46.Vector3(old.x, old.y, old.z) : new THREE46.Vector3(Math.random() * 2 - 1, Math.random() * 2 - 1, 0),
51617
- pinned: old?.pinned ?? false,
51978
+ position: new THREE46.Vector3(px, py, pz),
51979
+ pinned: store.isPinned(node.id),
51618
51980
  isPositionDirty: false
51619
51981
  };
51620
51982
  });
@@ -51624,6 +51986,7 @@ function GraphRenderer({
51624
51986
  targetId: edge.target
51625
51987
  }));
51626
51988
  lc.start?.();
51989
+ geoSettleSigRef.current = "";
51627
51990
  }
51628
51991
  }
51629
51992
  if (layoutAdapter && layoutAdapter.needsUpdate && "clearNeedsUpdate" in layoutAdapter) {
@@ -51638,6 +52001,22 @@ function GraphRenderer({
51638
52001
  lcRef.graph.renderNeedsUpdate = false;
51639
52002
  }
51640
52003
  }
52004
+ {
52005
+ const mapApi = apiInstanceRef.current?.map;
52006
+ if (!mapApi?.isEnabled?.()) {
52007
+ geoSettleSigRef.current = "";
52008
+ } else {
52009
+ const mode = mapApi.getMode();
52010
+ const n = store.data.nodes.length;
52011
+ const buf = store.positionProvider?.getPositions?.();
52012
+ const bufReady = !!buf && buf.length >= n * 3 && n > 0 && (buf[0] !== 0 || buf[1] !== 0 || buf[2] !== 0);
52013
+ const sig = `${n}|${mode}`;
52014
+ if (bufReady && mode && sig !== geoSettleSigRef.current) {
52015
+ geoSettleSigRef.current = sig;
52016
+ mapApi.applyGeoLayout({ mode });
52017
+ }
52018
+ }
52019
+ }
51641
52020
  if (nodeRendererRef.current && !childNodeRendererRef.current) {
51642
52021
  nodeRendererRef.current.forceUpdateAllAttributes();
51643
52022
  }
@@ -51753,7 +52132,11 @@ function GraphRenderer({
51753
52132
  renderer.setClearColor(effectiveBackground, 1);
51754
52133
  needsRenderRef.current = true;
51755
52134
  }
51756
- }, [effectiveBackground]);
52135
+ const host = containerProp ?? internalContainer;
52136
+ if (host) {
52137
+ host.style.backgroundColor = "#" + effectiveBackground.toString(16).padStart(6, "0");
52138
+ }
52139
+ }, [effectiveBackground, containerProp, internalContainer]);
51757
52140
  useEffect26(() => {
51758
52141
  if (contextValue) {
51759
52142
  setContextValue((prev) => prev ? { ...prev, theme: resolvedTheme } : prev);
@@ -51772,7 +52155,7 @@ function GraphRenderer({
51772
52155
  }
51773
52156
  }, [isMapMode]);
51774
52157
  useEffect26(() => {
51775
- apiInstanceRef.current?.emphasis.setHoverEnabled(!!hoverDim);
52158
+ apiInstanceRef.current?.emphasis.setHoverDimEnabled(!!hoverDim);
51776
52159
  }, [hoverDim, contextValue]);
51777
52160
  useEffect26(() => {
51778
52161
  if (is3DProp === is3D) return;
@@ -52332,7 +52715,7 @@ function GraphRenderer({
52332
52715
  useEffect26(() => {
52333
52716
  containerRef.current = containerProp ?? null;
52334
52717
  }, [containerProp]);
52335
- const handleQuickCreateDone = useCallback18(() => {
52718
+ const handleQuickCreateDone = useCallback17(() => {
52336
52719
  setEdgeCreateResult(null);
52337
52720
  needsRenderRef.current = true;
52338
52721
  }, []);
@@ -52649,7 +53032,7 @@ function GraphRenderer({
52649
53032
  ) : null;
52650
53033
  const captionPropResolved = resolveBoolOrConfig(captionProp);
52651
53034
  const edgeCaptionPropResolved = resolveBoolOrConfig(edgeCaptionProp);
52652
- const autoTextLayers = !hasChildren && /* @__PURE__ */ jsxs22(Fragment4, { children: [
53035
+ const autoTextLayers = !hasChildren && /* @__PURE__ */ jsxs22(Fragment5, { children: [
52653
53036
  captionPropResolved && captionPropResolved.visible !== false && /* @__PURE__ */ jsx32(
52654
53037
  TextLayer,
52655
53038
  {