@origingame/engine 0.1.1 → 0.3.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 (109) hide show
  1. package/bin/og.mjs +1 -1
  2. package/dist/web/origin-engine.d.ts +219 -5
  3. package/dist/web/origin-engine.js +1344 -125
  4. package/dist/web/origin-engine_bg.wasm +0 -0
  5. package/dist/web/origin-engine_bg.wasm.d.ts +68 -3
  6. package/dist/web-publish/origin-engine-lanes.js +1007 -22
  7. package/dist/web-publish/origin-engine-lanes_bg.wasm +0 -0
  8. package/dist/web-publish/origin-engine.d.ts +162 -5
  9. package/dist/web-publish/origin-engine.js +1004 -19
  10. package/dist/web-publish/origin-engine_bg.wasm +0 -0
  11. package/dist/web-publish/origin-engine_bg.wasm.d.ts +52 -3
  12. package/dist/web-publish-2d/origin-engine-lanes.js +1007 -22
  13. package/dist/web-publish-2d/origin-engine-lanes_bg.wasm +0 -0
  14. package/dist/web-publish-2d/origin-engine.d.ts +162 -5
  15. package/dist/web-publish-2d/origin-engine.js +1004 -19
  16. package/dist/web-publish-2d/origin-engine_bg.wasm +0 -0
  17. package/dist/web-publish-2d/origin-engine_bg.wasm.d.ts +52 -3
  18. package/knowledge/looks/catalogue.json +40 -40
  19. package/knowledge/package.json +4 -4
  20. package/knowledge/scaffold/distribution.json +14 -0
  21. package/knowledge/scaffold/origin-engine.json +2 -2
  22. package/knowledge/scaffold/template/README.md +2 -1
  23. package/knowledge/scaffold/template/assets/audio/sting.ogt +10 -0
  24. package/knowledge/scaffold/template/assets/timelines/intro.ogt +101 -0
  25. package/knowledge/scaffold/template/assets/timelines/narration.srt +11 -0
  26. package/knowledge/scaffold/template/host.d.ts +46 -0
  27. package/knowledge/scaffold/template/package.json +1 -1
  28. package/knowledge/scaffold/template/project.ogt +1 -1
  29. package/knowledge/scaffold/template/src/main.ts +1 -1
  30. package/knowledge/scaffold/template/tests/frames.ts +134 -0
  31. package/knowledge/scaffold/template/tests/intro.og.ts +65 -0
  32. package/knowledge/scaffold/template/tests/smoke.og.ts +30 -36
  33. package/knowledge/scaffold/template/tsconfig.json +1 -1
  34. package/knowledge/scripts/mount.ts +2 -1
  35. package/knowledge/scripts/validate.ts +21 -11
  36. package/knowledge/skills/og-build/SKILL.md +25 -6
  37. package/knowledge/skills/og-core/SKILL.md +11 -0
  38. package/knowledge/skills/og-feel/SKILL.md +8 -1
  39. package/knowledge/skills/og-game/SKILL.md +994 -21
  40. package/knowledge/skills/og-i18n/SKILL.md +12 -3
  41. package/knowledge/skills/og-platform-sdk/SKILL.md +4 -1
  42. package/knowledge/skills/og-taste/SKILL.md +82 -73
  43. package/knowledge/skills/og-ui/SKILL.md +82 -54
  44. package/knowledge/wiki/ai.md +20 -20
  45. package/knowledge/wiki/anim.md +384 -41
  46. package/knowledge/wiki/atmosphere.md +36 -13
  47. package/knowledge/wiki/audio.md +18 -18
  48. package/knowledge/wiki/camera.md +19 -13
  49. package/knowledge/wiki/commands.md +19 -13
  50. package/knowledge/wiki/debug.md +414 -0
  51. package/knowledge/wiki/game.md +8 -8
  52. package/knowledge/wiki/i18n.md +7 -7
  53. package/knowledge/wiki/index.md +265 -7
  54. package/knowledge/wiki/input.md +47 -47
  55. package/knowledge/wiki/load.md +236 -68
  56. package/knowledge/wiki/math.md +2614 -7
  57. package/knowledge/wiki/nav.md +34 -34
  58. package/knowledge/wiki/net.md +340 -0
  59. package/knowledge/wiki/path.md +402 -0
  60. package/knowledge/wiki/physics.md +124 -106
  61. package/knowledge/wiki/platform.md +465 -31
  62. package/knowledge/wiki/probe.md +681 -67
  63. package/knowledge/wiki/reflect.md +15 -15
  64. package/knowledge/wiki/render.md +3904 -1897
  65. package/knowledge/wiki/rng.md +14 -14
  66. package/knowledge/wiki/stream.md +15 -15
  67. package/knowledge/wiki/system.md +8 -8
  68. package/knowledge/wiki/systems.md +2 -2
  69. package/knowledge/wiki/terrain.md +19 -19
  70. package/knowledge/wiki/tilemap.md +19 -15
  71. package/knowledge/wiki/time.md +4 -4
  72. package/knowledge/wiki/timeline.md +396 -0
  73. package/knowledge/wiki/transform.md +8 -8
  74. package/knowledge/wiki/tween.md +17 -17
  75. package/knowledge/wiki/ui.md +603 -629
  76. package/knowledge/wiki/video.md +157 -0
  77. package/knowledge/wiki/world.md +67 -37
  78. package/package.json +7 -6
  79. package/schema/api.schema.json +21071 -13964
  80. package/shell/page.ts +26 -2
  81. package/shell/platform.ts +46 -0
  82. package/shell/player.ts +7 -0
  83. package/src/depth.ts +71 -0
  84. package/src/e6.ts +32 -1
  85. package/src/env.d.ts +5 -1
  86. package/src/generated/abi.ts +189 -3
  87. package/src/index.ts +26 -4
  88. package/src/light.ts +18 -0
  89. package/src/math.ts +622 -0
  90. package/src/node/index.ts +17 -0
  91. package/src/node/playtest-run.ts +114 -18
  92. package/src/node/polish.ts +15 -4
  93. package/src/node/render.ts +291 -0
  94. package/src/node/run.ts +91 -6
  95. package/src/p2.ts +19 -1
  96. package/src/playtest.ts +57 -4
  97. package/src/runtime.ts +15 -3
  98. package/src/targets.ts +28 -0
  99. package/src/trace.ts +169 -0
  100. package/src/ui-kit/huds.ts +49 -45
  101. package/src/ui-kit/menus.ts +12 -12
  102. package/src/ui-kit/settings.ts +2 -2
  103. package/src/ui-kit/store.ts +18 -18
  104. package/src/ui-kit/story.ts +6 -4
  105. package/src/ui-kit/util.ts +8 -8
  106. package/src/web/shell.ts +58 -0
  107. package/src/web/worker.ts +103 -2
  108. package/types/bindings.json +8945 -6456
  109. package/types/index.d.ts +15507 -11437
@@ -18,7 +18,7 @@ module anim {
18
18
  # declarations follow, each quoted below
19
19
  ```
20
20
 
21
- <sub>`api.ogt` line 5606</sub>
21
+ <sub>`api.ogt` line 7139</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 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 5921</sub>
109
+ <sub>`api.ogt` line 7454</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 5949</sub>
139
+ <sub>`api.ogt` line 7482</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 5969</sub>
169
+ <sub>`api.ogt` line 7502</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 6054</sub>
200
+ <sub>`api.ogt` line 7587</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 6062</sub>
231
+ <sub>`api.ogt` line 7595</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 7603</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 7708</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 7722</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 5690</sub>
359
+ <sub>`api.ogt` line 7223</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 5705</sub>
421
+ <sub>`api.ogt` line 7238</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 5744</sub>
497
+ <sub>`api.ogt` line 7277</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 5792</sub>
570
+ <sub>`api.ogt` line 7325</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 5840</sub>
641
+ <sub>`api.ogt` line 7373</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 5884</sub>
672
+ <sub>`api.ogt` line 7417</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 5992</sub>
728
+ <sub>`api.ogt` line 7525</sub>
627
729
 
628
730
  <a id="record-FlipbookEvent"></a>
629
731
 
@@ -650,7 +752,139 @@ event FlipbookEvent {
650
752
  }
651
753
  ```
652
754
 
653
- <sub>`api.ogt` line 6023</sub>
755
+ <sub>`api.ogt` line 7556</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
+ | `finished` | `boolean` | `false` | — | — | read only | Written: a clip that does not loop reached its end (or its start, played backwards). |
777
+
778
+ ```ogt
779
+ component Skeleton2D {
780
+ 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."
781
+ 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)."
782
+ field rig Rig2D "The rig (og.load.rig2d's `rig`); 0 is none."
783
+ field clip u32 "The clip: an index into Rig2DInfo.clips (og.anim.clip finds one by name)." {
784
+ min 0
785
+ }
786
+ field time f32 "Seconds into the clip; written every tick, set it to seek." {
787
+ min 0
788
+ unit s
789
+ }
790
+ field speed f32 "The playback rate: 1 as authored, 2 twice as fast, negative backwards." {
791
+ default 1
792
+ min -10
793
+ max 10
794
+ tunable true
795
+ }
796
+ 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." {
797
+ default true
798
+ }
799
+ field flipX bool "Mirror the rig left to right about the entity's position (a character facing left)."
800
+ field layer i32 "The sprite layer it draws in, sorted with the sprites there (after them when they share the layer)."
801
+ field finished bool "Written: a clip that does not loop reached its end (or its start, played backwards)." {
802
+ readonly true
803
+ }
804
+ }
805
+ ```
806
+
807
+ <sub>`api.ogt` line 7620</sub>
808
+
809
+ <a id="record-Skeleton2DEvent"></a>
810
+
811
+ ### `og.Skeleton2DEvent` (event)
812
+
813
+ A 2D skeleton's clip 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.
814
+
815
+ Token `og.Skeleton2DEvent`, registered under the schema name `og.Skeleton2DEvent`; its value type is `Skeleton2DEvent`.
816
+
817
+ | Field | Type | Default | Range | Unit | Notes | Doc |
818
+ |---|---|---|---|---|---|---|
819
+ | `entity` | `Entity` | `0` | — | — | — | The entity with the og.Skeleton2D. |
820
+ | `clip` | `number` | `0` | — | — | — | The clip index. |
821
+ | `name` | `string` | `""` | — | — | — | The event's name (at most 63 bytes). |
822
+ | `time` | `number` | `0` | — | `s` | — | The event's time in the clip. |
823
+
824
+ ```ogt
825
+ event Skeleton2DEvent {
826
+ doc "A 2D skeleton's clip 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."
827
+ field entity Entity "The entity with the og.Skeleton2D."
828
+ field clip u32 "The clip index."
829
+ field name String "The event's name (at most 63 bytes)."
830
+ field time f32 "The event's time in the clip." {
831
+ unit s
832
+ }
833
+ }
834
+ ```
835
+
836
+ <sub>`api.ogt` line 7647</sub>
837
+
838
+ <a id="record-IkTarget2D"></a>
839
+
840
+ ### `og.IkTarget2D` (component)
841
+
842
+ 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.
843
+
844
+ Token `og.IkTarget2D`, registered under the schema name `og.IkTarget2D`; its value type is `IkTarget2D`.
845
+
846
+ | Field | Type | Default | Range | Unit | Notes | Doc |
847
+ |---|---|---|---|---|---|---|
848
+ | `skeleton` | `Entity` | `0` | — | — | — | The entity with the og.Skeleton2D. |
849
+ | `constraint` | `number` | `0` | ≥ 0 | — | — | The constraint: an index into Rig2DInfo.constraints. |
850
+ | `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). |
851
+ | `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). |
852
+ | `tolerance` | `number` | `0.01` | ≥ 0 | `m` | — | The distance at which the target counts as reached. |
853
+ | `reached` | `boolean` | `false` | — | — | read only | Written: the tip is within `tolerance` of the target after solving. |
854
+ | `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). |
855
+
856
+ ```ogt
857
+ component IkTarget2D {
858
+ 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."
859
+ field skeleton Entity "The entity with the og.Skeleton2D."
860
+ field constraint u32 "The constraint: an index into Rig2DInfo.constraints." {
861
+ min 0
862
+ }
863
+ 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)." {
864
+ unit m
865
+ }
866
+ 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)." {
867
+ default 1
868
+ min 0
869
+ max 1
870
+ tunable true
871
+ }
872
+ field tolerance f32 "The distance at which the target counts as reached." {
873
+ default 0.01
874
+ min 0
875
+ unit m
876
+ }
877
+ field reached bool "Written: the tip is within `tolerance` of the target after solving." {
878
+ readonly true
879
+ }
880
+ 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)." {
881
+ unit m
882
+ readonly true
883
+ }
884
+ }
885
+ ```
886
+
887
+ <sub>`api.ogt` line 7657</sub>
654
888
 
655
889
  ## Types
656
890
 
@@ -666,7 +900,7 @@ A generational handle: a number the engine hands out. A dead handle is an error
666
900
  handle SkeletonAsset "A rig: a glTF's nodes in topological order with their rest transforms, and its skins (joints and inverse bind matrices)."
667
901
  ```
668
902
 
669
- <sub>`api.ogt` line 5612</sub>
903
+ <sub>`api.ogt` line 7145</sub>
670
904
 
671
905
  <a id="type-ClipAsset"></a>
672
906
 
@@ -680,7 +914,7 @@ A generational handle: a number the engine hands out. A dead handle is an error
680
914
  handle ClipAsset "An animation clip, resampled at the cook's rate, with its markers."
681
915
  ```
682
916
 
683
- <sub>`api.ogt` line 5613</sub>
917
+ <sub>`api.ogt` line 7146</sub>
684
918
 
685
919
  <a id="type-GraphAsset"></a>
686
920
 
@@ -694,7 +928,7 @@ A generational handle: a number the engine hands out. A dead handle is an error
694
928
  handle GraphAsset "A blend-tree graph (`type animgraph`) whose clip references were resolved to clip handles."
695
929
  ```
696
930
 
697
- <sub>`api.ogt` line 5614</sub>
931
+ <sub>`api.ogt` line 7147</sub>
698
932
 
699
933
  <a id="type-RootMotion"></a>
700
934
 
@@ -719,7 +953,7 @@ enum RootMotion {
719
953
  }
720
954
  ```
721
955
 
722
- <sub>`api.ogt` line 5637</sub>
956
+ <sub>`api.ogt` line 7170</sub>
723
957
 
724
958
  <a id="type-BlendshapeSource"></a>
725
959
 
@@ -742,7 +976,7 @@ enum BlendshapeSource {
742
976
  }
743
977
  ```
744
978
 
745
- <sub>`api.ogt` line 5651</sub>
979
+ <sub>`api.ogt` line 7184</sub>
746
980
 
747
981
  <a id="type-IkSolver"></a>
748
982
 
@@ -765,7 +999,7 @@ enum IkSolver {
765
999
  }
766
1000
  ```
767
1001
 
768
- <sub>`api.ogt` line 5664</sub>
1002
+ <sub>`api.ogt` line 7197</sub>
769
1003
 
770
1004
  <a id="type-IkSpace"></a>
771
1005
 
@@ -788,7 +1022,7 @@ enum IkSpace {
788
1022
  }
789
1023
  ```
790
1024
 
791
- <sub>`api.ogt` line 5677</sub>
1025
+ <sub>`api.ogt` line 7210</sub>
792
1026
 
793
1027
  <a id="type-ClipInfo"></a>
794
1028
 
@@ -815,7 +1049,7 @@ struct ClipInfo {
815
1049
  }
816
1050
  ```
817
1051
 
818
- <sub>`api.ogt` line 5895</sub>
1052
+ <sub>`api.ogt` line 7428</sub>
819
1053
 
820
1054
  <a id="type-Animation"></a>
821
1055
 
@@ -842,7 +1076,7 @@ struct Animation {
842
1076
  }
843
1077
  ```
844
1078
 
845
- <sub>`api.ogt` line 5905</sub>
1079
+ <sub>`api.ogt` line 7438</sub>
846
1080
 
847
1081
  <a id="type-GraphDesc"></a>
848
1082
 
@@ -866,7 +1100,7 @@ struct GraphDesc {
866
1100
  }
867
1101
  ```
868
1102
 
869
- <sub>`api.ogt` line 5914</sub>
1103
+ <sub>`api.ogt` line 7447</sub>
870
1104
 
871
1105
  <a id="type-Rig"></a>
872
1106
 
@@ -880,7 +1114,7 @@ A generational handle: a number the engine hands out. A dead handle is an error
880
1114
  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
1115
  ```
882
1116
 
883
- <sub>`api.ogt` line 5928</sub>
1117
+ <sub>`api.ogt` line 7461</sub>
884
1118
 
885
1119
  <a id="type-HumanBone"></a>
886
1120
 
@@ -901,7 +1135,7 @@ struct HumanBone {
901
1135
  }
902
1136
  ```
903
1137
 
904
- <sub>`api.ogt` line 5930</sub>
1138
+ <sub>`api.ogt` line 7463</sub>
905
1139
 
906
1140
  <a id="type-Humanoid"></a>
907
1141
 
@@ -922,7 +1156,7 @@ struct Humanoid {
922
1156
  }
923
1157
  ```
924
1158
 
925
- <sub>`api.ogt` line 5936</sub>
1159
+ <sub>`api.ogt` line 7469</sub>
926
1160
 
927
1161
  <a id="type-HumanoidDesc"></a>
928
1162
 
@@ -946,7 +1180,7 @@ struct HumanoidDesc {
946
1180
  }
947
1181
  ```
948
1182
 
949
- <sub>`api.ogt` line 5942</sub>
1183
+ <sub>`api.ogt` line 7475</sub>
950
1184
 
951
1185
  <a id="type-RetargetDesc"></a>
952
1186
 
@@ -980,7 +1214,7 @@ struct RetargetDesc {
980
1214
  }
981
1215
  ```
982
1216
 
983
- <sub>`api.ogt` line 5956</sub>
1217
+ <sub>`api.ogt` line 7489</sub>
984
1218
 
985
1219
  <a id="type-FlipbookSheet"></a>
986
1220
 
@@ -994,7 +1228,7 @@ A generational handle: a number the engine hands out. A dead handle is an error
994
1228
  handle FlipbookSheet "A sprite sheet's frames and clips (a cooked `.ogt` of `type flipbook`), from og.load.flipbook."
995
1229
  ```
996
1230
 
997
- <sub>`api.ogt` line 5976</sub>
1231
+ <sub>`api.ogt` line 7509</sub>
998
1232
 
999
1233
  <a id="type-FlipMode"></a>
1000
1234
 
@@ -1019,7 +1253,7 @@ enum FlipMode {
1019
1253
  }
1020
1254
  ```
1021
1255
 
1022
- <sub>`api.ogt` line 5985</sub>
1256
+ <sub>`api.ogt` line 7518</sub>
1023
1257
 
1024
1258
  <a id="type-FlipbookClipInfo"></a>
1025
1259
 
@@ -1050,7 +1284,7 @@ struct FlipbookClipInfo {
1050
1284
  }
1051
1285
  ```
1052
1286
 
1053
- <sub>`api.ogt` line 6031</sub>
1287
+ <sub>`api.ogt` line 7564</sub>
1054
1288
 
1055
1289
  <a id="type-FlipbookInfo"></a>
1056
1290
 
@@ -1081,7 +1315,104 @@ struct FlipbookInfo {
1081
1315
  }
1082
1316
  ```
1083
1317
 
1084
- <sub>`api.ogt` line 6043</sub>
1318
+ <sub>`api.ogt` line 7576</sub>
1319
+
1320
+ <a id="type-Rig2D"></a>
1321
+
1322
+ ### `Rig2D` (handle)
1323
+
1324
+ 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.
1325
+
1326
+ A generational handle: a number the engine hands out. A dead handle is an error value, never a crash.
1327
+
1328
+ ```ogt
1329
+ 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."
1330
+ ```
1331
+
1332
+ <sub>`api.ogt` line 7611</sub>
1333
+
1334
+ <a id="type-Rig2DClipInfo"></a>
1335
+
1336
+ ### `Rig2DClipInfo` (struct)
1337
+
1338
+ One clip of a loaded 2D rig.
1339
+
1340
+ | Field | Type | Default | Range | Unit | Notes | Doc |
1341
+ |---|---|---|---|---|---|---|
1342
+ | `clip` | `number` | `0` | — | — | — | Its index, what Skeleton2D.clip takes. |
1343
+ | `name` | `string` | `""` | — | — | — | Its name in the rig. |
1344
+ | `duration` | `number` | `0` | — | `s` | — | Its length. |
1345
+ | `loop` | `boolean` | `false` | — | — | — | Whether the rig's author meant it to loop (its `loop` line): copy it into Skeleton2D.loop. |
1346
+ | `events` | `readonly string[]` | `[]` | — | — | — | Its events' names, in time order. |
1347
+
1348
+ ```ogt
1349
+ struct Rig2DClipInfo {
1350
+ doc "One clip of a loaded 2D rig."
1351
+ field clip u32 "Its index, what Skeleton2D.clip takes."
1352
+ field name String "Its name in the rig."
1353
+ field duration f32 "Its length." {
1354
+ unit s
1355
+ }
1356
+ field loop bool "Whether the rig's author meant it to loop (its `loop` line): copy it into Skeleton2D.loop."
1357
+ field events List.String "Its events' names, in time order."
1358
+ }
1359
+ ```
1360
+
1361
+ <sub>`api.ogt` line 7686</sub>
1362
+
1363
+ <a id="type-Rig2DInfo"></a>
1364
+
1365
+ ### `Rig2DInfo` (struct)
1366
+
1367
+ What og.load.rig2d registered, or og.anim.rig2dInfo reads back from a handle.
1368
+
1369
+ | Field | Type | Default | Range | Unit | Notes | Doc |
1370
+ |---|---|---|---|---|---|---|
1371
+ | `rig` | `Rig2D` | `0` | — | — | — | What Skeleton2D.rig takes. |
1372
+ | `texture` | `Texture` | `0` | — | — | — | The rig's texture (loaded with it). |
1373
+ | `unit` | `number` | `0` | — | — | — | Pixels of the rig per world unit. |
1374
+ | `bones` | `readonly string[]` | `[]` | — | — | — | The bones' names, parents first. |
1375
+ | `slots` | `readonly string[]` | `[]` | — | — | — | The slots' names, in draw order. |
1376
+ | `constraints` | `readonly string[]` | `[]` | — | — | — | The IK constraints' names: an index here is IkTarget2D.constraint. |
1377
+ | `clips` | `readonly Rig2DClipInfo[]` | `[]` | — | — | — | Its clips, in file order. |
1378
+
1379
+ ```ogt
1380
+ struct Rig2DInfo {
1381
+ doc "What og.load.rig2d registered, or og.anim.rig2dInfo reads back from a handle."
1382
+ field rig Rig2D "What Skeleton2D.rig takes."
1383
+ field texture Texture "The rig's texture (loaded with it)."
1384
+ field unit f32 "Pixels of the rig per world unit."
1385
+ field bones List.String "The bones' names, parents first."
1386
+ field slots List.String "The slots' names, in draw order."
1387
+ field constraints List.String "The IK constraints' names: an index here is IkTarget2D.constraint."
1388
+ field clips List.Rig2DClipInfo "Its clips, in file order."
1389
+ }
1390
+ ```
1391
+
1392
+ <sub>`api.ogt` line 7697</sub>
1393
+
1394
+ <a id="type-Skeleton2DBox"></a>
1395
+
1396
+ ### `Skeleton2DBox` (struct)
1397
+
1398
+ 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.
1399
+
1400
+ | Field | Type | Default | Range | Unit | Notes | Doc |
1401
+ |---|---|---|---|---|---|---|
1402
+ | `slot` | `string` | `""` | — | — | — | The slot showing it (`slot/child-slot` inside a child armature). |
1403
+ | `name` | `string` | `""` | — | — | — | The box's name in the rig. |
1404
+ | `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). |
1405
+
1406
+ ```ogt
1407
+ struct Skeleton2DBox {
1408
+ 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."
1409
+ field slot String "The slot showing it (`slot/child-slot` inside a child armature)."
1410
+ field name String "The box's name in the rig."
1411
+ 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)."
1412
+ }
1413
+ ```
1414
+
1415
+ <sub>`api.ogt` line 7715</sub>
1085
1416
 
1086
1417
  ## Column kinds
1087
1418
 
@@ -1097,6 +1428,7 @@ Each is a factory, `SkeletonAsset(value?, options?)`, that makes one field of a
1097
1428
  | <a id="column-IkSolver"></a>`IkSolver` | `IkSolver` | `Uint32Array` | 1 | An IkSolver field: the variant's index. |
1098
1429
  | <a id="column-IkSpace"></a>`IkSpace` | `IkSpace` | `Uint32Array` | 1 | An IkSpace field: the variant's index. |
1099
1430
  | <a id="column-FlipbookSheet"></a>`FlipbookSheet` | `FlipbookSheet` | `Uint32Array` | 2 | A FlipbookSheet handle field. |
1431
+ | <a id="column-Rig2D"></a>`Rig2D` | `Rig2D` | `Uint32Array` | 2 | A Rig2D handle field. |
1100
1432
 
1101
1433
  ```ogt
1102
1434
  column SkeletonAsset {
@@ -1107,7 +1439,7 @@ column SkeletonAsset {
1107
1439
  }
1108
1440
  ```
1109
1441
 
1110
- <sub>`api.ogt` line 5616</sub>
1442
+ <sub>`api.ogt` line 7149</sub>
1111
1443
 
1112
1444
  ```ogt
1113
1445
  column ClipAsset {
@@ -1118,7 +1450,7 @@ column ClipAsset {
1118
1450
  }
1119
1451
  ```
1120
1452
 
1121
- <sub>`api.ogt` line 5623</sub>
1453
+ <sub>`api.ogt` line 7156</sub>
1122
1454
 
1123
1455
  ```ogt
1124
1456
  column GraphAsset {
@@ -1129,7 +1461,7 @@ column GraphAsset {
1129
1461
  }
1130
1462
  ```
1131
1463
 
1132
- <sub>`api.ogt` line 5630</sub>
1464
+ <sub>`api.ogt` line 7163</sub>
1133
1465
 
1134
1466
  ```ogt
1135
1467
  column RootMotion {
@@ -1140,7 +1472,7 @@ column RootMotion {
1140
1472
  }
1141
1473
  ```
1142
1474
 
1143
- <sub>`api.ogt` line 5644</sub>
1475
+ <sub>`api.ogt` line 7177</sub>
1144
1476
 
1145
1477
  ```ogt
1146
1478
  column BlendshapeSource {
@@ -1151,7 +1483,7 @@ column BlendshapeSource {
1151
1483
  }
1152
1484
  ```
1153
1485
 
1154
- <sub>`api.ogt` line 5657</sub>
1486
+ <sub>`api.ogt` line 7190</sub>
1155
1487
 
1156
1488
  ```ogt
1157
1489
  column IkSolver {
@@ -1162,7 +1494,7 @@ column IkSolver {
1162
1494
  }
1163
1495
  ```
1164
1496
 
1165
- <sub>`api.ogt` line 5670</sub>
1497
+ <sub>`api.ogt` line 7203</sub>
1166
1498
 
1167
1499
  ```ogt
1168
1500
  column IkSpace {
@@ -1173,7 +1505,7 @@ column IkSpace {
1173
1505
  }
1174
1506
  ```
1175
1507
 
1176
- <sub>`api.ogt` line 5683</sub>
1508
+ <sub>`api.ogt` line 7216</sub>
1177
1509
 
1178
1510
  ```ogt
1179
1511
  column FlipbookSheet {
@@ -1184,4 +1516,15 @@ column FlipbookSheet {
1184
1516
  }
1185
1517
  ```
1186
1518
 
1187
- <sub>`api.ogt` line 5978</sub>
1519
+ <sub>`api.ogt` line 7511</sub>
1520
+
1521
+ ```ogt
1522
+ column Rig2D {
1523
+ doc "A Rig2D handle field."
1524
+ array Uint32Array
1525
+ stride 2
1526
+ value Rig2D
1527
+ }
1528
+ ```
1529
+
1530
+ <sub>`api.ogt` line 7613</sub>