Skip to content

Bake project-owned terrain

quick start Beginner ⏱ 6 min vgai 0.1.0

Prerequisites: Installed vgai and run the editor

What you'll learn

  • Run a scene that uses ordinary GLB terrain
  • See a baked sum-of-sines heightfield
  • Understand why generation belongs to the project

What you'll build: A look at the terrain scene β€” a reproducibly baked heightfield GLB.

Walkthrough β€” Bake project-owned terrain Β· generated by site/media/lessons/scenes-batch.lesson.ts (4 steps)

The terrain scene loads a normal project-owned GLB. Its source script uses native Three.js to build a horizontal heightfield from a deterministic sum of sines, then bakes the result to the model asset that the scene and its trimesh collider consume.

  1. Open the terrain scene. The scene is already open β€” if you followed the link above, the terrain scene is loaded and rendering (in the local dev editor: VGAI_PROJECT=examples/feature-scenes npm run dev, then open scenes/terrain.vscn.json).

    The terrain scene loaded
    The terrain scene.
  2. Enter play mode β€” the project-owned GLB loads. The model contains an XZ plane displaced in +Y; the runtime does not need a terrain-specific engine type.

    The procedural terrain rendered
    A generated heightfield.
  3. A baked sum-of-sines heightfield renders. The generation script owns width, depth, segments, amplitude, and frequency, and the resulting model pairs with a trimesh collider that follows its actual surface.

    The terrain surface
    Deterministic terrain.
  4. Stop play mode. Press Stop (or Escape).

Recap

New functionality

  • Ran a scene using ordinary GLB terrain
  • Saw a reproducibly baked heightfield

New concepts & skills

  • Terrain is project-owned content
  • Generation can use native Three.js directly
  • The checked-in GLB pairs with a trimesh collider

Next lesson β†’ Manual: Instancing, terrain & splines

On Your Own!

Extend what you built:

  • Raise amplitude in the project generator for taller hills
  • Regenerate the GLB with more segments
  • Author a replacement terrain in Blender