Reference
Scenarios and automation
Eleven named viewpoints, each a mode, a camera and a time of day. They're deterministic, which is what the smoke test, the HUD's Viewpoints panel, the docs' media capture and the ?scenario= URL all rely on.
village-dayEye level on the path at 10:12, looking down past the stilt houses to the pier.jungle-pathThe hill path under the canopy at 09:24, over the village and lagoon.beachThe south beach at 11:30: crabs, rowing boats and the pier.pier-dayDown the length of the pier at 13:00.pier-sunsetSun 2.2° above the sea, south-west of the pier.pier-night21:24: lamps, lamplight pools on the water, stars.boatAt the helm: windscreen, chart plotter, radar, wheel and throttle.boat-chaseThe chase camera at 15:30 with the wake behind the hull.underwaterThe humpback and its fish schools over the coral bommies, 7 m down.drone-islandThe whole island from 700 m out and 420 m up.drone-lagoonThe lagoon, reef patches and pier from 70 m up.#What a scenario does
game.applyScenario(name) (from src/IslandGame.js):
- pauses the clock and sets the time immediately (
'sunset'means a sun elevation of 2.2° at azimuth 205°, over the sea); - re-seeds the birds and crabs, sets the sea life to a fixed time and moors the boat at the pier head;
- switches mode instantly and places the camera: a walker position and view for
walkandswim, a boat position, heading and camera view forboat, a camera position and view fordrone; - fires a
scenarioevent.
underwater is computed rather than stored: it finds the whale's position at a fixed time and puts you 21 m off its inshore flank, 7 m down, looking at it.
#The table
| Name | Mode | Time | What it shows |
|---|---|---|---|
village-day | walk | 10:12 | The village path down to the pier: stilt houses, stalls, fences, path stones, lamps |
jungle-path | walk | 09:24 | The hill path through the jungle canopy, over the village and lagoon |
beach | walk | 11:30 | The south beach with crabs, rowing boats and the pier |
pier-day | walk | 13:00 | Down the length of the pier |
pier-sunset | walk | sunset | The pier at sunset, sun over the sea |
pier-night | walk | 21:24 | Lamps, lamplight pools on the water, stars |
boat | boat (cockpit) | 12:12 | Windscreen, chart plotter, radar, wheel and throttle; 40% throttle |
boat-chase | boat (chase) | 15:30 | The chase camera with the wake; 55% throttle |
underwater | swim | 12:30 | The humpback with its fish schools over the coral bommies |
drone-island | drone | 12:00 | The whole island from 700 m out |
drone-lagoon | drone | 11:00 | The lagoon, reef patches and pier from 70 m up |
The definitions are in src/config/scenarios.js; add one there and it appears in the HUD, in window.__pro.presets and in the smoke test.
'pier-sunset': {
label: 'Pier at sunset', mode: 'walk', time: 'sunset',
at: [70.5, 236], ...look([70.5, 4, 236], [60, 4.2, 330]),
},
boat: {
label: 'Boat · cockpit', mode: 'boat', view: 'cockpit', time: 12.2,
boat: [170, 330, -2.35],
},#The automation contract
demo/main.js exposes window.__pro, the same contract every NatureGL demo uses:
window.__pro = {
ready: false, // true after the first frame rendered
system: game, // the IslandGame
presets: Object.keys(SCENARIOS), // the eleven scenario names
qualities: Object.keys(QUALITY_LEVELS),// ['low', 'medium', 'high', 'ultra']
applyPreset: name => game.applyScenario(name),
setQuality: level => game.setQuality(level),
rain: on => game.rain.toggle(on), // island extra
};Open the page with ?smoke for automation: the start card is not shown and no scenario is applied at load.
Through __pro.system a script can reach everything else. The docs' videos, for example, hold keys by adding them to game.input.down, so the real controllers do the driving:
const g = window.__pro.system;
g.input.down.add('KeyW'); // walk, throttle up or fly forward, depending on the mode
// …
g.input.down.clear();#The smoke test
npm test # every scenario
node scripts/smoke.mjs --presets beach,boat --quality low --settle 1500 --headedscripts/smoke.mjs starts a Vite dev server on a free port, opens demo/?smoke at 1280×720 in Chromium on the real GPU (--use-angle=metal), waits for __pro.ready, then for every scenario:
- calls
__pro.applyPreset(name); - waits for the settle time (2 s by default);
- counts frames for 2 s to get the fps;
- saves
test-results/<name>.png.
It prints the renderer string, any warnings, and the min, median and max fps. It exits non-zero on any page error, console error or HTTP error (except a missing favicon).
#Other scripts
| Script | Does |
|---|---|
node scripts/shot.mjs [--presets a,b] [--quality q] [--eval js] [--out dir] | Screenshots scenarios to test-results/shots/ without the error gate |
node scripts/play-test.mjs | Drives the real input path with key presses: walks the pier, boards the boat, throttles and steers, switches to the chase camera, leaves, flies the drone, lands, swims and dives. Screenshots each step to test-results/play/. |