Stage 3. moons.js: 21 moons as lit spheres with local per-parent compression (clear the exaggerated parent, ordering preserved), retrograde via negative period. rings.js: Saturn textured annulus (true 74500–140220 km scaled with parent) + Uranus thin schematic ring, tilted with axial tilt, DoubleSide. Moons draw at the parent's exaggeration so Io/Jupiter ≈ 0.026 ratio holds. Label visibility gated via CSS2DObject.visible (CSS2DRenderer clobbers div.style.display every frame — fixed). Gate: Galilean laps 1.00:0.50:0.25 (1:2:4), Triton retrograde (Δθ<0), moons ordered io<europa<ganymede<callisto. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
44 lines
1.8 KiB
JavaScript
44 lines
1.8 KiB
JavaScript
// SOLARGOD moons layer (Stage 3) — every moon in the registry as a lit sphere,
|
|
// positioned by ctx.bodyWorld (main.js computes the local compressed offset in the
|
|
// parent's equatorial plane; retrograde via negative period). Moons draw at the
|
|
// SAME exaggeration as their parent, so the true radius ratio (e.g. Io/Jupiter
|
|
// ≈ 0.026) is preserved. Labels appear only when the parent (or the moon) is the
|
|
// focus, to keep the wide view clean (brief §5).
|
|
|
|
export default function create(ctx) {
|
|
const { THREE, scene, CONFIG, ui, scale, bodies, focus, toLocal, effectiveE, makeLabel, registerPick } = ctx;
|
|
|
|
const entries = [];
|
|
for (const id in bodies) {
|
|
const b = bodies[id];
|
|
if (b.type !== 'moon') continue;
|
|
const mat = new THREE.MeshStandardMaterial({ color: new THREE.Color(b.color), roughness: 1, metalness: 0 });
|
|
const mesh = new THREE.Mesh(new THREE.SphereGeometry(1, 24, 16), mat);
|
|
mesh.visible = true;
|
|
scene.add(mesh);
|
|
registerPick(mesh, id);
|
|
const lbl = makeLabel(mesh, b.name, 'body-label moon');
|
|
lbl.obj.visible = false; // CSS2DRenderer honors obj.visible (not div.style.display)
|
|
entries.push({ id, b, mesh, lbl });
|
|
}
|
|
|
|
let show = true;
|
|
ui.addLayer('moons', 'Moons', true, (on) => { show = on; for (const e of entries) e.mesh.visible = on; });
|
|
ui.setStatus('moons', `${entries.length} moons`, 'ok');
|
|
|
|
return {
|
|
id: 'moons',
|
|
onClockTick(simMs, jd) {
|
|
for (const e of entries) {
|
|
const abs = ctx.bodyWorld[e.id];
|
|
if (!abs) continue;
|
|
toLocal(abs, e.mesh.position);
|
|
e.mesh.scale.setScalar(scale.drawRadius(e.b.radiusKm, effectiveE(e.b.parent)));
|
|
const near = focus.id === e.b.parent || focus.id === e.id;
|
|
e.lbl.obj.visible = show && near;
|
|
e.lbl.div.classList.toggle('focused', e.id === focus.id);
|
|
}
|
|
},
|
|
};
|
|
}
|