Widen galaxy orbits, relax lock layout, enlarge vault disk

This commit is contained in:
Tessera Agent
2026-11-09 10:56:21 +00:00
parent a920235feb
commit 2085b35cfa
2 changed files with 111 additions and 45 deletions

View File

@@ -1,4 +1,4 @@
/** Flow + lock layouts in viewBox coordinates (±~240). */
/** Flow + lock layouts in viewBox coordinates (origin center, ±~300). */
export type OrbitPhysics = {
rx: number;
@@ -8,16 +8,33 @@ export type OrbitPhysics = {
phase: number;
};
const GOLDEN = 2.399963229728653;
export type Vec2 = { x: number; y: number };
const GOLDEN = 2.399963229728653;
const VIEW_R = 258;
/** Per-star ellipses from inner rim to ~90% of viewport radius. */
export function flowOrbitPhysics(index: number, total: number): OrbitPhysics {
const ring = index % 4;
const n = Math.max(total, 1);
const lane = index / Math.max(n - 1, 1);
const band = index % 5;
const rx =
92 +
lane * (VIEW_R - 92) +
band * 7 +
((index * 11) % 5) * 4;
const ry =
68 +
((index * 13) % 9) * 14 +
lane * 72 +
(index % 3) * 9;
const tiltDeg = -42 + ((index * 23 + band * 17) % 84);
return {
rx: 128 + ring * 26 + (index % 3) * 12,
ry: 88 + (index % 5) * 16 + ring * 12,
tiltDeg: -28 + (index * 19) % 56,
speed: 0.06 + (index % 7) * 0.011,
phase: (index / Math.max(total, 1)) * Math.PI * 2 + index * 0.17,
rx: Math.min(rx, VIEW_R),
ry: Math.min(ry, VIEW_R * 0.88),
tiltDeg,
speed: 0.05 + (index % 9) * 0.009 + band * 0.004,
phase: (index / n) * Math.PI * 2 + index * GOLDEN * 0.15,
};
}
@@ -26,7 +43,7 @@ export function positionOnEllipse(
rx: number,
ry: number,
tiltDeg: number,
): { x: number; y: number } {
): Vec2 {
const ex = Math.cos(angle) * rx;
const ey = Math.sin(angle) * ry;
const rad = (tiltDeg * Math.PI) / 180;
@@ -36,46 +53,94 @@ export function positionOnEllipse(
};
}
/** Even spread with minimum separation — polar slots + ring stagger. */
export function lockedSlot(index: number, total: number): { x: number; y: number } {
const n = Math.max(total, 1);
function slotSeed(index: number, total: number): Vec2 {
const angle = -Math.PI / 2 + index * GOLDEN;
const band = index % 3;
const radius = 138 + band * 48 + Math.floor(index / 3) * 6;
const squash = 0.92 + (index % 2) * 0.06;
const band = index % 4;
const radius = 118 + band * 46 + Math.floor(index / 4) * 10;
const squash = 0.9 + (index % 3) * 0.05;
return {
x: Math.cos(angle) * radius,
y: Math.sin(angle) * radius * squash,
x: Math.cos(angle) * Math.min(radius, VIEW_R),
y: Math.sin(angle) * Math.min(radius, VIEW_R) * squash,
};
}
function dist(a: Vec2, b: Vec2): number {
const dx = a.x - b.x;
const dy = a.y - b.y;
return Math.hypot(dx, dy);
}
const layoutCache = new Map<number, Vec2[]>();
/** Golden-angle seeds relaxed for minimum star separation (lock mode). */
export function lockedPositions(total: number): Vec2[] {
const cached = layoutCache.get(total);
if (cached) return cached;
const pts = Array.from({ length: total }, (_, i) => slotSeed(i, total));
const minSep = total > 14 ? 38 : 44;
for (let iter = 0; iter < 32; iter++) {
for (let i = 0; i < total; i++) {
for (let j = i + 1; j < total; j++) {
const d = dist(pts[i], pts[j]);
if (d < minSep && d > 0.001) {
const push = (minSep - d) * 0.55;
const ux = (pts[i].x - pts[j].x) / d;
const uy = (pts[i].y - pts[j].y) / d;
pts[i].x += ux * push;
pts[i].y += uy * push;
pts[j].x -= ux * push;
pts[j].y -= uy * push;
}
}
const r = dist(pts[i], { x: 0, y: 0 });
const vaultPad = 78;
if (r < vaultPad && r > 0.001) {
const s = vaultPad / r;
pts[i].x *= s;
pts[i].y *= s;
}
const edge = dist(pts[i], { x: 0, y: 0 });
if (edge > VIEW_R) {
const s = VIEW_R / edge;
pts[i].x *= s;
pts[i].y *= s;
}
}
}
layoutCache.set(total, pts);
return pts;
}
export function lockedSlot(index: number, total: number): Vec2 {
return lockedPositions(total)[index] ?? slotSeed(index, total);
}
export function moonPositions(
cx: number,
cy: number,
count: number,
time: number,
flowing: boolean,
baseSpread = 26,
baseSpread = 32,
): { x: number; y: number; angle: number }[] {
const out: { x: number; y: number; angle: number }[] = [];
for (let mi = 0; mi < count; mi++) {
const slice = (mi / Math.max(count, 1)) * Math.PI * 2;
const angle = flowing ? slice + time * (0.45 + mi * 0.05) : slice - Math.PI / 2;
const dist = flowing ? baseSpread * 0.55 : baseSpread + (mi % 2) * 4;
const angle = flowing ? slice + time * (0.4 + mi * 0.06) : slice - Math.PI / 2;
const dist = flowing ? baseSpread * 0.62 : baseSpread + (mi % 2) * 5;
out.push({
angle,
x: cx + Math.cos(angle) * dist,
y: cy + Math.sin(angle) * dist * 0.85,
y: cy + Math.sin(angle) * dist * 0.86,
});
}
return out;
}
export function lerpPos(
a: { x: number; y: number },
b: { x: number; y: number },
t: number,
): { x: number; y: number } {
export function lerpPos(a: Vec2, b: Vec2, t: number): Vec2 {
return {
x: a.x * t + b.x * (1 - t),
y: a.y * t + b.y * (1 - t),