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.

35 lignes · 841 octetsBrut · Historique
1export type V3 = [number, number, number];
2
3/**
4 * Where a scene's camera should fly. Each page creates its own instance and hands it to
5 * its scene, so the galaxy and system maps never share (or inherit) camera state.
6 */
7export class CameraFlight {
8 pos = $state<V3>([0, 0, 0]);
9 look = $state<V3>([0, 0, 0]);
10 /** Increments on every flyTo, so a repeated target still triggers a flight. 0 = never flown. */
11 seq = $state(0);
12
13 constructor(
14 readonly home: V3,
15 readonly homeLook: V3 = [0, 0, 0]
16 ) {
17 this.pos = home;
18 this.look = homeLook;
19 }
20
21 flyTo(pos: V3, look: V3) {
22 this.pos = pos;
23 this.look = look;
24 this.seq++;
25 }
26
27 goHome() {
28 this.flyTo(this.home, this.homeLook);
29 }
30}
31
32export const flyDurationMs = () =>
33 typeof window !== 'undefined' && window.matchMedia('(prefers-reduced-motion: reduce)').matches
34 ? 0
35 : 900;