threedog 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +4 -4
  2. package/core/Assets.js +12 -0
  3. package/core/Engine.js +13 -4
  4. package/core/describeRender.js +7 -1
  5. package/core/grid.js +127 -0
  6. package/core/gridLoad.js +19 -0
  7. package/core/loop.js +7 -2
  8. package/core/renamed.js +1 -0
  9. package/core/styleParts.js +9 -7
  10. package/docs/AI.md +28 -23
  11. package/docs/API.md +3 -3
  12. package/docs/CODEMAP.md +5 -3
  13. package/docs/COMMANDS.md +5 -3
  14. package/docs/CONVENTIONS.md +6 -6
  15. package/docs/api/assets.md +1 -0
  16. package/docs/api/characters.md +3 -2
  17. package/docs/api/engine.md +3 -3
  18. package/docs/api/style.md +7 -7
  19. package/docs/api/tools.md +3 -2
  20. package/docs/api/vegetation.md +1 -0
  21. package/docs/recipes/01-new-game.md +41 -43
  22. package/docs/recipes/02-npc.md +24 -24
  23. package/docs/recipes/03-items-pickups.md +4 -4
  24. package/docs/recipes/04-quests.md +23 -23
  25. package/docs/recipes/05-props-bake.md +5 -5
  26. package/docs/recipes/07-flow-scenes-pause.md +2 -2
  27. package/docs/recipes/08-weather-sky.md +5 -5
  28. package/docs/recipes/09-style-pack.md +35 -100
  29. package/docs/recipes/13-animation.md +22 -6
  30. package/docs/recipes/14-custom-module.md +6 -7
  31. package/docs/recipes/15-perf.md +8 -0
  32. package/docs/recipes/16-dev-bridge.md +7 -7
  33. package/docs/recipes/18-world.md +5 -2
  34. package/docs/recipes/19-shooting-picking.md +9 -8
  35. package/docs/recipes/20-content-actions-save.md +10 -10
  36. package/docs/recipes/22-shop-gold.md +16 -16
  37. package/docs/recipes/23-ops.md +2 -2
  38. package/docs/recipes/27-net.md +2 -2
  39. package/docs/recipes/28-terrain.md +2 -2
  40. package/docs/recipes/29-grid.md +47 -27
  41. package/docs/recipes/34-environment-lighting.md +2 -2
  42. package/docs/recipes/35-style-from-reference.md +41 -46
  43. package/docs/recipes/36-sky-ground-plant-looks.md +22 -20
  44. package/docs/recipes/37-terrain-look-hooks.md +34 -13
  45. package/docs/recipes/38-environment-look-hooks.md +47 -42
  46. package/docs/recipes/42-terrain-shape.md +1 -1
  47. package/docs/recipes/43-shader-patches-surface-looks.md +35 -20
  48. package/docs/recipes/44-water-weather-look-hooks.md +5 -5
  49. package/docs/recipes/45-cascaded-shadows.md +1 -1
  50. package/docs/recipes/46-blender-art-route.md +4 -4
  51. package/docs/recipes/47-island-snow-backdrop.md +4 -3
  52. package/docs/recipes/48-make-material.md +2 -2
  53. package/docs/recipes/49-game-module-contract.md +25 -25
  54. package/docs/recipes/51-capability-catalog.md +2 -2
  55. package/docs/recipes/52-look.md +43 -5
  56. package/docs/recipes/53-ground-up-close.md +58 -0
  57. package/examples/action/GAMEMAP.md +2 -2
  58. package/examples/action/main.js +3 -2
  59. package/examples/sheepisland/GAMEMAP.md +1 -1
  60. package/examples/styletest/content/npcs.js +1 -1
  61. package/examples/styletest/main.js +1 -1
  62. package/examples/world/content/npcs.js +1 -1
  63. package/examples/world/main.js +1 -1
  64. package/index.d.ts +8 -2
  65. package/index.js +3 -2
  66. package/llms.txt +9 -8
  67. package/modules/characters/Character.js +21 -19
  68. package/modules/characters/assetModel.js +35 -7
  69. package/modules/characters/proceduralRig.js +45 -10
  70. package/modules/content/index.js +1 -1
  71. package/modules/gameplay/pickups.js +1 -1
  72. package/modules/vegetation/Vegetation.js +15 -3
  73. package/modules/vegetation/index.js +1 -1
  74. package/modules/vegetation/nearFade.js +39 -0
  75. package/package.json +2 -1
  76. package/render/detail.js +39 -15
  77. package/types/core.d.ts +7 -5
  78. package/types/gameplay.d.ts +12 -6
  79. package/types/style.d.ts +20 -15
  80. package/types/world.d.ts +7 -1
@@ -1,9 +1,9 @@
1
- # Terrain look open points: shading, color map, triangle cut, normals
1
+ # Crisp ground color borders, terrain normals, height from a grid
2
2
 
3
3
  For an AI that wants the ground to look a way the defaults do not: crisp color borders (a river bank, a path edge), a coarse low-poly mesh with
4
- fine color, a different triangle cut, custom lighting normals. Terrain basics are in `28-terrain.md`, ground color noise in
5
- `36-sky-ground-plant-looks.md`. Every default below is the original look, bit for bit (checked against hashes of the old output in
6
- `tests/specs/terrain-look.mjs`). Each knob has three exits: a parameter, a small pure function, or replacing the whole ground material.
4
+ fine color, a different triangle cut, custom lighting normals, height read from a grid or image. Terrain basics are in `28-terrain.md`, ground
5
+ color noise in `36-sky-ground-plant-looks.md`, the ground up close (detail, variation, symptoms) in `53-ground-up-close.md`. Each knob names its
6
+ default (`tests/specs/terrain-look.mjs` pins them). Each knob has three exits: a parameter, a small pure function, or replacing the whole ground material.
7
7
 
8
8
  ## Why the bank is jagged: color lived on the mesh
9
9
  With `shading: 'smooth'` or `'flat'` a color is computed at a grid point (or triangle center) and blended across the triangle. At the default
@@ -11,9 +11,6 @@ With `shading: 'smooth'` or `'flat'` a color is computed at a grid point (or tri
11
11
  Raising `resolution` fixes it at the price of triangles (and collision, and edit granularity). `shading: 'texture'` cuts the link: color is
12
12
  computed per pixel into a per-chunk image, the mesh stays as coarse as you like.
13
13
 
14
- Material roles (`makeMaterial('role')`) are free labels: a role the style does not list uses `materials.default`, and the engine warns only on a name
15
- that looks like a typo of a known one (`09-style-pack.md`). A style that wants a special ground surface adds its own role and ground material.
16
-
17
14
  ## 1. `shading: 'texture'` (and `colorResolution`)
18
15
  ```js
19
16
  engine.use(terrain({ ...terrainPreset(), shading: 'texture', colorResolution: 128 }));
@@ -64,21 +61,20 @@ terrain({ normalFn: (i, j, h, cell) => [(h(i - 1, j) - h(i + 1, j)) / cell, 4, (
64
61
  ```js
65
62
  terrain({ diagonal: 'adaptive' }) // 'fixed' (default) | 'adaptive' | 'alternate'
66
63
  ```
67
- `fixed` cuts every cell the same way (the original mesh). `adaptive` cuts along the diagonal with the smaller height difference, which removes
64
+ `fixed` cuts every cell the same way. `adaptive` cuts along the diagonal with the smaller height difference, which removes
68
65
  the zigzag ridges a fixed cut leaves on a slope; `alternate` flips every other cell (no directional bias on flat low-poly facets). `engine.surface`,
69
66
  collision and vegetation heights follow the chosen cut, so nothing floats. Because it changes the walkable shape, it belongs to the game's
70
67
  `terrain({...})`, not to a style (rule R34 and `style check` accept `shading`, `colorResolution`, `normals`, `normalFn` in `style.terrain.config`
71
68
  and flag `diagonal`).
72
69
 
73
70
  ## 4. `boundsPad`: the chunk bounding sphere margin
74
- `boundsPad: { up: 3, radius: 8 }` (meters, the original values) is the margin of the culling sphere: the center is raised by `up`, the radius grows
71
+ `boundsPad: { up: 3, radius: 8 }` (meters, the defaults) is the margin of the culling sphere: the center is raised by `up`, the radius grows
75
72
  by `radius`. Raise it if a shader moves vertices far (wind on tall ground cover, a vertex-displacement patch) and chunks pop out at the screen edge.
76
73
 
77
74
  ## 5. Relation to `style.terrain.variation`
78
- `variation` shapes *what* color a point gets (blend size, grain, patches); `shading` decides *where* that color is evaluated. They compose:
79
- in texture mode the grain (`jitter.size`, default 0.33 m) is sampled by pixel, so with `colorResolution: 128` (0.5 m pixels) it is coarser than the
80
- vertex version; set `jitter.size` near the pixel size or use `patches` for the painterly look. In vertex modes the mesh limited every one of these to
81
- cell size; in texture mode `patches: { size: 20, levels: 4 }` shows real hard-edged strokes.
75
+ `variation` shapes *what* color a point gets; `shading` decides *where* it is evaluated. In vertex modes every variation is limited to cell size; in
76
+ texture mode it is sampled per pixel, so `patches: { size: 20, levels: 4 }` gives hard-edged color blocks, and a `jitter.size` below the pixel size
77
+ (0.5 m at `colorResolution: 128`) comes out as one grain per pixel, coarser than asked. Choosing a combination, and ground that looks wrong up close: recipe 53.
82
78
 
83
79
  ## 6. Example: a river bank
84
80
  ```js
@@ -92,6 +88,31 @@ engine.use(terrain({
92
88
  ```
93
89
  Using a preset (`riverAt` of `@threedog/terrain-noise`) the same switch gives crisp banks without more triangles: `terrain({ ...terrainPreset(), shading: 'texture' })`.
94
90
 
91
+ ## 7. Height from a grid or image
92
+ `sampleGrid(data, { width, height, size | cellSize, origin, interp })` turns numbers laid out on a regular grid into a function `(x, z) => value`;
93
+ `await engine.assets.gridFromImage(nameOrUrl, { channel, range, bits })` reads such a grid from an image (PNG at full 8 or 16 bits, jpg/webp at 8;
94
+ `channel` is `'r'`/`'g'`/`'b'`/`'a'`; `range: [min, max]` maps the pixel values to world units, default `[0, 1]`). Samples sit on the grid nodes, so
95
+ `width` samples span `width - 1` cells; outside the grid the edge value is used, or `outside: v`. The grid is just a field: height, moisture, a
96
+ ground-type weight, spawn density, a walkable mask, danger, travel cost.
97
+
98
+ `interp` is the look between nodes; none of them is the right one:
99
+ - `'nearest'`: flat steps, one value per cell. Terraces, blocky or voxel-like ground, tile masks, numbers that are ids.
100
+ - `'linear'` (default): plain bilinear blend; smooth enough for most fields, never leaves the range of its four corners.
101
+ - `'cubic'`: smooth slopes without cell creases (rolling hills, soft gradients). It can overshoot beside a sharp step; `clamp: true` keeps the
102
+ result inside the four corner values.
103
+
104
+ ```js
105
+ const g = await engine.assets.gridFromImage('/maps/height16.png', { range: [-5, 60] }); // meters, 16-bit file
106
+ const heightAt = sampleGrid(g.data, { ...g, size: [512, 512], origin: [-256, -256], interp: 'cubic', clamp: true });
107
+ heightAt(10, 20); // gameplay side: where to put a camp, a mine, a lighthouse
108
+ const wet = sampleGrid(moisture, { width: 32, height: 32, cellSize: 8 }); // a hand-made field: wetter ground grows reeds, rice, moss
109
+ const walk = sampleGrid(mask, { width: 64, height: 64, cellSize: 1, interp: 'nearest', outside: 0 }); // 0 / 1 per tile; off the map: not walkable
110
+ ```
111
+ A terrain `height` function is recompiled in a worker and cannot capture `heightAt`, so the terrain reads the same image through its own
112
+ `heightmap` (bilinear, centered on `center`): `terrain({ heightmap: { ...g, size: [512, 512], min: -5, max: 60 } })` with `g` from `gridFromImage`
113
+ using the default `range` (it expects 0-1 values; `min`/`max` scale them). Use `sampleGrid` for everything outside the terrain module; when you need
114
+ a look the terrain's bilinear read does not give (terraces: `nearest`), bake it into the data first or write the step in a `height` function.
115
+
95
116
  ## Whole replacement
96
117
  Anything beyond this: `terrain({ material })` (or `style.terrain.material`) swaps the ground material and `engine.terrain.T.buildChunk(cx, cz)` returns the
97
118
  raw arrays (`pos`, `nor`, `col`, `uv`, and `tex: { data, size }` in texture mode) if you build chunk meshes yourself.
@@ -1,71 +1,76 @@
1
- # Environment look open points: lights, fog, exposure, sky layers
1
+ # Owning lights, fog and exposure yourself
2
2
 
3
- For an AI that wants lighting, fog or the sky to look a way the defaults do not. Sky basics are in `08-weather-sky.md`, clouds and ground color in
4
- `36-sky-ground-plant-looks.md`, environment lighting in `34-environment-lighting.md`. Every default below draws exactly what it drew before
5
- (checked pixel by pixel in `tests/specs/appearance-env.mjs`). Each knob has three exits: a parameter, a GLSL function you replace, or turning the
6
- engine's part off and bringing your own three.js objects.
3
+ The normal way to change lights, fog, exposure and the sky is `engine.look.<part>.set` / `patch` ([recipe 52](52-look.md)): the sky keeps
4
+ driving them over the day, and your values sit on top. This page is the next step, for when that is not enough: your own fog math, exposure over
5
+ the day, extra sky layers, and taking a light or the fog away from the sky entirely. Sky basics are in `08-weather-sky.md`, clouds and ground color in
6
+ `36-sky-ground-plant-looks.md`, environment lighting in `34-environment-lighting.md`. Each section starts with the `look` call and ends with the exit.
7
7
 
8
- ## Lights: let the sky drive them, drive them yourself, or switch them off
8
+ ## Lights: override, take over, or switch off
9
9
  The engine has one directional light (`engine.lights.sun`, also `engine.sky.sun`; moonlight at night, the shadows live on it) and one hemisphere
10
10
  ambient (`engine.lights.hemi` = `engine.sky.hemi`). The sky module rewrites their color and intensity every frame from `style.sky.keyframes`,
11
- so editing them directly is overwritten (a dev warning says so). **Without the sky module** both lights still exist as a bright placeholder (hemi 1.2, white sun 2 at (40, 80, 30), no shadows): for a night scene set them yourself (`engine.lights.sun.color/intensity`, `engine.lights.hemi.intensity`) or install `sky`. Choose per light:
11
+ so editing the three.js objects directly is overwritten (a dev warning says so). **Without the sky module** both lights are a bright placeholder
12
+ (hemi 1.2, white sun 2 at (40, 80, 30), no shadows).
12
13
 
13
14
  ```js
14
- engine.use(sky({ sun: 'manual' })); // the sky still aims the sun along the time of day and moves the shadow box
15
+ engine.look.lights.set({ sun: { color: '#ffd0a0', intensity: 1.4 }, hemi: { intensity: 0.5 } }, { owner: 'dusk' }); // 1. override, any hour
16
+ engine.sky.modify('cave', { sun: 0.3, ambient: 0.4 }); // or a multiplier on top of the day cycle (recipe 52)
17
+
18
+ engine.use(sky({ sun: 'manual' })); // 2. take over: the sky still aims the sun along the time of day and moves the shadow box
15
19
  engine.sky.sun.color.set(0xffd0a0); engine.sky.sun.intensity = 1.4; // yours now, never overwritten
16
20
 
17
- engine.use(sky({ sun: false, hemisphere: false })); // a dungeon: both hidden, never touched; the dome still shows sun and moon
21
+ engine.use(sky({ sun: false, hemisphere: false })); // 3. switch off (a dungeon): both hidden, never touched; the dome still shows sun and moon
18
22
  const torch = new THREE.PointLight(0xffa040, 6, 12); engine.add(torch); // add your own lights before engine.start()
19
23
  ```
20
24
 
21
- - `createEngine({ lights: false })` goes one step further: the default sun and hemisphere are never put in the scene (no placeholder light even before a sky is installed), `engine.lights.sun` / `hemi` stay as detached objects so nothing reads `undefined`. Use it for a scene lit entirely by your own lights.
22
- - Many lights indoors (lamps, torches in every room): do not add a `PointLight` per lamp; `lightPool({ point: 6 })` keeps a fixed number of real lights and moves them to the nearest sources, so the light count (and shader recompiles) stays constant.
23
- - Default `true`: the sky drives everything (as before). `'manual'`: color and intensity are the game's; the sun keeps its direction and shadow box.
24
- `false`: `visible = false`, no shadows, never touched (lightning no longer flashes the ambient either).
25
- - Shadows: only the engine sun's shadow is managed (size, bias, snapping via `engine.look.shadow.set`). Your own `castShadow` lights work as in
26
- three.js, each costing its own shadow pass; `engine.setShadows(false)` turns theirs off too and restores them after.
27
- - Add or remove lights before `engine.start()`: a light count that changes mid-play recompiles every material (one long frame). Many torches:
28
- `lightPool()`. Brightness tweaks without giving up the keyframes: a multiplier layer, see [recipe 52](52-look.md#skymodify-vs-looklights).
29
-
30
- ## Fog: kind, color, density, or your own math
31
- `style.sky.fog` (a look; `sky({ fog })` overrides it):
25
+ - `sky({ sun, hemisphere })`: `true` (default) the sky drives everything; `'manual'` color and intensity are the game's, the sun keeps its
26
+ direction and shadow box; `false` `visible = false`, no shadows, never touched (lightning no longer flashes the ambient either).
27
+ - `createEngine({ lights: false })` goes one step further: the default sun and hemisphere are never put in the scene, `engine.lights.sun` / `hemi`
28
+ stay as detached objects so nothing reads `undefined`. Use it for a scene lit entirely by your own lights.
29
+ - Shadows: only the engine sun's shadow is managed (`engine.look.shadow.set`). Your own `castShadow` lights work as in three.js, each costing its
30
+ own shadow pass; `engine.setShadows(false)` turns theirs off too and restores them after.
31
+ - Add or remove lights before `engine.start()`: a light count that changes mid-play recompiles every material (one long frame). Many lamps or
32
+ torches: `lightPool({ point: 6 })` keeps a fixed number of real lights and moves them to the nearest sources (recipe 09, "Lights and stalls").
32
33
 
34
+ ## Fog: kind, color, density, your own math, or your own fog
33
35
  ```js
34
- fog: { kind: 'exp2' } // three's FogExp2, density derived so it reaches as far as the linear fog did
35
- fog: { kind: 'height', height: 2, falloff: 0.08, density: 0.03 } // valley mist: thick below y = 2, thinning 8% per meter above
36
- fog: { kind: 'exp', color: 0xb8c4d0 } // own color: the dome's lower band fades to it, so the horizon line never shows
37
- fog: { color: sky => sky.isDay ? 0xc8d0d8 : 0x10141c } // a function, evaluated each frame
38
- fog: { kind: 'exp', glsl: `vec4 threedogFog(vec3 c, float depth, vec3 p){
36
+ engine.look.fog.set({ far: 220, color: '#9bb' }); // live: color, density, near, far, enabled, linear <-> exp2
37
+ engine.look.fog.set({ kind: 'height', height: 2, falloff: 0.08, density: 0.03 }); // valley mist; before the first frame (below)
38
+ engine.look.fog.patch('fog', `vec4 threedogFog(vec3 c, float depth, vec3 p){
39
39
  float f = 1.0 - exp(-fogDensity * depth);
40
- return vec4(mix(c, vec3(1.0, 0.85, 0.7), f * 0.3), f); }` } // warm far haze
40
+ return vec4(mix(c, vec3(1.0, 0.85, 0.7), f * 0.3), f); }`); // warm far haze
41
+ engine.look.fog.replace('manual'); // the exit: the sky stops writing scene.fog (or pass a THREE.Fog)
41
42
  ```
43
+ The same keys are the style layer `style.sky.fog` (or `sky({ fog })`), e.g. `fog: { kind: 'exp', color: 0xb8c4d0 }` or
44
+ `fog: { color: sky => sky.isDay ? 0xc8d0d8 : 0x10141c }` (a function, evaluated each frame).
42
45
 
43
- - `kind`: `'linear'` (default, near = 0.3 x far) | `'exp'` | `'exp2'` | `'height'`. `color`: `'horizon'` (default) | color | `(sky) => color`.
44
- `density` per meter (default derived from `engine.fogFar`); weather fog divides it, `engine.setFogFar` still moves the derived one.
45
- - `glsl` replaces the fog math in every material, built-in or yours: `vec4 threedogFog(vec3 color, float depth, vec3 worldPos)` returns
46
+ - `kind`: `'linear'` (default, near = 0.3 x far) | `'exp'` | `'exp2'` | `'height'`. `color`: `'horizon'` (default; the dome's lower band fades to
47
+ the fog color, so the horizon line never shows) | color | `(sky) => color`. `density` per meter (default derived from the fog distance);
48
+ weather fog divides it, `engine.setFogFar` still moves the derived one.
49
+ - The `fog` hook replaces the fog math in every material, built-in or yours: `vec4 threedogFog(vec3 color, float depth, vec3 worldPos)` returns
46
50
  (fog rgb, amount 0..1). In scope: `fogColor`, `cameraPosition`, `fogNear` / `fogFar` (linear) or `fogDensity` (other kinds),
47
51
  `THREEDOG_FOG_HEIGHT`, `THREEDOG_FOG_FALLOFF`.
48
- - How it works and its limits: `'exp'`, `'height'` and `glsl` replace three's `fog_*` shader chunks once at install (three caches programs by
49
- material settings, not by source, so the fog model cannot change mid-play; color and density stay live). No custom uniforms (three copies fog
50
- uniforms into each material when it compiles); write constants. Materials with `fog: false` (the dome) are not fogged; the dome follows the
51
- fog color as above. A ShaderMaterial of your own gets the same fog when it sets `fog: true` and includes the fog chunks.
52
- - Whole replacement: `sky({ fog: 'manual' })` creates `scene.fog` once and never writes it (set its color / near / far, or assign your own
53
- object); `sky({ fog: false })` sets `scene.fog = null` (leave fog out of your materials with `fog: false` and fog in a post pass). Default
54
- `true` = the sky drives it. This is a sky() option, not a style key.
55
- - Two engines on one page share three's fog chunks: the same custom `kind` / `height` / `falloff` / `glsl` is fine (reference counted, the
56
- originals return when the last one is disposed); a different custom setting throws. Plain `linear` / `exp2` do not touch the chunks.
52
+ - Limits: `'exp'`, `'height'` and the hook replace three's `fog_*` shader chunks once (three caches programs by material settings, not by
53
+ source), so they only work before the first frame (style, `sky({ fog })`, or right after `createEngine`); later they throw. Color and density
54
+ stay live. No custom uniforms (three copies fog uniforms into each material when it compiles); write constants. Materials with `fog: false`
55
+ (the dome) are not fogged. A ShaderMaterial of your own gets the same fog when it sets `fog: true` and includes the fog chunks.
56
+ - Your own fog: `look.fog.replace('manual')` or `sky({ fog: 'manual' })` creates `scene.fog` once and never writes it (set its color / near /
57
+ far, or assign your own object); `sky({ fog: false })` sets `scene.fog = null` (leave fog out of your materials with `fog: false` and fog in a
58
+ post pass).
59
+ - Two engines on one page share three's fog chunks: the same custom `kind` / `height` / `falloff` / hook is fine (reference counted); a different
60
+ custom setting throws. Plain `linear` / `exp2` do not touch the chunks.
57
61
 
58
62
  ## Exposure and tone mapping over time
59
63
  ```js
60
64
  exposure: [[0, 1.6], [0.3, 1], [0.75, 1.1]] // style: per time of day (0-1), wraps across midnight
61
65
  exposure: sky => sky.isDay ? 1 : 1.5 // or a function, evaluated by the sky module every frame
62
- engine.look.tone.set({ exposure: 1.3 }); // at run time: number, keyframes or function (replaces the style's);
66
+ engine.look.tone.set({ exposure: 1.3 }); // at run time: number, keyframes or function (replaces the style's)
63
67
  engine.look.tone.set({ mapping: 'agx' }); // 'aces' | 'agx' | 'neutral' | 'none'; materials recompile on their next draw
64
68
  ```
65
- A plain number behaves as before (set once, no per-frame work). Keyframes and functions need the sky module (it knows the time of day).
69
+ A plain number is set once (no per-frame work). Keyframes and functions need the sky module (it knows the time of day).
66
70
 
67
- ## Extra sky layers: rainbow, aurora, painted bands
68
- `style.sky.layers` (or `sky({ layers })`), drawn on the dome after clouds and stars; none by default (the dome shader text is then unchanged):
71
+ ## Extra sky layers: rainbow, aurora, color bands
72
+ `style.sky.layers` (or `sky({ layers })`; at run time `engine.look.sky.patch('layer:aurora', { glsl, blend })`, recipe 52), drawn on the dome
73
+ after clouds and stars; none by default:
69
74
 
70
75
  ```js
71
76
  layers: [{ blend: 'add', uniforms: { uAurora: [0.2, 1, 0.6] }, glsl: `vec4 threedogSkyLayer(vec3 d, float time, vec3 sunDir, float night){
@@ -1,6 +1,6 @@
1
1
  # Terrain outline: islands, floating rocks, a world that ends
2
2
 
3
- `terrain({ shape })` decides where there is ground at all. Without it the ground goes on forever, exactly as before. With it, ground exists only
3
+ `terrain({ shape })` decides where there is ground at all. Without it (the default) the ground goes on forever. With it, ground exists only
4
4
  where `mask > 0`; the rim is cut through the cells in straight lines, walls hang down from it, and an optional underside closes it.
5
5
 
6
6
  ## 1. A floating island with a ragged rim (copy this)
@@ -6,13 +6,14 @@ material** (a function or instance). Use the first that does the job.
6
6
 
7
7
  ## Material roles are open
8
8
  `style.materials` maps a role name to a material. The engine asks for `default terrain vegetation character water pickup prop`; **any other
9
- name is fine** (`wool`, `bark`, `lantern`): code asks for it with `engine.makeMaterial('wool', { color })`, an unlisted role uses `materials.default`.
9
+ name is fine** (`cloth`, `metal`, `glass`): code asks for it with `engine.makeMaterial('cloth', { color })`, an unlisted role uses `materials.default`.
10
10
  Only a name very close to an existing one (`props`, `charcter`) warns, as a probable typo.
11
11
 
12
12
  ```js
13
13
  materials: {
14
14
  default: { type: 'lambert' },
15
- wool: { type: 'standard', roughness: 1, detail: { noise: 'grain', projection: 'triplanar', scale: 3, normal: 0.01 } },
15
+ cloth: { type: 'standard', roughness: 1, detail: { noise: 'grain', projection: 'triplanar', scale: 3, normal: 0.01 } },
16
+ glass: { type: 'physical', transmission: 1, roughness: 0.05, thickness: 0.2 },
16
17
  rock: { type: 'standard', map: 'rock.png', normalMap: 'rock_n.png', roughnessMap: 'rock_r.png', repeat: 4 },
17
18
  prop: (params, purpose, engine) => new THREE.MeshMatcapMaterial({ matcap: texture, color: params.color }), // any Material
18
19
  }
@@ -22,18 +23,17 @@ three.js Material. A **spec** is plain data (`type: lambert | phong | standard |
22
23
  `materials.default` when that is a spec too; keys the material has are set, spec keys below are handled by the engine.
23
24
 
24
25
  ## Exit 1: parameters in the spec
25
- **Texture names.** A texture slot may be an asset name (`map`, `emissiveMap` are sRGB; `normalMap roughnessMap metalnessMap aoMap bumpMap alphaMap
26
- displacementMap specularMap...` are linear). The engine loads it with `engine.assets.texture`, sets anisotropy, wrap and `repeat` (a number or `[x, y]`;
27
- `wrap: 'repeat' | 'clamp' | 'mirror'`), and a neutral stand-in (flat normal, white) sits in the slot until the image arrives. A texture object works too.
28
- A key the type lacks (`roughnessMap` on `lambert`) warns once with the type to use; a misspelled slot (`normalmap`) throws with the near name.
29
- `style check` verifies the names against the asset pack (`materials.*.map` and the other slots, `materials.*.detail.texture`).
26
+ The accepted spec keys, texture slots, `repeat` / `wrap` and who wins between pack and call: recipe 48. How texture names load: the engine
27
+ fetches the asset with `engine.assets.texture` (`map`, `emissiveMap` sRGB, the other slots linear), sets anisotropy, wrap and repeat, and a neutral
28
+ stand-in (flat normal, white) sits in the slot until the image arrives. `style check` verifies the names against the asset pack. This page
29
+ covers the keys that add shader code: `detail`, `lighting`, toon `ramp`, seasons.
30
30
 
31
- **`detail`**: grain, paper or strokes over the surface, in world space (needs no UVs). Off unless written; every number is a uniform, so
31
+ **`detail`**: a noise pattern, a texture or your own GLSL laid over the surface in world space (needs no UVs). Off unless written; every number is a uniform, so
32
32
  100 materials with different `scale` / `strength` / `direction` compile **one** program (tested: 8 variants, +0 programs).
33
33
 
34
34
  | key | meaning |
35
35
  |---|---|
36
- | `noise` | `'grain'` (default) `'paper'` `'stroke'`; or `texture: 'name'` (asset name or a Texture), or `glsl` (below) |
36
+ | `noise` | `'grain'` (default) `'paper'` `'stroke'` `'dabs'` (soft oval dabs, no direction); or `texture: 'name'` (asset name or a Texture), or `glsl` (below) |
37
37
  | `projection` | `'world'` top-down (default, fine for ground) or `'triplanar'` (walls, rocks, characters) |
38
38
  | `scale` `strength` | repeats per meter (0.25), color effect 0-1 (0.35) |
39
39
  | `mode` `tint` | `'multiply'` (default) `'add'` `'mix'`; tint colors the sample |
@@ -41,9 +41,10 @@ A key the type lacks (`roughnessMap` on `lambert`) warns once with the type to u
41
41
  | `octaves` | 1-4 noise layers (2) |
42
42
  | `normal` | relief height in meters (bumps the normal; 0 = off) |
43
43
  | `roughness` | amount the sample moves roughness (`standard` / `physical`) |
44
+ | `fade` | default `true`: the effect fades out where its pattern is smaller than a pixel (far, grazing), so it does not shimmer; `false` keeps it |
44
45
 
45
46
  Which channels (color, normal, roughness) are on is fixed when the material is made (it is part of the program); the numbers can change any time.
46
- `style.terrain.detail` (`{ texture, scale, strength }`) is the same patch for the ground.
47
+ The ground takes the same object as `style.terrain.detail` / `look.ground.set({ detail })`; which detail suits which ground: recipe 53.
47
48
 
48
49
  **`lighting`** shapes the light after it is summed. three has no "shadow color": a shadow only removes the sun's light. The patch reads the first
49
50
  directional light (the sun; three sorts shadow casters first) and its shadow value for the pixel:
@@ -63,7 +64,7 @@ orange-on-green muddy; `mix` moves the surface `strength` of the way to the colo
63
64
 
64
65
  ## Exit 2: your own GLSL
65
66
  `detail.glsl` replaces the noise: `vec4 threedogDetailSample(vec2 p)` returns `vec4(color, height 0-1)`; `p` is already scaled, turned, stretched;
66
- `uniforms: { uCells: 6 }` (numbers, colors, arrays, textures) are in scope. `lighting.glsl` replaces the three light effects:
67
+ `uniforms: { uCells: 6 }` (numbers, colors, arrays, textures) are in scope; `threedogDetailFootprint` is one pixel in pattern units (`fade` uses it; read it to fade your own sample). `lighting.glsl` replaces the three light effects:
67
68
  `void threedogLighting(inout ReflectedLight light, vec3 normal, vec3 viewDir, vec3 sunDir, float sunShadow, vec3 albedo)` (view space; `sunShadow` 1 lit,
68
69
  0 shadowed; change `light.directDiffuse` / `indirectDiffuse`, the lights are already summed).
69
70
 
@@ -78,6 +79,21 @@ For anything else write a **named patch** and add it with `applyEffects(material
78
79
  glsl: { fragment: { pars: 'uniform float uFuzz;', // pars = declarations at the top
79
80
  color_fragment: 'diffuseColor.rgb *= 1.0 - uFuzz * 0.5;' } } } // chunk name -> code placed after `#include <chunk>`
80
81
  ```
82
+ Patches on one material must agree. Each patch declares what it relies on, and a bad combination throws when it is added (or logs once at compile):
83
+
84
+ | Field | Meaning | Checked |
85
+ |---|---|---|
86
+ | `needs.data` | Program inputs the code reads: `'instancing'`, `'instancingColor'`, `'vertexColors'`, `'skinning'`, `'batching'` | when the program compiles (console.error once per material) |
87
+ | `needs.patches` | Patches it builds on, e.g. `['world']` for the `vThreedogWorld` varying (world position; `applyEffects` adds `world` itself when a patch needs it) | when added |
88
+ | `conflicts` | Patch names it cannot share a material with | when added, both ways |
89
+ | `uniforms` | A uniform name belongs to one patch; share `engine.uniforms` (`uTime`, `uWind`, `uCloud`...) instead of making your own `uTime` | when added |
90
+ | `shadow` | Render steps: without it the color pass only; `true` also runs its vertex code in the depth (sun / spot shadows) and distance (point-light shadows) passes | - |
91
+ | `cacheKey` | Changes whenever the GLSL text changes (defines, branches), never for uniform values; the program key joins every patch's `name=cacheKey` in order | same name + cacheKey with different code throws |
92
+ ```js
93
+ applyEffects(mat, { wind: 0.03, season: 'foliage', patches: [{ name: 'ripple', needs: { patches: ['world'] }, conflicts: ['wind'],
94
+ glsl: { fragment: { color_fragment: 'diffuseColor.rgb *= 0.9 + 0.1 * sin(vThreedogWorld.x);' } } }] }); // throws: 'wind' and 'ripple' cannot be combined
95
+ ```
96
+
81
97
  A chunk value may be `{ before, after }`. A missing chunk throws when the patch is added (`strict`), not as a silent no-op. Chunk names in three **0.187**
82
98
  (read from `three/src/renderers/shaders`), in main-body order:
83
99
 
@@ -101,20 +117,19 @@ A `materials` entry that is a Material instance (cloned per use, its patches kep
101
117
  lit materials returned by it. Nothing else is applied: textures, `detail` and `lighting` keys are only read on specs, so call `applyEffects(material,
102
118
  { detail, patches })` yourself.
103
119
 
104
- ## Three complete looks
120
+ ## Three complete looks (different directions, same mechanism)
105
121
  ```js
106
122
  const looks = {
107
- // wool: rough, fuzzy, soft light, a warm rim; one fine grain seen from every side
108
- wool: { type: 'standard', roughness: 1, detail: { noise: 'grain', projection: 'triplanar', scale: 4, octaves: 3, strength: 0.25, normal: 0.01 },
109
- lighting: { wrap: 0.5, rim: { color: 0xffd9a8, strength: 0.35, power: 2.5 } } },
110
- // leaves: toon bands, brush strokes along the wind, cool shade, a bit of transmitted light on the side away from the sun
123
+ // metal, realistic PBR: a texture set does the work; a fine world-space grain moves only the roughness (smudges), not the color
124
+ metal: { type: 'standard', metalness: 1, roughness: 0.35, map: 'steel.png', normalMap: 'steel_n.png', roughnessMap: 'steel_r.png', repeat: 2,
125
+ detail: { noise: 'grain', projection: 'triplanar', scale: 6, strength: 0, roughness: 0.25 } },
126
+ // poster, flat and unlit: no light or shadow, the color is exactly the given one; a faint grain keeps large areas from looking empty
127
+ poster: { type: 'basic', detail: { noise: 'paper', scale: 2, strength: 0.12 } },
128
+ // leaf, stylized: toon bands, directional strokes along the wind, cool shade, a rim on the side away from the sun
111
129
  leaf: { type: 'toon', ramp: [0.45, 0.8, 1], soften: 0.25, detail: { noise: 'stroke', direction: 35, scale: 1.2, strength: 0.3, mode: 'add' },
112
130
  lighting: { shadowTint: { color: 0x5a6fb0, strength: 0.7 }, rim: { color: 0xb8e08a, strength: 0.3, shadowSide: 1 } } },
113
- // rock: a real texture set, plus a world-space grain that also roughens it
114
- rock: { type: 'standard', map: 'rock.png', normalMap: 'rock_n.png', roughnessMap: 'rock_r.png', repeat: 3,
115
- detail: { noise: 'paper', projection: 'triplanar', scale: 0.8, strength: 0.2, normal: 0.02, roughness: 0.3 } },
116
131
  };
117
132
  ```
118
- Fetch them with `engine.makeMaterial('wool')`. Check a pack with `threedog style check`; the pixel and program-count guarantees are in `tests/specs/surface.mjs`.
133
+ Fetch them with `engine.makeMaterial('metal')`. Check a pack with `threedog style check`; the pixel and program-count guarantees are in `tests/specs/surface.mjs`.
119
134
 
120
135
  To change these from code at run time (`materials`, `surface`, `ground`, `wind` look parts), see recipe 52.
@@ -1,9 +1,9 @@
1
- # Water and weather look open points: depth color, foam, reflections, rain and snow, lightning, own particles
1
+ # Water and rain/snow looks: depth color, foam, reflections, particles, lightning
2
2
 
3
3
  For an AI that wants water or weather particles to look a way the defaults do not. Water basics are the `water()` module and `style.water` (color, opacity, waves,
4
- fresnel, normal map); lights, fog and the sky are in `38-environment-look-hooks.md`. Every default below draws exactly what it drew before
5
- (checked pixel by pixel against the old shaders in `tests/specs/appearance-water.mjs`), and a style that writes none of the new keys gets the same
6
- shader text, so it pays nothing. Three exits: a parameter, a GLSL function you replace, or your own material.
4
+ fresnel, normal map); lights, fog and the sky are in `38-environment-look-hooks.md`. A style that writes none of the keys below keeps the built-in
5
+ shaders and pays nothing for them (`tests/specs/appearance-water.mjs`). Three exits: a parameter, a GLSL function you replace, or your own material.
6
+ At run time the same keys go through `engine.look.water` / `engine.look.weather` (recipe 52).
7
7
 
8
8
  ## Water: depth color and crest foam (parameters)
9
9
  ```js
@@ -78,7 +78,7 @@ water: { material: () => {
78
78
  - Tested: `tests/specs/appearance-water.mjs` renders this exact example and finds the reflected box in the mirror texture.
79
79
 
80
80
  ## Weather particles: rain and snow parameters
81
- `style.weather.rain` / `snow` (left-out keys keep the built-in look; the defaults are pixel for pixel the old ones):
81
+ `style.weather.rain` / `snow` (left-out keys keep the built-in look):
82
82
 
83
83
  ```js
84
84
  weather: {
@@ -1,6 +1,6 @@
1
1
  # Cascaded shadows
2
2
 
3
- Off by default: the sun casts one shadow map around the focus (`extent`, default 70 m), exactly as before. Cascades split the sun's shadow
3
+ Off by default: the sun casts one shadow map around the focus (`extent`, default 70 m). Cascades split the sun's shadow
4
4
  along the view into 2-4 maps (three's CSM addon): sharp near the camera, coarse far away. Use them when near shadows look blocky and the
5
5
  world is bigger than one map covers well.
6
6
 
@@ -1,4 +1,4 @@
1
- # Hand-painted art route: from Blender to the game
1
+ # Blender to game (GLB) route
2
2
 
3
3
  Code-built geometry (`models.js`, recipe 05) is good for blockout, props and variations, but it cannot reach the finish of hand-made art: painted
4
4
  textures, baked shadows, sculpted edges. That finish comes from Blender. This page is the whole path, in order. The level naming rules live in
@@ -79,11 +79,11 @@ A whole level is `level({ url: '/models/town.glb' })` (recipe 10). Animation cli
79
79
 
80
80
  ## 5. The GLB's own materials and the style
81
81
  **The GLB keeps its own materials.** The engine loads them as they are (textures, colors, roughness) and does not swap them for style roles;
82
- that is what lets a hand-painted texture show. `style.materials` (recipe 43) applies only to what code builds through `engine.makeMaterial(role, ...)`
83
- (terrain, vegetation, procedural models, pickups). One scene can mix painted GLB props and styled code-built things.
82
+ that is what lets a painted or baked texture show. `style.materials` (recipe 43) applies only to what code builds through `engine.makeMaterial(role, ...)`
83
+ (terrain, vegetation, procedural models, pickups). One scene can mix GLB props and styled code-built things.
84
84
 
85
85
  There is no automatic mapping from a GLB material name to a style role and no flag for it. To make a GLB follow the style anyway, do it in your
86
- game code, per model: name the material in Blender after the role (`wool`, `bark`) and look it up:
86
+ game code, per model: name the material in Blender after the role (`cloth`, `metal`, `glass`) and look it up:
87
87
  ```js
88
88
  const m = await engine.assets.model('hat');
89
89
  m.traverse(o => { if (o.isMesh) o.material = engine.makeMaterial(o.material.name, { color: o.material.color.getHex() }); });
@@ -1,7 +1,8 @@
1
- # Floating island look: round rim, snow that settles, flat backdrop
1
+ # Snow cover, flat backdrop, rounded terrain rim
2
2
 
3
- A floating island scene (recipe 42 for the outline) usually wants three more things: a soft rim, trees and ground that turn white while
4
- it snows, and a plain background with no horizon. All three are style or scenario settings; none needs a shader of your own.
3
+ Three independent settings, each for its own situation: a **rounded rim** for terrain with a visible edge (an island, a diorama board, a floating
4
+ level; recipe 42 for the outline), **snow cover** for any outdoor scene where it snows, and a **flat backdrop** for a scene that should have no
5
+ horizon (a menu stage, a board game, a diorama). All are style or scenario settings; none needs a shader of your own.
5
6
 
6
7
  ## Round rim
7
8
  `terrain({ shape: { edge: { round: 1.2 } } })` bends the top down by up to 1.2 m toward the rim. The side wall follows every bend of the
@@ -11,8 +11,8 @@
11
11
  - `type`: `'lambert' | 'phong' | 'standard' | 'physical' | 'toon' | 'basic'` (default `lambert`, or whatever the pack says).
12
12
  - Texture slots by asset name (or a `THREE.Texture`): `map`, `emissiveMap` (sRGB), `normalMap`, `roughnessMap`, `metalnessMap`, `aoMap`, `bumpMap`,
13
13
  `alphaMap`... The slot must exist on the type (`roughnessMap` needs `standard`). Plus `repeat` (number or `[x, y]`) and `wrap` (`repeat | clamp | mirror`).
14
- - `detail`: grain / paper / strokes / a texture laid over the surface in world space (no UVs).
15
- - `lighting`: extra light shaping (shadow tint, rim, wrap, own GLSL), merged over `style.lighting`; `false` opts out.
14
+ - `detail`: a noise (`grain`, `paper`, `stroke`, `dabs`), a texture or your own GLSL laid over the surface in world space (no UVs); its keys: recipe 43.
15
+ - `lighting`: extra light shaping (shadow tint, rim, wrap, own GLSL), merged over `style.lighting`; `false` opts out (recipe 43).
16
16
  - toon only: `steps` (number of bands), or `ramp` (+ `soften`). `ramp` on a non-toon type throws.
17
17
  - A key the chosen material does not have (`roughness` on lambert) is skipped on purpose, so one spec works for any type.
18
18
  A key that looks like a typo of a real one (`roughnes`) warns once in dev with `did you mean 'roughness'?`. Nothing is ever blocked.
@@ -1,7 +1,7 @@
1
- # Writing a game system module (crops, burning, a production machine) that plugs into the engine's contracts
1
+ # Writing a game system module (a smelter, a recharging turret, growing crops) that plugs into the engine's contracts
2
2
 
3
3
  A game system is a module (`{ name, install, ... }`) given to `engine.use(...)`. If it follows the five contracts below it saves, loads, skips time,
4
- shows in `describe()` and the dev bridge, and can be driven by ops, without special cases. Read recipe 06 (clock, skip), 18 (world records), 23 (ops).
4
+ shows in `describe()` and the dev bridge, and can be driven by ops, without special cases. Read recipe 14 (template, hook cheat sheet), 06 (clock, skip), 18 (world records), 23 (ops).
5
5
 
6
6
  ## The five contracts
7
7
  1. **State.** Prefer world records (`engine.world.add({ kind, ... })`, recipe 18): saved, streamed and far-simulated for you. State that is not a
@@ -17,7 +17,7 @@ shows in `describe()` and the dev bridge, and can be driven by ops, without spec
17
17
  `describeText()` show it). A game without a module uses `engine.describe.add(name, fn)`. The name must be new (it throws on a clash).
18
18
  5. **Actions are ops.** `engine.ops.define('noun.verb', { args, can, run, offers, reasons, desc })`. `can` is read-only and returns `true` or a reason
19
19
  string (a key of `reasons`); `run` changes state; `offers(e, ctx)` lists the arg sets possible right now (shown by the bridge `ops` command and
20
- `describe`). Call with `engine.ops.run(name, args)` -> `{ ok, value }` or `{ ok: false, reason }`. Never mutate state from UI code directly.
20
+ `describe`). Call with `engine.ops.run(name, args)` -> `{ ok, value }` or `{ ok: false, code, facts, nextActions }` (read `r.code`). Never mutate state from UI code directly.
21
21
 
22
22
  ## Declaring stage and dependencies
23
23
  `stage` picks where the hooks run (first to last): `control, world, environment, gameplay, presentation, late (default), audio`; `before / after`
@@ -25,28 +25,28 @@ shows in `describe()` and the dev bridge, and can be driven by ops, without spec
25
25
  otherwise: put those `engine.use` calls first). `optional: { sky: 'what is lost without it' }` is a soft dependency (use `engine.sky?.`). Core never imports
26
26
  modules. The module `name` must not clash with an existing engine property.
27
27
 
28
- ## One copyable module: a crop
28
+ ## One copyable module: something that finishes after a delay (a smelter, a turret recharge, a crop)
29
29
  ```js
30
- export const crops = () => {
31
- const plots = new Map(); // id -> plantedAt (game seconds)
30
+ export const jobs = () => {
31
+ const started = new Map(); // id -> startedAt (game seconds)
32
32
  return {
33
- name: 'crops', stage: 'gameplay', requires: [],
33
+ name: 'jobs', stage: 'gameplay', requires: [],
34
34
  install(e) {
35
- e.saves.register('crops', { version: 1, // contract 1: saved and restored
36
- save: () => [...plots],
37
- load: d => { plots.clear(); for (const [id, t] of d) plots.set(id, t); } });
38
- const grown = id => Math.min(1, (e.clock.now - plots.get(id)) / 120); // contracts 2+3: derived from clock.now, so normal == skipped
39
- e.ops.define('crop.plant', { args: { id: 'string' }, desc: 'Plant a crop plot', // contract 5
40
- can: (_, { id }) => (plots.has(id) ? 'taken' : true),
41
- run: (_, { id }) => { plots.set(id, e.clock.now); return id; }, reasons: { taken: 'Plot already planted' } });
42
- e.ops.define('crop.harvest', { args: { id: 'string' }, desc: 'Harvest a ripe crop',
43
- can: (_, { id }) => (!plots.has(id) ? 'empty' : grown(id) < 1 ? 'notRipe' : true),
44
- offers: () => [...plots.keys()].filter(id => grown(id) >= 1).map(id => ({ id })),
45
- run: (_, { id }) => { plots.delete(id); e.inventory.add('carrot', 2); return id; },
46
- reasons: { empty: 'Nothing planted', notRipe: 'Not ripe yet' } });
47
- return { grown }; // becomes engine.crops
35
+ e.saves.register('jobs', { version: 1, // contract 1: saved and restored
36
+ save: () => [...started],
37
+ load: d => { started.clear(); for (const [id, t] of d) started.set(id, t); } });
38
+ const progress = id => Math.min(1, (e.clock.now - started.get(id)) / 120); // contracts 2+3: derived from clock.now, so normal == skipped
39
+ e.ops.define('job.start', { args: { id: 'string' }, desc: 'Start a job on a machine', // contract 5
40
+ can: (_, { id }) => (started.has(id) ? 'busy' : true),
41
+ run: (_, { id }) => { started.set(id, e.clock.now); return id; }, reasons: { busy: 'Already running' } });
42
+ e.ops.define('job.collect', { args: { id: 'string' }, desc: 'Collect a finished job',
43
+ can: (_, { id }) => (!started.has(id) ? 'idle' : progress(id) < 1 ? 'notDone' : true),
44
+ offers: () => [...started.keys()].filter(id => progress(id) >= 1).map(id => ({ id })),
45
+ run: (_, { id }) => { started.delete(id); e.inventory.add('item', 2); return id; },
46
+ reasons: { idle: 'Nothing running', notDone: 'Not done yet' } });
47
+ return { progress }; // becomes engine.jobs
48
48
  },
49
- describe: e => ({ plots: plots.size, ripe: [...plots.keys()].filter(id => e.crops.grown(id) >= 1) }), // contract 4
49
+ describe: e => ({ running: started.size, done: [...started.keys()].filter(id => e.jobs.progress(id) >= 1) }), // contract 4
50
50
  };
51
51
  };
52
52
  ```
@@ -55,11 +55,11 @@ module (add `requires: ['inventory']`, or drop the `inventory.add` line).
55
55
 
56
56
  ## Check "advance 10h normally == skip 10h" (bridge, no new tools)
57
57
  ```
58
- npx threedog op crop.plant id=a ; npx threedog step 36000 ; npx threedog describe crops # A: normal play
59
- npx threedog reload ; npx threedog op crop.plant id=a ; npx threedog op time.skip seconds=36000 ; npx threedog describe crops # B: skipped
60
- npx threedog js "JSON.stringify(engine.crops.grown('a'))" # same number both times; compare whole state with: threedog snap-describe save|diff
58
+ npx threedog op job.start id=a ; npx threedog step 36000 ; npx threedog describe jobs # A: normal play
59
+ npx threedog reload ; npx threedog op job.start id=a ; npx threedog op time.skip seconds=36000 ; npx threedog describe jobs # B: skipped
60
+ npx threedog js "JSON.stringify(engine.jobs.progress('a'))" # same number both times; compare whole state with: threedog snap-describe save|diff
61
61
  ```
62
- Both runs must give equal `describe crops` (and `describe time`); if B differs, the module accumulates in `fixed` and needs a `skip` hook or `far`.
62
+ Both runs must give equal `describe jobs` (and `describe time`); if B differs, the module accumulates in `fixed` and needs a `skip` hook or `far`.
63
63
 
64
64
  ## What the engine does NOT check for you
65
65
  - That `save` really includes **all** your state, or that `load` is the inverse of `save` (an unsaved field silently resets on load).
@@ -57,7 +57,7 @@ The schema types are those of op args plus `object`, `array` and `function` (opt
57
57
  time hooks; a `fixed` hook without `skip` is listed under problems (recipe 49).
58
58
 
59
59
  ## 5. "How do I get this effect": `threedog how`
60
- `npx threedog how "rain"` (also `how 下雨`) scores the words of the task against the AI.md task rows and the recipe headings with their first sentence, and prints the
60
+ `npx threedog how "rain"` scores the words of the task against the AI.md task rows and the recipe headings with their first sentence, and prints the
61
61
  top five: the API in the row, the recipe path with section (`recipes/08-weather-sky.md §1`) and a one-line snippet. It reads the docs only, so it works with no page
62
62
  and prints the same list every run. When a dev page runs it adds up to three live catalog modules whose name matches the first English word. Words match at a word
63
- start (`rain` does not hit `terrain`); a few Chinese task words are mapped to the English words the docs use. No hit means rephrase, or read AI.md.
63
+ start (`rain` does not hit `terrain`). No hit means rephrase, or read AI.md.