Skybox and lights
Skybox
import { createSkybox } from '@maomi/sge/skybox';
fps.scene.add(createSkybox('/assets/skybox/night'));The engine is agnostic about which skyboxes exist — you pass a directory; the engine owns only the convention inside it: six WebP cube faces named
<dir>/left.webp right.webp up.webp down.webp front.webp back.webpOptional arguments: size (default 2000) and opacity (a shader-based fade, for layering or transitions).
Lights
defaultLights(options) returns a group with the standard rig: hemisphere + ambient fill and one shadow-casting directional light. The options that matter are all about the shadow frustum:
| Option | What it does |
|---|---|
shadowExtent | half-size of the square shadow footprint. The 2048² map is spread over (2·extent)², so smaller = sharper. Default 100 suits large roaming worlds; a fixed 50×50 level wants ~30. |
shadowNormalBias | acne vs. contact: default 0.02 is safe for uneven/voxel ground; pass 0 for flat floors so contact shadows hug bases. |
shadowCenter | where the footprint is centered (default: origin). A world built around a non-zero center must pass its center, or distant geometry falls outside the footprint and gets acne strips instead of shadows. |
Backdrops
For orbit scenes that don't want a skybox, stageBackdrop(centre, edge, lattice) (from @maomi/sge/backdrop) paints a lit-stage gradient onto scene.background: a pool of light in the middle, vignetted corners, a faint lattice for texture. Made for board games viewed from above.
Scene transitions
fadeOut() / fadeIn() (from @maomi/sge/transition) drive a full-screen black overlay — a module singleton that survives route changes, so a world swap can fade through black:
await fadeOut();
swapWorlds();
await fadeIn();