@kineviz/gl 0.4.4 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +1298 -1
- package/dist/index.css.map +1 -0
- package/dist/index.d.mts +222 -3
- package/dist/index.d.ts +222 -3
- package/dist/index.js +59329 -5611
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +59083 -5633
- package/dist/index.mjs.map +1 -0
- package/dist/kineviz-gl.umd.js +1176 -495
- package/dist/schemas.js +2646 -1
- package/dist/schemas.js.map +1 -0
- package/dist/schemas.mjs +2619 -1
- package/dist/schemas.mjs.map +1 -0
- package/package.json +1 -1
package/dist/kineviz-gl.umd.js
CHANGED
|
@@ -41773,7 +41773,7 @@ var KinevizGL = (() => {
|
|
|
41773
41773
|
};
|
|
41774
41774
|
}
|
|
41775
41775
|
var lbvh_bounds_default = "// P1: scene AABB via atomicMin/atomicMax on i32 bit-reinterpretation of f32 positions.\n// Uses ordered-i32 trick: for positive floats, integer bit pattern preserves order;\n// for negative, flipping all bits restores order. Inverse on read recovers f32.\n\nstruct BoundsParams { nodeCount: u32, _pad0: u32, _pad1: u32, _pad2: u32 };\n\n@group(0) @binding(0) var<storage, read> positions: array<vec4<f32>>;\n@group(0) @binding(1) var<storage, read_write> bounds: array<atomic<i32>, 6>;\n@group(0) @binding(2) var<uniform> params: BoundsParams;\n\nfn floatToOrderedInt(f: f32) -> i32 {\n let bits = bitcast<i32>(f);\n return select(bits ^ 0x7FFFFFFF, bits, bits >= 0);\n}\n\n@compute @workgroup_size(64)\nfn main(@builtin(global_invocation_id) gid: vec3<u32>) {\n let i = gid.x;\n if (i >= params.nodeCount) { return; }\n let p = positions[i].xyz;\n let xi = floatToOrderedInt(p.x);\n let yi = floatToOrderedInt(p.y);\n let zi = floatToOrderedInt(p.z);\n atomicMin(&bounds[0], xi); atomicMax(&bounds[1], xi);\n atomicMin(&bounds[2], yi); atomicMax(&bounds[3], yi);\n atomicMin(&bounds[4], zi); atomicMax(&bounds[5], zi);\n}\n";
|
|
41776
|
-
var lbvh_morton_default = "// P2: per-node Morton code from normalized position. Mirrors mortonReference.ts exactly.\n\
|
|
41776
|
+
var lbvh_morton_default = "// P2: per-node Morton code from normalized position. Mirrors mortonReference.ts exactly.\n\nstruct MortonParams { nodeCount: u32, _pad0: u32, _pad1: u32, _pad2: u32 };\n\n@group(0) @binding(0) var<storage, read> positions: array<vec4<f32>>;\n@group(0) @binding(1) var<storage, read> bounds: array<i32, 6>; // result of P1\n@group(0) @binding(2) var<storage, read_write> mortons: array<u32>;\n@group(0) @binding(3) var<storage, read_write> sortedIndices: array<u32>;\n@group(0) @binding(4) var<uniform> params: MortonParams;\n\nfn orderedIntToFloat(i: i32) -> f32 {\n return bitcast<f32>(select(i ^ 0x7FFFFFFF, i, i >= 0));\n}\n\nfn mortonExpand10(v: u32) -> u32 {\n var x = v & 0x3FFu;\n x = (x | (x << 16u)) & 0x030000FFu;\n x = (x | (x << 8u)) & 0x0300F00Fu;\n x = (x | (x << 4u)) & 0x030C30C3u;\n x = (x | (x << 2u)) & 0x09249249u;\n return x;\n}\n\n@compute @workgroup_size(64)\nfn main(@builtin(global_invocation_id) gid: vec3<u32>) {\n let i = gid.x;\n if (i >= params.nodeCount) { return; }\n\n let minX = orderedIntToFloat(bounds[0]); let maxX = orderedIntToFloat(bounds[1]);\n let minY = orderedIntToFloat(bounds[2]); let maxY = orderedIntToFloat(bounds[3]);\n let minZ = orderedIntToFloat(bounds[4]); let maxZ = orderedIntToFloat(bounds[5]);\n let span = vec3<f32>(max(maxX - minX, 1e-9), max(maxY - minY, 1e-9), max(maxZ - minZ, 1e-9));\n\n let p = positions[i].xyz;\n let n01 = (p - vec3<f32>(minX, minY, minZ)) / span; // [0,1]\n let scaled = clamp(n01 * 1024.0, vec3<f32>(0.0), vec3<f32>(1023.0));\n let xi = u32(scaled.x); let yi = u32(scaled.y); let zi = u32(scaled.z);\n\n mortons[i] = mortonExpand10(xi) | (mortonExpand10(yi) << 1u) | (mortonExpand10(zi) << 2u);\n sortedIndices[i] = i;\n}\n";
|
|
41777
41777
|
var lbvh_build_default = '// P4: Karras-2012 binary radix tree build. One thread per internal node (N-1 threads).\n// Each internal node i covers a range of sorted Morton codes; the split is the largest\n// prefix-difference inside the range.\n//\n// Child pointer encoding (consistent with comBuffer layout):\n// child < N-1 \u2192 internal node, comBuffer index = child\n// child >= N-1 \u2192 leaf, comBuffer index = child, leaf_index_in_sorted = child - (N-1)\n//\n// Race-avoidance: each thread writes its OWN slot in `internalBuf` (left, right, _, last)\n// AND writes parents of its children into a SEPARATE `parentBuf`. Each parentBuf slot is\n// written by exactly one thread (the parent \u2014 child\u2192parent is unique), no race.\n\nstruct BuildParams { nodeCount: u32, _pad0: u32, _pad1: u32, _pad2: u32 };\n\n@group(0) @binding(0) var<storage, read> mortons: array<u32>;\n@group(0) @binding(1) var<storage, read_write> internalBuf: array<vec4<i32>>; // (left, right, _unused, last)\n@group(0) @binding(2) var<storage, read_write> parentBuf: array<i32>; // pre-initialized to -1 by orchestrator\n@group(0) @binding(3) var<storage, read_write> aabb: array<vec4<f32>>; // 2*(2N-1): [2i]=min, [2i+1]=max\n@group(0) @binding(4) var<storage, read> sortedIndices: array<u32>;\n@group(0) @binding(5) var<storage, read> positions: array<vec4<f32>>;\n@group(0) @binding(6) var<uniform> params: BuildParams;\n\nfn lcp(a: i32, b: i32) -> i32 {\n let n = i32(params.nodeCount);\n if (a < 0 || b < 0 || a >= n || b >= n) { return -1; }\n let ua = u32(a); let ub = u32(b);\n if (mortons[ua] == mortons[ub]) {\n // Tie-break with the index itself to ensure unique ordering when Morton codes collide.\n return 32 + i32(countLeadingZeros(ua ^ ub));\n }\n return i32(countLeadingZeros(mortons[ua] ^ mortons[ub]));\n}\n\n@compute @workgroup_size(64)\nfn main(@builtin(global_invocation_id) gid: vec3<u32>) {\n let i = i32(gid.x);\n let n = i32(params.nodeCount);\n let internalCount = n - 1;\n\n // Initialize leaf AABBs (one thread per leaf \u2014 reusing internal-node thread pool).\n // Each thread also initializes its own leaf entry to keep this self-contained.\n if (i < n) {\n let p = positions[sortedIndices[u32(i)]].xyz;\n let leafBase = (n - 1) + i;\n aabb[2 * leafBase ] = vec4<f32>(p, 0.0);\n aabb[2 * leafBase + 1] = vec4<f32>(p, 0.0);\n }\n\n if (i >= internalCount) { return; }\n\n // Determine direction d of the range covered by internal node i.\n let lcpRight = lcp(i, i + 1);\n let lcpLeft = lcp(i, i - 1);\n let d = select(-1, 1, lcpRight > lcpLeft);\n let lcpMin = select(lcpRight, lcpLeft, d == 1); // LCP with the "opposite" direction\n\n // Exponential search for upper bound of range length.\n var lmax: i32 = 2;\n while (lcp(i, i + lmax * d) > lcpMin) { lmax = lmax * 2; }\n\n // Binary search for exact range length l.\n var l: i32 = 0;\n var t: i32 = lmax / 2;\n while (t > 0) {\n if (lcp(i, i + (l + t) * d) > lcpMin) { l = l + t; }\n t = t / 2;\n }\n let j: i32 = i + l * d;\n let first = min(i, j);\n let last = max(i, j);\n\n // Find split \u03B3: binary search for the largest position where \u03B4(first, \u03B3) > \u03B4(first, last).\n let lcpNode = lcp(first, last);\n var s: i32 = 0;\n var divisor: i32 = 2;\n var step: i32 = (l + divisor - 1) / divisor; // ceil\n while (step >= 1) {\n if (lcp(i, i + (s + step) * d) > lcpNode) { s = s + step; }\n if (step == 1) { break; }\n divisor = divisor * 2;\n step = (l + divisor - 1) / divisor;\n }\n let gamma: i32 = i + s * d + min(d, 0); // gamma is split point in [first, last)\n\n // Encode children: leaf if range collapses to a single element, else internal.\n let leftIsLeaf = (min(i, j) == gamma);\n let rightIsLeaf = (max(i, j) == gamma + 1);\n let leftChild = select(gamma, gamma + (n - 1), leftIsLeaf);\n let rightChild = select(gamma + 1, gamma + 1 + (n - 1), rightIsLeaf);\n\n // Write own slot ONLY (no race; each thread owns its index).\n internalBuf[i] = vec4<i32>(leftChild, rightChild, 0, last);\n\n // Write parent of each INTERNAL child into parentBuf (leaves don\'t need parent\n // because depth/COM reduce walks parent\u2192child only). Each parentBuf slot is\n // written by exactly one thread (the unique parent), so no race.\n if (!leftIsLeaf) { parentBuf[leftChild] = i; }\n if (!rightIsLeaf) { parentBuf[rightChild] = i; }\n}\n';
|
|
41778
41778
|
var lbvh_find_root_default = "// P4b: find the root internal node. The root is the unique internal node with\n// parentBuf[i] == -1 (parentBuf is pre-initialized to -1 by orchestrator; P4 overwrote\n// it for every child of every internal node, so only the root remains at -1).\n\nstruct FindRootParams { nodeCount: u32, _pad0: u32, _pad1: u32, _pad2: u32 };\n\n@group(0) @binding(0) var<storage, read> parentBuf: array<i32>;\n@group(0) @binding(1) var<storage, read_write> rootOut: array<u32, 1>;\n@group(0) @binding(2) var<uniform> params: FindRootParams;\n\n@compute @workgroup_size(64)\nfn main(@builtin(global_invocation_id) gid: vec3<u32>) {\n let i = i32(gid.x);\n let internalCount = i32(params.nodeCount) - 1;\n if (i >= internalCount) { return; }\n\n // Exactly one internal node has parent == -1: the root. Safe plain store.\n if (parentBuf[i] == -1) {\n rootOut[0] = u32(i);\n }\n}\n";
|
|
41779
41779
|
var lbvh_assign_depths_default = "// P5: BFS ping-pong. One dispatch per BFS level (LBVH_MAX_DEPTH total = 32, empty levels are no-ops).\n// FrontierCount comes from a GPU-side counter buffer (no CPU readback). currentDepth\n// is the only per-dispatch param and uses a DEDICATED per-dispatch uniform buffer\n// (one of LBVH_MAX_DEPTH=32, allocated once in orchestrator init).\n\nstruct DepthsParams {\n nodeCount: u32,\n currentDepth: u32,\n _pad0: u32,\n _pad1: u32,\n};\n\n@group(0) @binding(0) var<storage, read> internalBuf: array<vec4<i32>>;\n@group(0) @binding(1) var<storage, read> queueIn: array<u32>;\n@group(0) @binding(2) var<storage, read_write> queueOut: array<u32>;\n@group(0) @binding(3) var<storage, read_write> frontierCounts: array<atomic<u32>>; // indexed by depth (0..MAX_DEPTH)\n@group(0) @binding(4) var<storage, read_write> depthBuffer: array<u32>;\n@group(0) @binding(5) var<uniform> params: DepthsParams;\n\n@compute @workgroup_size(64)\nfn main(@builtin(global_invocation_id) gid: vec3<u32>) {\n let i = gid.x;\n // Read the TRUE frontier size for this depth from the counter buffer.\n // atomicLoad is the correct read primitive for an atomic<u32>.\n let frontierCount = atomicLoad(&frontierCounts[params.currentDepth]);\n if (i >= frontierCount) { return; }\n\n let nodeIdx = queueIn[i]; // internal node index (u32)\n depthBuffer[nodeIdx] = params.currentDepth;\n\n let entry = internalBuf[nodeIdx];\n let leftChild = entry.x; // i32\n let rightChild = entry.y;\n let internalCount = i32(params.nodeCount) - 1;\n\n // Enqueue only INTERNAL children (leaves don't need depth).\n if (leftChild < internalCount) {\n let slot = atomicAdd(&frontierCounts[params.currentDepth + 1u], 1u);\n queueOut[slot] = u32(leftChild);\n }\n if (rightChild < internalCount) {\n let slot = atomicAdd(&frontierCounts[params.currentDepth + 1u], 1u);\n queueOut[slot] = u32(rightChild);\n }\n}\n";
|
|
@@ -41849,13 +41849,11 @@ var KinevizGL = (() => {
|
|
|
41849
41849
|
this.depthsBG_BtoA = [];
|
|
41850
41850
|
this.reduceLevelBGs = [];
|
|
41851
41851
|
this.nodeCount = 0;
|
|
41852
|
-
this.dimensions = 3;
|
|
41853
41852
|
this.theta = 0.9;
|
|
41854
41853
|
this.strength = -30;
|
|
41855
41854
|
this.distanceMin = 1;
|
|
41856
41855
|
this.distanceMax = Infinity;
|
|
41857
41856
|
this.nodeCount = ctx.nodeCount;
|
|
41858
|
-
this.dimensions = ctx.dimensions ?? 3;
|
|
41859
41857
|
this.init();
|
|
41860
41858
|
}
|
|
41861
41859
|
setTheta(v) {
|
|
@@ -42003,7 +42001,7 @@ var KinevizGL = (() => {
|
|
|
42003
42001
|
]
|
|
42004
42002
|
});
|
|
42005
42003
|
d.queue.writeBuffer(this.boundsParamsBuf, 0, new Uint32Array([this.nodeCount, 0, 0, 0]));
|
|
42006
|
-
d.queue.writeBuffer(this.mortonParamsBuf, 0, new Uint32Array([this.nodeCount,
|
|
42004
|
+
d.queue.writeBuffer(this.mortonParamsBuf, 0, new Uint32Array([this.nodeCount, 0, 0, 0]));
|
|
42007
42005
|
d.queue.writeBuffer(this.buildParamsBuf, 0, new Uint32Array([this.nodeCount, 0, 0, 0]));
|
|
42008
42006
|
d.queue.writeBuffer(this.findRootParamsBuf, 0, new Uint32Array([this.nodeCount, 0, 0, 0]));
|
|
42009
42007
|
}
|
|
@@ -42107,11 +42105,7 @@ var KinevizGL = (() => {
|
|
|
42107
42105
|
device: ctx.device,
|
|
42108
42106
|
nodeCount: ctx.nodeCount,
|
|
42109
42107
|
positions: ctx.positionBuffer,
|
|
42110
|
-
velocities: ctx.velocityBuffer
|
|
42111
|
-
// 2D mode → 2D Morton (16 bits/axis); avoids wasting a third of the
|
|
42112
|
-
// Morton bits on the unused z axis and the dense-region collisions that
|
|
42113
|
-
// produced the 2D large-N artifact. nDim is supplied by the simulation.
|
|
42114
|
-
dimensions: ctx.nDim
|
|
42108
|
+
velocities: ctx.velocityBuffer
|
|
42115
42109
|
};
|
|
42116
42110
|
passes = new LBVHPasses(lbvhCtx, buffers);
|
|
42117
42111
|
passes.setStrength(strength);
|
|
@@ -42156,6 +42150,250 @@ var KinevizGL = (() => {
|
|
|
42156
42150
|
return force;
|
|
42157
42151
|
}
|
|
42158
42152
|
var quad_clear_default = "// Clear quadtree cell buffer to zero. One thread per cell slot (4 i32s/cell).\n//\n// Layout:\n// group(0)\n// binding(0) cells array<atomic<i32>> read_write\n// binding(1) params ClearParams uniform\n\nstruct ClearParams {\n cellSlotCount: u32, // totalCells \xD7 CELL_STRIDE (4)\n // Number of invocations per Y-row of the dispatch grid (= workgroupCountX \xD7 workgroup_size).\n // Used to recover the linear slot index from a 2D dispatch. Required because the\n // 3D octree at L=7 needs ~150k workgroups for clear, exceeding WebGPU's 65,535\n // per-dim limit; we split across X and Y instead.\n dispatchStrideX: u32,\n _pad1: u32,\n _pad2: u32,\n};\n\n@group(0) @binding(0) var<storage, read_write> cells: array<atomic<i32>>;\n@group(0) @binding(1) var<uniform> params: ClearParams;\n\n@compute @workgroup_size(64)\nfn main(@builtin(global_invocation_id) gid: vec3<u32>) {\n let i = gid.y * params.dispatchStrideX + gid.x;\n if (i >= params.cellSlotCount) { return; }\n atomicStore(&cells[i], 0);\n}\n";
|
|
42153
|
+
var quad_bin_default = "// quad-bin: per-node atomic write of (x, y, mass) into the LEAF cell at MAX level\n// of a fixed-depth 2D quadtree. Reads bounds directly from boundsBuffer (ordered-int\n// encoding produced by lbvh-bounds.wgsl).\n//\n// Cells indexed by Morton interleave (cellX, cellY).\n// leafOffset = (4^L - 1) / 3\n// mortonIdx = interleave(cellX, cellY) in [0, 4^L)\n// Fixed-point sums: position * FIXED_SCALE as i32 atomicAdd. Mass = 1 (count).\n\nstruct BinParams {\n nodeCount: u32,\n maxLevel: u32,\n leafOffset: u32,\n fixedScale: f32,\n};\n\n@group(0) @binding(0) var<storage, read> positions: array<vec4<f32>>;\n@group(0) @binding(1) var<storage, read_write> cells: array<atomic<i32>>;\n@group(0) @binding(2) var<storage, read> bounds: array<i32, 6>; // xMin,xMax,yMin,yMax,zMin,zMax (ordered-int)\n@group(0) @binding(3) var<uniform> params: BinParams;\n\nfn orderedIntToFloat(i: i32) -> f32 {\n return bitcast<f32>(select(i ^ 0x7FFFFFFF, i, i >= 0));\n}\n\nfn mortonExpand16(v: u32) -> u32 {\n var x = v & 0xFFFFu;\n x = (x | (x << 8u)) & 0x00FF00FFu;\n x = (x | (x << 4u)) & 0x0F0F0F0Fu;\n x = (x | (x << 2u)) & 0x33333333u;\n x = (x | (x << 1u)) & 0x55555555u;\n return x;\n}\n\n@compute @workgroup_size(64)\nfn main(@builtin(global_invocation_id) gid: vec3<u32>) {\n let i = gid.x;\n if (i >= params.nodeCount) { return; }\n\n let xMin = orderedIntToFloat(bounds[0]);\n let xMax = orderedIntToFloat(bounds[1]);\n let yMin = orderedIntToFloat(bounds[2]);\n let yMax = orderedIntToFloat(bounds[3]);\n let spanX = max(xMax - xMin, 1e-9);\n let spanY = max(yMax - yMin, 1e-9);\n\n let p = positions[i].xy;\n let levelSize = 1u << params.maxLevel;\n let n01 = clamp(vec2<f32>((p.x - xMin) / spanX, (p.y - yMin) / spanY),\n vec2<f32>(0.0), vec2<f32>(0.999999));\n let cellXi = u32(n01.x * f32(levelSize));\n let cellYi = u32(n01.y * f32(levelSize));\n let mortonIdx = mortonExpand16(cellXi) | (mortonExpand16(cellYi) << 1u);\n\n let cellArrayIdx = params.leafOffset + mortonIdx;\n let baseSlot = cellArrayIdx * 4u;\n\n // Store raw `p * fixedScale` (legacy semantics). FIXED_SCALE chosen small\n // enough that N \xD7 max|p| \xD7 scale < 2^31 (no i32 overflow at typical scales).\n // Normalized variant tested 2026-05-21 \u2014 math was correct but produced 3\xD7\n // wider layout than legacy at same params; reverted to raw.\n let xFixed = i32(p.x * params.fixedScale);\n let yFixed = i32(p.y * params.fixedScale);\n atomicAdd(&cells[baseSlot + 0u], xFixed);\n atomicAdd(&cells[baseSlot + 1u], yFixed);\n atomicAdd(&cells[baseSlot + 3u], 1i);\n}\n";
|
|
42154
|
+
var quad_accumulate_default = "// quad-accumulate: bottom-up COM aggregation.\n//\n// Dispatched once per level k (from MAX_LEVEL-1 down to 0). For each cell at\n// level k (4^k cells), read its 4 children at level k+1 (Morton-contiguous:\n// children of cell M are M*4, M*4+1, M*4+2, M*4+3), sum their (sum_x, sum_y,\n// mass), write to parent slot.\n//\n// d3-force-3d's accumulate(): treeNode.x = \u03A3(child.x * child.mass) / \u03A3mass.\n// We store (sum_x, sum_y, mass) directly (no division yet) \u2014 traverse divides\n// at read time. Avoids precision loss from premature division.\n\nstruct AccumParams {\n parentOffset: u32, // (4^k - 1) / 3 \u2014 offset of level k cells\n childOffset: u32, // (4^(k+1) - 1) / 3 \u2014 offset of level k+1 cells\n parentCount: u32, // 4^k \u2014 number of cells at parent level\n _pad: u32,\n};\n\n@group(0) @binding(0) var<storage, read_write> cells: array<atomic<i32>>;\n@group(0) @binding(1) var<uniform> params: AccumParams;\n\n@compute @workgroup_size(64)\nfn main(@builtin(global_invocation_id) gid: vec3<u32>) {\n let pi = gid.x;\n if (pi >= params.parentCount) { return; }\n\n let parentBase = (params.parentOffset + pi) * 4u;\n let child0Base = (params.childOffset + pi * 4u) * 4u;\n\n var sx: i32 = 0;\n var sy: i32 = 0;\n var sm: i32 = 0;\n for (var c: u32 = 0u; c < 4u; c = c + 1u) {\n let cb = child0Base + c * 4u;\n sx = sx + atomicLoad(&cells[cb + 0u]);\n sy = sy + atomicLoad(&cells[cb + 1u]);\n sm = sm + atomicLoad(&cells[cb + 3u]);\n }\n atomicStore(&cells[parentBase + 0u], sx);\n atomicStore(&cells[parentBase + 1u], sy);\n atomicStore(&cells[parentBase + 3u], sm);\n}\n";
|
|
42155
|
+
var quad_traverse_default = "// quad-traverse: per-query-node Barnes-Hut DFS over a fixed-depth 2D quadtree.\n// Matches d3-force-3d's apply() (manyBody.js).\n//\n// Reads bounds directly from boundsBuffer to compute cellWidth at each level.\n// 2D only \u2014 z component of position/velocity untouched.\n\nstruct TraverseParams {\n nodeCount: u32,\n maxLevel: u32,\n _pad0: u32,\n _pad1: u32,\n strength: f32,\n alpha: f32,\n theta2: f32,\n distanceMin2: f32,\n distanceMax2: f32,\n fixedScale: f32,\n _pad2: f32,\n _pad3: f32,\n};\n\n@group(0) @binding(0) var<storage, read> positions: array<vec4<f32>>;\n@group(0) @binding(1) var<storage, read_write> velocities: array<vec4<f32>>;\n// atomic variables MUST be read_write in WGSL (even when only atomicLoad-ed).\n@group(0) @binding(2) var<storage, read_write> cells: array<atomic<i32>>;\n@group(0) @binding(3) var<storage, read> levelOffsets: array<u32>;\n@group(0) @binding(4) var<storage, read> bounds: array<i32, 6>;\n@group(0) @binding(5) var<uniform> params: TraverseParams;\n\nfn orderedIntToFloat(i: i32) -> f32 {\n return bitcast<f32>(select(i ^ 0x7FFFFFFF, i, i >= 0));\n}\n\n// 16-bit value \u2192 32-bit interleaved (kept in sync with quad-bin.wgsl). Used to\n// compute the query's own leaf cellIdx so the leaf-level branch can subtract\n// the query's contribution from the cell COM (leaf-COM fix; see\n// oct-traverse.wgsl for the 3D analogue).\nfn mortonExpand16(v: u32) -> u32 {\n var x = v & 0xFFFFu;\n x = (x | (x << 8u)) & 0x00FF00FFu;\n x = (x | (x << 4u)) & 0x0F0F0F0Fu;\n x = (x | (x << 2u)) & 0x33333333u;\n x = (x | (x << 1u)) & 0x55555555u;\n return x;\n}\n\n// MAX_STACK=32: max tree depth = 8 levels, each internal pop pushes 4 \u2192 worst-case\n// stack depth \u2264 4 \xD7 maxLevel = 32. Workgroup memory: 64 \xD7 32 \xD7 4 = 8 KB (limit 16 KB).\n// Pack (level, cellIdx) into single u32: high 8 bits = level (0..32), low 24 bits =\n// cellIdx (max 87381 = ((4^9-1)/3) fits in 17 bits, plenty of room in 24).\nconst WG_SIZE: u32 = 64u;\nconst MAX_STACK: u32 = 32u;\nvar<workgroup> stack: array<u32, 2048>; // WG_SIZE \xD7 MAX_STACK\n\n@compute @workgroup_size(64)\nfn main(\n @builtin(global_invocation_id) gid: vec3<u32>,\n @builtin(local_invocation_index) lid: u32,\n) {\n let queryIdx = gid.x;\n if (queryIdx >= params.nodeCount) { return; }\n\n let qp = positions[queryIdx].xy;\n var accum = vec2<f32>(0.0, 0.0);\n let stackBase = lid * MAX_STACK;\n let invScale = 1.0 / params.fixedScale;\n\n let xMin = orderedIntToFloat(bounds[0]);\n let xMax = orderedIntToFloat(bounds[1]);\n let yMin = orderedIntToFloat(bounds[2]);\n let yMax = orderedIntToFloat(bounds[3]);\n let boundsMax = max(xMax - xMin, yMax - yMin);\n\n // Precompute query's own leaf cellIdx (same mapping as quad-bin.wgsl) so the\n // leaf-level branch can subtract self-contribution and avoid the cross-star.\n let spanXq = max(xMax - xMin, 1e-9);\n let spanYq = max(yMax - yMin, 1e-9);\n let levelSizeMax = 1u << params.maxLevel;\n let n01q = clamp(\n vec2<f32>((qp.x - xMin) / spanXq, (qp.y - yMin) / spanYq),\n vec2<f32>(0.0), vec2<f32>(0.999999));\n let qcx = u32(n01q.x * f32(levelSizeMax));\n let qcy = u32(n01q.y * f32(levelSizeMax));\n let queryMorton = mortonExpand16(qcx) | (mortonExpand16(qcy) << 1u);\n let queryLeafCellIdx = levelOffsets[params.maxLevel] + queryMorton;\n\n // Push root: level=0, cellIdx=0. Packed: (0 << 24) | 0 = 0.\n var top: u32 = 0u;\n stack[stackBase + top] = 0u;\n top = top + 1u;\n\n loop {\n if (top == 0u) { break; }\n top = top - 1u;\n let packed = stack[stackBase + top];\n let level = packed >> 24u;\n let cellIdx = packed & 0x00FFFFFFu;\n\n let cb = cellIdx * 4u;\n let mass = f32(atomicLoad(&cells[cb + 3u]));\n if (mass < 0.5) { continue; }\n let sumX = f32(atomicLoad(&cells[cb + 0u])) * invScale;\n let sumY = f32(atomicLoad(&cells[cb + 1u])) * invScale;\n let comX = sumX / mass;\n let comY = sumY / mass;\n\n let levelSize = f32(1u << level);\n let cellWidth = boundsMax / levelSize;\n\n let dx = comX - qp.x;\n let dy = comY - qp.y;\n let l = max(dx * dx + dy * dy, 1e-12);\n\n // BH criterion: cellWidth\xB2 / \u03B8\xB2 < l \u27FA cellWidth\xB2 < l \xD7 \u03B8\xB2\n if (cellWidth * cellWidth < l * params.theta2) {\n var l2 = l;\n if (l2 >= params.distanceMax2) { continue; }\n if (l2 < params.distanceMin2) { l2 = sqrt(params.distanceMin2 * l2); }\n let c = params.strength * mass * params.alpha / l2;\n accum.x = accum.x + dx * c;\n accum.y = accum.y + dy * c;\n continue;\n }\n\n if (level >= params.maxLevel) {\n // Leaf-COM fix: if this leaf is the query's own cell, subtract the\n // query's (x, y, 1) contribution from the cell sum/count so the effective\n // COM is the centroid of the OTHER nodes in the leaf. See oct-traverse\n // for rationale (cross-star avoidance on dense graphs).\n if (cellIdx == queryLeafCellIdx) {\n let adjMass = mass - 1.0;\n if (adjMass < 0.5) { continue; } // query was the sole occupant\n let adjSumX = sumX - qp.x;\n let adjSumY = sumY - qp.y;\n let adjComX = adjSumX / adjMass;\n let adjComY = adjSumY / adjMass;\n let dxa = adjComX - qp.x;\n let dya = adjComY - qp.y;\n var la = max(dxa * dxa + dya * dya, 1e-12);\n if (la >= params.distanceMax2) { continue; }\n if (la < params.distanceMin2) { la = sqrt(params.distanceMin2 * la); }\n let ca = params.strength * adjMass * params.alpha / la;\n accum.x = accum.x + dxa * ca;\n accum.y = accum.y + dya * ca;\n continue;\n }\n // Leaf cell: apply COM aggregate (mass nodes). Self-interaction guard:\n // if leaf contains only this query node, COM == queryPos \u2192 dx=dy=0 \u2192 skip.\n let isSelf = (mass < 1.5) && (abs(dx) < 1e-6) && (abs(dy) < 1e-6);\n if (isSelf) { continue; }\n var l2 = l;\n if (l2 >= params.distanceMax2) { continue; }\n if (l2 < params.distanceMin2) { l2 = sqrt(params.distanceMin2 * l2); }\n let c = params.strength * mass * params.alpha / l2;\n accum.x = accum.x + dx * c;\n accum.y = accum.y + dy * c;\n continue;\n }\n\n // Descend into 4 children. Children of cell at Morton M, level k are at\n // level k+1, Morton M*4..M*4+3, stored at levelOffsets[k+1] + M*4 + c.\n let parentMorton = cellIdx - levelOffsets[level];\n let childBase = levelOffsets[level + 1u] + parentMorton * 4u;\n if (top + 4u <= MAX_STACK) {\n let nextLevel = level + 1u;\n for (var c: u32 = 0u; c < 4u; c = c + 1u) {\n stack[stackBase + top] = (nextLevel << 24u) | (childBase + c);\n top = top + 1u;\n }\n }\n }\n\n velocities[queryIdx] = vec4<f32>(\n velocities[queryIdx].x + accum.x,\n velocities[queryIdx].y + accum.y,\n velocities[queryIdx].z,\n velocities[queryIdx].w,\n );\n}\n";
|
|
42156
|
+
var QUADTREE_MAX_LEVEL = 8;
|
|
42157
|
+
var QUADTREE_WORKGROUP_SIZE = 64;
|
|
42158
|
+
var FIXED_SCALE = 64;
|
|
42159
|
+
var CELL_STRIDE = 4;
|
|
42160
|
+
function totalCellsQuadtree(maxLevel) {
|
|
42161
|
+
return Math.floor((Math.pow(4, maxLevel + 1) - 1) / 3);
|
|
42162
|
+
}
|
|
42163
|
+
function levelOffsetQuadtree(level) {
|
|
42164
|
+
return Math.floor((Math.pow(4, level) - 1) / 3);
|
|
42165
|
+
}
|
|
42166
|
+
var QuadTreePass = class {
|
|
42167
|
+
constructor(ctx, maxLevel = QUADTREE_MAX_LEVEL) {
|
|
42168
|
+
this.accumParamsBufs = [];
|
|
42169
|
+
this.accumBGs = [];
|
|
42170
|
+
this.config = {
|
|
42171
|
+
strength: -30,
|
|
42172
|
+
theta: 0.9,
|
|
42173
|
+
distanceMin: 1,
|
|
42174
|
+
distanceMax: Infinity
|
|
42175
|
+
};
|
|
42176
|
+
this.device = ctx.device;
|
|
42177
|
+
this.nodeCount = ctx.nodeCount;
|
|
42178
|
+
this.maxLevel = maxLevel;
|
|
42179
|
+
this.totalCells = totalCellsQuadtree(maxLevel);
|
|
42180
|
+
const d = this.device;
|
|
42181
|
+
const STORAGE = GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST | GPUBufferUsage.COPY_SRC;
|
|
42182
|
+
const UNIFORM = GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST;
|
|
42183
|
+
this.cellsBuffer = d.createBuffer({
|
|
42184
|
+
label: "quad-cells",
|
|
42185
|
+
size: this.totalCells * CELL_STRIDE * 4,
|
|
42186
|
+
// i32 = 4 bytes
|
|
42187
|
+
usage: STORAGE
|
|
42188
|
+
});
|
|
42189
|
+
this.boundsBuffer = d.createBuffer({
|
|
42190
|
+
label: "quad-bounds",
|
|
42191
|
+
size: 32,
|
|
42192
|
+
// atomic<i32> × 6 padded
|
|
42193
|
+
usage: STORAGE
|
|
42194
|
+
});
|
|
42195
|
+
this.levelOffsetsBuffer = d.createBuffer({
|
|
42196
|
+
label: "quad-level-offsets",
|
|
42197
|
+
size: (maxLevel + 1) * 4,
|
|
42198
|
+
usage: STORAGE
|
|
42199
|
+
});
|
|
42200
|
+
const offsets = new Uint32Array(maxLevel + 1);
|
|
42201
|
+
for (let k = 0; k <= maxLevel; k++) offsets[k] = levelOffsetQuadtree(k);
|
|
42202
|
+
d.queue.writeBuffer(this.levelOffsetsBuffer, 0, offsets);
|
|
42203
|
+
this.boundsParamsBuf = d.createBuffer({ label: "quad-bounds-params", size: 16, usage: UNIFORM });
|
|
42204
|
+
this.clearParamsBuf = d.createBuffer({ label: "quad-clear-params", size: 16, usage: UNIFORM });
|
|
42205
|
+
this.binParamsBuf = d.createBuffer({ label: "quad-bin-params", size: 16, usage: UNIFORM });
|
|
42206
|
+
this.traverseParamsBuf = d.createBuffer({ label: "quad-traverse-params", size: 48, usage: UNIFORM });
|
|
42207
|
+
for (let k = 0; k < maxLevel; k++) {
|
|
42208
|
+
const buf = d.createBuffer({ label: `quad-accum-params-L${k}`, size: 16, usage: UNIFORM });
|
|
42209
|
+
const p = new Uint32Array([
|
|
42210
|
+
levelOffsetQuadtree(k),
|
|
42211
|
+
// parentOffset
|
|
42212
|
+
levelOffsetQuadtree(k + 1),
|
|
42213
|
+
// childOffset
|
|
42214
|
+
Math.pow(4, k),
|
|
42215
|
+
// parentCount = 4^k
|
|
42216
|
+
0
|
|
42217
|
+
]);
|
|
42218
|
+
d.queue.writeBuffer(buf, 0, p);
|
|
42219
|
+
this.accumParamsBufs.push(buf);
|
|
42220
|
+
}
|
|
42221
|
+
const totalSlots = this.totalCells * CELL_STRIDE;
|
|
42222
|
+
const totalWG = Math.ceil(totalSlots / QUADTREE_WORKGROUP_SIZE);
|
|
42223
|
+
const dispatchStrideX = totalWG * QUADTREE_WORKGROUP_SIZE;
|
|
42224
|
+
d.queue.writeBuffer(
|
|
42225
|
+
this.clearParamsBuf,
|
|
42226
|
+
0,
|
|
42227
|
+
new Uint32Array([totalSlots, dispatchStrideX, 0, 0])
|
|
42228
|
+
);
|
|
42229
|
+
const mk = (label, code) => d.createShaderModule({ label, code });
|
|
42230
|
+
const pipe = (label, m2, entry = "main") => d.createComputePipeline({ label, layout: "auto", compute: { module: m2, entryPoint: entry } });
|
|
42231
|
+
this.boundsPipeline = pipe("quad-bounds-pipe", mk("quad-bounds", lbvh_bounds_default));
|
|
42232
|
+
this.clearPipeline = pipe("quad-clear-pipe", mk("quad-clear", quad_clear_default));
|
|
42233
|
+
this.binPipeline = pipe("quad-bin-pipe", mk("quad-bin", quad_bin_default));
|
|
42234
|
+
this.accumPipeline = pipe("quad-accum-pipe", mk("quad-accum", quad_accumulate_default));
|
|
42235
|
+
this.traversePipeline = pipe("quad-traverse-pipe", mk("quad-traverse", quad_traverse_default));
|
|
42236
|
+
this.bindAll(ctx);
|
|
42237
|
+
}
|
|
42238
|
+
bindAll(ctx) {
|
|
42239
|
+
const d = this.device;
|
|
42240
|
+
this.boundsBG = d.createBindGroup({
|
|
42241
|
+
layout: this.boundsPipeline.getBindGroupLayout(0),
|
|
42242
|
+
entries: [
|
|
42243
|
+
{ binding: 0, resource: { buffer: ctx.positionBuffer } },
|
|
42244
|
+
{ binding: 1, resource: { buffer: this.boundsBuffer } },
|
|
42245
|
+
{ binding: 2, resource: { buffer: this.boundsParamsBuf } }
|
|
42246
|
+
]
|
|
42247
|
+
});
|
|
42248
|
+
this.clearBG = d.createBindGroup({
|
|
42249
|
+
layout: this.clearPipeline.getBindGroupLayout(0),
|
|
42250
|
+
entries: [
|
|
42251
|
+
{ binding: 0, resource: { buffer: this.cellsBuffer } },
|
|
42252
|
+
{ binding: 1, resource: { buffer: this.clearParamsBuf } }
|
|
42253
|
+
]
|
|
42254
|
+
});
|
|
42255
|
+
this.binBG = d.createBindGroup({
|
|
42256
|
+
layout: this.binPipeline.getBindGroupLayout(0),
|
|
42257
|
+
entries: [
|
|
42258
|
+
{ binding: 0, resource: { buffer: ctx.positionBuffer } },
|
|
42259
|
+
{ binding: 1, resource: { buffer: this.cellsBuffer } },
|
|
42260
|
+
{ binding: 2, resource: { buffer: this.boundsBuffer } },
|
|
42261
|
+
{ binding: 3, resource: { buffer: this.binParamsBuf } }
|
|
42262
|
+
]
|
|
42263
|
+
});
|
|
42264
|
+
for (let k = 0; k < this.maxLevel; k++) {
|
|
42265
|
+
this.accumBGs.push(d.createBindGroup({
|
|
42266
|
+
layout: this.accumPipeline.getBindGroupLayout(0),
|
|
42267
|
+
entries: [
|
|
42268
|
+
{ binding: 0, resource: { buffer: this.cellsBuffer } },
|
|
42269
|
+
{ binding: 1, resource: { buffer: this.accumParamsBufs[k] } }
|
|
42270
|
+
]
|
|
42271
|
+
}));
|
|
42272
|
+
}
|
|
42273
|
+
this.traverseBG = d.createBindGroup({
|
|
42274
|
+
layout: this.traversePipeline.getBindGroupLayout(0),
|
|
42275
|
+
entries: [
|
|
42276
|
+
{ binding: 0, resource: { buffer: ctx.positionBuffer } },
|
|
42277
|
+
{ binding: 1, resource: { buffer: ctx.velocityBuffer } },
|
|
42278
|
+
{ binding: 2, resource: { buffer: this.cellsBuffer } },
|
|
42279
|
+
{ binding: 3, resource: { buffer: this.levelOffsetsBuffer } },
|
|
42280
|
+
{ binding: 4, resource: { buffer: this.boundsBuffer } },
|
|
42281
|
+
{ binding: 5, resource: { buffer: this.traverseParamsBuf } }
|
|
42282
|
+
]
|
|
42283
|
+
});
|
|
42284
|
+
const binParams = new ArrayBuffer(16);
|
|
42285
|
+
new Uint32Array(binParams, 0, 3).set([this.nodeCount, this.maxLevel, levelOffsetQuadtree(this.maxLevel)]);
|
|
42286
|
+
new Float32Array(binParams, 12, 1)[0] = FIXED_SCALE;
|
|
42287
|
+
d.queue.writeBuffer(this.binParamsBuf, 0, binParams);
|
|
42288
|
+
d.queue.writeBuffer(this.boundsParamsBuf, 0, new Uint32Array([this.nodeCount, 0, 0, 0]));
|
|
42289
|
+
}
|
|
42290
|
+
setConfig(c2) {
|
|
42291
|
+
Object.assign(this.config, c2);
|
|
42292
|
+
}
|
|
42293
|
+
apply(alpha, encoder) {
|
|
42294
|
+
const d = this.device;
|
|
42295
|
+
const n = this.nodeCount;
|
|
42296
|
+
const wg = QUADTREE_WORKGROUP_SIZE;
|
|
42297
|
+
const sent = new Int32Array([2147483647, -2147483648, 2147483647, -2147483648, 2147483647, -2147483648]);
|
|
42298
|
+
d.queue.writeBuffer(this.boundsBuffer, 0, sent);
|
|
42299
|
+
this.run(encoder, this.boundsPipeline, this.boundsBG, Math.ceil(n / wg), "quad-p1-bounds");
|
|
42300
|
+
this.run(
|
|
42301
|
+
encoder,
|
|
42302
|
+
this.clearPipeline,
|
|
42303
|
+
this.clearBG,
|
|
42304
|
+
Math.ceil(this.totalCells * CELL_STRIDE / wg),
|
|
42305
|
+
"quad-p2-clear"
|
|
42306
|
+
);
|
|
42307
|
+
this.run(encoder, this.binPipeline, this.binBG, Math.ceil(n / wg), "quad-p3-bin");
|
|
42308
|
+
for (let k = this.maxLevel - 1; k >= 0; k--) {
|
|
42309
|
+
this.run(
|
|
42310
|
+
encoder,
|
|
42311
|
+
this.accumPipeline,
|
|
42312
|
+
this.accumBGs[k],
|
|
42313
|
+
Math.ceil(Math.pow(4, k) / wg),
|
|
42314
|
+
`quad-p4-accum-L${k}`
|
|
42315
|
+
);
|
|
42316
|
+
}
|
|
42317
|
+
const tp = new ArrayBuffer(48);
|
|
42318
|
+
const tu = new Uint32Array(tp);
|
|
42319
|
+
const tf = new Float32Array(tp);
|
|
42320
|
+
tu[0] = n;
|
|
42321
|
+
tu[1] = this.maxLevel;
|
|
42322
|
+
tf[4] = this.config.strength;
|
|
42323
|
+
tf[5] = alpha;
|
|
42324
|
+
tf[6] = this.config.theta * this.config.theta;
|
|
42325
|
+
tf[7] = this.config.distanceMin * this.config.distanceMin;
|
|
42326
|
+
tf[8] = this.config.distanceMax === Infinity ? 1e30 : this.config.distanceMax * this.config.distanceMax;
|
|
42327
|
+
tf[9] = FIXED_SCALE;
|
|
42328
|
+
d.queue.writeBuffer(this.traverseParamsBuf, 0, tp);
|
|
42329
|
+
this.run(encoder, this.traversePipeline, this.traverseBG, Math.ceil(n / wg), "quad-p5-traverse");
|
|
42330
|
+
}
|
|
42331
|
+
run(encoder, pipe, bg, workgroups, label) {
|
|
42332
|
+
const p = encoder.beginComputePass({ label });
|
|
42333
|
+
p.setPipeline(pipe);
|
|
42334
|
+
p.setBindGroup(0, bg);
|
|
42335
|
+
p.dispatchWorkgroups(workgroups);
|
|
42336
|
+
p.end();
|
|
42337
|
+
}
|
|
42338
|
+
dispose() {
|
|
42339
|
+
this.cellsBuffer.destroy();
|
|
42340
|
+
this.boundsBuffer.destroy();
|
|
42341
|
+
this.levelOffsetsBuffer.destroy();
|
|
42342
|
+
this.boundsParamsBuf.destroy();
|
|
42343
|
+
this.clearParamsBuf.destroy();
|
|
42344
|
+
this.binParamsBuf.destroy();
|
|
42345
|
+
this.traverseParamsBuf.destroy();
|
|
42346
|
+
this.accumParamsBufs.forEach((b) => b.destroy());
|
|
42347
|
+
}
|
|
42348
|
+
};
|
|
42349
|
+
function webgpuForceManyBodyQuadtree() {
|
|
42350
|
+
let strength = -30;
|
|
42351
|
+
let distanceMin = 1;
|
|
42352
|
+
let distanceMax = Infinity;
|
|
42353
|
+
let theta = 0.9;
|
|
42354
|
+
let pass = null;
|
|
42355
|
+
const force = {
|
|
42356
|
+
initialize(_nodes, _random, _nDim) {
|
|
42357
|
+
},
|
|
42358
|
+
initGPU(ctx) {
|
|
42359
|
+
pass?.dispose();
|
|
42360
|
+
pass = new QuadTreePass(ctx);
|
|
42361
|
+
pass.setConfig({ strength, theta, distanceMin, distanceMax });
|
|
42362
|
+
},
|
|
42363
|
+
apply(alpha, encoder) {
|
|
42364
|
+
pass?.apply(alpha, encoder);
|
|
42365
|
+
},
|
|
42366
|
+
dispose() {
|
|
42367
|
+
pass?.dispose();
|
|
42368
|
+
pass = null;
|
|
42369
|
+
},
|
|
42370
|
+
strength(value) {
|
|
42371
|
+
if (arguments.length === 0) return strength;
|
|
42372
|
+
strength = +value;
|
|
42373
|
+
pass?.setConfig({ strength });
|
|
42374
|
+
return force;
|
|
42375
|
+
},
|
|
42376
|
+
distanceMin(value) {
|
|
42377
|
+
if (arguments.length === 0) return distanceMin;
|
|
42378
|
+
distanceMin = +value;
|
|
42379
|
+
pass?.setConfig({ distanceMin });
|
|
42380
|
+
return force;
|
|
42381
|
+
},
|
|
42382
|
+
distanceMax(value) {
|
|
42383
|
+
if (arguments.length === 0) return distanceMax;
|
|
42384
|
+
distanceMax = +value;
|
|
42385
|
+
pass?.setConfig({ distanceMax });
|
|
42386
|
+
return force;
|
|
42387
|
+
},
|
|
42388
|
+
theta(value) {
|
|
42389
|
+
if (arguments.length === 0) return theta;
|
|
42390
|
+
theta = +value;
|
|
42391
|
+
pass?.setConfig({ theta });
|
|
42392
|
+
return force;
|
|
42393
|
+
}
|
|
42394
|
+
};
|
|
42395
|
+
return force;
|
|
42396
|
+
}
|
|
42159
42397
|
var oct_bin_default = "// oct-bin: 3D version of quad-bin. Per-node atomic write of (x, y, z, mass)\n// into the LEAF cell at MAX level of a fixed-depth 3D octree.\n// Cell address: leafOffset + morton3D(cellX, cellY, cellZ).\n\nstruct BinParams {\n nodeCount: u32,\n maxLevel: u32,\n leafOffset: u32,\n fixedScale: f32,\n};\n\n@group(0) @binding(0) var<storage, read> positions: array<vec4<f32>>;\n@group(0) @binding(1) var<storage, read_write> cells: array<atomic<i32>>;\n@group(0) @binding(2) var<storage, read> bounds: array<i32, 6>;\n@group(0) @binding(3) var<uniform> params: BinParams;\n\nfn orderedIntToFloat(i: i32) -> f32 {\n return bitcast<f32>(select(i ^ 0x7FFFFFFF, i, i >= 0));\n}\n\n// 10-bit value \u2192 30-bit interleaved (each input bit at every 3rd output bit).\nfn mortonExpand10(v: u32) -> u32 {\n var x = v & 0x3FFu;\n x = (x | (x << 16u)) & 0x030000FFu;\n x = (x | (x << 8u)) & 0x0300F00Fu;\n x = (x | (x << 4u)) & 0x030C30C3u;\n x = (x | (x << 2u)) & 0x09249249u;\n return x;\n}\n\n@compute @workgroup_size(64)\nfn main(@builtin(global_invocation_id) gid: vec3<u32>) {\n let i = gid.x;\n if (i >= params.nodeCount) { return; }\n\n let xMin = orderedIntToFloat(bounds[0]);\n let xMax = orderedIntToFloat(bounds[1]);\n let yMin = orderedIntToFloat(bounds[2]);\n let yMax = orderedIntToFloat(bounds[3]);\n let zMin = orderedIntToFloat(bounds[4]);\n let zMax = orderedIntToFloat(bounds[5]);\n let spanX = max(xMax - xMin, 1e-9);\n let spanY = max(yMax - yMin, 1e-9);\n let spanZ = max(zMax - zMin, 1e-9);\n\n let p = positions[i].xyz;\n let levelSize = 1u << params.maxLevel;\n let n01 = clamp(\n vec3<f32>((p.x - xMin) / spanX, (p.y - yMin) / spanY, (p.z - zMin) / spanZ),\n vec3<f32>(0.0), vec3<f32>(0.999999));\n let cellXi = u32(n01.x * f32(levelSize));\n let cellYi = u32(n01.y * f32(levelSize));\n let cellZi = u32(n01.z * f32(levelSize));\n let mortonIdx =\n mortonExpand10(cellXi)\n | (mortonExpand10(cellYi) << 1u)\n | (mortonExpand10(cellZi) << 2u);\n\n let cellArrayIdx = params.leafOffset + mortonIdx;\n let baseSlot = cellArrayIdx * 4u;\n\n // Store raw `p * fixedScale` (legacy semantics).\n let xFixed = i32(p.x * params.fixedScale);\n let yFixed = i32(p.y * params.fixedScale);\n let zFixed = i32(p.z * params.fixedScale);\n atomicAdd(&cells[baseSlot + 0u], xFixed);\n atomicAdd(&cells[baseSlot + 1u], yFixed);\n atomicAdd(&cells[baseSlot + 2u], zFixed);\n atomicAdd(&cells[baseSlot + 3u], 1i);\n}\n";
|
|
42160
42398
|
var oct_accumulate_default = "// oct-accumulate: bottom-up COM aggregation for 3D octree.\n//\n// Mirrors d3-force-3d's manyBody accumulate:\n// strength += child.value;\n// strength *= Math.sqrt(4 / numChildren); // 0.707 for octree (8 children)\n//\n// Implemented by scaling the parent's accumulated MASS by sqrt(4/8) = 0.707 in\n// fixed-point. (Sum_x/Sum_y/Sum_z keep the un-scaled position-weighted sums;\n// COM at traverse is sum/mass, so mass scaling makes the force F = strength *\n// mass * alpha / l\xB2 also scale by 0.707 \u2014 matching d3 exactly.)\n\nstruct AccumParams {\n parentOffset: u32,\n childOffset: u32,\n parentCount: u32, // 8^k\n _pad: u32,\n};\n\n@group(0) @binding(0) var<storage, read_write> cells: array<atomic<i32>>;\n@group(0) @binding(1) var<uniform> params: AccumParams;\n\n@compute @workgroup_size(64)\nfn main(@builtin(global_invocation_id) gid: vec3<u32>) {\n let pi = gid.x;\n if (pi >= params.parentCount) { return; }\n\n let parentBase = (params.parentOffset + pi) * 4u;\n let child0Base = (params.childOffset + pi * 8u) * 4u;\n\n var sx: i32 = 0;\n var sy: i32 = 0;\n var sz: i32 = 0;\n var sm: i32 = 0;\n for (var c: u32 = 0u; c < 8u; c = c + 1u) {\n let cb = child0Base + c * 4u;\n sx = sx + atomicLoad(&cells[cb + 0u]);\n sy = sy + atomicLoad(&cells[cb + 1u]);\n sz = sz + atomicLoad(&cells[cb + 2u]);\n sm = sm + atomicLoad(&cells[cb + 3u]);\n }\n // Store UNSCALED sums + UNSCALED count. d3's sqrt(4/numChildren) scaling\n // is applied at FORCE APPLICATION time in oct-traverse using the cell's\n // level \u2014 keeps COM = sum/count correct (scaled COM would inflate positions).\n atomicStore(&cells[parentBase + 0u], sx);\n atomicStore(&cells[parentBase + 1u], sy);\n atomicStore(&cells[parentBase + 2u], sz);\n atomicStore(&cells[parentBase + 3u], sm);\n}\n";
|
|
42161
42399
|
var oct_traverse_default = `// oct-traverse: per-query-node Barnes-Hut DFS over fixed-depth 3D octree.
|
|
@@ -42861,28 +43099,23 @@ fn main(
|
|
|
42861
43099
|
this.simulation = sim;
|
|
42862
43100
|
}
|
|
42863
43101
|
/** Build a charge force matching the current dimension + node count.
|
|
42864
|
-
* LBVH binary radix tree (tight AABB + single-node leaves: no
|
|
42865
|
-
*
|
|
42866
|
-
*
|
|
42867
|
-
*
|
|
42868
|
-
*
|
|
42869
|
-
*
|
|
42870
|
-
*
|
|
42871
|
-
*
|
|
42872
|
-
*
|
|
42873
|
-
*
|
|
42874
|
-
*
|
|
42875
|
-
*
|
|
42876
|
-
* giving 32× finer spatial resolution and far fewer dense-region collisions.
|
|
42877
|
-
* z stays 0 (integrate masks it each tick), so the traverse's dz terms vanish.
|
|
42878
|
-
*
|
|
42879
|
-
* 3D mode → LBVH (3D Morton) for N≥10k; fixed octree for N<10k (fast, and
|
|
42880
|
-
* uniform-enough density at small N that the artifact does not appear).
|
|
43102
|
+
* N≥10k → LBVH binary radix tree (tight AABB + single-node leaves: no
|
|
43103
|
+
* fixed-grid axis bias, no leaf-COM averaging; mandatory on dense
|
|
43104
|
+
* scale-free graphs where the fixed-depth oct/quadtree's axis-
|
|
43105
|
+
* aligned intermediate-level COMs produce the "4-quadrant lobe"
|
|
43106
|
+
* artifact even with leaf-COM self-subtract and L=7/8). Threshold
|
|
43107
|
+
* dropped 100k → 10k on 2026-05-22. **2D mode reuses the 3D LBVH**
|
|
43108
|
+
* with z=0 across all positions: the integrate shader masks z to 0
|
|
43109
|
+
* each tick (`nDim < 3 → p.z=0; v.z=0`), so z-axis force compute is
|
|
43110
|
+
* ~1/3 wasted but the layout output is identical. This sidesteps
|
|
43111
|
+
* implementing a 2D-specific LBVH while killing the same intermediate-
|
|
43112
|
+
* COM artifact in 2D.
|
|
43113
|
+
* N<10k → fixed-depth octree/quadtree (d3-force-3d parity, fast, no artifact).
|
|
42881
43114
|
*/
|
|
42882
43115
|
makeChargeForce(n) {
|
|
42883
43116
|
if (this.params.dimensions === 2) {
|
|
42884
|
-
const f2 =
|
|
42885
|
-
f2.theta(this.params.octreeTheta);
|
|
43117
|
+
const f2 = webgpuForceManyBodyQuadtree();
|
|
43118
|
+
f2.theta?.(this.params.octreeTheta);
|
|
42886
43119
|
f2.strength(this.params.charge);
|
|
42887
43120
|
return f2;
|
|
42888
43121
|
}
|
|
@@ -43074,32 +43307,6 @@ fn main(
|
|
|
43074
43307
|
}
|
|
43075
43308
|
this.graph.renderNeedsUpdate = true;
|
|
43076
43309
|
}
|
|
43077
|
-
/**
|
|
43078
|
-
* Drag write: set a single node's position on BOTH the CPU readback buffer
|
|
43079
|
-
* (`sharedArray`, what the renderer samples in mode='cpu') and the GPU
|
|
43080
|
-
* position buffer (so the next readback doesn't overwrite it). `index` is the
|
|
43081
|
-
* store/sim node index — identical to the addressing of getPositions()/
|
|
43082
|
-
* sharedArray (offset/3) — which is exactly what the engine's DragHandler
|
|
43083
|
-
* passes. Mirrors CPUPositionProvider.updatePosition; the WebGPU adapter was
|
|
43084
|
-
* missing this, so after DragHandler retired its getPositions() borrowed-array
|
|
43085
|
-
* fallback (position-coherence refactor) drag writes silently no-op'd.
|
|
43086
|
-
*/
|
|
43087
|
-
updatePosition(index3, x3, y3, z3) {
|
|
43088
|
-
const o = index3 * 3;
|
|
43089
|
-
if (o >= 0 && o + 2 < this.sharedArray.length) {
|
|
43090
|
-
this.sharedArray[o] = x3;
|
|
43091
|
-
this.sharedArray[o + 1] = y3;
|
|
43092
|
-
this.sharedArray[o + 2] = z3;
|
|
43093
|
-
}
|
|
43094
|
-
const sn = this.simNodes[index3];
|
|
43095
|
-
if (sn) {
|
|
43096
|
-
sn.x = x3;
|
|
43097
|
-
sn.y = y3;
|
|
43098
|
-
sn.z = z3;
|
|
43099
|
-
}
|
|
43100
|
-
this.simulation?.uploadPosition(index3, x3, y3, z3);
|
|
43101
|
-
this.graph.renderNeedsUpdate = true;
|
|
43102
|
-
}
|
|
43103
43310
|
// ---------------- Pin / unpin ----------------
|
|
43104
43311
|
pinNodes(nodes) {
|
|
43105
43312
|
if (!this.simulation) return;
|
|
@@ -44615,7 +44822,8 @@ fn main(
|
|
|
44615
44822
|
{ name: "ringColors", stride: 3, default: 0, optional: true },
|
|
44616
44823
|
{ name: "ripple", stride: 1, default: 0 },
|
|
44617
44824
|
{ name: "breathe", stride: 1, default: 0 },
|
|
44618
|
-
{ name: "halo", stride: 1, default: 0 }
|
|
44825
|
+
{ name: "halo", stride: 1, default: 0 },
|
|
44826
|
+
{ name: "suppressFill", stride: 1, default: 0 }
|
|
44619
44827
|
];
|
|
44620
44828
|
var EDGE_RENDER_PROPERTIES = [
|
|
44621
44829
|
{ name: "colors", stride: 3, default: 0, initValues: [0.5, 0.5, 0.5] },
|
|
@@ -46857,6 +47065,28 @@ fn main(
|
|
|
46857
47065
|
}
|
|
46858
47066
|
return out;
|
|
46859
47067
|
}
|
|
47068
|
+
/**
|
|
47069
|
+
* Suppress (or restore) the built-in node fill for the given node ids. A
|
|
47070
|
+
* suppressed node still lays out, picks, selects, and connects edges — only
|
|
47071
|
+
* its dot/ring/icon stops drawing, so a custom layer can own its look.
|
|
47072
|
+
* Backs createNodeShaderLayer({ hideBuiltinNode: true }).
|
|
47073
|
+
*/
|
|
47074
|
+
setNodeFillSuppressed(ids, on) {
|
|
47075
|
+
const st = this.nodeState;
|
|
47076
|
+
if (!st) return;
|
|
47077
|
+
const v = on ? 1 : 0;
|
|
47078
|
+
let changed = false;
|
|
47079
|
+
for (const id of ids) {
|
|
47080
|
+
const idx = this.index.getNodeIndex(id);
|
|
47081
|
+
if (idx !== void 0 && idx >= 0 && idx < st.suppressFill.length) {
|
|
47082
|
+
if (st.suppressFill[idx] !== v) {
|
|
47083
|
+
st.suppressFill[idx] = v;
|
|
47084
|
+
changed = true;
|
|
47085
|
+
}
|
|
47086
|
+
}
|
|
47087
|
+
}
|
|
47088
|
+
if (changed) this.updateStrategy.markDirty("nodeSuppressFill");
|
|
47089
|
+
}
|
|
46860
47090
|
/**
|
|
46861
47091
|
* Get all currently hidden node IDs. Backed by `_nodeState.hidden[]`
|
|
46862
47092
|
* (0 = visible, 1 = hidden).
|
|
@@ -48419,13 +48649,13 @@ fn main(
|
|
|
48419
48649
|
};
|
|
48420
48650
|
|
|
48421
48651
|
// src/shaders/node.vert.glsl
|
|
48422
|
-
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';
|
|
48652
|
+
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 float nodeSuppressFill;\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 vSuppressFill;\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 vSuppressFill = nodeSuppressFill;\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';
|
|
48423
48653
|
|
|
48424
48654
|
// src/shaders/node.frag.glsl
|
|
48425
|
-
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 // \xD7 vOpacity: rings must dim with their node under focusContext \u2014 the\n // ring/additive writes below otherwise ignore the per-node dim opacity.\n rippleAlphaSum *= vOpacity;\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 // \xD7 vOpacity: the max() must not resurrect alpha focusContext dimmed.\n gl_FragColor.a = max(gl_FragColor.a, falloff * vHalo * HALO_ALPHA * vOpacity);\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";
|
|
48655
|
+
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 vSuppressFill;\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 if (vSuppressFill > 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 // \xD7 vOpacity: rings must dim with their node under focusContext \u2014 the\n // ring/additive writes below otherwise ignore the per-node dim opacity.\n rippleAlphaSum *= vOpacity;\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 // \xD7 vOpacity: the max() must not resurrect alpha focusContext dimmed.\n gl_FragColor.a = max(gl_FragColor.a, falloff * vHalo * HALO_ALPHA * vOpacity);\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";
|
|
48426
48656
|
|
|
48427
48657
|
// src/shaders/edge.vert.glsl
|
|
48428
|
-
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// Fine-line coverage: |vSide| at which the desired (possibly sub-pixel) line\n// edge sits inside the min-width geometric strip. 1.0 = no thinning; <1 fades a\n// thin line's alpha so it stays a crisp hairline instead of shimmering/fattening.\nvarying float vCoreEdge;\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 // Short arcs (city-scale edges on a globe) are visually straight, and the\n // great-circle endpoint pullback degenerates for them: when a node's radius\n // is a large fraction of the tiny arc, the arc-fraction saturates (clamped)\n // and the edge/arrow stops well inside the node \u2014 visible as edges punching\n // through the bubble at deep map zoom (e.g. adjacent Tube stations). Only ride\n // the great-circle arc for arcs long enough to visibly curve (~1.1\xB0); shorter\n // ones fall through to the straight/curve branch, whose chord pullback reaches\n // the node surface correctly (no 0.49 clamp). MUST match arrow.vert.glsl.\n float arcOmega = acos(clamp(dot(normalize(srcPos), normalize(tgtPos)), -1.0, 1.0));\n bool isSphereEdge = sphereRadius > 0.001 && shape < 1.5 && bothOnSphere && arcOmega > 0.02;\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 // The node-radius gap (srcOffset/tgtOffset, a world-space radius) must be\n // applied as an ARC-LENGTH pullback along the great circle, NOT as a chord\n // subtraction. `normalize(tgtPos - edgeNorm * tgtOffset)` (the old form)\n // retreats the endpoint along the straight chord; for long edges the chord\n // dives through the globe interior, so re-normalizing barely changes the\n // angular position and the rendered arc \u2014 and the arrowhead mirroring it \u2014\n // collapse onto the node center instead of stopping one node-radius back\n // along the visible arc. Stepping each endpoint direction along the arc by\n // offset / sphereRadius radians keeps the gap a true on-surface distance,\n // so the edge/arrow meet the node boundary at every edge length and zoom.\n // MUST stay in sync with arrow.vert.glsl's isSphereArrow branch.\n vec3 dSrcRaw = normalize(srcPos);\n vec3 dTgtRaw = normalize(tgtPos);\n float omegaFull = acos(clamp(dot(dSrcRaw, dTgtRaw), -1.0, 1.0));\n // Pull each endpoint back along the arc by its node-radius worth of arc\n // length. Capping each fraction independently at 0.49 (the old form)\n // under-pulls the LARGER endpoint on short arcs \u2014 the pullback ends up far\n // less than the node radius, so the edge end lands INSIDE the node (visible\n // as edges punching through the bubble at deep map zoom). Instead cap the\n // COMBINED pullback at 0.98 of the arc and split it proportionally, so each\n // endpoint keeps as much of its full node-radius pullback as the arc allows\n // and the bigger node still wins its share. MUST stay in sync with\n // arrow.vert.glsl.\n //\n // Screen-foreshorten compensation: the node is a screen-facing billboard\n // (constant screen radius) but this pullback is a world arc-length along the\n // surface tangent. When that tangent dives toward the camera the pullback\n // projects to far fewer pixels than the node radius and the edge enters the\n // node disc (verified numerically: penetrating edges had foreshorten<0.6).\n // Scale each endpoint's pullback up by 1/foreshorten (clamped to 3.3x) so the\n // ON-SCREEN gap clears the node's screen radius; foreshorten==1 (tangent in\n // screen plane) leaves normal edges unchanged. MUST stay in sync with\n // arrow.vert.glsl.\n vec3 tanSrc = normalize(dTgtRaw - dot(dTgtRaw, dSrcRaw) * dSrcRaw);\n vec3 tanTgt = normalize(dSrcRaw - dot(dSrcRaw, dTgtRaw) * dTgtRaw);\n vec3 vDirSrc = normalize((modelViewMatrix * vec4(srcPos, 1.0)).xyz);\n vec3 vDirTgt = normalize((modelViewMatrix * vec4(tgtPos, 1.0)).xyz);\n vec3 tanSrcV = normalize((modelViewMatrix * vec4(tanSrc, 0.0)).xyz);\n vec3 tanTgtV = normalize((modelViewMatrix * vec4(tanTgt, 0.0)).xyz);\n float foreSrc = max(sqrt(max(0.0, 1.0 - pow(dot(tanSrcV, vDirSrc), 2.0))), 0.3);\n float foreTgt = max(sqrt(max(0.0, 1.0 - pow(dot(tanTgtV, vDirTgt), 2.0))), 0.3);\n float srcOffsetAdj = srcOffset / foreSrc;\n float tgtOffsetAdj = tgtOffset / foreTgt;\n float srcFracRaw = omegaFull > 1e-6 ? (srcOffsetAdj / sphereRadius) / omegaFull : 0.0;\n float tgtFracRaw = omegaFull > 1e-6 ? (tgtOffsetAdj / sphereRadius) / omegaFull : 0.0;\n float fracSum = srcFracRaw + tgtFracRaw;\n float fracK = fracSum > 0.98 ? 0.98 / fracSum : 1.0;\n float srcFrac = srcFracRaw * fracK;\n float tgtFrac = tgtFracRaw * fracK;\n dirSrcS = slerp(dSrcRaw, dTgtRaw, srcFrac);\n dirTgtS = slerp(dTgtRaw, dSrcRaw, tgtFrac);\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 // Fine-line anti-aliasing (the deck.gl / Mapbox technique). Do NOT fatten a\n // thin line to stop it shimmering \u2014 instead draw it at a minimum geometric\n // width so the strip always covers \u2265~1px (MSAA-safe, no sub-pixel drop-out),\n // then carry the *desired* width as a coverage fraction so the fragment shader\n // fades the strip's alpha to match. A 0.3px arc is drawn ~1px wide at 0.3\n // coverage, reading as a delicate hairline \u2014 neither shimmering (sub-pixel)\n // nor fat (a hard min-width clamp). The on-screen half-width of the current\n // `w` is `0.25 * w * resolution.y / pixelWidth` (clip\u2192NDC divide then NDC\u2192px).\n float desiredHalfPx = 0.25 * w * resolution.y / max(pixelWidth, 1e-6);\n float MIN_HALF_PX = 0.5;\n // Upper clamp mirrors node.vert.glsl's pixelSize cap. In the world-scaled\n // regime `w` is clip-space-constant, so the on-screen width (= w / clip.w)\n // grows without bound as the camera zooms in (clip.w -> 0). Nodes cap their\n // on-screen diameter at 4096px; edges previously had only the lower clamp, so\n // at deep zoom a handful of edges each ballooned to thousands of pixels and\n // washed the whole viewport a single solid color. Cap the half-width so one\n // edge can never flood the screen. Tunable: raise for fatter max edges.\n float MAX_HALF_PX = 64.0;\n float drawHalfPx = clamp(desiredHalfPx, MIN_HALF_PX, MAX_HALF_PX);\n vCoreEdge = clamp(desiredHalfPx / drawHalfPx, 0.0, 1.0); // 1 for thick, <1 fades sub-pixel\n w = drawHalfPx * 4.0 * pixelWidth / resolution.y; // round-trips to the original w when not thinning\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";
|
|
48658
|
+
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// Fine-line coverage: |vSide| at which the desired (possibly sub-pixel) line\n// edge sits inside the min-width geometric strip. 1.0 = no thinning; <1 fades a\n// thin line's alpha so it stays a crisp hairline instead of shimmering/fattening.\nvarying float vCoreEdge;\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 // Short arcs (city-scale edges on a globe) are visually straight, and the\n // great-circle endpoint pullback degenerates for them: when a node's radius\n // is a large fraction of the tiny arc, the arc-fraction saturates (clamped)\n // and the edge/arrow stops well inside the node \u2014 visible as edges punching\n // through the bubble at deep map zoom (e.g. adjacent Tube stations). Only ride\n // the great-circle arc for arcs long enough to visibly curve (~1.1\xB0); shorter\n // ones fall through to the straight/curve branch, whose chord pullback reaches\n // the node surface correctly (no 0.49 clamp). MUST match arrow.vert.glsl.\n float arcOmega = acos(clamp(dot(normalize(srcPos), normalize(tgtPos)), -1.0, 1.0));\n bool isSphereEdge = sphereRadius > 0.001 && shape < 1.5 && bothOnSphere && arcOmega > 0.02;\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 // The node-radius gap (srcOffset/tgtOffset, a world-space radius) must be\n // applied as an ARC-LENGTH pullback along the great circle, NOT as a chord\n // subtraction. `normalize(tgtPos - edgeNorm * tgtOffset)` (the old form)\n // retreats the endpoint along the straight chord; for long edges the chord\n // dives through the globe interior, so re-normalizing barely changes the\n // angular position and the rendered arc \u2014 and the arrowhead mirroring it \u2014\n // collapse onto the node center instead of stopping one node-radius back\n // along the visible arc. Stepping each endpoint direction along the arc by\n // offset / sphereRadius radians keeps the gap a true on-surface distance,\n // so the edge/arrow meet the node boundary at every edge length and zoom.\n // MUST stay in sync with arrow.vert.glsl's isSphereArrow branch.\n vec3 dSrcRaw = normalize(srcPos);\n vec3 dTgtRaw = normalize(tgtPos);\n float omegaFull = acos(clamp(dot(dSrcRaw, dTgtRaw), -1.0, 1.0));\n // Pull each endpoint back along the arc by its node-radius worth of arc\n // length. Capping each fraction independently at 0.49 (the old form)\n // under-pulls the LARGER endpoint on short arcs \u2014 the pullback ends up far\n // less than the node radius, so the edge end lands INSIDE the node (visible\n // as edges punching through the bubble at deep map zoom). Instead cap the\n // COMBINED pullback at 0.98 of the arc and split it proportionally, so each\n // endpoint keeps as much of its full node-radius pullback as the arc allows\n // and the bigger node still wins its share. MUST stay in sync with\n // arrow.vert.glsl.\n //\n // Screen-foreshorten compensation: the node is a screen-facing billboard\n // (constant screen radius) but this pullback is a world arc-length along the\n // surface tangent. When that tangent dives toward the camera the pullback\n // projects to far fewer pixels than the node radius and the edge enters the\n // node disc (verified numerically: penetrating edges had foreshorten<0.6).\n // Scale each endpoint's pullback up by 1/foreshorten (clamped to 3.3x) so the\n // ON-SCREEN gap clears the node's screen radius; foreshorten==1 (tangent in\n // screen plane) leaves normal edges unchanged. MUST stay in sync with\n // arrow.vert.glsl.\n vec3 tanSrc = normalize(dTgtRaw - dot(dTgtRaw, dSrcRaw) * dSrcRaw);\n vec3 tanTgt = normalize(dSrcRaw - dot(dSrcRaw, dTgtRaw) * dTgtRaw);\n vec3 vDirSrc = normalize((modelViewMatrix * vec4(srcPos, 1.0)).xyz);\n vec3 vDirTgt = normalize((modelViewMatrix * vec4(tgtPos, 1.0)).xyz);\n vec3 tanSrcV = normalize((modelViewMatrix * vec4(tanSrc, 0.0)).xyz);\n vec3 tanTgtV = normalize((modelViewMatrix * vec4(tanTgt, 0.0)).xyz);\n float foreSrc = max(sqrt(max(0.0, 1.0 - pow(dot(tanSrcV, vDirSrc), 2.0))), 0.3);\n float foreTgt = max(sqrt(max(0.0, 1.0 - pow(dot(tanTgtV, vDirTgt), 2.0))), 0.3);\n float srcOffsetAdj = srcOffset / foreSrc;\n float tgtOffsetAdj = tgtOffset / foreTgt;\n float srcFracRaw = omegaFull > 1e-6 ? (srcOffsetAdj / sphereRadius) / omegaFull : 0.0;\n float tgtFracRaw = omegaFull > 1e-6 ? (tgtOffsetAdj / sphereRadius) / omegaFull : 0.0;\n float fracSum = srcFracRaw + tgtFracRaw;\n float fracK = fracSum > 0.98 ? 0.98 / fracSum : 1.0;\n float srcFrac = srcFracRaw * fracK;\n float tgtFrac = tgtFracRaw * fracK;\n dirSrcS = slerp(dSrcRaw, dTgtRaw, srcFrac);\n dirTgtS = slerp(dTgtRaw, dSrcRaw, tgtFrac);\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 // Fine-line anti-aliasing (the deck.gl / Mapbox technique). Do NOT fatten a\n // thin line to stop it shimmering \u2014 instead draw it at a minimum geometric\n // width so the strip always covers \u2265~1px (MSAA-safe, no sub-pixel drop-out),\n // then carry the *desired* width as a coverage fraction so the fragment shader\n // fades the strip's alpha to match. A 0.3px arc is drawn ~1px wide at 0.3\n // coverage, reading as a delicate hairline \u2014 neither shimmering (sub-pixel)\n // nor fat (a hard min-width clamp). The on-screen half-width of the current\n // `w` is `0.25 * w * resolution.y / pixelWidth` (clip\u2192NDC divide then NDC\u2192px).\n float desiredHalfPx = 0.25 * w * resolution.y / max(pixelWidth, 1e-6);\n float MIN_HALF_PX = 0.5;\n float drawHalfPx = max(desiredHalfPx, MIN_HALF_PX);\n vCoreEdge = clamp(desiredHalfPx / drawHalfPx, 0.0, 1.0); // 1 for thick, <1 fades sub-pixel\n w = drawHalfPx * 4.0 * pixelWidth / resolution.y; // round-trips to the original w when not thinning\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";
|
|
48429
48659
|
|
|
48430
48660
|
// src/shaders/edge.frag.glsl
|
|
48431
48661
|
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// Flow particles (EdgeFlowEffect): global speed multiplier (1.0 = base\n// 0.8 counters/sec) and particle color. Synced from edgeState by the renderer.\nuniform float flowSpeed;\nuniform vec3 flowColor;\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;\nvarying float vCoreEdge;\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 // Coverage-based anti-aliasing for crisp, fine hairlines. `vCoreEdge` is the\n // |vSide| where the desired line edge sits inside the min-width geometric\n // strip (1.0 for normal lines; <1 when the vertex shader widened a sub-pixel\n // line and asked us to fade it back). The fade spans ~1px (fwidth) centred on\n // that edge, so a thin line resolves to a smooth, delicate stroke instead of\n // a shimmering sub-pixel ribbon or a fattened band. Skipped when tube-glow\n // owns the border region (it has its own soft falloff).\n if (vTubeGlow <= 0.0) {\n float aa = fwidth(vSide);\n float edgeAA = 1.0 - smoothstep(vCoreEdge - aa, vCoreEdge + aa, abs(vSide));\n gl_FragColor.a *= edgeAA;\n }\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 // Effect dim factor: the alpha-raising effects below (flow, glow stream)\n // use max() against the base alpha, which would otherwise RESURRECT\n // fragments that were dimmed or hidden upstream. They must respect:\n // - vOpacity: focusContext / per-edge dim (also 0 on the globe's far\n // side \u2014 the vertex shader culls back-facing edges via vOpacity = 0,\n // so this is what keeps particles from shining through the planet);\n // - step(vCounters, visibility): the edgeDraw reveal front.\n float effectDim = vOpacity * step(vCounters, visibility);\n\n // Flow particles: dots moving along edge. flowSpeed/flowColor come from\n // EdgeFlowConfig via the renderer uniforms (1.0 = base 0.8 counters/sec).\n if (vFlow > 0.0) {\n float gap = 0.08;\n float dotSize = 0.015;\n float phase = mod(vCounters - time * 0.8 * flowSpeed, gap);\n float dist = abs(phase - gap * 0.5) / dotSize;\n if (dist < 1.0) {\n float flowGlow = (1.0 - dist * dist) * vFlow * effectDim;\n gl_FragColor.rgb = mix(gl_FragColor.rgb, flowColor, 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 * effectDim;\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 // \xD7 vOpacity: preA is only a binary gate; the additive halo must dim\n // with the edge under focusContext, not just vanish at preA == 0.\n glowAdd = vColor.rgb * falloff * GLOW_GAIN * step(0.0001, preA) * vOpacity;\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";
|
|
@@ -48588,6 +48818,12 @@ void main() {
|
|
|
48588
48818
|
// src/shaders/marker-trail.frag.glsl
|
|
48589
48819
|
var marker_trail_frag_default = 'precision highp float;\n\n// Comet-trail fragment: alpha fades quadratically toward the tail and softly\n// across the ribbon edges; color runs white-hot at the head into the marker\n// tint \u2014 the classic threat-map "meteor streak".\n\nvarying float vT;\nvarying float vSide;\nvarying vec3 vColor;\nvarying float vOpacity;\n\nvoid main() {\n float along = (1.0 - vT) * (1.0 - vT); // 1 at head \u2192 0 at tail tip\n float across = 1.0 - vSide * vSide; // soft ribbon edges\n float a = along * across * vOpacity;\n if (a < 0.01) discard;\n vec3 col = mix(vec3(1.0), vColor, smoothstep(0.0, 0.3, vT));\n gl_FragColor = vec4(col, a);\n}\n';
|
|
48590
48820
|
|
|
48821
|
+
// src/shaders/coverage.vert.glsl
|
|
48822
|
+
var coverage_vert_default = "attribute vec3 aCenter;\nattribute float aRadius;\nattribute vec3 aColor;\nattribute float aFillOpacity;\nattribute float aFalloff;\nattribute vec3 aRingColor;\nattribute float aRingWidth;\nattribute float aRingOpacity; // boundary-ring opacity, independent of fillOpacity\nattribute vec3 aPulse; // x=flag, y=speed, z=rings\nattribute float aDim; // anchor node render opacity (focus / click-dim); 1 = full\nattribute float aSelected; // 1 when the anchor node is selected\nvarying vec2 vLocal; // [-1,1]; length 1 at the circle edge\nvarying vec3 vColor; varying float vFill; varying float vFalloff;\nvarying vec3 vRingColor; varying float vRingWidth; varying vec3 vPulse;\nvarying float vRingOpacity;\nvarying float vDim;\nvarying float vSelected;\nvoid main() {\n vLocal = position.xy * 2.0; // position.xy in [-0.5,0.5]\n vColor = aColor; vFill = aFillOpacity; vFalloff = aFalloff;\n vRingColor = aRingColor; vRingWidth = aRingWidth; vPulse = aPulse;\n vRingOpacity = aRingOpacity;\n vDim = aDim;\n vSelected = aSelected;\n vec3 world = aCenter + vec3(position.xy * 2.0 * aRadius, 0.0); // flat disc in cloudScene XY\n gl_Position = projectionMatrix * modelViewMatrix * vec4(world, 1.0);\n}\n";
|
|
48823
|
+
|
|
48824
|
+
// src/shaders/coverage.frag.glsl
|
|
48825
|
+
var coverage_frag_default = "precision highp float;\nuniform float uTime;\nuniform vec3 uSelectedColor; // colour of the selection marker (dashed radius spoke; default white)\nvarying vec2 vLocal;\nvarying vec3 vColor; varying float vFill; varying float vFalloff;\nvarying vec3 vRingColor; varying float vRingWidth; varying vec3 vPulse;\nvarying float vRingOpacity;\nvarying float vDim;\nvarying float vSelected; // 1 when the anchor node is selected\nvoid main() {\n float d = length(vLocal);\n if (d > 1.0) discard;\n bool sel = vSelected > 0.5;\n // radial signal falloff shape (strong center -> weak edge), 0..1\n float fill = pow(1.0 - clamp(d, 0.0, 1.0), max(vFalloff, 0.0));\n // boundary ring shape near d == 1, 0..1.\n float ring = (vRingWidth > 0.0) ? (1.0 - smoothstep(0.0, vRingWidth, abs(d - 1.0))) : 0.0;\n // optional expanding pulse rings (radar ping), bounded by the real radius\n float pulse = 0.0;\n if (vPulse.x > 0.5) {\n float rings = max(vPulse.z, 1.0);\n // Fixed bound <4 keeps this WebGL2-portable; variable `break` is safe under GLSL ES 3.00 (WebGL2 context).\n for (int i = 0; i < 4; i++) {\n if (float(i) >= rings) break;\n float phase = fract(d - uTime * vPulse.y - float(i) / rings);\n pulse += (1.0 - phase) * (1.0 - d) * 0.5;\n }\n }\n // A selected disc stays un-dimmed so it remains prominent while its\n // focus-dimmed neighbours fade (click-to-isolate). Its boundary keeps its own\n // colour/opacity \u2014 the selection is marked by a dashed RADIUS SPOKE (below).\n float dim = sel ? 1.0 : vDim;\n vec3 col = mix(vColor, vRingColor, ring);\n // fillOpacity (vFill) scales ONLY the interior fill and the radar pulse, so you\n // can fade the fill to let the basemap show through. The boundary ring has its\n // OWN opacity (vRingOpacity) and is unaffected by fillOpacity \u2014 it stays crisp.\n // Then * dim so a disc fades with its node under focus / click-dim.\n float alpha = clamp(max(vFill * fill, vRingOpacity * ring) + vFill * pulse, 0.0, 1.0) * dim;\n\n // Selection marker: a dashed RADIUS spoke from the centre (d=0) out to the +X\n // edge (d=1), drawn in uSelectedColor \u2014 replaces the old solid white ring and\n // reads as a literal radius line annotating the coverage reach.\n if (sel) {\n const float halfThick = 0.008; // spoke half-width in local units (fraction of radius)\n const float dashFreq = 7.0; // ~7 dashes from centre to edge\n float onAxis = 1.0 - smoothstep(halfThick * 0.5, halfThick, abs(vLocal.y));\n float onSide = step(0.0, vLocal.x); // +X half only (centre -> right edge)\n float dash = step(fract(d * dashFreq), 0.55); // alternating dash/gap along the radius\n float spoke = onAxis * onSide * dash;\n if (spoke > 0.0) {\n col = mix(col, uSelectedColor, spoke);\n alpha = max(alpha, spoke); // spoke at full opacity (sel => dim == 1)\n }\n }\n\n if (alpha <= 0.0) discard;\n gl_FragColor = vec4(col, alpha);\n}\n";
|
|
48826
|
+
|
|
48591
48827
|
// src/shaders/index.ts
|
|
48592
48828
|
var nodeVertexShader = node_vert_default;
|
|
48593
48829
|
var nodeFragmentShader = node_frag_default;
|
|
@@ -48603,6 +48839,8 @@ void main() {
|
|
|
48603
48839
|
var markerFragmentShader = marker_frag_default;
|
|
48604
48840
|
var markerTrailVertexShader = marker_trail_vert_default;
|
|
48605
48841
|
var markerTrailFragmentShader = marker_trail_frag_default;
|
|
48842
|
+
var coverageVertexShader = coverage_vert_default;
|
|
48843
|
+
var coverageFragmentShader = coverage_frag_default;
|
|
48606
48844
|
|
|
48607
48845
|
// src/utils/hoverDimTimestamp.ts
|
|
48608
48846
|
function easeInOutCubic(t) {
|
|
@@ -48799,6 +49037,7 @@ void main() {
|
|
|
48799
49037
|
this.geometry.setAttribute("nodeIconUV", new InstancedBufferAttribute(state.iconUVs, 4));
|
|
48800
49038
|
this.geometry.setAttribute("nodeImageUV", new InstancedBufferAttribute(state.imageUVs, 4));
|
|
48801
49039
|
this.geometry.setAttribute("aNodeCollect", new InstancedBufferAttribute(state.collection, 1));
|
|
49040
|
+
this.geometry.setAttribute("nodeSuppressFill", new InstancedBufferAttribute(state.suppressFill, 1));
|
|
48802
49041
|
const nodeFlagsArr = new Float32Array(capacity);
|
|
48803
49042
|
for (let i = 0; i < capacity; i++) {
|
|
48804
49043
|
nodeFlagsArr[i] = (state.selected[i] > 0 ? 1 : 0) + (state.highlighted[i] > 0 ? 2 : 0) + (state.pinned[i] > 0 ? 4 : 0) + (state.hidden[i] > 0 ? 8 : 0);
|
|
@@ -48823,6 +49062,7 @@ void main() {
|
|
|
48823
49062
|
this.geometry.setAttribute("nodeIconUV", new InstancedBufferAttribute(new Float32Array(capacity * 4).fill(-1), 4));
|
|
48824
49063
|
this.geometry.setAttribute("nodeImageUV", new InstancedBufferAttribute(new Float32Array(capacity * 4).fill(-1), 4));
|
|
48825
49064
|
this.geometry.setAttribute("aNodeCollect", new InstancedBufferAttribute(new Float32Array(capacity), 1));
|
|
49065
|
+
this.geometry.setAttribute("nodeSuppressFill", new InstancedBufferAttribute(new Float32Array(capacity), 1));
|
|
48826
49066
|
this.geometry.setAttribute("nodeFlags", new InstancedBufferAttribute(new Float32Array(capacity), 1));
|
|
48827
49067
|
this.geometry.setAttribute("nodeEffects", new InstancedBufferAttribute(new Float32Array(capacity * 3), 3));
|
|
48828
49068
|
}
|
|
@@ -49046,6 +49286,7 @@ void main() {
|
|
|
49046
49286
|
// Packed into nodeFlags
|
|
49047
49287
|
nodeRingColors: "nodeRingColor",
|
|
49048
49288
|
nodeCollection: "aNodeCollect",
|
|
49289
|
+
nodeSuppressFill: "nodeSuppressFill",
|
|
49049
49290
|
nodeRipple: null,
|
|
49050
49291
|
// Packed into nodeEffects.x
|
|
49051
49292
|
nodeBreathe: null,
|
|
@@ -51350,7 +51591,7 @@ void main() {
|
|
|
51350
51591
|
};
|
|
51351
51592
|
|
|
51352
51593
|
// src/react/GraphContext.tsx
|
|
51353
|
-
var
|
|
51594
|
+
var import_react52 = __toESM(require_react());
|
|
51354
51595
|
|
|
51355
51596
|
// src/interaction/types.ts
|
|
51356
51597
|
var DEFAULT_INTERACTION_CONFIG = {
|
|
@@ -58632,6 +58873,74 @@ void main() {
|
|
|
58632
58873
|
return v < lo ? lo : v > hi ? hi : v;
|
|
58633
58874
|
}
|
|
58634
58875
|
|
|
58876
|
+
// src/react/layers/EngineLayerHost.ts
|
|
58877
|
+
function mountEngineLayer(host, name, factory, config, opts) {
|
|
58878
|
+
const renderer = factory();
|
|
58879
|
+
const getDrawingBufferSize = () => {
|
|
58880
|
+
const v = new Vector2();
|
|
58881
|
+
host.getRenderer()?.getDrawingBufferSize(v);
|
|
58882
|
+
return { width: v.x || 1, height: v.y || 1 };
|
|
58883
|
+
};
|
|
58884
|
+
const ctx = {
|
|
58885
|
+
cloudScene: host.cloudScene,
|
|
58886
|
+
camera: host.camera,
|
|
58887
|
+
store: host.store,
|
|
58888
|
+
iconAtlasManager: host.iconAtlasManager,
|
|
58889
|
+
invalidate: host.invalidate,
|
|
58890
|
+
isMapMode: host.isMapMode(),
|
|
58891
|
+
sphereRadius: host.mapSphereRadius(),
|
|
58892
|
+
renderOrder: renderOrderForSlot,
|
|
58893
|
+
getDrawingBufferSize,
|
|
58894
|
+
getEdgeOpacity: (edgeId) => {
|
|
58895
|
+
const idx = host.store.index.getEdgeIndex(edgeId);
|
|
58896
|
+
const op = host.store.edgeState?.opacities;
|
|
58897
|
+
return idx !== void 0 && op ? op[idx] : 1;
|
|
58898
|
+
},
|
|
58899
|
+
getNodeOpacity: (nodeId) => {
|
|
58900
|
+
const idx = host.store.index.getNodeIndex?.(nodeId);
|
|
58901
|
+
const op = host.store.nodeState?.opacities;
|
|
58902
|
+
return idx !== void 0 && idx >= 0 && op ? op[idx] : 1;
|
|
58903
|
+
}
|
|
58904
|
+
};
|
|
58905
|
+
renderer.mount(ctx);
|
|
58906
|
+
renderer.update?.(config);
|
|
58907
|
+
host.invalidate();
|
|
58908
|
+
let rafId = 0;
|
|
58909
|
+
let disposed = false;
|
|
58910
|
+
if (opts?.frame === true) {
|
|
58911
|
+
let last = performance.now();
|
|
58912
|
+
const pump = () => {
|
|
58913
|
+
if (disposed) return;
|
|
58914
|
+
const now2 = performance.now();
|
|
58915
|
+
const dt = (now2 - last) / 1e3;
|
|
58916
|
+
last = now2;
|
|
58917
|
+
const req = renderer.frame?.(dt, ctx);
|
|
58918
|
+
if (req) host.invalidate();
|
|
58919
|
+
rafId = requestAnimationFrame(pump);
|
|
58920
|
+
};
|
|
58921
|
+
rafId = requestAnimationFrame(pump);
|
|
58922
|
+
}
|
|
58923
|
+
host.registerMapModeCallback(name, (enabled, sphereRadius = 0) => {
|
|
58924
|
+
ctx.sphereRadius = sphereRadius;
|
|
58925
|
+
ctx.isMapMode = enabled;
|
|
58926
|
+
renderer.onMapMode?.(enabled, sphereRadius);
|
|
58927
|
+
host.invalidate();
|
|
58928
|
+
});
|
|
58929
|
+
return {
|
|
58930
|
+
update(next) {
|
|
58931
|
+
renderer.update?.(next);
|
|
58932
|
+
host.invalidate();
|
|
58933
|
+
},
|
|
58934
|
+
dispose() {
|
|
58935
|
+
disposed = true;
|
|
58936
|
+
if (rafId) cancelAnimationFrame(rafId);
|
|
58937
|
+
host.registerMapModeCallback(name, null);
|
|
58938
|
+
renderer.dispose();
|
|
58939
|
+
host.invalidate();
|
|
58940
|
+
}
|
|
58941
|
+
};
|
|
58942
|
+
}
|
|
58943
|
+
|
|
58635
58944
|
// src/react/hooks/useLayer.ts
|
|
58636
58945
|
function useEngineLayer(name, factory, config, deps, opts) {
|
|
58637
58946
|
const {
|
|
@@ -58647,83 +58956,28 @@ void main() {
|
|
|
58647
58956
|
const { iconAtlasManager } = useAtlasManagers();
|
|
58648
58957
|
const rendererRef2 = (0, import_react13.useRef)(null);
|
|
58649
58958
|
rendererRef2.current = renderer;
|
|
58650
|
-
const
|
|
58651
|
-
const v = new Vector2();
|
|
58652
|
-
rendererRef2.current?.getDrawingBufferSize(v);
|
|
58653
|
-
return { width: v.x || 1, height: v.y || 1 };
|
|
58654
|
-
}).current;
|
|
58655
|
-
const rendererRef = (0, import_react13.useRef)(null);
|
|
58656
|
-
const ctxRef = (0, import_react13.useRef)(null);
|
|
58657
|
-
const lastFrameRef = (0, import_react13.useRef)(0);
|
|
58658
|
-
const wantsFrame = opts?.frame === true;
|
|
58959
|
+
const mountedRef = (0, import_react13.useRef)(null);
|
|
58659
58960
|
(0, import_react13.useEffect)(() => {
|
|
58660
|
-
const
|
|
58661
|
-
rendererRef.current = renderer2;
|
|
58662
|
-
const ctx = {
|
|
58961
|
+
const host = {
|
|
58663
58962
|
cloudScene,
|
|
58664
58963
|
camera,
|
|
58964
|
+
getRenderer: () => rendererRef2.current,
|
|
58665
58965
|
store,
|
|
58666
|
-
iconAtlasManager,
|
|
58667
58966
|
invalidate,
|
|
58668
|
-
|
|
58669
|
-
|
|
58670
|
-
|
|
58671
|
-
|
|
58672
|
-
getEdgeOpacity: (edgeId) => {
|
|
58673
|
-
const idx = store.index.getEdgeIndex(edgeId);
|
|
58674
|
-
const op = store.edgeState?.opacities;
|
|
58675
|
-
return idx !== void 0 && op ? op[idx] : 1;
|
|
58676
|
-
},
|
|
58677
|
-
getNodeOpacity: (nodeId) => {
|
|
58678
|
-
const idx = store.index.getNodeIndex?.(nodeId);
|
|
58679
|
-
const op = store.nodeState?.opacities;
|
|
58680
|
-
return idx !== void 0 && idx >= 0 && op ? op[idx] : 1;
|
|
58681
|
-
}
|
|
58967
|
+
registerMapModeCallback,
|
|
58968
|
+
iconAtlasManager,
|
|
58969
|
+
isMapMode: () => isMapMode,
|
|
58970
|
+
mapSphereRadius: () => mapSphereRadius
|
|
58682
58971
|
};
|
|
58683
|
-
|
|
58684
|
-
|
|
58685
|
-
invalidate();
|
|
58686
|
-
let rafId = 0;
|
|
58687
|
-
if (wantsFrame) {
|
|
58688
|
-
lastFrameRef.current = performance.now();
|
|
58689
|
-
const pump = () => {
|
|
58690
|
-
const liveCtx = ctxRef.current;
|
|
58691
|
-
const liveRenderer = rendererRef.current;
|
|
58692
|
-
if (liveCtx && liveRenderer) {
|
|
58693
|
-
const now2 = performance.now();
|
|
58694
|
-
const dtSeconds = (now2 - lastFrameRef.current) / 1e3;
|
|
58695
|
-
lastFrameRef.current = now2;
|
|
58696
|
-
const req = liveRenderer.frame?.(dtSeconds, liveCtx);
|
|
58697
|
-
if (req) invalidate();
|
|
58698
|
-
}
|
|
58699
|
-
rafId = requestAnimationFrame(pump);
|
|
58700
|
-
};
|
|
58701
|
-
rafId = requestAnimationFrame(pump);
|
|
58702
|
-
}
|
|
58703
|
-
registerMapModeCallback(name, (enabled, sphereRadius = 0) => {
|
|
58704
|
-
const liveCtx = ctxRef.current;
|
|
58705
|
-
if (liveCtx) {
|
|
58706
|
-
liveCtx.sphereRadius = sphereRadius;
|
|
58707
|
-
liveCtx.isMapMode = enabled;
|
|
58708
|
-
}
|
|
58709
|
-
rendererRef.current?.onMapMode?.(enabled, sphereRadius);
|
|
58710
|
-
invalidate();
|
|
58711
|
-
});
|
|
58972
|
+
const mounted = mountEngineLayer(host, name, factory, config, opts);
|
|
58973
|
+
mountedRef.current = mounted;
|
|
58712
58974
|
return () => {
|
|
58713
|
-
|
|
58714
|
-
|
|
58715
|
-
rendererRef.current?.dispose();
|
|
58716
|
-
rendererRef.current = null;
|
|
58717
|
-
ctxRef.current = null;
|
|
58718
|
-
invalidate();
|
|
58975
|
+
mounted.dispose();
|
|
58976
|
+
mountedRef.current = null;
|
|
58719
58977
|
};
|
|
58720
58978
|
}, [name, cloudScene, camera, store, ...deps]);
|
|
58721
58979
|
(0, import_react13.useEffect)(() => {
|
|
58722
|
-
|
|
58723
|
-
if (renderer2) {
|
|
58724
|
-
renderer2.update?.(config);
|
|
58725
|
-
invalidate();
|
|
58726
|
-
}
|
|
58980
|
+
mountedRef.current?.update(config);
|
|
58727
58981
|
}, [config]);
|
|
58728
58982
|
}
|
|
58729
58983
|
|
|
@@ -58782,11 +59036,37 @@ void main() {
|
|
|
58782
59036
|
return null;
|
|
58783
59037
|
}
|
|
58784
59038
|
|
|
59039
|
+
// src/react/layers/LayerHost.tsx
|
|
59040
|
+
var import_react16 = __toESM(require_react());
|
|
59041
|
+
function LayerHost() {
|
|
59042
|
+
const api = useRenderEngineApi();
|
|
59043
|
+
const { store, cloudScene, camera, renderer, invalidate, registerMapModeCallback } = useGraphHandle();
|
|
59044
|
+
const { iconAtlasManager } = useAtlasManagers();
|
|
59045
|
+
const isMapMode = useIsMapMode();
|
|
59046
|
+
const mapSphereRadius = useMapSphereRadius();
|
|
59047
|
+
(0, import_react16.useEffect)(() => {
|
|
59048
|
+
const host = {
|
|
59049
|
+
cloudScene,
|
|
59050
|
+
camera,
|
|
59051
|
+
getRenderer: () => renderer,
|
|
59052
|
+
store,
|
|
59053
|
+
invalidate,
|
|
59054
|
+
registerMapModeCallback,
|
|
59055
|
+
iconAtlasManager,
|
|
59056
|
+
isMapMode: () => isMapMode,
|
|
59057
|
+
mapSphereRadius: () => mapSphereRadius
|
|
59058
|
+
};
|
|
59059
|
+
api.layers._wireHost(host);
|
|
59060
|
+
return () => api.layers._wireHost(null);
|
|
59061
|
+
}, [api, store, cloudScene, camera, renderer]);
|
|
59062
|
+
return null;
|
|
59063
|
+
}
|
|
59064
|
+
|
|
58785
59065
|
// src/react/layers/FlatLayer.tsx
|
|
58786
|
-
var
|
|
59066
|
+
var import_react18 = __toESM(require_react());
|
|
58787
59067
|
|
|
58788
59068
|
// src/react/components/PitchToggleButton.tsx
|
|
58789
|
-
var
|
|
59069
|
+
var import_react17 = __toESM(require_react());
|
|
58790
59070
|
var import_react_dom = __toESM(require_react_dom());
|
|
58791
59071
|
var import_jsx_runtime7 = __toESM(require_jsx_runtime());
|
|
58792
59072
|
function PitchToggleButton({
|
|
@@ -58795,8 +59075,8 @@ void main() {
|
|
|
58795
59075
|
durationMs = 400
|
|
58796
59076
|
}) {
|
|
58797
59077
|
const api = useOptionalRenderEngineApi();
|
|
58798
|
-
const [pitch, setPitchState] = (0,
|
|
58799
|
-
(0,
|
|
59078
|
+
const [pitch, setPitchState] = (0, import_react17.useState)(() => api?.map.getPitch() ?? 0);
|
|
59079
|
+
(0, import_react17.useEffect)(() => {
|
|
58800
59080
|
if (!api) return;
|
|
58801
59081
|
const off = api.events.on(
|
|
58802
59082
|
"map:pitchChanged",
|
|
@@ -59063,8 +59343,8 @@ void main() {
|
|
|
59063
59343
|
const { cloudScene, camera, control, invalidate, registerFrameCallback, setMapMode, interaction, container } = useGraphHandle();
|
|
59064
59344
|
const { is3D } = useIs3D();
|
|
59065
59345
|
const api = useOptionalRenderEngineApi();
|
|
59066
|
-
const flatRef = (0,
|
|
59067
|
-
(0,
|
|
59346
|
+
const flatRef = (0, import_react18.useRef)(null);
|
|
59347
|
+
(0, import_react18.useEffect)(() => {
|
|
59068
59348
|
const resolvedTileUrl = tileProvider ? MapTileProviders[tileProvider] : tileUrl ?? DEFAULT_TILE_URL;
|
|
59069
59349
|
const config = { tileUrl: resolvedTileUrl, minLevel, maxLevel };
|
|
59070
59350
|
const flat = new SlippyMapFlat(mapSize, config);
|
|
@@ -59107,7 +59387,7 @@ void main() {
|
|
|
59107
59387
|
api?.map?.disableMap(swapToken !== null ? { swapToken } : void 0);
|
|
59108
59388
|
};
|
|
59109
59389
|
}, [mapSize, tileUrl, tileProvider, minLevel, maxLevel]);
|
|
59110
|
-
(0,
|
|
59390
|
+
(0, import_react18.useEffect)(() => {
|
|
59111
59391
|
if (!control) return;
|
|
59112
59392
|
const prevRange = control.getZoomRange();
|
|
59113
59393
|
const zoomMax2D = camera.position.z - 1e-4;
|
|
@@ -59126,7 +59406,7 @@ void main() {
|
|
|
59126
59406
|
control.setWheelIdleSnap(null);
|
|
59127
59407
|
};
|
|
59128
59408
|
}, [control, camera, mapSize]);
|
|
59129
|
-
(0,
|
|
59409
|
+
(0, import_react18.useEffect)(() => {
|
|
59130
59410
|
if (flatRef.current) {
|
|
59131
59411
|
flatRef.current.visible = visible;
|
|
59132
59412
|
invalidate();
|
|
@@ -59137,7 +59417,7 @@ void main() {
|
|
|
59137
59417
|
}
|
|
59138
59418
|
|
|
59139
59419
|
// src/react/layers/GlobeLayer.tsx
|
|
59140
|
-
var
|
|
59420
|
+
var import_react19 = __toESM(require_react());
|
|
59141
59421
|
|
|
59142
59422
|
// src/map/geo-map/SlippyMapGlobe.ts
|
|
59143
59423
|
var MAX_LEVEL_TO_RENDER_ALL_TILES = 6;
|
|
@@ -59894,10 +60174,10 @@ void main() {
|
|
|
59894
60174
|
}) {
|
|
59895
60175
|
const { scene, cloudScene, camera, container, invalidate, registerFrameCallback, setMapMode, setMapDamping, store, interaction, control: graphControl } = useGraphHandle();
|
|
59896
60176
|
const api = useOptionalRenderEngineApi();
|
|
59897
|
-
const globeRef = (0,
|
|
59898
|
-
const controlRef = (0,
|
|
60177
|
+
const globeRef = (0, import_react19.useRef)(null);
|
|
60178
|
+
const controlRef = (0, import_react19.useRef)(null);
|
|
59899
60179
|
const resolvedTileUrl = tileProvider ? MapTileProviders[tileProvider] : tileUrl ?? DEFAULT_TILE_URL2;
|
|
59900
|
-
(0,
|
|
60180
|
+
(0, import_react19.useEffect)(() => {
|
|
59901
60181
|
const savedPosition = cloudScene.position.clone();
|
|
59902
60182
|
const savedQuaternion = cloudScene.quaternion.clone();
|
|
59903
60183
|
const globe = new SlippyMapGlobe(radius, {
|
|
@@ -59986,19 +60266,19 @@ void main() {
|
|
|
59986
60266
|
invalidate();
|
|
59987
60267
|
};
|
|
59988
60268
|
}, [radius, minLevel, maxLevel, mercatorProjection]);
|
|
59989
|
-
(0,
|
|
60269
|
+
(0, import_react19.useEffect)(() => {
|
|
59990
60270
|
if (globeRef.current) {
|
|
59991
60271
|
globeRef.current.switchTileUrl(resolvedTileUrl);
|
|
59992
60272
|
invalidate();
|
|
59993
60273
|
}
|
|
59994
60274
|
}, [resolvedTileUrl]);
|
|
59995
|
-
(0,
|
|
60275
|
+
(0, import_react19.useEffect)(() => {
|
|
59996
60276
|
if (globeRef.current) {
|
|
59997
60277
|
globeRef.current.visible = visible;
|
|
59998
60278
|
invalidate();
|
|
59999
60279
|
}
|
|
60000
60280
|
}, [visible, invalidate]);
|
|
60001
|
-
(0,
|
|
60281
|
+
(0, import_react19.useEffect)(() => {
|
|
60002
60282
|
if (globeRef.current) {
|
|
60003
60283
|
globeRef.current.setAtmosphere({ enabled: atmosphere, color: atmosphereColor });
|
|
60004
60284
|
invalidate();
|
|
@@ -60009,10 +60289,10 @@ void main() {
|
|
|
60009
60289
|
}
|
|
60010
60290
|
|
|
60011
60291
|
// src/react/toolbar/ToolbarAutoMount.tsx
|
|
60012
|
-
var
|
|
60292
|
+
var import_react35 = __toESM(require_react());
|
|
60013
60293
|
|
|
60014
60294
|
// src/react/toolbar/Toolbar.tsx
|
|
60015
|
-
var
|
|
60295
|
+
var import_react33 = __toESM(require_react());
|
|
60016
60296
|
|
|
60017
60297
|
// ../node_modules/@radix-ui/react-tooltip/dist/index.mjs
|
|
60018
60298
|
var React30 = __toESM(require_react(), 1);
|
|
@@ -62149,12 +62429,12 @@ void main() {
|
|
|
62149
62429
|
|
|
62150
62430
|
// ../node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
|
|
62151
62431
|
var React19 = __toESM(require_react(), 1);
|
|
62152
|
-
var
|
|
62432
|
+
var import_react20 = __toESM(require_react(), 1);
|
|
62153
62433
|
var ReactDOM2 = __toESM(require_react_dom(), 1);
|
|
62154
62434
|
var isClient = typeof document !== "undefined";
|
|
62155
62435
|
var noop2 = function noop3() {
|
|
62156
62436
|
};
|
|
62157
|
-
var index2 = isClient ?
|
|
62437
|
+
var index2 = isClient ? import_react20.useLayoutEffect : noop2;
|
|
62158
62438
|
function deepEqual(a2, b) {
|
|
62159
62439
|
if (a2 === b) {
|
|
62160
62440
|
return true;
|
|
@@ -63517,7 +63797,7 @@ void main() {
|
|
|
63517
63797
|
var Arrow22 = TooltipArrow;
|
|
63518
63798
|
|
|
63519
63799
|
// src/react/toolbar/docks/FloatingDock.tsx
|
|
63520
|
-
var
|
|
63800
|
+
var import_react28 = __toESM(require_react());
|
|
63521
63801
|
|
|
63522
63802
|
// ../node_modules/clsx/dist/clsx.mjs
|
|
63523
63803
|
function r(e) {
|
|
@@ -63536,9 +63816,9 @@ void main() {
|
|
|
63536
63816
|
var clsx_default = clsx;
|
|
63537
63817
|
|
|
63538
63818
|
// src/react/toolbar/items/ToolItem.tsx
|
|
63539
|
-
var
|
|
63819
|
+
var import_react21 = __toESM(require_react());
|
|
63540
63820
|
var import_jsx_runtime19 = __toESM(require_jsx_runtime());
|
|
63541
|
-
var ToolItem =
|
|
63821
|
+
var ToolItem = import_react21.default.forwardRef(function ToolItem2({ item, ctx, onInvoke }, ref) {
|
|
63542
63822
|
if (item.kind === "separator") {
|
|
63543
63823
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "rx-tool-separator", role: "separator" });
|
|
63544
63824
|
}
|
|
@@ -63576,7 +63856,7 @@ void main() {
|
|
|
63576
63856
|
});
|
|
63577
63857
|
|
|
63578
63858
|
// src/react/toolbar/items/OverflowMenu.tsx
|
|
63579
|
-
var
|
|
63859
|
+
var import_react23 = __toESM(require_react());
|
|
63580
63860
|
|
|
63581
63861
|
// ../node_modules/@radix-ui/react-popover/dist/index.mjs
|
|
63582
63862
|
var React42 = __toESM(require_react(), 1);
|
|
@@ -64001,9 +64281,9 @@ void main() {
|
|
|
64001
64281
|
}
|
|
64002
64282
|
|
|
64003
64283
|
// ../node_modules/use-callback-ref/dist/es2015/useRef.js
|
|
64004
|
-
var
|
|
64284
|
+
var import_react22 = __toESM(require_react());
|
|
64005
64285
|
function useCallbackRef5(initialValue, callback) {
|
|
64006
|
-
var ref = (0,
|
|
64286
|
+
var ref = (0, import_react22.useState)(function() {
|
|
64007
64287
|
return {
|
|
64008
64288
|
// value
|
|
64009
64289
|
value: initialValue,
|
|
@@ -64950,7 +65230,7 @@ void main() {
|
|
|
64950
65230
|
// src/react/toolbar/items/OverflowMenu.tsx
|
|
64951
65231
|
var import_jsx_runtime22 = __toESM(require_jsx_runtime());
|
|
64952
65232
|
function OverflowMenu({ items, ctx, onInvoke, orientation }) {
|
|
64953
|
-
const [open, setOpen] = (0,
|
|
65233
|
+
const [open, setOpen] = (0, import_react23.useState)(false);
|
|
64954
65234
|
if (items.length === 0) return null;
|
|
64955
65235
|
const handleItemInvoke = (item) => {
|
|
64956
65236
|
onInvoke(item);
|
|
@@ -64981,9 +65261,9 @@ void main() {
|
|
|
64981
65261
|
}
|
|
64982
65262
|
|
|
64983
65263
|
// src/react/toolbar/docks/DockDragHandle.tsx
|
|
64984
|
-
var
|
|
65264
|
+
var import_react24 = __toESM(require_react());
|
|
64985
65265
|
var import_jsx_runtime23 = __toESM(require_jsx_runtime());
|
|
64986
|
-
var DockDragHandle =
|
|
65266
|
+
var DockDragHandle = import_react24.default.forwardRef(
|
|
64987
65267
|
function DockDragHandle2({ orientation }, ref) {
|
|
64988
65268
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
64989
65269
|
"div",
|
|
@@ -65017,10 +65297,10 @@ void main() {
|
|
|
65017
65297
|
}
|
|
65018
65298
|
|
|
65019
65299
|
// src/react/toolbar/popover/ToolPopover.tsx
|
|
65020
|
-
var
|
|
65300
|
+
var import_react26 = __toESM(require_react());
|
|
65021
65301
|
|
|
65022
65302
|
// src/react/toolbar/popover/LayoutSettingsView.tsx
|
|
65023
|
-
var
|
|
65303
|
+
var import_react25 = __toESM(require_react());
|
|
65024
65304
|
var import_jsx_runtime25 = __toESM(require_jsx_runtime());
|
|
65025
65305
|
function getDefaults(params) {
|
|
65026
65306
|
const d = {};
|
|
@@ -65031,21 +65311,21 @@ void main() {
|
|
|
65031
65311
|
const params = item.params ?? [];
|
|
65032
65312
|
const stored = ctx.getState().layoutParams[item.id];
|
|
65033
65313
|
const defaults = getDefaults(params);
|
|
65034
|
-
const [values, setValues] = (0,
|
|
65035
|
-
(0,
|
|
65314
|
+
const [values, setValues] = (0, import_react25.useState)({ ...defaults, ...stored });
|
|
65315
|
+
(0, import_react25.useEffect)(() => {
|
|
65036
65316
|
if (stored) setValues((v) => ({ ...defaults, ...stored, ...v }));
|
|
65037
65317
|
}, [stored]);
|
|
65038
|
-
const setValue = (0,
|
|
65318
|
+
const setValue = (0, import_react25.useCallback)((key, val) => {
|
|
65039
65319
|
setValues((prev) => {
|
|
65040
65320
|
const next = { ...prev, [key]: val };
|
|
65041
65321
|
ctx.dispatch({ type: "SET_LAYOUT_PARAMS", toolId: item.id, params: next });
|
|
65042
65322
|
return next;
|
|
65043
65323
|
});
|
|
65044
65324
|
}, [ctx, item.id]);
|
|
65045
|
-
const handleApply = (0,
|
|
65325
|
+
const handleApply = (0, import_react25.useCallback)(() => {
|
|
65046
65326
|
onApply(item);
|
|
65047
65327
|
}, [item, onApply]);
|
|
65048
|
-
const handleReset = (0,
|
|
65328
|
+
const handleReset = (0, import_react25.useCallback)(() => {
|
|
65049
65329
|
const d = getDefaults(params);
|
|
65050
65330
|
setValues(d);
|
|
65051
65331
|
ctx.dispatch({ type: "SET_LAYOUT_PARAMS", toolId: item.id, params: d });
|
|
@@ -65127,8 +65407,8 @@ void main() {
|
|
|
65127
65407
|
isPinnable
|
|
65128
65408
|
}) {
|
|
65129
65409
|
const layout = parent.popoverLayout ?? "list";
|
|
65130
|
-
const [settingsItem, setSettingsItem] = (0,
|
|
65131
|
-
const handleLeafClick = (0,
|
|
65410
|
+
const [settingsItem, setSettingsItem] = (0, import_react26.useState)(null);
|
|
65411
|
+
const handleLeafClick = (0, import_react26.useCallback)(
|
|
65132
65412
|
(item) => {
|
|
65133
65413
|
if (item.kind === "separator") return;
|
|
65134
65414
|
onInvoke(item);
|
|
@@ -65136,7 +65416,7 @@ void main() {
|
|
|
65136
65416
|
},
|
|
65137
65417
|
[onInvoke, onOpenChange, layout, parent.keepOpen]
|
|
65138
65418
|
);
|
|
65139
|
-
const handleOpenChange = (0,
|
|
65419
|
+
const handleOpenChange = (0, import_react26.useCallback)((next) => {
|
|
65140
65420
|
if (!next) setSettingsItem(null);
|
|
65141
65421
|
onOpenChange(next);
|
|
65142
65422
|
}, [onOpenChange]);
|
|
@@ -65227,10 +65507,10 @@ void main() {
|
|
|
65227
65507
|
}
|
|
65228
65508
|
|
|
65229
65509
|
// src/react/toolbar/responsive/useBreakpoint.ts
|
|
65230
|
-
var
|
|
65510
|
+
var import_react27 = __toESM(require_react());
|
|
65231
65511
|
function useBreakpoint(containerRef, axis) {
|
|
65232
|
-
const [level, setLevel] = (0,
|
|
65233
|
-
(0,
|
|
65512
|
+
const [level, setLevel] = (0, import_react27.useState)("L");
|
|
65513
|
+
(0, import_react27.useLayoutEffect)(() => {
|
|
65234
65514
|
const el = containerRef.current;
|
|
65235
65515
|
if (!el) return;
|
|
65236
65516
|
const compute = (w, h) => axis === "horizontal" ? computeHorizontalLevel(w) : computeVerticalLevel(h);
|
|
@@ -65310,23 +65590,23 @@ void main() {
|
|
|
65310
65590
|
onPin,
|
|
65311
65591
|
pinnedTools
|
|
65312
65592
|
} = props;
|
|
65313
|
-
const dockRef = (0,
|
|
65314
|
-
const handleRef = (0,
|
|
65593
|
+
const dockRef = (0, import_react28.useRef)(null);
|
|
65594
|
+
const handleRef = (0, import_react28.useRef)(null);
|
|
65315
65595
|
const level = useBreakpoint(containerRef, dock.orientation === "horizontal" ? "horizontal" : "vertical");
|
|
65316
|
-
const { visible, overflow } = (0,
|
|
65596
|
+
const { visible, overflow } = (0, import_react28.useMemo)(
|
|
65317
65597
|
() => filterItemsByBreakpoint(dock.items, level),
|
|
65318
65598
|
[dock.items, level]
|
|
65319
65599
|
);
|
|
65320
65600
|
const sizeSpec = SIZE_SPEC[level];
|
|
65321
|
-
const [resolved, setResolved] = (0,
|
|
65601
|
+
const [resolved, setResolved] = (0, import_react28.useState)(
|
|
65322
65602
|
position.x >= 0 && position.y >= 0 ? position : null
|
|
65323
65603
|
);
|
|
65324
|
-
(0,
|
|
65604
|
+
(0, import_react28.useEffect)(() => {
|
|
65325
65605
|
if (position.x >= 0 && position.y >= 0) {
|
|
65326
65606
|
setResolved(position);
|
|
65327
65607
|
}
|
|
65328
65608
|
}, [position]);
|
|
65329
|
-
(0,
|
|
65609
|
+
(0, import_react28.useEffect)(() => {
|
|
65330
65610
|
if (resolved !== null) return;
|
|
65331
65611
|
const container = containerRef.current;
|
|
65332
65612
|
const dockEl = dockRef.current;
|
|
@@ -65336,7 +65616,7 @@ void main() {
|
|
|
65336
65616
|
const next = dock.orientation === "vertical" ? { x: Math.max(0, cb.width - db.width - 14), y: Math.max(0, (cb.height - db.height) / 2) } : { x: Math.max(0, (cb.width - db.width) / 2), y: Math.max(0, cb.height - db.height - 14) };
|
|
65337
65617
|
setResolved(next);
|
|
65338
65618
|
}, [resolved, dock.orientation, containerRef]);
|
|
65339
|
-
(0,
|
|
65619
|
+
(0, import_react28.useEffect)(() => {
|
|
65340
65620
|
const handle = handleRef.current;
|
|
65341
65621
|
if (!handle) return;
|
|
65342
65622
|
const onMouseDown = (e) => {
|
|
@@ -65375,7 +65655,7 @@ void main() {
|
|
|
65375
65655
|
handle.removeEventListener("mousedown", onMouseDown);
|
|
65376
65656
|
};
|
|
65377
65657
|
}, [resolved, containerRef, onPositionChange]);
|
|
65378
|
-
(0,
|
|
65658
|
+
(0, import_react28.useEffect)(() => {
|
|
65379
65659
|
const container = containerRef.current;
|
|
65380
65660
|
const dockEl = dockRef.current;
|
|
65381
65661
|
if (!container || !dockEl || !resolved) return;
|
|
@@ -65452,13 +65732,13 @@ void main() {
|
|
|
65452
65732
|
}
|
|
65453
65733
|
|
|
65454
65734
|
// src/react/toolbar/popover/FloatingPanel.tsx
|
|
65455
|
-
var
|
|
65735
|
+
var import_react30 = __toESM(require_react());
|
|
65456
65736
|
var import_react_dom4 = __toESM(require_react_dom());
|
|
65457
65737
|
|
|
65458
65738
|
// src/react/toolbar/utils/useBlockNativeSceneEvents.ts
|
|
65459
|
-
var
|
|
65739
|
+
var import_react29 = __toESM(require_react());
|
|
65460
65740
|
function useBlockNativeSceneEvents3(ref) {
|
|
65461
|
-
(0,
|
|
65741
|
+
(0, import_react29.useEffect)(() => {
|
|
65462
65742
|
const el = ref.current;
|
|
65463
65743
|
if (!el) return;
|
|
65464
65744
|
const stop = (e) => {
|
|
@@ -65489,12 +65769,12 @@ void main() {
|
|
|
65489
65769
|
onFocus,
|
|
65490
65770
|
children
|
|
65491
65771
|
}) {
|
|
65492
|
-
const panelRef = (0,
|
|
65493
|
-
const headerRef = (0,
|
|
65494
|
-
const positionRef = (0,
|
|
65772
|
+
const panelRef = (0, import_react30.useRef)(null);
|
|
65773
|
+
const headerRef = (0, import_react30.useRef)(null);
|
|
65774
|
+
const positionRef = (0, import_react30.useRef)(position);
|
|
65495
65775
|
positionRef.current = position;
|
|
65496
65776
|
useBlockNativeSceneEvents3(panelRef);
|
|
65497
|
-
(0,
|
|
65777
|
+
(0, import_react30.useEffect)(() => {
|
|
65498
65778
|
const header = headerRef.current;
|
|
65499
65779
|
if (!header) return;
|
|
65500
65780
|
const onMouseDown = (e) => {
|
|
@@ -65550,16 +65830,16 @@ void main() {
|
|
|
65550
65830
|
}
|
|
65551
65831
|
|
|
65552
65832
|
// src/react/toolbar/i18n/ToolbarI18nProvider.tsx
|
|
65553
|
-
var
|
|
65833
|
+
var import_react32 = __toESM(require_react());
|
|
65554
65834
|
|
|
65555
65835
|
// src/react/toolbar/i18n/useToolbarIntl.ts
|
|
65556
|
-
var
|
|
65557
|
-
var ToolbarI18nContext =
|
|
65836
|
+
var import_react31 = __toESM(require_react());
|
|
65837
|
+
var ToolbarI18nContext = import_react31.default.createContext({
|
|
65558
65838
|
locale: "en",
|
|
65559
65839
|
t: (key) => key
|
|
65560
65840
|
});
|
|
65561
65841
|
function useToolbarIntl() {
|
|
65562
|
-
return (0,
|
|
65842
|
+
return (0, import_react31.useContext)(ToolbarI18nContext);
|
|
65563
65843
|
}
|
|
65564
65844
|
function lookupMessage(key, _ignored, opts) {
|
|
65565
65845
|
const template = opts.override[key] ?? opts.bundle[key] ?? opts.fallback[key] ?? key;
|
|
@@ -65681,7 +65961,7 @@ void main() {
|
|
|
65681
65961
|
messages = {},
|
|
65682
65962
|
children
|
|
65683
65963
|
}) {
|
|
65684
|
-
const value = (0,
|
|
65964
|
+
const value = (0, import_react32.useMemo)(() => {
|
|
65685
65965
|
const bundle = bundles[locale] ?? {};
|
|
65686
65966
|
const t = (key, values) => lookupMessage(key, void 0, {
|
|
65687
65967
|
override: messages,
|
|
@@ -65985,15 +66265,15 @@ void main() {
|
|
|
65985
66265
|
}) {
|
|
65986
66266
|
const contextApi = useOptionalRenderEngineApi();
|
|
65987
66267
|
const api = apiProp ?? contextApi ?? null;
|
|
65988
|
-
(0,
|
|
66268
|
+
(0, import_react33.useSyncExternalStore)(
|
|
65989
66269
|
(cb) => registry.subscribe(cb),
|
|
65990
66270
|
() => registry.getAllDocks(),
|
|
65991
66271
|
() => registry.getAllDocks()
|
|
65992
66272
|
);
|
|
65993
66273
|
const docks = registry.getAllDocks();
|
|
65994
66274
|
const { t } = useToolbarIntl();
|
|
65995
|
-
const [, forceTick] = (0,
|
|
65996
|
-
(0,
|
|
66275
|
+
const [, forceTick] = (0, import_react33.useReducer)((n) => n + 1, 0);
|
|
66276
|
+
(0, import_react33.useEffect)(() => {
|
|
65997
66277
|
if (!api) return;
|
|
65998
66278
|
let last = {
|
|
65999
66279
|
sel: api.selection.getSelectedNodeIds().length,
|
|
@@ -66025,7 +66305,7 @@ void main() {
|
|
|
66025
66305
|
const id = setInterval(check, 50);
|
|
66026
66306
|
return () => clearInterval(id);
|
|
66027
66307
|
}, [api]);
|
|
66028
|
-
const dispatch2 = (0,
|
|
66308
|
+
const dispatch2 = (0, import_react33.useCallback)(
|
|
66029
66309
|
(action) => {
|
|
66030
66310
|
switch (action.type) {
|
|
66031
66311
|
case "SET_DOCK_POSITION":
|
|
@@ -66073,22 +66353,22 @@ void main() {
|
|
|
66073
66353
|
onLayoutParamsChange
|
|
66074
66354
|
]
|
|
66075
66355
|
);
|
|
66076
|
-
const state = (0,
|
|
66356
|
+
const state = (0, import_react33.useMemo)(
|
|
66077
66357
|
() => ({ dockPositions, collapsed, pinnedTools, activeToggles, pinnedPositions, layoutParams }),
|
|
66078
66358
|
[dockPositions, collapsed, pinnedTools, activeToggles, pinnedPositions, layoutParams]
|
|
66079
66359
|
);
|
|
66080
|
-
const ctx = (0,
|
|
66360
|
+
const ctx = (0, import_react33.useMemo)(
|
|
66081
66361
|
() => ({ api, t, locale, getState: () => state, dispatch: dispatch2 }),
|
|
66082
66362
|
[api, t, locale, state, dispatch2]
|
|
66083
66363
|
);
|
|
66084
|
-
const [popoverState, localDispatch] = (0,
|
|
66085
|
-
const zIndexMap = (0,
|
|
66086
|
-
const zCounter = (0,
|
|
66087
|
-
const bringToFront = (0,
|
|
66364
|
+
const [popoverState, localDispatch] = (0, import_react33.useReducer)(popoverReducer, initialPopoverState);
|
|
66365
|
+
const zIndexMap = (0, import_react33.useRef)(/* @__PURE__ */ new Map());
|
|
66366
|
+
const zCounter = (0, import_react33.useRef)(1);
|
|
66367
|
+
const bringToFront = (0, import_react33.useCallback)((toolId) => {
|
|
66088
66368
|
zCounter.current += 1;
|
|
66089
66369
|
zIndexMap.current.set(toolId, zCounter.current);
|
|
66090
66370
|
}, []);
|
|
66091
|
-
(0,
|
|
66371
|
+
(0, import_react33.useEffect)(() => {
|
|
66092
66372
|
const onKey = (e) => {
|
|
66093
66373
|
if (e.key !== "Escape") return;
|
|
66094
66374
|
const tag = document.activeElement?.tagName;
|
|
@@ -66105,7 +66385,7 @@ void main() {
|
|
|
66105
66385
|
document.addEventListener("keydown", onKey);
|
|
66106
66386
|
return () => document.removeEventListener("keydown", onKey);
|
|
66107
66387
|
}, [pinnedTools, popoverState.status, dispatch2]);
|
|
66108
|
-
const handleInvoke = (0,
|
|
66388
|
+
const handleInvoke = (0, import_react33.useCallback)(
|
|
66109
66389
|
(item) => {
|
|
66110
66390
|
if (item.kind === "action") {
|
|
66111
66391
|
void item.onInvoke(ctx);
|
|
@@ -66127,7 +66407,7 @@ void main() {
|
|
|
66127
66407
|
},
|
|
66128
66408
|
[ctx, activeToggles, dispatch2, pinnedTools]
|
|
66129
66409
|
);
|
|
66130
|
-
const findParentItem = (0,
|
|
66410
|
+
const findParentItem = (0, import_react33.useCallback)(
|
|
66131
66411
|
(toolId) => {
|
|
66132
66412
|
for (const dock of docks) {
|
|
66133
66413
|
for (const it of dock.items) {
|
|
@@ -66138,10 +66418,10 @@ void main() {
|
|
|
66138
66418
|
},
|
|
66139
66419
|
[docks]
|
|
66140
66420
|
);
|
|
66141
|
-
const containerRef = (0,
|
|
66421
|
+
const containerRef = (0, import_react33.useRef)(null);
|
|
66142
66422
|
useBlockNativeSceneEvents3(containerRef);
|
|
66143
|
-
const [fontsReady, setFontsReady] = (0,
|
|
66144
|
-
(0,
|
|
66423
|
+
const [fontsReady, setFontsReady] = (0, import_react33.useState)(false);
|
|
66424
|
+
(0, import_react33.useEffect)(() => {
|
|
66145
66425
|
if (typeof document === "undefined" || !document.fonts) return;
|
|
66146
66426
|
if (fontsReady) {
|
|
66147
66427
|
document.body.classList.add("rx-fonts-ready");
|
|
@@ -66220,7 +66500,7 @@ void main() {
|
|
|
66220
66500
|
);
|
|
66221
66501
|
}
|
|
66222
66502
|
function PinnedPanelBody({ parent, ctx, onInvoke }) {
|
|
66223
|
-
const [settingsItem, setSettingsItem] = (0,
|
|
66503
|
+
const [settingsItem, setSettingsItem] = (0, import_react33.useState)(null);
|
|
66224
66504
|
if (settingsItem) {
|
|
66225
66505
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
66226
66506
|
LayoutSettingsView,
|
|
@@ -67054,24 +67334,24 @@ void main() {
|
|
|
67054
67334
|
}
|
|
67055
67335
|
|
|
67056
67336
|
// src/react/toolbar/state/useToolbarState.ts
|
|
67057
|
-
var
|
|
67337
|
+
var import_react34 = __toESM(require_react());
|
|
67058
67338
|
function useToolbarState(initialState) {
|
|
67059
|
-
const [dockPositions, setDockPositions] = (0,
|
|
67339
|
+
const [dockPositions, setDockPositions] = (0, import_react34.useState)(
|
|
67060
67340
|
initialState?.dockPositions ?? DEFAULT_DOCK_POSITIONS
|
|
67061
67341
|
);
|
|
67062
|
-
const [collapsed, setCollapsed] = (0,
|
|
67342
|
+
const [collapsed, setCollapsed] = (0, import_react34.useState)(
|
|
67063
67343
|
initialState?.collapsed ?? {}
|
|
67064
67344
|
);
|
|
67065
|
-
const [pinnedTools, setPinnedTools] = (0,
|
|
67345
|
+
const [pinnedTools, setPinnedTools] = (0, import_react34.useState)(
|
|
67066
67346
|
initialState?.pinnedTools ?? []
|
|
67067
67347
|
);
|
|
67068
|
-
const [activeToggles, setActiveToggles] = (0,
|
|
67348
|
+
const [activeToggles, setActiveToggles] = (0, import_react34.useState)(
|
|
67069
67349
|
initialState?.activeToggles ?? {}
|
|
67070
67350
|
);
|
|
67071
|
-
const [pinnedPositions, setPinnedPositions] = (0,
|
|
67351
|
+
const [pinnedPositions, setPinnedPositions] = (0, import_react34.useState)(
|
|
67072
67352
|
initialState?.pinnedPositions ?? {}
|
|
67073
67353
|
);
|
|
67074
|
-
const [layoutParams, setLayoutParams] = (0,
|
|
67354
|
+
const [layoutParams, setLayoutParams] = (0, import_react34.useState)(
|
|
67075
67355
|
initialState?.layoutParams ?? {}
|
|
67076
67356
|
);
|
|
67077
67357
|
return {
|
|
@@ -67094,7 +67374,7 @@ void main() {
|
|
|
67094
67374
|
var import_jsx_runtime31 = __toESM(require_jsx_runtime());
|
|
67095
67375
|
function ToolbarAutoMount({ config }) {
|
|
67096
67376
|
const configObj = typeof config === "object" ? config : {};
|
|
67097
|
-
const defaultRegistry = (0,
|
|
67377
|
+
const defaultRegistry = (0, import_react35.useMemo)(() => createDefaultRegistry(), []);
|
|
67098
67378
|
const state = useToolbarState();
|
|
67099
67379
|
const registry = configObj.registry ?? defaultRegistry;
|
|
67100
67380
|
const api = useOptionalRenderEngineApi();
|
|
@@ -67104,14 +67384,14 @@ void main() {
|
|
|
67104
67384
|
}
|
|
67105
67385
|
|
|
67106
67386
|
// src/react/legend/LegendPanel.tsx
|
|
67107
|
-
var
|
|
67387
|
+
var import_react46 = __toESM(require_react());
|
|
67108
67388
|
|
|
67109
67389
|
// src/react/legend/hooks/useLegendData.ts
|
|
67110
|
-
var
|
|
67390
|
+
var import_react36 = __toESM(require_react());
|
|
67111
67391
|
function useLegendData(store, api) {
|
|
67112
|
-
const [, setVersion] = (0,
|
|
67113
|
-
const bump = (0,
|
|
67114
|
-
(0,
|
|
67392
|
+
const [, setVersion] = (0, import_react36.useState)(0);
|
|
67393
|
+
const bump = (0, import_react36.useCallback)(() => setVersion((v) => v + 1), []);
|
|
67394
|
+
(0, import_react36.useEffect)(() => {
|
|
67115
67395
|
const unsubs = [
|
|
67116
67396
|
api.events.on("nodes:added", bump),
|
|
67117
67397
|
api.events.on("nodes:removed", bump),
|
|
@@ -67167,17 +67447,17 @@ void main() {
|
|
|
67167
67447
|
}
|
|
67168
67448
|
|
|
67169
67449
|
// src/react/legend/hooks/usePopover.ts
|
|
67170
|
-
var
|
|
67450
|
+
var import_react37 = __toESM(require_react());
|
|
67171
67451
|
function usePopover() {
|
|
67172
|
-
const [state, setState] = (0,
|
|
67452
|
+
const [state, setState] = (0, import_react37.useState)({
|
|
67173
67453
|
isOpen: false,
|
|
67174
67454
|
targetKey: null,
|
|
67175
67455
|
position: null,
|
|
67176
67456
|
flipped: false
|
|
67177
67457
|
});
|
|
67178
|
-
const popoverRef = (0,
|
|
67179
|
-
const hasDraggedRef = (0,
|
|
67180
|
-
const open = (0,
|
|
67458
|
+
const popoverRef = (0, import_react37.useRef)(null);
|
|
67459
|
+
const hasDraggedRef = (0, import_react37.useRef)(false);
|
|
67460
|
+
const open = (0, import_react37.useCallback)((key, anchorEl) => {
|
|
67181
67461
|
const rect = anchorEl.getBoundingClientRect();
|
|
67182
67462
|
const popoverWidth = 250;
|
|
67183
67463
|
const spaceLeft = rect.left;
|
|
@@ -67185,10 +67465,10 @@ void main() {
|
|
|
67185
67465
|
const position = flipped ? { top: rect.bottom + 8, left: rect.right - popoverWidth } : { top: rect.top, left: rect.left - popoverWidth - 12 };
|
|
67186
67466
|
setState({ isOpen: true, targetKey: key, position, flipped });
|
|
67187
67467
|
}, []);
|
|
67188
|
-
const close = (0,
|
|
67468
|
+
const close = (0, import_react37.useCallback)(() => {
|
|
67189
67469
|
setState({ isOpen: false, targetKey: null, position: null, flipped: false });
|
|
67190
67470
|
}, []);
|
|
67191
|
-
const toggle = (0,
|
|
67471
|
+
const toggle = (0, import_react37.useCallback)(
|
|
67192
67472
|
(key, anchorEl) => {
|
|
67193
67473
|
if (state.isOpen && state.targetKey === key) {
|
|
67194
67474
|
close();
|
|
@@ -67198,7 +67478,7 @@ void main() {
|
|
|
67198
67478
|
},
|
|
67199
67479
|
[state.isOpen, state.targetKey, open, close]
|
|
67200
67480
|
);
|
|
67201
|
-
(0,
|
|
67481
|
+
(0, import_react37.useEffect)(() => {
|
|
67202
67482
|
if (!state.isOpen) return;
|
|
67203
67483
|
const handler = (e) => {
|
|
67204
67484
|
if (hasDraggedRef.current) {
|
|
@@ -67212,7 +67492,7 @@ void main() {
|
|
|
67212
67492
|
document.addEventListener("mousedown", handler, true);
|
|
67213
67493
|
return () => document.removeEventListener("mousedown", handler, true);
|
|
67214
67494
|
}, [state.isOpen, close]);
|
|
67215
|
-
(0,
|
|
67495
|
+
(0, import_react37.useEffect)(() => {
|
|
67216
67496
|
if (!state.isOpen) return;
|
|
67217
67497
|
const handler = (e) => {
|
|
67218
67498
|
if (e.key === "Escape") close();
|
|
@@ -67224,7 +67504,7 @@ void main() {
|
|
|
67224
67504
|
}
|
|
67225
67505
|
|
|
67226
67506
|
// src/react/legend/CategoryPill.tsx
|
|
67227
|
-
var
|
|
67507
|
+
var import_react38 = __toESM(require_react());
|
|
67228
67508
|
|
|
67229
67509
|
// src/react/legend/colorPalettes.ts
|
|
67230
67510
|
var COLOR_PALETTES = [
|
|
@@ -67348,10 +67628,10 @@ void main() {
|
|
|
67348
67628
|
function CategoryPill({ entry, onSelect, onEditClick }) {
|
|
67349
67629
|
const { name, count: count4, color, isSelected, isHidden: isHidden2, colorMapping } = entry;
|
|
67350
67630
|
const textColor = contrastText(color);
|
|
67351
|
-
const handleClick = (0,
|
|
67631
|
+
const handleClick = (0, import_react38.useCallback)(() => {
|
|
67352
67632
|
onSelect(name);
|
|
67353
67633
|
}, [onSelect, name]);
|
|
67354
|
-
const handleKeyDown = (0,
|
|
67634
|
+
const handleKeyDown = (0, import_react38.useCallback)(
|
|
67355
67635
|
(e) => {
|
|
67356
67636
|
if (e.key === "Enter" || e.key === " ") {
|
|
67357
67637
|
e.preventDefault();
|
|
@@ -67360,14 +67640,14 @@ void main() {
|
|
|
67360
67640
|
},
|
|
67361
67641
|
[onSelect, name]
|
|
67362
67642
|
);
|
|
67363
|
-
const handleBrushClick = (0,
|
|
67643
|
+
const handleBrushClick = (0, import_react38.useCallback)(
|
|
67364
67644
|
(e) => {
|
|
67365
67645
|
e.stopPropagation();
|
|
67366
67646
|
onEditClick(name, e.currentTarget);
|
|
67367
67647
|
},
|
|
67368
67648
|
[onEditClick, name]
|
|
67369
67649
|
);
|
|
67370
|
-
const handleBrushKeyDown = (0,
|
|
67650
|
+
const handleBrushKeyDown = (0, import_react38.useCallback)(
|
|
67371
67651
|
(e) => {
|
|
67372
67652
|
if (e.key === "Enter" || e.key === " ") {
|
|
67373
67653
|
e.preventDefault();
|
|
@@ -67433,15 +67713,15 @@ void main() {
|
|
|
67433
67713
|
}
|
|
67434
67714
|
|
|
67435
67715
|
// src/react/legend/RelationshipPill.tsx
|
|
67436
|
-
var
|
|
67716
|
+
var import_react39 = __toESM(require_react());
|
|
67437
67717
|
var import_jsx_runtime33 = __toESM(require_jsx_runtime());
|
|
67438
67718
|
function RelationshipPill({ entry, onSelect, onEditClick }) {
|
|
67439
67719
|
const { name, count: count4, color, isSelected } = entry;
|
|
67440
67720
|
const textColor = contrastText(color);
|
|
67441
|
-
const handleClick = (0,
|
|
67721
|
+
const handleClick = (0, import_react39.useCallback)(() => {
|
|
67442
67722
|
onSelect(name);
|
|
67443
67723
|
}, [onSelect, name]);
|
|
67444
|
-
const handleKeyDown = (0,
|
|
67724
|
+
const handleKeyDown = (0, import_react39.useCallback)(
|
|
67445
67725
|
(e) => {
|
|
67446
67726
|
if (e.key === "Enter" || e.key === " ") {
|
|
67447
67727
|
e.preventDefault();
|
|
@@ -67450,14 +67730,14 @@ void main() {
|
|
|
67450
67730
|
},
|
|
67451
67731
|
[onSelect, name]
|
|
67452
67732
|
);
|
|
67453
|
-
const handleBrushClick = (0,
|
|
67733
|
+
const handleBrushClick = (0, import_react39.useCallback)(
|
|
67454
67734
|
(e) => {
|
|
67455
67735
|
e.stopPropagation();
|
|
67456
67736
|
onEditClick(name, e.currentTarget);
|
|
67457
67737
|
},
|
|
67458
67738
|
[onEditClick, name]
|
|
67459
67739
|
);
|
|
67460
|
-
const handleBrushKeyDown = (0,
|
|
67740
|
+
const handleBrushKeyDown = (0, import_react39.useCallback)(
|
|
67461
67741
|
(e) => {
|
|
67462
67742
|
if (e.key === "Enter" || e.key === " ") {
|
|
67463
67743
|
e.preventDefault();
|
|
@@ -67504,10 +67784,10 @@ void main() {
|
|
|
67504
67784
|
}
|
|
67505
67785
|
|
|
67506
67786
|
// src/react/legend/StylePopover.tsx
|
|
67507
|
-
var
|
|
67787
|
+
var import_react45 = __toESM(require_react());
|
|
67508
67788
|
|
|
67509
67789
|
// src/react/legend/popover/ColorTab.tsx
|
|
67510
|
-
var
|
|
67790
|
+
var import_react41 = __toESM(require_react());
|
|
67511
67791
|
|
|
67512
67792
|
// src/react/legend/popover/SwatchGrid.tsx
|
|
67513
67793
|
var import_jsx_runtime34 = __toESM(require_jsx_runtime());
|
|
@@ -67601,7 +67881,7 @@ void main() {
|
|
|
67601
67881
|
}
|
|
67602
67882
|
|
|
67603
67883
|
// src/react/legend/i18n.ts
|
|
67604
|
-
var
|
|
67884
|
+
var import_react40 = __toESM(require_react());
|
|
67605
67885
|
var DEFAULT_LEGEND_MESSAGES = {
|
|
67606
67886
|
"legend.section.nodes": "NODES",
|
|
67607
67887
|
"legend.section.edges": "EDGES",
|
|
@@ -67634,11 +67914,11 @@ void main() {
|
|
|
67634
67914
|
"legend.noProperties": "No properties available",
|
|
67635
67915
|
"legend.appliesToCategory": "Applies to this category"
|
|
67636
67916
|
};
|
|
67637
|
-
var LegendI18nContext =
|
|
67917
|
+
var LegendI18nContext = import_react40.default.createContext({
|
|
67638
67918
|
t: (key) => DEFAULT_LEGEND_MESSAGES[key] ?? key
|
|
67639
67919
|
});
|
|
67640
67920
|
function useLegendIntl() {
|
|
67641
|
-
return (0,
|
|
67921
|
+
return (0, import_react40.useContext)(LegendI18nContext);
|
|
67642
67922
|
}
|
|
67643
67923
|
function getMessage(messages, key, params) {
|
|
67644
67924
|
const template = messages?.[key] ?? DEFAULT_LEGEND_MESSAGES[key] ?? key;
|
|
@@ -67670,33 +67950,33 @@ void main() {
|
|
|
67670
67950
|
}
|
|
67671
67951
|
function ColorTab({ targetKey, isCategory, store, api }) {
|
|
67672
67952
|
const { t } = useLegendIntl();
|
|
67673
|
-
const [mode, setMode] = (0,
|
|
67674
|
-
const [selectedPalette, setSelectedPalette] = (0,
|
|
67675
|
-
const [selectedProperty, setSelectedProperty] = (0,
|
|
67676
|
-
const [subMode, setSubMode] = (0,
|
|
67677
|
-
const [gradientScheme, setGradientScheme] = (0,
|
|
67953
|
+
const [mode, setMode] = (0, import_react41.useState)("default");
|
|
67954
|
+
const [selectedPalette, setSelectedPalette] = (0, import_react41.useState)(getStoredPalette);
|
|
67955
|
+
const [selectedProperty, setSelectedProperty] = (0, import_react41.useState)("");
|
|
67956
|
+
const [subMode, setSubMode] = (0, import_react41.useState)("discrete");
|
|
67957
|
+
const [gradientScheme, setGradientScheme] = (0, import_react41.useState)("viridis");
|
|
67678
67958
|
const currentColor = isCategory ? store.visualMapper.categoryColors.getColor(targetKey) : store.visualMapper.relationshipColors.getColor(targetKey);
|
|
67679
|
-
const paletteNames = (0,
|
|
67959
|
+
const paletteNames = (0, import_react41.useMemo)(() => {
|
|
67680
67960
|
const preferred = isCategory ? NODE_PALETTES : EDGE_PALETTES;
|
|
67681
67961
|
const allNames = COLOR_PALETTES.map((p) => p.name);
|
|
67682
67962
|
const rest = allNames.filter((n) => !preferred.includes(n));
|
|
67683
67963
|
return [...preferred, ...rest];
|
|
67684
67964
|
}, [isCategory]);
|
|
67685
|
-
const paletteColors = (0,
|
|
67965
|
+
const paletteColors = (0, import_react41.useMemo)(() => {
|
|
67686
67966
|
const palette = COLOR_PALETTES.find((p) => p.name === selectedPalette);
|
|
67687
67967
|
return palette?.colors ?? COLOR_PALETTES[0].colors;
|
|
67688
67968
|
}, [selectedPalette]);
|
|
67689
|
-
const propertyKeys = (0,
|
|
67969
|
+
const propertyKeys = (0, import_react41.useMemo)(() => {
|
|
67690
67970
|
if (isCategory) {
|
|
67691
67971
|
return api.types.getNodeTypeProperties(targetKey).map((p) => p.key);
|
|
67692
67972
|
}
|
|
67693
67973
|
return api.types.getEdgeTypeProperties(targetKey).map((p) => p.key);
|
|
67694
67974
|
}, [api, targetKey, isCategory]);
|
|
67695
|
-
const activeProperty = (0,
|
|
67975
|
+
const activeProperty = (0, import_react41.useMemo)(() => {
|
|
67696
67976
|
if (selectedProperty && propertyKeys.includes(selectedProperty)) return selectedProperty;
|
|
67697
67977
|
return propertyKeys[0] ?? "";
|
|
67698
67978
|
}, [selectedProperty, propertyKeys]);
|
|
67699
|
-
const propertyValues = (0,
|
|
67979
|
+
const propertyValues = (0, import_react41.useMemo)(() => {
|
|
67700
67980
|
if (!activeProperty) return [];
|
|
67701
67981
|
const items = isCategory ? store.data.nodes.filter((n) => n.category === targetKey) : store.data.edges.filter((e) => e.relationship === targetKey);
|
|
67702
67982
|
const counts = /* @__PURE__ */ new Map();
|
|
@@ -67717,7 +67997,7 @@ void main() {
|
|
|
67717
67997
|
}
|
|
67718
67998
|
return entries.sort((a2, b) => b.count - a2.count);
|
|
67719
67999
|
}, [activeProperty, isCategory, targetKey, store, paletteColors]);
|
|
67720
|
-
const gradientDomain = (0,
|
|
68000
|
+
const gradientDomain = (0, import_react41.useMemo)(() => {
|
|
67721
68001
|
if (!activeProperty) return [0, 1];
|
|
67722
68002
|
const items = isCategory ? store.data.nodes.filter((n) => n.category === targetKey) : store.data.edges.filter((e) => e.relationship === targetKey);
|
|
67723
68003
|
const numericValues = items.map((item) => {
|
|
@@ -67729,7 +68009,7 @@ void main() {
|
|
|
67729
68009
|
const max2 = Math.max(...numericValues);
|
|
67730
68010
|
return [min2, max2 === min2 ? min2 + 1 : max2];
|
|
67731
68011
|
}, [activeProperty, isCategory, targetKey, store]);
|
|
67732
|
-
const handleSwatchSelect = (0,
|
|
68012
|
+
const handleSwatchSelect = (0, import_react41.useCallback)(
|
|
67733
68013
|
(color) => {
|
|
67734
68014
|
if (isCategory) {
|
|
67735
68015
|
api.style.setCategoryColor(targetKey, color);
|
|
@@ -67739,15 +68019,15 @@ void main() {
|
|
|
67739
68019
|
},
|
|
67740
68020
|
[api, targetKey, isCategory]
|
|
67741
68021
|
);
|
|
67742
|
-
const handlePaletteChange = (0,
|
|
68022
|
+
const handlePaletteChange = (0, import_react41.useCallback)((e) => {
|
|
67743
68023
|
const name = e.target.value;
|
|
67744
68024
|
setSelectedPalette(name);
|
|
67745
68025
|
setStoredPalette(name);
|
|
67746
68026
|
}, []);
|
|
67747
|
-
const handlePropertyChange = (0,
|
|
68027
|
+
const handlePropertyChange = (0, import_react41.useCallback)((e) => {
|
|
67748
68028
|
setSelectedProperty(e.target.value);
|
|
67749
68029
|
}, []);
|
|
67750
|
-
const handleApplyDiscrete = (0,
|
|
68030
|
+
const handleApplyDiscrete = (0, import_react41.useCallback)(() => {
|
|
67751
68031
|
if (!activeProperty) return;
|
|
67752
68032
|
const colorMap = {};
|
|
67753
68033
|
for (const entry of propertyValues) {
|
|
@@ -67759,7 +68039,7 @@ void main() {
|
|
|
67759
68039
|
api.style.colorEdgesByProperty(activeProperty, { mode: "ordinal", relationship: targetKey, colorMap });
|
|
67760
68040
|
}
|
|
67761
68041
|
}, [activeProperty, propertyValues, isCategory, targetKey, api]);
|
|
67762
|
-
const handleApplyGradient = (0,
|
|
68042
|
+
const handleApplyGradient = (0, import_react41.useCallback)(() => {
|
|
67763
68043
|
if (!activeProperty) return;
|
|
67764
68044
|
const { colorFrom, colorTo } = getGradientColors(gradientScheme);
|
|
67765
68045
|
if (isCategory) {
|
|
@@ -67898,26 +68178,26 @@ void main() {
|
|
|
67898
68178
|
}
|
|
67899
68179
|
|
|
67900
68180
|
// src/react/legend/popover/SizeTab.tsx
|
|
67901
|
-
var
|
|
68181
|
+
var import_react42 = __toESM(require_react());
|
|
67902
68182
|
var import_jsx_runtime38 = __toESM(require_jsx_runtime());
|
|
67903
68183
|
var DEFAULT_SIZE2 = 10;
|
|
67904
68184
|
var DEFAULT_MIN_SIZE = 5;
|
|
67905
68185
|
var DEFAULT_MAX_SIZE = 25;
|
|
67906
68186
|
function SizeTab({ targetKey, store, api }) {
|
|
67907
68187
|
const { t } = useLegendIntl();
|
|
67908
|
-
const [defaultSize, setDefaultSize] = (0,
|
|
67909
|
-
const [sizeByProperty, setSizeByProperty] = (0,
|
|
67910
|
-
const [selectedProperty, setSelectedProperty] = (0,
|
|
67911
|
-
const [minSize, setMinSize] = (0,
|
|
67912
|
-
const [maxSize, setMaxSize] = (0,
|
|
67913
|
-
const propertyKeys = (0,
|
|
68188
|
+
const [defaultSize, setDefaultSize] = (0, import_react42.useState)(DEFAULT_SIZE2);
|
|
68189
|
+
const [sizeByProperty, setSizeByProperty] = (0, import_react42.useState)(false);
|
|
68190
|
+
const [selectedProperty, setSelectedProperty] = (0, import_react42.useState)("");
|
|
68191
|
+
const [minSize, setMinSize] = (0, import_react42.useState)(DEFAULT_MIN_SIZE);
|
|
68192
|
+
const [maxSize, setMaxSize] = (0, import_react42.useState)(DEFAULT_MAX_SIZE);
|
|
68193
|
+
const propertyKeys = (0, import_react42.useMemo)(() => {
|
|
67914
68194
|
return api.types.getNodeTypeProperties(targetKey).map((p) => p.key);
|
|
67915
68195
|
}, [api, targetKey]);
|
|
67916
|
-
const activeProperty = (0,
|
|
68196
|
+
const activeProperty = (0, import_react42.useMemo)(() => {
|
|
67917
68197
|
if (selectedProperty && propertyKeys.includes(selectedProperty)) return selectedProperty;
|
|
67918
68198
|
return propertyKeys[0] ?? "";
|
|
67919
68199
|
}, [selectedProperty, propertyKeys]);
|
|
67920
|
-
const handleDefaultSizeChange = (0,
|
|
68200
|
+
const handleDefaultSizeChange = (0, import_react42.useCallback)(
|
|
67921
68201
|
(e) => {
|
|
67922
68202
|
const size4 = Number(e.target.value);
|
|
67923
68203
|
setDefaultSize(size4);
|
|
@@ -67928,7 +68208,7 @@ void main() {
|
|
|
67928
68208
|
},
|
|
67929
68209
|
[api, store, targetKey]
|
|
67930
68210
|
);
|
|
67931
|
-
const handleApplySizeByProperty = (0,
|
|
68211
|
+
const handleApplySizeByProperty = (0, import_react42.useCallback)(() => {
|
|
67932
68212
|
if (!activeProperty) return;
|
|
67933
68213
|
api.style.sizeNodesByProperty(activeProperty, {
|
|
67934
68214
|
minSize,
|
|
@@ -68034,16 +68314,16 @@ void main() {
|
|
|
68034
68314
|
}
|
|
68035
68315
|
|
|
68036
68316
|
// src/react/legend/popover/WidthTab.tsx
|
|
68037
|
-
var
|
|
68317
|
+
var import_react43 = __toESM(require_react());
|
|
68038
68318
|
var import_jsx_runtime39 = __toESM(require_jsx_runtime());
|
|
68039
68319
|
var DEFAULT_WIDTH = 1;
|
|
68040
68320
|
function WidthTab({ targetKey, store, api }) {
|
|
68041
68321
|
const { t } = useLegendIntl();
|
|
68042
|
-
const [defaultWidth, setDefaultWidth] = (0,
|
|
68322
|
+
const [defaultWidth, setDefaultWidth] = (0, import_react43.useState)(() => {
|
|
68043
68323
|
const config = store.visualMapper.getRelationshipConfig(targetKey);
|
|
68044
68324
|
return config?.defaultWidth ?? DEFAULT_WIDTH;
|
|
68045
68325
|
});
|
|
68046
|
-
const handleDefaultWidthChange = (0,
|
|
68326
|
+
const handleDefaultWidthChange = (0, import_react43.useCallback)(
|
|
68047
68327
|
(e) => {
|
|
68048
68328
|
const width = Number(e.target.value);
|
|
68049
68329
|
setDefaultWidth(width);
|
|
@@ -68072,11 +68352,11 @@ void main() {
|
|
|
68072
68352
|
}
|
|
68073
68353
|
|
|
68074
68354
|
// src/react/legend/popover/CaptionTab.tsx
|
|
68075
|
-
var
|
|
68355
|
+
var import_react44 = __toESM(require_react());
|
|
68076
68356
|
var import_jsx_runtime40 = __toESM(require_jsx_runtime());
|
|
68077
68357
|
function CaptionTab({ targetKey, isCategory, store, api }) {
|
|
68078
68358
|
const { t } = useLegendIntl();
|
|
68079
|
-
const existingConfig = (0,
|
|
68359
|
+
const existingConfig = (0, import_react44.useMemo)(() => {
|
|
68080
68360
|
if (isCategory) {
|
|
68081
68361
|
const catConfig = store.visualMapper.getCategoryConfig(targetKey);
|
|
68082
68362
|
return catConfig?.captionConfig ?? null;
|
|
@@ -68084,25 +68364,25 @@ void main() {
|
|
|
68084
68364
|
const relConfig = store.visualMapper.getRelationshipConfig(targetKey);
|
|
68085
68365
|
return relConfig?.captionConfig ?? null;
|
|
68086
68366
|
}, [store, targetKey, isCategory]);
|
|
68087
|
-
const [captions, setCaptions] = (0,
|
|
68367
|
+
const [captions, setCaptions] = (0, import_react44.useState)(
|
|
68088
68368
|
() => existingConfig?.captions ?? []
|
|
68089
68369
|
);
|
|
68090
|
-
const [selectedProperty, setSelectedProperty] = (0,
|
|
68091
|
-
const propertyKeys = (0,
|
|
68370
|
+
const [selectedProperty, setSelectedProperty] = (0, import_react44.useState)("");
|
|
68371
|
+
const propertyKeys = (0, import_react44.useMemo)(() => {
|
|
68092
68372
|
if (isCategory) {
|
|
68093
68373
|
return api.types.getNodeTypeProperties(targetKey).map((p) => p.key);
|
|
68094
68374
|
}
|
|
68095
68375
|
return api.types.getEdgeTypeProperties(targetKey).map((p) => p.key);
|
|
68096
68376
|
}, [api, targetKey, isCategory]);
|
|
68097
|
-
const availableProperties = (0,
|
|
68377
|
+
const availableProperties = (0, import_react44.useMemo)(() => {
|
|
68098
68378
|
const usedSources = new Set(captions.map((c2) => c2.source));
|
|
68099
68379
|
return propertyKeys.filter((key) => !usedSources.has(`property:${key}`));
|
|
68100
68380
|
}, [propertyKeys, captions]);
|
|
68101
|
-
const activeProperty = (0,
|
|
68381
|
+
const activeProperty = (0, import_react44.useMemo)(() => {
|
|
68102
68382
|
if (selectedProperty && availableProperties.includes(selectedProperty)) return selectedProperty;
|
|
68103
68383
|
return availableProperties[0] ?? "";
|
|
68104
68384
|
}, [selectedProperty, availableProperties]);
|
|
68105
|
-
const applyToStore = (0,
|
|
68385
|
+
const applyToStore = (0, import_react44.useCallback)(
|
|
68106
68386
|
(newCaptions) => {
|
|
68107
68387
|
if (isCategory) {
|
|
68108
68388
|
const existing = store.visualMapper.getCategoryConfig(targetKey);
|
|
@@ -68131,7 +68411,7 @@ void main() {
|
|
|
68131
68411
|
},
|
|
68132
68412
|
[store, targetKey, isCategory]
|
|
68133
68413
|
);
|
|
68134
|
-
const handleAddProperty = (0,
|
|
68414
|
+
const handleAddProperty = (0, import_react44.useCallback)(() => {
|
|
68135
68415
|
if (!activeProperty) return;
|
|
68136
68416
|
const newDef = {
|
|
68137
68417
|
source: `property:${activeProperty}`,
|
|
@@ -68142,7 +68422,7 @@ void main() {
|
|
|
68142
68422
|
setSelectedProperty("");
|
|
68143
68423
|
applyToStore(updated);
|
|
68144
68424
|
}, [activeProperty, captions, applyToStore]);
|
|
68145
|
-
const handleRemoveCaption = (0,
|
|
68425
|
+
const handleRemoveCaption = (0, import_react44.useCallback)(
|
|
68146
68426
|
(index3) => {
|
|
68147
68427
|
const updated = captions.filter((_2, i) => i !== index3);
|
|
68148
68428
|
setCaptions(updated);
|
|
@@ -68150,7 +68430,7 @@ void main() {
|
|
|
68150
68430
|
},
|
|
68151
68431
|
[captions, applyToStore]
|
|
68152
68432
|
);
|
|
68153
|
-
const handleClearAll = (0,
|
|
68433
|
+
const handleClearAll = (0, import_react44.useCallback)(() => {
|
|
68154
68434
|
setCaptions([]);
|
|
68155
68435
|
applyToStore([]);
|
|
68156
68436
|
}, [applyToStore]);
|
|
@@ -68233,7 +68513,7 @@ void main() {
|
|
|
68233
68513
|
width: "legend.tab.width"
|
|
68234
68514
|
};
|
|
68235
68515
|
function useBlockNativeSceneEvents4(ref) {
|
|
68236
|
-
(0,
|
|
68516
|
+
(0, import_react45.useEffect)(() => {
|
|
68237
68517
|
const el = ref.current;
|
|
68238
68518
|
if (!el) return;
|
|
68239
68519
|
const stop = (e) => e.stopPropagation();
|
|
@@ -68257,17 +68537,17 @@ void main() {
|
|
|
68257
68537
|
}) {
|
|
68258
68538
|
const { t } = useLegendIntl();
|
|
68259
68539
|
const tabs = isCategory ? [...CATEGORY_TABS] : [...RELATIONSHIP_TABS];
|
|
68260
|
-
const [activeTab, setActiveTab] = (0,
|
|
68261
|
-
const headerRef = (0,
|
|
68262
|
-
const dragTransformRef = (0,
|
|
68540
|
+
const [activeTab, setActiveTab] = (0, import_react45.useState)(tabs[0]);
|
|
68541
|
+
const headerRef = (0, import_react45.useRef)(null);
|
|
68542
|
+
const dragTransformRef = (0, import_react45.useRef)({ x: 0, y: 0 });
|
|
68263
68543
|
const visualMapper = store.visualMapper;
|
|
68264
68544
|
const dotColor = isCategory ? visualMapper.categoryColors.getColor(targetKey) : visualMapper.relationshipColors.getColor(targetKey);
|
|
68265
68545
|
useBlockNativeSceneEvents4(popoverRef);
|
|
68266
|
-
(0,
|
|
68546
|
+
(0, import_react45.useEffect)(() => {
|
|
68267
68547
|
dragTransformRef.current = { x: 0, y: 0 };
|
|
68268
68548
|
if (popoverRef.current) popoverRef.current.style.transform = "";
|
|
68269
68549
|
}, [targetKey, popoverRef]);
|
|
68270
|
-
(0,
|
|
68550
|
+
(0, import_react45.useEffect)(() => {
|
|
68271
68551
|
const header = headerRef.current;
|
|
68272
68552
|
if (!header) return;
|
|
68273
68553
|
const onMouseDown = (e) => {
|
|
@@ -68362,16 +68642,16 @@ void main() {
|
|
|
68362
68642
|
var import_jsx_runtime42 = __toESM(require_jsx_runtime());
|
|
68363
68643
|
var OVERFLOW_THRESHOLD = 20;
|
|
68364
68644
|
function LegendPanel({ store, api, visible = true, messages, minimapVisible = false, iconAtlasManager }) {
|
|
68365
|
-
const t = (0,
|
|
68645
|
+
const t = (0, import_react46.useCallback)(
|
|
68366
68646
|
(key, params) => getMessage(messages, key, params),
|
|
68367
68647
|
[messages]
|
|
68368
68648
|
);
|
|
68369
|
-
const i18nValue = (0,
|
|
68649
|
+
const i18nValue = (0, import_react46.useMemo)(() => ({ t }), [t]);
|
|
68370
68650
|
const { categories, relationships } = useLegendData(store, api);
|
|
68371
68651
|
const popover = usePopover();
|
|
68372
|
-
const [expandedCategories, setExpandedCategories] = (0,
|
|
68373
|
-
const [expandedRelationships, setExpandedRelationships] = (0,
|
|
68374
|
-
const handleCategorySelect = (0,
|
|
68652
|
+
const [expandedCategories, setExpandedCategories] = (0, import_react46.useState)(false);
|
|
68653
|
+
const [expandedRelationships, setExpandedRelationships] = (0, import_react46.useState)(false);
|
|
68654
|
+
const handleCategorySelect = (0, import_react46.useCallback)(
|
|
68375
68655
|
(name) => {
|
|
68376
68656
|
const nodes = store.queries.getNodesByCategory(name);
|
|
68377
68657
|
const ids = nodes.map((n) => n.id);
|
|
@@ -68379,7 +68659,7 @@ void main() {
|
|
|
68379
68659
|
},
|
|
68380
68660
|
[store, api]
|
|
68381
68661
|
);
|
|
68382
|
-
const handleRelationshipSelect = (0,
|
|
68662
|
+
const handleRelationshipSelect = (0, import_react46.useCallback)(
|
|
68383
68663
|
(name) => {
|
|
68384
68664
|
const edges = store.queries.getEdgesByRelationship(name);
|
|
68385
68665
|
const ids = edges.map((e) => e.id);
|
|
@@ -68387,7 +68667,7 @@ void main() {
|
|
|
68387
68667
|
},
|
|
68388
68668
|
[store, api]
|
|
68389
68669
|
);
|
|
68390
|
-
const handleEditClick = (0,
|
|
68670
|
+
const handleEditClick = (0, import_react46.useCallback)(
|
|
68391
68671
|
(key, anchorEl) => {
|
|
68392
68672
|
popover.toggle(key, anchorEl);
|
|
68393
68673
|
},
|
|
@@ -68395,18 +68675,18 @@ void main() {
|
|
|
68395
68675
|
);
|
|
68396
68676
|
const isEmpty = categories.length === 0 && relationships.length === 0;
|
|
68397
68677
|
const isHidden2 = !visible || isEmpty;
|
|
68398
|
-
const visibleCategories = (0,
|
|
68678
|
+
const visibleCategories = (0, import_react46.useMemo)(() => {
|
|
68399
68679
|
if (expandedCategories || categories.length <= OVERFLOW_THRESHOLD) return categories;
|
|
68400
68680
|
return categories.slice(0, OVERFLOW_THRESHOLD);
|
|
68401
68681
|
}, [categories, expandedCategories]);
|
|
68402
68682
|
const hiddenCategoryCount = categories.length - visibleCategories.length;
|
|
68403
|
-
const visibleRelationships = (0,
|
|
68683
|
+
const visibleRelationships = (0, import_react46.useMemo)(() => {
|
|
68404
68684
|
if (expandedRelationships || relationships.length <= OVERFLOW_THRESHOLD) return relationships;
|
|
68405
68685
|
return relationships.slice(0, OVERFLOW_THRESHOLD);
|
|
68406
68686
|
}, [relationships, expandedRelationships]);
|
|
68407
68687
|
const hiddenRelationshipCount = relationships.length - visibleRelationships.length;
|
|
68408
|
-
const scrollRef = (0,
|
|
68409
|
-
(0,
|
|
68688
|
+
const scrollRef = (0, import_react46.useRef)(null);
|
|
68689
|
+
(0, import_react46.useEffect)(() => {
|
|
68410
68690
|
const el = scrollRef.current;
|
|
68411
68691
|
if (!el) return;
|
|
68412
68692
|
const stop = (e) => e.stopPropagation();
|
|
@@ -70465,7 +70745,7 @@ void main() {
|
|
|
70465
70745
|
};
|
|
70466
70746
|
|
|
70467
70747
|
// src/react/interactionProps.ts
|
|
70468
|
-
var
|
|
70748
|
+
var import_react47 = __toESM(require_react());
|
|
70469
70749
|
function extractModifiers(e) {
|
|
70470
70750
|
return {
|
|
70471
70751
|
shift: e.shiftKey,
|
|
@@ -70557,15 +70837,15 @@ void main() {
|
|
|
70557
70837
|
}
|
|
70558
70838
|
}
|
|
70559
70839
|
function useEventCallbackRef(value) {
|
|
70560
|
-
const ref = (0,
|
|
70561
|
-
(0,
|
|
70840
|
+
const ref = (0, import_react47.useRef)(value);
|
|
70841
|
+
(0, import_react47.useEffect)(() => {
|
|
70562
70842
|
ref.current = value;
|
|
70563
70843
|
}, [value]);
|
|
70564
70844
|
return ref;
|
|
70565
70845
|
}
|
|
70566
70846
|
function useInteractionPropBridge(ctx, callbacks) {
|
|
70567
70847
|
const cbRef = useEventCallbackRef(callbacks);
|
|
70568
|
-
(0,
|
|
70848
|
+
(0, import_react47.useEffect)(() => {
|
|
70569
70849
|
if (!ctx?.interaction || !ctx?.camera || !ctx?.renderer) return;
|
|
70570
70850
|
const interaction = ctx.interaction;
|
|
70571
70851
|
const camera = ctx.camera;
|
|
@@ -70665,7 +70945,7 @@ void main() {
|
|
|
70665
70945
|
}
|
|
70666
70946
|
|
|
70667
70947
|
// src/react/lifecycleProps.ts
|
|
70668
|
-
var
|
|
70948
|
+
var import_react48 = __toESM(require_react());
|
|
70669
70949
|
function adaptAlgorithmErrorContext(payload) {
|
|
70670
70950
|
return {
|
|
70671
70951
|
source: "algorithm",
|
|
@@ -70711,15 +70991,15 @@ void main() {
|
|
|
70711
70991
|
};
|
|
70712
70992
|
}
|
|
70713
70993
|
function useEventCallbackRef2(value) {
|
|
70714
|
-
const ref = (0,
|
|
70715
|
-
(0,
|
|
70994
|
+
const ref = (0, import_react48.useRef)(value);
|
|
70995
|
+
(0, import_react48.useEffect)(() => {
|
|
70716
70996
|
ref.current = value;
|
|
70717
70997
|
}, [value]);
|
|
70718
70998
|
return ref;
|
|
70719
70999
|
}
|
|
70720
71000
|
function useLifecyclePropBridge(api, callbacks) {
|
|
70721
71001
|
const cbRef = useEventCallbackRef2(callbacks);
|
|
70722
|
-
(0,
|
|
71002
|
+
(0, import_react48.useEffect)(() => {
|
|
70723
71003
|
if (!api) return;
|
|
70724
71004
|
const unsub = [];
|
|
70725
71005
|
unsub.push(api.events.on("destroy", () => cbRef.current.onDestroy?.()));
|
|
@@ -70743,13 +71023,13 @@ void main() {
|
|
|
70743
71023
|
}
|
|
70744
71024
|
|
|
70745
71025
|
// src/react/controlledProps.ts
|
|
70746
|
-
var
|
|
71026
|
+
var import_react49 = __toESM(require_react());
|
|
70747
71027
|
var _controlledWarnCache = /* @__PURE__ */ new Set();
|
|
70748
71028
|
function useControlled(propName, controlled, defaultValue) {
|
|
70749
71029
|
const isControlled = controlled !== void 0;
|
|
70750
|
-
const [uncontrolledValue, setUncontrolledValue] = (0,
|
|
70751
|
-
const wasControlledRef = (0,
|
|
70752
|
-
(0,
|
|
71030
|
+
const [uncontrolledValue, setUncontrolledValue] = (0, import_react49.useState)(defaultValue);
|
|
71031
|
+
const wasControlledRef = (0, import_react49.useRef)(isControlled);
|
|
71032
|
+
(0, import_react49.useEffect)(() => {
|
|
70753
71033
|
if ((typeof globalThis !== "undefined" && globalThis.process?.env?.NODE_ENV) === "production") return;
|
|
70754
71034
|
if (wasControlledRef.current !== isControlled) {
|
|
70755
71035
|
if (!_controlledWarnCache.has(`${propName}-mode-switch`)) {
|
|
@@ -70773,8 +71053,8 @@ void main() {
|
|
|
70773
71053
|
controlled,
|
|
70774
71054
|
defaultValue ?? { nodes: [], edges: [] }
|
|
70775
71055
|
);
|
|
70776
|
-
const lastAppliedRef = (0,
|
|
70777
|
-
(0,
|
|
71056
|
+
const lastAppliedRef = (0, import_react49.useRef)(null);
|
|
71057
|
+
(0, import_react49.useEffect)(() => {
|
|
70778
71058
|
if (!api || !isControlled) return;
|
|
70779
71059
|
const last = lastAppliedRef.current;
|
|
70780
71060
|
if (last && last.nodes.length === value.nodes.length && last.edges.length === value.edges.length && last.nodes.every((id, i) => id === value.nodes[i]) && last.edges.every((id, i) => id === value.edges[i])) return;
|
|
@@ -70785,11 +71065,11 @@ void main() {
|
|
|
70785
71065
|
if (value.edges.length > 0) await api.selection.selectEdges(value.edges, "replace");
|
|
70786
71066
|
})();
|
|
70787
71067
|
}, [api, isControlled, value]);
|
|
70788
|
-
const onChangeRef = (0,
|
|
70789
|
-
(0,
|
|
71068
|
+
const onChangeRef = (0, import_react49.useRef)(onChange);
|
|
71069
|
+
(0, import_react49.useEffect)(() => {
|
|
70790
71070
|
onChangeRef.current = onChange;
|
|
70791
71071
|
}, [onChange]);
|
|
70792
|
-
(0,
|
|
71072
|
+
(0, import_react49.useEffect)(() => {
|
|
70793
71073
|
if (!api) return;
|
|
70794
71074
|
const unsub = api.events.on("selection:changed", (payload) => {
|
|
70795
71075
|
if (isControlled && payload.source === "api") return;
|
|
@@ -70816,8 +71096,8 @@ void main() {
|
|
|
70816
71096
|
if (toShow.length > 0) await api.nodes.show(toShow);
|
|
70817
71097
|
if (toHide.length > 0) await api.nodes.hide(toHide);
|
|
70818
71098
|
};
|
|
70819
|
-
const uncontrolledMountedRef = (0,
|
|
70820
|
-
(0,
|
|
71099
|
+
const uncontrolledMountedRef = (0, import_react49.useRef)(false);
|
|
71100
|
+
(0, import_react49.useEffect)(() => {
|
|
70821
71101
|
if (!api || isControlled || uncontrolledMountedRef.current) return;
|
|
70822
71102
|
uncontrolledMountedRef.current = true;
|
|
70823
71103
|
if (value.nodes.length === 0) return;
|
|
@@ -70825,19 +71105,19 @@ void main() {
|
|
|
70825
71105
|
const toHide = value.nodes.filter((id) => !current.has(id));
|
|
70826
71106
|
if (toHide.length > 0) void api.nodes.hide(toHide);
|
|
70827
71107
|
}, [api]);
|
|
70828
|
-
const lastAppliedRef = (0,
|
|
70829
|
-
(0,
|
|
71108
|
+
const lastAppliedRef = (0, import_react49.useRef)(null);
|
|
71109
|
+
(0, import_react49.useEffect)(() => {
|
|
70830
71110
|
if (!api || !isControlled) return;
|
|
70831
71111
|
const last = lastAppliedRef.current;
|
|
70832
71112
|
if (last && last.nodes.length === value.nodes.length && last.nodes.every((id, i) => id === value.nodes[i])) return;
|
|
70833
71113
|
lastAppliedRef.current = value;
|
|
70834
71114
|
void reconcile(value);
|
|
70835
71115
|
}, [api, isControlled, value]);
|
|
70836
|
-
const onChangeRef = (0,
|
|
70837
|
-
(0,
|
|
71116
|
+
const onChangeRef = (0, import_react49.useRef)(onChange);
|
|
71117
|
+
(0, import_react49.useEffect)(() => {
|
|
70838
71118
|
onChangeRef.current = onChange;
|
|
70839
71119
|
}, [onChange]);
|
|
70840
|
-
(0,
|
|
71120
|
+
(0, import_react49.useEffect)(() => {
|
|
70841
71121
|
if (!api) return;
|
|
70842
71122
|
const unsub = api.events.on("visibility:changed", (_payload) => {
|
|
70843
71123
|
const next = { nodes: api.store.getHiddenNodeIds(), edges: [] };
|
|
@@ -70851,23 +71131,23 @@ void main() {
|
|
|
70851
71131
|
}
|
|
70852
71132
|
function useControlledIs3D(api, controlled, defaultValue, onChange) {
|
|
70853
71133
|
const { value, isControlled, setUncontrolled } = useControlled("is3D", controlled, defaultValue);
|
|
70854
|
-
const uncontrolledMountedRef = (0,
|
|
70855
|
-
(0,
|
|
71134
|
+
const uncontrolledMountedRef = (0, import_react49.useRef)(false);
|
|
71135
|
+
(0, import_react49.useEffect)(() => {
|
|
70856
71136
|
if (!api || isControlled || uncontrolledMountedRef.current) return;
|
|
70857
71137
|
uncontrolledMountedRef.current = true;
|
|
70858
71138
|
const targetDim = value ? 3 : 2;
|
|
70859
71139
|
if (api.getDimensions() !== targetDim) api.setDimensions(targetDim);
|
|
70860
71140
|
}, [api]);
|
|
70861
|
-
(0,
|
|
71141
|
+
(0, import_react49.useEffect)(() => {
|
|
70862
71142
|
if (!api || !isControlled) return;
|
|
70863
71143
|
const targetDim = value ? 3 : 2;
|
|
70864
71144
|
if (api.getDimensions() !== targetDim) api.setDimensions(targetDim);
|
|
70865
71145
|
}, [api, isControlled, value]);
|
|
70866
|
-
const onChangeRef = (0,
|
|
70867
|
-
(0,
|
|
71146
|
+
const onChangeRef = (0, import_react49.useRef)(onChange);
|
|
71147
|
+
(0, import_react49.useEffect)(() => {
|
|
70868
71148
|
onChangeRef.current = onChange;
|
|
70869
71149
|
}, [onChange]);
|
|
70870
|
-
(0,
|
|
71150
|
+
(0, import_react49.useEffect)(() => {
|
|
70871
71151
|
if (!api) return;
|
|
70872
71152
|
const unsub = api.events.on("view:changed", (payload) => {
|
|
70873
71153
|
if (payload.mode === void 0) return;
|
|
@@ -70886,21 +71166,21 @@ void main() {
|
|
|
70886
71166
|
controlled,
|
|
70887
71167
|
defaultValue ?? "dark"
|
|
70888
71168
|
);
|
|
70889
|
-
const uncontrolledMountedRef = (0,
|
|
70890
|
-
(0,
|
|
71169
|
+
const uncontrolledMountedRef = (0, import_react49.useRef)(false);
|
|
71170
|
+
(0, import_react49.useEffect)(() => {
|
|
70891
71171
|
if (!api || isControlled || uncontrolledMountedRef.current) return;
|
|
70892
71172
|
uncontrolledMountedRef.current = true;
|
|
70893
71173
|
api.renderer.setTheme(value);
|
|
70894
71174
|
}, [api]);
|
|
70895
|
-
(0,
|
|
71175
|
+
(0, import_react49.useEffect)(() => {
|
|
70896
71176
|
if (!api || !isControlled) return;
|
|
70897
71177
|
api.renderer.setTheme(value);
|
|
70898
71178
|
}, [api, isControlled, value]);
|
|
70899
|
-
const onChangeRef = (0,
|
|
70900
|
-
(0,
|
|
71179
|
+
const onChangeRef = (0, import_react49.useRef)(onChange);
|
|
71180
|
+
(0, import_react49.useEffect)(() => {
|
|
70901
71181
|
onChangeRef.current = onChange;
|
|
70902
71182
|
}, [onChange]);
|
|
70903
|
-
(0,
|
|
71183
|
+
(0, import_react49.useEffect)(() => {
|
|
70904
71184
|
if (!api) return;
|
|
70905
71185
|
const unsub = api.events.on("view:changed", (payload) => {
|
|
70906
71186
|
if (payload.theme === void 0) return;
|
|
@@ -70931,26 +71211,26 @@ void main() {
|
|
|
70931
71211
|
defaultValue ?? { position: [0, 0, -15], cameraZ: 1e-3 }
|
|
70932
71212
|
);
|
|
70933
71213
|
const explicitDefault = defaultValue !== void 0;
|
|
70934
|
-
const uncontrolledMountedRef = (0,
|
|
70935
|
-
(0,
|
|
71214
|
+
const uncontrolledMountedRef = (0, import_react49.useRef)(false);
|
|
71215
|
+
(0, import_react49.useEffect)(() => {
|
|
70936
71216
|
if (!api || isControlled || uncontrolledMountedRef.current) return;
|
|
70937
71217
|
if (!explicitDefault) return;
|
|
70938
71218
|
uncontrolledMountedRef.current = true;
|
|
70939
71219
|
api.camera.setViewState(value);
|
|
70940
71220
|
}, [api]);
|
|
70941
|
-
const lastAppliedRef = (0,
|
|
70942
|
-
(0,
|
|
71221
|
+
const lastAppliedRef = (0, import_react49.useRef)(null);
|
|
71222
|
+
(0, import_react49.useEffect)(() => {
|
|
70943
71223
|
if (!api || !isControlled) return;
|
|
70944
71224
|
if (viewStateEqual(lastAppliedRef.current, value)) return;
|
|
70945
71225
|
lastAppliedRef.current = value;
|
|
70946
71226
|
api.camera.setViewState(value);
|
|
70947
71227
|
}, [api, isControlled, value]);
|
|
70948
|
-
const onChangeRef = (0,
|
|
70949
|
-
(0,
|
|
71228
|
+
const onChangeRef = (0, import_react49.useRef)(onChange);
|
|
71229
|
+
(0, import_react49.useEffect)(() => {
|
|
70950
71230
|
onChangeRef.current = onChange;
|
|
70951
71231
|
}, [onChange]);
|
|
70952
71232
|
const hasOnChange = !!onChange;
|
|
70953
|
-
(0,
|
|
71233
|
+
(0, import_react49.useEffect)(() => {
|
|
70954
71234
|
if (!api || !hasOnChange) return;
|
|
70955
71235
|
let raf = 0;
|
|
70956
71236
|
let prev = api.camera.getViewState();
|
|
@@ -70986,25 +71266,25 @@ void main() {
|
|
|
70986
71266
|
if (toUnpin.length > 0) await api.nodes.unpin(toUnpin);
|
|
70987
71267
|
if (toPin.length > 0) await api.nodes.pin(toPin);
|
|
70988
71268
|
};
|
|
70989
|
-
const uncontrolledMountedRef = (0,
|
|
70990
|
-
(0,
|
|
71269
|
+
const uncontrolledMountedRef = (0, import_react49.useRef)(false);
|
|
71270
|
+
(0, import_react49.useEffect)(() => {
|
|
70991
71271
|
if (!api || isControlled || uncontrolledMountedRef.current) return;
|
|
70992
71272
|
uncontrolledMountedRef.current = true;
|
|
70993
71273
|
void reconcile(value);
|
|
70994
71274
|
}, [api]);
|
|
70995
|
-
const lastAppliedRef = (0,
|
|
70996
|
-
(0,
|
|
71275
|
+
const lastAppliedRef = (0, import_react49.useRef)(null);
|
|
71276
|
+
(0, import_react49.useEffect)(() => {
|
|
70997
71277
|
if (!api || !isControlled) return;
|
|
70998
71278
|
const last = lastAppliedRef.current;
|
|
70999
71279
|
if (last && last.nodes.length === value.nodes.length && last.nodes.every((id, i) => id === value.nodes[i])) return;
|
|
71000
71280
|
lastAppliedRef.current = value;
|
|
71001
71281
|
void reconcile(value);
|
|
71002
71282
|
}, [api, isControlled, value]);
|
|
71003
|
-
const onChangeRef = (0,
|
|
71004
|
-
(0,
|
|
71283
|
+
const onChangeRef = (0, import_react49.useRef)(onChange);
|
|
71284
|
+
(0, import_react49.useEffect)(() => {
|
|
71005
71285
|
onChangeRef.current = onChange;
|
|
71006
71286
|
}, [onChange]);
|
|
71007
|
-
(0,
|
|
71287
|
+
(0, import_react49.useEffect)(() => {
|
|
71008
71288
|
if (!api) return;
|
|
71009
71289
|
const unsub = api.events.on("pin:changed", (payload) => {
|
|
71010
71290
|
const next = { nodes: payload.nodeIds, edges: [] };
|
|
@@ -71018,18 +71298,18 @@ void main() {
|
|
|
71018
71298
|
}
|
|
71019
71299
|
function useControlledHover(api, controlled, onChange) {
|
|
71020
71300
|
const isControlled = controlled !== void 0;
|
|
71021
|
-
const lastWriteRef = (0,
|
|
71022
|
-
(0,
|
|
71301
|
+
const lastWriteRef = (0, import_react49.useRef)(null);
|
|
71302
|
+
(0, import_react49.useEffect)(() => {
|
|
71023
71303
|
if (!api || !isControlled) return;
|
|
71024
71304
|
const target = controlled ?? null;
|
|
71025
71305
|
lastWriteRef.current = target;
|
|
71026
71306
|
api.hover.set(target);
|
|
71027
71307
|
}, [api, isControlled, controlled]);
|
|
71028
|
-
const onChangeRef = (0,
|
|
71029
|
-
(0,
|
|
71308
|
+
const onChangeRef = (0, import_react49.useRef)(onChange);
|
|
71309
|
+
(0, import_react49.useEffect)(() => {
|
|
71030
71310
|
onChangeRef.current = onChange;
|
|
71031
71311
|
}, [onChange]);
|
|
71032
|
-
(0,
|
|
71312
|
+
(0, import_react49.useEffect)(() => {
|
|
71033
71313
|
if (!api) return;
|
|
71034
71314
|
const lastObservedRef = { current: null };
|
|
71035
71315
|
const unsub = api.interaction.hover.onChange((hover) => {
|
|
@@ -71076,7 +71356,7 @@ void main() {
|
|
|
71076
71356
|
};
|
|
71077
71357
|
|
|
71078
71358
|
// src/react/graph-context/propResolvers.ts
|
|
71079
|
-
var
|
|
71359
|
+
var import_react50 = __toESM(require_react());
|
|
71080
71360
|
var _aliasWarnCache = /* @__PURE__ */ new Set();
|
|
71081
71361
|
function resolveAliasProp(newName, oldName, newVal, oldVal, defaultVal) {
|
|
71082
71362
|
if (newVal === void 0 && oldVal === void 0) return defaultVal;
|
|
@@ -71151,8 +71431,8 @@ void main() {
|
|
|
71151
71431
|
}
|
|
71152
71432
|
function hasManualMapLayer(children) {
|
|
71153
71433
|
let found = false;
|
|
71154
|
-
|
|
71155
|
-
if (!
|
|
71434
|
+
import_react50.default.Children.forEach(children, (child) => {
|
|
71435
|
+
if (!import_react50.default.isValidElement(child)) return;
|
|
71156
71436
|
if (child.type === FlatLayer || child.type === GlobeLayer) found = true;
|
|
71157
71437
|
});
|
|
71158
71438
|
return found;
|
|
@@ -84023,6 +84303,19 @@ void main() {
|
|
|
84023
84303
|
return { lat: coords.latitude, lng: coords.longitude };
|
|
84024
84304
|
}
|
|
84025
84305
|
}
|
|
84306
|
+
/**
|
|
84307
|
+
* Convert a true ground distance (km) at a given latitude into world/scene
|
|
84308
|
+
* units, matching how node positions are placed (Mercator meters × mapScale).
|
|
84309
|
+
* Web Mercator inflates ground distance by 1/cos(lat); we divide by cos(lat) so
|
|
84310
|
+
* a circle of this radius covers the correct ground area on the basemap.
|
|
84311
|
+
* With no map active, mapScale is the default-provider scale (1).
|
|
84312
|
+
*/
|
|
84313
|
+
groundKmToWorld(km, latitudeDeg) {
|
|
84314
|
+
const scale = this._defaultCoordProvider.getScale();
|
|
84315
|
+
const cos = Math.cos(latitudeDeg * Math.PI / 180);
|
|
84316
|
+
const safeCos = Math.abs(cos) < 1e-6 ? 1e-6 : cos;
|
|
84317
|
+
return km * 1e3 / safeCos * scale;
|
|
84318
|
+
}
|
|
84026
84319
|
/**
|
|
84027
84320
|
* Convert lat/lng to screen pixel coordinates `{ x, y }` in the canvas.
|
|
84028
84321
|
*
|
|
@@ -85264,6 +85557,399 @@ void main() {
|
|
|
85264
85557
|
}
|
|
85265
85558
|
};
|
|
85266
85559
|
|
|
85560
|
+
// src/api/modules/LayersApi.ts
|
|
85561
|
+
var LayersApi = class {
|
|
85562
|
+
constructor() {
|
|
85563
|
+
this.hostRef = null;
|
|
85564
|
+
this.mounted = /* @__PURE__ */ new Map();
|
|
85565
|
+
this.pending = [];
|
|
85566
|
+
}
|
|
85567
|
+
mount(name, factory, config, opts) {
|
|
85568
|
+
if (!this.hostRef) {
|
|
85569
|
+
this.pending.push({ name, factory, config, opts });
|
|
85570
|
+
return;
|
|
85571
|
+
}
|
|
85572
|
+
if (this.mounted.has(name)) this.unmount(name);
|
|
85573
|
+
const handle = mountEngineLayer(this.hostRef, name, factory, config, opts);
|
|
85574
|
+
this.mounted.set(name, handle);
|
|
85575
|
+
}
|
|
85576
|
+
update(name, config) {
|
|
85577
|
+
const pend = this.pending.find((p) => p.name === name);
|
|
85578
|
+
if (pend) {
|
|
85579
|
+
pend.config = config;
|
|
85580
|
+
return;
|
|
85581
|
+
}
|
|
85582
|
+
this.mounted.get(name)?.update(config);
|
|
85583
|
+
}
|
|
85584
|
+
unmount(name) {
|
|
85585
|
+
this.pending = this.pending.filter((p) => p.name !== name);
|
|
85586
|
+
this.mounted.get(name)?.dispose();
|
|
85587
|
+
this.mounted.delete(name);
|
|
85588
|
+
}
|
|
85589
|
+
has(name) {
|
|
85590
|
+
return this.mounted.has(name) || this.pending.some((p) => p.name === name);
|
|
85591
|
+
}
|
|
85592
|
+
list() {
|
|
85593
|
+
return [...this.mounted.keys(), ...this.pending.map((p) => p.name)];
|
|
85594
|
+
}
|
|
85595
|
+
/**
|
|
85596
|
+
* @internal Wired by <LayerHost> on mount; pass null on unmount to tear everything down.
|
|
85597
|
+
*
|
|
85598
|
+
* When called with a NEW non-null host (replacing a previous host), all currently-mounted
|
|
85599
|
+
* layers are disposed and discarded — they are NOT re-mounted under the new host (factories
|
|
85600
|
+
* are not retained past mount). Only mounts still in the `pending` queue (i.e. issued before
|
|
85601
|
+
* the first host was wired) are (re)hydrated under the new host. In the current single-
|
|
85602
|
+
* `<LayerHost>` topology a host is wired once and never replaced, so this path is not
|
|
85603
|
+
* exercised in production; callers needing layers to survive a host replacement must
|
|
85604
|
+
* re-mount them externally.
|
|
85605
|
+
*/
|
|
85606
|
+
_wireHost(host) {
|
|
85607
|
+
if (host === this.hostRef) return;
|
|
85608
|
+
for (const h of this.mounted.values()) h.dispose();
|
|
85609
|
+
this.mounted.clear();
|
|
85610
|
+
this.hostRef = host;
|
|
85611
|
+
if (!host) return;
|
|
85612
|
+
const queued = this.pending;
|
|
85613
|
+
this.pending = [];
|
|
85614
|
+
for (const p of queued) this.mount(p.name, p.factory, p.config, p.opts);
|
|
85615
|
+
}
|
|
85616
|
+
};
|
|
85617
|
+
|
|
85618
|
+
// src/coverage/CoverageRenderer.ts
|
|
85619
|
+
var CORNERS2 = [
|
|
85620
|
+
[-0.5, 0.5],
|
|
85621
|
+
[0.5, 0.5],
|
|
85622
|
+
[0.5, -0.5],
|
|
85623
|
+
[-0.5, -0.5]
|
|
85624
|
+
];
|
|
85625
|
+
var CoverageRenderer = class {
|
|
85626
|
+
constructor() {
|
|
85627
|
+
this.maxItems = 256;
|
|
85628
|
+
this.ctx = null;
|
|
85629
|
+
this.geometry = null;
|
|
85630
|
+
this.material = null;
|
|
85631
|
+
this.mesh = null;
|
|
85632
|
+
this.items = [];
|
|
85633
|
+
this.hasPulse = false;
|
|
85634
|
+
this.time = 0;
|
|
85635
|
+
// Per-vertex attribute backing arrays (capacity = maxItems * 4 verts).
|
|
85636
|
+
this.positions = null;
|
|
85637
|
+
// static quad corners (xy = corner, z = 0)
|
|
85638
|
+
this.aCenter = null;
|
|
85639
|
+
// 3 per vert
|
|
85640
|
+
this.aRadius = null;
|
|
85641
|
+
// 1 per vert
|
|
85642
|
+
this.aColor = null;
|
|
85643
|
+
// 3 per vert (fill RGB)
|
|
85644
|
+
this.aFillOpacity = null;
|
|
85645
|
+
// 1 per vert
|
|
85646
|
+
this.aFalloff = null;
|
|
85647
|
+
// 1 per vert
|
|
85648
|
+
this.aRingColor = null;
|
|
85649
|
+
// 3 per vert
|
|
85650
|
+
this.aRingWidth = null;
|
|
85651
|
+
// 1 per vert
|
|
85652
|
+
this.aRingOpacity = null;
|
|
85653
|
+
// 1 per vert (independent of fillOpacity)
|
|
85654
|
+
this.aPulse = null;
|
|
85655
|
+
// 3 per vert (flag, speed, rings)
|
|
85656
|
+
this.aDim = null;
|
|
85657
|
+
// 1 per vert: anchor node render opacity (focus/click-dim)
|
|
85658
|
+
this.aSelected = null;
|
|
85659
|
+
}
|
|
85660
|
+
// 1 per vert: anchor node selected flag (0/1)
|
|
85661
|
+
mount(ctx) {
|
|
85662
|
+
this.ctx = ctx;
|
|
85663
|
+
const cap = this.maxItems * 4;
|
|
85664
|
+
const geometry = new BufferGeometry();
|
|
85665
|
+
this.positions = new Float32Array(cap * 3);
|
|
85666
|
+
for (let v = 0; v < cap; v++) {
|
|
85667
|
+
const c2 = CORNERS2[v % 4];
|
|
85668
|
+
this.positions[v * 3] = c2[0];
|
|
85669
|
+
this.positions[v * 3 + 1] = c2[1];
|
|
85670
|
+
this.positions[v * 3 + 2] = 0;
|
|
85671
|
+
}
|
|
85672
|
+
geometry.setAttribute("position", new Float32BufferAttribute(this.positions, 3));
|
|
85673
|
+
const dyn = (array, itemSize) => {
|
|
85674
|
+
const attr = new BufferAttribute(array, itemSize);
|
|
85675
|
+
attr.setUsage(DynamicDrawUsage);
|
|
85676
|
+
return attr;
|
|
85677
|
+
};
|
|
85678
|
+
this.aCenter = new Float32Array(cap * 3);
|
|
85679
|
+
this.aRadius = new Float32Array(cap);
|
|
85680
|
+
this.aColor = new Float32Array(cap * 3);
|
|
85681
|
+
this.aFillOpacity = new Float32Array(cap);
|
|
85682
|
+
this.aFalloff = new Float32Array(cap);
|
|
85683
|
+
this.aRingColor = new Float32Array(cap * 3);
|
|
85684
|
+
this.aRingWidth = new Float32Array(cap);
|
|
85685
|
+
this.aRingOpacity = new Float32Array(cap);
|
|
85686
|
+
this.aPulse = new Float32Array(cap * 3);
|
|
85687
|
+
this.aDim = new Float32Array(cap).fill(1);
|
|
85688
|
+
this.aSelected = new Float32Array(cap);
|
|
85689
|
+
geometry.setAttribute("aCenter", dyn(this.aCenter, 3));
|
|
85690
|
+
geometry.setAttribute("aRadius", dyn(this.aRadius, 1));
|
|
85691
|
+
geometry.setAttribute("aColor", dyn(this.aColor, 3));
|
|
85692
|
+
geometry.setAttribute("aFillOpacity", dyn(this.aFillOpacity, 1));
|
|
85693
|
+
geometry.setAttribute("aFalloff", dyn(this.aFalloff, 1));
|
|
85694
|
+
geometry.setAttribute("aRingColor", dyn(this.aRingColor, 3));
|
|
85695
|
+
geometry.setAttribute("aRingWidth", dyn(this.aRingWidth, 1));
|
|
85696
|
+
geometry.setAttribute("aRingOpacity", dyn(this.aRingOpacity, 1));
|
|
85697
|
+
geometry.setAttribute("aPulse", dyn(this.aPulse, 3));
|
|
85698
|
+
geometry.setAttribute("aDim", dyn(this.aDim, 1));
|
|
85699
|
+
geometry.setAttribute("aSelected", dyn(this.aSelected, 1));
|
|
85700
|
+
const indices = new Uint16Array(this.maxItems * 6);
|
|
85701
|
+
for (let i = 0; i < this.maxItems; i++) {
|
|
85702
|
+
const b = i * 4;
|
|
85703
|
+
const o = i * 6;
|
|
85704
|
+
indices[o] = b;
|
|
85705
|
+
indices[o + 1] = b + 1;
|
|
85706
|
+
indices[o + 2] = b + 2;
|
|
85707
|
+
indices[o + 3] = b;
|
|
85708
|
+
indices[o + 4] = b + 2;
|
|
85709
|
+
indices[o + 5] = b + 3;
|
|
85710
|
+
}
|
|
85711
|
+
geometry.setIndex(new BufferAttribute(indices, 1));
|
|
85712
|
+
geometry.setDrawRange(0, 0);
|
|
85713
|
+
const material = new ShaderMaterial({
|
|
85714
|
+
vertexShader: coverageVertexShader,
|
|
85715
|
+
fragmentShader: coverageFragmentShader,
|
|
85716
|
+
uniforms: {
|
|
85717
|
+
uTime: { value: 0 },
|
|
85718
|
+
// Colour of the selection marker — a dashed radius spoke drawn from the
|
|
85719
|
+
// disc centre to its edge (default white); makes the selected coverage
|
|
85720
|
+
// stand out from focus-highlighted neighbours.
|
|
85721
|
+
uSelectedColor: { value: new Vector3(1, 1, 1) }
|
|
85722
|
+
},
|
|
85723
|
+
// Transparent alpha-blended overlay. depthTest OFF: avoid precision fighting
|
|
85724
|
+
// with the basemap tiles (same NDC depth range, same rationale as MarkerRenderer).
|
|
85725
|
+
transparent: true,
|
|
85726
|
+
depthWrite: false,
|
|
85727
|
+
depthTest: false,
|
|
85728
|
+
// DoubleSide: flat quads can face away after projection depending on view.
|
|
85729
|
+
side: DoubleSide
|
|
85730
|
+
});
|
|
85731
|
+
const mesh = new Mesh(geometry, material);
|
|
85732
|
+
mesh.frustumCulled = false;
|
|
85733
|
+
mesh.name = "CoverageRenderer";
|
|
85734
|
+
mesh.renderOrder = ctx.renderOrder("overlay", 1);
|
|
85735
|
+
this.geometry = geometry;
|
|
85736
|
+
this.material = material;
|
|
85737
|
+
this.mesh = mesh;
|
|
85738
|
+
ctx.cloudScene.add(mesh);
|
|
85739
|
+
}
|
|
85740
|
+
update(config) {
|
|
85741
|
+
const ctx = this.ctx;
|
|
85742
|
+
if (!ctx || !this.geometry) return;
|
|
85743
|
+
this.items = (config.items ?? []).slice(0, this.maxItems);
|
|
85744
|
+
this.hasPulse = this.items.some((it) => !!it.pulse);
|
|
85745
|
+
const positions = ctx.store.positionProvider?.getPositions() ?? null;
|
|
85746
|
+
const index3 = ctx.store.index;
|
|
85747
|
+
const selArr = ctx.store.nodeState?.selected ?? null;
|
|
85748
|
+
const aCenter = this.aCenter;
|
|
85749
|
+
const aRadius = this.aRadius;
|
|
85750
|
+
const aColor = this.aColor;
|
|
85751
|
+
const aFillOpacity = this.aFillOpacity;
|
|
85752
|
+
const aFalloff = this.aFalloff;
|
|
85753
|
+
const aRingColor = this.aRingColor;
|
|
85754
|
+
const aRingWidth = this.aRingWidth;
|
|
85755
|
+
const aRingOpacity = this.aRingOpacity;
|
|
85756
|
+
const aPulse = this.aPulse;
|
|
85757
|
+
const aDim = this.aDim;
|
|
85758
|
+
const aSelected = this.aSelected;
|
|
85759
|
+
for (let i = 0; i < this.items.length; i++) {
|
|
85760
|
+
const it = this.items[i];
|
|
85761
|
+
let cx = 0, cy = 0, cz = 0;
|
|
85762
|
+
if (it.position) {
|
|
85763
|
+
[cx, cy, cz] = it.position;
|
|
85764
|
+
} else if (it.anchorNodeId && positions) {
|
|
85765
|
+
const ni = index3.getNodeIndex(it.anchorNodeId);
|
|
85766
|
+
if (ni !== void 0 && ni >= 0) {
|
|
85767
|
+
cx = positions[ni * 3];
|
|
85768
|
+
cy = positions[ni * 3 + 1];
|
|
85769
|
+
cz = positions[ni * 3 + 2];
|
|
85770
|
+
}
|
|
85771
|
+
}
|
|
85772
|
+
const dim = it.anchorNodeId ? ctx.getNodeOpacity(it.anchorNodeId) : 1;
|
|
85773
|
+
let selFlag = 0;
|
|
85774
|
+
if (it.anchorNodeId && selArr) {
|
|
85775
|
+
const sni = index3.getNodeIndex(it.anchorNodeId);
|
|
85776
|
+
if (sni !== void 0 && sni >= 0) selFlag = selArr[sni] > 0 ? 1 : 0;
|
|
85777
|
+
}
|
|
85778
|
+
const fillOpacity = it.fillOpacity ?? 0.25;
|
|
85779
|
+
const falloff = it.falloff ?? 2;
|
|
85780
|
+
const ringColor = it.ringColor ?? it.fillColor;
|
|
85781
|
+
const ringWidth = it.ringWidth ?? 0.04;
|
|
85782
|
+
const ringOpacity = it.ringOpacity ?? 0.8;
|
|
85783
|
+
const pulseFlag = it.pulse ? 1 : 0;
|
|
85784
|
+
const pulseSpeed = it.pulse?.speed ?? 0.5;
|
|
85785
|
+
const pulseRings = it.pulse?.rings ?? 2;
|
|
85786
|
+
for (let v = 0; v < 4; v++) {
|
|
85787
|
+
const vi = i * 4 + v;
|
|
85788
|
+
aCenter[vi * 3] = cx;
|
|
85789
|
+
aCenter[vi * 3 + 1] = cy;
|
|
85790
|
+
aCenter[vi * 3 + 2] = cz;
|
|
85791
|
+
aRadius[vi] = it.radius;
|
|
85792
|
+
aColor[vi * 3] = it.fillColor[0];
|
|
85793
|
+
aColor[vi * 3 + 1] = it.fillColor[1];
|
|
85794
|
+
aColor[vi * 3 + 2] = it.fillColor[2];
|
|
85795
|
+
aFillOpacity[vi] = fillOpacity;
|
|
85796
|
+
aFalloff[vi] = falloff;
|
|
85797
|
+
aRingColor[vi * 3] = ringColor[0];
|
|
85798
|
+
aRingColor[vi * 3 + 1] = ringColor[1];
|
|
85799
|
+
aRingColor[vi * 3 + 2] = ringColor[2];
|
|
85800
|
+
aRingWidth[vi] = ringWidth;
|
|
85801
|
+
aRingOpacity[vi] = ringOpacity;
|
|
85802
|
+
aPulse[vi * 3] = pulseFlag;
|
|
85803
|
+
aPulse[vi * 3 + 1] = pulseSpeed;
|
|
85804
|
+
aPulse[vi * 3 + 2] = pulseRings;
|
|
85805
|
+
aDim[vi] = dim;
|
|
85806
|
+
aSelected[vi] = selFlag;
|
|
85807
|
+
}
|
|
85808
|
+
}
|
|
85809
|
+
this.geometry.getAttribute("aCenter").needsUpdate = true;
|
|
85810
|
+
this.geometry.getAttribute("aRadius").needsUpdate = true;
|
|
85811
|
+
this.geometry.getAttribute("aColor").needsUpdate = true;
|
|
85812
|
+
this.geometry.getAttribute("aFillOpacity").needsUpdate = true;
|
|
85813
|
+
this.geometry.getAttribute("aFalloff").needsUpdate = true;
|
|
85814
|
+
this.geometry.getAttribute("aRingColor").needsUpdate = true;
|
|
85815
|
+
this.geometry.getAttribute("aRingWidth").needsUpdate = true;
|
|
85816
|
+
this.geometry.getAttribute("aRingOpacity").needsUpdate = true;
|
|
85817
|
+
this.geometry.getAttribute("aPulse").needsUpdate = true;
|
|
85818
|
+
this.geometry.getAttribute("aDim").needsUpdate = true;
|
|
85819
|
+
this.geometry.getAttribute("aSelected").needsUpdate = true;
|
|
85820
|
+
this.geometry.setDrawRange(0, this.items.length * 6);
|
|
85821
|
+
}
|
|
85822
|
+
frame(dt, ctx) {
|
|
85823
|
+
const geometry = this.geometry;
|
|
85824
|
+
if (!geometry) return false;
|
|
85825
|
+
let moved = false, dimmed = false, selChanged = false;
|
|
85826
|
+
const positions = ctx.store.positionProvider?.getPositions() ?? null;
|
|
85827
|
+
const index3 = ctx.store.index;
|
|
85828
|
+
const selArr = ctx.store.nodeState?.selected ?? null;
|
|
85829
|
+
const aCenter = this.aCenter;
|
|
85830
|
+
const aDim = this.aDim;
|
|
85831
|
+
const aSelected = this.aSelected;
|
|
85832
|
+
for (let i = 0; i < this.items.length; i++) {
|
|
85833
|
+
const it = this.items[i];
|
|
85834
|
+
if (!it.anchorNodeId) continue;
|
|
85835
|
+
const ni = index3.getNodeIndex(it.anchorNodeId);
|
|
85836
|
+
if (ni === void 0 || ni < 0) continue;
|
|
85837
|
+
if (positions) {
|
|
85838
|
+
const cx = positions[ni * 3];
|
|
85839
|
+
const cy = positions[ni * 3 + 1];
|
|
85840
|
+
const cz = positions[ni * 3 + 2];
|
|
85841
|
+
const base = i * 4 * 3;
|
|
85842
|
+
if (aCenter[base] !== cx || aCenter[base + 1] !== cy || aCenter[base + 2] !== cz) {
|
|
85843
|
+
for (let v = 0; v < 4; v++) {
|
|
85844
|
+
const o = (i * 4 + v) * 3;
|
|
85845
|
+
aCenter[o] = cx;
|
|
85846
|
+
aCenter[o + 1] = cy;
|
|
85847
|
+
aCenter[o + 2] = cz;
|
|
85848
|
+
}
|
|
85849
|
+
moved = true;
|
|
85850
|
+
}
|
|
85851
|
+
}
|
|
85852
|
+
const op = ctx.getNodeOpacity(it.anchorNodeId);
|
|
85853
|
+
if (Math.abs(aDim[i * 4] - op) > 1e-4) {
|
|
85854
|
+
for (let v = 0; v < 4; v++) aDim[i * 4 + v] = op;
|
|
85855
|
+
dimmed = true;
|
|
85856
|
+
}
|
|
85857
|
+
const sel = selArr && selArr[ni] > 0 ? 1 : 0;
|
|
85858
|
+
if (aSelected[i * 4] !== sel) {
|
|
85859
|
+
for (let v = 0; v < 4; v++) aSelected[i * 4 + v] = sel;
|
|
85860
|
+
selChanged = true;
|
|
85861
|
+
}
|
|
85862
|
+
}
|
|
85863
|
+
if (moved) geometry.getAttribute("aCenter").needsUpdate = true;
|
|
85864
|
+
if (dimmed) geometry.getAttribute("aDim").needsUpdate = true;
|
|
85865
|
+
if (selChanged) geometry.getAttribute("aSelected").needsUpdate = true;
|
|
85866
|
+
if (this.hasPulse && this.material) {
|
|
85867
|
+
this.time += dt;
|
|
85868
|
+
this.material.uniforms.uTime.value = this.time;
|
|
85869
|
+
}
|
|
85870
|
+
return this.hasPulse || moved || dimmed || selChanged;
|
|
85871
|
+
}
|
|
85872
|
+
dispose() {
|
|
85873
|
+
if (this.mesh && this.ctx) this.ctx.cloudScene.remove(this.mesh);
|
|
85874
|
+
this.geometry?.dispose();
|
|
85875
|
+
this.material?.dispose();
|
|
85876
|
+
this.geometry = null;
|
|
85877
|
+
this.material = null;
|
|
85878
|
+
this.mesh = null;
|
|
85879
|
+
this.ctx = null;
|
|
85880
|
+
this.items = [];
|
|
85881
|
+
this.positions = null;
|
|
85882
|
+
this.aCenter = null;
|
|
85883
|
+
this.aRadius = null;
|
|
85884
|
+
this.aColor = null;
|
|
85885
|
+
this.aFillOpacity = null;
|
|
85886
|
+
this.aFalloff = null;
|
|
85887
|
+
this.aRingColor = null;
|
|
85888
|
+
this.aRingWidth = null;
|
|
85889
|
+
this.aRingOpacity = null;
|
|
85890
|
+
this.aPulse = null;
|
|
85891
|
+
this.aDim = null;
|
|
85892
|
+
this.aSelected = null;
|
|
85893
|
+
}
|
|
85894
|
+
};
|
|
85895
|
+
|
|
85896
|
+
// src/api/modules/CoverageApi.ts
|
|
85897
|
+
var NAME3 = "coverage";
|
|
85898
|
+
var CoverageApi = class {
|
|
85899
|
+
constructor(layers, kmToWorld) {
|
|
85900
|
+
this.layers = layers;
|
|
85901
|
+
this.kmToWorld = kmToWorld;
|
|
85902
|
+
this.items = /* @__PURE__ */ new Map();
|
|
85903
|
+
}
|
|
85904
|
+
resolve(key, spec) {
|
|
85905
|
+
const radius = spec.radius != null ? spec.radius : spec.radiusKm != null ? this.kmToWorld(spec.radiusKm, spec.latitude ?? 0) : 0;
|
|
85906
|
+
if (spec.radius == null && spec.radiusKm == null) {
|
|
85907
|
+
console.warn(
|
|
85908
|
+
`[coverage] item "${key}" has neither radius nor radiusKm; it will be invisible (radius 0)`
|
|
85909
|
+
);
|
|
85910
|
+
}
|
|
85911
|
+
const { radiusKm: _rk, latitude: _lat, ...rest } = spec;
|
|
85912
|
+
return { ...rest, anchorNodeId: rest.anchorNodeId ?? key, radius };
|
|
85913
|
+
}
|
|
85914
|
+
/** Set (or replace) the coverage disc for a single node. */
|
|
85915
|
+
set(nodeId, spec) {
|
|
85916
|
+
this.items.set(nodeId, this.resolve(nodeId, { ...spec, anchorNodeId: nodeId }));
|
|
85917
|
+
this.flush();
|
|
85918
|
+
}
|
|
85919
|
+
/** Set (or replace) coverage discs for multiple nodes in one call. */
|
|
85920
|
+
setMany(specs) {
|
|
85921
|
+
for (const s of specs) {
|
|
85922
|
+
const key = s.anchorNodeId != null ? s.anchorNodeId : s.position != null ? `pos:${s.position.join(",")}` : `pos:${this.items.size}`;
|
|
85923
|
+
this.items.set(key, this.resolve(key, s));
|
|
85924
|
+
}
|
|
85925
|
+
this.flush();
|
|
85926
|
+
}
|
|
85927
|
+
/**
|
|
85928
|
+
* Remove coverage for a single node, or clear all coverage.
|
|
85929
|
+
* @param nodeId - When provided, removes only that node's disc. When omitted, clears all.
|
|
85930
|
+
*/
|
|
85931
|
+
clear(nodeId) {
|
|
85932
|
+
if (nodeId) {
|
|
85933
|
+
this.items.delete(nodeId);
|
|
85934
|
+
} else {
|
|
85935
|
+
this.items.clear();
|
|
85936
|
+
}
|
|
85937
|
+
this.flush();
|
|
85938
|
+
}
|
|
85939
|
+
flush() {
|
|
85940
|
+
const items = [...this.items.values()];
|
|
85941
|
+
if (items.length === 0) {
|
|
85942
|
+
this.layers.unmount(NAME3);
|
|
85943
|
+
return;
|
|
85944
|
+
}
|
|
85945
|
+
if (this.layers.has(NAME3)) {
|
|
85946
|
+
this.layers.update(NAME3, { items });
|
|
85947
|
+
} else {
|
|
85948
|
+
this.layers.mount(NAME3, () => new CoverageRenderer(), { items }, { frame: true });
|
|
85949
|
+
}
|
|
85950
|
+
}
|
|
85951
|
+
};
|
|
85952
|
+
|
|
85267
85953
|
// src/filter/DateParser.ts
|
|
85268
85954
|
var DATE_PATTERNS = [
|
|
85269
85955
|
// ISO 8601 with time: "2024-03-15T14:30:00Z" or "2024-03-15T14:30:00+08:00"
|
|
@@ -86617,6 +87303,8 @@ void main() {
|
|
|
86617
87303
|
);
|
|
86618
87304
|
this.overlays = new OverlaysApi(store, this.effectManager);
|
|
86619
87305
|
this.markers = new MarkersApi();
|
|
87306
|
+
this.layers = new LayersApi();
|
|
87307
|
+
this.coverage = new CoverageApi(this.layers, (km, lat) => this.map.groundKmToWorld(km, lat));
|
|
86620
87308
|
this.playback = new PlaybackApi(store, this.effectManager);
|
|
86621
87309
|
this.renderer = new RendererApi(this.events, interaction);
|
|
86622
87310
|
this.io = new IoApi(store, interaction, this.executor);
|
|
@@ -88173,17 +88861,8 @@ void main() {
|
|
|
88173
88861
|
*/
|
|
88174
88862
|
writeLocalPosition(nodeId, localPos) {
|
|
88175
88863
|
const index3 = this.store.index.getNodeIndex(nodeId);
|
|
88176
|
-
const provider = this.store.positionProvider;
|
|
88177
|
-
console.log("[DRAGDBG] writeLocalPosition", {
|
|
88178
|
-
nodeId,
|
|
88179
|
-
index: index3,
|
|
88180
|
-
providerType: provider?.constructor?.name,
|
|
88181
|
-
hasUpdatePosition: !!provider && "updatePosition" in provider && typeof provider.updatePosition === "function",
|
|
88182
|
-
hasWritePositions: !!provider && "writePositions" in provider && typeof provider.writePositions === "function",
|
|
88183
|
-
hasOnPositionsWritten: !!this._onPositionsWritten,
|
|
88184
|
-
pos: [localPos.x, localPos.y, localPos.z]
|
|
88185
|
-
});
|
|
88186
88864
|
if (index3 === void 0) return;
|
|
88865
|
+
const provider = this.store.positionProvider;
|
|
88187
88866
|
if (!provider) return;
|
|
88188
88867
|
if ("updatePosition" in provider && typeof provider.updatePosition === "function") {
|
|
88189
88868
|
provider.updatePosition(index3, localPos.x, localPos.y, localPos.z);
|
|
@@ -91610,7 +92289,7 @@ void main() {
|
|
|
91610
92289
|
}
|
|
91611
92290
|
|
|
91612
92291
|
// src/react/graph-context/usePropBridges.ts
|
|
91613
|
-
var
|
|
92292
|
+
var import_react51 = __toESM(require_react());
|
|
91614
92293
|
|
|
91615
92294
|
// src/icons/IconAtlasManager.ts
|
|
91616
92295
|
var SDF_FONT_SIZE = 96;
|
|
@@ -92126,19 +92805,19 @@ void main() {
|
|
|
92126
92805
|
imageAtlasManagerRef,
|
|
92127
92806
|
glyphAtlasManagerRef
|
|
92128
92807
|
} = args;
|
|
92129
|
-
(0,
|
|
92808
|
+
(0, import_react51.useEffect)(() => {
|
|
92130
92809
|
viewState.patch({ theme: resolvedTheme });
|
|
92131
92810
|
}, [resolvedTheme]);
|
|
92132
|
-
(0,
|
|
92811
|
+
(0, import_react51.useEffect)(() => {
|
|
92133
92812
|
viewState.patch({ textScale: textScaleProp, edgeTextScale: edgeTextScaleProp });
|
|
92134
92813
|
}, [textScaleProp, edgeTextScaleProp]);
|
|
92135
|
-
(0,
|
|
92814
|
+
(0, import_react51.useEffect)(() => {
|
|
92136
92815
|
viewState.patch({ isMapMode, mapDamping: mapDampingRef.current, mapSphereRadius: mapSphereRadiusRef.current });
|
|
92137
92816
|
}, [isMapMode]);
|
|
92138
|
-
(0,
|
|
92817
|
+
(0, import_react51.useEffect)(() => {
|
|
92139
92818
|
apiInstanceRef.current?.emphasis.setClickDimEnabled(!!clickDim);
|
|
92140
92819
|
}, [clickDim, contextValue]);
|
|
92141
|
-
(0,
|
|
92820
|
+
(0, import_react51.useEffect)(() => {
|
|
92142
92821
|
if (is3DProp === is3D) return;
|
|
92143
92822
|
setIs3DState(is3DProp);
|
|
92144
92823
|
const control = controlRef.current;
|
|
@@ -92165,8 +92844,8 @@ void main() {
|
|
|
92165
92844
|
edgeR.set3DMode(is3DProp);
|
|
92166
92845
|
}
|
|
92167
92846
|
}, [is3DProp]);
|
|
92168
|
-
const defaultDimAppliedRef = (0,
|
|
92169
|
-
(0,
|
|
92847
|
+
const defaultDimAppliedRef = (0, import_react51.useRef)(false);
|
|
92848
|
+
(0, import_react51.useEffect)(() => {
|
|
92170
92849
|
if (defaultDimAppliedRef.current) return;
|
|
92171
92850
|
if (is3DProp !== void 0) return;
|
|
92172
92851
|
if (defaultDim === void 0) return;
|
|
@@ -92174,22 +92853,22 @@ void main() {
|
|
|
92174
92853
|
defaultDimAppliedRef.current = true;
|
|
92175
92854
|
apiInstanceRef.current.setDimensions(defaultDim);
|
|
92176
92855
|
}, []);
|
|
92177
|
-
(0,
|
|
92856
|
+
(0, import_react51.useEffect)(() => {
|
|
92178
92857
|
const control = controlRef.current;
|
|
92179
92858
|
if (!control) return;
|
|
92180
92859
|
control.setEnablePan(effectiveEnableControl);
|
|
92181
92860
|
control.setEnableZoom(effectiveEnableControl);
|
|
92182
92861
|
control.setEnableRotate(effectiveEnableControl && is3DProp);
|
|
92183
92862
|
}, [effectiveEnableControl, is3DProp]);
|
|
92184
|
-
(0,
|
|
92863
|
+
(0, import_react51.useEffect)(() => {
|
|
92185
92864
|
viewState.patch({ is3D, effectiveMapProjection });
|
|
92186
92865
|
}, [is3D, effectiveMapProjection]);
|
|
92187
|
-
(0,
|
|
92866
|
+
(0, import_react51.useEffect)(() => {
|
|
92188
92867
|
if (apiInstanceRef.current) {
|
|
92189
92868
|
apiInstanceRef.current.map.wireIs3D(is3D);
|
|
92190
92869
|
}
|
|
92191
92870
|
}, [is3D]);
|
|
92192
|
-
(0,
|
|
92871
|
+
(0, import_react51.useEffect)(() => {
|
|
92193
92872
|
const mgr = new IconAtlasManager();
|
|
92194
92873
|
iconAtlasManagerRef.current = mgr;
|
|
92195
92874
|
const fonts = [MARKER_ICON_FONT, ...iconFonts ?? []];
|
|
@@ -92208,7 +92887,7 @@ void main() {
|
|
|
92208
92887
|
iconAtlasManagerRef.current = null;
|
|
92209
92888
|
};
|
|
92210
92889
|
}, [iconFonts]);
|
|
92211
|
-
(0,
|
|
92890
|
+
(0, import_react51.useEffect)(() => {
|
|
92212
92891
|
const mgr = new ImageAtlasManager();
|
|
92213
92892
|
imageAtlasManagerRef.current = mgr;
|
|
92214
92893
|
viewState.patch({ imageAtlasManager: mgr });
|
|
@@ -92218,7 +92897,7 @@ void main() {
|
|
|
92218
92897
|
imageAtlasManagerRef.current = null;
|
|
92219
92898
|
};
|
|
92220
92899
|
}, []);
|
|
92221
|
-
(0,
|
|
92900
|
+
(0, import_react51.useEffect)(() => {
|
|
92222
92901
|
const mgr = new GlyphAtlasManager();
|
|
92223
92902
|
glyphAtlasManagerRef.current = mgr;
|
|
92224
92903
|
viewState.patch({ glyphAtlasManager: mgr });
|
|
@@ -92366,9 +93045,9 @@ void main() {
|
|
|
92366
93045
|
position: initialPosition ?? [0, 0, -15],
|
|
92367
93046
|
cameraZ: cameraZ ?? 1e-3
|
|
92368
93047
|
} : void 0);
|
|
92369
|
-
const [viewMinimapVisible, setViewMinimapVisible] = (0,
|
|
92370
|
-
const [viewThemeOverride, setViewThemeOverride] = (0,
|
|
92371
|
-
const resolvedTheme =
|
|
93048
|
+
const [viewMinimapVisible, setViewMinimapVisible] = (0, import_react52.useState)(true);
|
|
93049
|
+
const [viewThemeOverride, setViewThemeOverride] = (0, import_react52.useState)(null);
|
|
93050
|
+
const resolvedTheme = import_react52.default.useMemo(() => {
|
|
92372
93051
|
if (typeof theme === "object" && theme !== null) return theme;
|
|
92373
93052
|
if (viewThemeOverride) return GraphThemes[viewThemeOverride];
|
|
92374
93053
|
if (typeof theme === "string") return GraphThemes[theme] || GraphThemes.dark;
|
|
@@ -92378,7 +93057,7 @@ void main() {
|
|
|
92378
93057
|
const luminance = 0.299 * r2 + 0.587 * g + 0.114 * b;
|
|
92379
93058
|
return { background: backgroundColor, isDark: luminance < 0.5 };
|
|
92380
93059
|
}, [theme, backgroundColor, viewThemeOverride]);
|
|
92381
|
-
const themeKey =
|
|
93060
|
+
const themeKey = import_react52.default.useMemo(() => {
|
|
92382
93061
|
if (typeof theme === "object" && theme !== null) {
|
|
92383
93062
|
return resolvedTheme.isDark ? "dark" : "light";
|
|
92384
93063
|
}
|
|
@@ -92391,7 +93070,7 @@ void main() {
|
|
|
92391
93070
|
}
|
|
92392
93071
|
return resolvedTheme.isDark ? "dark" : "light";
|
|
92393
93072
|
}, [theme, viewThemeOverride, resolvedTheme.isDark]);
|
|
92394
|
-
const resolvedProvider =
|
|
93073
|
+
const resolvedProvider = import_react52.default.useMemo(() => {
|
|
92395
93074
|
if (typeof mapProvider === "string" && mapProvider.length > 0) {
|
|
92396
93075
|
return mapProvider;
|
|
92397
93076
|
}
|
|
@@ -92407,38 +93086,38 @@ void main() {
|
|
|
92407
93086
|
return "cartoDark";
|
|
92408
93087
|
}, [mapProvider, theme, viewThemeOverride]);
|
|
92409
93088
|
const effectiveBackground = theme || viewThemeOverride ? resolvedTheme.background : backgroundColor;
|
|
92410
|
-
const [internalContainer, setInternalContainer] =
|
|
92411
|
-
const containerRef = (0,
|
|
92412
|
-
const rendererRef = (0,
|
|
92413
|
-
const sceneRef = (0,
|
|
92414
|
-
const cameraRef = (0,
|
|
92415
|
-
const cloudSceneRef = (0,
|
|
92416
|
-
const controlRef = (0,
|
|
92417
|
-
const interactionRef = (0,
|
|
92418
|
-
const apiInstanceRef = (0,
|
|
92419
|
-
const nodeRendererRef = (0,
|
|
92420
|
-
const edgeRendererRef = (0,
|
|
92421
|
-
const childNodeRendererRef = (0,
|
|
92422
|
-
const childEdgeRendererRef = (0,
|
|
92423
|
-
const frameCallbacksRef = (0,
|
|
92424
|
-
const mapModeCallbacksRef = (0,
|
|
92425
|
-
const mapMaxGrowthCallbacksRef = (0,
|
|
92426
|
-
const [isMapMode, setIsMapMode] =
|
|
92427
|
-
const mapDampingRef = (0,
|
|
92428
|
-
const mapSphereRadiusRef = (0,
|
|
92429
|
-
const mapProviderWarnedRef =
|
|
92430
|
-
const effectiveCameraZ =
|
|
93089
|
+
const [internalContainer, setInternalContainer] = import_react52.default.useState(null);
|
|
93090
|
+
const containerRef = (0, import_react52.useRef)(containerProp ?? null);
|
|
93091
|
+
const rendererRef = (0, import_react52.useRef)(null);
|
|
93092
|
+
const sceneRef = (0, import_react52.useRef)(new Scene());
|
|
93093
|
+
const cameraRef = (0, import_react52.useRef)(new PerspectiveCamera(42, 1, 1e-4, 2e4));
|
|
93094
|
+
const cloudSceneRef = (0, import_react52.useRef)(new Group());
|
|
93095
|
+
const controlRef = (0, import_react52.useRef)(null);
|
|
93096
|
+
const interactionRef = (0, import_react52.useRef)(null);
|
|
93097
|
+
const apiInstanceRef = (0, import_react52.useRef)(null);
|
|
93098
|
+
const nodeRendererRef = (0, import_react52.useRef)(null);
|
|
93099
|
+
const edgeRendererRef = (0, import_react52.useRef)(null);
|
|
93100
|
+
const childNodeRendererRef = (0, import_react52.useRef)(null);
|
|
93101
|
+
const childEdgeRendererRef = (0, import_react52.useRef)(null);
|
|
93102
|
+
const frameCallbacksRef = (0, import_react52.useRef)(/* @__PURE__ */ new Map());
|
|
93103
|
+
const mapModeCallbacksRef = (0, import_react52.useRef)(/* @__PURE__ */ new Map());
|
|
93104
|
+
const mapMaxGrowthCallbacksRef = (0, import_react52.useRef)(/* @__PURE__ */ new Map());
|
|
93105
|
+
const [isMapMode, setIsMapMode] = import_react52.default.useState(false);
|
|
93106
|
+
const mapDampingRef = (0, import_react52.useRef)(0.3);
|
|
93107
|
+
const mapSphereRadiusRef = (0, import_react52.useRef)(0);
|
|
93108
|
+
const mapProviderWarnedRef = import_react52.default.useRef(false);
|
|
93109
|
+
const effectiveCameraZ = import_react52.default.useMemo(
|
|
92431
93110
|
() => cameraZ ?? (mapProp ? 6 : 3),
|
|
92432
93111
|
[cameraZ, mapProp]
|
|
92433
93112
|
);
|
|
92434
|
-
const [effectiveEnableControl, effectiveControlConfig] =
|
|
93113
|
+
const [effectiveEnableControl, effectiveControlConfig] = import_react52.default.useMemo(
|
|
92435
93114
|
() => {
|
|
92436
93115
|
const { enabled, config } = resolveControlsProp(controlsProp, enableControl, controlConfig);
|
|
92437
93116
|
return [enabled ?? (mapProp && is3DProp === true ? false : true), config];
|
|
92438
93117
|
},
|
|
92439
93118
|
[controlsProp, enableControl, controlConfig, mapProp, is3DProp]
|
|
92440
93119
|
);
|
|
92441
|
-
|
|
93120
|
+
import_react52.default.useEffect(() => {
|
|
92442
93121
|
if (typeof mapProvider === "string" && mapProvider.length > 0 && !mapProviderWarnedRef.current) {
|
|
92443
93122
|
mapProviderWarnedRef.current = true;
|
|
92444
93123
|
console.warn(
|
|
@@ -92446,36 +93125,36 @@ void main() {
|
|
|
92446
93125
|
);
|
|
92447
93126
|
}
|
|
92448
93127
|
}, [mapProvider]);
|
|
92449
|
-
const [is3D, setIs3DState] =
|
|
92450
|
-
const [autoMapLayerType, setAutoMapLayerType] =
|
|
92451
|
-
const mapSwapTokenRef =
|
|
92452
|
-
const [autoMapLayerEventConfig, setAutoMapLayerEventConfig] =
|
|
92453
|
-
const effectiveMapProjection =
|
|
93128
|
+
const [is3D, setIs3DState] = import_react52.default.useState(is3DProp);
|
|
93129
|
+
const [autoMapLayerType, setAutoMapLayerType] = import_react52.default.useState(null);
|
|
93130
|
+
const mapSwapTokenRef = import_react52.default.useRef(null);
|
|
93131
|
+
const [autoMapLayerEventConfig, setAutoMapLayerEventConfig] = import_react52.default.useState(null);
|
|
93132
|
+
const effectiveMapProjection = import_react52.default.useMemo(
|
|
92454
93133
|
() => deriveEffectiveMapProjection(mapProjectionProp, is3D),
|
|
92455
93134
|
[mapProjectionProp, is3D]
|
|
92456
93135
|
);
|
|
92457
|
-
const iconAtlasManagerRef = (0,
|
|
92458
|
-
const imageAtlasManagerRef = (0,
|
|
92459
|
-
const glyphAtlasManagerRef = (0,
|
|
92460
|
-
const imageSyncRequestRef = (0,
|
|
92461
|
-
const pendingStructureChangeRef = (0,
|
|
92462
|
-
const geoSettleSigRef = (0,
|
|
92463
|
-
const layoutAdapterRef = (0,
|
|
92464
|
-
const layoutControllerRef = (0,
|
|
92465
|
-
const forceWasFinishedRef = (0,
|
|
92466
|
-
const forceStartPositionsRef = (0,
|
|
92467
|
-
const storeRef = (0,
|
|
92468
|
-
const needsRenderRef = (0,
|
|
92469
|
-
const lastStoreVersionRef = (0,
|
|
92470
|
-
const animationFrameRef = (0,
|
|
92471
|
-
const renderRuntimeRef = (0,
|
|
93136
|
+
const iconAtlasManagerRef = (0, import_react52.useRef)(null);
|
|
93137
|
+
const imageAtlasManagerRef = (0, import_react52.useRef)(null);
|
|
93138
|
+
const glyphAtlasManagerRef = (0, import_react52.useRef)(null);
|
|
93139
|
+
const imageSyncRequestRef = (0, import_react52.useRef)(0);
|
|
93140
|
+
const pendingStructureChangeRef = (0, import_react52.useRef)(false);
|
|
93141
|
+
const geoSettleSigRef = (0, import_react52.useRef)("");
|
|
93142
|
+
const layoutAdapterRef = (0, import_react52.useRef)(null);
|
|
93143
|
+
const layoutControllerRef = (0, import_react52.useRef)(layoutController);
|
|
93144
|
+
const forceWasFinishedRef = (0, import_react52.useRef)(void 0);
|
|
93145
|
+
const forceStartPositionsRef = (0, import_react52.useRef)(null);
|
|
93146
|
+
const storeRef = (0, import_react52.useRef)(storeProp ?? new GraphStore());
|
|
93147
|
+
const needsRenderRef = (0, import_react52.useRef)(false);
|
|
93148
|
+
const lastStoreVersionRef = (0, import_react52.useRef)(storeRef.current.version);
|
|
93149
|
+
const animationFrameRef = (0, import_react52.useRef)(null);
|
|
93150
|
+
const renderRuntimeRef = (0, import_react52.useRef)(null);
|
|
92472
93151
|
if (!renderRuntimeRef.current) {
|
|
92473
93152
|
renderRuntimeRef.current = new RenderRuntime({ store: storeRef.current });
|
|
92474
93153
|
renderRuntimeRef.current.setExternalInvalidate(() => {
|
|
92475
93154
|
needsRenderRef.current = true;
|
|
92476
93155
|
});
|
|
92477
93156
|
}
|
|
92478
|
-
const viewStateStoreRef = (0,
|
|
93157
|
+
const viewStateStoreRef = (0, import_react52.useRef)(null);
|
|
92479
93158
|
if (!viewStateStoreRef.current) {
|
|
92480
93159
|
viewStateStoreRef.current = new ViewStateStore({
|
|
92481
93160
|
isMapMode,
|
|
@@ -92494,12 +93173,12 @@ void main() {
|
|
|
92494
93173
|
});
|
|
92495
93174
|
}
|
|
92496
93175
|
const viewStateStore = viewStateStoreRef.current;
|
|
92497
|
-
(0,
|
|
93176
|
+
(0, import_react52.useSyncExternalStore)(
|
|
92498
93177
|
viewStateStore.subscribe,
|
|
92499
93178
|
() => viewStateStore.getSnapshot().iconAtlasManager,
|
|
92500
93179
|
() => viewStateStore.getSnapshot().iconAtlasManager
|
|
92501
93180
|
);
|
|
92502
|
-
const [contextValue, setContextValue] = (0,
|
|
93181
|
+
const [contextValue, setContextValue] = (0, import_react52.useState)(null);
|
|
92503
93182
|
useInteractionPropBridge(contextValue, {
|
|
92504
93183
|
onNodeClick,
|
|
92505
93184
|
onNodeDoubleClick,
|
|
@@ -92535,7 +93214,7 @@ void main() {
|
|
|
92535
93214
|
useControlledTheme(contextValue?.api ?? null, theme, defaultTheme, onThemeChange);
|
|
92536
93215
|
useControlledViewState(contextValue?.api ?? null, viewState, effectiveDefaultViewState, onViewStateChange);
|
|
92537
93216
|
useControlledPinned(contextValue?.api ?? null, pinned, defaultPinned, onPinnedChange);
|
|
92538
|
-
const hoverBridgeApi =
|
|
93217
|
+
const hoverBridgeApi = import_react52.default.useMemo(() => {
|
|
92539
93218
|
if (!contextValue?.api || !contextValue?.interaction) return null;
|
|
92540
93219
|
return {
|
|
92541
93220
|
hover: contextValue.api.hover,
|
|
@@ -92543,12 +93222,12 @@ void main() {
|
|
|
92543
93222
|
};
|
|
92544
93223
|
}, [contextValue?.api, contextValue?.interaction]);
|
|
92545
93224
|
useControlledHover(hoverBridgeApi, hoveredId, onHoverChange);
|
|
92546
|
-
const [edgeCreateResult, setEdgeCreateResult] = (0,
|
|
93225
|
+
const [edgeCreateResult, setEdgeCreateResult] = (0, import_react52.useState)(
|
|
92547
93226
|
null
|
|
92548
93227
|
);
|
|
92549
|
-
const [createPanelAllowedRels, setCreatePanelAllowedRels] = (0,
|
|
92550
|
-
const [internalIconVersion, setInternalIconVersion] = (0,
|
|
92551
|
-
(0,
|
|
93228
|
+
const [createPanelAllowedRels, setCreatePanelAllowedRels] = (0, import_react52.useState)(void 0);
|
|
93229
|
+
const [internalIconVersion, setInternalIconVersion] = (0, import_react52.useState)(0);
|
|
93230
|
+
(0, import_react52.useEffect)(() => {
|
|
92552
93231
|
const store = storeProp ?? storeRef.current;
|
|
92553
93232
|
const dispose = store.subscribeIconVersionChanged(() => {
|
|
92554
93233
|
setInternalIconVersion(store.iconVersion);
|
|
@@ -92556,28 +93235,28 @@ void main() {
|
|
|
92556
93235
|
setInternalIconVersion(store.iconVersion);
|
|
92557
93236
|
return dispose;
|
|
92558
93237
|
}, [storeProp]);
|
|
92559
|
-
const changeCategoryFlowRef = (0,
|
|
92560
|
-
const contextMenuManagerRef = (0,
|
|
92561
|
-
const nodeInfoManagerRef = (0,
|
|
92562
|
-
const internalForceCtrlRef = (0,
|
|
92563
|
-
const internalForceAdapterRef = (0,
|
|
92564
|
-
const [internalLayoutController, setInternalLayoutController] = (0,
|
|
93238
|
+
const changeCategoryFlowRef = (0, import_react52.useRef)(null);
|
|
93239
|
+
const contextMenuManagerRef = (0, import_react52.useRef)(null);
|
|
93240
|
+
const nodeInfoManagerRef = (0, import_react52.useRef)(null);
|
|
93241
|
+
const internalForceCtrlRef = (0, import_react52.useRef)(null);
|
|
93242
|
+
const internalForceAdapterRef = (0, import_react52.useRef)(null);
|
|
93243
|
+
const [internalLayoutController, setInternalLayoutController] = (0, import_react52.useState)(null);
|
|
92565
93244
|
const effectiveLayoutController = layoutController ?? internalLayoutController ?? void 0;
|
|
92566
|
-
(0,
|
|
93245
|
+
(0, import_react52.useEffect)(() => {
|
|
92567
93246
|
layoutControllerRef.current = effectiveLayoutController;
|
|
92568
93247
|
}, [effectiveLayoutController]);
|
|
92569
|
-
(0,
|
|
93248
|
+
(0, import_react52.useEffect)(() => {
|
|
92570
93249
|
if (storeProp) {
|
|
92571
93250
|
storeRef.current = storeProp;
|
|
92572
93251
|
}
|
|
92573
93252
|
}, [storeProp]);
|
|
92574
|
-
(0,
|
|
93253
|
+
(0, import_react52.useEffect)(() => {
|
|
92575
93254
|
if (dataProp) {
|
|
92576
93255
|
storeRef.current.setData(dataProp);
|
|
92577
93256
|
}
|
|
92578
93257
|
}, [dataProp]);
|
|
92579
|
-
const hasChildren =
|
|
92580
|
-
const effectiveNodeCloud =
|
|
93258
|
+
const hasChildren = import_react52.default.Children.count(children) > 0;
|
|
93259
|
+
const effectiveNodeCloud = import_react52.default.useMemo(() => {
|
|
92581
93260
|
if (hasChildren) return nodeCloud;
|
|
92582
93261
|
const nodePropResolved = resolveBoolOrConfig(nodeProp);
|
|
92583
93262
|
if (nodePropResolved) {
|
|
@@ -92595,7 +93274,7 @@ void main() {
|
|
|
92595
93274
|
}
|
|
92596
93275
|
return nodeCloud ?? true;
|
|
92597
93276
|
}, [hasChildren, nodeProp, nodeCloud, resolvedTheme.isDark]);
|
|
92598
|
-
const effectiveEdgeCloud =
|
|
93277
|
+
const effectiveEdgeCloud = import_react52.default.useMemo(() => {
|
|
92599
93278
|
if (hasChildren) return edgeCloud;
|
|
92600
93279
|
const edgePropResolved = resolveBoolOrConfig(edgeProp);
|
|
92601
93280
|
if (edgePropResolved) {
|
|
@@ -92614,19 +93293,19 @@ void main() {
|
|
|
92614
93293
|
}
|
|
92615
93294
|
return edgeCloud ?? true;
|
|
92616
93295
|
}, [hasChildren, edgeProp, edgeCloud]);
|
|
92617
|
-
const effectiveMap =
|
|
93296
|
+
const effectiveMap = import_react52.default.useMemo(() => {
|
|
92618
93297
|
if (!mapProp) return null;
|
|
92619
93298
|
const base = mapProp === true ? {} : mapProp;
|
|
92620
93299
|
const tileProvider = base.tileProvider ?? (typeof mapProvider === "string" && mapProvider.length > 0 ? mapProvider : void 0);
|
|
92621
93300
|
return { ...base, tileProvider };
|
|
92622
93301
|
}, [mapProp, mapProvider]);
|
|
92623
|
-
const maxNodeGrowth =
|
|
93302
|
+
const maxNodeGrowth = import_react52.default.useMemo(() => {
|
|
92624
93303
|
if (typeof mapProp === "object" && mapProp?.maxNodeGrowth !== void 0) {
|
|
92625
93304
|
return mapProp.maxNodeGrowth;
|
|
92626
93305
|
}
|
|
92627
93306
|
return 4;
|
|
92628
93307
|
}, [mapProp]);
|
|
92629
|
-
|
|
93308
|
+
import_react52.default.useEffect(() => {
|
|
92630
93309
|
if (!effectiveMap) return;
|
|
92631
93310
|
if (!contextValue) return;
|
|
92632
93311
|
const damping = 0.3;
|
|
@@ -92649,7 +93328,7 @@ void main() {
|
|
|
92649
93328
|
}
|
|
92650
93329
|
}
|
|
92651
93330
|
}, [effectiveMap, is3D, contextValue]);
|
|
92652
|
-
|
|
93331
|
+
import_react52.default.useEffect(() => {
|
|
92653
93332
|
if (!effectiveMap) {
|
|
92654
93333
|
setAutoMapLayerType(null);
|
|
92655
93334
|
return;
|
|
@@ -92667,7 +93346,7 @@ void main() {
|
|
|
92667
93346
|
}
|
|
92668
93347
|
setAutoMapLayerType(nextType);
|
|
92669
93348
|
}, [effectiveMap, is3D, children, autoMapLayerType]);
|
|
92670
|
-
|
|
93349
|
+
import_react52.default.useEffect(() => {
|
|
92671
93350
|
const api2 = apiInstanceRef.current;
|
|
92672
93351
|
if (!api2) return;
|
|
92673
93352
|
if (!contextValue) return;
|
|
@@ -92704,8 +93383,8 @@ void main() {
|
|
|
92704
93383
|
unsubProviderChanged();
|
|
92705
93384
|
};
|
|
92706
93385
|
}, [contextValue, effectiveMap, children]);
|
|
92707
|
-
const [runtimeCaption, setRuntimeCaption] = (0,
|
|
92708
|
-
|
|
93386
|
+
const [runtimeCaption, setRuntimeCaption] = (0, import_react52.useState)(null);
|
|
93387
|
+
import_react52.default.useEffect(() => {
|
|
92709
93388
|
const api2 = apiInstanceRef.current;
|
|
92710
93389
|
if (!api2 || !contextValue) return;
|
|
92711
93390
|
const sync = () => {
|
|
@@ -92718,7 +93397,7 @@ void main() {
|
|
|
92718
93397
|
unsub();
|
|
92719
93398
|
};
|
|
92720
93399
|
}, [contextValue]);
|
|
92721
|
-
|
|
93400
|
+
import_react52.default.useEffect(() => {
|
|
92722
93401
|
if (!effectiveMap) return;
|
|
92723
93402
|
const geoLayoutConfig = effectiveMap.geoLayout;
|
|
92724
93403
|
if (geoLayoutConfig === false) return;
|
|
@@ -92818,13 +93497,11 @@ void main() {
|
|
|
92818
93497
|
return staticStore.structureEpoch;
|
|
92819
93498
|
}
|
|
92820
93499
|
});
|
|
92821
|
-
|
|
92822
|
-
|
|
92823
|
-
|
|
92824
|
-
|
|
92825
|
-
|
|
92826
|
-
childEdgeRendererRef.current?.setPositionProvider(provider);
|
|
92827
|
-
}
|
|
93500
|
+
api2.store.setPositionProvider(provider);
|
|
93501
|
+
nodeRendererRef.current?.setPositionProvider(provider);
|
|
93502
|
+
edgeRendererRef.current?.setPositionProvider(provider);
|
|
93503
|
+
childNodeRendererRef.current?.setPositionProvider(provider);
|
|
93504
|
+
childEdgeRendererRef.current?.setPositionProvider(provider);
|
|
92828
93505
|
const eRenderer = edgeRendererRef.current ?? childEdgeRendererRef.current;
|
|
92829
93506
|
const classifier = eRenderer && typeof eRenderer.getEdgeClassifier === "function" ? eRenderer.getEdgeClassifier() : null;
|
|
92830
93507
|
if (classifier) {
|
|
@@ -92898,7 +93575,7 @@ void main() {
|
|
|
92898
93575
|
api2.events.off("graph:dataReset", debounced);
|
|
92899
93576
|
};
|
|
92900
93577
|
}, [effectiveMap, is3D, contextValue]);
|
|
92901
|
-
(0,
|
|
93578
|
+
(0, import_react52.useEffect)(() => {
|
|
92902
93579
|
const container = containerProp ?? internalContainer;
|
|
92903
93580
|
if (!container) return;
|
|
92904
93581
|
const {
|
|
@@ -93049,7 +93726,7 @@ void main() {
|
|
|
93049
93726
|
effectiveCameraZ,
|
|
93050
93727
|
onReady
|
|
93051
93728
|
]);
|
|
93052
|
-
(0,
|
|
93729
|
+
(0, import_react52.useEffect)(() => {
|
|
93053
93730
|
const container = containerProp ?? internalContainer;
|
|
93054
93731
|
if (!container) return;
|
|
93055
93732
|
container.setAttribute("data-gxr-theme", themeKey);
|
|
@@ -93057,14 +93734,14 @@ void main() {
|
|
|
93057
93734
|
container.removeAttribute("data-gxr-theme");
|
|
93058
93735
|
};
|
|
93059
93736
|
}, [containerProp, internalContainer, themeKey]);
|
|
93060
|
-
|
|
93737
|
+
import_react52.default.useEffect(() => {
|
|
93061
93738
|
if ((typeof globalThis !== "undefined" && globalThis.process?.env?.NODE_ENV) !== "production" && containerProp != null && (style != null || className != null)) {
|
|
93062
93739
|
console.warn(
|
|
93063
93740
|
"[@kineviz/gl] `style` / `className` props are ignored when `container` is provided. Style the external container directly."
|
|
93064
93741
|
);
|
|
93065
93742
|
}
|
|
93066
93743
|
}, [containerProp, style, className]);
|
|
93067
|
-
(0,
|
|
93744
|
+
(0, import_react52.useEffect)(() => {
|
|
93068
93745
|
const renderer = rendererRef.current;
|
|
93069
93746
|
if (renderer) {
|
|
93070
93747
|
renderer.setClearColor(effectiveBackground, 1);
|
|
@@ -93103,7 +93780,7 @@ void main() {
|
|
|
93103
93780
|
imageAtlasManagerRef,
|
|
93104
93781
|
glyphAtlasManagerRef
|
|
93105
93782
|
});
|
|
93106
|
-
(0,
|
|
93783
|
+
(0, import_react52.useEffect)(() => {
|
|
93107
93784
|
if (!contextValue || !forceLayout || layoutController) {
|
|
93108
93785
|
if (internalForceCtrlRef.current) {
|
|
93109
93786
|
try {
|
|
@@ -93228,7 +93905,7 @@ void main() {
|
|
|
93228
93905
|
}
|
|
93229
93906
|
};
|
|
93230
93907
|
}, [contextValue, forceLayout, layoutController]);
|
|
93231
|
-
(0,
|
|
93908
|
+
(0, import_react52.useEffect)(() => {
|
|
93232
93909
|
const lcEffective = layoutController ?? internalLayoutController ?? null;
|
|
93233
93910
|
if (!contextValue || !lcEffective) {
|
|
93234
93911
|
layoutAdapterRef.current = null;
|
|
@@ -93316,7 +93993,7 @@ void main() {
|
|
|
93316
93993
|
apiInstanceRef.current?.wireLayoutController(null);
|
|
93317
93994
|
};
|
|
93318
93995
|
}, [contextValue, layoutController, internalLayoutController, autoStartLayout]);
|
|
93319
|
-
(0,
|
|
93996
|
+
(0, import_react52.useEffect)(() => {
|
|
93320
93997
|
if (!contextValue || !effectiveNodeCloud) return;
|
|
93321
93998
|
const config = typeof effectiveNodeCloud === "object" ? effectiveNodeCloud : {};
|
|
93322
93999
|
const { positionProvider, iconAtlas, iconColumns, pinTexture, avatarTexture, defaultNodeSize, ...rendererConfig } = config;
|
|
@@ -93378,21 +94055,21 @@ void main() {
|
|
|
93378
94055
|
nodeRendererRef.current = null;
|
|
93379
94056
|
};
|
|
93380
94057
|
}, [contextValue, effectiveNodeCloud]);
|
|
93381
|
-
(0,
|
|
94058
|
+
(0, import_react52.useEffect)(() => {
|
|
93382
94059
|
if (!isMapMode) return;
|
|
93383
94060
|
nodeRendererRef.current?.setMapMode(true, mapSphereRadiusRef.current, mapDampingRef.current);
|
|
93384
94061
|
edgeRendererRef.current?.setMapMode(true, mapSphereRadiusRef.current, mapDampingRef.current);
|
|
93385
94062
|
edgeRendererRef.current?.setSphereRadius(mapSphereRadiusRef.current);
|
|
93386
94063
|
contextValue?.invalidate();
|
|
93387
94064
|
}, [isMapMode, contextValue, effectiveNodeCloud, effectiveEdgeCloud]);
|
|
93388
|
-
(0,
|
|
94065
|
+
(0, import_react52.useEffect)(() => {
|
|
93389
94066
|
if (typeof effectiveNodeCloud === "object" && effectiveNodeCloud.lightMode !== void 0) return;
|
|
93390
94067
|
const nodeRenderer = nodeRendererRef.current;
|
|
93391
94068
|
if (!nodeRenderer) return;
|
|
93392
94069
|
nodeRenderer.setOptions({ lightMode: !resolvedTheme.isDark });
|
|
93393
94070
|
contextValue?.invalidate();
|
|
93394
94071
|
}, [contextValue, effectiveNodeCloud, resolvedTheme.isDark]);
|
|
93395
|
-
(0,
|
|
94072
|
+
(0, import_react52.useEffect)(() => {
|
|
93396
94073
|
const nodeRenderer = nodeRendererRef.current;
|
|
93397
94074
|
if (!contextValue?.interaction || !nodeRenderer) return;
|
|
93398
94075
|
const mesh = nodeRenderer.getMesh();
|
|
@@ -93400,7 +94077,7 @@ void main() {
|
|
|
93400
94077
|
contextValue.interaction.setupNodePicking(mesh.geometry);
|
|
93401
94078
|
contextValue.interaction.syncTransforms(cloudSceneRef.current);
|
|
93402
94079
|
}, [contextValue?.interaction]);
|
|
93403
|
-
(0,
|
|
94080
|
+
(0, import_react52.useEffect)(() => {
|
|
93404
94081
|
const renderer = nodeRendererRef.current;
|
|
93405
94082
|
const iconMgr = iconAtlasManagerRef.current;
|
|
93406
94083
|
if (!renderer || !contextValue) return;
|
|
@@ -93433,7 +94110,7 @@ void main() {
|
|
|
93433
94110
|
}
|
|
93434
94111
|
contextValue.invalidate();
|
|
93435
94112
|
});
|
|
93436
|
-
(0,
|
|
94113
|
+
(0, import_react52.useEffect)(() => {
|
|
93437
94114
|
const requestId = ++imageSyncRequestRef.current;
|
|
93438
94115
|
let cancelled = false;
|
|
93439
94116
|
const renderer = nodeRendererRef.current;
|
|
@@ -93485,7 +94162,7 @@ void main() {
|
|
|
93485
94162
|
cancelled = true;
|
|
93486
94163
|
};
|
|
93487
94164
|
});
|
|
93488
|
-
(0,
|
|
94165
|
+
(0, import_react52.useEffect)(() => {
|
|
93489
94166
|
if (!contextValue || !effectiveEdgeCloud) return;
|
|
93490
94167
|
const config = typeof effectiveEdgeCloud === "object" ? effectiveEdgeCloud : {};
|
|
93491
94168
|
const {
|
|
@@ -93542,13 +94219,13 @@ void main() {
|
|
|
93542
94219
|
};
|
|
93543
94220
|
}, [contextValue, effectiveEdgeCloud]);
|
|
93544
94221
|
const internalNodeSizeScale = typeof effectiveNodeCloud === "object" ? effectiveNodeCloud.nodeSizeScale : void 0;
|
|
93545
|
-
(0,
|
|
94222
|
+
(0, import_react52.useEffect)(() => {
|
|
93546
94223
|
if (internalNodeSizeScale === void 0) return;
|
|
93547
94224
|
contextValue?.store.setGlobalNodeSizeScale(internalNodeSizeScale);
|
|
93548
94225
|
edgeRendererRef.current?.setNodeSizeScale(internalNodeSizeScale);
|
|
93549
94226
|
contextValue?.invalidate();
|
|
93550
94227
|
}, [internalNodeSizeScale, contextValue]);
|
|
93551
|
-
(0,
|
|
94228
|
+
(0, import_react52.useEffect)(() => {
|
|
93552
94229
|
const edgeRenderer = edgeRendererRef.current;
|
|
93553
94230
|
if (!contextValue?.interaction || !edgeRenderer) return;
|
|
93554
94231
|
const edgeMesh = edgeRenderer.getMesh();
|
|
@@ -93557,7 +94234,7 @@ void main() {
|
|
|
93557
94234
|
contextValue.interaction.syncTransforms(contextValue.cloudScene, edgeMesh);
|
|
93558
94235
|
}
|
|
93559
94236
|
}, [contextValue?.interaction]);
|
|
93560
|
-
(0,
|
|
94237
|
+
(0, import_react52.useEffect)(() => {
|
|
93561
94238
|
const interaction = interactionRef.current;
|
|
93562
94239
|
if (!interaction) return;
|
|
93563
94240
|
const nodeRenderer = nodeRendererRef.current || childNodeRendererRef.current;
|
|
@@ -93569,7 +94246,7 @@ void main() {
|
|
|
93569
94246
|
iconAtlasManager: iconAtlasManagerRef.current ?? null
|
|
93570
94247
|
});
|
|
93571
94248
|
}, [contextValue?.interaction, iconFonts]);
|
|
93572
|
-
(0,
|
|
94249
|
+
(0, import_react52.useEffect)(() => {
|
|
93573
94250
|
const api2 = apiInstanceRef.current;
|
|
93574
94251
|
if (!api2) return;
|
|
93575
94252
|
const handleDeleteKey = (e) => {
|
|
@@ -93590,10 +94267,10 @@ void main() {
|
|
|
93590
94267
|
document.addEventListener("keydown", handleDeleteKey);
|
|
93591
94268
|
return () => document.removeEventListener("keydown", handleDeleteKey);
|
|
93592
94269
|
}, [contextValue]);
|
|
93593
|
-
(0,
|
|
94270
|
+
(0, import_react52.useEffect)(() => {
|
|
93594
94271
|
containerRef.current = containerProp ?? null;
|
|
93595
94272
|
}, [containerProp]);
|
|
93596
|
-
const handleQuickCreateDone = (0,
|
|
94273
|
+
const handleQuickCreateDone = (0, import_react52.useCallback)(() => {
|
|
93597
94274
|
setEdgeCreateResult(null);
|
|
93598
94275
|
needsRenderRef.current = true;
|
|
93599
94276
|
}, []);
|
|
@@ -93610,7 +94287,7 @@ void main() {
|
|
|
93610
94287
|
is3D
|
|
93611
94288
|
});
|
|
93612
94289
|
const api = apiInstanceRef.current;
|
|
93613
|
-
const historyWiredRef = (0,
|
|
94290
|
+
const historyWiredRef = (0, import_react52.useRef)(false);
|
|
93614
94291
|
if (api && interactionRef.current?.shortcuts && !historyWiredRef.current) {
|
|
93615
94292
|
const sm = interactionRef.current.shortcuts;
|
|
93616
94293
|
const history = api.history;
|
|
@@ -93801,7 +94478,7 @@ void main() {
|
|
|
93801
94478
|
})
|
|
93802
94479
|
);
|
|
93803
94480
|
}
|
|
93804
|
-
(0,
|
|
94481
|
+
(0, import_react52.useEffect)(() => {
|
|
93805
94482
|
if (apiRef && api) {
|
|
93806
94483
|
apiRef.current = api;
|
|
93807
94484
|
}
|
|
@@ -93811,10 +94488,10 @@ void main() {
|
|
|
93811
94488
|
}
|
|
93812
94489
|
};
|
|
93813
94490
|
}, [api, apiRef]);
|
|
93814
|
-
(0,
|
|
94491
|
+
(0, import_react52.useEffect)(() => {
|
|
93815
94492
|
if (api) api.events.emit("ready", {});
|
|
93816
94493
|
}, [api]);
|
|
93817
|
-
(0,
|
|
94494
|
+
(0, import_react52.useEffect)(() => {
|
|
93818
94495
|
if (!api?.map) return;
|
|
93819
94496
|
api.map.setProvider(resolvedProvider);
|
|
93820
94497
|
const off = api.events.on("map:enabled", (_p) => {
|
|
@@ -93822,11 +94499,11 @@ void main() {
|
|
|
93822
94499
|
});
|
|
93823
94500
|
return off;
|
|
93824
94501
|
}, [api, resolvedProvider]);
|
|
93825
|
-
const onViewChangeRef = (0,
|
|
93826
|
-
(0,
|
|
94502
|
+
const onViewChangeRef = (0, import_react52.useRef)(onViewChange);
|
|
94503
|
+
(0, import_react52.useEffect)(() => {
|
|
93827
94504
|
onViewChangeRef.current = onViewChange;
|
|
93828
94505
|
}, [onViewChange]);
|
|
93829
|
-
(0,
|
|
94506
|
+
(0, import_react52.useEffect)(() => {
|
|
93830
94507
|
if (!api) return;
|
|
93831
94508
|
setViewMinimapVisible(api.renderer.isMinimapVisible());
|
|
93832
94509
|
api.map.wireMapDamping((damping) => {
|
|
@@ -93848,7 +94525,7 @@ void main() {
|
|
|
93848
94525
|
unsub();
|
|
93849
94526
|
};
|
|
93850
94527
|
}, [api, contextValue, maxNodeGrowth]);
|
|
93851
|
-
(0,
|
|
94528
|
+
(0, import_react52.useEffect)(() => {
|
|
93852
94529
|
return () => {
|
|
93853
94530
|
apiInstanceRef.current?.dispose();
|
|
93854
94531
|
nodeInfoManagerRef.current?.dispose();
|
|
@@ -93955,6 +94632,7 @@ void main() {
|
|
|
93955
94632
|
),
|
|
93956
94633
|
children,
|
|
93957
94634
|
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(MarkersBridge, {}),
|
|
94635
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(LayerHost, {}),
|
|
93958
94636
|
autoTextLayers,
|
|
93959
94637
|
autoMapLayer,
|
|
93960
94638
|
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(GroupCloud, {}),
|
|
@@ -94010,16 +94688,19 @@ void main() {
|
|
|
94010
94688
|
var GraphCanvas = GraphRenderer;
|
|
94011
94689
|
|
|
94012
94690
|
// src/react/layers/NodeCloud.tsx
|
|
94013
|
-
var
|
|
94691
|
+
var import_react53 = __toESM(require_react());
|
|
94014
94692
|
|
|
94015
94693
|
// src/react/layers/EdgeCloud.tsx
|
|
94016
|
-
var
|
|
94694
|
+
var import_react54 = __toESM(require_react());
|
|
94017
94695
|
|
|
94018
94696
|
// src/react/layers/AxisLayer.tsx
|
|
94019
|
-
var
|
|
94697
|
+
var import_react55 = __toESM(require_react());
|
|
94020
94698
|
|
|
94021
94699
|
// src/react/layers/MarkerLayer.tsx
|
|
94022
|
-
var
|
|
94700
|
+
var import_react56 = __toESM(require_react());
|
|
94701
|
+
|
|
94702
|
+
// src/react/layers/CoverageLayer.tsx
|
|
94703
|
+
var import_react57 = __toESM(require_react());
|
|
94023
94704
|
|
|
94024
94705
|
// src/map/ScaledLODRadial.ts
|
|
94025
94706
|
var _pov = new Vector3();
|
|
@@ -94194,7 +94875,7 @@ void main() {
|
|
|
94194
94875
|
var NodeSizeService = _NodeSizeService;
|
|
94195
94876
|
|
|
94196
94877
|
// src/filter/useGraphFilter.ts
|
|
94197
|
-
var
|
|
94878
|
+
var import_react58 = __toESM(require_react());
|
|
94198
94879
|
|
|
94199
94880
|
// src/umd-entry.ts
|
|
94200
94881
|
var version = "0.3.0";
|