Skip to content

Development source guide ยท workspace 0.1.0

Scenes, cameras and visual effects

A scene becomes understandable when you can answer four questions: which objects exist, which geometry each one uses, where the camera looks and which rendering path presents them. Start there before adding advanced effects.

Choose the rendering path

Path Good starting use Important boundary
Basic application scene Learning transforms, showing simple mesh objects and testing a small interaction Its standard shader uses grayscale directional diffuse lighting; it is not an automatic textured material renderer.
Custom 3D rendering A game that explicitly prepares meshes, draw lists, environment and effects The game must upload resources, populate lists and implement its draw integration. It is not activated by adding settings to game.toml.

Use the first scene to establish the basic path. Do not interpret a successfully imported model as proof that its textures, materials or animation will appear in that path.

Place an object where the camera can see it

For the basic scene, create a mesh during initialization, add an entity with a transform and associate it with the corresponding mesh index. Set the camera view deliberately.

When an object is missing:

  1. Confirm the entity still exists and has both transform and mesh-index components.
  2. Confirm its index refers to a mesh uploaded during initialization.
  3. Check its position and mesh dimensions. The basic transform has position and rotation, not a scale field; change geometry dimensions or use a custom scaled instance where appropriate.
  4. Check camera direction and distance.
  5. Check clipping before changing the model itself.

The standard runner's perspective projection uses a 1.0-radian field of view, a near distance of 0.1 and a far distance of 500.0. Those are basic-runner values, not universal limits of every custom renderer.

Moving an object along world X is not the same as moving it horizontally across the screen. Camera orientation changes the visible direction. The first tutorial intentionally keeps the camera fixed so that distinction is easy to observe.

Work with imported models honestly

The inspected glTF loader extracts primitive positions, normals, first UV coordinates and indices. It can supply fallback normals, zero UVs or generated indices when those fields are absent, and skips primitives without positions.

That loader alone does not recreate a full imported scene with node transforms, material bindings, a skin and running animation. Decide which information your game needs and trace the path that actually consumes it.

A useful model-import test is one known asset, a known camera and one visible result. Only after checking geometry should you diagnose materials, animation or a large scene. Read asset access and packing before assuming a file on disk will be present in a release.

Build a custom visual scene

The custom renderer exposes mesh construction, mesh instances and draw lists. The game can submit transforms and tints, selected surface finishes, blob shadows, billboards, glow particles and water rectangles.

A practical integration has these stages:

  1. Create or load geometry and explicitly upload it.
  2. Keep valid renderer mesh IDs for the resources you use.
  3. Add the intended instances and effects to draw lists for the current frame.
  4. Build a frame with camera, time and environment settings.
  5. Render through the game's draw hook.
  6. Rebuild the lists for the next frame; the renderer clears submitted lists after rendering.

These are programming interfaces, not a serialized material-node editor. Missing renderer mesh IDs are skipped, so a silent missing object can be a resource-registration problem rather than a camera problem.

Set environment and lighting

The custom environment describes sky colors, fog, ambient and sun color, stars and moon. Time-of-day keys can interpolate across a 24-hour wrap. The game decides how its world clock drives that environment.

The custom frame accepts point lights, but uses only the first four. Do not plan a scene around unlimited per-frame point lights without changing the implementation. Fog and lighting belong to the chosen rendering integration, not automatically to every mesh that exists in the entity world.

Voxel light propagation is a separate grid-based tool. Its sky and block channels use four bits each. Supplying that grid and applying its results to visuals are game work; arbitrary imported models do not become part of a voxel lighting world by default.

Cameras and presentation

Camera tools include follow behavior, shake and volume-selected or rail-style shots. The game must update the camera and use its resulting matrix. Choosing a camera-volume rule is not equivalent to automatically attaching a camera to every player entity.

Retro-style presentation can combine fixed internal resolution, snapping, dithering and affine-style rendering in the appropriate path. These are distinct choices; lowering resolution alone does not implement every retro effect.

For a letterboxed or fixed-resolution presentation, convert pointer coordinates before hit testing. The context's view-coordinate helper maps the window into ctx.fixed_res, or leaves the coordinates unchanged when no fixed resolution is configured. If UI logical resolution differs from that internal render resolution, apply the additional scale too. It is not a universal DPI/UI transform. A menu can look correctly placed but respond to the wrong position if these spaces are mixed.

Animation and cutscenes

Animation needs a skeleton, clips, an animator and game integration. A clip supplies timed bone tracks; the game advances it and applies the result. Replaying the current clip does not automatically restart it, and root-motion deltas are returned for the caller to apply.

A minimal clip row, for a game with a bone named root, is:

[
  {
    "id": "turn",
    "len": 1,
    "loop": true,
    "tracks": {
      "root": [[0, 0, 0, 0], [1, 0, 90, 0]]
    }
  }
]

This describes a one-second rotation track using XYZ degrees. It is not a file you can drop into every project and expect to play: the skeleton, loading path and animation call still need to exist.

Cutscene tools provide timed camera/actor/effect information and cues. Game code executes those cues and binds any skip control. The available hold-to-skip helper uses 0.4 seconds; it does not add a universal player key or menu automatically.

Particle effects and budgets

The implemented particle path uses presets and a fixed-capacity pool. It supports seeded variation, lifetime/speed ranges, gravity or drag, size/color changes and selected ground responses. The game must spawn particles, update the pool and submit its visible output.

When capacity is exhausted, new particles are dropped and the dropped count increases. Raising the pool capacity trades memory and work for capacity; it is not a guarantee of better-looking results. Start with a small effect and inspect its count and visibility.

Richer chained-emitter and attachment descriptions in design material are not a guarantee that those exact interfaces exist. Use the current preset/pool API instead of inventing configuration keys from a sketch.

Continue with interface integration, audio or inspection to connect presentation to actual game behavior.