incanto 0.28.0 → 0.30.0

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 (63) hide show
  1. package/README.md +44 -0
  2. package/bin/incanto-editor.mjs +219 -29
  3. package/dist/2d.d.ts +54 -6
  4. package/dist/2d.js +3 -3
  5. package/dist/3d.d.ts +353 -16
  6. package/dist/3d.js +5 -5
  7. package/dist/{behavior-CPibUfnH.d.ts → behavior-BAc0erXF.d.ts} +21 -0
  8. package/dist/{create-game-71TJjW1T.js → create-game-5z_QVtLx.js} +59 -16
  9. package/dist/{create-game-BRgWpNsa.js → create-game-DuBTv2zI.js} +276 -49
  10. package/dist/debug-draw-BM3DsvtT.js +18 -0
  11. package/dist/debug.d.ts +51 -6
  12. package/dist/debug.js +242 -19
  13. package/dist/editor-switch-B0wB_DSr.d.ts +59 -0
  14. package/dist/editor.d.ts +49 -0
  15. package/dist/editor.js +8554 -0
  16. package/dist/{gameplay-DEG-TP7D.js → gameplay-Cfr6aFZ1.js} +219 -40
  17. package/dist/gameplay.d.ts +1 -1
  18. package/dist/gameplay.js +1 -1
  19. package/dist/index.d.ts +31 -3
  20. package/dist/index.js +2 -2
  21. package/dist/{loader-DILt9PGC.d.ts → loader-B242FF6N.d.ts} +1 -1
  22. package/dist/net.d.ts +1 -1
  23. package/dist/net.js +2 -2
  24. package/dist/{pathfinding-RWYkNKx9.d.ts → pathfinding-BwD974Ss.d.ts} +1 -1
  25. package/dist/{physics-2d-DiVFFlH3.js → physics-2d-3kOQCtgd.js} +88 -3
  26. package/dist/{physics-3d--y5clE2j.js → physics-3d-CeRH-Ff_.js} +475 -9
  27. package/dist/react.d.ts +1 -1
  28. package/dist/react.js +1 -1
  29. package/dist/{register-nObreUQR.js → register-BTg0EM7s.js} +35 -3
  30. package/dist/{register-6R75AC7-.js → register-DJ0SByQg.js} +5550 -5073
  31. package/dist/{register-CvpSUU3O.js → register-DWcWq4QG.js} +22 -2
  32. package/dist/{register-BFFE1Mh1.js → register-MelqEdza.js} +1 -1
  33. package/dist/teardown-ByzfDPyu.js +240 -0
  34. package/dist/test.d.ts +35 -3
  35. package/dist/test.js +104 -10
  36. package/dist/vite.d.ts +139 -1
  37. package/dist/vite.js +355 -4
  38. package/editor/assets/{agent8-CojUfCXN.js → agent8-CAp0i5qn.js} +1 -1
  39. package/editor/assets/debug-BoEYfbqK.js +2 -0
  40. package/editor/assets/index-BO6WU8by.js +10696 -0
  41. package/editor/index.html +3 -157
  42. package/package.json +3 -2
  43. package/schemas/scene.schema.json +102 -4
  44. package/skills/incanto-3d-models.md +38 -0
  45. package/skills/incanto-assets.md +13 -0
  46. package/skills/incanto-building-3d-games.md +83 -6
  47. package/skills/incanto-editor.md +212 -8
  48. package/skills/incanto-environment.md +65 -1
  49. package/skills/incanto-node-reference.md +33 -1
  50. package/skills/incanto-physics-and-input.md +60 -6
  51. package/skills/incanto-verifying-your-game.md +57 -2
  52. package/templates-app/beacon-isle-3d/docs/project-3d-rules.md +5 -0
  53. package/templates-app/beacon-isle-3d/package.json +1 -1
  54. package/templates-app/beacon-isle-3d/vite.config.ts +7 -0
  55. package/templates-app/tps-3d/docs/project-3d-rules.md +5 -0
  56. package/templates-app/tps-3d/package.json +1 -1
  57. package/templates-app/tps-3d/vite.config.ts +7 -0
  58. package/templates-app/village-quest-3d/docs/project-3d-rules.md +5 -0
  59. package/templates-app/village-quest-3d/package.json +1 -1
  60. package/templates-app/village-quest-3d/vite.config.ts +7 -0
  61. package/dist/debug-draw-CZmOYjL2.js +0 -13
  62. package/editor/assets/index-D6RQgROR.js +0 -8330
  63. package/editor/assets/index-D8QvwvOm.css +0 -1
@@ -97,10 +97,19 @@ never be one node each. One instanced node draws them all at once:
97
97
  ```
98
98
 
99
99
  - Each row: `[x, y, z, yawDeg?, scale?]` — dense enough to GENERATE hundreds
100
- (pair with `terrain.heightAt` for y).
100
+ (pair with `snapToGround` or `terrain.heightAt` for y).
101
101
  - Same `mesh`/`size`/`material` surface as MeshInstance3D. Replace the whole
102
- `transforms` array to update. No per-instance colliders — add a few
103
- StaticBody3D boxes only where gameplay needs blocking.
102
+ `transforms` array to update.
103
+ - **`collider` makes the whole field SOLID**: `"collider": {}` gives every row
104
+ its own static collider SHAPED LIKE THE MESH — a faceted `gem` stone collides
105
+ as that stone's own hull, not as a ball tucked inside it, so you can't clip
106
+ through the corners that stick out. Sized from `size` × that row's scale and
107
+ turned by its yaw. All of them hang off one fixed body, so a fifty-stone
108
+ scatter costs fifty shapes and no per-frame work. A boulder field the player
109
+ walks straight through is the tell that a world is scenery rather than a
110
+ place.
111
+ `{ "shape": "sphere", "radius": r }` / `{ "shape": "box", "size": [x,y,z] }`
112
+ opt out into a cheaper approximation when a rough blocker is all you want.
104
113
 
105
114
  ### `LoftMesh3D` (smooth swept hulls — vehicle bodies, canopies)
106
115
 
@@ -367,14 +376,82 @@ show it as the background (otherwise `background` color applies). Standard
367
376
  materials need this OR explicit lights to be visible. An explicit HDRI wins
368
377
  over the `sky`'s image-based ambience.
369
378
 
370
- ## Preloading with a progress bar
379
+ ## NEVER compute a Y against the terrain by hand
380
+
381
+ This is the single most repeated mistake in scene authoring, and it is not a
382
+ careless one: the number is right when you write it and wrong the moment
383
+ anything reshapes the ground under it — a river carving its bed, a basin, a new
384
+ seed, a generator that mirrors a carve slightly differently. Boulders in
385
+ mid-air, a player buried to the waist, bridge posts hanging over a creek: all
386
+ the same bug.
387
+
388
+ **Say what you mean instead.** Every `Node3D` takes `snapToGround`:
389
+
390
+ ```json
391
+ { "name": "Boulder", "type": "MeshInstance3D",
392
+ "props": { "mesh": "gem", "size": [1.2, 0.8, 1.1],
393
+ "position": [12, 0, -30], // y is IGNORED
394
+ "snapToGround": 0.4 } } // half its height → it rests on the ground
395
+ ```
396
+
397
+ - `true` — put the node's origin on the ground.
398
+ - a number — the same, lifted that many metres (a prop whose origin is at its
399
+ middle wants half its height).
400
+ - `false` — "this hangs in the air ON PURPOSE" (a bridge deck, a lantern, a
401
+ cloud). The grounding check below skips these, so mark them.
402
+ - omitted — `y` is used exactly as authored.
403
+
404
+ Resolved at load, in the same frame the terrain is built, and it honours an
405
+ ancestor's yaw, so props under a turned rig land where they look.
406
+
407
+ **And check it.** `findFloatingProps` from `incanto/test` reports every prop
408
+ whose underside is off the ground, instanced fields row by row:
409
+
410
+ ```ts
411
+ import { findFloatingProps } from 'incanto/test';
412
+ const off = findFloatingProps(gameJson);
413
+ ok(`every prop meets the ground (${off.length})`, off.length === 0);
414
+ for (const o of off) console.error(` ${o.path}: ${o.gap > 0 ? 'floats' : 'buried'} ${o.gap} m`);
415
+ ```
416
+
417
+ Put it in your `verify.ts` next to `auditScene`. It costs nothing and it is the
418
+ difference between shipping a floating bridge and not.
419
+
420
+ ## The loading screen has to cover the WHOLE boot
421
+
422
+ Downloading the assets is the first half. Building a dressed scene and
423
+ compiling its GPU programs is the second, and on a big outdoor scene the second
424
+ is the longer one (measured on the creek template: 1.5 s of assets, then **7 s
425
+ of shader compile** — 49 programs). A bar that reaches 100% on the last
426
+ downloaded byte and then leaves the player looking at a blank canvas is worse
427
+ than no bar at all.
428
+
429
+ So run ONE bar across both, with `createGame3D`'s `onProgress`:
371
430
 
372
431
  ```ts
373
432
  import { assetUrls, preloadUrls } from 'incanto';
433
+
434
+ const progress = (fraction: number, label: string) => {
435
+ bar.style.width = `${Math.round(fraction * 100)}%`;
436
+ text.textContent = `${Math.round(fraction * 100)}% · ${label}`;
437
+ };
374
438
  await preloadUrls(assetUrls(sceneJson.assets), (done, total) =>
375
- bar.style.width = `${(done / total) * 100}%`);
439
+ progress((done / total) * 0.5, 'assets'));
440
+ const game = await createGame3D({
441
+ canvas, scene: sceneJson,
442
+ onProgress: (f, label) => progress(0.5 + f * 0.5, label),
443
+ });
444
+ document.querySelector('#loading')?.remove(); // now it is really ready
376
445
  ```
377
- Warms the HTTP cache before the engine starts; failures warn, never block.
446
+
447
+ `onProgress` reports `scene` → `physics` → `renderer` → `shaders` → `ready`,
448
+ and yields a frame at each step so the bar actually repaints (a callback fired
449
+ inside one synchronous block updates nothing a player can see). `createGame3D`
450
+ also draws its FIRST FRAME before it resolves, so the compile lands while your
451
+ screen is still up rather than after you remove it.
452
+
453
+ Preloading warms the HTTP cache before the engine starts; failures warn, never
454
+ block.
378
455
 
379
456
  ## Particles
380
457
 
@@ -18,9 +18,50 @@ bunx incanto-editor level.scene.json --output build/level.scene.json --port 5179
18
18
 
19
19
  **Project mode** (no file argument — the usual way) scans the current directory for
20
20
  `*.scene.json` (skipping node_modules/dist/hidden dirs): one scene auto-opens; several
21
- show a picker; the picker can also CREATE a new scene (`levels/arena.scene.json`
22
- minimal 2D scene, parent dirs made). A `scenes` button switches files anytime. The page
23
- can only ever address `*.scene.json` files under the launch directory.
21
+ open the scene browser. The page can only ever address `*.scene.json` files under the
22
+ launch directory.
23
+
24
+ ### The scene browser (`scenes`)
25
+
26
+ The `scenes` button opens the project as a tree, not a list of paths:
27
+
28
+ - **Every `.json` in the project is listed** — a scene is JSON by definition, so
29
+ nothing else could be one — and each row says whether it IS a scene, read from
30
+ the file rather than guessed from its name. A scene declares itself:
31
+ `{"format": 1, "type": "scene", "name", "root"}`, the same four keys the loader
32
+ demands. Scene rows show `3d · 24 nodes`; anything else is dimmed and marked
33
+ `not a scene`, and opening it fails with the reason (`"type" must be "scene",
34
+ and this file has no "type"`). So a scene you saved as `level.json` is right
35
+ there and opens; `package.json` is right there and tells you why it will not.
36
+ (Non-scene contents never leave the server — only the reason does.)
37
+ - **Folders**, sorted, with a scene count each; a chain that holds nothing else
38
+ collapses into one row (`src / scenes`). Small projects open fully expanded.
39
+ - **The scene you are editing** is marked and revealed, and the cursor starts on it.
40
+ - **A filter box** — type any part of a path; matches show wherever they are hiding.
41
+ Keyboard from that box: `↑↓` move · `→` open a folder · `←` close it · `⏎` load ·
42
+ `Esc` close (backdrop and ✕ work too).
43
+ - Each row carries **when it was last written and how big it is**, which is usually
44
+ how you recognise the file you were just in.
45
+ - **create** makes a new scene at the path in the box — left empty it uses the
46
+ placeholder, which tracks the folder you are standing in, so a scene lands beside
47
+ its siblings rather than at the project root. Parent dirs are created.
48
+ - Loading another scene while you have unsaved EDITS asks first.
49
+
50
+ **The same browser opens inside a running game.** When the game's dev server serves
51
+ the project's scenes, `☰ debug ▸ ✎ edit this scene` gives you the whole project: the
52
+ editor opens on the scene the game is running, and `scenes` switches to any other one,
53
+ saves back to ITS file, and `play ▸ run as the game` boots whichever scene you loaded.
54
+ That needs one plugin in `vite.config.ts` (already there in every `incanto-new`
55
+ project):
56
+
57
+ ```ts
58
+ import { incantoScenes } from 'incanto/vite';
59
+ export default defineConfig({ plugins: [incantoScenes()] });
60
+ ```
61
+
62
+ Without it the `scenes` button is still there and says what to add — a missing
63
+ one-line plugin should be a sentence you can act on, not a button that quietly
64
+ is not there. The editor still edits the scene the game booted with meanwhile.
24
65
 
25
66
  Opens a local page (default `http://127.0.0.1:5179/`) with three panes:
26
67
 
@@ -45,9 +86,16 @@ Opens a local page (default `http://127.0.0.1:5179/`) with three panes:
45
86
  (dimension, gravity with real inputs, environment/input/assets/multiplayer).
46
87
  - **Viewport with DIRECT MANIPULATION** — a mode toolbar (top left) + the
47
88
  Unity/Godot keys: **W move · E rotate · R scale** (active mode highlighted).
48
- A collider-visibility toggle sits beside the mode tools: light-green
49
- wireframes for every body (2D shapes AND 3D box/sphere/capsule), persisted,
50
- and carried into play mode as the engine's physics debugDraw.
89
+ A collider-visibility toggle sits beside the mode tools, and it shows the
90
+ colliders the ENGINE builds, not a drawing of the `collider` prop: it attaches
91
+ Rapier to the edit view with `simulate: false` and turns on the same
92
+ `debugDraw` the play view uses. So a mesh-fitted body, an InstancedMesh3D
93
+ scatter's hulls, a terrain and a character capsule all appear — none of them
94
+ are in the scene JSON — and rotation, scale and offset are wherever physics
95
+ actually puts them. Nothing is simulated: bodies are posed from the tree each
96
+ tick (an outline follows a gizmo drag) and the solver never runs, so the scene
97
+ does not fall over while you edit it. Persisted, and carried into play mode
98
+ unchanged.
51
99
  Move: axis arrows (X red, Y green, Z blue in 3D) + center square for free
52
100
  movement. Rotate: drag the ring(s) — one ring in 2D, three world-axis rings
53
101
  in 3D — with a live degree readout at the cursor. Scale: the same arrows with
@@ -56,8 +104,13 @@ and carried into play mode as the engine's physics debugDraw.
56
104
  SNAP** — rotations to 15°, positions to the grid (10 px in 2D, 0.5 u in 3D),
57
105
  scales to 0.25 steps (the readout shows the snapped value).
58
106
  2D additionally supports click-pick, body drag, wheel zoom-at-cursor,
59
- right/middle/Shift-drag pan, Alt+wheel scale, and collider wireframes;
60
- `F` frames the scene in both dimensions. The add-node dropdown is grouped by
107
+ right/middle/Shift-drag pan, Alt+wheel scale, and collider wireframes.
108
+ **`F` frames the SELECTED node** (its whole subtree; a light or empty node has
109
+ no bounds, so the camera goes to it at a readable distance) — and the whole
110
+ scene when nothing is selected, which is the Maya/Unity/Unreal meaning of the
111
+ key. Same as the ⌖ frame button, and as `frame in view` in the tree's
112
+ right-click menu. This is how you find a node you selected in the tree that is
113
+ nowhere near the camera; double-click in the tree stays RENAME. The add-node dropdown is grouped by
61
114
  category (Core / 2D / 2D Physics / 3D / 3D Physics / Network, plus a trailing
62
115
  Other catch-all so an unclaimed type can never vanish from the list). The
63
116
  dropdown, inspector and in-editor docs are registry/schema-driven — newly
@@ -110,6 +163,157 @@ Save activates only when the working scene differs from the original
110
163
  (`Ctrl/Cmd+S`); undo is `Ctrl/Cmd+Z`. Saving writes pretty-printed JSON to
111
164
  `--output` (default: the input file).
112
165
 
166
+ ## The agent8 asset library (📚)
167
+
168
+ Every field that takes a resource carries a **📚** button:
169
+
170
+ | Field | Writes |
171
+ |---|---|
172
+ | `ModelInstance3D.model` | scene asset (`model`) + the `$ref` |
173
+ | `ModelInstance3D.animation` | scene asset (`animation`) + the `$ref` — or type an embedded clip name |
174
+ | `Sprite2D.texture`, `AnimatedSprite2D.sheet` | scene asset (`texture` / `spritesheet`) + the `$ref` |
175
+ | `TileMap2D.texture` | scene asset (`texture`) + the `$ref` |
176
+ | `Sprite3D.texture`, `AnimatedSprite3D.sheet` | the URL (3D sprites take raw URLs) |
177
+ | material `map` / `normalMap`, `Tree3D.leafTexture`, `AudioPlayer.src` | the URL |
178
+ | ASSETS + form, and any asset's `url` | the URL (+ a suggested key) |
179
+
180
+ It opens the agent8 catalog that opens the agent8 catalog: shelves down the
181
+ left (**Everything** / 2D · sprite characters / 3D · characters, monsters,
182
+ objects, vehicles, weapons, polyhaven, textures), keyword search, and a detail
183
+ pane with the description, tags, format/size/mime and the URL. **Everything** is
184
+ the tagless shelf — the one that searches the whole catalog and the only way to
185
+ reach assets the tag tree does not name (sounds, one-off props).
186
+
187
+ The preview is the real thing: an image renders as an image, a **GLB is
188
+ rendered by the engine itself** (turntable, drag to spin, `targetHeight: 1` so
189
+ everything frames the same) — the same loader the game will use, so what you
190
+ see is what the scene gets.
191
+
192
+ Picking does the whole job, not half of it:
193
+
194
+ - a **URL field** (material map, leaf texture, audio src) gets the URL;
195
+ - a **`$assetKey` field** (`ModelInstance3D.model`, sprite texture/sheet) gets a
196
+ scene `assets{}` entry AND the ref that resolves to it — one action, no
197
+ separate "declare the asset" step. An entry with the same url is reused, so
198
+ browsing to the model you already have does not duplicate it;
199
+ - the ASSETS **+** form fills the url and suggests the key from the file name.
200
+
201
+ A sheet lands as a `spritesheet`, not a plain `texture` — the engine hard-fails
202
+ on the latter in an `AnimatedSprite2D.sheet` — with `frameWidth`/`frameHeight`
203
+ taken from the catalog's metadata when it carries them, and LEFT BLANK when it
204
+ does not (an invented frame size renders wrong art in silence; a blank field
205
+ asks you the question).
206
+
207
+ **Sprite configs are the good pick.** Many sprite characters ship a sibling
208
+ `<name>.json` (frame grid + named frame ranges) and the card wears an
209
+ `animated` badge. Picking one declares the sheet asset with its frame size AND
210
+ writes the node's `animations` + `autoplay` — one click gives you a sprite that
211
+ actually animates, instead of a still frame and a homework assignment.
212
+
213
+ What is on the shelves depends on the account behind your token. The public
214
+ catalog at the time of writing:
215
+
216
+ ```
217
+ 3d 5,325 characters 392 · objects 1,992 · textures 2,538 · polyhaven 2,723
218
+ animations 24 · shaders 14 · vehicles 12 · weapons 6 · monsters 6
219
+ 2d 436 projects 361 (ui, characters, sounds) · sprite_characters 54
220
+ building 9 · minecraft 7 · characterportraits 5
221
+ ```
222
+
223
+ Tags are lowercase — the catalog's own convention, and the query is
224
+ case-sensitive. If a shelf you expect is missing it is missing upstream: browse
225
+ from **Everything** and the tree shows what is actually there.
226
+
227
+ A field that knows where its art lives opens there — a model at
228
+ `3d / characters`, a clip at `3d / animations`, a material map at
229
+ `3d / textures`, a sprite sheet at `2d / sprite_characters` — and the rest start
230
+ at the root. It is a hint, not a cage: the breadcrumb walks anywhere. Either way
231
+ the kind filter applies, so a "model" field never offers you a .png.
232
+
233
+ **Access.** The catalog is per-account and its CORS list has no localhost in it,
234
+ so the page cannot call it directly — `incanto-editor` proxies it at
235
+ `GET /api/library`. Give the server a Verse8 token:
236
+
237
+ ```bash
238
+ bunx incanto-editor --token <v8 access token>
239
+ INCANTO_V8_TOKEN=<token> bunx incanto-editor # same thing
240
+ ```
241
+
242
+ With no token the 📚 panel asks for one and keeps it in the browser
243
+ (`localStorage`), which is the right answer for a shared machine — the token is
244
+ sent only to your own editor server, never written to disk by it, and forwarded
245
+ upstream as a bearer. `INCANTO_LIBRARY_URL` points the proxy somewhere else
246
+ (a mirror, or a stub in tests).
247
+
248
+ A game hosting the editor (the live play ⇄ edit switch) has no catalog of its
249
+ own — but its dev server can serve the same proxy, and then the 📚 works there
250
+ too:
251
+
252
+ ```ts
253
+ // vite.config.ts
254
+ import { incantoLibrary, incantoScenes } from 'incanto/vite';
255
+ export default defineConfig({ plugins: [incantoScenes(), incantoLibrary()] });
256
+ ```
257
+ ```ts
258
+ // main.ts
259
+ createGame3D({
260
+ ...,
261
+ debug: import.meta.env.VITE_INCANTO_DEBUG === '1',
262
+ editor: { library: true }, // "my dev server serves /api/library"
263
+ });
264
+ ```
265
+
266
+ `incantoLibrary()` is `apply: 'serve'` — dev only, nothing reaches a build, and
267
+ the token stays in the terminal that started the server (`INCANTO_V8_TOKEN`, or
268
+ `incantoLibrary({ token })`). `editor: { library: fn }` plugs in your own
269
+ transport instead. With neither, the buttons are simply absent.
270
+
271
+ ## Play, and the switch into the running game
272
+
273
+ **▶ play** means two different things and the editor asks which:
274
+
275
+ - **▶ preview here** — the scene simulates inside the editor viewport with the
276
+ game's TypeScript behaviors STRIPPED. Engine-native motion only (physics,
277
+ animation, water) — a quick look, not the game.
278
+ - **⤢ run as the game** — the page BECOMES the game: `createGame3D` boots the
279
+ working scene with your behaviors, your loading screen and the debug overlay.
280
+ This is the real thing, and it carries the edits you have not saved.
281
+
282
+ From that game, the ☰ debug menu's **✎ edit this scene** switches straight back
283
+ to the editor — same window, no reload, and the edit camera picks up the pose
284
+ the player was looking from. **✕ exit** in the editor returns to the game
285
+ without playing. The pair is one loop you can ride all session:
286
+
287
+ ```
288
+ game --(☰ debug ▸ ✎ edit this scene)--> editor
289
+ editor --(▶ play ▸ ⤢ run as the game)--> game
290
+ ```
291
+
292
+ What crosses is the AUTHORED scene, never the stepped tree: a running scene has
293
+ been moved by physics and spawned into by behaviors, and editing that would mean
294
+ editing wherever the simulation happened to be. Games hosting the editor
295
+ themselves (`createGame3D({ editor: … })`) get a **save** button only when they
296
+ pass `editor.save` — otherwise edits live as long as the session does.
297
+
298
+ ## Animating a model from the inspector
299
+
300
+ Select a `ModelInstance3D` and everything about what it is DOING sits in one
301
+ **animation** card: the clip, whether it loops, how fast, and where in the clip
302
+ it starts. The clip list is the model's own embedded clips plus the scene's
303
+ animation assets, and 📚 pulls a clip-only GLB from the agent8 library
304
+ (`3d / animations`) — picking one declares the asset and writes the ref.
305
+
306
+ - **speed** −3…3. `1` is as authored, `0` freezes the pose, negative plays
307
+ backwards. It retimes the clip already playing, so dragging it is smooth.
308
+ - **animationOffset** seconds into the clip. Changing it re-seeks live, which
309
+ makes it a scrubber as well as a stagger control — give copies different
310
+ offsets so a row of torches stops flickering in lockstep.
311
+ - The **upper-body layer** (a second clip on the upper body only) is folded away
312
+ until you use it.
313
+
314
+ The edit viewport keeps ambient visuals moving, so all of this animates while
315
+ you are editing — you see the change, not a still frame.
316
+
113
317
  ## Painting TileMap2D levels
114
318
 
115
319
  Select a `TileMap2D` node and the inspector grows a **🖌 paint tiles** tool:
@@ -520,6 +520,64 @@ automatic, no props.
520
520
  { "name": "Terrain", "type": "Terrain3D",
521
521
  "props": { "size": [200, 200], "maxHeight": 6, "seed": 1, "theme": "island" } }
522
522
  ] }
523
+ **`reflectivity` (0..1, null = the preset's own)** dials how much sky the
524
+ surface throws back at grazing angles. Turn it DOWN under a bright or overcast
525
+ sky: that sky's radiance runs far past 1, so a high ceiling paints the water
526
+ white — and a Water3D doing that beside a River3D (which paints an AUTHORED sky
527
+ palette and never blows out) reads as two unrelated materials meeting at a line.
528
+ The river template's plunge pool runs 0.06 for exactly that reason.
529
+
530
+ ### Condition a traced course before a river runs it
531
+
532
+ ```ts
533
+ import { smoothCourse, traceDownhillPath } from 'incanto/3d';
534
+ const path = smoothCourse(traceDownhillPath(heightAt, opts), widestWidth / 2);
535
+ ```
536
+
537
+ **Do this every time you feed `traceDownhillPath` into a River3D.** A steepest-
538
+ descent trace zigzags at the terrain's noise scale and can hook back within
539
+ metres of a reach it already ran. A ribbon on that course cannot be well formed:
540
+ tight corners fold its inner edge, and a hook stacks two sheets of water on the
541
+ same ground — which renders as translucent sheets of paper pasted over one
542
+ another, with no rendering fix available. `smoothCourse` relaxes the bends to
543
+ what the width can take, drops sub-width noise, and CUTS the course where it
544
+ folds back (a creek does not flow over its own reach; ending is the better
545
+ answer).
546
+
547
+ ### A river's course sets its maximum width
548
+
549
+ A `River3D` surface is a RIBBON swept along `path`, and a swept ribbon cannot be
550
+ wider than the bend it is taking — past that, its inner edge folds through
551
+ itself. The engine holds the INNER bank inside the local turn radius (the outer
552
+ bank keeps every metre the ground gives it, which is what a real bend looks
553
+ like: point bar inside, cut bank outside).
554
+
555
+ The failure this prevents is worth recognising, because it is the one visual bug
556
+ this node keeps producing: **bare channel floor beside the water — the creek
557
+ appears to stop in the middle of its own bed.** It means the ground is wetter
558
+ than the course can carry. River3D says so at load:
559
+
560
+ ```
561
+ [incanto] River3D 'Creek': the course is too tight for the water it holds —
562
+ 41 of 608 stations leave bare channel beside the ribbon (worst at 210 m: ground
563
+ wet to 11.3 m from the centre, a bend that can only carry 2.1 m). Fix by EASING
564
+ THE BENDS in `path` (fewer, straighter points), NARROWING `widths` there, or
565
+ placing standing water (a Water3D) if that reach is really a pool.
566
+ ```
567
+
568
+ Three rules that keep a river out of this entirely:
569
+
570
+ 1. **Widths ≤ ⅓ of the tightest bend.** A `traceDownhillPath` result zig-zags;
571
+ thin it or raise its `step` before handing it to a wide river.
572
+ 2. **A wide slow reach is still the river.** Don't put a Water3D pool at the
573
+ foot of a River3D — they are different shaders with different sky and foam
574
+ models, they cannot be tuned to match, and they meet along a visible seam.
575
+ Open the `widths` profile instead (`[2.4, 4.5, 7, 9]` is a spring→pool run).
576
+ 3. **Verify it, don't eyeball it.** `findRiverCoverageGaps(rings)` (exported from
577
+ `incanto/3d`) reports the reaches where the ribbon falls short, and a probe a
578
+ metre outside each bank — ground still BELOW the waterline out there — counts
579
+ bare channel headlessly. The river template gates on both.
580
+
523
581
  That snippet is the canonical PHYSICS recipe: the `heightfield` collider has
524
582
  no params of its own — it pulls the height grid from its Terrain3D CHILD, so
525
583
  visuals and collision can never drift apart. It is static-only (load-time
@@ -819,6 +877,12 @@ the scene root a cutout has nothing to stand in for, and the loader says so.
819
877
  | `size` | `[2, 1, 1]` | box extent in meters, centered on the node — which PART of the parent holds water back |
820
878
  | `enabled` | `true` | live toggle — a scuttled hull can start letting the sea in |
821
879
 
880
+ **A plunge pool is a `Water3D`, not a river.** A `River3D` is a current: a
881
+ ribbon fitted to the ground it runs over. Run one across a carved basin and it
882
+ lays a strip of water over the bowl with its edges hanging in mid-air — end the
883
+ creek at the lip and put a pool in the basin instead. Size a square surface to
884
+ `side = radius · √2` so its corners land on the rim rather than over the bank.
885
+
822
886
  **A cutout cannot punch a hole in open water**, because nothing is ever cut out
823
887
  of the water. The mask is the parent's own silhouette, so water can only be
824
888
  hidden behind geometry the player is already looking at. Overshoot the box and
@@ -979,7 +1043,7 @@ underneath decides everything else.
979
1043
  | `terrain` | `''` | drape target path; empty = auto-find the first Terrain3D (a wrong path fails at load) |
980
1044
  | `carve` | `true` | cut the bed. The river trenches its own channel into the terrain it drapes on — see below |
981
1045
  | `flowForce` | `1` | how hard the current sweeps bodies downstream (0 = visual only) |
982
- | `spray` | `1` | mist at the foot of every waterfall the course turns out to contain — the node finds the drops and hangs a Particles3D plume on each (0 = off) |
1046
+ | `spray` | `1` | mist at the foot of every drop the course turns out to contain — the node finds them and hangs a Particles3D plume on each (0 = off) |
983
1047
  | `sunDirection` / `sunColor` / `sunIntensity` | sky / `#fff6e0` / `1` | glint (the environment sun wins while `sunDirection` is default) |
984
1048
 
985
1049
  **What the node derives for you**, all from `path` + the ground: