logo
By Lawrence

5 minutes

Put the Ship on Screen

A space fighter is the easiest thing in this game to get nearly right. By the end of this lesson the real falconship is on screen, lit, facing the way you expect. By the end of the next one you'll know why the obvious way to make it face that direction breaks the moment the ship rolls.

Start with a project and the assets.

bjs create spaceshooter && cd spaceshooter
bjs download scene SpaceshooterFlight1 --all

That second command does the real work: it reads the scene, acquires every component it names, downloads the GLB assets it references, and drops the lot under public/scenes/. Nothing is copied by hand — this is the same path a member takes, so if it works here it works for them.

Three entities and nothing else

Open src/scenes/spaceshooter.json. The whole scene is three entities:

{
  "Ambient": {
    "tags": ["ambient"],
    "components": {
      "HemisphericLight": { "direction": [0, 1, 0], "intensity": 0.45, "diffuse": [0.7, 0.78, 0.95] }
    }
  },
  "Camera": {
    "tags": ["camera"],
    "components": {
      "CameraState6DOF": {
        "x": -7, "y": 3, "z": -7,
        "q": [0.913899, 0.135435, 0.378549, -0.056099],
        "fov": 1.05, "near": 0.1, "far": 200000
      }
    }
  },
  "Player": {
    "tags": ["player"],
    "components": {
      "Transform6DOF": { "x": 0, "y": 0, "z": 0, "rx": 0, "ry": 0, "rz": 0 },
      "Renderable": {
        "shape": "spaceplane",
        "sx": 3, "sy": 1, "sz": 4,
        "r": 0.55, "g": 0.62, "b": 0.78,
        "emissive": 0.18,
        "selfShadow": true,
        "glbSrc": "/spaceshooter/falconship.glb"
      }
    }
  }
}

A light, a camera, and a ship. The far plane at 200000 looks absurd until you remember there is no horizon out here — Course 3 draws its sky as a box 160000 units across, whose corners sit some 138,000 units from your eye, and a nearer plane would slice them off.

Continue reading

Unlock the Full Course

Every lesson, the runnable examples, and the finished build — yours to keep.

$9one-time

Was this page helpful?

We read every note — tell us what's working and what isn't.

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search