Skip to content

3D games

Phase 5c added 3D (ADR 0026). Start from the template with pnpm create-game my-island --template island, or use Start from the 3D template in the platform editor.

In game.json:

  • "display": { "mode": "3d", ... }
  • "physics": { "engine": "rapier3d", "gravity3d": { "x": 0, "y": -20, "z": 0 } }

With these, the game loads:

  • Three.js, for rendering;
  • deterministic Rapier, for physics.

Both come as a separate chunk that 2D games never download. The 2D renderer stays on top as a transparent layer, so HUD widgets, menus, banners, the dialogue box and touch controls work as in 2D. Units are metres, and y is up.

A scene names a 3D level with "level3d": "levels3d/island.json". 3D levels live in game/levels3d/, and contain:

  • pieces: blocks such as box, ramp, cylinder and sphere. Each has a position (its centre), a size, an optional rotation (degrees), a color, and collides. A ramp rises from height 0 at its -x side to size.y at its +x side.
  • objects: prefab spawns with a position, trigger boxes that emit trigger:<event>, and named points.
  • lights (default: soft ambient light plus a sun with shadows) and sky (colour and fog).
  • killY: entities that fall below it emit <name>:fell. Answer with respawn, which returns them to where they started.

AI tools: read_level3d and edit_level3d.

Placement and drawing:

  • Transform3D: position, rotation in degrees, and scale.
  • Mesh: a primitive shape and colour.
  • Model: a glTF model, declared as an asset of type model (.glb), with an animation clip playing.
  • Light3D: a light.
  • Camera3D: a camera that follows a target at a set distance and height (turned with the cameraX axis), or stays fixed.
  • Spin3D: turns and bobs an entity, for collectibles.

Physics:

  • Collider3D: box, sphere, capsule, cylinder or ramp. Set sensor for trigger zones, with event, filterTag and once.
  • RigidBody3D: dynamic, fixed or kinematic. An entity with only a Collider3D gets a fixed body.
  • Mover3D: moves a kinematic body back and forth (and spins it). Characters standing on it ride along.

Characters:

  • CharacterController3D: walks relative to the camera, climbs slopes and steps, and jumps with coyote time and buffering. It emits <name>:jumped and <name>:landed.
  • CharacterAnimator3D: plays the model’s idle, run, jump and fall clips.

A Pickup with a sensor Collider3D is collected when touched, as in 2D. Each scene’s state gets <kind>Total, the number of pickups of each kind.

The template’s models are written as .glb from code (templates/island/tools/gltf.ts): flat-shaded boxes, cylinders and gems, a node tree, and rotation animations. Models made in other tools work too, as long as they are .glb files or .gltf files with embedded buffers.

  • No visual 3D level editor yet: edit 3D levels as JSON or with the AI tools, and check them in the preview.
  • 3D screenshots need a browser; headless runs simulate physics without drawing.
  • Content packs cannot add 3D levels yet.