@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/README.md +95 -60
- package/dist/index.d.mts +162 -32
- package/dist/index.d.ts +162 -32
- package/dist/index.js +560 -177
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +620 -237
- package/dist/index.mjs.map +1 -1
- package/dist/kineviz-gl.umd.js +2269 -2249
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8221,6 +8221,9 @@ var WebGPUForceLayoutController = class {
|
|
|
8221
8221
|
sn.fx = ln.position.x;
|
|
8222
8222
|
sn.fy = ln.position.y;
|
|
8223
8223
|
sn.fz = ln.position.z;
|
|
8224
|
+
sn.x = ln.position.x;
|
|
8225
|
+
sn.y = ln.position.y;
|
|
8226
|
+
sn.z = ln.position.z;
|
|
8224
8227
|
} else if (useRandom3D) {
|
|
8225
8228
|
const u = Math.random(), v = Math.random(), w = Math.random();
|
|
8226
8229
|
const theta = 2 * Math.PI * u;
|
|
@@ -8504,6 +8507,9 @@ var WebGPUForceLayoutController = class {
|
|
|
8504
8507
|
sn.fx = node.position.x;
|
|
8505
8508
|
sn.fy = node.position.y;
|
|
8506
8509
|
sn.fz = node.position.z;
|
|
8510
|
+
sn.x = node.position.x;
|
|
8511
|
+
sn.y = node.position.y;
|
|
8512
|
+
sn.z = node.position.z;
|
|
8507
8513
|
this.simulation.uploadPosition(idx, node.position.x, node.position.y, node.position.z);
|
|
8508
8514
|
this.simulation.uploadPinned(idx, true);
|
|
8509
8515
|
} else {
|
|
@@ -14755,10 +14761,10 @@ var THREE14 = __toESM(require("three"));
|
|
|
14755
14761
|
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';
|
|
14756
14762
|
|
|
14757
14763
|
// src/shaders/node.frag.glsl
|
|
14758
|
-
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";
|
|
14764
|
+
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";
|
|
14759
14765
|
|
|
14760
14766
|
// src/shaders/edge.vert.glsl
|
|
14761
|
-
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";
|
|
14767
|
+
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";
|
|
14762
14768
|
|
|
14763
14769
|
// src/shaders/edge.frag.glsl
|
|
14764
14770
|
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";
|
|
@@ -14770,7 +14776,7 @@ var picking_vert_default = "// Mirrors node.vert.glsl billboard math. Intentiona
|
|
|
14770
14776
|
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";
|
|
14771
14777
|
|
|
14772
14778
|
// src/shaders/arrow.vert.glsl
|
|
14773
|
-
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";
|
|
14779
|
+
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";
|
|
14774
14780
|
|
|
14775
14781
|
// src/shaders/arrow.frag.glsl
|
|
14776
14782
|
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";
|
|
@@ -19927,6 +19933,10 @@ var InteractionCoordinator = class {
|
|
|
19927
19933
|
// Original enabled states (for restoration)
|
|
19928
19934
|
this.graphControlWasEnabled = true;
|
|
19929
19935
|
this.dragHandlerWasEnabled = true;
|
|
19936
|
+
// When true, GlobeControl (or another external control) owns background
|
|
19937
|
+
// pan/rotate gestures; coordinator skips them so the DragHandler stays
|
|
19938
|
+
// enabled and node-drag keeps working in globe mode.
|
|
19939
|
+
this._bgGestureExternal = false;
|
|
19930
19940
|
this.picker = picker;
|
|
19931
19941
|
this.dragHandler = dragHandler;
|
|
19932
19942
|
this.graphControl = graphControl;
|
|
@@ -19945,6 +19955,16 @@ var InteractionCoordinator = class {
|
|
|
19945
19955
|
get globeMode() {
|
|
19946
19956
|
return this.config.globeMode;
|
|
19947
19957
|
}
|
|
19958
|
+
/**
|
|
19959
|
+
* When true, an external control (GlobeControl) owns background pan/rotate
|
|
19960
|
+
* gestures, so the coordinator skips enterPanMode/enterRotateMode on
|
|
19961
|
+
* background mousedown. This keeps the DragHandler enabled so node-drag still
|
|
19962
|
+
* works in globe mode (otherwise enterPanMode disables it). Set by GlobeLayer
|
|
19963
|
+
* on mount, cleared on unmount. Node/group drags are unaffected.
|
|
19964
|
+
*/
|
|
19965
|
+
setBackgroundGestureExternal(enabled) {
|
|
19966
|
+
this._bgGestureExternal = enabled;
|
|
19967
|
+
}
|
|
19948
19968
|
/**
|
|
19949
19969
|
* Set the PathSelectHandler for Shift+drag path selection.
|
|
19950
19970
|
*/
|
|
@@ -20024,12 +20044,14 @@ var InteractionCoordinator = class {
|
|
|
20024
20044
|
return;
|
|
20025
20045
|
}
|
|
20026
20046
|
}
|
|
20047
|
+
if (this._bgGestureExternal) return;
|
|
20027
20048
|
this.enterPanMode();
|
|
20028
20049
|
}
|
|
20029
20050
|
} else if (event.button === 2) {
|
|
20030
20051
|
if (pickResult.type === "node" && pickResult.picked) {
|
|
20031
20052
|
this.debug("Right click on node - context menu territory");
|
|
20032
20053
|
} else {
|
|
20054
|
+
if (this._bgGestureExternal) return;
|
|
20033
20055
|
this.enterRotateMode();
|
|
20034
20056
|
}
|
|
20035
20057
|
}
|
|
@@ -20053,6 +20075,10 @@ var InteractionCoordinator = class {
|
|
|
20053
20075
|
case "rotate":
|
|
20054
20076
|
return false;
|
|
20055
20077
|
case "idle":
|
|
20078
|
+
if (!this.isEventOverCanvas(event)) {
|
|
20079
|
+
this.hoverHandler.onMouseLeave();
|
|
20080
|
+
return false;
|
|
20081
|
+
}
|
|
20056
20082
|
this.hoverHandler.onMouseMove(screenX, screenY);
|
|
20057
20083
|
return false;
|
|
20058
20084
|
default:
|
|
@@ -20179,6 +20205,19 @@ var InteractionCoordinator = class {
|
|
|
20179
20205
|
this.debug("Reset to idle state");
|
|
20180
20206
|
}
|
|
20181
20207
|
// ==================== Utilities ====================
|
|
20208
|
+
/**
|
|
20209
|
+
* True when the event originated on the renderer canvas itself, not on an
|
|
20210
|
+
* overlay element (panel / toolbar / legend) layered inside the container.
|
|
20211
|
+
* Mirrors the `event.target === renderer.domElement` guard used for
|
|
20212
|
+
* mousedown / click / contextmenu in InteractionManager. When the canvas
|
|
20213
|
+
* element is unavailable we fail open (treat as over-canvas) to avoid
|
|
20214
|
+
* silently disabling hover.
|
|
20215
|
+
*/
|
|
20216
|
+
isEventOverCanvas(event) {
|
|
20217
|
+
const canvas = this.dragHandler.getRendererElement?.();
|
|
20218
|
+
if (!canvas) return true;
|
|
20219
|
+
return event.target === canvas;
|
|
20220
|
+
}
|
|
20182
20221
|
debug(message) {
|
|
20183
20222
|
if (this.config.debug) {
|
|
20184
20223
|
console.log(`[InteractionCoordinator] ${message}`);
|
|
@@ -21821,7 +21860,11 @@ var _InteractionManager = class _InteractionManager {
|
|
|
21821
21860
|
}
|
|
21822
21861
|
}
|
|
21823
21862
|
if (!this.drag.isDragging) {
|
|
21824
|
-
this.
|
|
21863
|
+
if (event.target === this.renderer.domElement) {
|
|
21864
|
+
this.hover.onMouseMove(x3, y3);
|
|
21865
|
+
} else {
|
|
21866
|
+
this.hover.onMouseLeave();
|
|
21867
|
+
}
|
|
21825
21868
|
}
|
|
21826
21869
|
}
|
|
21827
21870
|
handleMouseUp(event) {
|
|
@@ -26087,7 +26130,17 @@ function useBlockNativeSceneEvents2(ref) {
|
|
|
26087
26130
|
};
|
|
26088
26131
|
}, [ref]);
|
|
26089
26132
|
}
|
|
26090
|
-
function
|
|
26133
|
+
function nodeColor(store, nodeId) {
|
|
26134
|
+
const idx = store.index.getNodeIndex(nodeId);
|
|
26135
|
+
const ns = store.nodeState;
|
|
26136
|
+
if (idx === void 0 || !ns) return "var(--gxr-accent)";
|
|
26137
|
+
const c2 = ns.colors;
|
|
26138
|
+
const r = Math.round((c2[idx * 3] ?? 0) * 255);
|
|
26139
|
+
const g = Math.round((c2[idx * 3 + 1] ?? 0) * 255);
|
|
26140
|
+
const b = Math.round((c2[idx * 3 + 2] ?? 0) * 255);
|
|
26141
|
+
return `rgb(${r}, ${g}, ${b})`;
|
|
26142
|
+
}
|
|
26143
|
+
function NodeInfoPanel({ manager, store, container, showExpandNeighbors, onExpandNeighbors }) {
|
|
26091
26144
|
const [state, setState] = (0, import_react5.useState)(manager.state);
|
|
26092
26145
|
const hasDraggedRef = (0, import_react5.useRef)(false);
|
|
26093
26146
|
(0, import_react5.useEffect)(() => {
|
|
@@ -26102,7 +26155,9 @@ function NodeInfoPanel({ manager, store, container }) {
|
|
|
26102
26155
|
store,
|
|
26103
26156
|
container,
|
|
26104
26157
|
manager,
|
|
26105
|
-
hasDraggedRef
|
|
26158
|
+
hasDraggedRef,
|
|
26159
|
+
showExpandNeighbors,
|
|
26160
|
+
onExpandNeighbors
|
|
26106
26161
|
}
|
|
26107
26162
|
);
|
|
26108
26163
|
}
|
|
@@ -26112,7 +26167,9 @@ function NodeInfoPanelInner({
|
|
|
26112
26167
|
store,
|
|
26113
26168
|
container,
|
|
26114
26169
|
manager,
|
|
26115
|
-
hasDraggedRef
|
|
26170
|
+
hasDraggedRef,
|
|
26171
|
+
showExpandNeighbors,
|
|
26172
|
+
onExpandNeighbors
|
|
26116
26173
|
}) {
|
|
26117
26174
|
const panelRef = (0, import_react5.useRef)(null);
|
|
26118
26175
|
const dragTransformRef = (0, import_react5.useRef)({ x: 0, y: 0 });
|
|
@@ -26165,6 +26222,7 @@ function NodeInfoPanelInner({
|
|
|
26165
26222
|
const header = headerRef.current;
|
|
26166
26223
|
if (!header) return;
|
|
26167
26224
|
const onMouseDown = (e) => {
|
|
26225
|
+
if (e.target.closest("[data-no-drag]")) return;
|
|
26168
26226
|
e.preventDefault();
|
|
26169
26227
|
hasDraggedRef.current = false;
|
|
26170
26228
|
const startX = e.clientX;
|
|
@@ -26194,9 +26252,34 @@ function NodeInfoPanelInner({
|
|
|
26194
26252
|
const title = resolveNodeTitle(node);
|
|
26195
26253
|
const imageResult = findFirstImage(node.properties);
|
|
26196
26254
|
const showImage = imageResult && !imageError;
|
|
26197
|
-
const
|
|
26198
|
-
const
|
|
26199
|
-
const
|
|
26255
|
+
const avatarColor = nodeColor(store, nodeId);
|
|
26256
|
+
const sourceRaw = node.properties["_source"];
|
|
26257
|
+
const sourceStr = sourceRaw === void 0 || sourceRaw === null ? "" : String(sourceRaw);
|
|
26258
|
+
const propEntries = Object.entries(node.properties).filter(([key, value]) => {
|
|
26259
|
+
if (key.startsWith("_")) return false;
|
|
26260
|
+
if (imageResult && key === imageResult.key) return false;
|
|
26261
|
+
if (String(value ?? "") === title) return false;
|
|
26262
|
+
return true;
|
|
26263
|
+
});
|
|
26264
|
+
const seen = /* @__PURE__ */ new Set();
|
|
26265
|
+
const relations = [];
|
|
26266
|
+
for (const n of store.queries.getNeighbors(nodeId)) {
|
|
26267
|
+
if (seen.has(n.nodeId)) continue;
|
|
26268
|
+
const neighbor = store.queries.getNode(n.nodeId);
|
|
26269
|
+
if (!neighbor) continue;
|
|
26270
|
+
seen.add(n.nodeId);
|
|
26271
|
+
relations.push({
|
|
26272
|
+
id: n.nodeId,
|
|
26273
|
+
title: resolveNodeTitle(neighbor),
|
|
26274
|
+
category: neighbor.category,
|
|
26275
|
+
color: nodeColor(store, n.nodeId)
|
|
26276
|
+
});
|
|
26277
|
+
}
|
|
26278
|
+
const navigateTo = (id) => {
|
|
26279
|
+
store.selectNodes([id]);
|
|
26280
|
+
manager.show(id, rawPosition);
|
|
26281
|
+
};
|
|
26282
|
+
const SECTION_PAD = "14px 16px";
|
|
26200
26283
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
26201
26284
|
"div",
|
|
26202
26285
|
{
|
|
@@ -26208,9 +26291,12 @@ function NodeInfoPanelInner({
|
|
|
26208
26291
|
top: clampedPos.top,
|
|
26209
26292
|
zIndex: 1e4,
|
|
26210
26293
|
width: 320,
|
|
26294
|
+
maxHeight: "82vh",
|
|
26295
|
+
display: "flex",
|
|
26296
|
+
flexDirection: "column",
|
|
26211
26297
|
background: "var(--gxr-panel-bg)",
|
|
26212
26298
|
border: `1px solid var(--gxr-panel-border)`,
|
|
26213
|
-
borderRadius:
|
|
26299
|
+
borderRadius: 12,
|
|
26214
26300
|
boxShadow: "var(--gxr-shadow)",
|
|
26215
26301
|
overflow: "hidden",
|
|
26216
26302
|
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
@@ -26223,130 +26309,217 @@ function NodeInfoPanelInner({
|
|
|
26223
26309
|
{
|
|
26224
26310
|
ref: headerRef,
|
|
26225
26311
|
style: {
|
|
26226
|
-
padding:
|
|
26227
|
-
background: "var(--gxr-panel-header-bg)",
|
|
26228
|
-
borderBottom: `1px solid var(--gxr-panel-border)`,
|
|
26312
|
+
padding: SECTION_PAD,
|
|
26229
26313
|
display: "flex",
|
|
26230
|
-
|
|
26231
|
-
|
|
26314
|
+
alignItems: "flex-start",
|
|
26315
|
+
gap: 14,
|
|
26232
26316
|
cursor: "move",
|
|
26233
26317
|
userSelect: "none"
|
|
26234
26318
|
},
|
|
26235
26319
|
children: [
|
|
26236
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
26237
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
26238
|
-
"span",
|
|
26239
|
-
{
|
|
26240
|
-
onClick: () => manager.hide(),
|
|
26241
|
-
style: { fontSize: 18, color: "var(--gxr-text-muted)", cursor: "pointer", lineHeight: 1 },
|
|
26242
|
-
children: "\xD7"
|
|
26243
|
-
}
|
|
26244
|
-
)
|
|
26245
|
-
]
|
|
26246
|
-
}
|
|
26247
|
-
),
|
|
26248
|
-
showImage ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
26249
|
-
"div",
|
|
26250
|
-
{
|
|
26251
|
-
style: {
|
|
26252
|
-
display: "flex",
|
|
26253
|
-
padding: 14,
|
|
26254
|
-
borderBottom: `1px solid var(--gxr-panel-border)`
|
|
26255
|
-
},
|
|
26256
|
-
children: [
|
|
26257
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
26320
|
+
showImage ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
26258
26321
|
"img",
|
|
26259
26322
|
{
|
|
26260
26323
|
src: imageResult.url,
|
|
26261
26324
|
onError: () => setImageError(true),
|
|
26325
|
+
style: { width: 52, height: 52, borderRadius: 12, objectFit: "cover", flexShrink: 0 }
|
|
26326
|
+
}
|
|
26327
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
26328
|
+
"div",
|
|
26329
|
+
{
|
|
26262
26330
|
style: {
|
|
26263
|
-
width:
|
|
26264
|
-
height:
|
|
26265
|
-
borderRadius:
|
|
26266
|
-
objectFit: "cover",
|
|
26331
|
+
width: 52,
|
|
26332
|
+
height: 52,
|
|
26333
|
+
borderRadius: 12,
|
|
26267
26334
|
flexShrink: 0,
|
|
26268
|
-
|
|
26269
|
-
boxShadow:
|
|
26335
|
+
background: avatarColor,
|
|
26336
|
+
boxShadow: `0 0 18px ${avatarColor}55`
|
|
26270
26337
|
}
|
|
26271
26338
|
}
|
|
26272
26339
|
),
|
|
26273
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: {
|
|
26274
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { color: "var(--gxr-text-primary)", fontSize: 15, fontWeight: 600, marginBottom: 6 }, children: title }),
|
|
26340
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { flex: 1, minWidth: 0 }, children: [
|
|
26275
26341
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
26276
26342
|
"div",
|
|
26277
26343
|
{
|
|
26278
26344
|
style: {
|
|
26279
|
-
color: "var(--gxr-
|
|
26280
|
-
fontSize:
|
|
26281
|
-
|
|
26282
|
-
|
|
26283
|
-
|
|
26284
|
-
|
|
26285
|
-
|
|
26286
|
-
marginBottom: 8
|
|
26345
|
+
color: "var(--gxr-text-primary)",
|
|
26346
|
+
fontSize: 20,
|
|
26347
|
+
fontWeight: 700,
|
|
26348
|
+
lineHeight: 1.2,
|
|
26349
|
+
overflow: "hidden",
|
|
26350
|
+
textOverflow: "ellipsis",
|
|
26351
|
+
whiteSpace: "nowrap"
|
|
26287
26352
|
},
|
|
26288
|
-
children:
|
|
26353
|
+
children: title
|
|
26289
26354
|
}
|
|
26290
26355
|
),
|
|
26291
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { color: "var(--gxr-text-
|
|
26292
|
-
|
|
26293
|
-
|
|
26356
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { color: "var(--gxr-text-secondary)", fontSize: 13, marginTop: 4 }, children: [
|
|
26357
|
+
node.category,
|
|
26358
|
+
sourceStr && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
26359
|
+
" \xB7 ",
|
|
26360
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: { color: "var(--gxr-text-muted)" }, children: [
|
|
26361
|
+
"_source: ",
|
|
26362
|
+
sourceStr
|
|
26363
|
+
] })
|
|
26364
|
+
] })
|
|
26294
26365
|
] })
|
|
26295
|
-
] })
|
|
26366
|
+
] }),
|
|
26367
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
26368
|
+
"span",
|
|
26369
|
+
{
|
|
26370
|
+
"data-no-drag": true,
|
|
26371
|
+
onClick: () => manager.hide(),
|
|
26372
|
+
style: { fontSize: 20, color: "var(--gxr-text-muted)", cursor: "pointer", lineHeight: 1, flexShrink: 0 },
|
|
26373
|
+
children: "\xD7"
|
|
26374
|
+
}
|
|
26375
|
+
)
|
|
26296
26376
|
]
|
|
26297
26377
|
}
|
|
26298
|
-
)
|
|
26299
|
-
|
|
26300
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { padding:
|
|
26301
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { color: "var(--gxr-text-primary)", fontSize: 15, fontWeight: 600, marginBottom: 4 }, children: title }),
|
|
26378
|
+
),
|
|
26379
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { overflowY: "auto", flex: 1 }, children: [
|
|
26380
|
+
propEntries.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { padding: SECTION_PAD, borderTop: `1px solid var(--gxr-panel-divider)` }, children: [
|
|
26302
26381
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
26303
26382
|
"div",
|
|
26304
26383
|
{
|
|
26305
26384
|
style: {
|
|
26306
|
-
color: "var(--gxr-
|
|
26307
|
-
fontSize:
|
|
26308
|
-
|
|
26309
|
-
|
|
26310
|
-
padding: "2px 8px",
|
|
26311
|
-
borderRadius: 4
|
|
26385
|
+
color: "var(--gxr-text-secondary)",
|
|
26386
|
+
fontSize: 13,
|
|
26387
|
+
marginBottom: 10,
|
|
26388
|
+
letterSpacing: 0.5
|
|
26312
26389
|
},
|
|
26313
|
-
children:
|
|
26390
|
+
children: "\u5C5E\u6027"
|
|
26314
26391
|
}
|
|
26315
|
-
)
|
|
26316
|
-
|
|
26317
|
-
|
|
26318
|
-
|
|
26319
|
-
|
|
26320
|
-
|
|
26321
|
-
|
|
26322
|
-
|
|
26323
|
-
|
|
26324
|
-
|
|
26325
|
-
|
|
26326
|
-
|
|
26327
|
-
|
|
26328
|
-
|
|
26329
|
-
|
|
26330
|
-
|
|
26392
|
+
),
|
|
26393
|
+
propEntries.map(([key, value], i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
26394
|
+
"div",
|
|
26395
|
+
{
|
|
26396
|
+
style: {
|
|
26397
|
+
display: "flex",
|
|
26398
|
+
justifyContent: "space-between",
|
|
26399
|
+
alignItems: "baseline",
|
|
26400
|
+
gap: 12,
|
|
26401
|
+
padding: "9px 0",
|
|
26402
|
+
borderBottom: i < propEntries.length - 1 ? `1px solid var(--gxr-panel-divider)` : void 0
|
|
26403
|
+
},
|
|
26404
|
+
children: [
|
|
26405
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { color: "var(--gxr-text-secondary)", fontSize: 13, flexShrink: 0 }, children: key }),
|
|
26406
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
26407
|
+
"span",
|
|
26408
|
+
{
|
|
26409
|
+
style: {
|
|
26410
|
+
color: "var(--gxr-text-primary)",
|
|
26411
|
+
fontSize: 13,
|
|
26412
|
+
fontWeight: 500,
|
|
26413
|
+
textAlign: "right",
|
|
26414
|
+
wordBreak: "break-word"
|
|
26415
|
+
},
|
|
26416
|
+
children: String(value ?? "")
|
|
26417
|
+
}
|
|
26418
|
+
)
|
|
26419
|
+
]
|
|
26331
26420
|
},
|
|
26332
|
-
|
|
26333
|
-
|
|
26334
|
-
),
|
|
26335
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.
|
|
26336
|
-
|
|
26337
|
-
|
|
26338
|
-
|
|
26339
|
-
|
|
26340
|
-
|
|
26341
|
-
|
|
26342
|
-
|
|
26343
|
-
|
|
26344
|
-
|
|
26421
|
+
key
|
|
26422
|
+
))
|
|
26423
|
+
] }),
|
|
26424
|
+
relations.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { padding: SECTION_PAD, borderTop: `1px solid var(--gxr-panel-divider)` }, children: [
|
|
26425
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
26426
|
+
"div",
|
|
26427
|
+
{
|
|
26428
|
+
style: {
|
|
26429
|
+
display: "flex",
|
|
26430
|
+
justifyContent: "space-between",
|
|
26431
|
+
alignItems: "center",
|
|
26432
|
+
color: "var(--gxr-text-secondary)",
|
|
26433
|
+
fontSize: 13,
|
|
26434
|
+
marginBottom: 10,
|
|
26435
|
+
letterSpacing: 0.5
|
|
26436
|
+
},
|
|
26437
|
+
children: [
|
|
26438
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "\u5173\u7CFB" }),
|
|
26439
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { color: "var(--gxr-text-muted)" }, children: relations.length })
|
|
26440
|
+
]
|
|
26441
|
+
}
|
|
26442
|
+
),
|
|
26443
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: relations.map((rel) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
26444
|
+
"div",
|
|
26445
|
+
{
|
|
26446
|
+
onClick: () => navigateTo(rel.id),
|
|
26447
|
+
title: rel.title,
|
|
26448
|
+
style: {
|
|
26449
|
+
display: "flex",
|
|
26450
|
+
alignItems: "center",
|
|
26451
|
+
gap: 10,
|
|
26452
|
+
padding: "11px 14px",
|
|
26453
|
+
borderRadius: 10,
|
|
26454
|
+
border: `1px solid var(--gxr-panel-border)`,
|
|
26455
|
+
background: "var(--gxr-hover-bg)",
|
|
26456
|
+
cursor: "pointer"
|
|
26457
|
+
},
|
|
26458
|
+
onMouseEnter: (e) => {
|
|
26459
|
+
e.currentTarget.style.borderColor = "var(--gxr-text-muted)";
|
|
26460
|
+
},
|
|
26461
|
+
onMouseLeave: (e) => {
|
|
26462
|
+
e.currentTarget.style.borderColor = "var(--gxr-panel-border)";
|
|
26463
|
+
},
|
|
26464
|
+
children: [
|
|
26465
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
26466
|
+
"span",
|
|
26467
|
+
{
|
|
26468
|
+
style: {
|
|
26469
|
+
width: 9,
|
|
26470
|
+
height: 9,
|
|
26471
|
+
borderRadius: "50%",
|
|
26472
|
+
background: rel.color,
|
|
26473
|
+
flexShrink: 0
|
|
26474
|
+
}
|
|
26475
|
+
}
|
|
26476
|
+
),
|
|
26477
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
26478
|
+
"span",
|
|
26479
|
+
{
|
|
26480
|
+
style: {
|
|
26481
|
+
flex: 1,
|
|
26482
|
+
minWidth: 0,
|
|
26483
|
+
color: "var(--gxr-text-primary)",
|
|
26484
|
+
fontSize: 14,
|
|
26485
|
+
overflow: "hidden",
|
|
26486
|
+
textOverflow: "ellipsis",
|
|
26487
|
+
whiteSpace: "nowrap"
|
|
26488
|
+
},
|
|
26489
|
+
children: rel.title
|
|
26490
|
+
}
|
|
26491
|
+
),
|
|
26492
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { color: "var(--gxr-text-muted)", fontSize: 12, flexShrink: 0 }, children: rel.category })
|
|
26493
|
+
]
|
|
26345
26494
|
},
|
|
26346
|
-
|
|
26347
|
-
}
|
|
26348
|
-
)
|
|
26349
|
-
] },
|
|
26495
|
+
rel.id
|
|
26496
|
+
)) })
|
|
26497
|
+
] })
|
|
26498
|
+
] }),
|
|
26499
|
+
showExpandNeighbors && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { padding: SECTION_PAD, borderTop: `1px solid var(--gxr-panel-divider)` }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
26500
|
+
"button",
|
|
26501
|
+
{
|
|
26502
|
+
"data-no-drag": true,
|
|
26503
|
+
onClick: () => onExpandNeighbors?.(nodeId),
|
|
26504
|
+
style: {
|
|
26505
|
+
width: "100%",
|
|
26506
|
+
padding: "10px 14px",
|
|
26507
|
+
borderRadius: 10,
|
|
26508
|
+
border: `1px solid var(--gxr-panel-border)`,
|
|
26509
|
+
background: "transparent",
|
|
26510
|
+
color: "var(--gxr-text-secondary)",
|
|
26511
|
+
fontSize: 13,
|
|
26512
|
+
cursor: "pointer"
|
|
26513
|
+
},
|
|
26514
|
+
onMouseEnter: (e) => {
|
|
26515
|
+
e.currentTarget.style.background = "var(--gxr-hover-bg)";
|
|
26516
|
+
},
|
|
26517
|
+
onMouseLeave: (e) => {
|
|
26518
|
+
e.currentTarget.style.background = "transparent";
|
|
26519
|
+
},
|
|
26520
|
+
children: "\u2197 \u6269\u5C55\u90BB\u5C45"
|
|
26521
|
+
}
|
|
26522
|
+
) })
|
|
26350
26523
|
]
|
|
26351
26524
|
}
|
|
26352
26525
|
);
|
|
@@ -26613,7 +26786,7 @@ var _MinimapRenderer = class _MinimapRenderer {
|
|
|
26613
26786
|
this.cloudScene.updateMatrixWorld(true);
|
|
26614
26787
|
const savedClearColor = this.renderer.getClearColor().clone();
|
|
26615
26788
|
const savedClearAlpha = this.renderer.getClearAlpha();
|
|
26616
|
-
const minimapBg = this.config.isDark ?
|
|
26789
|
+
const minimapBg = this.config.isDark ? 1315860 : 16316666;
|
|
26617
26790
|
this.renderer.setClearColor(minimapBg, 1);
|
|
26618
26791
|
this.renderer.setRenderTarget(this.renderTarget);
|
|
26619
26792
|
this.renderer.clear();
|
|
@@ -26812,6 +26985,7 @@ function MinimapOverlay({
|
|
|
26812
26985
|
onToggleCollapse,
|
|
26813
26986
|
zoomPercent,
|
|
26814
26987
|
onFitToScreen,
|
|
26988
|
+
onResetZoom,
|
|
26815
26989
|
cameraZ
|
|
26816
26990
|
}) {
|
|
26817
26991
|
const containerRef = (0, import_react6.useRef)(null);
|
|
@@ -26966,7 +27140,7 @@ function MinimapOverlay({
|
|
|
26966
27140
|
className: "minimap-ctrl-zoom",
|
|
26967
27141
|
title: "Reset zoom to 100%",
|
|
26968
27142
|
onMouseDown: (e) => e.stopPropagation(),
|
|
26969
|
-
onClick: () =>
|
|
27143
|
+
onClick: () => onResetZoom(),
|
|
26970
27144
|
children: [
|
|
26971
27145
|
Math.round(zoomPercent),
|
|
26972
27146
|
"%"
|
|
@@ -27067,7 +27241,7 @@ function MinimapLayer({
|
|
|
27067
27241
|
const viewportFrameRef = (0, import_react7.useRef)({ x: 0, y: 0, w: 0, h: 0 });
|
|
27068
27242
|
const [viewportFrame, setViewportFrame] = (0, import_react7.useState)({ x: 0, y: 0, w: 0, h: 0 });
|
|
27069
27243
|
const [zoomPercent, setZoomPercent] = (0, import_react7.useState)(100);
|
|
27070
|
-
const
|
|
27244
|
+
const baselineZoomRef = (0, import_react7.useRef)(null);
|
|
27071
27245
|
const dpr = Math.min(window.devicePixelRatio, 2);
|
|
27072
27246
|
const pixelWidth = Math.round(width * dpr);
|
|
27073
27247
|
const pixelHeight = Math.round(height * dpr);
|
|
@@ -27124,7 +27298,11 @@ function MinimapLayer({
|
|
|
27124
27298
|
const frame2 = mr.mapper.computeViewportFrame(viewport);
|
|
27125
27299
|
if (control) {
|
|
27126
27300
|
const currentZ = control.getZoom();
|
|
27127
|
-
|
|
27301
|
+
if (baselineZoomRef.current === null && currentZ <= -0.1) {
|
|
27302
|
+
baselineZoomRef.current = currentZ;
|
|
27303
|
+
}
|
|
27304
|
+
const baseline = baselineZoomRef.current ?? currentZ;
|
|
27305
|
+
const pct = Math.round(baseline / Math.min(currentZ, -0.1) * 100);
|
|
27128
27306
|
setZoomPercent(Math.max(1, pct));
|
|
27129
27307
|
}
|
|
27130
27308
|
const prev = viewportFrameRef.current;
|
|
@@ -27164,6 +27342,11 @@ function MinimapLayer({
|
|
|
27164
27342
|
control.setPosition(target[0], target[1]);
|
|
27165
27343
|
control.setZoom(target[2]);
|
|
27166
27344
|
}, [control, store, camera]);
|
|
27345
|
+
const handleResetZoom = (0, import_react7.useCallback)(() => {
|
|
27346
|
+
if (!control) return;
|
|
27347
|
+
control.setPosition(0, 0);
|
|
27348
|
+
control.setZoom(baselineZoomRef.current ?? control.getZoom());
|
|
27349
|
+
}, [control]);
|
|
27167
27350
|
if (isMapMode) return null;
|
|
27168
27351
|
if (!control) return null;
|
|
27169
27352
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
@@ -27182,6 +27365,7 @@ function MinimapLayer({
|
|
|
27182
27365
|
onToggleCollapse: () => setCollapsed((c2) => !c2),
|
|
27183
27366
|
zoomPercent,
|
|
27184
27367
|
onFitToScreen: handleFitToScreen,
|
|
27368
|
+
onResetZoom: handleResetZoom,
|
|
27185
27369
|
cameraZ: camera.position.z
|
|
27186
27370
|
}
|
|
27187
27371
|
);
|
|
@@ -28871,7 +29055,8 @@ var DEFAULT_CONFIG7 = {
|
|
|
28871
29055
|
maxPitch: 88,
|
|
28872
29056
|
dragThreshold: 3,
|
|
28873
29057
|
zoomToCursor: false,
|
|
28874
|
-
onPitchDelta: void 0
|
|
29058
|
+
onPitchDelta: void 0,
|
|
29059
|
+
shouldSkipDrag: void 0
|
|
28875
29060
|
};
|
|
28876
29061
|
var _euler = new THREE39.Euler(0, 0, 0, "YXZ");
|
|
28877
29062
|
var _quatY = new THREE39.Quaternion();
|
|
@@ -29046,6 +29231,7 @@ var GlobeControl = class {
|
|
|
29046
29231
|
window.addEventListener("mouseup", this._onMouseUp);
|
|
29047
29232
|
return;
|
|
29048
29233
|
}
|
|
29234
|
+
if (this.config.shouldSkipDrag && this.config.shouldSkipDrag(e)) return;
|
|
29049
29235
|
this.isDragging = true;
|
|
29050
29236
|
this.dragConfirmed = false;
|
|
29051
29237
|
this.downX = e.clientX;
|
|
@@ -29224,6 +29410,10 @@ function GlobeLayer({
|
|
|
29224
29410
|
cloudScene.add(globe);
|
|
29225
29411
|
setMapMode(true, radius, 0.3);
|
|
29226
29412
|
if (graphControl) graphControl.enabled = false;
|
|
29413
|
+
if (interaction) {
|
|
29414
|
+
interaction.drag.enabled = true;
|
|
29415
|
+
interaction.coordinator?.setBackgroundGestureExternal(true);
|
|
29416
|
+
}
|
|
29227
29417
|
if (container) {
|
|
29228
29418
|
const control = new GlobeControl(cloudScene, container, {
|
|
29229
29419
|
zoomMin: -100,
|
|
@@ -29235,6 +29425,16 @@ function GlobeLayer({
|
|
|
29235
29425
|
if (api?.map) {
|
|
29236
29426
|
api.map.setPitch(api.map.getPitch() + delta);
|
|
29237
29427
|
}
|
|
29428
|
+
},
|
|
29429
|
+
// Let node drags win over globe orbit: if a node is under the cursor on
|
|
29430
|
+
// mousedown, skip the GlobeControl orbit so the InteractionManager's
|
|
29431
|
+
// DragHandler moves the node instead. Background mousedowns still rotate.
|
|
29432
|
+
shouldSkipDrag: (e) => {
|
|
29433
|
+
const picker = interaction?.picker;
|
|
29434
|
+
if (!picker?.pick || !container) return false;
|
|
29435
|
+
const rect = container.getBoundingClientRect();
|
|
29436
|
+
const res = picker.pick(e.clientX - rect.left, e.clientY - rect.top);
|
|
29437
|
+
return !!(res && res.type === "node" && res.picked);
|
|
29238
29438
|
}
|
|
29239
29439
|
});
|
|
29240
29440
|
control.onChange(() => {
|
|
@@ -29277,6 +29477,7 @@ function GlobeLayer({
|
|
|
29277
29477
|
cloudScene.position.copy(savedPosition);
|
|
29278
29478
|
cloudScene.quaternion.copy(savedQuaternion);
|
|
29279
29479
|
if (graphControl) graphControl.enabled = true;
|
|
29480
|
+
interaction?.coordinator?.setBackgroundGestureExternal(false);
|
|
29280
29481
|
invalidate();
|
|
29281
29482
|
};
|
|
29282
29483
|
}, [radius, minLevel, maxLevel, mercatorProjection]);
|
|
@@ -41103,18 +41304,34 @@ var EmphasisApi = class {
|
|
|
41103
41304
|
this.effectManager.stopAll(type);
|
|
41104
41305
|
}
|
|
41105
41306
|
/**
|
|
41106
|
-
* Enable or disable the hover-
|
|
41307
|
+
* Enable or disable the hover-DIM feature (fade everything outside the
|
|
41308
|
+
* hovered node's 1-hop neighborhood).
|
|
41107
41309
|
*
|
|
41108
|
-
*
|
|
41109
|
-
*
|
|
41110
|
-
*
|
|
41310
|
+
* **Independent of the hover ring.** The ring/halo is governed by
|
|
41311
|
+
* {@link setEmphasisGlowEnabled} (on by default); this switch only controls
|
|
41312
|
+
* the dimming of non-neighbors. Default `false` — dim is opt-in.
|
|
41313
|
+
*
|
|
41314
|
+
* When enabled, hovering a node dims all other nodes and edges except the
|
|
41315
|
+
* hovered node, its 1-hop neighbors, and the connecting edges. When
|
|
41316
|
+
* disabled, hovering still shows the ring (if glow is on) but fades nothing.
|
|
41111
41317
|
*
|
|
41112
41318
|
* Not undoable. Not recorded in history.
|
|
41113
41319
|
*
|
|
41114
41320
|
* @param enabled - `true` to enable hover dimming, `false` to disable.
|
|
41115
41321
|
*/
|
|
41322
|
+
setHoverDimEnabled(enabled) {
|
|
41323
|
+
this.hoverEmphasis?.setDimEnabled(enabled);
|
|
41324
|
+
}
|
|
41325
|
+
/**
|
|
41326
|
+
* @deprecated Legacy name for {@link setHoverDimEnabled} — historically this
|
|
41327
|
+
* was the single master switch that coupled dim and glow. It now controls
|
|
41328
|
+
* only the dim feature (the ring is governed by
|
|
41329
|
+
* {@link setEmphasisGlowEnabled}). Prefer `setHoverDimEnabled`.
|
|
41330
|
+
*
|
|
41331
|
+
* @param enabled - `true` to enable hover dimming, `false` to disable.
|
|
41332
|
+
*/
|
|
41116
41333
|
setHoverEnabled(enabled) {
|
|
41117
|
-
this.hoverEmphasis?.
|
|
41334
|
+
this.hoverEmphasis?.setDimEnabled(enabled);
|
|
41118
41335
|
}
|
|
41119
41336
|
/**
|
|
41120
41337
|
* Set the opacity of dimmed nodes and edges during hover emphasis.
|
|
@@ -41147,13 +41364,18 @@ var EmphasisApi = class {
|
|
|
41147
41364
|
this.hoverEmphasis?.setConfig({ duration: ms });
|
|
41148
41365
|
}
|
|
41149
41366
|
/**
|
|
41150
|
-
* Enable or disable the
|
|
41151
|
-
*
|
|
41152
|
-
*
|
|
41367
|
+
* Enable or disable the hover RING (node halo + edge tube glow). Default
|
|
41368
|
+
* `true` — the ring shows on hover out of the box.
|
|
41369
|
+
*
|
|
41370
|
+
* **Independent of the dim feature** ({@link setHoverDimEnabled}). In
|
|
41371
|
+
* glow-only mode (dim off) the ring is drawn on the hovered node alone; when
|
|
41372
|
+
* dim is also on, it extends to the kept set (1-hop neighbors), the same way
|
|
41373
|
+
* trace emphasis lights up its whole keep set. Does not affect the dim
|
|
41374
|
+
* opacity controlled by {@link setHoverDimOpacity}.
|
|
41153
41375
|
*
|
|
41154
41376
|
* Not undoable. Not recorded in history.
|
|
41155
41377
|
*
|
|
41156
|
-
* @param enabled - `true` to enable
|
|
41378
|
+
* @param enabled - `true` to enable the ring, `false` to disable.
|
|
41157
41379
|
*/
|
|
41158
41380
|
setEmphasisGlowEnabled(enabled) {
|
|
41159
41381
|
this.hoverEmphasis?.setConfig({ glowEnabled: enabled });
|
|
@@ -41183,14 +41405,15 @@ var EmphasisApi = class {
|
|
|
41183
41405
|
this.hoverEmphasis?.setConfig({ haloStrength: Math.max(0, strength) });
|
|
41184
41406
|
}
|
|
41185
41407
|
/**
|
|
41186
|
-
* Returns whether the hover-
|
|
41408
|
+
* Returns whether the hover-DIM feature is enabled.
|
|
41187
41409
|
*
|
|
41188
41410
|
* @returns `true` if hover dimming will fire on hover-enter; `false`
|
|
41189
|
-
* otherwise
|
|
41190
|
-
*
|
|
41411
|
+
* otherwise (the ring may still show — see {@link setEmphasisGlowEnabled}).
|
|
41412
|
+
* Also returns `false` when no {@link HoverEmphasisController} is wired
|
|
41413
|
+
* (the API was constructed without a controller).
|
|
41191
41414
|
*/
|
|
41192
41415
|
isHoverEnabled() {
|
|
41193
|
-
return this.hoverEmphasis?.
|
|
41416
|
+
return this.hoverEmphasis?.isDimEnabled() ?? false;
|
|
41194
41417
|
}
|
|
41195
41418
|
/**
|
|
41196
41419
|
* Programmatic dim. Apply an arbitrary keep set — every node / edge
|
|
@@ -44835,6 +45058,18 @@ var _MapApi = class _MapApi {
|
|
|
44835
45058
|
this._autoFitDebounceMs = 200;
|
|
44836
45059
|
// Whether a mode transition is in progress
|
|
44837
45060
|
this._transitioning = false;
|
|
45061
|
+
// Set by GraphContext right before it swaps the auto map layer
|
|
45062
|
+
// (FlatLayer↔GlobeLayer) for a 2D↔3D change while the map stays active.
|
|
45063
|
+
// Suppresses the teardown in the single disableMap() that the outgoing
|
|
45064
|
+
// layer's unmount cleanup fires — see disableMap() / beginLayerSwap().
|
|
45065
|
+
this._inLayerSwap = false;
|
|
45066
|
+
// Wall-clock (ms) when beginLayerSwap last armed the flag. The suppression is
|
|
45067
|
+
// only honored within LAYER_SWAP_SUPPRESS_WINDOW_MS of arming: a real swap's
|
|
45068
|
+
// outgoing disableMap fires within one render commit, but if the flag is
|
|
45069
|
+
// armed and never consumed (e.g. the layer updates in place instead of
|
|
45070
|
+
// unmount→remount), a STALE flag must not swallow a genuine user "Hide Map"
|
|
45071
|
+
// seconds later. See disableMap().
|
|
45072
|
+
this._layerSwapArmedAt = 0;
|
|
44838
45073
|
// Per-node elevation offsets above the map surface (cleared on disableMap)
|
|
44839
45074
|
this._elevation = /* @__PURE__ */ new Map();
|
|
44840
45075
|
// Currently baked-in elevation offset (tracks what is already in the position buffer)
|
|
@@ -45159,8 +45394,9 @@ var _MapApi = class _MapApi {
|
|
|
45159
45394
|
* Phase 1: records state and emits event. Scene wiring is Phase 2/3.
|
|
45160
45395
|
*/
|
|
45161
45396
|
async enableMap(options) {
|
|
45397
|
+
this._inLayerSwap = false;
|
|
45162
45398
|
if (this._enabled) return;
|
|
45163
|
-
const mode = options?.mode ?? "planar";
|
|
45399
|
+
const mode = options?.mode ?? (this._is3D ? "spherical" : "planar");
|
|
45164
45400
|
const providerKey = options?.provider ?? "cartoDark";
|
|
45165
45401
|
this._enabled = true;
|
|
45166
45402
|
this._mode = mode;
|
|
@@ -45172,6 +45408,24 @@ var _MapApi = class _MapApi {
|
|
|
45172
45408
|
this._reapplyElevationFor(Array.from(this._elevation.keys()));
|
|
45173
45409
|
this.events.emit("map:enabled", { mode, provider: providerKey });
|
|
45174
45410
|
}
|
|
45411
|
+
/**
|
|
45412
|
+
* Mark that the NEXT `disableMap()` is part of a 2D↔3D layer swap
|
|
45413
|
+
* (FlatLayer↔GlobeLayer), not a real map-off, so that single call skips its
|
|
45414
|
+
* teardown (and crucially its geo unpin). Call this immediately before
|
|
45415
|
+
* swapping the auto map layer while the map stays active.
|
|
45416
|
+
*
|
|
45417
|
+
* Self-limiting: the flag is consumed by the next `disableMap()`, cleared by
|
|
45418
|
+
* any `enableMap()` (the incoming layer's mount), AND time-boxed — see
|
|
45419
|
+
* `LAYER_SWAP_SUPPRESS_WINDOW_MS`. The time box guarantees a flag that was
|
|
45420
|
+
* armed but never consumed (layer updated in place rather than
|
|
45421
|
+
* unmount→remount) cannot linger to swallow a later genuine "Hide Map".
|
|
45422
|
+
*
|
|
45423
|
+
* @internal — used by GraphContext's auto-map-layer effect.
|
|
45424
|
+
*/
|
|
45425
|
+
beginLayerSwap() {
|
|
45426
|
+
this._inLayerSwap = true;
|
|
45427
|
+
this._layerSwapArmedAt = typeof performance !== "undefined" ? performance.now() : Date.now();
|
|
45428
|
+
}
|
|
45175
45429
|
/**
|
|
45176
45430
|
* Disable map mode and restore the scene to its pre-map state.
|
|
45177
45431
|
*
|
|
@@ -45180,6 +45434,13 @@ var _MapApi = class _MapApi {
|
|
|
45180
45434
|
* Emits `"map:disabled"`.
|
|
45181
45435
|
*/
|
|
45182
45436
|
disableMap() {
|
|
45437
|
+
if (this._inLayerSwap) {
|
|
45438
|
+
this._inLayerSwap = false;
|
|
45439
|
+
const now2 = typeof performance !== "undefined" ? performance.now() : Date.now();
|
|
45440
|
+
if (now2 - this._layerSwapArmedAt < _MapApi.LAYER_SWAP_SUPPRESS_WINDOW_MS) {
|
|
45441
|
+
return;
|
|
45442
|
+
}
|
|
45443
|
+
}
|
|
45183
45444
|
this._elevation.clear();
|
|
45184
45445
|
this._appliedElevation.clear();
|
|
45185
45446
|
if (this._geoPinnedIds.size > 0) {
|
|
@@ -45203,8 +45464,37 @@ var _MapApi = class _MapApi {
|
|
|
45203
45464
|
this._lastAppliedScenePosZ = null;
|
|
45204
45465
|
this._lastAppliedPitchRad = null;
|
|
45205
45466
|
if (this._cloudScene) this._cloudScene.rotation.x = 0;
|
|
45467
|
+
this._reheatLayout();
|
|
45206
45468
|
this.events.emit("map:disabled", {});
|
|
45207
45469
|
}
|
|
45470
|
+
/**
|
|
45471
|
+
* Re-enable + reheat the live force layout so released nodes re-flow.
|
|
45472
|
+
*
|
|
45473
|
+
* Show Map's `stopLayout()` left the controller's `_enable=false`, and
|
|
45474
|
+
* `restartLayout()` early-returns while disabled — so we must RE-ENABLE
|
|
45475
|
+
* first. Critically we use `restartLayout()` (reheat the EXISTING sim in
|
|
45476
|
+
* place), NOT `startLayout()`: startLayout does a full dispose+buildSimulation
|
|
45477
|
+
* that re-seeds pin state from the stale `graph.layoutNodes[].pinned` mirror
|
|
45478
|
+
* (which is never set for geo), which would UNPIN geo and break the map
|
|
45479
|
+
* projection. Routed through the provider's layoutController (the WebGPU /
|
|
45480
|
+
* CPU-adapter wiring); falls back to the legacy `_layoutRuntime` sim handle
|
|
45481
|
+
* for the d3 engine.
|
|
45482
|
+
*/
|
|
45483
|
+
_reheatLayout() {
|
|
45484
|
+
const lc = this.store.positionProvider?.layoutController;
|
|
45485
|
+
if (lc) {
|
|
45486
|
+
if (lc.c) lc.c._enable = true;
|
|
45487
|
+
if (typeof lc.restart === "function") {
|
|
45488
|
+
lc.restart();
|
|
45489
|
+
return;
|
|
45490
|
+
}
|
|
45491
|
+
}
|
|
45492
|
+
const sim = this.store._layoutRuntime?.engine?.controller?.simulation;
|
|
45493
|
+
if (sim && typeof sim.alpha === "function") {
|
|
45494
|
+
sim.alpha(0.5);
|
|
45495
|
+
sim.restart?.();
|
|
45496
|
+
}
|
|
45497
|
+
}
|
|
45208
45498
|
/**
|
|
45209
45499
|
* Whether map mode is currently active.
|
|
45210
45500
|
*/
|
|
@@ -46209,10 +46499,10 @@ var _MapApi = class _MapApi {
|
|
|
46209
46499
|
for (const id of geoNodeIds) {
|
|
46210
46500
|
if (!this.store.isPinned(id)) newlyPinnedGeoIds.push(id);
|
|
46211
46501
|
}
|
|
46212
|
-
if (
|
|
46213
|
-
this.store.pinNodes(
|
|
46214
|
-
for (const id of newlyPinnedGeoIds) this._geoPinnedIds.add(id);
|
|
46502
|
+
if (geoNodeIds.length > 0) {
|
|
46503
|
+
this.store.pinNodes(geoNodeIds);
|
|
46215
46504
|
}
|
|
46505
|
+
for (const id of newlyPinnedGeoIds) this._geoPinnedIds.add(id);
|
|
46216
46506
|
const alphaBump = options.alphaBump ?? 0.5;
|
|
46217
46507
|
if (alphaBump > 0) {
|
|
46218
46508
|
const sim = this.store._layoutRuntime?.engine?.controller?.simulation;
|
|
@@ -46579,6 +46869,7 @@ var _MapApi = class _MapApi {
|
|
|
46579
46869
|
return this.flyTo(center, { duration, mode, zoomLevel });
|
|
46580
46870
|
}
|
|
46581
46871
|
};
|
|
46872
|
+
_MapApi.LAYER_SWAP_SUPPRESS_WINDOW_MS = 1e3;
|
|
46582
46873
|
// ── View Control (Phase 2) ─────────────────────────────────────────────────
|
|
46583
46874
|
// Zoom math constants (shared by getZoomLevel / setZoomLevel)
|
|
46584
46875
|
_MapApi.VIEWPORT_H = 800;
|
|
@@ -48500,6 +48791,12 @@ var RenderEngineApi = class {
|
|
|
48500
48791
|
lc.transitionDimensions(targetDim);
|
|
48501
48792
|
}
|
|
48502
48793
|
this.renderer.setMode(targetDim === 2 ? "2D" : "3D");
|
|
48794
|
+
if (this.map.isEnabled()) {
|
|
48795
|
+
const targetMode = targetDim === 3 ? "spherical" : "planar";
|
|
48796
|
+
if (this.map.getMode() !== targetMode) {
|
|
48797
|
+
void this.map.transition(targetMode);
|
|
48798
|
+
}
|
|
48799
|
+
}
|
|
48503
48800
|
}
|
|
48504
48801
|
/**
|
|
48505
48802
|
* Return the currently active dimension (2 or 3).
|
|
@@ -48534,7 +48831,7 @@ var RenderEngineApi = class {
|
|
|
48534
48831
|
|
|
48535
48832
|
// src/interaction/hover/HoverEmphasisController.ts
|
|
48536
48833
|
var FRAME_KEY = "hoverDimAnim";
|
|
48537
|
-
var DEFAULTS2 = { duration: 200, dimOpacity: 0.15,
|
|
48834
|
+
var DEFAULTS2 = { duration: 200, dimOpacity: 0.15, dimEnabled: false, glowEnabled: true, glowStrength: 1, haloStrength: 1 };
|
|
48538
48835
|
var INSTANT_THRESHOLD_MS = 1;
|
|
48539
48836
|
function easeInOutCubic2(x3) {
|
|
48540
48837
|
return x3 < 0.5 ? 4 * x3 * x3 * x3 : 1 - Math.pow(-2 * x3 + 2, 3) / 2;
|
|
@@ -48553,7 +48850,7 @@ var HoverEmphasisController = class {
|
|
|
48553
48850
|
// the dim state is fully driven by whoever called setExternalKeepSet
|
|
48554
48851
|
// (typically the trace-neighbors toolbar handler or another host UI).
|
|
48555
48852
|
this._externalKeep = null;
|
|
48556
|
-
// _config.
|
|
48853
|
+
// _config.dimEnabled snapshot taken on the first setExternalKeepSet call.
|
|
48557
48854
|
// clearExternalKeepSet uses it to restore the host's pre-external intent
|
|
48558
48855
|
// synchronously, so a trace started with hover-dim disabled returns
|
|
48559
48856
|
// to enabled=false IMMEDIATELY (not after the ramp). The synchronous
|
|
@@ -48600,6 +48897,31 @@ var HoverEmphasisController = class {
|
|
|
48600
48897
|
}
|
|
48601
48898
|
return { nodes, edges: /* @__PURE__ */ new Set([target.index]) };
|
|
48602
48899
|
}
|
|
48900
|
+
/**
|
|
48901
|
+
* Glow-only keep set: just the hovered target, no neighbors. Used when
|
|
48902
|
+
* `dimEnabled` is false — the hover ring is drawn on the node/edge under
|
|
48903
|
+
* the cursor and nothing else lights up or dims.
|
|
48904
|
+
*/
|
|
48905
|
+
_singletonKeepSet(target) {
|
|
48906
|
+
if (target == null) return null;
|
|
48907
|
+
if (target.kind === "node") {
|
|
48908
|
+
return { nodes: /* @__PURE__ */ new Set([target.index]), edges: /* @__PURE__ */ new Set() };
|
|
48909
|
+
}
|
|
48910
|
+
return { nodes: /* @__PURE__ */ new Set(), edges: /* @__PURE__ */ new Set([target.index]) };
|
|
48911
|
+
}
|
|
48912
|
+
/**
|
|
48913
|
+
* Pick the keep set for a hover target by feature mode. Dim on → the full
|
|
48914
|
+
* 1-hop neighborhood (so neighbors stay bright); dim off (glow-only) → just
|
|
48915
|
+
* the hovered target so the ring is scoped to that node/edge.
|
|
48916
|
+
*/
|
|
48917
|
+
_keepSetFor(target) {
|
|
48918
|
+
return this._config.dimEnabled ? this._computeKeepSet(target) : this._singletonKeepSet(target);
|
|
48919
|
+
}
|
|
48920
|
+
/** True when at least one hover feature (glow ring or dim) is active, i.e.
|
|
48921
|
+
* hover events should be processed. */
|
|
48922
|
+
_wantsHover() {
|
|
48923
|
+
return this._config.glowEnabled !== false || this._config.dimEnabled === true;
|
|
48924
|
+
}
|
|
48603
48925
|
/**
|
|
48604
48926
|
* Diff writer: drives the GPU-side bit 16 (hoverDim) on nodes/edges.
|
|
48605
48927
|
* - next == null → hover-leave: clear all bits, drop keep-set.
|
|
@@ -48615,6 +48937,7 @@ var HoverEmphasisController = class {
|
|
|
48615
48937
|
this.deps.setHoverTimeUniform(Math.floor(now2) % 524288);
|
|
48616
48938
|
const g = this._config.glowEnabled === false ? 0 : this._config.glowStrength ?? 1;
|
|
48617
48939
|
const h = this._config.glowEnabled === false ? 0 : this._config.haloStrength ?? 1;
|
|
48940
|
+
const dim = this._config.dimEnabled === true;
|
|
48618
48941
|
if (next == null) {
|
|
48619
48942
|
this.deps.clearAllHoverDimBits();
|
|
48620
48943
|
this.deps.clearAllEmphasisGlow();
|
|
@@ -48622,11 +48945,13 @@ var HoverEmphasisController = class {
|
|
|
48622
48945
|
return;
|
|
48623
48946
|
}
|
|
48624
48947
|
if (prev == null) {
|
|
48625
|
-
|
|
48626
|
-
|
|
48627
|
-
|
|
48628
|
-
|
|
48629
|
-
|
|
48948
|
+
if (dim) {
|
|
48949
|
+
for (let i = 0; i < this.deps.nodeCount; i++) {
|
|
48950
|
+
if (!next.nodes.has(i)) this.deps.setNodeHoverDimBit(i, 1);
|
|
48951
|
+
}
|
|
48952
|
+
for (let i = 0; i < this.deps.edgeCount; i++) {
|
|
48953
|
+
if (!next.edges.has(i)) this.deps.setEdgeHoverDimBit(i, 1);
|
|
48954
|
+
}
|
|
48630
48955
|
}
|
|
48631
48956
|
for (const idx of next.nodes) this.deps.setNodeHalo(idx, h);
|
|
48632
48957
|
for (const idx of next.edges) this.deps.setEdgeTubeGlow(idx, g);
|
|
@@ -48634,19 +48959,19 @@ var HoverEmphasisController = class {
|
|
|
48634
48959
|
return;
|
|
48635
48960
|
}
|
|
48636
48961
|
for (const idx of prev.nodes) if (!next.nodes.has(idx)) {
|
|
48637
|
-
this.deps.setNodeHoverDimBit(idx, 1);
|
|
48962
|
+
if (dim) this.deps.setNodeHoverDimBit(idx, 1);
|
|
48638
48963
|
this.deps.setNodeHalo(idx, 0);
|
|
48639
48964
|
}
|
|
48640
48965
|
for (const idx of next.nodes) if (!prev.nodes.has(idx)) {
|
|
48641
|
-
this.deps.setNodeHoverDimBit(idx, 0);
|
|
48966
|
+
if (dim) this.deps.setNodeHoverDimBit(idx, 0);
|
|
48642
48967
|
this.deps.setNodeHalo(idx, h);
|
|
48643
48968
|
}
|
|
48644
48969
|
for (const idx of prev.edges) if (!next.edges.has(idx)) {
|
|
48645
|
-
this.deps.setEdgeHoverDimBit(idx, 1);
|
|
48970
|
+
if (dim) this.deps.setEdgeHoverDimBit(idx, 1);
|
|
48646
48971
|
this.deps.setEdgeTubeGlow(idx, 0);
|
|
48647
48972
|
}
|
|
48648
48973
|
for (const idx of next.edges) if (!prev.edges.has(idx)) {
|
|
48649
|
-
this.deps.setEdgeHoverDimBit(idx, 0);
|
|
48974
|
+
if (dim) this.deps.setEdgeHoverDimBit(idx, 0);
|
|
48650
48975
|
this.deps.setEdgeTubeGlow(idx, g);
|
|
48651
48976
|
}
|
|
48652
48977
|
this._keep = next;
|
|
@@ -48674,38 +48999,63 @@ var HoverEmphasisController = class {
|
|
|
48674
48999
|
this.deps.clearAllEmphasisGlow();
|
|
48675
49000
|
this.deps.requestRender();
|
|
48676
49001
|
}
|
|
49002
|
+
this._reconcile();
|
|
48677
49003
|
}
|
|
48678
|
-
if (partial.
|
|
49004
|
+
if (partial.dimEnabled != null) this.setDimEnabled(partial.dimEnabled);
|
|
49005
|
+
if (partial.enabled != null) this.setDimEnabled(partial.enabled);
|
|
48679
49006
|
}
|
|
48680
|
-
|
|
48681
|
-
|
|
49007
|
+
/** Enable/disable the dim feature (fade everything outside the kept set).
|
|
49008
|
+
* Independent of the glow ring. */
|
|
49009
|
+
setDimEnabled(enabled) {
|
|
49010
|
+
this._config.dimEnabled = enabled;
|
|
48682
49011
|
if (!enabled) {
|
|
49012
|
+
this.deps.clearAllHoverDimBits();
|
|
49013
|
+
this.deps.requestRender();
|
|
49014
|
+
}
|
|
49015
|
+
this._reconcile();
|
|
49016
|
+
}
|
|
49017
|
+
/** @deprecated Legacy master switch. Maps to {@link setDimEnabled} — the
|
|
49018
|
+
* hover ring is governed independently by `glowEnabled`. */
|
|
49019
|
+
setEnabled(enabled) {
|
|
49020
|
+
this.setDimEnabled(enabled);
|
|
49021
|
+
}
|
|
49022
|
+
/** Reconcile the Disabled state with the two feature flags: the controller
|
|
49023
|
+
* is hard-disabled only when NEITHER glow nor dim wants to act. */
|
|
49024
|
+
_reconcile() {
|
|
49025
|
+
if (!this._wantsHover()) {
|
|
48683
49026
|
this._enterDisabled();
|
|
48684
49027
|
} else if (this._state === "Disabled") {
|
|
48685
49028
|
this._state = "Idle";
|
|
48686
49029
|
}
|
|
48687
49030
|
}
|
|
49031
|
+
/** @deprecated Returns whether the DIM feature is enabled (legacy name). */
|
|
48688
49032
|
isEnabled() {
|
|
48689
|
-
return this._config.
|
|
49033
|
+
return this._config.dimEnabled;
|
|
49034
|
+
}
|
|
49035
|
+
isDimEnabled() {
|
|
49036
|
+
return this._config.dimEnabled;
|
|
49037
|
+
}
|
|
49038
|
+
isGlowEnabled() {
|
|
49039
|
+
return this._config.glowEnabled !== false;
|
|
48690
49040
|
}
|
|
48691
49041
|
getConfig() {
|
|
48692
49042
|
return { ...this._config };
|
|
48693
49043
|
}
|
|
48694
49044
|
onHoverEnter(target) {
|
|
48695
|
-
if (!this.
|
|
49045
|
+
if (!this._wantsHover()) return;
|
|
48696
49046
|
if (this._state === "Disabled" || this._state === "Suppressed") return;
|
|
48697
49047
|
if (this._externalKeep) return;
|
|
48698
|
-
const next = this.
|
|
49048
|
+
const next = this._keepSetFor(target);
|
|
48699
49049
|
this._applyKeepSet(this._keep, next);
|
|
48700
49050
|
this._goRampingUp();
|
|
48701
49051
|
this.deps.requestRender();
|
|
48702
49052
|
}
|
|
48703
49053
|
onHoverMove(target) {
|
|
48704
|
-
if (!this.
|
|
49054
|
+
if (!this._wantsHover()) return;
|
|
48705
49055
|
if (this._state === "Disabled" || this._state === "Suppressed") return;
|
|
48706
49056
|
if (this._externalKeep) return;
|
|
48707
49057
|
if (this._state === "Idle") return this.onHoverEnter(target);
|
|
48708
|
-
const next = this.
|
|
49058
|
+
const next = this._keepSetFor(target);
|
|
48709
49059
|
this._applyKeepSet(this._keep, next);
|
|
48710
49060
|
this.deps.requestRender();
|
|
48711
49061
|
}
|
|
@@ -48739,10 +49089,10 @@ var HoverEmphasisController = class {
|
|
|
48739
49089
|
}
|
|
48740
49090
|
const next = { nodes, edges };
|
|
48741
49091
|
if (this._externalEnabledBefore === null) {
|
|
48742
|
-
this._externalEnabledBefore = this._config.
|
|
49092
|
+
this._externalEnabledBefore = this._config.dimEnabled;
|
|
48743
49093
|
}
|
|
48744
|
-
if (!this._config.
|
|
48745
|
-
this._config.
|
|
49094
|
+
if (!this._config.dimEnabled) {
|
|
49095
|
+
this._config.dimEnabled = true;
|
|
48746
49096
|
this.deps.setHoverProgressUniform(1);
|
|
48747
49097
|
}
|
|
48748
49098
|
this._applyKeepSet(this._externalKeep ?? this._keep, next);
|
|
@@ -48752,22 +49102,22 @@ var HoverEmphasisController = class {
|
|
|
48752
49102
|
this.deps.requestRender();
|
|
48753
49103
|
}
|
|
48754
49104
|
/** Cancel the programmatic dim. Per-instance un-dim ramps fire smoothly.
|
|
48755
|
-
* Restores the pre-external `_config.
|
|
49105
|
+
* Restores the pre-external `_config.dimEnabled` so a trace started with
|
|
48756
49106
|
* hover-dim disabled stays off — even if a click happens MID-ramp.
|
|
48757
|
-
* We set `_config.
|
|
49107
|
+
* We set `_config.dimEnabled` synchronously (rather than deferring to
|
|
48758
49108
|
* `_enterIdle`) because `onMouseDown` unregisters the ramp frame
|
|
48759
49109
|
* callback as part of Suppressed-state housekeeping; without an
|
|
48760
49110
|
* immediate flip, click→mouseup leaves the controller in Idle with
|
|
48761
|
-
* `
|
|
49111
|
+
* `dimEnabled === true`, and the next hover re-triggers dim. The state
|
|
48762
49112
|
* machine still cycles through RampingDown→Idle to play the visual
|
|
48763
|
-
* un-dim animation; `onHoverEnter`/`onHoverMove`
|
|
48764
|
-
*
|
|
49113
|
+
* un-dim animation; `onHoverEnter`/`onHoverMove` scope the kept set by
|
|
49114
|
+
* `dimEnabled` so the intermediate states draw the ring without dimming. */
|
|
48765
49115
|
clearExternalKeepSet() {
|
|
48766
49116
|
if (!this._externalKeep) return;
|
|
48767
49117
|
this._applyKeepSet(this._externalKeep, null);
|
|
48768
49118
|
this._externalKeep = null;
|
|
48769
49119
|
if (this._externalEnabledBefore === false) {
|
|
48770
|
-
this._config.
|
|
49120
|
+
this._config.dimEnabled = false;
|
|
48771
49121
|
}
|
|
48772
49122
|
this._externalEnabledBefore = null;
|
|
48773
49123
|
this._goRampingDown();
|
|
@@ -50632,7 +50982,9 @@ function useIs3D() {
|
|
|
50632
50982
|
return { is3D, setIs3D };
|
|
50633
50983
|
}
|
|
50634
50984
|
var GraphThemes = {
|
|
50635
|
-
|
|
50985
|
+
// Neutral charcoal (no blue tint) — matches the UI chrome dark base
|
|
50986
|
+
// (--gxr-panel-bg #1c1c1c in tokens.css) so canvas and panels agree.
|
|
50987
|
+
dark: { background: 1842204, isDark: true },
|
|
50636
50988
|
light: { background: 16119285, isDark: false },
|
|
50637
50989
|
midnight: { background: 858922, isDark: true },
|
|
50638
50990
|
forest: { background: 1715738, isDark: true },
|
|
@@ -50692,7 +51044,7 @@ function GraphRenderer({
|
|
|
50692
51044
|
data: dataProp,
|
|
50693
51045
|
minimap: minimapProp = true,
|
|
50694
51046
|
map: mapProp,
|
|
50695
|
-
toolbar: toolbarProp =
|
|
51047
|
+
toolbar: toolbarProp = false,
|
|
50696
51048
|
legend: legendProp,
|
|
50697
51049
|
layoutController,
|
|
50698
51050
|
forceLayout,
|
|
@@ -50707,7 +51059,7 @@ function GraphRenderer({
|
|
|
50707
51059
|
mapProjection: mapProjectionProp,
|
|
50708
51060
|
onThemeChange,
|
|
50709
51061
|
onViewChange,
|
|
50710
|
-
hoverDim =
|
|
51062
|
+
hoverDim = false,
|
|
50711
51063
|
// Phase 2 — interaction callbacks
|
|
50712
51064
|
onNodeClick,
|
|
50713
51065
|
onNodeDoubleClick,
|
|
@@ -50852,6 +51204,7 @@ function GraphRenderer({
|
|
|
50852
51204
|
const glyphAtlasManagerRef = (0, import_react43.useRef)(null);
|
|
50853
51205
|
const imageSyncRequestRef = (0, import_react43.useRef)(0);
|
|
50854
51206
|
const pendingStructureChangeRef = (0, import_react43.useRef)(false);
|
|
51207
|
+
const geoSettleSigRef = (0, import_react43.useRef)("");
|
|
50855
51208
|
const layoutAdapterRef = (0, import_react43.useRef)(null);
|
|
50856
51209
|
const layoutControllerRef = (0, import_react43.useRef)(layoutController);
|
|
50857
51210
|
const forceWasFinishedRef = (0, import_react43.useRef)(void 0);
|
|
@@ -51011,12 +51364,16 @@ function GraphRenderer({
|
|
|
51011
51364
|
if (api2?.map) {
|
|
51012
51365
|
const mode = is3D ? "spherical" : "planar";
|
|
51013
51366
|
const provider = effectiveMap.tileProvider;
|
|
51014
|
-
|
|
51015
|
-
mode
|
|
51016
|
-
|
|
51017
|
-
|
|
51018
|
-
|
|
51019
|
-
|
|
51367
|
+
if (api2.map.isEnabled()) {
|
|
51368
|
+
if (api2.map.getMode() !== mode) void api2.map.transition(mode);
|
|
51369
|
+
} else {
|
|
51370
|
+
void api2.map.enableMap({
|
|
51371
|
+
mode,
|
|
51372
|
+
...typeof provider === "string" && provider.length > 0 ? { provider } : {},
|
|
51373
|
+
...effectiveMap.mapSize !== void 0 ? { mapSize: effectiveMap.mapSize } : {},
|
|
51374
|
+
...effectiveMap.globeRadius !== void 0 ? { globeRadius: effectiveMap.globeRadius } : {}
|
|
51375
|
+
});
|
|
51376
|
+
}
|
|
51020
51377
|
}
|
|
51021
51378
|
}, [effectiveMap, is3D, contextValue]);
|
|
51022
51379
|
import_react43.default.useEffect(() => {
|
|
@@ -51031,8 +51388,12 @@ function GraphRenderer({
|
|
|
51031
51388
|
setAutoMapLayerType(null);
|
|
51032
51389
|
return;
|
|
51033
51390
|
}
|
|
51034
|
-
|
|
51035
|
-
|
|
51391
|
+
const nextType = is3D ? "globe" : "flat";
|
|
51392
|
+
if (autoMapLayerType && autoMapLayerType !== nextType) {
|
|
51393
|
+
apiInstanceRef.current?.map.beginLayerSwap();
|
|
51394
|
+
}
|
|
51395
|
+
setAutoMapLayerType(nextType);
|
|
51396
|
+
}, [effectiveMap, is3D, children, autoMapLayerType]);
|
|
51036
51397
|
import_react43.default.useEffect(() => {
|
|
51037
51398
|
const api2 = apiInstanceRef.current;
|
|
51038
51399
|
if (!api2) return;
|
|
@@ -51262,6 +51623,7 @@ function GraphRenderer({
|
|
|
51262
51623
|
if (!container.style.position || container.style.position === "static") {
|
|
51263
51624
|
container.style.position = "relative";
|
|
51264
51625
|
}
|
|
51626
|
+
container.style.backgroundColor = "#" + effectiveBackground.toString(16).padStart(6, "0");
|
|
51265
51627
|
const canvas = renderer.domElement;
|
|
51266
51628
|
canvas.style.position = "absolute";
|
|
51267
51629
|
canvas.style.top = "0";
|
|
@@ -51551,8 +51913,8 @@ function GraphRenderer({
|
|
|
51551
51913
|
edgeR?.setSphereRadius(sphereRadius ?? 0);
|
|
51552
51914
|
interaction?.picker?.setMapMode(enabled, sphereRadius, damping);
|
|
51553
51915
|
control?.setMapMode(enabled);
|
|
51554
|
-
if (interaction) {
|
|
51555
|
-
interaction.drag.enabled =
|
|
51916
|
+
if (interaction && !enabled) {
|
|
51917
|
+
interaction.drag.enabled = true;
|
|
51556
51918
|
}
|
|
51557
51919
|
mapModeCallbacksRef.current.forEach((cb) => cb(enabled, sphereRadius, damping));
|
|
51558
51920
|
mapDampingRef.current = damping ?? 0.3;
|
|
@@ -51842,21 +52204,21 @@ function GraphRenderer({
|
|
|
51842
52204
|
if (lc?.graph) {
|
|
51843
52205
|
const storeNodes = store.data.nodes;
|
|
51844
52206
|
const storeEdges = store.data.edges;
|
|
52207
|
+
const livePositions = store.getAllPositions();
|
|
51845
52208
|
const oldPositions = /* @__PURE__ */ new Map();
|
|
51846
52209
|
for (const ln of lc.graph.layoutNodes || []) {
|
|
51847
|
-
oldPositions.set(ln.id, {
|
|
51848
|
-
x: ln.position.x,
|
|
51849
|
-
y: ln.position.y,
|
|
51850
|
-
z: ln.position.z,
|
|
51851
|
-
pinned: ln.pinned
|
|
51852
|
-
});
|
|
52210
|
+
oldPositions.set(ln.id, { x: ln.position.x, y: ln.position.y, z: ln.position.z, pinned: ln.pinned });
|
|
51853
52211
|
}
|
|
51854
52212
|
lc.graph.layoutNodes = storeNodes.map((node) => {
|
|
51855
|
-
const
|
|
52213
|
+
const live = livePositions.get(node.id);
|
|
52214
|
+
const old = live ? void 0 : oldPositions.get(node.id);
|
|
52215
|
+
const px = live ? live[0] : old ? old.x : Math.random() * 2 - 1;
|
|
52216
|
+
const py = live ? live[1] : old ? old.y : Math.random() * 2 - 1;
|
|
52217
|
+
const pz = live ? live[2] : old ? old.z : 0;
|
|
51856
52218
|
return {
|
|
51857
52219
|
id: node.id,
|
|
51858
|
-
position:
|
|
51859
|
-
pinned:
|
|
52220
|
+
position: new THREE46.Vector3(px, py, pz),
|
|
52221
|
+
pinned: store.isPinned(node.id),
|
|
51860
52222
|
isPositionDirty: false
|
|
51861
52223
|
};
|
|
51862
52224
|
});
|
|
@@ -51866,6 +52228,7 @@ function GraphRenderer({
|
|
|
51866
52228
|
targetId: edge.target
|
|
51867
52229
|
}));
|
|
51868
52230
|
lc.start?.();
|
|
52231
|
+
geoSettleSigRef.current = "";
|
|
51869
52232
|
}
|
|
51870
52233
|
}
|
|
51871
52234
|
if (layoutAdapter && layoutAdapter.needsUpdate && "clearNeedsUpdate" in layoutAdapter) {
|
|
@@ -51880,6 +52243,22 @@ function GraphRenderer({
|
|
|
51880
52243
|
lcRef.graph.renderNeedsUpdate = false;
|
|
51881
52244
|
}
|
|
51882
52245
|
}
|
|
52246
|
+
{
|
|
52247
|
+
const mapApi = apiInstanceRef.current?.map;
|
|
52248
|
+
if (!mapApi?.isEnabled?.()) {
|
|
52249
|
+
geoSettleSigRef.current = "";
|
|
52250
|
+
} else {
|
|
52251
|
+
const mode = mapApi.getMode();
|
|
52252
|
+
const n = store.data.nodes.length;
|
|
52253
|
+
const buf = store.positionProvider?.getPositions?.();
|
|
52254
|
+
const bufReady = !!buf && buf.length >= n * 3 && n > 0 && (buf[0] !== 0 || buf[1] !== 0 || buf[2] !== 0);
|
|
52255
|
+
const sig = `${n}|${mode}`;
|
|
52256
|
+
if (bufReady && mode && sig !== geoSettleSigRef.current) {
|
|
52257
|
+
geoSettleSigRef.current = sig;
|
|
52258
|
+
mapApi.applyGeoLayout({ mode });
|
|
52259
|
+
}
|
|
52260
|
+
}
|
|
52261
|
+
}
|
|
51883
52262
|
if (nodeRendererRef.current && !childNodeRendererRef.current) {
|
|
51884
52263
|
nodeRendererRef.current.forceUpdateAllAttributes();
|
|
51885
52264
|
}
|
|
@@ -51995,7 +52374,11 @@ function GraphRenderer({
|
|
|
51995
52374
|
renderer.setClearColor(effectiveBackground, 1);
|
|
51996
52375
|
needsRenderRef.current = true;
|
|
51997
52376
|
}
|
|
51998
|
-
|
|
52377
|
+
const host = containerProp ?? internalContainer;
|
|
52378
|
+
if (host) {
|
|
52379
|
+
host.style.backgroundColor = "#" + effectiveBackground.toString(16).padStart(6, "0");
|
|
52380
|
+
}
|
|
52381
|
+
}, [effectiveBackground, containerProp, internalContainer]);
|
|
51999
52382
|
(0, import_react43.useEffect)(() => {
|
|
52000
52383
|
if (contextValue) {
|
|
52001
52384
|
setContextValue((prev) => prev ? { ...prev, theme: resolvedTheme } : prev);
|
|
@@ -52014,7 +52397,7 @@ function GraphRenderer({
|
|
|
52014
52397
|
}
|
|
52015
52398
|
}, [isMapMode]);
|
|
52016
52399
|
(0, import_react43.useEffect)(() => {
|
|
52017
|
-
apiInstanceRef.current?.emphasis.
|
|
52400
|
+
apiInstanceRef.current?.emphasis.setHoverDimEnabled(!!hoverDim);
|
|
52018
52401
|
}, [hoverDim, contextValue]);
|
|
52019
52402
|
(0, import_react43.useEffect)(() => {
|
|
52020
52403
|
if (is3DProp === is3D) return;
|