Fix galaxy flow motion and lock overlap separation
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
lerpPos,
|
||||
moonPositions,
|
||||
positionOnEllipse,
|
||||
relaxLockedMoons,
|
||||
} from "../../lib/galaxyLayout";
|
||||
import {
|
||||
layoutLockLabels,
|
||||
@@ -83,13 +84,28 @@ export function BlackholeGalaxy({
|
||||
const starOrbits = useMemo(() => orbits.slice(0, MAX_STARS), [orbits]);
|
||||
const snapsByOrbit = useMemo(() => groupSnaps(snapshots), [snapshots]);
|
||||
|
||||
const lockLabels = useMemo(() => {
|
||||
const positions = starOrbits.map((_, i) =>
|
||||
lockedSlot(i, starOrbits.length),
|
||||
const lockLayout = useMemo(() => {
|
||||
const n = starOrbits.length;
|
||||
if (!n) {
|
||||
return { stars: [] as { x: number; y: number }[], moons: [] as { x: number; y: number }[][], labels: [] as { x: number; y: number }[] };
|
||||
}
|
||||
const stars = Array.from({ length: n }, (_, i) =>
|
||||
lockedSlot(i, n),
|
||||
);
|
||||
const names = starOrbits.map((o) => o.name);
|
||||
return layoutLockLabels(positions, names, STAR_R_LOCK);
|
||||
}, [starOrbits]);
|
||||
const rawMoons = starOrbits.map((orbit, i) => {
|
||||
const moons = snapsByOrbit.get(orbit.name) ?? [];
|
||||
return moonPositions(stars[i].x, stars[i].y, moons.length, 0, false, 36).map(
|
||||
(p) => ({ x: p.x, y: p.y }),
|
||||
);
|
||||
});
|
||||
const moons = relaxLockedMoons(stars, rawMoons);
|
||||
const labels = layoutLockLabels(
|
||||
stars,
|
||||
starOrbits.map((o) => o.name),
|
||||
STAR_R_LOCK,
|
||||
);
|
||||
return { stars, moons, labels };
|
||||
}, [starOrbits, snapsByOrbit]);
|
||||
|
||||
const showLabels = !flowing || blend < 0.35;
|
||||
|
||||
@@ -167,21 +183,21 @@ export function BlackholeGalaxy({
|
||||
phys.tiltDeg,
|
||||
);
|
||||
const lockPos = lockedSlot(i, starOrbits.length);
|
||||
const { x, y } = lerpPos(flowPos, lockPos, 1 - blend);
|
||||
const { x, y } = lerpPos(flowPos, lockPos, blend);
|
||||
const moons = snapsByOrbit.get(orbit.name) ?? [];
|
||||
const color = statusColor(orbit.last_status);
|
||||
const starR = flowing ? STAR_R_FLOW : STAR_R_LOCK;
|
||||
const interactive = !flowing || blend < 0.15;
|
||||
const label = lockLabels[i];
|
||||
|
||||
const moonPts = moonPositions(
|
||||
const label = lockLayout.labels[i];
|
||||
const flowMoons = moonPositions(
|
||||
x,
|
||||
y,
|
||||
moons.length,
|
||||
t,
|
||||
flowing && blend > 0.5,
|
||||
34,
|
||||
true,
|
||||
36,
|
||||
);
|
||||
const lockMoons = lockLayout.moons[i] ?? [];
|
||||
|
||||
return (
|
||||
<g key={orbit.id}>
|
||||
@@ -212,7 +228,15 @@ export function BlackholeGalaxy({
|
||||
}}
|
||||
/>
|
||||
{moons.map((moon, mi) => {
|
||||
const mp = moonPts[mi];
|
||||
const flowMp = flowMoons[mi];
|
||||
const lockMp = lockMoons[mi];
|
||||
const mp = lockMp
|
||||
? lerpPos(
|
||||
{ x: flowMp.x, y: flowMp.y },
|
||||
lockMp,
|
||||
blend,
|
||||
)
|
||||
: flowMp;
|
||||
const sel = moon.id === selectedSnapshotId;
|
||||
const mr = flowing ? 3.8 : sel ? 7.5 : 6;
|
||||
const hit = flowing ? mr : MOON_HIT_LOCK;
|
||||
|
||||
Reference in New Issue
Block a user