Skip to content
Sina Hassan

Loading planet…

Lab · Playable demo

Planet Rounds

Click or tap the surface to blast a crater. Drag to orbit, and switch maps from the panel.

How it's built

A Unity game's planets, in the browser

Planet Rounds is a networked tank game I'm building in Unity, fought on small voxel planets where every shell carves the terrain. Rather than ship a heavy engine build, I rebuilt the planet renderer and crater system for the web in TypeScript, Three.js, and React Three Fiber, using the game's real map data.

  1. 01Reading the game's maps

    Planet Rounds stores each planet as a .vmap file: a palette, optional material kinds per color (glowing, crystal, brittle), and a run-length encoded grid of 16-bit cells, deflated.

    A Node bake script downsamples each map to a 170³ grid by majority vote, so thin features survive and colors stay true, then writes a compact web format. The browser inflates it with the native DecompressionStream, so no compression library ships to the client.

  2. 02Meshing off the main thread

    A Web Worker turns the grid into geometry, emitting only faces that touch empty space. Every vertex gets four-level ambient occlusion from its neighboring cells, and quads flip their diagonal where needed so the shading never streaks.

    The planet is split into 24³ chunks. Buffers move back to the page as transferables, so nothing is copied, and the interface stays responsive while a planet loads.

  3. 03Destruction

    A click raycasts the surface, and the worker clears a jittered sphere of cells, scorches the rim, and rebuilds only the chunks the crater touched.

    The removed cells come back as debris: up to 900 sampled voxels per blast feed an instanced pool that falls back toward the planet's center, alongside an additive shockwave, a flash light, and camera shake.

  4. 04Rendering

    React Three Fiber renders a standard PBR material patched in onBeforeCompile with a per-vertex glow attribute, so the game's glowing and crystal materials pulse and catch the bloom pass while ordinary terrain doesn't.

    A fresnel shell draws the atmosphere. A performance monitor lowers the pixel ratio on slower devices, and the render loop stops entirely while the planet is off screen.

  5. 05Accessibility

    The canvas is labeled for screen readers, and a real button blasts a crater near the center of the view, so the demo works from the keyboard. Results are announced through a live region.

    With reduced motion, the planet stops auto-rotating, the camera no longer shakes, and debris moves more gently. On touch screens, the embedded demo doesn't trap page scrolling.

Baked maps

Size and visible surface voxels of each baked 170³ map
MapDownloadSurface voxels
Coral Reef783 KB91,885
Spiky Orb457 KB67,148
Cursed Orb311 KB134,901
Tiny Terra Haven1.5 MB64,642
Circular Cityscape1.45 MB69,782

Also on this site

The portrait on the home page started as a 77 MB GLB. A second bake script samples 72,000 points across its surface, weighted toward the face, keeps the texture color under each one, and quantizes everything into a 914 KB buffer. A custom shader assembles it, shows it in monochrome, and dissolves it on scroll. Under the cursor, a denser 180,000-point layer fades in with full color, so that patch looks like the original model.

Back to the home page