@origingame/engine 0.0.0-stage → 0.1.1

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 (159) hide show
  1. package/bin/og.mjs +25 -0
  2. package/dist/web/origin-engine.d.ts +1233 -0
  3. package/dist/web/origin-engine.js +8628 -0
  4. package/dist/web/origin-engine_bg.wasm +0 -0
  5. package/dist/web/origin-engine_bg.wasm.d.ts +366 -0
  6. package/dist/web-publish/origin-engine-lanes.js +8509 -0
  7. package/dist/web-publish/origin-engine-lanes_bg.wasm +0 -0
  8. package/dist/web-publish/origin-engine.d.ts +1176 -0
  9. package/dist/web-publish/origin-engine.js +8313 -0
  10. package/dist/web-publish/origin-engine_bg.wasm +0 -0
  11. package/dist/web-publish/origin-engine_bg.wasm.d.ts +347 -0
  12. package/dist/web-publish/snippets/wasm-bindgen-rayon-38edf6e439f6d70d/src/workerHelpers.no-bundler.js +77 -0
  13. package/dist/web-publish-2d/origin-engine-lanes.js +8509 -0
  14. package/dist/web-publish-2d/origin-engine-lanes_bg.wasm +0 -0
  15. package/dist/web-publish-2d/origin-engine.d.ts +1176 -0
  16. package/dist/web-publish-2d/origin-engine.js +8313 -0
  17. package/dist/web-publish-2d/origin-engine_bg.wasm +0 -0
  18. package/dist/web-publish-2d/origin-engine_bg.wasm.d.ts +347 -0
  19. package/dist/web-publish-2d/snippets/wasm-bindgen-rayon-38edf6e439f6d70d/src/workerHelpers.no-bundler.js +77 -0
  20. package/knowledge/README.md +31 -0
  21. package/knowledge/knowledge.json +13 -0
  22. package/knowledge/looks/catalogue.json +1871 -0
  23. package/knowledge/package.json +33 -0
  24. package/knowledge/rules/platform.json +329 -0
  25. package/knowledge/scaffold/README.md +27 -0
  26. package/knowledge/scaffold/distribution.json +48 -0
  27. package/knowledge/scaffold/origin-engine.json +19 -0
  28. package/knowledge/scaffold/template/.origin/setup +14 -0
  29. package/knowledge/scaffold/template/LICENSES.md +23 -0
  30. package/knowledge/scaffold/template/README.md +37 -0
  31. package/knowledge/scaffold/template/assets/ai/guard.ogt +48 -0
  32. package/knowledge/scaffold/template/assets/audio/click.ogt +9 -0
  33. package/knowledge/scaffold/template/assets/fonts/NotoSansSC-Regular-subset.ttf.ogt +12 -0
  34. package/knowledge/scaffold/template/assets/fonts/OFL.txt +93 -0
  35. package/knowledge/scaffold/template/assets/looks/origin-game.ogt +12 -0
  36. package/knowledge/scaffold/template/assets/nav/yard.ogt +27 -0
  37. package/knowledge/scaffold/template/assets/scenes/main.ogt +34 -0
  38. package/knowledge/scaffold/template/assets/strings/en.ogt +14 -0
  39. package/knowledge/scaffold/template/assets/textures/stone_n.png.ogt +7 -0
  40. package/knowledge/scaffold/template/gitattributes +22 -0
  41. package/knowledge/scaffold/template/gitignore +8 -0
  42. package/knowledge/scaffold/template/package.json +18 -0
  43. package/knowledge/scaffold/template/project.ogt +25 -0
  44. package/knowledge/scaffold/template/src/main.ts +246 -0
  45. package/knowledge/scaffold/template/tests/guard.og.ts +67 -0
  46. package/knowledge/scaffold/template/tests/smoke.og.ts +43 -0
  47. package/knowledge/scaffold/template/tsconfig.json +17 -0
  48. package/knowledge/scripts/lib.ts +207 -0
  49. package/knowledge/scripts/mount.ts +210 -0
  50. package/knowledge/scripts/pack.ts +25 -0
  51. package/knowledge/scripts/scaffold.ts +72 -0
  52. package/knowledge/scripts/validate.ts +749 -0
  53. package/knowledge/skills/og-ai/SKILL.md +386 -0
  54. package/knowledge/skills/og-audio/SKILL.md +191 -0
  55. package/knowledge/skills/og-build/SKILL.md +330 -0
  56. package/knowledge/skills/og-core/SKILL.md +285 -0
  57. package/knowledge/skills/og-feel/SKILL.md +385 -0
  58. package/knowledge/skills/og-game/SKILL.md +1479 -0
  59. package/knowledge/skills/og-i18n/SKILL.md +220 -0
  60. package/knowledge/skills/og-platform-sdk/SKILL.md +199 -0
  61. package/knowledge/skills/og-taste/SKILL.md +537 -0
  62. package/knowledge/skills/og-ui/SKILL.md +444 -0
  63. package/knowledge/wiki/ai.md +627 -0
  64. package/knowledge/wiki/anim.md +1187 -0
  65. package/knowledge/wiki/atmosphere.md +636 -0
  66. package/knowledge/wiki/audio.md +732 -0
  67. package/knowledge/wiki/camera.md +711 -0
  68. package/knowledge/wiki/commands.md +357 -0
  69. package/knowledge/wiki/game.md +220 -0
  70. package/knowledge/wiki/i18n.md +213 -0
  71. package/knowledge/wiki/index.md +1027 -0
  72. package/knowledge/wiki/input.md +1714 -0
  73. package/knowledge/wiki/load.md +1280 -0
  74. package/knowledge/wiki/math.md +166 -0
  75. package/knowledge/wiki/nav.md +1154 -0
  76. package/knowledge/wiki/physics.md +3142 -0
  77. package/knowledge/wiki/platform.md +857 -0
  78. package/knowledge/wiki/probe.md +1692 -0
  79. package/knowledge/wiki/reflect.md +285 -0
  80. package/knowledge/wiki/render.md +3511 -0
  81. package/knowledge/wiki/rng.md +393 -0
  82. package/knowledge/wiki/stream.md +376 -0
  83. package/knowledge/wiki/system.md +197 -0
  84. package/knowledge/wiki/systems.md +43 -0
  85. package/knowledge/wiki/terrain.md +727 -0
  86. package/knowledge/wiki/tilemap.md +422 -0
  87. package/knowledge/wiki/time.md +150 -0
  88. package/knowledge/wiki/transform.md +230 -0
  89. package/knowledge/wiki/tween.md +580 -0
  90. package/knowledge/wiki/ui.md +8000 -0
  91. package/knowledge/wiki/world.md +909 -0
  92. package/package.json +68 -4
  93. package/schema/api.schema.json +29675 -0
  94. package/shell/README.md +22 -0
  95. package/shell/brand/README.md +23 -0
  96. package/shell/brand/icon-192.png +0 -0
  97. package/shell/brand/icon-512.png +0 -0
  98. package/shell/brand/mark-on-paper.svg +6 -0
  99. package/shell/brand/origin-mark.svg +5 -0
  100. package/shell/brand/origin-motion.css +251 -0
  101. package/shell/brand/tokens.css +20 -0
  102. package/shell/brand.ts +132 -0
  103. package/shell/page.ts +715 -0
  104. package/shell/platform.ts +203 -0
  105. package/shell/player.ts +238 -0
  106. package/shell/shell.css +185 -0
  107. package/shell/sw.ts +177 -0
  108. package/shell/transport.ts +515 -0
  109. package/shell/wire.ts +369 -0
  110. package/src/e6.ts +69 -0
  111. package/src/env.d.ts +100 -0
  112. package/src/generated/abi.ts +980 -0
  113. package/src/index.ts +193 -0
  114. package/src/node/audio.ts +86 -0
  115. package/src/node/build.ts +109 -0
  116. package/src/node/device.ts +981 -0
  117. package/src/node/doctor.ts +60 -0
  118. package/src/node/index.ts +102 -0
  119. package/src/node/platform.ts +24 -0
  120. package/src/node/playtest-run.ts +249 -0
  121. package/src/node/png.ts +130 -0
  122. package/src/node/polish.ts +976 -0
  123. package/src/node/run.ts +373 -0
  124. package/src/node/web-build.ts +808 -0
  125. package/src/p2.ts +35 -0
  126. package/src/platform-local.ts +211 -0
  127. package/src/playtest.ts +131 -0
  128. package/src/runtime.ts +1509 -0
  129. package/src/systems/cameras.ts +247 -0
  130. package/src/ui-kit/bind.ts +141 -0
  131. package/src/ui-kit/huds.ts +303 -0
  132. package/src/ui-kit/index.ts +36 -0
  133. package/src/ui-kit/menus.ts +187 -0
  134. package/src/ui-kit/settings.ts +131 -0
  135. package/src/ui-kit/store.ts +222 -0
  136. package/src/ui-kit/story.ts +89 -0
  137. package/src/ui-kit/util.ts +106 -0
  138. package/src/web/a11y.ts +429 -0
  139. package/src/web/audio-worklet.ts +193 -0
  140. package/src/web/audio.ts +307 -0
  141. package/src/web/basis.ts +239 -0
  142. package/src/web/gamepad.ts +123 -0
  143. package/src/web/host.ts +166 -0
  144. package/src/web/input.ts +237 -0
  145. package/src/web/lanes.ts +21 -0
  146. package/src/web/play.ts +20 -0
  147. package/src/web/rpc-ring.ts +110 -0
  148. package/src/web/settle.ts +122 -0
  149. package/src/web/shell.ts +643 -0
  150. package/src/web/text-input.ts +248 -0
  151. package/src/web/worker.ts +1002 -0
  152. package/types/bindings.json +13654 -0
  153. package/types/index.d.ts +20090 -0
  154. package/vendor/basis/LICENSE +201 -0
  155. package/vendor/basis/NOTICE +15 -0
  156. package/vendor/basis/README.md +18 -0
  157. package/vendor/basis/basis_transcoder.js +19 -0
  158. package/vendor/basis/basis_transcoder.wasm +0 -0
  159. package/README.md +0 -3
@@ -0,0 +1,1154 @@
1
+ <!-- Generated from crates/og-api/api.ogt by `og api gen`. Do not edit: `og api check` fails on any difference; change api.ogt and regenerate. -->
2
+
3
+ # The `nav` module
4
+
5
+ Navigation: grids (A* and jump point search with eight-way moves that never cut a blocked corner, line-of-sight smoothing), flow fields for crowds, and navmeshes (baked at cook time from a level's static colliders and models, or built at runtime for a flat procedural level) with funnel paths and box obstacles that rebuild only the tiles they touch.
6
+
7
+ Agents are entities with an og.NavAgent (and an og.Transform): the og.nav system, after the game's systems and before physics, plans their paths, follows them and adds the og.Steering behaviours; an entity with an og.Velocity (a physics body) gets its velocity written, any other its Transform moved. Everything is deterministic and in snapshots: paths, grid edits, obstacles and flow targets.
8
+
9
+ Agents move on the profile's plane: x and y in 2D (a grid's rows run up), x and z in 3D (y kept on grids, from the surface on a navmesh).
10
+
11
+ - **TypeScript**: functions are the namespace `og.nav`; components, resources and events are tokens on `og`.
12
+ - **Publish builds**: kept (members may override).
13
+ - **Skill**: `og-ai`, which teaches the module (how much of it to use, and how to prove it).
14
+ - **Index**: [every module and name](index.md).
15
+
16
+ ```ogt
17
+ module nav {
18
+ # declarations follow, each quoted below
19
+ ```
20
+
21
+ <sub>`api.ogt` line 6798</sub>
22
+
23
+ ## Contents
24
+
25
+ | Name | Kind | Summary |
26
+ |---|---|---|
27
+ | [`Navigation`](#type-Navigation) | handle | A grid, a navmesh or a flow field agents plan on. |
28
+ | [`Navigation()`](#column-Navigation) | column kind | A Navigation handle field. |
29
+ | [`NAV_IDLE`](#const-NAV_IDLE) | constant | NavAgent.status: not seeking. |
30
+ | [`NAV_MOVING`](#const-NAV_MOVING) | constant | NavAgent.status: following a path or a flow field. |
31
+ | [`NAV_ARRIVED`](#const-NAV_ARRIVED) | constant | NavAgent.status: within stopDistance of the target. |
32
+ | [`NAV_UNREACHABLE`](#const-NAV_UNREACHABLE) | constant | NavAgent.status: no path reaches the target, or the agent is off its grid or navmesh. |
33
+ | [`NAV_PARTIAL`](#const-NAV_PARTIAL) | constant | NavAgent.status: the target is cut off; moving to the reachable point nearest it. |
34
+ | [`NavAlgorithm`](#type-NavAlgorithm) | enum | The grid search a path query runs. |
35
+ | [`og.NavAgent`](#record-NavAgent) | component | An entity that moves itself towards `target` while `seeking`, by a path over `nav` (a grid, navmesh or flow field; 0 goes straight). og.nav re-plans when the target moved more than repathDistance, every repathTicks, or when the grid or navmesh changed, at most 32 plans a tick across agents. |
36
+ | [`og.Steering`](#record-Steering) | component | Steering behaviours an og.NavAgent adds to its path following, each by weight (0 is off): flee, wander, pursue, evade, separation from other agents and avoidance of colliders ahead (three physics rays). |
37
+ | [`NavGridDesc`](#type-NavGridDesc) | desc struct | A grid of square cells over the plane: cell (0, 0)'s lower corner at `origin`, rows running up. |
38
+ | [`TilemapGridDesc`](#type-TilemapGridDesc) | desc struct | A grid over a placed og.Tilemap: one cell per map cell, blocked where a collision layer has a solid tile. |
39
+ | [`NavCell`](#type-NavCell) | struct | A grid cell. |
40
+ | [`PathDesc`](#type-PathDesc) | desc struct | A path query. |
41
+ | [`NavPath`](#type-NavPath) | struct | A path. |
42
+ | [`FlowDesc`](#type-FlowDesc) | desc struct | A flow field over a grid. |
43
+ | [`NavBox`](#type-NavBox) | desc struct | An axis-aligned box. |
44
+ | [`NavMeshDesc`](#type-NavMeshDesc) | desc struct | A navmesh built at runtime over a flat floor (a procedural level): the floor box, the boxes it carves out, and the agent it is for. |
45
+ | [`NavMeshInfo`](#type-NavMeshInfo) | struct | A navmesh's shape. |
46
+ | [`NavRebuild`](#type-NavRebuild) | struct | What an obstacle change rebuilt. |
47
+ | [`og.nav.grid`](#fn-grid) | function | A grid agents and path queries plan on. Runtime edits (og.nav.setCost) are world state. |
48
+ | [`og.nav.gridFromTilemap`](#fn-gridFromTilemap) | function | A grid over a placed map: its cells, its world position (the map's top-left corner at the entity), blocked where the collision layers have solid tiles. Edits to the map later do not follow; build another. |
49
+ | [`og.nav.setCost`](#fn-setCost) | function | Change a grid cell's cost (0 blocks it): agents on the grid re-plan, flow fields over it rebuild. |
50
+ | [`og.nav.cellAt`](#fn-cellAt) | function | The grid cell under a world point. |
51
+ | [`og.nav.findPath`](#fn-findPath) | function | A path between two points on a grid or a navmesh, now: corners, length and whether it reaches the end. |
52
+ | [`og.nav.flowField`](#fn-flowField) | function | A flow field towards targets over a grid: one Dijkstra pass gives every cell a direction, so any number of agents (NavAgent.nav = the field) steer by a lookup. It rebuilds when the grid changes. |
53
+ | [`og.nav.setFlowTargets`](#fn-setFlowTargets) | function | Move a flow field's targets (rebuilds it). |
54
+ | [`og.nav.flowAt`](#fn-flowAt) | function | The direction a flow field gives at a point (unit length, or zero at a target or where nothing is reachable). |
55
+ | [`og.nav.load`](#fn-load) | function | A cooked navmesh: an `.ogt` of `type navmesh` (the agent, the cell sizes, the bounds and the geometry: a scene's static colliders and models, glTF models, terrains, boxes; og-ai §1 has every line) baked by og cook. |
56
+ | [`og.nav.build`](#fn-build) | function | A navmesh over a flat floor with boxes carved out, built now: for procedural levels (a level with slopes and stairs is baked at cook time with og.nav.load). |
57
+ | [`og.nav.setObstacle`](#fn-setObstacle) | function | Set, move or (with no box) remove an obstacle on a navmesh: the spans under the box (grown by the agent radius) are blocked and only the tiles it touches, and their neighbours, are rebuilt. Agents on the mesh re-plan. World state. |
58
+ | [`og.nav.nearest`](#fn-nearest) | function | The point on a navmesh nearest a world point, within `extent` (half sizes). |
59
+ | [`og.nav.pathOf`](#fn-pathOf) | function | The path an agent follows now (its corners from where it planned), for debugging and playtests; `dump_nav:<entity>` writes the same. |
60
+
61
+ ## Functions
62
+
63
+ <a id="fn-grid"></a>
64
+
65
+ ### `og.nav.grid`
66
+
67
+ A grid agents and path queries plan on. Runtime edits (og.nav.setCost) are world state.
68
+
69
+ ```ts
70
+ og.nav.grid(world: World, desc?: NavGridDesc): Result<Navigation>
71
+ ```
72
+
73
+ | Parameter | Type | Optional | Doc |
74
+ |---|---|---|---|
75
+ | `world` | `World` | no | The world. |
76
+ | `desc` | `NavGridDesc` | yes | Its size, cell size, origin and costs. |
77
+
78
+ **Returns** `Result<Navigation>`: Refused for costs of the wrong length.
79
+
80
+ Binding symbol `og_nav_grid` · publish builds: kept
81
+
82
+ ```ogt
83
+ fn grid {
84
+ doc "A grid agents and path queries plan on. Runtime edits (og.nav.setCost) are world state."
85
+ param world World "The world."
86
+ param desc NavGridDesc "Its size, cell size, origin and costs."
87
+ returns Result.Navigation "Refused for costs of the wrong length."
88
+ }
89
+ ```
90
+
91
+ <sub>`api.ogt` line 7154</sub>
92
+
93
+ <a id="fn-gridFromTilemap"></a>
94
+
95
+ ### `og.nav.gridFromTilemap`
96
+
97
+ A grid over a placed map: its cells, its world position (the map's top-left corner at the entity), blocked where the collision layers have solid tiles. Edits to the map later do not follow; build another.
98
+
99
+ ```ts
100
+ og.nav.gridFromTilemap(world: World, desc?: TilemapGridDesc): Result<Navigation>
101
+ ```
102
+
103
+ | Parameter | Type | Optional | Doc |
104
+ |---|---|---|---|
105
+ | `world` | `World` | no | The world. |
106
+ | `desc` | `TilemapGridDesc` | yes | The map's entity and the blocking layers. |
107
+
108
+ **Returns** `Result<Navigation>`: Refused for an entity without an og.Tilemap or a map not loaded.
109
+
110
+ Binding symbol `og_nav_grid_from_tilemap` · publish builds: kept
111
+
112
+ ```ogt
113
+ fn gridFromTilemap {
114
+ doc "A grid over a placed map: its cells, its world position (the map's top-left corner at the entity), blocked where the collision layers have solid tiles. Edits to the map later do not follow; build another."
115
+ param world World "The world."
116
+ param desc TilemapGridDesc "The map's entity and the blocking layers."
117
+ returns Result.Navigation "Refused for an entity without an og.Tilemap or a map not loaded."
118
+ }
119
+ ```
120
+
121
+ <sub>`api.ogt` line 7161</sub>
122
+
123
+ <a id="fn-setCost"></a>
124
+
125
+ ### `og.nav.setCost`
126
+
127
+ Change a grid cell's cost (0 blocks it): agents on the grid re-plan, flow fields over it rebuild.
128
+
129
+ ```ts
130
+ og.nav.setCost(world: World, grid: Navigation, x: number, y: number, cost: number): Result<void>
131
+ ```
132
+
133
+ | Parameter | Type | Optional | Doc |
134
+ |---|---|---|---|
135
+ | `world` | `World` | no | The world. |
136
+ | `grid` | `Navigation` | no | The grid. |
137
+ | `x` | `number` | no | The column. |
138
+ | `y` | `number` | no | The row (0 is the bottom). |
139
+ | `cost` | `number` | no | 0 blocked, 1 normal, up to 255. |
140
+
141
+ **Returns** `Result<void>`: Refused for an unknown grid or a cell outside it.
142
+
143
+ Binding symbol `og_nav_set_cost` · publish builds: kept
144
+
145
+ ```ogt
146
+ fn setCost {
147
+ doc "Change a grid cell's cost (0 blocks it): agents on the grid re-plan, flow fields over it rebuild."
148
+ param world World "The world."
149
+ param grid Navigation "The grid."
150
+ param x u32 "The column."
151
+ param y u32 "The row (0 is the bottom)."
152
+ param cost u32 "0 blocked, 1 normal, up to 255."
153
+ returns Result.Void "Refused for an unknown grid or a cell outside it."
154
+ }
155
+ ```
156
+
157
+ <sub>`api.ogt` line 7168</sub>
158
+
159
+ <a id="fn-cellAt"></a>
160
+
161
+ ### `og.nav.cellAt`
162
+
163
+ The grid cell under a world point.
164
+
165
+ ```ts
166
+ og.nav.cellAt(world: World, grid: Navigation, point: Vector3): NavCell
167
+ ```
168
+
169
+ | Parameter | Type | Optional | Doc |
170
+ |---|---|---|---|
171
+ | `world` | `World` | no | The world. |
172
+ | `grid` | `Navigation` | no | The grid. |
173
+ | `point` | `Vector3` | no | A world point. |
174
+
175
+ **Returns** `NavCell`.
176
+
177
+ Binding symbol `og_nav_cell_at` · publish builds: kept
178
+
179
+ ```ogt
180
+ fn cellAt {
181
+ doc "The grid cell under a world point."
182
+ param world World "The world."
183
+ param grid Navigation "The grid."
184
+ param point Vector3 "A world point."
185
+ returns NavCell
186
+ }
187
+ ```
188
+
189
+ <sub>`api.ogt` line 7178</sub>
190
+
191
+ <a id="fn-findPath"></a>
192
+
193
+ ### `og.nav.findPath`
194
+
195
+ A path between two points on a grid or a navmesh, now: corners, length and whether it reaches the end.
196
+
197
+ ```ts
198
+ og.nav.findPath(world: World, desc?: PathDesc): Result<NavPath>
199
+ ```
200
+
201
+ | Parameter | Type | Optional | Doc |
202
+ |---|---|---|---|
203
+ | `world` | `World` | no | The world. |
204
+ | `desc` | `PathDesc` | yes | The grid or navmesh and the two points. |
205
+
206
+ **Returns** `Result<NavPath>`: Refused for an unknown grid or navmesh, or when no path starts (an end off the grid or mesh).
207
+
208
+ Binding symbol `og_nav_find_path` · publish builds: kept
209
+
210
+ ```ogt
211
+ fn findPath {
212
+ doc "A path between two points on a grid or a navmesh, now: corners, length and whether it reaches the end."
213
+ param world World "The world."
214
+ param desc PathDesc "The grid or navmesh and the two points."
215
+ returns Result.NavPath "Refused for an unknown grid or navmesh, or when no path starts (an end off the grid or mesh)."
216
+ }
217
+ ```
218
+
219
+ <sub>`api.ogt` line 7186</sub>
220
+
221
+ <a id="fn-flowField"></a>
222
+
223
+ ### `og.nav.flowField`
224
+
225
+ A flow field towards targets over a grid: one Dijkstra pass gives every cell a direction, so any number of agents (NavAgent.nav = the field) steer by a lookup. It rebuilds when the grid changes.
226
+
227
+ ```ts
228
+ og.nav.flowField(world: World, desc?: FlowDesc): Result<Navigation>
229
+ ```
230
+
231
+ | Parameter | Type | Optional | Doc |
232
+ |---|---|---|---|
233
+ | `world` | `World` | no | The world. |
234
+ | `desc` | `FlowDesc` | yes | The grid and the targets. |
235
+
236
+ **Returns** `Result<Navigation>`: Refused for an unknown grid.
237
+
238
+ Binding symbol `og_nav_flow_field` · publish builds: kept
239
+
240
+ ```ogt
241
+ fn flowField {
242
+ doc "A flow field towards targets over a grid: one Dijkstra pass gives every cell a direction, so any number of agents (NavAgent.nav = the field) steer by a lookup. It rebuilds when the grid changes."
243
+ param world World "The world."
244
+ param desc FlowDesc "The grid and the targets."
245
+ returns Result.Navigation "Refused for an unknown grid."
246
+ }
247
+ ```
248
+
249
+ <sub>`api.ogt` line 7193</sub>
250
+
251
+ <a id="fn-setFlowTargets"></a>
252
+
253
+ ### `og.nav.setFlowTargets`
254
+
255
+ Move a flow field's targets (rebuilds it).
256
+
257
+ ```ts
258
+ og.nav.setFlowTargets(world: World, field: Navigation, targets: readonly Vector3[]): Result<void>
259
+ ```
260
+
261
+ | Parameter | Type | Optional | Doc |
262
+ |---|---|---|---|
263
+ | `world` | `World` | no | The world. |
264
+ | `field` | `Navigation` | no | The flow field. |
265
+ | `targets` | `readonly Vector3[]` | no | The new targets. |
266
+
267
+ **Returns** `Result<void>`: Refused for an unknown flow field.
268
+
269
+ Binding symbol `og_nav_set_flow_targets` · publish builds: kept
270
+
271
+ ```ogt
272
+ fn setFlowTargets {
273
+ doc "Move a flow field's targets (rebuilds it)."
274
+ param world World "The world."
275
+ param field Navigation "The flow field."
276
+ param targets List.Vector3 "The new targets."
277
+ returns Result.Void "Refused for an unknown flow field."
278
+ }
279
+ ```
280
+
281
+ <sub>`api.ogt` line 7200</sub>
282
+
283
+ <a id="fn-flowAt"></a>
284
+
285
+ ### `og.nav.flowAt`
286
+
287
+ The direction a flow field gives at a point (unit length, or zero at a target or where nothing is reachable).
288
+
289
+ ```ts
290
+ og.nav.flowAt(world: World, field: Navigation, point: Vector3): Vector3
291
+ ```
292
+
293
+ | Parameter | Type | Optional | Doc |
294
+ |---|---|---|---|
295
+ | `world` | `World` | no | The world. |
296
+ | `field` | `Navigation` | no | The flow field. |
297
+ | `point` | `Vector3` | no | A world point. |
298
+
299
+ **Returns** `Vector3`.
300
+
301
+ Binding symbol `og_nav_flow_at` · publish builds: kept
302
+
303
+ ```ogt
304
+ fn flowAt {
305
+ doc "The direction a flow field gives at a point (unit length, or zero at a target or where nothing is reachable)."
306
+ param world World "The world."
307
+ param field Navigation "The flow field."
308
+ param point Vector3 "A world point."
309
+ returns Vector3
310
+ }
311
+ ```
312
+
313
+ <sub>`api.ogt` line 7208</sub>
314
+
315
+ <a id="fn-load"></a>
316
+
317
+ ### `og.nav.load`
318
+
319
+ A cooked navmesh: an `.ogt` of `type navmesh` (the agent, the cell sizes, the bounds and the geometry: a scene's static colliders and models, glTF models, terrains, boxes; og-ai §1 has every line) baked by og cook.
320
+
321
+ ```ts
322
+ og.nav.load(world: World, path: string): Result<NavMeshInfo>
323
+ ```
324
+
325
+ | Parameter | Type | Optional | Doc |
326
+ |---|---|---|---|
327
+ | `world` | `World` | no | The world. |
328
+ | `path` | `string` | no | The navmesh asset, such as `levels/arena.nav.ogt`. |
329
+
330
+ **Returns** `Result<NavMeshInfo>`: Refused for a path that is not a cooked navmesh.
331
+
332
+ Binding symbol `og_nav_load` · publish builds: kept
333
+
334
+ ```ogt
335
+ fn load {
336
+ doc "A cooked navmesh: an `.ogt` of `type navmesh` (the agent, the cell sizes, the bounds and the geometry: a scene's static colliders and models, glTF models, terrains, boxes; og-ai §1 has every line) baked by og cook."
337
+ param world World "The world."
338
+ param path String "The navmesh asset, such as `levels/arena.nav.ogt`."
339
+ returns Result.NavMeshInfo "Refused for a path that is not a cooked navmesh."
340
+ }
341
+ ```
342
+
343
+ <sub>`api.ogt` line 7216</sub>
344
+
345
+ <a id="fn-build"></a>
346
+
347
+ ### `og.nav.build`
348
+
349
+ A navmesh over a flat floor with boxes carved out, built now: for procedural levels (a level with slopes and stairs is baked at cook time with og.nav.load).
350
+
351
+ ```ts
352
+ og.nav.build(world: World, desc?: NavMeshDesc): Result<NavMeshInfo>
353
+ ```
354
+
355
+ | Parameter | Type | Optional | Doc |
356
+ |---|---|---|---|
357
+ | `world` | `World` | no | The world. |
358
+ | `desc` | `NavMeshDesc` | yes | The floor, the boxes and the agent. |
359
+
360
+ **Returns** `Result<NavMeshInfo>`: Refused for an empty floor.
361
+
362
+ Binding symbol `og_nav_build` · publish builds: kept
363
+
364
+ ```ogt
365
+ fn build {
366
+ doc "A navmesh over a flat floor with boxes carved out, built now: for procedural levels (a level with slopes and stairs is baked at cook time with og.nav.load)."
367
+ param world World "The world."
368
+ param desc NavMeshDesc "The floor, the boxes and the agent."
369
+ returns Result.NavMeshInfo "Refused for an empty floor."
370
+ }
371
+ ```
372
+
373
+ <sub>`api.ogt` line 7223</sub>
374
+
375
+ <a id="fn-setObstacle"></a>
376
+
377
+ ### `og.nav.setObstacle`
378
+
379
+ Set, move or (with no box) remove an obstacle on a navmesh: the spans under the box (grown by the agent radius) are blocked and only the tiles it touches, and their neighbours, are rebuilt. Agents on the mesh re-plan. World state.
380
+
381
+ ```ts
382
+ og.nav.setObstacle(world: World, mesh: Navigation, id: number, obstacle?: NavBox): Result<NavRebuild>
383
+ ```
384
+
385
+ | Parameter | Type | Optional | Doc |
386
+ |---|---|---|---|
387
+ | `world` | `World` | no | The world. |
388
+ | `mesh` | `Navigation` | no | The navmesh. |
389
+ | `id` | `number` | no | The obstacle's id, the game's own (a door's number). |
390
+ | `obstacle` | `NavBox` | yes | The box; omitted removes the obstacle. |
391
+
392
+ **Returns** `Result<NavRebuild>`: Refused for an unknown navmesh.
393
+
394
+ Binding symbol `og_nav_set_obstacle` · publish builds: kept
395
+
396
+ ```ogt
397
+ fn setObstacle {
398
+ doc "Set, move or (with no box) remove an obstacle on a navmesh: the spans under the box (grown by the agent radius) are blocked and only the tiles it touches, and their neighbours, are rebuilt. Agents on the mesh re-plan. World state."
399
+ param world World "The world."
400
+ param mesh Navigation "The navmesh."
401
+ param id u32 "The obstacle's id, the game's own (a door's number)."
402
+ param obstacle NavBox "The box; omitted removes the obstacle." {
403
+ optional true
404
+ }
405
+ returns Result.NavRebuild "Refused for an unknown navmesh."
406
+ }
407
+ ```
408
+
409
+ <sub>`api.ogt` line 7230</sub>
410
+
411
+ <a id="fn-nearest"></a>
412
+
413
+ ### `og.nav.nearest`
414
+
415
+ The point on a navmesh nearest a world point, within `extent` (half sizes).
416
+
417
+ ```ts
418
+ og.nav.nearest(world: World, mesh: Navigation, point: Vector3, extent?: Vector3): Vector3 | null
419
+ ```
420
+
421
+ | Parameter | Type | Optional | Doc |
422
+ |---|---|---|---|
423
+ | `world` | `World` | no | The world. |
424
+ | `mesh` | `Navigation` | no | The navmesh. |
425
+ | `point` | `Vector3` | no | A world point. |
426
+ | `extent` | `Vector3` | yes | The search box's half sizes; zero: 2 2 2. |
427
+
428
+ **Returns** `Vector3 | null`: Null when no polygon is within the box.
429
+
430
+ Binding symbol `og_nav_nearest` · publish builds: kept
431
+
432
+ ```ogt
433
+ fn nearest {
434
+ doc "The point on a navmesh nearest a world point, within `extent` (half sizes)."
435
+ param world World "The world."
436
+ param mesh Navigation "The navmesh."
437
+ param point Vector3 "A world point."
438
+ param extent Vector3 "The search box's half sizes; zero: 2 2 2." {
439
+ optional true
440
+ }
441
+ returns Option.Vector3 "Null when no polygon is within the box."
442
+ }
443
+ ```
444
+
445
+ <sub>`api.ogt` line 7241</sub>
446
+
447
+ <a id="fn-pathOf"></a>
448
+
449
+ ### `og.nav.pathOf`
450
+
451
+ The path an agent follows now (its corners from where it planned), for debugging and playtests; `dump_nav:<entity>` writes the same.
452
+
453
+ ```ts
454
+ og.nav.pathOf(world: World, entity: Entity): NavPath | null
455
+ ```
456
+
457
+ | Parameter | Type | Optional | Doc |
458
+ |---|---|---|---|
459
+ | `world` | `World` | no | The world. |
460
+ | `entity` | `Entity` | no | An entity with an og.NavAgent. |
461
+
462
+ **Returns** `NavPath | null`: Null for an entity that has not planned.
463
+
464
+ Binding symbol `og_nav_path_of` · publish builds: kept
465
+
466
+ ```ogt
467
+ fn pathOf {
468
+ doc "The path an agent follows now (its corners from where it planned), for debugging and playtests; `dump_nav:<entity>` writes the same."
469
+ param world World "The world."
470
+ param entity Entity "An entity with an og.NavAgent."
471
+ returns Option.NavPath "Null for an entity that has not planned."
472
+ }
473
+ ```
474
+
475
+ <sub>`api.ogt` line 7252</sub>
476
+
477
+ ## Components, resources and events
478
+
479
+ <a id="record-NavAgent"></a>
480
+
481
+ ### `og.NavAgent` (component)
482
+
483
+ An entity that moves itself towards `target` while `seeking`, by a path over `nav` (a grid, navmesh or flow field; 0 goes straight). og.nav re-plans when the target moved more than repathDistance, every repathTicks, or when the grid or navmesh changed, at most 32 plans a tick across agents.
484
+
485
+ Token `og.NavAgent`, registered under the schema name `og.NavAgent`; its value type is `NavAgent`.
486
+
487
+ | Field | Type | Default | Range | Unit | Notes | Doc |
488
+ |---|---|---|---|---|---|---|
489
+ | `nav` | `Navigation` | `0` | — | — | — | The grid, navmesh or flow field it plans on (og.nav.grid, og.nav.load, og.nav.flowField); 0 moves straight at the target. |
490
+ | `target` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | — | — | Where it goes while seeking. |
491
+ | `seeking` | `boolean` | `false` | — | — | — | Moves towards the target while true. |
492
+ | `speed` | `number` | `3.5` | 0 … 100 | `mps` | tunable | Top speed. |
493
+ | `acceleration` | `number` | `20` | 0 … 1000 | `mps2` | tunable | How fast it changes velocity. |
494
+ | `radius` | `number` | `0.4` | 0 … 10 | `m` | tunable | Its radius: grid paths keep this clear of walls; separation uses it. |
495
+ | `stopDistance` | `number` | `0.1` | 0 … 10 | `m` | tunable | It has arrived within this distance of the target. |
496
+ | `slowRadius` | `number` | `1` | 0 … 20 | `m` | tunable | It slows down inside this distance of the target. |
497
+ | `repathTicks` | `number` | `30` | 0 … 3600 | `ticks` | — | Re-plans this often while seeking (0: only when the target moves). |
498
+ | `repathDistance` | `number` | `0.5` | 0 … 100 | `m` | — | Re-plans when the target moved farther than this from the last plan. |
499
+ | `smooth` | `boolean` | `true` | — | — | — | Pulls grid paths straight where nothing is in the way. |
500
+ | `faceMovement` | `boolean` | `false` | — | — | — | Turns the entity to face where it moves (3D: about +Y, its +Z forward; 2D: about +Z, its +X forward). |
501
+ | `turnSpeed` | `number` | `10` | 0 … 100 | `radps` | — | How fast it turns when facing its movement. |
502
+ | `drive` | `boolean` | `true` | — | — | — | Moves the entity (its og.Velocity, or its og.Transform) while true; false keeps planning but leaves the motion to the game (a knock-back, a stun). |
503
+ | `status` | `number` | `0` | — | — | read only | NAV_IDLE, NAV_MOVING, NAV_ARRIVED, NAV_UNREACHABLE or NAV_PARTIAL (written by og.nav). |
504
+ | `velocity` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `mps` | read only | Its velocity (written by og.nav). |
505
+ | `waypoint` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `m` | read only | The path corner it heads for (written by og.nav). |
506
+ | `remaining` | `number` | `0` | — | `m` | read only | The path length left (written by og.nav). |
507
+ | `plans` | `number` | `0` | — | — | read only | Paths planned so far (written by og.nav). |
508
+
509
+ ```ogt
510
+ component NavAgent {
511
+ doc "An entity that moves itself towards `target` while `seeking`, by a path over `nav` (a grid, navmesh or flow field; 0 goes straight). og.nav re-plans when the target moved more than repathDistance, every repathTicks, or when the grid or navmesh changed, at most 32 plans a tick across agents."
512
+ field nav Navigation "The grid, navmesh or flow field it plans on (og.nav.grid, og.nav.load, og.nav.flowField); 0 moves straight at the target."
513
+ field target Vector3 "Where it goes while seeking."
514
+ field seeking bool "Moves towards the target while true."
515
+ field speed f32 "Top speed." {
516
+ default 3.5
517
+ min 0
518
+ max 100
519
+ unit mps
520
+ tunable true
521
+ }
522
+ field acceleration f32 "How fast it changes velocity." {
523
+ default 20
524
+ min 0
525
+ max 1000
526
+ unit mps2
527
+ tunable true
528
+ }
529
+ field radius f32 "Its radius: grid paths keep this clear of walls; separation uses it." {
530
+ default 0.4
531
+ min 0
532
+ max 10
533
+ unit m
534
+ tunable true
535
+ }
536
+ field stopDistance f32 "It has arrived within this distance of the target." {
537
+ default 0.1
538
+ min 0
539
+ max 10
540
+ unit m
541
+ tunable true
542
+ }
543
+ field slowRadius f32 "It slows down inside this distance of the target." {
544
+ default 1
545
+ min 0
546
+ max 20
547
+ unit m
548
+ tunable true
549
+ }
550
+ field repathTicks u32 "Re-plans this often while seeking (0: only when the target moves)." {
551
+ default 30
552
+ min 0
553
+ max 3600
554
+ unit ticks
555
+ }
556
+ field repathDistance f32 "Re-plans when the target moved farther than this from the last plan." {
557
+ default 0.5
558
+ min 0
559
+ max 100
560
+ unit m
561
+ }
562
+ field smooth bool "Pulls grid paths straight where nothing is in the way." {
563
+ default true
564
+ }
565
+ field faceMovement bool "Turns the entity to face where it moves (3D: about +Y, its +Z forward; 2D: about +Z, its +X forward)."
566
+ field turnSpeed f32 "How fast it turns when facing its movement." {
567
+ default 10
568
+ min 0
569
+ max 100
570
+ unit radps
571
+ }
572
+ field drive bool "Moves the entity (its og.Velocity, or its og.Transform) while true; false keeps planning but leaves the motion to the game (a knock-back, a stun)." {
573
+ default true
574
+ }
575
+ field status u32 "NAV_IDLE, NAV_MOVING, NAV_ARRIVED, NAV_UNREACHABLE or NAV_PARTIAL (written by og.nav)." {
576
+ readonly true
577
+ }
578
+ field velocity Vector3 "Its velocity (written by og.nav)." {
579
+ unit mps
580
+ readonly true
581
+ }
582
+ field waypoint Vector3 "The path corner it heads for (written by og.nav)." {
583
+ unit m
584
+ readonly true
585
+ }
586
+ field remaining f32 "The path length left (written by og.nav)." {
587
+ unit m
588
+ readonly true
589
+ }
590
+ field plans u32 "Paths planned so far (written by og.nav)." {
591
+ readonly true
592
+ }
593
+ }
594
+ ```
595
+
596
+ <sub>`api.ogt` line 6825</sub>
597
+
598
+ <a id="record-Steering"></a>
599
+
600
+ ### `og.Steering` (component)
601
+
602
+ Steering behaviours an og.NavAgent adds to its path following, each by weight (0 is off): flee, wander, pursue, evade, separation from other agents and avoidance of colliders ahead (three physics rays).
603
+
604
+ Token `og.Steering`, registered under the schema name `og.Steering`; its value type is `Steering`.
605
+
606
+ | Field | Type | Default | Range | Unit | Notes | Doc |
607
+ |---|---|---|---|---|---|---|
608
+ | `seek` | `number` | `1` | 0 … 10 | — | tunable | Weight of following the path to the target (seek, then arrive at the end). |
609
+ | `flee` | `number` | `0` | 0 … 10 | — | tunable | Weight of fleeing fleeFrom. |
610
+ | `fleeFrom` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `m` | — | What it flees. |
611
+ | `fleeRadius` | `number` | `6` | 0 … 100 | `m` | tunable | It flees (and evades) only inside this distance (0: always). |
612
+ | `wander` | `number` | `0` | 0 … 10 | — | tunable | Weight of wandering. |
613
+ | `wanderRadius` | `number` | `1` | 0 … 20 | `m` | tunable | The wander circle's radius. |
614
+ | `wanderDistance` | `number` | `2` | 0 … 20 | `m` | tunable | How far ahead the wander circle is. |
615
+ | `wanderJitter` | `number` | `3` | 0 … 50 | `radps` | tunable | How fast the wander point moves round the circle. |
616
+ | `pursue` | `Entity` | `0` | — | — | — | An entity to pursue (seek where it will be, from its NavAgent or og.Velocity); 0: none. |
617
+ | `pursueWeight` | `number` | `1` | 0 … 10 | — | tunable | Weight of pursuing. |
618
+ | `evade` | `Entity` | `0` | — | — | — | An entity to evade (flee where it will be); 0: none. |
619
+ | `evadeWeight` | `number` | `1` | 0 … 10 | — | tunable | Weight of evading. |
620
+ | `separation` | `number` | `0` | 0 … 10 | — | tunable | Weight of keeping apart from other agents. |
621
+ | `separationRadius` | `number` | `1` | 0 … 20 | `m` | tunable | Other agents closer than this push it away. |
622
+ | `avoidance` | `number` | `0` | 0 … 10 | — | tunable | Weight of avoiding colliders ahead. |
623
+ | `avoidDistance` | `number` | `2` | 0 … 50 | `m` | tunable | How far ahead the avoidance rays reach. |
624
+ | `avoidMask` | `number` | `0` | — | — | — | Collision layers the avoidance rays hit (0: every layer). |
625
+ | `wanderAngle` | `number` | `0` | — | `rad` | read only | The wander angle (written by og.nav). |
626
+
627
+ ```ogt
628
+ component Steering {
629
+ doc "Steering behaviours an og.NavAgent adds to its path following, each by weight (0 is off): flee, wander, pursue, evade, separation from other agents and avoidance of colliders ahead (three physics rays)."
630
+ field seek f32 "Weight of following the path to the target (seek, then arrive at the end)." {
631
+ default 1
632
+ min 0
633
+ max 10
634
+ tunable true
635
+ }
636
+ field flee f32 "Weight of fleeing fleeFrom." {
637
+ min 0
638
+ max 10
639
+ tunable true
640
+ }
641
+ field fleeFrom Vector3 "What it flees." {
642
+ unit m
643
+ }
644
+ field fleeRadius f32 "It flees (and evades) only inside this distance (0: always)." {
645
+ default 6
646
+ min 0
647
+ max 100
648
+ unit m
649
+ tunable true
650
+ }
651
+ field wander f32 "Weight of wandering." {
652
+ min 0
653
+ max 10
654
+ tunable true
655
+ }
656
+ field wanderRadius f32 "The wander circle's radius." {
657
+ default 1
658
+ min 0
659
+ max 20
660
+ unit m
661
+ tunable true
662
+ }
663
+ field wanderDistance f32 "How far ahead the wander circle is." {
664
+ default 2
665
+ min 0
666
+ max 20
667
+ unit m
668
+ tunable true
669
+ }
670
+ field wanderJitter f32 "How fast the wander point moves round the circle." {
671
+ default 3
672
+ min 0
673
+ max 50
674
+ unit radps
675
+ tunable true
676
+ }
677
+ field pursue Entity "An entity to pursue (seek where it will be, from its NavAgent or og.Velocity); 0: none."
678
+ field pursueWeight f32 "Weight of pursuing." {
679
+ default 1
680
+ min 0
681
+ max 10
682
+ tunable true
683
+ }
684
+ field evade Entity "An entity to evade (flee where it will be); 0: none."
685
+ field evadeWeight f32 "Weight of evading." {
686
+ default 1
687
+ min 0
688
+ max 10
689
+ tunable true
690
+ }
691
+ field separation f32 "Weight of keeping apart from other agents." {
692
+ min 0
693
+ max 10
694
+ tunable true
695
+ }
696
+ field separationRadius f32 "Other agents closer than this push it away." {
697
+ default 1
698
+ min 0
699
+ max 20
700
+ unit m
701
+ tunable true
702
+ }
703
+ field avoidance f32 "Weight of avoiding colliders ahead." {
704
+ min 0
705
+ max 10
706
+ tunable true
707
+ }
708
+ field avoidDistance f32 "How far ahead the avoidance rays reach." {
709
+ default 2
710
+ min 0
711
+ max 50
712
+ unit m
713
+ tunable true
714
+ }
715
+ field avoidMask u32 "Collision layers the avoidance rays hit (0: every layer)."
716
+ field wanderAngle f32 "The wander angle (written by og.nav)." {
717
+ unit rad
718
+ readonly true
719
+ }
720
+ }
721
+ ```
722
+
723
+ <sub>`api.ogt` line 6910</sub>
724
+
725
+ ## Types
726
+
727
+ <a id="type-Navigation"></a>
728
+
729
+ ### `Navigation` (handle)
730
+
731
+ A grid, a navmesh or a flow field agents plan on.
732
+
733
+ A generational handle: a number the engine hands out. A dead handle is an error value, never a crash.
734
+
735
+ ```ogt
736
+ handle Navigation "A grid, a navmesh or a flow field agents plan on."
737
+ ```
738
+
739
+ <sub>`api.ogt` line 6804</sub>
740
+
741
+ <a id="type-NavAlgorithm"></a>
742
+
743
+ ### `NavAlgorithm` (enum)
744
+
745
+ The grid search a path query runs.
746
+
747
+ A string: one of the variants below. The zero value is `"jps"`.
748
+
749
+ | Variant | Doc |
750
+ |---|---|
751
+ | `"jps"` | Jump point search: the same optimal paths as A* with fewer nodes; on a grid with weighted cells it runs A*. |
752
+ | `"astar"` | A* over every cell. |
753
+
754
+ ```ogt
755
+ enum NavAlgorithm {
756
+ doc "The grid search a path query runs."
757
+ variant jps "Jump point search: the same optimal paths as A* with fewer nodes; on a grid with weighted cells it runs A*."
758
+ variant astar "A* over every cell."
759
+ }
760
+ ```
761
+
762
+ <sub>`api.ogt` line 6819</sub>
763
+
764
+ <a id="type-NavGridDesc"></a>
765
+
766
+ ### `NavGridDesc` (desc struct)
767
+
768
+ A grid of square cells over the plane: cell (0, 0)'s lower corner at `origin`, rows running up.
769
+
770
+ A desc: every field may be omitted and takes its default; `{}` is valid.
771
+
772
+ | Field | Type | Default | Range | Unit | Notes | Doc |
773
+ |---|---|---|---|---|---|---|
774
+ | `width` | `number` | `32` | 1 … 4096 | — | — | Cells across. |
775
+ | `height` | `number` | `32` | 1 … 4096 | — | — | Cells up. |
776
+ | `cellSize` | `number` | `1` | 0.01 … 100 | `m` | — | A cell's side. |
777
+ | `origin` | `Vector2` | `{ x: 0, y: 0 }` | — | `m` | — | Where cell (0, 0)'s lower corner is (x, y in 2D; x, z in 3D). |
778
+ | `costs` | `readonly number[]` | `[]` | — | — | — | Row-major cell costs from row 0 (0 blocked, 1 normal, up to 255 to avoid); empty: every cell 1. |
779
+
780
+ ```ogt
781
+ struct NavGridDesc {
782
+ doc "A grid of square cells over the plane: cell (0, 0)'s lower corner at `origin`, rows running up."
783
+ desc true
784
+ field width u32 "Cells across." {
785
+ default 32
786
+ min 1
787
+ max 4096
788
+ }
789
+ field height u32 "Cells up." {
790
+ default 32
791
+ min 1
792
+ max 4096
793
+ }
794
+ field cellSize f32 "A cell's side." {
795
+ default 1
796
+ min 0.01
797
+ max 100
798
+ unit m
799
+ }
800
+ field origin Vector2 "Where cell (0, 0)'s lower corner is (x, y in 2D; x, z in 3D)." {
801
+ unit m
802
+ }
803
+ field costs List.u32 "Row-major cell costs from row 0 (0 blocked, 1 normal, up to 255 to avoid); empty: every cell 1."
804
+ }
805
+ ```
806
+
807
+ <sub>`api.ogt` line 7004</sub>
808
+
809
+ <a id="type-TilemapGridDesc"></a>
810
+
811
+ ### `TilemapGridDesc` (desc struct)
812
+
813
+ A grid over a placed og.Tilemap: one cell per map cell, blocked where a collision layer has a solid tile.
814
+
815
+ A desc: every field may be omitted and takes its default; `{}` is valid.
816
+
817
+ | Field | Type | Default | Range | Unit | Notes | Doc |
818
+ |---|---|---|---|---|---|---|
819
+ | `entity` | `Entity` | `0` | — | — | — | The entity with the og.Tilemap. |
820
+ | `layers` | `readonly string[]` | `[]` | — | — | — | The layers whose solid tiles block; empty: every collision layer. |
821
+ | `inflate` | `number` | `0` | ≤ 8 | — | — | Also block this many cells around each blocked one (wide agents). |
822
+
823
+ ```ogt
824
+ struct TilemapGridDesc {
825
+ doc "A grid over a placed og.Tilemap: one cell per map cell, blocked where a collision layer has a solid tile."
826
+ desc true
827
+ field entity Entity "The entity with the og.Tilemap."
828
+ field layers List.String "The layers whose solid tiles block; empty: every collision layer."
829
+ field inflate u32 "Also block this many cells around each blocked one (wide agents)." {
830
+ max 8
831
+ }
832
+ }
833
+ ```
834
+
835
+ <sub>`api.ogt` line 7029</sub>
836
+
837
+ <a id="type-NavCell"></a>
838
+
839
+ ### `NavCell` (struct)
840
+
841
+ A grid cell.
842
+
843
+ | Field | Type | Default | Range | Unit | Notes | Doc |
844
+ |---|---|---|---|---|---|---|
845
+ | `x` | `number` | `0` | — | — | — | The column. |
846
+ | `y` | `number` | `0` | — | — | — | The row (0 is the bottom). |
847
+ | `inside` | `boolean` | `false` | — | — | — | Whether the point was on the grid. |
848
+
849
+ ```ogt
850
+ struct NavCell {
851
+ doc "A grid cell."
852
+ field x u32 "The column."
853
+ field y u32 "The row (0 is the bottom)."
854
+ field inside bool "Whether the point was on the grid."
855
+ }
856
+ ```
857
+
858
+ <sub>`api.ogt` line 7039</sub>
859
+
860
+ <a id="type-PathDesc"></a>
861
+
862
+ ### `PathDesc` (desc struct)
863
+
864
+ A path query.
865
+
866
+ A desc: every field may be omitted and takes its default; `{}` is valid.
867
+
868
+ | Field | Type | Default | Range | Unit | Notes | Doc |
869
+ |---|---|---|---|---|---|---|
870
+ | `nav` | `Navigation` | `0` | — | — | — | The grid or navmesh. |
871
+ | `from` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `m` | — | The start. |
872
+ | `to` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `m` | — | The end. |
873
+ | `algorithm` | `NavAlgorithm` | `"jps"` | — | — | — | The grid search. |
874
+ | `smooth` | `boolean` | `true` | — | — | — | Pull a grid path straight where nothing is in the way. |
875
+ | `radius` | `number` | `0` | 0 … 10 | `m` | — | Keep this clear of grid walls when smoothing. |
876
+
877
+ ```ogt
878
+ struct PathDesc {
879
+ doc "A path query."
880
+ desc true
881
+ field nav Navigation "The grid or navmesh."
882
+ field from Vector3 "The start." {
883
+ unit m
884
+ }
885
+ field to Vector3 "The end." {
886
+ unit m
887
+ }
888
+ field algorithm NavAlgorithm "The grid search."
889
+ field smooth bool "Pull a grid path straight where nothing is in the way." {
890
+ default true
891
+ }
892
+ field radius f32 "Keep this clear of grid walls when smoothing." {
893
+ min 0
894
+ max 10
895
+ unit m
896
+ }
897
+ }
898
+ ```
899
+
900
+ <sub>`api.ogt` line 7046</sub>
901
+
902
+ <a id="type-NavPath"></a>
903
+
904
+ ### `NavPath` (struct)
905
+
906
+ A path.
907
+
908
+ | Field | Type | Default | Range | Unit | Notes | Doc |
909
+ |---|---|---|---|---|---|---|
910
+ | `points` | `readonly Vector3[]` | `[]` | — | — | — | Its corners, start and end included. |
911
+ | `length` | `number` | `0` | — | `m` | — | Its length. |
912
+ | `complete` | `boolean` | `false` | — | — | — | Whether it reaches the end (false: it stops at the reachable point nearest it). |
913
+ | `expanded` | `number` | `0` | — | — | — | Cells or polygons the search took off its open list. |
914
+ | `algorithm` | `string` | `""` | — | — | — | What ran: jps, astar or navmesh. |
915
+
916
+ ```ogt
917
+ struct NavPath {
918
+ doc "A path."
919
+ field points List.Vector3 "Its corners, start and end included."
920
+ field length f32 "Its length." {
921
+ unit m
922
+ }
923
+ field complete bool "Whether it reaches the end (false: it stops at the reachable point nearest it)."
924
+ field expanded u32 "Cells or polygons the search took off its open list."
925
+ field algorithm String "What ran: jps, astar or navmesh."
926
+ }
927
+ ```
928
+
929
+ <sub>`api.ogt` line 7067</sub>
930
+
931
+ <a id="type-FlowDesc"></a>
932
+
933
+ ### `FlowDesc` (desc struct)
934
+
935
+ A flow field over a grid.
936
+
937
+ A desc: every field may be omitted and takes its default; `{}` is valid.
938
+
939
+ | Field | Type | Default | Range | Unit | Notes | Doc |
940
+ |---|---|---|---|---|---|---|
941
+ | `grid` | `Navigation` | `0` | — | — | — | The grid. |
942
+ | `targets` | `readonly Vector3[]` | `[]` | — | — | — | Where agents go: each point's cell is a target. |
943
+
944
+ ```ogt
945
+ struct FlowDesc {
946
+ doc "A flow field over a grid."
947
+ desc true
948
+ field grid Navigation "The grid."
949
+ field targets List.Vector3 "Where agents go: each point's cell is a target."
950
+ }
951
+ ```
952
+
953
+ <sub>`api.ogt` line 7078</sub>
954
+
955
+ <a id="type-NavBox"></a>
956
+
957
+ ### `NavBox` (desc struct)
958
+
959
+ An axis-aligned box.
960
+
961
+ A desc: every field may be omitted and takes its default; `{}` is valid.
962
+
963
+ | Field | Type | Default | Range | Unit | Notes | Doc |
964
+ |---|---|---|---|---|---|---|
965
+ | `min` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `m` | — | Its lowest corner. |
966
+ | `max` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `m` | — | Its highest corner. |
967
+
968
+ ```ogt
969
+ struct NavBox {
970
+ doc "An axis-aligned box."
971
+ desc true
972
+ field min Vector3 "Its lowest corner." {
973
+ unit m
974
+ }
975
+ field max Vector3 "Its highest corner." {
976
+ unit m
977
+ }
978
+ }
979
+ ```
980
+
981
+ <sub>`api.ogt` line 7085</sub>
982
+
983
+ <a id="type-NavMeshDesc"></a>
984
+
985
+ ### `NavMeshDesc` (desc struct)
986
+
987
+ A navmesh built at runtime over a flat floor (a procedural level): the floor box, the boxes it carves out, and the agent it is for.
988
+
989
+ A desc: every field may be omitted and takes its default; `{}` is valid.
990
+
991
+ | Field | Type | Default | Range | Unit | Notes | Doc |
992
+ |---|---|---|---|---|---|---|
993
+ | `min` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `m` | — | The floor's lowest corner (its y is the floor's height). |
994
+ | `max` | `Vector3` | `{ x: 16, y: 1, z: 16 }` | — | `m` | — | The floor's highest corner. |
995
+ | `blocked` | `readonly NavBox[]` | `[]` | — | — | — | Boxes standing on the floor (walls, crates). |
996
+ | `cellSize` | `number` | `0.25` | 0.02 … 4 | `m` | — | The voxel width. |
997
+ | `agentRadius` | `number` | `0.4` | 0 … 10 | `m` | — | Walls are kept this far away. |
998
+ | `agentHeight` | `number` | `1.8` | 0.1 … 20 | `m` | — | The agent's height. |
999
+ | `tileSize` | `number` | `32` | 8 … 256 | — | — | Cells per tile side: an obstacle rebuilds the tiles it touches. |
1000
+
1001
+ ```ogt
1002
+ struct NavMeshDesc {
1003
+ doc "A navmesh built at runtime over a flat floor (a procedural level): the floor box, the boxes it carves out, and the agent it is for."
1004
+ desc true
1005
+ field min Vector3 "The floor's lowest corner (its y is the floor's height)." {
1006
+ unit m
1007
+ }
1008
+ field max Vector3 "The floor's highest corner." {
1009
+ default 16 1 16
1010
+ unit m
1011
+ }
1012
+ field blocked List.NavBox "Boxes standing on the floor (walls, crates)."
1013
+ field cellSize f32 "The voxel width." {
1014
+ default 0.25
1015
+ min 0.02
1016
+ max 4
1017
+ unit m
1018
+ }
1019
+ field agentRadius f32 "Walls are kept this far away." {
1020
+ default 0.4
1021
+ min 0
1022
+ max 10
1023
+ unit m
1024
+ }
1025
+ field agentHeight f32 "The agent's height." {
1026
+ default 1.8
1027
+ min 0.1
1028
+ max 20
1029
+ unit m
1030
+ }
1031
+ field tileSize u32 "Cells per tile side: an obstacle rebuilds the tiles it touches." {
1032
+ default 32
1033
+ min 8
1034
+ max 256
1035
+ }
1036
+ }
1037
+ ```
1038
+
1039
+ <sub>`api.ogt` line 7096</sub>
1040
+
1041
+ <a id="type-NavMeshInfo"></a>
1042
+
1043
+ ### `NavMeshInfo` (struct)
1044
+
1045
+ A navmesh's shape.
1046
+
1047
+ | Field | Type | Default | Range | Unit | Notes | Doc |
1048
+ |---|---|---|---|---|---|---|
1049
+ | `mesh` | `Navigation` | `0` | — | — | — | What NavAgent.nav and the queries take. |
1050
+ | `polygons` | `number` | `0` | — | — | — | Its convex polygons. |
1051
+ | `tiles` | `number` | `0` | — | — | — | Its tiles. |
1052
+ | `min` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `m` | — | The lowest corner of the box around its polygons. |
1053
+ | `max` | `Vector3` | `{ x: 0, y: 0, z: 0 }` | — | `m` | — | The highest corner of the box around its polygons (its highest walkable floor's y). |
1054
+ | `cellSize` | `number` | `0` | — | `m` | — | Its voxel width. |
1055
+
1056
+ ```ogt
1057
+ struct NavMeshInfo {
1058
+ doc "A navmesh's shape."
1059
+ field mesh Navigation "What NavAgent.nav and the queries take."
1060
+ field polygons u32 "Its convex polygons."
1061
+ field tiles u32 "Its tiles."
1062
+ field min Vector3 "The lowest corner of the box around its polygons." {
1063
+ unit m
1064
+ }
1065
+ field max Vector3 "The highest corner of the box around its polygons (its highest walkable floor's y)." {
1066
+ unit m
1067
+ }
1068
+ field cellSize f32 "Its voxel width." {
1069
+ unit m
1070
+ }
1071
+ }
1072
+ ```
1073
+
1074
+ <sub>`api.ogt` line 7132</sub>
1075
+
1076
+ <a id="type-NavRebuild"></a>
1077
+
1078
+ ### `NavRebuild` (struct)
1079
+
1080
+ What an obstacle change rebuilt.
1081
+
1082
+ | Field | Type | Default | Range | Unit | Notes | Doc |
1083
+ |---|---|---|---|---|---|---|
1084
+ | `tiles` | `readonly number[]` | `[]` | — | — | — | The tiles rebuilt, by index. |
1085
+ | `polygons` | `number` | `0` | — | — | — | The navmesh's polygons now. |
1086
+
1087
+ ```ogt
1088
+ struct NavRebuild {
1089
+ doc "What an obstacle change rebuilt."
1090
+ field tiles List.u32 "The tiles rebuilt, by index."
1091
+ field polygons u32 "The navmesh's polygons now."
1092
+ }
1093
+ ```
1094
+
1095
+ <sub>`api.ogt` line 7148</sub>
1096
+
1097
+ ## Column kinds
1098
+
1099
+ Each is a factory, `Navigation(value?, options?)`, that makes one field of a component or resource layout.
1100
+
1101
+ | Column | Value | Typed array | Stride | Doc |
1102
+ |---|---|---|---|---|
1103
+ | <a id="column-Navigation"></a>`Navigation` | `Navigation` | `Uint32Array` | 2 | A Navigation handle field. |
1104
+
1105
+ ```ogt
1106
+ column Navigation {
1107
+ doc "A Navigation handle field."
1108
+ array Uint32Array
1109
+ stride 2
1110
+ value Navigation
1111
+ }
1112
+ ```
1113
+
1114
+ <sub>`api.ogt` line 6806</sub>
1115
+
1116
+ ## Constants
1117
+
1118
+ | Constant | Type | Value | Doc |
1119
+ |---|---|---|---|
1120
+ | <a id="const-NAV_IDLE"></a>`NAV_IDLE` | `number` | `0` | NavAgent.status: not seeking. |
1121
+ | <a id="const-NAV_MOVING"></a>`NAV_MOVING` | `number` | `1` | NavAgent.status: following a path or a flow field. |
1122
+ | <a id="const-NAV_ARRIVED"></a>`NAV_ARRIVED` | `number` | `2` | NavAgent.status: within stopDistance of the target. |
1123
+ | <a id="const-NAV_UNREACHABLE"></a>`NAV_UNREACHABLE` | `number` | `3` | NavAgent.status: no path reaches the target, or the agent is off its grid or navmesh. |
1124
+ | <a id="const-NAV_PARTIAL"></a>`NAV_PARTIAL` | `number` | `4` | NavAgent.status: the target is cut off; moving to the reachable point nearest it. |
1125
+
1126
+ ```ogt
1127
+ const NAV_IDLE u32 0 "NavAgent.status: not seeking."
1128
+ ```
1129
+
1130
+ <sub>`api.ogt` line 6813</sub>
1131
+
1132
+ ```ogt
1133
+ const NAV_MOVING u32 1 "NavAgent.status: following a path or a flow field."
1134
+ ```
1135
+
1136
+ <sub>`api.ogt` line 6814</sub>
1137
+
1138
+ ```ogt
1139
+ const NAV_ARRIVED u32 2 "NavAgent.status: within stopDistance of the target."
1140
+ ```
1141
+
1142
+ <sub>`api.ogt` line 6815</sub>
1143
+
1144
+ ```ogt
1145
+ const NAV_UNREACHABLE u32 3 "NavAgent.status: no path reaches the target, or the agent is off its grid or navmesh."
1146
+ ```
1147
+
1148
+ <sub>`api.ogt` line 6816</sub>
1149
+
1150
+ ```ogt
1151
+ const NAV_PARTIAL u32 4 "NavAgent.status: the target is cut off; moving to the reachable point nearest it."
1152
+ ```
1153
+
1154
+ <sub>`api.ogt` line 6817</sub>