Initial project setup: Rust/WASM solar system simulator with SvelteKit frontend

- Rust workspace with 4 crates: orbital-mechanics, mass-driver-core, mass-driver-wasm, mass-driver-backend
- Keplerian orbital mechanics engine with JPL elements for 14 bodies (Sun, 8 planets, Pluto, Ceres, Europa, Titan, Ganymede)
- Kepler equation solver and orbital position computation compiled to WASM
- SvelteKit frontend with Tailwind CSS, Canvas2D renderer showing animated solar system
- Orbit ellipses, planet dots with labels, Sun glow, grid, scale bar, pan/zoom controls
- Time controls (play/pause, 5 speed levels, date picker) driving live simulation
- 2D/3D view toggle (3D placeholder for Threlte integration)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-07 22:06:30 -07:00
commit 5efe0736ac
45 changed files with 4626 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
<script lang="ts">
import { onMount } from 'svelte';
import { simulation } from '$lib/stores/simulation.svelte';
import { initWasm } from '$lib/wasm/loader';
import { getBodyInfos } from '$lib/wasm/bridge';
import Viewport from './(simulator)/components/Viewport.svelte';
import TimeControls from './(simulator)/components/TimeControls.svelte';
import ViewToggle from './(simulator)/components/ViewToggle.svelte';
let wasmError = $state('');
onMount(async () => {
try {
await initWasm();
simulation.bodyInfos = getBodyInfos();
simulation.wasmReady = true;
// Start in Jan 2025 for a recognizable view
simulation.setDate(2025, 1, 1);
simulation.isPlaying = true;
} catch (e) {
wasmError = String(e);
console.error('Failed to load WASM module:', e);
}
});
</script>
<div class="h-screen w-screen flex flex-col bg-[var(--bg-primary)]">
<!-- Top bar -->
<header class="flex items-center justify-between px-4 py-2 bg-[var(--bg-secondary)] border-b border-white/5 shrink-0">
<div class="flex items-center gap-3">
<h1 class="text-sm font-bold tracking-wide text-[var(--text-primary)]">
MASS DRIVER
</h1>
<span class="text-xs text-[var(--text-secondary)]">Interplanetary Relay Network</span>
</div>
<ViewToggle />
</header>
<!-- Main content -->
<main class="flex-1 relative overflow-hidden">
{#if wasmError}
<div class="absolute inset-0 flex items-center justify-center">
<div class="bg-red-900/50 border border-red-500/30 rounded-lg p-6 max-w-md">
<h2 class="text-red-400 font-bold mb-2">Failed to load simulation engine</h2>
<p class="text-sm text-red-300/80">{wasmError}</p>
</div>
</div>
{:else if !simulation.wasmReady}
<div class="absolute inset-0 flex items-center justify-center">
<div class="text-center">
<div class="w-8 h-8 border-2 border-[var(--accent-blue)] border-t-transparent rounded-full animate-spin mx-auto mb-3"></div>
<p class="text-sm text-[var(--text-secondary)]">Initializing simulation engine...</p>
</div>
</div>
{:else}
<Viewport />
{/if}
</main>
<!-- Bottom bar: time controls -->
<footer class="px-4 py-2 bg-[var(--bg-secondary)] border-t border-white/5 shrink-0">
<TimeControls />
</footer>
</div>