Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(coin-intel): keep the 3D funder graph compact so 500 wallets frame on screen, with a layout regression test

nirholas63aadb21c3e2
diff --git a/prompts/finish/_context/integrate-PROGRESS.md b/prompts/finish/_context/integrate-PROGRESS.md
index 19ff67e81..b4f7602f2 100644
--- a/prompts/finish/_context/integrate-PROGRESS.md
+++ b/prompts/finish/_context/integrate-PROGRESS.md
@@ -1418,3 +1418,9 @@ Remaining: the three-width browser check of the Posts view and a fresh `npm run
## 2026-10-23: order 534 follow-up pass, still partial
Re-ran the four test files (74 pass). The live trading read still did not render: local provider chain returned kilo 429, ovh timeouts, llm7 401, and Vertex Gemini 403 (project billing dunning, owner action). The browser render check of `.art-trading` was prepared but could not run because concurrent `npm install` runs kept `node_modules` (vite, playwright) in a half-written state for the whole pass. Remaining: open a story at `/markets/news` under `npm run dev` once an LLM provider answers; owner: restore Vertex billing or supply a provider key. Order file left in place.
+
+## 2026-10-23: orders 539 (integrate 40) and 545 (integrate 46), code done, two checks open
+
+539: Gini, funder seeded share and v1-launch signals (`api/_lib/coin/holder-signals.js`, `api/pump/token-stats.js`, oracle features) shipped earlier via a sweep commit; this session added the trader-sheet cells in `src/launch-detail.js`. Local `/api/pump/token-stats?mint=<THREE>` returns gini 0.4952 (n=20), launch_version V0, seeding `available:false` (trade history unavailable from the capped upstream). Tests: coin-holder-signals, pump-token-stats, coin-intel, 62 pass. The dev server proxies /api to prod, so the page cells read "-" until the next deploy.
+545: 3D funder graph (`src/funder-graph.js`, vendored engine in `src/vendor/swarming/`) was already wired; this session found and fixed a real layout bug (500 nodes drifted to radius 1776, off camera) with per-axis gravity, bounded charge range and a percentile-based fit, covered by `tests/funder-graph.test.js`. Browser-verified at 390 (reduced motion, 60fps idle, graph framed), 768 and 1280 with a 500-node harness, zero console errors. 60fps with 500 nodes on a real GPU is unmeasured: this box only has software GL.
+Remaining (orders kept): 539 page cells need a post-deploy browser check against live /api (owner deploys); 545 needs the 500-node 60fps check on a real GPU.
diff --git a/src/vendor/swarming/ForceSimulation.js b/src/vendor/swarming/ForceSimulation.js
index 3d2afbbeb..af4fd4ce6 100644
--- a/src/vendor/swarming/ForceSimulation.js
+++ b/src/vendor/swarming/ForceSimulation.js
@@ -2,7 +2,7 @@
// Changes: ported to plain JS; arbitrary weighted nodes and edges instead of the
// hub/leaf grouping model; per-node radius drives collision; bounded node budget.
-import { forceSimulation, forceLink, forceManyBody, forceCenter, forceCollide } from 'd3-force-3d';
+import { forceSimulation, forceLink, forceManyBody, forceCenter, forceCollide, forceX, forceY, forceZ } from 'd3-force-3d';
const DEFAULTS = {
charge: -60,
@@ -10,6 +10,7 @@ const DEFAULTS = {
damping: 0.4,
maxNodes: 5000,
alphaDecay: 0.02,
+ gravity: 0.12,
};
export class ForceSimulation {
@@ -20,8 +21,11 @@ export class ForceSimulation {
this.nodeMap = new Map();
const c = this.config;
this.simulation = forceSimulation([], 3)
- .force('charge', forceManyBody().strength((d) => c.charge * (0.4 + d.radius * 0.3)))
+ .force('charge', forceManyBody().strength((d) => c.charge * (0.4 + d.radius * 0.3)).theta(1.4).distanceMax(60))
.force('center', forceCenter(0, 0, 0).strength(0.05))
+ .force('gravityX', forceX(0).strength(c.gravity))
+ .force('gravityY', forceY(0).strength(c.gravity))
+ .force('gravityZ', forceZ(0).strength(c.gravity))
.force('collide', forceCollide().radius((d) => d.radius + 0.4).strength(0.8))
.force(
'link',
diff --git a/src/vendor/swarming/ThreeRenderer.js b/src/vendor/swarming/ThreeRenderer.js
index 08d494d5c..9249f70f1 100644
--- a/src/vendor/swarming/ThreeRenderer.js
+++ b/src/vendor/swarming/ThreeRenderer.js
@@ -32,6 +32,7 @@ export class ThreeRenderer {
this.ndc = new THREE.Vector2();
this.rafId = null;
this.lastFrame = 0;
+ this.maxZoom = 160;
this.renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true, powerPreference: 'high-performance' });
this.renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
@@ -43,7 +44,7 @@ export class ThreeRenderer {
container.appendChild(canvas);
this.scene = new THREE.Scene();
- this.camera = new THREE.PerspectiveCamera(50, 1, 0.1, 600);
+ this.camera = new THREE.PerspectiveCamera(50, 1, 0.1, 2000);
this.applyCamera();
this.scene.add(new THREE.AmbientLight(0xffffff, 0.9));
@@ -239,7 +240,7 @@ export class ThreeRenderer {
onWheel = (e) => {
e.preventDefault();
- this.spherical.radius = Math.max(18, Math.min(160, this.spherical.radius + e.deltaY * 0.06));
+ this.spherical.radius = Math.max(18, Math.min(this.maxZoom, this.spherical.radius + e.deltaY * 0.06 * (this.maxZoom / 160)));
this.applyCamera();
this.requestRender();
};
@@ -251,7 +252,7 @@ export class ThreeRenderer {
else if (e.key === 'ArrowUp') this.spherical.phi = Math.max(0.15, this.spherical.phi - step);
else if (e.key === 'ArrowDown') this.spherical.phi = Math.min(Math.PI - 0.15, this.spherical.phi + step);
else if (e.key === '+' || e.key === '=') this.spherical.radius = Math.max(18, this.spherical.radius - 6);
- else if (e.key === '-') this.spherical.radius = Math.min(160, this.spherical.radius + 6);
+ else if (e.key === '-') this.spherical.radius = Math.min(this.maxZoom, this.spherical.radius + 6);
else return;
e.preventDefault();
this.applyCamera();
@@ -260,9 +261,10 @@ export class ThreeRenderer {
/** Fit the camera distance to the current layout extent. */
fit() {
- let r = 10;
- for (const n of this.nodes) r = Math.max(r, Math.hypot(n.x || 0, n.y || 0, n.z || 0) + n.radius);
- this.spherical.radius = Math.max(30, Math.min(150, r * 2.4));
+ const dists = this.nodes.map((n) => Math.hypot(n.x || 0, n.y || 0, n.z || 0) + n.radius).sort((a, b) => a - b);
+ const r = Math.max(10, dists.length ? dists[Math.floor((dists.length - 1) * 0.92)] : 10);
+ this.maxZoom = Math.max(160, r * 4);
+ this.spherical.radius = Math.max(30, Math.min(this.maxZoom, r * 2.4));
this.applyCamera();
this.requestRender();
}
diff --git a/tests/funder-graph.test.js b/tests/funder-graph.test.js
index c46fcb7fd..d63cf3b05 100644
--- a/tests/funder-graph.test.js
+++ b/tests/funder-graph.test.js
@@ -1,5 +1,6 @@
import { describe, it, expect } from 'vitest';
import { buildGraph, clusterColor } from '../src/funder-graph.js';
+import { ForceSimulation } from '../src/vendor/swarming/ForceSimulation.js';
const THREE_MINT = 'FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump';
@@ -36,3 +37,20 @@ describe('buildGraph', () => {
expect(buildGraph([], []).nodes).toEqual([]);
});
});
+
+describe('ForceSimulation layout', () => {
+ it('keeps a 500-wallet graph compact so the fitted camera can frame every node', () => {
+ const wallets = Array.from({ length: 500 }, (_, i) => ({
+ wallet: `${THREE_MINT}${i}`,
+ net_sol: ((i * 7919) % 2000) / 100 + 0.1,
+ cluster: i % 3 === 0 ? i % 8 : null,
+ }));
+ const g = buildGraph(wallets, []);
+ const sim = new ForceSimulation();
+ sim.update(g.nodes, g.edges);
+ sim.settle();
+ const reach = Math.max(...sim.nodes.map((n) => Math.hypot(n.x, n.y, n.z)));
+ expect(Number.isFinite(reach)).toBe(true);
+ expect(reach).toBeLessThan(200);
+ });
+});