Fix self-node snapping on node addition

This commit is contained in:
Jack Kingsman
2026-03-13 10:42:36 -07:00
parent 96d8d1dc64
commit 70d28e53a9
2 changed files with 31 additions and 0 deletions

View File

@@ -78,6 +78,9 @@ function buildInitialRenderNode(node: PacketNetworkNode): GraphNode {
x: 0,
y: 0,
z: 0,
fx: 0,
fy: 0,
fz: 0,
vx: 0,
vy: 0,
vz: 0,
@@ -244,6 +247,9 @@ export function useVisualizerData3D({
existing.x = 0;
existing.y = 0;
existing.z = 0;
existing.fx = 0;
existing.fy = 0;
existing.fz = 0;
existing.vx = 0;
existing.vy = 0;
existing.vz = 0;

View File

@@ -123,6 +123,31 @@ afterEach(() => {
});
describe('useVisualizerData3D', () => {
it('hard-pins the self node at the origin', async () => {
const selfKey = 'ffffffffffff0000000000000000000000000000000000000000000000000000';
const { result } = renderVisualizerData({
packets: [],
contacts: [],
config: createConfig(selfKey),
});
await waitFor(() => expect(result.current.nodes.get('self')).toBeDefined());
const selfNode = result.current.nodes.get('self');
expect(selfNode).toMatchObject({
x: 0,
y: 0,
z: 0,
fx: 0,
fy: 0,
fz: 0,
vx: 0,
vy: 0,
vz: 0,
});
});
it('keeps canonical adjacency stable when ambiguous repeaters are shown or hidden', async () => {
const selfKey = 'ffffffffffff0000000000000000000000000000000000000000000000000000';
const aliceKey = 'aaaaaaaaaaaa0000000000000000000000000000000000000000000000000000';