incanto 0.53.0 → 0.54.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 (55) hide show
  1. package/bin/incanto-check.mjs +56 -1
  2. package/dist/2d.d.ts +46 -3
  3. package/dist/2d.js +3 -3
  4. package/dist/3d.d.ts +105 -6
  5. package/dist/3d.js +10 -6
  6. package/dist/{behavior-Do0Da56m.d.ts → behavior-CyQoSu4n.d.ts} +114 -10
  7. package/dist/{create-game-9D87XaiX.js → create-game-BRt6XKmP.js} +10 -6
  8. package/dist/{create-game-CDJ1lVqK.js → create-game-Czzp6ZuE.js} +10 -6
  9. package/dist/debug.d.ts +1 -1
  10. package/dist/debug.js +1 -1
  11. package/dist/{environment-presets-SkGanr2s.js → environment-presets-BQ_QsIBY.js} +222 -11
  12. package/dist/{gameplay-CRYw_Q-T.js → gameplay-CZ2yq37J.js} +30 -21
  13. package/dist/gameplay.d.ts +8 -3
  14. package/dist/gameplay.js +1 -1
  15. package/dist/index.d.ts +6 -6
  16. package/dist/index.js +5 -5
  17. package/dist/{loader-Cu_7kJDy.d.ts → loader-DhI1jFW_.d.ts} +1 -1
  18. package/dist/net.d.ts +2 -2
  19. package/dist/net.js +1 -1
  20. package/dist/{particle-sim-BzJ1yxoE.d.ts → particle-sim-C5OfBbmU.d.ts} +11 -0
  21. package/dist/{pathfinding-HNGFqGUZ.d.ts → pathfinding-CXGCpRQe.d.ts} +1 -1
  22. package/dist/{physics-2d-BhZZ-HAp.js → physics-2d-CfWAggJ1.js} +1 -1
  23. package/dist/{physics-3d-DmyO2oaN.js → physics-3d-Bes-GIuR.js} +2 -2
  24. package/dist/react.d.ts +1 -1
  25. package/dist/react.js +1 -1
  26. package/dist/{register-DROK2l7J.js → register-en63AEZO.js} +163 -4
  27. package/dist/{register-BTomIiYG.js → register-p48lHE2o.js} +130 -13
  28. package/dist/{replay-9Fy6C10F.d.ts → replay-ePMz26jw.d.ts} +1 -1
  29. package/dist/{replay-DYNUL4BU.js → replay-t1pP0gQg.js} +1 -1
  30. package/dist/{split-screen-DNmcX1Pz.d.ts → split-screen-BsdOHbzP.d.ts} +1 -1
  31. package/dist/{split-screen-CaF9hO7g.js → split-screen-CSb_uZ6W.js} +1 -1
  32. package/dist/{sprite-animation-D_p28jwU.js → sprite-animation-7qvUxF6Z.js} +19 -0
  33. package/dist/{src-C9xyZW7M.js → src-vNPQeQ1W.js} +1 -1
  34. package/dist/{teardown-Bw2aeyGI.js → teardown-C7uVSJvx.js} +1 -1
  35. package/dist/{test-CJRsciFk.js → test-Tnf1nQl3.js} +24 -12
  36. package/dist/test.d.ts +4 -4
  37. package/dist/test.js +2 -2
  38. package/dist/vite.js +2 -2
  39. package/editor/assets/{agent8-PlFHzJsh.js → agent8-BWaW-D85.js} +1 -1
  40. package/editor/assets/{debug-CebV7CDW.js → debug-DLF8rUtr.js} +2 -2
  41. package/editor/assets/{index-CdbsY31G.js → index-BYfiwbQx.js} +91 -91
  42. package/editor/index.html +1 -1
  43. package/package.json +1 -1
  44. package/schemas/scene.schema.json +8 -0
  45. package/skills/incanto-assets.md +45 -2
  46. package/skills/incanto-building-2d-games.md +35 -0
  47. package/skills/incanto-building-3d-games.md +3 -1
  48. package/skills/incanto-environment.md +3 -1
  49. package/skills/incanto-gameplay-behaviors.md +51 -4
  50. package/skills/incanto-node-reference.md +2 -0
  51. package/skills/incanto-performance.md +47 -0
  52. package/skills/incanto-verifying-your-game.md +31 -0
  53. package/templates-app/beacon-isle-3d/package.json +1 -1
  54. package/templates-app/tps-3d/package.json +1 -1
  55. package/templates-app/village-quest-3d/package.json +1 -1
package/editor/index.html CHANGED
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>Incanto Scene Editor</title>
7
7
  <link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><rect width='16' height='16' rx='3' fill='%236ee7dc'/><text x='8' y='12' text-anchor='middle' font-size='11' font-family='monospace' fill='%230e1018'>i</text></svg>" />
8
- <script type="module" crossorigin src="./assets/index-CdbsY31G.js"></script>
8
+ <script type="module" crossorigin src="./assets/index-BYfiwbQx.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="./assets/GameServer-C56iOUgF.js">
10
10
  </head>
11
11
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incanto",
3
- "version": "0.53.0",
3
+ "version": "0.54.0",
4
4
  "description": "Vibe-coding-first web game engine SDK — JSON-driven scenes on three.js",
5
5
  "keywords": [
6
6
  "game-engine",
@@ -4235,6 +4235,10 @@
4235
4235
  "type": "boolean",
4236
4236
  "default": true
4237
4237
  },
4238
+ "worldSpace": {
4239
+ "type": "boolean",
4240
+ "default": false
4241
+ },
4238
4242
  "rate": {
4239
4243
  "type": "number",
4240
4244
  "default": 40
@@ -4443,6 +4447,10 @@
4443
4447
  "type": "boolean",
4444
4448
  "default": true
4445
4449
  },
4450
+ "worldSpace": {
4451
+ "type": "boolean",
4452
+ "default": false
4453
+ },
4446
4454
  "rate": {
4447
4455
  "type": "number",
4448
4456
  "default": 40
@@ -146,6 +146,47 @@ Swap in real art later by changing ONLY the `assets{}` entry — node props
146
146
  stay untouched.
147
147
 
148
148
 
149
+ ## Art you named and never copied
150
+
151
+ `bunx incanto-check` warns when a scene asset points at a local file the project
152
+ does not contain:
153
+
154
+ ```
155
+ ok src/game.scene.json
156
+ warn: $hero → assets/hero.png is not in the project (looked in public/,
157
+ ./, and beside the scene). It will draw nothing.
158
+ ```
159
+
160
+ That used to be a browser-only failure — visible in `assetErrors()`, which needs
161
+ a running game and someone to look at it — and it is the single most common way
162
+ a scene draws nothing. Remote (`https:`) and inline (`data:`) urls are left
163
+ alone: the command cannot know, and guessing would be worse than the bug.
164
+
165
+ ## A spritesheet grid that does not fit says so
166
+
167
+ `frameWidth`/`frameHeight` are the two numbers nothing could check for you, and
168
+ getting them wrong does not fail — it draws the wrong art. A size that does not
169
+ divide the sheet slices every row a little further off centre; an animation
170
+ naming a frame past the end of the grid reads whatever is at the wrong end of
171
+ the image.
172
+
173
+ Both are reported now, once, the first time the sprite draws:
174
+
175
+ ```
176
+ [incanto] spritesheet 'hero' does not fit its frame size: 1344 px wide is not a
177
+ whole number of 100 px frames (672, 448, 336, 224, 192, 112 would divide it).
178
+ Every row after the first is cut off centre.
179
+
180
+ [incanto] spritesheet 'hero' has 35 frames (0–34), and an animation asks for
181
+ frame 40. Those frames draw whatever is at the wrong end of the sheet.
182
+ ```
183
+
184
+ The suggested sizes are the ones that actually divide your image, so the fix is
185
+ usually in the message. `bunx incanto-assets info <name>` prints the real frame
186
+ size for a built-in, and the editor's 📚 picker fills it in from the catalog's
187
+ metadata — or leaves it BLANK when the catalog does not carry it, because an
188
+ invented frame size is exactly this bug.
189
+
149
190
  ## Textures are shared automatically (3D)
150
191
 
151
192
  A hundred `Sprite3D`s pointing at one atlas cost **one** fetch, one decode and
@@ -162,9 +203,11 @@ Two consequences worth knowing:
162
203
  - **`pixelArt: true` also turns mipmaps off**, which is what makes pixel art stay
163
204
  crisp at distance instead of blurring into mud.
164
205
 
165
- A texture that 404s now shows up in `game.assetErrors()` alongside models, by the
206
+ A texture that 404s shows up in `game.assetErrors()` alongside models, by the
166
207
  URL you wrote — so "why is my sprite invisible" is answerable without opening the
167
- network tab. In **2D** the same question is `renderer.assets.errors()`
208
+ network tab. **That includes vegetation**: a `Tree3D` leaf or bark URL that fails
209
+ used to leave a grove of bare branches and say nothing anywhere, because that
210
+ node keeps its own texture cache. In **2D** the same question is `renderer.assets.errors()`
168
211
  (`$ref`, url and reason per failed entry), and the scene EDITOR reads it: a
169
212
  failed asset is red in the explorer with the url in its tooltip and the
170
213
  consequence in its inspector.
@@ -291,6 +291,41 @@ solid core carries the colour). `rate: 0` +
291
291
  { "signal": "finished", "from": "Boom", "to": ".", "handler": "onBoomDone" }
292
292
  ```
293
293
 
294
+ ### Where a particle LIVES: `worldSpace`
295
+
296
+ A particle is born in the emitter's LOCAL space by default, so the whole plume
297
+ moves with the node — right for a torch on a moving platform, wrong for almost
298
+ everything else:
299
+
300
+ - dust under a running player is GLUED to the player instead of left behind;
301
+ - and the standard way to place a one-shot — move the emitter, `replay()` —
302
+ drags the PREVIOUS burst across the level with it.
303
+
304
+ `"worldSpace": true` makes a particle keep the place it was born:
305
+
306
+ ```jsonc
307
+ { "name": "Dust", "type": "Particles2D",
308
+ "props": { "preset": "smoke", "worldSpace": true } }
309
+ ```
310
+
311
+ It follows a moving PARENT too, not just the node's own position. Default is
312
+ `false` so existing scenes look exactly as they did.
313
+
314
+ ### Armed, but not yet: `emitting: false`
315
+
316
+ A one-shot with `burst` fires on its FIRST FRAME — which is what you want for a
317
+ firework that is meant to go off as the level opens, and not at all what you
318
+ want for the twenty explosions authored on twenty destructible crates. Set
319
+ `"emitting": false` to arm one and hold it:
320
+
321
+ ```jsonc
322
+ { "name": "Boom", "type": "Particles2D",
323
+ "props": { "preset": "explosion", "rate": 0, "burst": 60, "emitting": false } }
324
+ ```
325
+
326
+ `node.replay()` fires it — that is the game asking, so `emitting: false` does
327
+ not hold it back — and re-arms it for the next time.
328
+
294
329
  `node.replay()` re-arms a one-shot. Simulation is deterministic under the
295
330
  engine seed — runScript verifies particle gameplay reproducibly.
296
331
 
@@ -463,7 +463,9 @@ block.
463
463
  ## Particles
464
464
 
465
465
  `Particles3D` mirrors `Particles2D` (same presets — `fire`, `explosion`,
466
- `magic`… and the same one-shot `rate: 0` + `burst` → `finished` pattern) as
466
+ `magic`… the same one-shot `rate: 0` + `burst` → `finished` pattern, and the
467
+ same `worldSpace` prop, which is what stops a moved one-shot dragging the
468
+ previous explosion across the level) as
467
469
  point sprites in meters: preset distances auto-scale ÷100 (presets are authored
468
470
  in 2D px). See incanto-building-2d-games for the full prop list.
469
471
 
@@ -1042,7 +1042,9 @@ emitter only when you want a specific custom burst:
1042
1042
 
1043
1043
  (`replay` re-arms the one-shot burst; a small behavior can also move the
1044
1044
  emitter to the body first — the signal hands you the node:
1045
- `onEntered(body) { splash.position = body.position; splash.replay(); }`.)
1045
+ `onEntered(body) { splash.position = body.position; splash.replay(); }` — give
1046
+ that emitter `"worldSpace": true`, or the second splash drags the first one to
1047
+ the new spot.)
1046
1048
 
1047
1049
  ## River3D — running water
1048
1050
 
@@ -815,12 +815,59 @@ import { CameraShake, Cooldown, hitStop, screenFlash } from 'incanto/gameplay';
815
815
  meters). For cameras WITHOUT a follow script attach the standalone
816
816
  `CameraShake` behavior — it composes with any other position writer and
817
817
  returns the camera exactly to base.
818
- - **screenFlash(color?, opacity?, seconds?)** — full-screen damage/pickup
819
- flash (DOM, headless no-op).
818
+ - **screenFlash(engine, color?, opacity?, seconds?)** — full-screen damage/
819
+ pickup flash. DOM, so it draws nothing headless — but it REPORTS (below), so
820
+ you can still check that it fired.
820
821
  - **hitStop(engine, seconds?)** — freezes `engine.timeScale` for REAL
821
- seconds then restores; stacked calls extend. Sells melee impacts.
822
+ seconds then restores; stacked calls extend. Sells melee impacts. It measures
823
+ those seconds on `engine.unscaledTime`, so it thaws in a headless session
824
+ exactly as it does in a browser.
822
825
  - **engine.timeScale** — 1 realtime, 0.5 slow motion, 0 pause: scales
823
- variable AND fixed updates together (physics, timers, behaviors).
826
+ variable AND fixed updates together (physics, timers, behaviors) — and it
827
+ means the same thing headless, so a pause menu and a slow-motion finish can be
828
+ tested. (A stepped frame still HAPPENS while paused: `update` runs with
829
+ `dt = 0`, which is how the pause menu's own key polling keeps working.)
830
+
831
+ ## Did the effect fire?
832
+
833
+ Sound has `engine.audio`; vision has **`engine.effects`**, and the question is
834
+ the same one. `framing()` says where an emitter IS — a particle system that
835
+ never fired and one that fired a hundred times sit at the same coordinates — and
836
+ shake, flash and hit-stop draw nothing at all in a run with no screen.
837
+
838
+ ```ts
839
+ session.engine.effects.clearLog();
840
+ smashTheCrystal();
841
+ session.step(200);
842
+
843
+ session.engine.effects.countOf('explosion'); // 1
844
+ session.engine.effects.countFrom('/Game/Crystal/Boom'); // 1
845
+ session.engine.effects.recent();
846
+ // [{ kind: 'burst', name: 'explosion', from: '/Game/Crystal/Boom', amount: 60, at: 1.2 }]
847
+ ```
848
+
849
+ - `kind` — `burst` (a one-shot fired) · `emit` (a continuous emitter STARTED —
850
+ once, not once per particle) · `trail` (a `Trail3D` started laying ribbon) ·
851
+ `shake` · `flash` · `hitstop`.
852
+ - `name` — the particle preset, or the flash colour.
853
+ - `from` — the node path, or `engine` for the screen-wide ones.
854
+ - `amount` — particles in the burst, shake magnitude, seconds frozen.
855
+ - Bounded at 200, `clearLog()` between assertions.
856
+
857
+ A `Trail3D`'s ribbon is a special case worth knowing: it is laid in the RENDER
858
+ pass, because each point needs the node's real world transform (a sword arc is a
859
+ rotating parent). So `trail.pointCount` is **0 headless** — that is the verify VM
860
+ working, not a broken trail — and the `trail` event above is what tells you the
861
+ wiring fired.
862
+
863
+ It records that the effect was ASKED FOR, not that a pixel moved — the burst
864
+ that never happened because the signal was never connected looks exactly like
865
+ the burst that happened off-screen, and this tells them apart. For "is it
866
+ running right now", a particle node also has **`aliveCount`**.
867
+
868
+ A shake suppressed by `reduceMotion` records NOTHING, on purpose: it did not
869
+ happen, and saying it did would send you hunting a camera bug that is an
870
+ accessibility setting.
824
871
 
825
872
  ## Game flow (win / lose / restart)
826
873
 
@@ -613,6 +613,7 @@ _No props (structural fields only)._
613
613
  | `visible` | `true` | boolean |
614
614
  | `preset` | `"custom"` | one of: `custom` `fire` `smoke` `sparks` `fireworks` `explosion` `flash` `lightning` `rain` `snow` `magic` |
615
615
  | `emitting` | `true` | boolean |
616
+ | `worldSpace` | `false` | boolean |
616
617
  | `rate` | `40` | number |
617
618
  | `burst` | `0` | number |
618
619
  | `lifetime` | `[0.6,1.2]` | array |
@@ -648,6 +649,7 @@ Signals: `finished`
648
649
  | `snapToGround` | `null` | null |
649
650
  | `preset` | `"custom"` | one of: `custom` `fire` `smoke` `sparks` `fireworks` `explosion` `flash` `lightning` `rain` `snow` `magic` |
650
651
  | `emitting` | `true` | boolean |
652
+ | `worldSpace` | `false` | boolean |
651
653
  | `rate` | `40` | number |
652
654
  | `burst` | `0` | number |
653
655
  | `lifetime` | `[0.6,1.2]` | array |
@@ -13,6 +13,37 @@ You do not implement any of this. You decide whether to expose it.
13
13
 
14
14
  ---
15
15
 
16
+ ## First: where did the frame go?
17
+
18
+ A settings menu is what you offer a PLAYER. This is what you ask the game.
19
+
20
+ ```ts
21
+ game.stats();
22
+ // { fps: 31, frameMs: 32.1, nodes: 4210, triangles: 890_000, drawCalls: 340,
23
+ // phases: { fixedMs: 21.4, updateMs: 2.2, renderMs: 6.1, otherMs: 2.4 } }
24
+ ```
25
+
26
+ `fps` and `frameMs` are a total, and a total has no next question. The four
27
+ slices say which part of the frame to look at:
28
+
29
+ | slice | what is in it | what to do about it |
30
+ | --- | --- | --- |
31
+ | `fixedMs` | physics and everything on `fixedUpdate` | fewer/simpler colliders, `fixedHz`, sleep distant bodies |
32
+ | `updateMs` | behaviors, node logic, tweens | the per-frame work your game does — profile it in your own code |
33
+ | `renderMs` | the renderer, reported by itself | quality tier, `renderScale`, draw calls, shadows |
34
+ | `otherMs` | the frame MINUS the three above | GC, browser layout, your own rAF work. **Allocations show up here.** |
35
+
36
+ `otherMs` is the one worth knowing about. A frame drop that everyone reads as a
37
+ GPU problem is often garbage collection, and it looks identical from the outside
38
+ — this engine lost a day to exactly that. A big `otherMs` with small everything
39
+ else means you are allocating per frame: replace arrays and objects created in
40
+ `update()` with reused ones.
41
+
42
+ Averages over the same rolling window as `frameMs`, so the numbers add up to it
43
+ and are comparable to each other. Headless (`step()`), `fps`/`frameMs` are 0 and
44
+ the slices are still real CPU times — a behavior that got slower shows up in a
45
+ test.
46
+
16
47
  ## The short version
17
48
 
18
49
  ```ts
@@ -32,6 +63,22 @@ Every one of those is written to the save store and comes back on the next launc
32
63
 
33
64
  ---
34
65
 
66
+ ## Leaks: a level swap has to give the GPU back
67
+
68
+ `stats().geometries` and `stats().textures` are the leak witnesses — they count
69
+ what three is holding right now. Swap levels a few times and read them again:
70
+
71
+ ```ts
72
+ const before = game.stats().geometries;
73
+ await loadLevel(2);
74
+ await loadLevel(1);
75
+ game.stats().geometries; // should be ~before, not 2x before
76
+ ```
77
+
78
+ Every node that builds geometry releases it when it is freed, and a scene swap
79
+ frees the old tree. If your own code holds a three object (a custom behavior
80
+ that built a mesh), dispose it in the behavior's `onExitTree`.
81
+
35
82
  ## The four levers, and what each actually costs
36
83
 
37
84
  | setting | values | costs | changes live |
@@ -679,6 +679,37 @@ expect(session.engine.audio.countOf('hit')).toBe(1);
679
679
  time; `countOf(name)` counts one. A clip whose FILE is broken shows up in
680
680
  `assetErrors()` instead. Full guide: `incanto-audio.md`.
681
681
 
682
+ ## Speed: which part of the frame is expensive?
683
+
684
+ ```ts
685
+ game.stats().phases;
686
+ // { fixedMs: 21.4, updateMs: 2.2, renderMs: 6.1, otherMs: 2.4 }
687
+ ```
688
+
689
+ Physics, behaviors, the renderer, and everything else. The last one is where GC
690
+ and per-frame allocation hide, and it is the slice a screenshot can never show.
691
+ See `incanto-performance.md`.
692
+
693
+ ## Sight: did the right thing SHOW?
694
+
695
+ The same question as sound, about the other half of a game's feedback. Nothing
696
+ renders in the VM, so shake, flash and freeze frames are no-ops and a particle
697
+ system that never fired sits at exactly the same coordinates as one that fired a
698
+ hundred times — `framing()` reports WHERE an emitter is, never whether it went
699
+ off.
700
+
701
+ ```ts
702
+ session.engine.effects.clearLog();
703
+ smashTheCrystal();
704
+ session.step(200);
705
+ expect(session.engine.effects.countOf('explosion')).toBe(1);
706
+ ```
707
+
708
+ `engine.effects.recent()` is the last 200 effects — `kind` (`burst` · `emit` ·
709
+ `shake` · `flash` · `hitstop`), the preset or colour, the node path, and how big.
710
+ `countFrom(path)` asks about one emitter, which is usually the wiring question.
711
+ A particle node's `aliveCount` answers the other one: is it running right now.
712
+
682
713
  ## Multiplayer: do the players end up in the SAME world?
683
714
 
684
715
  Every rung above asks about one player. A multiplayer game's first question is
@@ -14,7 +14,7 @@
14
14
  "@dimforge/rapier2d-compat": "0.19.3",
15
15
  "@dimforge/rapier3d-compat": "0.19.3",
16
16
  "@pixiv/three-vrm": "^3.5.3",
17
- "incanto": "^0.53.0",
17
+ "incanto": "^0.54.0",
18
18
  "three": "^0.184.0"
19
19
  },
20
20
  "devDependencies": {
@@ -13,7 +13,7 @@
13
13
  "@dimforge/rapier2d-compat": "0.19.3",
14
14
  "@dimforge/rapier3d-compat": "0.19.3",
15
15
  "@pixiv/three-vrm": "^3.5.3",
16
- "incanto": "^0.53.0",
16
+ "incanto": "^0.54.0",
17
17
  "three": "^0.184.0"
18
18
  },
19
19
  "devDependencies": {
@@ -13,7 +13,7 @@
13
13
  "@dimforge/rapier2d-compat": "0.19.3",
14
14
  "@dimforge/rapier3d-compat": "0.19.3",
15
15
  "@pixiv/three-vrm": "^3.5.3",
16
- "incanto": "^0.53.0",
16
+ "incanto": "^0.54.0",
17
17
  "three": "^0.184.0"
18
18
  },
19
19
  "devDependencies": {