@origingame/engine 0.2.0 → 0.4.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 (118) hide show
  1. package/bin/og.mjs +1 -1
  2. package/dist/web/origin-engine.d.ts +255 -5
  3. package/dist/web/origin-engine.js +1584 -125
  4. package/dist/web/origin-engine_bg.wasm +0 -0
  5. package/dist/web/origin-engine_bg.wasm.d.ts +80 -3
  6. package/dist/web-publish/origin-engine-lanes.js +1288 -82
  7. package/dist/web-publish/origin-engine-lanes_bg.wasm +0 -0
  8. package/dist/web-publish/origin-engine.d.ts +199 -6
  9. package/dist/web-publish/origin-engine.js +1285 -79
  10. package/dist/web-publish/origin-engine_bg.wasm +0 -0
  11. package/dist/web-publish/origin-engine_bg.wasm.d.ts +65 -4
  12. package/dist/web-publish-2d/origin-engine-lanes.js +1285 -79
  13. package/dist/web-publish-2d/origin-engine-lanes_bg.wasm +0 -0
  14. package/dist/web-publish-2d/origin-engine.d.ts +198 -5
  15. package/dist/web-publish-2d/origin-engine.js +1282 -76
  16. package/dist/web-publish-2d/origin-engine_bg.wasm +0 -0
  17. package/dist/web-publish-2d/origin-engine_bg.wasm.d.ts +64 -3
  18. package/knowledge/README.md +2 -1
  19. package/knowledge/guides/three-to-og.md +393 -0
  20. package/knowledge/knowledge.json +2 -1
  21. package/knowledge/looks/catalogue.json +40 -40
  22. package/knowledge/package.json +3 -2
  23. package/knowledge/scaffold/distribution.json +14 -0
  24. package/knowledge/scaffold/origin-engine.json +2 -2
  25. package/knowledge/scaffold/template/README.md +2 -1
  26. package/knowledge/scaffold/template/assets/audio/sting.ogt +10 -0
  27. package/knowledge/scaffold/template/assets/timelines/intro.ogt +101 -0
  28. package/knowledge/scaffold/template/assets/timelines/narration.srt +11 -0
  29. package/knowledge/scaffold/template/host.d.ts +46 -0
  30. package/knowledge/scaffold/template/package.json +1 -1
  31. package/knowledge/scaffold/template/project.ogt +1 -1
  32. package/knowledge/scaffold/template/src/main.ts +1 -1
  33. package/knowledge/scaffold/template/tests/frames.ts +134 -0
  34. package/knowledge/scaffold/template/tests/intro.og.ts +65 -0
  35. package/knowledge/scaffold/template/tests/smoke.og.ts +30 -36
  36. package/knowledge/scaffold/template/tsconfig.json +1 -1
  37. package/knowledge/scripts/mount.ts +2 -1
  38. package/knowledge/scripts/validate.ts +159 -31
  39. package/knowledge/skills/og-audio/SKILL.md +2 -2
  40. package/knowledge/skills/og-build/SKILL.md +29 -7
  41. package/knowledge/skills/og-core/SKILL.md +31 -5
  42. package/knowledge/skills/og-feel/SKILL.md +2 -2
  43. package/knowledge/skills/og-game/SKILL.md +1331 -16
  44. package/knowledge/skills/og-i18n/SKILL.md +7 -7
  45. package/knowledge/skills/og-model/SKILL.md +374 -0
  46. package/knowledge/skills/og-platform-sdk/SKILL.md +2 -1
  47. package/knowledge/skills/og-taste/SKILL.md +82 -73
  48. package/knowledge/skills/og-ui/SKILL.md +80 -58
  49. package/knowledge/wiki/ai.md +20 -20
  50. package/knowledge/wiki/anim.md +392 -41
  51. package/knowledge/wiki/atmosphere.md +36 -13
  52. package/knowledge/wiki/audio.md +18 -18
  53. package/knowledge/wiki/camera.md +19 -13
  54. package/knowledge/wiki/commands.md +19 -13
  55. package/knowledge/wiki/debug.md +414 -0
  56. package/knowledge/wiki/game.md +8 -8
  57. package/knowledge/wiki/i18n.md +7 -7
  58. package/knowledge/wiki/index.md +317 -8
  59. package/knowledge/wiki/input.md +47 -47
  60. package/knowledge/wiki/load.md +238 -70
  61. package/knowledge/wiki/math.md +2607 -0
  62. package/knowledge/wiki/nav.md +34 -34
  63. package/knowledge/wiki/net.md +340 -0
  64. package/knowledge/wiki/path.md +402 -0
  65. package/knowledge/wiki/physics.md +95 -95
  66. package/knowledge/wiki/platform.md +463 -29
  67. package/knowledge/wiki/probe.md +681 -67
  68. package/knowledge/wiki/reflect.md +29 -17
  69. package/knowledge/wiki/render.md +4993 -1998
  70. package/knowledge/wiki/rng.md +14 -14
  71. package/knowledge/wiki/shapes.md +727 -0
  72. package/knowledge/wiki/stream.md +15 -15
  73. package/knowledge/wiki/system.md +8 -8
  74. package/knowledge/wiki/systems.md +2 -2
  75. package/knowledge/wiki/terrain.md +24 -20
  76. package/knowledge/wiki/tilemap.md +13 -13
  77. package/knowledge/wiki/time.md +4 -4
  78. package/knowledge/wiki/timeline.md +396 -0
  79. package/knowledge/wiki/transform.md +8 -8
  80. package/knowledge/wiki/tween.md +17 -17
  81. package/knowledge/wiki/ui.md +560 -654
  82. package/knowledge/wiki/video.md +157 -0
  83. package/knowledge/wiki/world.md +36 -36
  84. package/package.json +4 -3
  85. package/schema/api.schema.json +28151 -19640
  86. package/shell/page.ts +26 -2
  87. package/shell/platform.ts +51 -0
  88. package/shell/player.ts +15 -2
  89. package/shell/transport.ts +6 -0
  90. package/src/depth.ts +71 -0
  91. package/src/e6.ts +32 -1
  92. package/src/env.d.ts +5 -1
  93. package/src/generated/abi.ts +226 -4
  94. package/src/geom.ts +260 -0
  95. package/src/index.ts +32 -4
  96. package/src/light.ts +18 -0
  97. package/src/math.ts +622 -0
  98. package/src/node/index.ts +17 -0
  99. package/src/node/playtest-run.ts +115 -18
  100. package/src/node/polish.ts +13 -3
  101. package/src/node/render.ts +291 -0
  102. package/src/node/run.ts +86 -5
  103. package/src/p2.ts +19 -1
  104. package/src/platform-local.ts +2 -0
  105. package/src/playtest.ts +65 -4
  106. package/src/runtime.ts +100 -9
  107. package/src/targets.ts +28 -0
  108. package/src/trace.ts +169 -0
  109. package/src/ui-kit/huds.ts +34 -34
  110. package/src/ui-kit/menus.ts +12 -12
  111. package/src/ui-kit/settings.ts +11 -2
  112. package/src/ui-kit/store.ts +18 -18
  113. package/src/ui-kit/story.ts +6 -4
  114. package/src/ui-kit/util.ts +8 -8
  115. package/src/web/shell.ts +59 -1
  116. package/src/web/worker.ts +105 -4
  117. package/types/bindings.json +9368 -6619
  118. package/types/index.d.ts +16377 -11520
@@ -18,7 +18,7 @@ module anim {
18
18
  # declarations follow, each quoted below
19
19
  ```
20
20
 
21
- <sub>`api.ogt` line 5636</sub>
21
+ <sub>`api.ogt` line 7707</sub>
22
22
 
23
23
  ## Contents
24
24
 
@@ -64,6 +64,17 @@ module anim {
64
64
  | [`FlipbookInfo`](#type-FlipbookInfo) | struct | What og.load.flipbook registered. |
65
65
  | [`og.anim.clip`](#fn-clip) | function | The index of a flipbook clip by name, for Flipbook.clip: `og.anim.clip(hero, "walk_down")`. -1 when the sheet has no such clip. |
66
66
  | [`og.anim.clip`](#fn-clip) | function | A loaded model's clip by name, for AnimationPlayer.clip: `og.anim.clip(og.load.animation(world, "models/slime.glb").value, "chase")`, the same lookup as a flipbook's (Animation.clips by ClipInfo.name). A skinned glTF's clips are its animations' names; an animated `.vox`'s are `frames` or its `voxClip` names. 0 (plays nothing) when the model has no such clip. |
67
+ | [`og.anim.clip`](#fn-clip) | function | The index of a 2D rig's clip by name, for Skeleton2D.clip: `og.anim.clip(og.load.rig2d(world, "rigs/hero.ogt").value, "walk")`. -1 when the rig has no such clip. |
68
+ | [`Rig2D`](#type-Rig2D) | handle | A 2D rig (a cooked `.ogt` of `type rig2d`): bones, slots, region, mesh, bounding-box and child-armature attachments, IK constraints, child armatures and clips, from og.load.rig2d. |
69
+ | [`Rig2D()`](#column-Rig2D) | column kind | A Rig2D handle field. |
70
+ | [`og.Skeleton2D`](#record-Skeleton2D) | component | Plays a clip of a 2D rig at the entity: the og.skeleton2d system advances it by scaled time (Time.scaledDt) after the game's systems and fires its events as og.Skeleton2DEvent; extraction draws its slots, in their order, as textured triangles of the sprite batch at `layer` (region attachments as quads, mesh attachments weighted to bones and deformed by the clip), lit by og.Lighting2D when the layer is in its range, as a sprite there is. The rig's pixels are `unit` to a world unit and +y is up; the entity's og.Transform places, turns (about z) and scales it. |
71
+ | [`og.Skeleton2DEvent`](#record-Skeleton2DEvent) | event | A 2D skeleton's clip, or the clip a child armature in one of its slots plays, passed one of its events (`event 0.2 "step"` in the rig) in the last tick: footsteps, the frame a swing lands. Read in the tick after, like every event; a clip started at 0 fires its events at 0, a looping clip fires each once per pass. |
72
+ | [`og.IkTarget2D`](#record-IkTarget2D) | component | Moves one IK constraint of a 2D skeleton (Rig2DInfo.constraints) to a point: a foot planted on the ground under it, a hand on a ledge, a tail's tip. A constraint is a chain of any length: one bone points at the target, two are solved exactly (bending the way the rig says), three or more by FABRIK from the animated pose, curling the way the rig says. Put it on its own entity, one per constraint; og.skeleton2d writes `reached` and `error`, and the drawn pose solves the same way. |
73
+ | [`Rig2DClipInfo`](#type-Rig2DClipInfo) | struct | One clip of a loaded 2D rig. |
74
+ | [`Rig2DInfo`](#type-Rig2DInfo) | struct | What og.load.rig2d registered, or og.anim.rig2dInfo reads back from a handle. |
75
+ | [`og.anim.rig2dInfo`](#fn-rig2dInfo) | function | What a loaded 2D rig holds: its bones, slots, IK constraints and clips, by the handle Skeleton2D.rig keeps (og.load.rig2d answers the same on load). |
76
+ | [`Skeleton2DBox`](#type-Skeleton2DBox) | struct | A bounding box a 2D skeleton's pose shows: a `box` attachment of its rig (or of a child armature in one of its slots) while its slot shows it. |
77
+ | [`og.anim.skeleton2dBoxes`](#fn-skeleton2dBoxes) | function | The bounding boxes an og.Skeleton2D's pose showed when og.skeleton2d last ran (after the game's systems, so a system reads the previous tick's): hurt and hit boxes a clip switches on and off with its slots' attachments, to test against points or other shapes. Empty for a rig without boxes or when no slot shows one. They are part of the og.skeleton2d state block, so a restored snapshot answers what it saved. |
67
78
 
68
79
  ## Functions
69
80
 
@@ -95,7 +106,7 @@ fn graph {
95
106
  }
96
107
  ```
97
108
 
98
- <sub>`api.ogt` line 5951</sub>
109
+ <sub>`api.ogt` line 8022</sub>
99
110
 
100
111
  <a id="fn-humanoid"></a>
101
112
 
@@ -125,7 +136,7 @@ fn humanoid {
125
136
  }
126
137
  ```
127
138
 
128
- <sub>`api.ogt` line 5979</sub>
139
+ <sub>`api.ogt` line 8050</sub>
129
140
 
130
141
  <a id="fn-retarget"></a>
131
142
 
@@ -155,7 +166,7 @@ fn retarget {
155
166
  }
156
167
  ```
157
168
 
158
- <sub>`api.ogt` line 5999</sub>
169
+ <sub>`api.ogt` line 8070</sub>
159
170
 
160
171
  <a id="fn-clip"></a>
161
172
 
@@ -186,7 +197,7 @@ fn clip {
186
197
  }
187
198
  ```
188
199
 
189
- <sub>`api.ogt` line 6084</sub>
200
+ <sub>`api.ogt` line 8155</sub>
190
201
 
191
202
  <a id="fn-clip-2"></a>
192
203
 
@@ -217,7 +228,98 @@ fn clip {
217
228
  }
218
229
  ```
219
230
 
220
- <sub>`api.ogt` line 6092</sub>
231
+ <sub>`api.ogt` line 8163</sub>
232
+
233
+ <a id="fn-clip-3"></a>
234
+
235
+ ### `og.anim.clip`
236
+
237
+ The index of a 2D rig's clip by name, for Skeleton2D.clip: `og.anim.clip(og.load.rig2d(world, "rigs/hero.ogt").value, "walk")`. -1 when the rig has no such clip.
238
+
239
+ ```ts
240
+ og.anim.clip(info: Rig2DInfo, name: string): number
241
+ ```
242
+
243
+ | Parameter | Type | Optional | Doc |
244
+ |---|---|---|---|
245
+ | `info` | `Rig2DInfo` | no | What og.load.rig2d or og.anim.rig2dInfo answered. |
246
+ | `name` | `string` | no | The clip's name. |
247
+
248
+ **Returns** `number`.
249
+
250
+ Implemented by the TypeScript runtime over the members of this module: no binding symbol.
251
+
252
+ ```ogt
253
+ fn clip {
254
+ doc "The index of a 2D rig's clip by name, for Skeleton2D.clip: `og.anim.clip(og.load.rig2d(world, \"rigs/hero.ogt\").value, \"walk\")`. -1 when the rig has no such clip."
255
+ host false
256
+ param info Rig2DInfo "What og.load.rig2d or og.anim.rig2dInfo answered."
257
+ param name String "The clip's name."
258
+ returns i32
259
+ }
260
+ ```
261
+
262
+ <sub>`api.ogt` line 8171</sub>
263
+
264
+ <a id="fn-rig2dInfo"></a>
265
+
266
+ ### `og.anim.rig2dInfo`
267
+
268
+ What a loaded 2D rig holds: its bones, slots, IK constraints and clips, by the handle Skeleton2D.rig keeps (og.load.rig2d answers the same on load).
269
+
270
+ ```ts
271
+ og.anim.rig2dInfo(world: World, rig: Rig2D): Result<Rig2DInfo>
272
+ ```
273
+
274
+ | Parameter | Type | Optional | Doc |
275
+ |---|---|---|---|
276
+ | `world` | `World` | no | The world whose animation owns the rig. |
277
+ | `rig` | `Rig2D` | no | The rig. |
278
+
279
+ **Returns** `Result<Rig2DInfo>`: Refused for a handle og.load.rig2d did not answer.
280
+
281
+ Binding symbol `og_anim_rig2d_info` · publish builds: kept
282
+
283
+ ```ogt
284
+ fn rig2dInfo {
285
+ doc "What a loaded 2D rig holds: its bones, slots, IK constraints and clips, by the handle Skeleton2D.rig keeps (og.load.rig2d answers the same on load)."
286
+ param world World "The world whose animation owns the rig."
287
+ param rig Rig2D "The rig."
288
+ returns Result.Rig2DInfo "Refused for a handle og.load.rig2d did not answer."
289
+ }
290
+ ```
291
+
292
+ <sub>`api.ogt` line 8281</sub>
293
+
294
+ <a id="fn-skeleton2dBoxes"></a>
295
+
296
+ ### `og.anim.skeleton2dBoxes`
297
+
298
+ The bounding boxes an og.Skeleton2D's pose showed when og.skeleton2d last ran (after the game's systems, so a system reads the previous tick's): hurt and hit boxes a clip switches on and off with its slots' attachments, to test against points or other shapes. Empty for a rig without boxes or when no slot shows one. They are part of the og.skeleton2d state block, so a restored snapshot answers what it saved.
299
+
300
+ ```ts
301
+ og.anim.skeleton2dBoxes(world: World, entity: Entity): Result<readonly Skeleton2DBox[]>
302
+ ```
303
+
304
+ | Parameter | Type | Optional | Doc |
305
+ |---|---|---|---|
306
+ | `world` | `World` | no | The world whose animation poses the skeleton. |
307
+ | `entity` | `Entity` | no | The entity with the og.Skeleton2D. |
308
+
309
+ **Returns** `Result<readonly Skeleton2DBox[]>`: Refused for an entity og.skeleton2d has not posed: no og.Skeleton2D with a loaded rig, or before its first tick.
310
+
311
+ Binding symbol `og_anim_skeleton2d_boxes` · publish builds: kept
312
+
313
+ ```ogt
314
+ fn skeleton2dBoxes {
315
+ doc "The bounding boxes an og.Skeleton2D's pose showed when og.skeleton2d last ran (after the game's systems, so a system reads the previous tick's): hurt and hit boxes a clip switches on and off with its slots' attachments, to test against points or other shapes. Empty for a rig without boxes or when no slot shows one. They are part of the og.skeleton2d state block, so a restored snapshot answers what it saved."
316
+ param world World "The world whose animation poses the skeleton."
317
+ param entity Entity "The entity with the og.Skeleton2D."
318
+ returns Result.List.Skeleton2DBox "Refused for an entity og.skeleton2d has not posed: no og.Skeleton2D with a loaded rig, or before its first tick."
319
+ }
320
+ ```
321
+
322
+ <sub>`api.ogt` line 8295</sub>
221
323
 
222
324
  ## Components, resources and events
223
325
 
@@ -254,7 +356,7 @@ component Skeleton {
254
356
  }
255
357
  ```
256
358
 
257
- <sub>`api.ogt` line 5720</sub>
359
+ <sub>`api.ogt` line 7791</sub>
258
360
 
259
361
  <a id="record-AnimationPlayer"></a>
260
362
 
@@ -316,7 +418,7 @@ component AnimationPlayer {
316
418
  }
317
419
  ```
318
420
 
319
- <sub>`api.ogt` line 5735</sub>
421
+ <sub>`api.ogt` line 7806</sub>
320
422
 
321
423
  <a id="record-AnimationGraph"></a>
322
424
 
@@ -392,7 +494,7 @@ component AnimationGraph {
392
494
  }
393
495
  ```
394
496
 
395
- <sub>`api.ogt` line 5774</sub>
497
+ <sub>`api.ogt` line 7845</sub>
396
498
 
397
499
  <a id="record-Blendshapes"></a>
398
500
 
@@ -465,7 +567,7 @@ component Blendshapes {
465
567
  }
466
568
  ```
467
569
 
468
- <sub>`api.ogt` line 5822</sub>
570
+ <sub>`api.ogt` line 7893</sub>
469
571
 
470
572
  <a id="record-IkChain"></a>
471
573
 
@@ -536,7 +638,7 @@ component IkChain {
536
638
  }
537
639
  ```
538
640
 
539
- <sub>`api.ogt` line 5870</sub>
641
+ <sub>`api.ogt` line 7941</sub>
540
642
 
541
643
  <a id="record-AnimationEvent"></a>
542
644
 
@@ -567,7 +669,7 @@ event AnimationEvent {
567
669
  }
568
670
  ```
569
671
 
570
- <sub>`api.ogt` line 5914</sub>
672
+ <sub>`api.ogt` line 7985</sub>
571
673
 
572
674
  <a id="record-Flipbook"></a>
573
675
 
@@ -623,7 +725,7 @@ component Flipbook {
623
725
  }
624
726
  ```
625
727
 
626
- <sub>`api.ogt` line 6022</sub>
728
+ <sub>`api.ogt` line 8093</sub>
627
729
 
628
730
  <a id="record-FlipbookEvent"></a>
629
731
 
@@ -650,7 +752,145 @@ event FlipbookEvent {
650
752
  }
651
753
  ```
652
754
 
653
- <sub>`api.ogt` line 6053</sub>
755
+ <sub>`api.ogt` line 8124</sub>
756
+
757
+ <a id="record-Skeleton2D"></a>
758
+
759
+ ### `og.Skeleton2D` (component)
760
+
761
+ Plays a clip of a 2D rig at the entity: the og.skeleton2d system advances it by scaled time (Time.scaledDt) after the game's systems and fires its events as og.Skeleton2DEvent; extraction draws its slots, in their order, as textured triangles of the sprite batch at `layer` (region attachments as quads, mesh attachments weighted to bones and deformed by the clip), lit by og.Lighting2D when the layer is in its range, as a sprite there is. The rig's pixels are `unit` to a world unit and +y is up; the entity's og.Transform places, turns (about z) and scales it.
762
+
763
+ Changing `clip` restarts at 0 (or at `time`, written in the same tick); writing a different time is a seek and fires no events. The pose is a function of these fields, the Transform and the og.IkTarget2D on it; the playback position is world state (the og.skeleton2d state block).
764
+
765
+ Token `og.Skeleton2D`, registered under the schema name `og.Skeleton2D`; its value type is `Skeleton2D`.
766
+
767
+ | Field | Type | Default | Range | Unit | Notes | Doc |
768
+ |---|---|---|---|---|---|---|
769
+ | `rig` | `Rig2D` | `0` | — | — | — | The rig (og.load.rig2d's `rig`); 0 is none. |
770
+ | `clip` | `number` | `0` | ≥ 0 | — | — | The clip: an index into Rig2DInfo.clips (og.anim.clip finds one by name). |
771
+ | `time` | `number` | `0` | ≥ 0 | `s` | — | Seconds into the clip; written every tick, set it to seek. |
772
+ | `speed` | `number` | `1` | -10 … 10 | — | tunable | The playback rate: 1 as authored, 2 twice as fast, negative backwards. |
773
+ | `loop` | `boolean` | `true` | — | — | — | Wrap at the clip's end; otherwise hold the last pose and set `finished`. Rig2DInfo.clips says what the rig's author meant. |
774
+ | `flipX` | `boolean` | `false` | — | — | — | Mirror the rig left to right about the entity's position (a character facing left). |
775
+ | `layer` | `number` | `0` | — | — | — | The sprite layer it draws in, sorted with the sprites there (after them when they share the layer). |
776
+ | `skin` | `number` | `0` | ≥ 0 | — | — | The skin it wears: an index into Rig2DInfo.skins (0 is the rig's default; `rig.skins.indexOf("armor")` finds one by name). A skin shows its own attachment wherever the setup pose or a clip shows the default's; a slot the skin leaves alone shows the default's. Change it any tick: the pose is drawn from it. |
777
+ | `finished` | `boolean` | `false` | — | — | read only | Written: a clip that does not loop reached its end (or its start, played backwards). |
778
+
779
+ ```ogt
780
+ component Skeleton2D {
781
+ doc "Plays a clip of a 2D rig at the entity: the og.skeleton2d system advances it by scaled time (Time.scaledDt) after the game's systems and fires its events as og.Skeleton2DEvent; extraction draws its slots, in their order, as textured triangles of the sprite batch at `layer` (region attachments as quads, mesh attachments weighted to bones and deformed by the clip), lit by og.Lighting2D when the layer is in its range, as a sprite there is. The rig's pixels are `unit` to a world unit and +y is up; the entity's og.Transform places, turns (about z) and scales it."
782
+ doc "Changing `clip` restarts at 0 (or at `time`, written in the same tick); writing a different time is a seek and fires no events. The pose is a function of these fields, the Transform and the og.IkTarget2D on it; the playback position is world state (the og.skeleton2d state block)."
783
+ field rig Rig2D "The rig (og.load.rig2d's `rig`); 0 is none."
784
+ field clip u32 "The clip: an index into Rig2DInfo.clips (og.anim.clip finds one by name)." {
785
+ min 0
786
+ }
787
+ field time f32 "Seconds into the clip; written every tick, set it to seek." {
788
+ min 0
789
+ unit s
790
+ }
791
+ field speed f32 "The playback rate: 1 as authored, 2 twice as fast, negative backwards." {
792
+ default 1
793
+ min -10
794
+ max 10
795
+ tunable true
796
+ }
797
+ field loop bool "Wrap at the clip's end; otherwise hold the last pose and set `finished`. Rig2DInfo.clips says what the rig's author meant." {
798
+ default true
799
+ }
800
+ field flipX bool "Mirror the rig left to right about the entity's position (a character facing left)."
801
+ field layer i32 "The sprite layer it draws in, sorted with the sprites there (after them when they share the layer)."
802
+ field skin u32 "The skin it wears: an index into Rig2DInfo.skins (0 is the rig's default; `rig.skins.indexOf(\"armor\")` finds one by name). A skin shows its own attachment wherever the setup pose or a clip shows the default's; a slot the skin leaves alone shows the default's. Change it any tick: the pose is drawn from it." {
803
+ min 0
804
+ }
805
+ field finished bool "Written: a clip that does not loop reached its end (or its start, played backwards)." {
806
+ readonly true
807
+ }
808
+ }
809
+ ```
810
+
811
+ <sub>`api.ogt` line 8188</sub>
812
+
813
+ <a id="record-Skeleton2DEvent"></a>
814
+
815
+ ### `og.Skeleton2DEvent` (event)
816
+
817
+ A 2D skeleton's clip, or the clip a child armature in one of its slots plays, passed one of its events (`event 0.2 "step"` in the rig) in the last tick: footsteps, the frame a swing lands. Read in the tick after, like every event; a clip started at 0 fires its events at 0, a looping clip fires each once per pass.
818
+
819
+ Token `og.Skeleton2DEvent`, registered under the schema name `og.Skeleton2DEvent`; its value type is `Skeleton2DEvent`.
820
+
821
+ | Field | Type | Default | Range | Unit | Notes | Doc |
822
+ |---|---|---|---|---|---|---|
823
+ | `entity` | `Entity` | `0` | — | — | — | The entity with the og.Skeleton2D. |
824
+ | `clip` | `number` | `0` | — | — | — | The clip index. |
825
+ | `name` | `string` | `""` | — | — | — | The event's name (at most 63 bytes). |
826
+ | `time` | `number` | `0` | — | `s` | — | The event's time in the clip. |
827
+ | `armature` | `string` | `""` | — | — | — | Empty for the skeleton's own clip; for an event of a child armature shown in one of its slots, that armature's name (`clip` and `time` are then the child's clip and its time): a flame's crackle apart from the keeper's footsteps (at most 63 bytes). |
828
+
829
+ ```ogt
830
+ event Skeleton2DEvent {
831
+ doc "A 2D skeleton's clip, or the clip a child armature in one of its slots plays, passed one of its events (`event 0.2 \"step\"` in the rig) in the last tick: footsteps, the frame a swing lands. Read in the tick after, like every event; a clip started at 0 fires its events at 0, a looping clip fires each once per pass."
832
+ field entity Entity "The entity with the og.Skeleton2D."
833
+ field clip u32 "The clip index."
834
+ field name String "The event's name (at most 63 bytes)."
835
+ field time f32 "The event's time in the clip." {
836
+ unit s
837
+ }
838
+ field armature String "Empty for the skeleton's own clip; for an event of a child armature shown in one of its slots, that armature's name (`clip` and `time` are then the child's clip and its time): a flame's crackle apart from the keeper's footsteps (at most 63 bytes)."
839
+ }
840
+ ```
841
+
842
+ <sub>`api.ogt` line 8218</sub>
843
+
844
+ <a id="record-IkTarget2D"></a>
845
+
846
+ ### `og.IkTarget2D` (component)
847
+
848
+ Moves one IK constraint of a 2D skeleton (Rig2DInfo.constraints) to a point: a foot planted on the ground under it, a hand on a ledge, a tail's tip. A constraint is a chain of any length: one bone points at the target, two are solved exactly (bending the way the rig says), three or more by FABRIK from the animated pose, curling the way the rig says. Put it on its own entity, one per constraint; og.skeleton2d writes `reached` and `error`, and the drawn pose solves the same way.
849
+
850
+ Token `og.IkTarget2D`, registered under the schema name `og.IkTarget2D`; its value type is `IkTarget2D`.
851
+
852
+ | Field | Type | Default | Range | Unit | Notes | Doc |
853
+ |---|---|---|---|---|---|---|
854
+ | `skeleton` | `Entity` | `0` | — | — | — | The entity with the og.Skeleton2D. |
855
+ | `constraint` | `number` | `0` | ≥ 0 | — | — | The constraint: an index into Rig2DInfo.constraints. |
856
+ | `target` | `Vector2` | `{ x: 0, y: 0 }` | — | `m` | — | Where the chain's tip should be, in the frame the skeleton entity's og.Transform is written in (the world for an entity without a parent). |
857
+ | `weight` | `number` | `1` | 0 … 1 | — | tunable | How much of the solve applies (0 is the animated pose, 1 fully solved), times the constraint's own weight (its `weight` line, or its clip's IK keys). |
858
+ | `tolerance` | `number` | `0.01` | ≥ 0 | `m` | — | The distance at which the target counts as reached. |
859
+ | `reached` | `boolean` | `false` | — | — | read only | Written: the tip is within `tolerance` of the target after solving. |
860
+ | `error` | `number` | `0` | — | `m` | read only | Written: the tip's distance from the target after solving (for a one-bone constraint, how far the target lies off the bone's line). |
861
+
862
+ ```ogt
863
+ component IkTarget2D {
864
+ doc "Moves one IK constraint of a 2D skeleton (Rig2DInfo.constraints) to a point: a foot planted on the ground under it, a hand on a ledge, a tail's tip. A constraint is a chain of any length: one bone points at the target, two are solved exactly (bending the way the rig says), three or more by FABRIK from the animated pose, curling the way the rig says. Put it on its own entity, one per constraint; og.skeleton2d writes `reached` and `error`, and the drawn pose solves the same way."
865
+ field skeleton Entity "The entity with the og.Skeleton2D."
866
+ field constraint u32 "The constraint: an index into Rig2DInfo.constraints." {
867
+ min 0
868
+ }
869
+ field target Vector2 "Where the chain's tip should be, in the frame the skeleton entity's og.Transform is written in (the world for an entity without a parent)." {
870
+ unit m
871
+ }
872
+ field weight f32 "How much of the solve applies (0 is the animated pose, 1 fully solved), times the constraint's own weight (its `weight` line, or its clip's IK keys)." {
873
+ default 1
874
+ min 0
875
+ max 1
876
+ tunable true
877
+ }
878
+ field tolerance f32 "The distance at which the target counts as reached." {
879
+ default 0.01
880
+ min 0
881
+ unit m
882
+ }
883
+ field reached bool "Written: the tip is within `tolerance` of the target after solving." {
884
+ readonly true
885
+ }
886
+ field error f32 "Written: the tip's distance from the target after solving (for a one-bone constraint, how far the target lies off the bone's line)." {
887
+ unit m
888
+ readonly true
889
+ }
890
+ }
891
+ ```
892
+
893
+ <sub>`api.ogt` line 8229</sub>
654
894
 
655
895
  ## Types
656
896
 
@@ -666,7 +906,7 @@ A generational handle: a number the engine hands out. A dead handle is an error
666
906
  handle SkeletonAsset "A rig: a glTF's nodes in topological order with their rest transforms, and its skins (joints and inverse bind matrices)."
667
907
  ```
668
908
 
669
- <sub>`api.ogt` line 5642</sub>
909
+ <sub>`api.ogt` line 7713</sub>
670
910
 
671
911
  <a id="type-ClipAsset"></a>
672
912
 
@@ -680,7 +920,7 @@ A generational handle: a number the engine hands out. A dead handle is an error
680
920
  handle ClipAsset "An animation clip, resampled at the cook's rate, with its markers."
681
921
  ```
682
922
 
683
- <sub>`api.ogt` line 5643</sub>
923
+ <sub>`api.ogt` line 7714</sub>
684
924
 
685
925
  <a id="type-GraphAsset"></a>
686
926
 
@@ -694,7 +934,7 @@ A generational handle: a number the engine hands out. A dead handle is an error
694
934
  handle GraphAsset "A blend-tree graph (`type animgraph`) whose clip references were resolved to clip handles."
695
935
  ```
696
936
 
697
- <sub>`api.ogt` line 5644</sub>
937
+ <sub>`api.ogt` line 7715</sub>
698
938
 
699
939
  <a id="type-RootMotion"></a>
700
940
 
@@ -719,7 +959,7 @@ enum RootMotion {
719
959
  }
720
960
  ```
721
961
 
722
- <sub>`api.ogt` line 5667</sub>
962
+ <sub>`api.ogt` line 7738</sub>
723
963
 
724
964
  <a id="type-BlendshapeSource"></a>
725
965
 
@@ -742,7 +982,7 @@ enum BlendshapeSource {
742
982
  }
743
983
  ```
744
984
 
745
- <sub>`api.ogt` line 5681</sub>
985
+ <sub>`api.ogt` line 7752</sub>
746
986
 
747
987
  <a id="type-IkSolver"></a>
748
988
 
@@ -765,7 +1005,7 @@ enum IkSolver {
765
1005
  }
766
1006
  ```
767
1007
 
768
- <sub>`api.ogt` line 5694</sub>
1008
+ <sub>`api.ogt` line 7765</sub>
769
1009
 
770
1010
  <a id="type-IkSpace"></a>
771
1011
 
@@ -788,7 +1028,7 @@ enum IkSpace {
788
1028
  }
789
1029
  ```
790
1030
 
791
- <sub>`api.ogt` line 5707</sub>
1031
+ <sub>`api.ogt` line 7778</sub>
792
1032
 
793
1033
  <a id="type-ClipInfo"></a>
794
1034
 
@@ -815,7 +1055,7 @@ struct ClipInfo {
815
1055
  }
816
1056
  ```
817
1057
 
818
- <sub>`api.ogt` line 5925</sub>
1058
+ <sub>`api.ogt` line 7996</sub>
819
1059
 
820
1060
  <a id="type-Animation"></a>
821
1061
 
@@ -842,7 +1082,7 @@ struct Animation {
842
1082
  }
843
1083
  ```
844
1084
 
845
- <sub>`api.ogt` line 5935</sub>
1085
+ <sub>`api.ogt` line 8006</sub>
846
1086
 
847
1087
  <a id="type-GraphDesc"></a>
848
1088
 
@@ -866,7 +1106,7 @@ struct GraphDesc {
866
1106
  }
867
1107
  ```
868
1108
 
869
- <sub>`api.ogt` line 5944</sub>
1109
+ <sub>`api.ogt` line 8015</sub>
870
1110
 
871
1111
  <a id="type-Rig"></a>
872
1112
 
@@ -880,7 +1120,7 @@ A generational handle: a number the engine hands out. A dead handle is an error
880
1120
  handle Rig "A humanoid map from og.load.rig (a cooked `.ogt` of `type rig`): the naming scheme a skeleton's node names follow and the standard bones it names outright."
881
1121
  ```
882
1122
 
883
- <sub>`api.ogt` line 5958</sub>
1123
+ <sub>`api.ogt` line 8029</sub>
884
1124
 
885
1125
  <a id="type-HumanBone"></a>
886
1126
 
@@ -901,7 +1141,7 @@ struct HumanBone {
901
1141
  }
902
1142
  ```
903
1143
 
904
- <sub>`api.ogt` line 5960</sub>
1144
+ <sub>`api.ogt` line 8031</sub>
905
1145
 
906
1146
  <a id="type-Humanoid"></a>
907
1147
 
@@ -922,7 +1162,7 @@ struct Humanoid {
922
1162
  }
923
1163
  ```
924
1164
 
925
- <sub>`api.ogt` line 5966</sub>
1165
+ <sub>`api.ogt` line 8037</sub>
926
1166
 
927
1167
  <a id="type-HumanoidDesc"></a>
928
1168
 
@@ -946,7 +1186,7 @@ struct HumanoidDesc {
946
1186
  }
947
1187
  ```
948
1188
 
949
- <sub>`api.ogt` line 5972</sub>
1189
+ <sub>`api.ogt` line 8043</sub>
950
1190
 
951
1191
  <a id="type-RetargetDesc"></a>
952
1192
 
@@ -980,7 +1220,7 @@ struct RetargetDesc {
980
1220
  }
981
1221
  ```
982
1222
 
983
- <sub>`api.ogt` line 5986</sub>
1223
+ <sub>`api.ogt` line 8057</sub>
984
1224
 
985
1225
  <a id="type-FlipbookSheet"></a>
986
1226
 
@@ -994,7 +1234,7 @@ A generational handle: a number the engine hands out. A dead handle is an error
994
1234
  handle FlipbookSheet "A sprite sheet's frames and clips (a cooked `.ogt` of `type flipbook`), from og.load.flipbook."
995
1235
  ```
996
1236
 
997
- <sub>`api.ogt` line 6006</sub>
1237
+ <sub>`api.ogt` line 8077</sub>
998
1238
 
999
1239
  <a id="type-FlipMode"></a>
1000
1240
 
@@ -1019,7 +1259,7 @@ enum FlipMode {
1019
1259
  }
1020
1260
  ```
1021
1261
 
1022
- <sub>`api.ogt` line 6015</sub>
1262
+ <sub>`api.ogt` line 8086</sub>
1023
1263
 
1024
1264
  <a id="type-FlipbookClipInfo"></a>
1025
1265
 
@@ -1050,7 +1290,7 @@ struct FlipbookClipInfo {
1050
1290
  }
1051
1291
  ```
1052
1292
 
1053
- <sub>`api.ogt` line 6061</sub>
1293
+ <sub>`api.ogt` line 8132</sub>
1054
1294
 
1055
1295
  <a id="type-FlipbookInfo"></a>
1056
1296
 
@@ -1081,7 +1321,106 @@ struct FlipbookInfo {
1081
1321
  }
1082
1322
  ```
1083
1323
 
1084
- <sub>`api.ogt` line 6073</sub>
1324
+ <sub>`api.ogt` line 8144</sub>
1325
+
1326
+ <a id="type-Rig2D"></a>
1327
+
1328
+ ### `Rig2D` (handle)
1329
+
1330
+ A 2D rig (a cooked `.ogt` of `type rig2d`): bones, slots, region, mesh, bounding-box and child-armature attachments, IK constraints, child armatures and clips, from og.load.rig2d.
1331
+
1332
+ A generational handle: a number the engine hands out. A dead handle is an error value, never a crash.
1333
+
1334
+ ```ogt
1335
+ handle Rig2D "A 2D rig (a cooked `.ogt` of `type rig2d`): bones, slots, region, mesh, bounding-box and child-armature attachments, IK constraints, child armatures and clips, from og.load.rig2d."
1336
+ ```
1337
+
1338
+ <sub>`api.ogt` line 8179</sub>
1339
+
1340
+ <a id="type-Rig2DClipInfo"></a>
1341
+
1342
+ ### `Rig2DClipInfo` (struct)
1343
+
1344
+ One clip of a loaded 2D rig.
1345
+
1346
+ | Field | Type | Default | Range | Unit | Notes | Doc |
1347
+ |---|---|---|---|---|---|---|
1348
+ | `clip` | `number` | `0` | — | — | — | Its index, what Skeleton2D.clip takes. |
1349
+ | `name` | `string` | `""` | — | — | — | Its name in the rig. |
1350
+ | `duration` | `number` | `0` | — | `s` | — | Its length. |
1351
+ | `loop` | `boolean` | `false` | — | — | — | Whether the rig's author meant it to loop (its `loop` line): copy it into Skeleton2D.loop. |
1352
+ | `events` | `readonly string[]` | `[]` | — | — | — | Its events' names, in time order. |
1353
+
1354
+ ```ogt
1355
+ struct Rig2DClipInfo {
1356
+ doc "One clip of a loaded 2D rig."
1357
+ field clip u32 "Its index, what Skeleton2D.clip takes."
1358
+ field name String "Its name in the rig."
1359
+ field duration f32 "Its length." {
1360
+ unit s
1361
+ }
1362
+ field loop bool "Whether the rig's author meant it to loop (its `loop` line): copy it into Skeleton2D.loop."
1363
+ field events List.String "Its events' names, in time order."
1364
+ }
1365
+ ```
1366
+
1367
+ <sub>`api.ogt` line 8258</sub>
1368
+
1369
+ <a id="type-Rig2DInfo"></a>
1370
+
1371
+ ### `Rig2DInfo` (struct)
1372
+
1373
+ What og.load.rig2d registered, or og.anim.rig2dInfo reads back from a handle.
1374
+
1375
+ | Field | Type | Default | Range | Unit | Notes | Doc |
1376
+ |---|---|---|---|---|---|---|
1377
+ | `rig` | `Rig2D` | `0` | — | — | — | What Skeleton2D.rig takes. |
1378
+ | `texture` | `Texture` | `0` | — | — | — | The rig's texture (loaded with it). |
1379
+ | `unit` | `number` | `0` | — | — | — | Pixels of the rig per world unit. |
1380
+ | `bones` | `readonly string[]` | `[]` | — | — | — | The bones' names, parents first. |
1381
+ | `slots` | `readonly string[]` | `[]` | — | — | — | The slots' names, in draw order. |
1382
+ | `constraints` | `readonly string[]` | `[]` | — | — | — | The IK constraints' names: an index here is IkTarget2D.constraint. |
1383
+ | `skins` | `readonly string[]` | `[]` | — | — | — | Its skins' names, `default` (the rig's own attachments) first: an index here is Skeleton2D.skin. |
1384
+ | `clips` | `readonly Rig2DClipInfo[]` | `[]` | — | — | — | Its clips, in file order. |
1385
+
1386
+ ```ogt
1387
+ struct Rig2DInfo {
1388
+ doc "What og.load.rig2d registered, or og.anim.rig2dInfo reads back from a handle."
1389
+ field rig Rig2D "What Skeleton2D.rig takes."
1390
+ field texture Texture "The rig's texture (loaded with it)."
1391
+ field unit f32 "Pixels of the rig per world unit."
1392
+ field bones List.String "The bones' names, parents first."
1393
+ field slots List.String "The slots' names, in draw order."
1394
+ field constraints List.String "The IK constraints' names: an index here is IkTarget2D.constraint."
1395
+ field skins List.String "Its skins' names, `default` (the rig's own attachments) first: an index here is Skeleton2D.skin."
1396
+ field clips List.Rig2DClipInfo "Its clips, in file order."
1397
+ }
1398
+ ```
1399
+
1400
+ <sub>`api.ogt` line 8269</sub>
1401
+
1402
+ <a id="type-Skeleton2DBox"></a>
1403
+
1404
+ ### `Skeleton2DBox` (struct)
1405
+
1406
+ A bounding box a 2D skeleton's pose shows: a `box` attachment of its rig (or of a child armature in one of its slots) while its slot shows it.
1407
+
1408
+ | Field | Type | Default | Range | Unit | Notes | Doc |
1409
+ |---|---|---|---|---|---|---|
1410
+ | `slot` | `string` | `""` | — | — | — | The slot showing it (`slot/child-slot` inside a child armature). |
1411
+ | `name` | `string` | `""` | — | — | — | The box's name in the rig. |
1412
+ | `points` | `readonly Vector2[]` | `[]` | — | — | — | Its polygon, moved by its bones (IK included), in the frame the skeleton entity's og.Transform is written in (the world for an entity without a parent). |
1413
+
1414
+ ```ogt
1415
+ struct Skeleton2DBox {
1416
+ doc "A bounding box a 2D skeleton's pose shows: a `box` attachment of its rig (or of a child armature in one of its slots) while its slot shows it."
1417
+ field slot String "The slot showing it (`slot/child-slot` inside a child armature)."
1418
+ field name String "The box's name in the rig."
1419
+ field points List.Vector2 "Its polygon, moved by its bones (IK included), in the frame the skeleton entity's og.Transform is written in (the world for an entity without a parent)."
1420
+ }
1421
+ ```
1422
+
1423
+ <sub>`api.ogt` line 8288</sub>
1085
1424
 
1086
1425
  ## Column kinds
1087
1426
 
@@ -1097,6 +1436,7 @@ Each is a factory, `SkeletonAsset(value?, options?)`, that makes one field of a
1097
1436
  | <a id="column-IkSolver"></a>`IkSolver` | `IkSolver` | `Uint32Array` | 1 | An IkSolver field: the variant's index. |
1098
1437
  | <a id="column-IkSpace"></a>`IkSpace` | `IkSpace` | `Uint32Array` | 1 | An IkSpace field: the variant's index. |
1099
1438
  | <a id="column-FlipbookSheet"></a>`FlipbookSheet` | `FlipbookSheet` | `Uint32Array` | 2 | A FlipbookSheet handle field. |
1439
+ | <a id="column-Rig2D"></a>`Rig2D` | `Rig2D` | `Uint32Array` | 2 | A Rig2D handle field. |
1100
1440
 
1101
1441
  ```ogt
1102
1442
  column SkeletonAsset {
@@ -1107,7 +1447,7 @@ column SkeletonAsset {
1107
1447
  }
1108
1448
  ```
1109
1449
 
1110
- <sub>`api.ogt` line 5646</sub>
1450
+ <sub>`api.ogt` line 7717</sub>
1111
1451
 
1112
1452
  ```ogt
1113
1453
  column ClipAsset {
@@ -1118,7 +1458,7 @@ column ClipAsset {
1118
1458
  }
1119
1459
  ```
1120
1460
 
1121
- <sub>`api.ogt` line 5653</sub>
1461
+ <sub>`api.ogt` line 7724</sub>
1122
1462
 
1123
1463
  ```ogt
1124
1464
  column GraphAsset {
@@ -1129,7 +1469,7 @@ column GraphAsset {
1129
1469
  }
1130
1470
  ```
1131
1471
 
1132
- <sub>`api.ogt` line 5660</sub>
1472
+ <sub>`api.ogt` line 7731</sub>
1133
1473
 
1134
1474
  ```ogt
1135
1475
  column RootMotion {
@@ -1140,7 +1480,7 @@ column RootMotion {
1140
1480
  }
1141
1481
  ```
1142
1482
 
1143
- <sub>`api.ogt` line 5674</sub>
1483
+ <sub>`api.ogt` line 7745</sub>
1144
1484
 
1145
1485
  ```ogt
1146
1486
  column BlendshapeSource {
@@ -1151,7 +1491,7 @@ column BlendshapeSource {
1151
1491
  }
1152
1492
  ```
1153
1493
 
1154
- <sub>`api.ogt` line 5687</sub>
1494
+ <sub>`api.ogt` line 7758</sub>
1155
1495
 
1156
1496
  ```ogt
1157
1497
  column IkSolver {
@@ -1162,7 +1502,7 @@ column IkSolver {
1162
1502
  }
1163
1503
  ```
1164
1504
 
1165
- <sub>`api.ogt` line 5700</sub>
1505
+ <sub>`api.ogt` line 7771</sub>
1166
1506
 
1167
1507
  ```ogt
1168
1508
  column IkSpace {
@@ -1173,7 +1513,7 @@ column IkSpace {
1173
1513
  }
1174
1514
  ```
1175
1515
 
1176
- <sub>`api.ogt` line 5713</sub>
1516
+ <sub>`api.ogt` line 7784</sub>
1177
1517
 
1178
1518
  ```ogt
1179
1519
  column FlipbookSheet {
@@ -1184,4 +1524,15 @@ column FlipbookSheet {
1184
1524
  }
1185
1525
  ```
1186
1526
 
1187
- <sub>`api.ogt` line 6008</sub>
1527
+ <sub>`api.ogt` line 8079</sub>
1528
+
1529
+ ```ogt
1530
+ column Rig2D {
1531
+ doc "A Rig2D handle field."
1532
+ array Uint32Array
1533
+ stride 2
1534
+ value Rig2D
1535
+ }
1536
+ ```
1537
+
1538
+ <sub>`api.ogt` line 8181</sub>