Examples
Every preview on this page is the real engine, running in the page: the site consumes marble3 as an npm package the way your app would, and nothing is a video. Previews start on their own as you scroll to them and pause when you scroll away (two draw at a time, one on a phone). Play, on each preview, opens the game on a page of its own: the whole window, with the controls in your hands.
Each example is one directory under website/demos/ exporting mount, the small contract this page embeds; its README explains it. At its core every one is still the engine's whole integration story: build a world, start() it, mount the element it returns.
Voxel world
Grass blocks hanging at every height up to 210 under a pale blue sky, over a floor of grass. Press Play to start on the largest ledge of floating blocks one jump apart and hop across; fall off and R brings you back. The Terrain panel reshapes it: width, seed, the terrain noise, and each ore's scarcity and scale.
Source: website/demos/voxel-world/: index.ts (the world), materials.ts (the blocks and ore veins), panel.ts (the terrain panel), credits.ts (whose textures they are); the six block tiles in assets/blocks/.
Things to notice:
- The noise swings 198 blocks every 10, which asks for about 270,000 blocks. VoxelTerrain gives each block type 20,000; the dirt, stone and ore overflow theirs, so the world hides those types and only the grass tops float.
- Collision is each column's top block alone, so every floating block is a platform. A jump rises 1.8 blocks: a ledge one block up, two cells over, is in reach.
- The
MaterialMapis called for every block's(x, y, z): grass on top, then the first ore whose 3D simplex noise rises above its scarcity, else dirt. Lower the magnitude in the panel and the columns fit again, ores and all.
Solar system
A walkable Solar System: the Sun and the eight planets orbiting on yellow rings under the Milky Way, the Moon circling Earth, a satellite circling with it, and Voyager 1 far out past the planets. Nothing is to scale — distances follow the square root of the real ones — so every planet is a walk away. Press Play, walk out to one, aim and click for its facts.
Source: website/demos/solar-system/: index.ts (the world), bodies.ts (the planets, spacecraft and their facts), planet.ts (a planet), prop.ts (a spacecraft model), info-card.ts (the facts card), credits.ts (whose assets these are); textures, sky and models in assets/.
Things to notice:
- Each planet is a static
PhysicEntitywith a sphere shape — solid, and pickable by theLookAtCursorray — that moves itself along its orbit and refreshes its broadphase box withworld.updateSingleAabbso the ray still finds it. - The spacecraft are
StaticMeshbodies: the full glTF model is drawn while a decimated proxy is the collision shape, both scaled by the same transform. - The floor is a bare
btStaticPlaneShapewith nothing drawn, so the sky shows under your feet.
Asteroid world
A field of grey voxel rubble under the Milky Way, the sky slowly wheeling overhead, and a shower of diamonds tumbling onto the rock. Press Play, walk over one or aim at it and click to pick it up. Every fifth find doubles your speed, and when the field is empty another shower falls.
Source: website/demos/asteroid-world/: index.ts (the world), diamond.ts (a diamond), materials.ts (the rubble), credits.ts (whose sky it is); the sky in assets/.
Things to notice:
- A diamond is a
Collectible: a dynamic body whose convex-hull shape comes from the gem's own geometry, so it falls and tumbles onto the rock like anything else, and is picked up by walking over it or clicking it. - The terrain streams collision bodies around every moving body, the diamonds included, so they land on it like the player does.
- The sky is the scene's cube-texture background, turned with
scene.backgroundRotation.
Quick FPS
An arena of tiled pillars under a low sun, where waves of enemies come for you: red walkers that bite, flyers that hover overhead and drop a cage on you, now and then a pink brute, and a green boss on wave 5. Press Play, click (or hold) to shoot and F to switch between a pistol, a rocket launcher and a laser. Clear a wave and you heal; a bigger one follows. Tutorial, on the preview, opens Build an FPS, which builds a smaller version of this game in seven chapters.
Source: website/demos/quick-fps/: index.ts (the world), terrain.ts (the arena), combat.ts (shooting and waves), enemy.ts and flying-enemy.ts (the enemies), weapon.ts (the guns), hud.ts (the screen), credits.ts (whose guns they are); the models in assets/guns/.
Things to notice:
- An enemy is a
CharacterEntity, the same body and controller as the player: each frame it sets a walk direction at you, and the controller does the rest. - A shot is
raycastFromCamera: a Bullet ray from the crosshair, whose hit names the entity it struck. The gun model is parented to the camera and has no body, so it never blocks the ray. - The guns are glTF models, Draco-compressed;
GLTFLoaderdecodes them with three.js's own decoder, bundled like any other asset.
Board scene
The board-game recipe: a Game looked at from above and the slot-based HUD doing the rest — a score line up top, a blinking hint, a button below the board, and a dialog when you win. Press Play to score.
Source: website/demos/board-scene/: index.ts (the whole game).
Things to notice:
- Every HUD call upserts by id —
hud.text('score', …)is called on every click and just rewrites the line. --hud-gappositionsabove-center/below-centerrelative to the board's size; the game knows how big its board is, the HUD doesn't. A percentage keeps it inside whatever box the game is mounted in.- The dialog takes the pointer while open; the world underneath is dimmed and unclickable.