tobogganSe connecter

starfleet-ui

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

22 lignes · 748 octetsBrut · Historique
1import { expect, test } from 'bun:test';
2import { frameGalaxy, galaxyPos } from './coords';
3
4test('galaxyPos maps game y to scene -z at galaxy scale', () => {
5 expect(galaxyPos({ x: 400, y: 200 })).toEqual([100, 0, -50]);
6});
7
8test('frameGalaxy looks at the middle of the systems, from above and in front', () => {
9 const { pos, look } = frameGalaxy([
10 { x: 0, y: 0 },
11 { x: 800, y: 400 }
12 ]);
13 // bounds in scene units: x 0..200, z -100..0 → centre (100, -50), extent 200
14 expect(look).toEqual([130, 0, -50]);
15 expect(pos[0]).toBe(130);
16 expect(pos[1]).toBeGreaterThan(200);
17 expect(pos[2]).toBeGreaterThan(-50);
18});
19
20test('frameGalaxy has a sensible default for an empty galaxy', () => {
21 expect(frameGalaxy([]).look).toEqual([0, 0, 0]);
22});