@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
@@ -14,8 +14,8 @@ needs a browser or a Rust toolchain. The command channel is
14
14
  The loop held for two whole games written from this package alone
15
15
  (`examples/lantern-vale`, `examples/hollowbell`): `og cook` took 47 and 69
16
16
  assets cold in 8.2 s and 3.6 s and under 100 ms after a change, without a
17
- warning, and every refusal named the line and the fix (a copied skin
18
- without its CJK `fallback` named the line and og-taste §1;
17
+ warning, and every refusal named the line and the fix (a copied UI style, as
18
+ styles were then called, without its CJK `fallback` named the line and og-taste §1;
19
19
  `PostEffects.vignette is true or false` named the line). Scripted runs gave
20
20
  the same frames every time, `store: "keep"` relaunches and two-process
21
21
  replays worked the first time they were asked for, and `og polish` scored
@@ -169,6 +169,15 @@ same store, for a relaunch (og-platform-sdk §4).
169
169
  - Determinism is checkable: two runs with the same seed and script give the
170
170
  same world hash in `dump_world`. When they do not, find the wall-clock
171
171
  read or the unseeded randomness before anything else.
172
+ - A model built as code (og-model) is judged on numbers and one sheet,
173
+ not on a frame read by eye: `view:<entity>:front|back|side|top`,
174
+ `view:<entity>:orbit:<degrees>` and `turntable:<entity>:<n>` frame it
175
+ from fixed cameras, and `og compare <reference.png> <render.png>`
176
+ prints the silhouette IoU and the ΔE00 per mask region and writes the
177
+ reference beside the render as one sheet PNG (`--mask`, `--align`,
178
+ `--json`). Two runs give the same numbers and the same sheet bytes, so
179
+ quote them with the command. og-model §3 has the commands and how to
180
+ read them, og-model §4 the gate each pass must meet.
172
181
  - Report what ran and what did not. A build that compiled is not a game
173
182
  that plays.
174
183
 
@@ -201,7 +210,10 @@ every screen that matters.
201
210
  | feel | Sound on input | inputs answered by a sound within 6 ticks | every action | og-audio §1 |
202
211
  | feel | Frame time | step + render, p95, on the tier it ran on (`metal` on a Mac, `vulkan` on a GPU); the probe's own screenshots (render, read back, PNG) are not the game's step and are left out. Without a renderer the row says `n/a (no renderer)`, as do contrast, text size and HUD occupancy, which read frames | 8.3 ms (half the frame) | og-game §14 |
203
212
 
204
- The report also lists clipped samples in the mix (og-audio §4). Contrast and
213
+ The report also lists clipped samples in the mix (og-audio §4), and a UI
214
+ style finding (no score) when a shot's `dump_ui` reports `style` empty: the
215
+ UI draws in prototype, the engine's placeholder, not a style of the game's
216
+ own (og-taste §1). Contrast and
205
217
  text size read text only: icons and images (their "text" is a picture's
206
218
  name), disabled controls and what they hold (WCAG exempts them), the
207
219
  slivers a scroll container cuts, what a dialog's or a tutorial's scrim
@@ -218,7 +230,7 @@ so it depends on the glyphs' coverage: thin strokes cover few pixels
218
230
  whole, and a regular-weight CJK face at body sizes measures lower than
219
231
  Latin in the same colours (a 15 px "设置" 3.1:1 where "Settings" reads
220
232
  4.6:1 on one button), as it reads lower to the eye. Darken the ink in the
221
- skin's palette, give the CJK face a heavier weight or the label a larger
233
+ style's palette, give the CJK face a heavier weight or the label a larger
222
234
  step; the measure is not wrong there. Facts are the game's `facts`
223
235
  (og-game §3): expose `hp`, `hits` or `kills` there or the hit measures stay
224
236
  n/a. A baseline line says how often things change with no input at all;
@@ -226,7 +238,7 @@ when it is high (a runner that always moves), read latency together with
226
238
  the frames.
227
239
 
228
240
  The numbers cannot judge a style. Read the frames before changing anything,
229
- fix the cause in the skin, the template or the system, never per call, and
241
+ fix the cause in the style, the template or the system, never per call, and
230
242
  run it again after the fix: the report is the evidence.
231
243
 
232
244
  ## 6. Shipping
@@ -234,14 +246,24 @@ run it again after the fix: the report is the evidence.
234
246
  `og build .` bundles `src/` to `dist/game.js`, cooks, and copies the engine
235
247
  runtime and wasm next to it. `og build . --publish` produces the published
236
248
  form: the probe keeps only its player-facing members (hello, tick, state,
237
- pick, entity, input, capture) and the command channel is gone.
249
+ pick, entity, input, capture) and the command channel is gone. A `2d`
250
+ project publishes the 2D module, which has no 3D world
251
+ (`RenderCapabilities.world3d` false): the build refuses scenes holding
252
+ `Terrain`, `TerrainScatter`, `Water`, `WaterSurface` or `Fluid3D`, naming
253
+ each by scene file and line (og-game §2).
238
254
  What ships is still checked by script, through what it keeps: real input
239
255
  on the published page and the probe's `tick`, `state` and `capture`. A
240
256
  playtest written in input steps (`key_down`, `type`, `touch_move_to` an
241
257
  id, `move_to_text`, `touch_start`) and `screenshot` steps runs there as it
242
258
  runs under `og test`, each frame compared with the same references; a
243
259
  game command (warp, give) has no channel there and is refused, so keep
244
- the steps a published check needs free of them. The engine runs this on
260
+ the steps a published check needs free of them. The page shows the
261
+ Player's Back over the canvas's top-left corner (12, 12, 40 by 40 CSS px
262
+ on a desktop page; og-ui §5), which anchored HUD groups keep out of, so
263
+ a playtest the page is held to gives its native run the same cover with
264
+ `setup: "cover:12,12,40,40"` (`PlaytestDesc.setup`: command steps run
265
+ once after `start`, before the first tick, never part of the page's
266
+ script) and its frames lay out as the page's. The engine runs this on
245
267
  the published build of its own games (its `tests/web/published.ts`: the
246
268
  boot, the title, a press, a typed name and a frame against the metal
247
269
  reference, with a clean console).
@@ -218,11 +218,26 @@ export const Move = defineSystem("Move", { reads: [Velocity], writes: [og.Transf
218
218
  module variable or as numbers of code points.
219
219
  A `str` holds 1 to 4,096 bytes: a larger capacity typechecks and is
220
220
  refused when the game starts (`a string field holds 1 to 4096 bytes`).
221
- - A field holds one value: a component has no array or list field. A few
222
- values are numbered fields (`p0`..`p7`, as og.CameraRail's rail points);
223
- a list is an entity per element with its own component, looped over by
224
- a query (a ring of skid marks, the laps of a race); a long record (a
225
- lap's taped inputs) is text in `str(4096)` chunks, an entity each.
221
+ - A field holds one value, or a fixed-capacity list of one number or
222
+ handle kind: `list(u32(), 8)`, `list(Asset(), 4)` (1 to 1,024 elements,
223
+ starting empty, never tunable). Reading it answers a frozen array, a
224
+ copy: `push`, `splice` and index writes throw, so write it whole
225
+ (`v.passes = [...v.passes, h]`, `v.passes = []`, `world.set(e, Chain,
226
+ { passes: [3, 5] })`). One over the capacity is refused with the fix
227
+ named (`declare the field list(u32(), 9) or larger`), never truncated.
228
+ Its column is the element's typed array with (capacity + 1) lanes per
229
+ entity, the count first, zeros past it, so `[]` and `[0]` are different
230
+ worlds. The probe reads it as a JSON array (`get:`, `dump_entity`),
231
+ `set:Chain.passes=[3,5]` (or `3,5`, nothing for `[]`) writes it whole, a
232
+ scene or a look gives it on one line (`passes 3 5`, the key alone for
233
+ `[]`), and snapshots and the hash carry it; a migrating restore keeps a
234
+ list that fits a new capacity and empties one that does not.
235
+ A list holds numbers only: a few vectors are numbered fields
236
+ (`p0`..`p7`, as og.CameraRail's rail points); a list of things with
237
+ fields of their own is an entity per element with its own component,
238
+ looped over by a query (a ring of skid marks, the laps of a race); a
239
+ long record (a lap's taped inputs) is text in `str(4096)` chunks, an
240
+ entity each.
226
241
  - A handle is a 64-bit number (an `og.load` answer, a texture, a sound,
227
242
  a geometry, a material, an entity): keep it in a field of its own kind,
228
243
  `Asset()`, `Texture()`, `Sound()`, `Geometry()`, `Material()` or
@@ -270,6 +285,17 @@ it is declared.
270
285
  probe and the command channel address entities by them.
271
286
  - Vector, quaternion, matrix, colour, transform and material vocabulary is
272
287
  three.js's (`position`, `quaternion`, `scale`, `metalness`, `roughness`).
288
+ - Math on those values is three.js's methods as pure functions, imported
289
+ from `@origingame/engine`: `vec3`, `vec2`, `quat`, `mat4`, `box3`,
290
+ `sphere`, `plane`, `frustum`, `ray`, `color` (`vec3.add(a, b)`,
291
+ `quat.slerp(a, b, t)`, `mat4.transformPoint(m, p)`,
292
+ `frustum.fromCamera(...)` then `frustum.intersectsBox(f, box)`,
293
+ `ray.intersectTriangle(r, a, b, c)` answering a point or null,
294
+ `color.fromHex(0x14161b)` answering linear RGB). They never change their
295
+ arguments and answer new plain objects, so there are no classes to
296
+ construct and a result is written into a column as any other value;
297
+ they use only arithmetic and `sqrt`, so a system using them stays
298
+ deterministic. Signatures: `reference/math.md`.
273
299
 
274
300
  ## 7. Where the API is described
275
301
 
@@ -135,7 +135,7 @@ is what a sprite wants.
135
135
  | Take-off | (0.85, 1.15) | 0.1 s |
136
136
  | Hit taken | (1.2, 0.8) | 0.15 s, with a flash |
137
137
  | Pickup collected (on the pickup) | (1.4, 1.4) then shrink to 0 | 0.15 s |
138
- | UI button press (the skin's `press` does it for og.ui) | (0.92, 0.92) | 0.08 s, unscaled |
138
+ | UI button press (the style's `press` does it for og.ui) | (0.92, 0.92) | 0.08 s, unscaled |
139
139
 
140
140
  Do not squash rigid things (crates, walls, the camera's target in a
141
141
  cutscene) or anything more than once per 6 ticks.
@@ -161,7 +161,7 @@ motion and hit stop (UI motion). `og.tween.squash` (§5) and
161
161
  | Constant motion, timers, scrolling, colour cycles | `linear` |
162
162
  | Most small motion when unsure | `quadOut` (the default) |
163
163
 
164
- Durations: 0.1–0.2 s for feedback, 0.12–0.3 s for UI (the skin's
164
+ Durations: 0.1–0.2 s for feedback, 0.12–0.3 s for UI (the style's
165
165
  durations, og-taste §5), 0.2–0.35 s for swaps, 0.4–0.8 s for camera moves,
166
166
  reveals and screen transitions (up to 0.7 s). Longer feels sluggish unless
167
167
  it is a cutscene or a reward.