wallhammer-web 0.0.0-stage → 0.4.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 (408) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +92 -2
  3. package/dist/base/data.d.ts +67 -0
  4. package/dist/base/data.js +10 -0
  5. package/dist/base/destructible.d.ts +167 -0
  6. package/dist/base/destructible.js +47 -0
  7. package/dist/base/env-slot.d.ts +101 -0
  8. package/dist/base/env-slot.js +8 -0
  9. package/dist/base/frames.d.ts +138 -0
  10. package/dist/base/frames.js +459 -0
  11. package/dist/base/index.d.ts +21 -0
  12. package/dist/base/index.js +11 -0
  13. package/dist/base/mat34.d.ts +46 -0
  14. package/dist/base/mat34.js +173 -0
  15. package/dist/base/material.d.ts +87 -0
  16. package/dist/base/material.js +6 -0
  17. package/dist/base/math.d.ts +27 -0
  18. package/dist/base/math.js +60 -0
  19. package/dist/base/progress.d.ts +38 -0
  20. package/dist/base/progress.js +81 -0
  21. package/dist/base/rig.d.ts +177 -0
  22. package/dist/base/rig.js +97 -0
  23. package/dist/base/trig.d.ts +29 -0
  24. package/dist/base/trig.js +169 -0
  25. package/dist/base/up.d.ts +26 -0
  26. package/dist/base/up.js +40 -0
  27. package/dist/base/view.d.ts +128 -0
  28. package/dist/base/view.js +136 -0
  29. package/dist/camera/camera.d.ts +99 -0
  30. package/dist/camera/camera.js +228 -0
  31. package/dist/camera/follow.d.ts +120 -0
  32. package/dist/camera/follow.js +320 -0
  33. package/dist/camera/free.d.ts +153 -0
  34. package/dist/camera/free.js +359 -0
  35. package/dist/camera/index.d.ts +10 -0
  36. package/dist/camera/index.js +6 -0
  37. package/dist/camera/orbit.d.ts +93 -0
  38. package/dist/camera/orbit.js +261 -0
  39. package/dist/camera/path.d.ts +48 -0
  40. package/dist/camera/path.js +179 -0
  41. package/dist/core/ballistic.d.ts +66 -0
  42. package/dist/core/ballistic.js +104 -0
  43. package/dist/core/bodies.d.ts +77 -0
  44. package/dist/core/bodies.js +125 -0
  45. package/dist/core/clock.d.ts +37 -0
  46. package/dist/core/clock.js +87 -0
  47. package/dist/core/cover-fade.d.ts +14 -0
  48. package/dist/core/cover-fade.js +38 -0
  49. package/dist/core/index.d.ts +13 -0
  50. package/dist/core/index.js +8 -0
  51. package/dist/core/kepler.d.ts +74 -0
  52. package/dist/core/kepler.js +108 -0
  53. package/dist/core/level-fade.d.ts +66 -0
  54. package/dist/core/level-fade.js +123 -0
  55. package/dist/core/palette.d.ts +15 -0
  56. package/dist/core/palette.js +47 -0
  57. package/dist/env/atmosphere.d.ts +129 -0
  58. package/dist/env/atmosphere.js +707 -0
  59. package/dist/env/cloud-field.d.ts +44 -0
  60. package/dist/env/cloud-field.js +111 -0
  61. package/dist/env/environment.d.ts +217 -0
  62. package/dist/env/environment.js +441 -0
  63. package/dist/env/frame-block.d.ts +29 -0
  64. package/dist/env/frame-block.js +152 -0
  65. package/dist/env/glsl.d.ts +35 -0
  66. package/dist/env/glsl.js +246 -0
  67. package/dist/env/index.d.ts +13 -0
  68. package/dist/env/index.js +9 -0
  69. package/dist/env/sky.d.ts +48 -0
  70. package/dist/env/sky.js +227 -0
  71. package/dist/env/sun.d.ts +31 -0
  72. package/dist/env/sun.js +42 -0
  73. package/dist/gen-arch/build.d.ts +17 -0
  74. package/dist/gen-arch/build.js +414 -0
  75. package/dist/gen-arch/damage/damaged.d.ts +44 -0
  76. package/dist/gen-arch/damage/damaged.js +1119 -0
  77. package/dist/gen-arch/damage/fall-material.d.ts +10 -0
  78. package/dist/gen-arch/damage/fall-material.js +47 -0
  79. package/dist/gen-arch/damage/fall.d.ts +78 -0
  80. package/dist/gen-arch/damage/fall.js +797 -0
  81. package/dist/gen-arch/damage/rubble.d.ts +22 -0
  82. package/dist/gen-arch/damage/rubble.js +188 -0
  83. package/dist/gen-arch/index.d.ts +25 -0
  84. package/dist/gen-arch/index.js +16 -0
  85. package/dist/gen-arch/interior/interior-plan.d.ts +114 -0
  86. package/dist/gen-arch/interior/interior-plan.js +615 -0
  87. package/dist/gen-arch/interior/interior.d.ts +97 -0
  88. package/dist/gen-arch/interior/interior.js +966 -0
  89. package/dist/gen-arch/structure/building-shader.d.ts +25 -0
  90. package/dist/gen-arch/structure/building-shader.js +946 -0
  91. package/dist/gen-arch/structure/buildings.d.ts +248 -0
  92. package/dist/gen-arch/structure/buildings.js +294 -0
  93. package/dist/gen-arch/structure/dims.d.ts +77 -0
  94. package/dist/gen-arch/structure/dims.js +39 -0
  95. package/dist/gen-arch/structure/distant.d.ts +62 -0
  96. package/dist/gen-arch/structure/distant.js +316 -0
  97. package/dist/gen-arch/structure/env-slots.d.ts +18 -0
  98. package/dist/gen-arch/structure/env-slots.js +47 -0
  99. package/dist/gen-arch/structure/facade.d.ts +193 -0
  100. package/dist/gen-arch/structure/facade.js +159 -0
  101. package/dist/gen-arch/structure/parts.d.ts +31 -0
  102. package/dist/gen-arch/structure/parts.js +69 -0
  103. package/dist/gen-arch/structure/roof.d.ts +76 -0
  104. package/dist/gen-arch/structure/roof.js +568 -0
  105. package/dist/gen-arch/structure/structure-material.d.ts +23 -0
  106. package/dist/gen-arch/structure/structure-material.js +55 -0
  107. package/dist/gen-arch/structure/writer.d.ts +94 -0
  108. package/dist/gen-arch/structure/writer.js +195 -0
  109. package/dist/gen-core/cell.d.ts +138 -0
  110. package/dist/gen-core/cell.js +150 -0
  111. package/dist/gen-core/cube-sphere.d.ts +57 -0
  112. package/dist/gen-core/cube-sphere.js +159 -0
  113. package/dist/gen-core/field.d.ts +55 -0
  114. package/dist/gen-core/field.js +154 -0
  115. package/dist/gen-core/geometry.d.ts +31 -0
  116. package/dist/gen-core/geometry.js +231 -0
  117. package/dist/gen-core/hash.d.ts +18 -0
  118. package/dist/gen-core/hash.js +58 -0
  119. package/dist/gen-core/height-field.d.ts +33 -0
  120. package/dist/gen-core/height-field.js +137 -0
  121. package/dist/gen-core/index.d.ts +22 -0
  122. package/dist/gen-core/index.js +17 -0
  123. package/dist/gen-core/instance-cells.d.ts +37 -0
  124. package/dist/gen-core/instance-cells.js +72 -0
  125. package/dist/gen-core/near-scatter.d.ts +56 -0
  126. package/dist/gen-core/near-scatter.js +120 -0
  127. package/dist/gen-core/noise.d.ts +23 -0
  128. package/dist/gen-core/noise.js +72 -0
  129. package/dist/gen-core/occupancy.d.ts +21 -0
  130. package/dist/gen-core/occupancy.js +104 -0
  131. package/dist/gen-core/sphere-patch.d.ts +138 -0
  132. package/dist/gen-core/sphere-patch.js +544 -0
  133. package/dist/gen-core/strip-surface.d.ts +34 -0
  134. package/dist/gen-core/strip-surface.js +246 -0
  135. package/dist/gen-core/strip.d.ts +102 -0
  136. package/dist/gen-core/strip.js +817 -0
  137. package/dist/gen-ground/env-slots.d.ts +48 -0
  138. package/dist/gen-ground/env-slots.js +78 -0
  139. package/dist/gen-ground/ground.d.ts +78 -0
  140. package/dist/gen-ground/ground.js +208 -0
  141. package/dist/gen-ground/index.d.ts +9 -0
  142. package/dist/gen-ground/index.js +7 -0
  143. package/dist/gen-ground/markings.d.ts +46 -0
  144. package/dist/gen-ground/markings.js +124 -0
  145. package/dist/gen-ground/materials.d.ts +18 -0
  146. package/dist/gen-ground/materials.js +22 -0
  147. package/dist/gen-ground/terrain-shader.d.ts +5 -0
  148. package/dist/gen-ground/terrain-shader.js +151 -0
  149. package/dist/gen-mesh/bare-shapes.d.ts +194 -0
  150. package/dist/gen-mesh/bare-shapes.js +596 -0
  151. package/dist/gen-mesh/bisect-surface.d.ts +47 -0
  152. package/dist/gen-mesh/bisect-surface.js +261 -0
  153. package/dist/gen-mesh/box.d.ts +18 -0
  154. package/dist/gen-mesh/box.js +2 -0
  155. package/dist/gen-mesh/cell-morph-mesh.d.ts +52 -0
  156. package/dist/gen-mesh/cell-morph-mesh.js +258 -0
  157. package/dist/gen-mesh/cell-surface-mesh.d.ts +32 -0
  158. package/dist/gen-mesh/cell-surface-mesh.js +140 -0
  159. package/dist/gen-mesh/chunk-mesh.d.ts +25 -0
  160. package/dist/gen-mesh/chunk-mesh.js +112 -0
  161. package/dist/gen-mesh/drape-mesh.d.ts +36 -0
  162. package/dist/gen-mesh/drape-mesh.js +98 -0
  163. package/dist/gen-mesh/height-field-mesh.d.ts +14 -0
  164. package/dist/gen-mesh/height-field-mesh.js +98 -0
  165. package/dist/gen-mesh/index.d.ts +26 -0
  166. package/dist/gen-mesh/index.js +15 -0
  167. package/dist/gen-mesh/line-mesh.d.ts +25 -0
  168. package/dist/gen-mesh/line-mesh.js +62 -0
  169. package/dist/gen-mesh/mesh-builder.d.ts +115 -0
  170. package/dist/gen-mesh/mesh-builder.js +315 -0
  171. package/dist/gen-mesh/packed-mesh.d.ts +53 -0
  172. package/dist/gen-mesh/packed-mesh.js +205 -0
  173. package/dist/gen-mesh/prism-mesh.d.ts +33 -0
  174. package/dist/gen-mesh/prism-mesh.js +176 -0
  175. package/dist/gen-mesh/rig-mesh.d.ts +9 -0
  176. package/dist/gen-mesh/rig-mesh.js +135 -0
  177. package/dist/gen-mesh/strip-mesh.d.ts +45 -0
  178. package/dist/gen-mesh/strip-mesh.js +258 -0
  179. package/dist/gen-plan/drain.d.ts +58 -0
  180. package/dist/gen-plan/drain.js +270 -0
  181. package/dist/gen-plan/grid.d.ts +37 -0
  182. package/dist/gen-plan/grid.js +182 -0
  183. package/dist/gen-plan/horizon.d.ts +50 -0
  184. package/dist/gen-plan/horizon.js +185 -0
  185. package/dist/gen-plan/index.d.ts +15 -0
  186. package/dist/gen-plan/index.js +13 -0
  187. package/dist/gen-plan/line-tiles.d.ts +35 -0
  188. package/dist/gen-plan/line-tiles.js +190 -0
  189. package/dist/gen-plan/lines.d.ts +31 -0
  190. package/dist/gen-plan/lines.js +183 -0
  191. package/dist/gen-plan/plots.d.ts +40 -0
  192. package/dist/gen-plan/plots.js +282 -0
  193. package/dist/gen-plan/route.d.ts +55 -0
  194. package/dist/gen-plan/route.js +297 -0
  195. package/dist/gen-plan/sites.d.ts +32 -0
  196. package/dist/gen-plan/sites.js +209 -0
  197. package/dist/gen-tex/code-stamp.d.ts +31 -0
  198. package/dist/gen-tex/code-stamp.js +137 -0
  199. package/dist/gen-tex/index.d.ts +7 -0
  200. package/dist/gen-tex/index.js +5 -0
  201. package/dist/gen-tex/light-horizon.d.ts +47 -0
  202. package/dist/gen-tex/light-horizon.js +180 -0
  203. package/dist/gen-tex/textures.d.ts +8 -0
  204. package/dist/gen-tex/textures.js +49 -0
  205. package/dist/gen-tex/value-textures.d.ts +46 -0
  206. package/dist/gen-tex/value-textures.js +102 -0
  207. package/dist/gen-vegetation/env-slots.d.ts +20 -0
  208. package/dist/gen-vegetation/env-slots.js +29 -0
  209. package/dist/gen-vegetation/index.d.ts +8 -0
  210. package/dist/gen-vegetation/index.js +7 -0
  211. package/dist/gen-vegetation/materials.d.ts +7 -0
  212. package/dist/gen-vegetation/materials.js +17 -0
  213. package/dist/gen-vegetation/planting.d.ts +170 -0
  214. package/dist/gen-vegetation/planting.js +363 -0
  215. package/dist/gen-vegetation/tree-shader.d.ts +23 -0
  216. package/dist/gen-vegetation/tree-shader.js +229 -0
  217. package/dist/gen-vegetation/trees.d.ts +59 -0
  218. package/dist/gen-vegetation/trees.js +329 -0
  219. package/dist/gpu/device.d.ts +286 -0
  220. package/dist/gpu/device.js +1157 -0
  221. package/dist/gpu/gl.d.ts +134 -0
  222. package/dist/gpu/gl.js +276 -0
  223. package/dist/gpu/index.d.ts +4 -0
  224. package/dist/gpu/index.js +3 -0
  225. package/dist/index.d.ts +11 -0
  226. package/dist/index.js +13 -0
  227. package/dist/motion/graph.d.ts +244 -0
  228. package/dist/motion/graph.js +739 -0
  229. package/dist/motion/index.d.ts +8 -0
  230. package/dist/motion/index.js +8 -0
  231. package/dist/motion/pose-ops.d.ts +30 -0
  232. package/dist/motion/pose-ops.js +232 -0
  233. package/dist/motion/reach.d.ts +45 -0
  234. package/dist/motion/reach.js +264 -0
  235. package/dist/motion/skeleton.d.ts +49 -0
  236. package/dist/motion/skeleton.js +99 -0
  237. package/dist/platform/byte-store.d.ts +21 -0
  238. package/dist/platform/byte-store.js +137 -0
  239. package/dist/platform/canvas.d.ts +29 -0
  240. package/dist/platform/canvas.js +76 -0
  241. package/dist/platform/context-loss.d.ts +8 -0
  242. package/dist/platform/context-loss.js +17 -0
  243. package/dist/platform/free-input.d.ts +51 -0
  244. package/dist/platform/free-input.js +100 -0
  245. package/dist/platform/index.d.ts +18 -0
  246. package/dist/platform/index.js +10 -0
  247. package/dist/platform/input.d.ts +48 -0
  248. package/dist/platform/input.js +117 -0
  249. package/dist/platform/keys.d.ts +12 -0
  250. package/dist/platform/keys.js +29 -0
  251. package/dist/platform/loop.d.ts +41 -0
  252. package/dist/platform/loop.js +84 -0
  253. package/dist/platform/walk-input.d.ts +74 -0
  254. package/dist/platform/walk-input.js +226 -0
  255. package/dist/platform/worker.d.ts +51 -0
  256. package/dist/platform/worker.js +170 -0
  257. package/dist/render/bone-instances.d.ts +24 -0
  258. package/dist/render/bone-instances.js +74 -0
  259. package/dist/render/cells.d.ts +70 -0
  260. package/dist/render/cells.js +144 -0
  261. package/dist/render/glsl.d.ts +66 -0
  262. package/dist/render/glsl.js +173 -0
  263. package/dist/render/index.d.ts +26 -0
  264. package/dist/render/index.js +16 -0
  265. package/dist/render/instance-sets.d.ts +97 -0
  266. package/dist/render/instance-sets.js +241 -0
  267. package/dist/render/near-instances.d.ts +75 -0
  268. package/dist/render/near-instances.js +219 -0
  269. package/dist/render/particles.d.ts +63 -0
  270. package/dist/render/particles.js +215 -0
  271. package/dist/render/pieces.d.ts +57 -0
  272. package/dist/render/pieces.js +151 -0
  273. package/dist/render/point-lights.d.ts +97 -0
  274. package/dist/render/point-lights.js +243 -0
  275. package/dist/render/renderer.d.ts +447 -0
  276. package/dist/render/renderer.js +1100 -0
  277. package/dist/render/rig.d.ts +74 -0
  278. package/dist/render/rig.js +576 -0
  279. package/dist/render/shadow-areas.d.ts +49 -0
  280. package/dist/render/shadow-areas.js +125 -0
  281. package/dist/render/shadow-glsl.d.ts +12 -0
  282. package/dist/render/shadow-glsl.js +146 -0
  283. package/dist/render/transient.d.ts +61 -0
  284. package/dist/render/transient.js +213 -0
  285. package/dist/render/value-glsl.d.ts +17 -0
  286. package/dist/render/value-glsl.js +208 -0
  287. package/dist/render/value-layers.d.ts +180 -0
  288. package/dist/render/value-layers.js +333 -0
  289. package/dist/runtime/atmosphere.d.ts +37 -0
  290. package/dist/runtime/atmosphere.js +304 -0
  291. package/dist/runtime/cloud-shell.d.ts +29 -0
  292. package/dist/runtime/cloud-shell.js +158 -0
  293. package/dist/runtime/engine.d.ts +155 -0
  294. package/dist/runtime/engine.js +305 -0
  295. package/dist/runtime/environment-link.d.ts +22 -0
  296. package/dist/runtime/environment-link.js +49 -0
  297. package/dist/runtime/index.d.ts +13 -0
  298. package/dist/runtime/index.js +12 -0
  299. package/dist/runtime/precipitation-glsl.d.ts +2 -0
  300. package/dist/runtime/precipitation-glsl.js +70 -0
  301. package/dist/runtime/precipitation.d.ts +11 -0
  302. package/dist/runtime/precipitation.js +78 -0
  303. package/dist/runtime/sky.d.ts +30 -0
  304. package/dist/runtime/sky.js +114 -0
  305. package/dist/runtime/streaming.d.ts +245 -0
  306. package/dist/runtime/streaming.js +602 -0
  307. package/dist/sim/agenda.d.ts +167 -0
  308. package/dist/sim/agenda.js +425 -0
  309. package/dist/sim/bytes.d.ts +34 -0
  310. package/dist/sim/bytes.js +125 -0
  311. package/dist/sim/destruction/apply.d.ts +59 -0
  312. package/dist/sim/destruction/apply.js +243 -0
  313. package/dist/sim/destruction/cell-states.d.ts +54 -0
  314. package/dist/sim/destruction/cell-states.js +198 -0
  315. package/dist/sim/destruction/index.d.ts +11 -0
  316. package/dist/sim/destruction/index.js +10 -0
  317. package/dist/sim/destruction/int-geometry.d.ts +17 -0
  318. package/dist/sim/destruction/int-geometry.js +131 -0
  319. package/dist/sim/destruction/pick.d.ts +13 -0
  320. package/dist/sim/destruction/pick.js +59 -0
  321. package/dist/sim/destruction/rubble.d.ts +8 -0
  322. package/dist/sim/destruction/rubble.js +159 -0
  323. package/dist/sim/destruction/state.d.ts +15 -0
  324. package/dist/sim/destruction/state.js +83 -0
  325. package/dist/sim/destruction/structure.d.ts +30 -0
  326. package/dist/sim/destruction/structure.js +139 -0
  327. package/dist/sim/events.d.ts +37 -0
  328. package/dist/sim/events.js +106 -0
  329. package/dist/sim/fixed.d.ts +21 -0
  330. package/dist/sim/fixed.js +64 -0
  331. package/dist/sim/flow-probe.d.ts +58 -0
  332. package/dist/sim/flow-probe.js +158 -0
  333. package/dist/sim/flow.d.ts +257 -0
  334. package/dist/sim/flow.js +967 -0
  335. package/dist/sim/index.d.ts +28 -0
  336. package/dist/sim/index.js +20 -0
  337. package/dist/sim/interlock.d.ts +47 -0
  338. package/dist/sim/interlock.js +252 -0
  339. package/dist/sim/movers.d.ts +228 -0
  340. package/dist/sim/movers.js +1083 -0
  341. package/dist/sim/nav.d.ts +72 -0
  342. package/dist/sim/nav.js +292 -0
  343. package/dist/sim/paths.d.ts +80 -0
  344. package/dist/sim/paths.js +197 -0
  345. package/dist/sim/regions.d.ts +87 -0
  346. package/dist/sim/regions.js +517 -0
  347. package/dist/sim/simulation.d.ts +114 -0
  348. package/dist/sim/simulation.js +291 -0
  349. package/dist/sim/states.d.ts +23 -0
  350. package/dist/sim/states.js +54 -0
  351. package/dist/sim/table.d.ts +49 -0
  352. package/dist/sim/table.js +126 -0
  353. package/dist/sim/zones.d.ts +11 -0
  354. package/dist/sim/zones.js +196 -0
  355. package/dist/tools/collision-lines.d.ts +12 -0
  356. package/dist/tools/collision-lines.js +50 -0
  357. package/dist/tools/data-view-glsl.d.ts +3 -0
  358. package/dist/tools/data-view-glsl.js +63 -0
  359. package/dist/tools/data-view-layers.d.ts +20 -0
  360. package/dist/tools/data-view-layers.js +60 -0
  361. package/dist/tools/debug-view.d.ts +30 -0
  362. package/dist/tools/debug-view.js +4 -0
  363. package/dist/tools/index.d.ts +10 -0
  364. package/dist/tools/index.js +7 -0
  365. package/dist/tools/mesh-checks.d.ts +67 -0
  366. package/dist/tools/mesh-checks.js +188 -0
  367. package/dist/tools/profile.d.ts +85 -0
  368. package/dist/tools/profile.js +173 -0
  369. package/dist/world/cell-cache.d.ts +32 -0
  370. package/dist/world/cell-cache.js +60 -0
  371. package/dist/world/cell-format.d.ts +25 -0
  372. package/dist/world/cell-format.js +232 -0
  373. package/dist/world/collide.d.ts +192 -0
  374. package/dist/world/collide.js +822 -0
  375. package/dist/world/index.d.ts +16 -0
  376. package/dist/world/index.js +12 -0
  377. package/dist/world/mesh-solids.d.ts +48 -0
  378. package/dist/world/mesh-solids.js +169 -0
  379. package/dist/world/pick.d.ts +34 -0
  380. package/dist/world/pick.js +177 -0
  381. package/dist/world/providers.d.ts +66 -0
  382. package/dist/world/providers.js +83 -0
  383. package/dist/world/sphere.d.ts +69 -0
  384. package/dist/world/sphere.js +271 -0
  385. package/dist/world/streaming.d.ts +288 -0
  386. package/dist/world/streaming.js +801 -0
  387. package/dist/world/walker.d.ts +145 -0
  388. package/dist/world/walker.js +502 -0
  389. package/docs/architecture.md +111 -0
  390. package/docs/cameras.md +302 -0
  391. package/docs/concepts.md +123 -0
  392. package/docs/destruction.md +127 -0
  393. package/docs/frames.md +199 -0
  394. package/docs/generators.md +575 -0
  395. package/docs/getting-started.md +123 -0
  396. package/docs/headless.md +50 -0
  397. package/docs/motion.md +160 -0
  398. package/docs/planet.md +152 -0
  399. package/docs/recipes.md +521 -0
  400. package/docs/reference.md +364 -0
  401. package/docs/rendering.md +823 -0
  402. package/docs/rigs.md +203 -0
  403. package/docs/simulation.md +235 -0
  404. package/docs/streaming.md +590 -0
  405. package/docs/system.md +166 -0
  406. package/docs/tools.md +175 -0
  407. package/docs/walking.md +262 -0
  408. package/package.json +131 -3
@@ -0,0 +1,28 @@
1
+ export { ByteReader, ByteWriter, hashBytes } from './bytes.ts';
2
+ export { EntityTable } from './table.ts';
3
+ export type { ColumnSpec, ColumnType, Columns } from './table.ts';
4
+ export { EventQueue } from './events.ts';
5
+ export type { SimData, SimEvent, SimValue } from './events.ts';
6
+ export { Simulation } from './simulation.ts';
7
+ export type { Command, CommandHandler, SimState, SimulationOptions, System } from './simulation.ts';
8
+ export { approachSpeed, brakeSpeed, isqrt, mm, mmPerTick, mmPerTick2, stoppingDistance } from './fixed.ts';
9
+ export { PathSet } from './paths.ts';
10
+ export type { Path, PathDef, PathStop } from './paths.ts';
11
+ export { NavGraph } from './nav.ts';
12
+ export type { NavEdgeInput, NavGraphInput, RouteOptions } from './nav.ts';
13
+ export { MOVER_STATE, Movers, POSE_STRIDE, TRANSFORM_STRIDE, capsuleDist2 } from './movers.ts';
14
+ export type { Capsule, CollisionMode, KnownObstacles, MoversOptions, SpawnOptions } from './movers.ts';
15
+ export { buildZoneIntervals } from './zones.ts';
16
+ export type { ZoneIntervals } from './zones.ts';
17
+ export { Interlock } from './interlock.ts';
18
+ export type { InterlockOptions, SharedArea } from './interlock.ts';
19
+ export { StateMachine } from './states.ts';
20
+ export type { StateDef } from './states.ts';
21
+ export { Agendas } from './agenda.ts';
22
+ export type { AgendaActivity, AgendaEntity, AgendaOptions, AgendaPlace } from './agenda.ts';
23
+ export { RegionNav } from './regions.ts';
24
+ export type { RegionNavOptions } from './regions.ts';
25
+ export { FLOW_STATE, FlowNetwork } from './flow.ts';
26
+ export type { FlowCensus, FlowMoverOptions, FlowOptions, FlowTrip } from './flow.ts';
27
+ export { createFlowProbe, flowProbeLine } from './flow-probe.ts';
28
+ export type { FlowProbe, FlowProbeOptions, FlowProbeResult } from './flow-probe.ts';
@@ -0,0 +1,20 @@
1
+ // Layer 5, sim: fixed-step simulation (determinism tier A). Tick counter, command log, systems, snapshots and the
2
+ // state hash; dense entity tables with own ids; the event queue; paths, the navigation graph with A*, movers with
3
+ // stops and collision modes (following, conflict zones, obstacles, crowd avoidance), shared areas between mover sets,
4
+ // agendas and a state machine; a coarse queue model over a whole network with individual movers in a focus area,
5
+ // and a route search on two levels (regions and gates) with a cache. Imports only base, core and gen-core: it runs headless in plain Node.
6
+ export { ByteReader, ByteWriter, hashBytes } from './bytes.js';
7
+ export { EntityTable } from './table.js';
8
+ export { EventQueue } from './events.js';
9
+ export { Simulation } from './simulation.js';
10
+ export { approachSpeed, brakeSpeed, isqrt, mm, mmPerTick, mmPerTick2, stoppingDistance } from './fixed.js';
11
+ export { PathSet } from './paths.js';
12
+ export { NavGraph } from './nav.js';
13
+ export { MOVER_STATE, Movers, POSE_STRIDE, TRANSFORM_STRIDE, capsuleDist2 } from './movers.js';
14
+ export { buildZoneIntervals } from './zones.js';
15
+ export { Interlock } from './interlock.js';
16
+ export { StateMachine } from './states.js';
17
+ export { Agendas } from './agenda.js';
18
+ export { RegionNav } from './regions.js';
19
+ export { FLOW_STATE, FlowNetwork } from './flow.js';
20
+ export { createFlowProbe, flowProbeLine } from './flow-probe.js';
@@ -0,0 +1,47 @@
1
+ import type { Capsule, Movers } from './movers.ts';
2
+ import type { Path } from './paths.ts';
3
+ import type { Simulation } from './simulation.ts';
4
+ export interface SharedArea extends Capsule {
5
+ /** The side with right of way on this area. */
6
+ priority: 0 | 1;
7
+ }
8
+ export interface InterlockOptions {
9
+ areas: readonly SharedArea[];
10
+ /** Distance before an area within which a priority entity counts as about to enter, metres. Default 3. */
11
+ approach?: number;
12
+ }
13
+ interface AreaIntervals {
14
+ s0: Int32Array;
15
+ s1: Int32Array;
16
+ area: Int32Array;
17
+ }
18
+ export declare class Interlock {
19
+ readonly name: string;
20
+ private readonly areas;
21
+ private readonly priority;
22
+ private readonly approach;
23
+ private readonly sides;
24
+ private readonly intervals;
25
+ private readonly grid;
26
+ /** Per side and area: entities on it, entities close before it, entities that can no longer stop before it. */
27
+ readonly on: [Int32Array, Int32Array];
28
+ readonly near: [Int32Array, Int32Array];
29
+ readonly committed: [Int32Array, Int32Array];
30
+ constructor(name: string, options: InterlockOptions);
31
+ get areaCount(): number;
32
+ /** Links a mover set as side 0 or 1. Its collision must be `static`, `lanes` or `agents`. */
33
+ attach(movers: Movers, side: 0 | 1): void;
34
+ /** Drops the cached stretches of a released path. */
35
+ forget(side: 0 | 1, path: number): void;
36
+ /** Drops every cached stretch of a side (its paths were replaced, e.g. by loading a snapshot). */
37
+ forgetAll(side: 0 | 1): void;
38
+ /** Area stretches along a path of one side, mm; the body half width of that set is added to every area. */
39
+ stretches(side: 0 | 1, p: Path): AreaIntervals;
40
+ /** Does no grid cell under segment `seg` of a path hold an area? (Cells of its rounded bounding box, 1 mm wider.) */
41
+ private segmentEmpty;
42
+ /** Recounts who is on, near and committed to every area. Register it before both movers systems. */
43
+ readonly system: (_sim: Simulation) => void;
44
+ /** Free distance (mm) for row `r` of `movers` on side `side`: how far it may go before the next area it must wait at. */
45
+ limitFor(movers: Movers, side: 0 | 1, r: number, p: Path, reach: number): number;
46
+ }
47
+ export {};
@@ -0,0 +1,252 @@
1
+ // Shared areas between two mover sets (side 0 and side 1), for places where their paths cross: each area is a capsule
2
+ // and one side has priority on it. The rules, all from the state at the start of the tick:
3
+ //
4
+ // - The yielding side does not enter while somebody of the priority side is on the area, close before it
5
+ // (`approach`) or can no longer stop before it, unless it can no longer stop itself.
6
+ // - The priority side does not enter while somebody of the yielding side is on the area or can no longer stop
7
+ // before it (it is committed).
8
+ //
9
+ // The yielding side only ever waits for entities that are there or about to be; the priority side only for ones
10
+ // that are already through the door. Nobody waits for a waiting entity of the other side, so the two sides cannot
11
+ // wait for each other in a circle. Occupancy is derived from positions each tick: the interlock adds nothing to
12
+ // snapshots. Register `system` before the systems of both mover sets.
13
+ import { mm, stoppingDistance } from './fixed.js';
14
+ import { MOVER_STATE, capsuleDist2 } from './movers.js';
15
+ const STEP = 250;
16
+ const HOLD = 500;
17
+ const NO_LIMIT = 0x7fffffff;
18
+ const CELL = 16000;
19
+ /**
20
+ * Distance within which an entity at speed `v` can no longer stop before a point: its next move is at least
21
+ * `v − decel`, and braking from there takes `stoppingDistance(v − decel)`. An entity held back by `limitFor` keeps
22
+ * more than that (the limit leaves `HOLD`), so a held entity never turns committed on its own.
23
+ */
24
+ function committedWithin(v, decel) {
25
+ return v > 0 ? stoppingDistance(Math.max(0, v - decel), decel) : 0;
26
+ }
27
+ export class Interlock {
28
+ name;
29
+ areas;
30
+ priority;
31
+ approach;
32
+ sides = [null, null];
33
+ intervals = [new Map(), new Map()];
34
+ grid = new Map();
35
+ /** Per side and area: entities on it, entities close before it, entities that can no longer stop before it. */
36
+ on;
37
+ near;
38
+ committed;
39
+ constructor(name, options) {
40
+ this.name = name;
41
+ const n = options.areas.length;
42
+ this.areas = new Int32Array(n * 5);
43
+ this.priority = new Uint8Array(n);
44
+ options.areas.forEach((a, i) => {
45
+ this.areas.set([mm(a.ax), mm(a.az), mm(a.bx), mm(a.bz), mm(a.radius)], i * 5);
46
+ this.priority[i] = a.priority;
47
+ const r = mm(a.radius) + 3000;
48
+ for (let cx = Math.floor((Math.min(mm(a.ax), mm(a.bx)) - r) / CELL); cx <= Math.floor((Math.max(mm(a.ax), mm(a.bx)) + r) / CELL); cx++) {
49
+ for (let cz = Math.floor((Math.min(mm(a.az), mm(a.bz)) - r) / CELL); cz <= Math.floor((Math.max(mm(a.az), mm(a.bz)) + r) / CELL); cz++) {
50
+ const k = (cx + 0x8000) * 0x10000 + (cz + 0x8000);
51
+ const list = this.grid.get(k);
52
+ if (list)
53
+ list.push(i);
54
+ else
55
+ this.grid.set(k, [i]);
56
+ }
57
+ }
58
+ });
59
+ this.approach = mm(options.approach ?? 3);
60
+ this.on = [new Int32Array(n), new Int32Array(n)];
61
+ this.near = [new Int32Array(n), new Int32Array(n)];
62
+ this.committed = [new Int32Array(n), new Int32Array(n)];
63
+ }
64
+ get areaCount() {
65
+ return this.priority.length;
66
+ }
67
+ /** Links a mover set as side 0 or 1. Its collision must be `static`, `lanes` or `agents`. */
68
+ attach(movers, side) {
69
+ this.sides[side] = movers;
70
+ movers.interlock = { il: this, side };
71
+ }
72
+ /** Drops the cached stretches of a released path. */
73
+ forget(side, path) {
74
+ this.intervals[side].delete(path);
75
+ }
76
+ /** Drops every cached stretch of a side (its paths were replaced, e.g. by loading a snapshot). */
77
+ forgetAll(side) {
78
+ this.intervals[side].clear();
79
+ }
80
+ /** Area stretches along a path of one side, mm; the body half width of that set is added to every area. */
81
+ stretches(side, p) {
82
+ let iv = this.intervals[side].get(p.id);
83
+ if (iv)
84
+ return iv;
85
+ const movers = this.sides[side];
86
+ const half = movers.halfWidth;
87
+ const s0 = [];
88
+ const s1 = [];
89
+ const area = [];
90
+ const pt = [0, 0];
91
+ // Areas open along the walk (with where they opened) and areas under the current point. Few at a time, so plain
92
+ // arrays; the result is sorted at the end, so the order of closing does not matter.
93
+ const openA = [];
94
+ const openS = [];
95
+ const inside = [];
96
+ // Segments whose grid cells hold no area: every sample on them is outside all areas, so after the first one
97
+ // (which closes what is open) the walk jumps to the next segment. Same samples, same result, far fewer lookups.
98
+ let seg = 0;
99
+ let segChecked = -1;
100
+ let segEmpty = false;
101
+ for (let d = 0;; d += STEP) {
102
+ const u = Math.min(d, p.length);
103
+ if (u < p.length) {
104
+ while (seg + 1 < p.segments && p.segStart[seg + 1] <= u)
105
+ seg++;
106
+ if (segChecked !== seg) {
107
+ segChecked = seg;
108
+ segEmpty = this.segmentEmpty(p, seg);
109
+ }
110
+ if (segEmpty) {
111
+ for (let k = 0; k < openA.length; k++) {
112
+ s0.push(openS[k]);
113
+ s1.push(u);
114
+ area.push(openA[k]);
115
+ }
116
+ openA.length = 0;
117
+ openS.length = 0;
118
+ const end = Math.min(p.segStart[seg + 1], p.length);
119
+ while (d + STEP < end)
120
+ d += STEP;
121
+ continue;
122
+ }
123
+ }
124
+ movers.paths.pointAt(p, u, pt);
125
+ const x = Math.round(pt[0] * 1000);
126
+ const z = Math.round(pt[1] * 1000);
127
+ const cand = this.grid.get((Math.floor(x / CELL) + 0x8000) * 0x10000 + (Math.floor(z / CELL) + 0x8000));
128
+ inside.length = 0;
129
+ if (cand) {
130
+ for (const a of cand) {
131
+ const o = a * 5;
132
+ const r = this.areas[o + 4] + half;
133
+ if (capsuleDist2(x, z, this.areas[o], this.areas[o + 1], this.areas[o + 2], this.areas[o + 3]) < r * r)
134
+ inside.push(a);
135
+ }
136
+ }
137
+ for (const a of inside) {
138
+ if (openA.indexOf(a) < 0) {
139
+ openA.push(a);
140
+ openS.push(u);
141
+ }
142
+ }
143
+ for (let k = openA.length - 1; k >= 0; k--) {
144
+ if (inside.indexOf(openA[k]) >= 0)
145
+ continue;
146
+ s0.push(openS[k]);
147
+ s1.push(u);
148
+ area.push(openA[k]);
149
+ openA.splice(k, 1);
150
+ openS.splice(k, 1);
151
+ }
152
+ if (u >= p.length)
153
+ break;
154
+ }
155
+ for (let k = 0; k < openA.length; k++) {
156
+ s0.push(openS[k]);
157
+ s1.push(p.length);
158
+ area.push(openA[k]);
159
+ }
160
+ const order = s0.map((_, i) => i).sort((a, b) => s0[a] - s0[b] || area[a] - area[b]);
161
+ iv = { s0: Int32Array.from(order, (i) => s0[i]), s1: Int32Array.from(order, (i) => s1[i]), area: Int32Array.from(order, (i) => area[i]) };
162
+ this.intervals[side].set(p.id, iv);
163
+ return iv;
164
+ }
165
+ /** Does no grid cell under segment `seg` of a path hold an area? (Cells of its rounded bounding box, 1 mm wider.) */
166
+ segmentEmpty(p, seg) {
167
+ const a = seg;
168
+ const b = (seg + 1) % p.xs.length;
169
+ const ax = Math.round(p.xs[a] * 1000);
170
+ const az = Math.round(p.zs[a] * 1000);
171
+ const bx = Math.round(p.xs[b] * 1000);
172
+ const bz = Math.round(p.zs[b] * 1000);
173
+ const c0 = Math.floor((Math.min(ax, bx) - 1) / CELL);
174
+ const c1 = Math.floor((Math.max(ax, bx) + 1) / CELL);
175
+ const r0 = Math.floor((Math.min(az, bz) - 1) / CELL);
176
+ const r1 = Math.floor((Math.max(az, bz) + 1) / CELL);
177
+ for (let cx = c0; cx <= c1; cx++)
178
+ for (let cz = r0; cz <= r1; cz++)
179
+ if (this.grid.has((cx + 0x8000) * 0x10000 + (cz + 0x8000)))
180
+ return false;
181
+ return true;
182
+ }
183
+ /** Recounts who is on, near and committed to every area. Register it before both movers systems. */
184
+ system = (_sim) => {
185
+ for (const side of [0, 1]) {
186
+ this.on[side].fill(0);
187
+ this.near[side].fill(0);
188
+ this.committed[side].fill(0);
189
+ const m = this.sides[side];
190
+ if (!m)
191
+ continue;
192
+ const c = m.table.col;
193
+ for (let r = 0; r < m.count; r++) {
194
+ const p = m.paths.get(c.path[r]);
195
+ const iv = this.stretches(side, p);
196
+ if (iv.s0.length === 0)
197
+ continue;
198
+ const [rear, front] = m.body(r);
199
+ const moving = c.state[r] === MOVER_STATE.moving;
200
+ const stop = moving ? committedWithin(c.speed[r], c.decel[r]) : 0;
201
+ for (let lap = 0; lap < (p.loop ? 2 : 1); lap++) {
202
+ const off = lap * p.length;
203
+ for (let i = 0; i < iv.s0.length; i++) {
204
+ const a0 = iv.s0[i] + off;
205
+ const a1 = iv.s1[i] + off;
206
+ const a = iv.area[i];
207
+ if (a1 >= rear && a0 <= front)
208
+ this.on[side][a]++;
209
+ else if (moving && a0 > front) {
210
+ if (a0 - front <= this.approach)
211
+ this.near[side][a]++;
212
+ if (c.speed[r] > 0 && a0 - front <= stop)
213
+ this.committed[side][a]++;
214
+ }
215
+ }
216
+ }
217
+ }
218
+ }
219
+ };
220
+ /** Free distance (mm) for row `r` of `movers` on side `side`: how far it may go before the next area it must wait at. */
221
+ limitFor(movers, side, r, p, reach) {
222
+ const iv = this.stretches(side, p);
223
+ if (iv.s0.length === 0)
224
+ return NO_LIMIT;
225
+ const c = movers.table.col;
226
+ const [rear, front] = movers.body(r);
227
+ const other = (1 - side);
228
+ const stop = committedWithin(c.speed[r], c.decel[r]);
229
+ for (let lap = 0; lap < (p.loop ? 2 : 1); lap++) {
230
+ const off = lap * p.length;
231
+ for (let i = 0; i < iv.s0.length; i++) {
232
+ const a0 = iv.s0[i] + off;
233
+ const a1 = iv.s1[i] + off;
234
+ if (a1 < rear)
235
+ continue;
236
+ if (a0 <= front)
237
+ continue;
238
+ if (a0 - front > reach)
239
+ return NO_LIMIT;
240
+ const a = iv.area[i];
241
+ let blocked;
242
+ if (this.priority[a] === side)
243
+ blocked = this.on[other][a] > 0 || this.committed[other][a] > 0;
244
+ else
245
+ blocked = (this.on[other][a] > 0 || this.near[other][a] > 0 || this.committed[other][a] > 0) && !(c.speed[r] > 0 && a0 - front <= stop);
246
+ if (blocked)
247
+ return Math.max(0, a0 - front - HOLD);
248
+ }
249
+ }
250
+ return NO_LIMIT;
251
+ }
252
+ }
@@ -0,0 +1,228 @@
1
+ import { ByteReader, ByteWriter } from './bytes.ts';
2
+ import type { Interlock } from './interlock.ts';
3
+ import { PathSet } from './paths.ts';
4
+ import type { PathDef } from './paths.ts';
5
+ import type { SimState, Simulation } from './simulation.ts';
6
+ import { EntityTable } from './table.ts';
7
+ export type CollisionMode = 'none' | 'follow' | 'static' | 'agents' | 'lanes';
8
+ export declare const MOVER_STATE: {
9
+ readonly moving: 0;
10
+ readonly dwelling: 1;
11
+ readonly done: 2;
12
+ };
13
+ declare const MOVER_COLUMNS: {
14
+ readonly path: 'i32';
15
+ readonly seg: 'i32';
16
+ /** Distance along the path in mm, and its value one tick earlier (unwrapped, for interpolation). */
17
+ readonly dist: 'i32';
18
+ readonly prev: 'i32';
19
+ /** Speed now and wanted, mm per tick; acceleration and braking, mm per tick². */
20
+ readonly speed: 'i32';
21
+ readonly cruise: 'i32';
22
+ readonly accel: 'i32';
23
+ readonly decel: 'i32';
24
+ /** Distance to keep to the entity ahead, mm (centre to centre). */
25
+ readonly gap: 'i32';
26
+ /** Index of the next stop along the path (equal to the number of stops: the first stop of the next lap). */
27
+ readonly stop: 'i32';
28
+ readonly dwell: 'i32';
29
+ readonly state: 'u8';
30
+ /** Free integer for the app (kind, colour, group). */
31
+ readonly tag: 'i32';
32
+ };
33
+ type MoverColumns = typeof MOVER_COLUMNS;
34
+ export interface SpawnOptions {
35
+ path: number;
36
+ /** Start this far along the path, metres. */
37
+ at?: number;
38
+ /** Cruising speed, m/s. */
39
+ cruise: number;
40
+ /** m/s². Defaults 1 and 2. */
41
+ accel?: number;
42
+ decel?: number;
43
+ /** Distance kept to the entity ahead, metres. Default 2. */
44
+ gap?: number;
45
+ /** Initial speed, m/s. */
46
+ speed?: number;
47
+ tag?: number;
48
+ /** Body reach ahead of and behind the anchor, metres (zones, areas, obstacles). Defaults gap / 4 each. */
49
+ front?: number;
50
+ back?: number;
51
+ /** Body width, metres (obstacles). Default the set's `width`. */
52
+ width?: number;
53
+ }
54
+ /** A capsule: the segment a–b swollen by `radius`, metres. */
55
+ export interface Capsule {
56
+ ax: number;
57
+ az: number;
58
+ bx: number;
59
+ bz: number;
60
+ radius: number;
61
+ }
62
+ /**
63
+ * Known moving obstacles for one tick: flat capsules `ax, az, bx, bz, radius` in metres. It must be a pure function
64
+ * of the tick (a replayed schedule), so that seeking and replaying give the same simulation. Entities do not enter a
65
+ * capsule; one already inside is free to leave it.
66
+ */
67
+ export type KnownObstacles = (tick: number) => ArrayLike<number>;
68
+ export interface MoversOptions {
69
+ hz: number;
70
+ collision?: CollisionMode;
71
+ namespace?: number;
72
+ /** Default body width of the entities, metres (obstacle clearance). Default 1.8. */
73
+ width?: number;
74
+ }
75
+ /** Floats per entity written by `extract`: x, z, direction x, direction z, metres along the path, speed m/s. */
76
+ export declare const TRANSFORM_STRIDE = 6;
77
+ /**
78
+ * Floats per entity written by `extractPose`: the six of `extract`, then the turn rate in rad/s (positive turns
79
+ * right, clockwise seen from above) and the state (`MOVER_STATE`). Enough to animate a rig.
80
+ */
81
+ export declare const POSE_STRIDE = 8;
82
+ export declare class Movers implements SimState {
83
+ readonly name: string;
84
+ readonly hz: number;
85
+ readonly collision: CollisionMode;
86
+ readonly table: EntityTable<MoverColumns>;
87
+ readonly paths: PathSet;
88
+ private readonly features;
89
+ private readonly extended;
90
+ private readonly defaultHalf;
91
+ private follow;
92
+ private order;
93
+ private readonly point;
94
+ private readonly point2;
95
+ private readonly frame;
96
+ /** Static obstacles: flat capsules in mm (ax, az, bx, bz, radius). Simulation state. */
97
+ private obstacles;
98
+ /** Obstacle indices by grid cell (not state: rebuilt when the obstacles change). */
99
+ private obstacleGrid;
100
+ private readonly cache;
101
+ /** Conflict zones (`lanes`): intervals per path and the entity holding each zone (0 = free). */
102
+ private zones;
103
+ private holder;
104
+ private known;
105
+ /** Shared areas with another set. */
106
+ interlock: {
107
+ il: Interlock;
108
+ side: 0 | 1;
109
+ } | null;
110
+ /** Lane groups of the last follow pass: lane → rows sorted by position on it. */
111
+ private laneRows;
112
+ private lanePos;
113
+ constructor(name: string, options: MoversOptions);
114
+ get count(): number;
115
+ /** Default half width of the entities, mm. */
116
+ get halfWidth(): number;
117
+ private get ext();
118
+ /** Adds an entity on a path and returns its id. */
119
+ spawn(o: SpawnOptions): number;
120
+ /** Moves an entity onto another path (no interpolation across the switch). An owned path it leaves is freed. */
121
+ setPath(id: number, path: number, at?: number): void;
122
+ /** Adds a path owned by this entity (freed when it leaves it) and moves the entity onto it. */
123
+ send(id: number, def: PathDef, at?: number): number;
124
+ remove(id: number): void;
125
+ /** State of one entity in app units. */
126
+ info(id: number): {
127
+ state: number;
128
+ path: number;
129
+ along: number;
130
+ speed: number;
131
+ tag: number;
132
+ };
133
+ /**
134
+ * Ticks an entity has waited in a row for a zone, an area or an obstacle (0 when it moves freely or only follows the
135
+ * one ahead). Extended modes only. A ring of queues that all wait on each other never clears by itself; the caller
136
+ * can watch this and move one of them (`setPath`) to break it.
137
+ */
138
+ waited(id: number): number;
139
+ /** Where an entity is now (at the last tick, with its offset), metres. */
140
+ position(id: number): [number, number];
141
+ private mustRow;
142
+ private releaseIfOwned;
143
+ private place;
144
+ private requireExtended;
145
+ /** Adds a static obstacle (a capsule in metres) and returns its index. Entities stop before it. */
146
+ addObstacle(o: Capsule): number;
147
+ get obstacleCount(): number;
148
+ /**
149
+ * Stretches of a path that an entity of the default width cannot pass because of static obstacles, metres along
150
+ * the path. Meant for build time: a path that is blocked is better not used at all, since an entity would stand
151
+ * before the obstacle for ever and everybody behind it too.
152
+ */
153
+ blocked(path: number): {
154
+ from: number;
155
+ to: number;
156
+ }[];
157
+ /** Obstacles by grid cell: every cell a capsule (swollen by the default half width) touches lists its offset. */
158
+ private obstacleCells;
159
+ private pathCache;
160
+ /**
161
+ * Builds the conflict zones of the `lanes` mode from the paths in the set now: where segments of different lanes
162
+ * come closer than `clearance` metres, the stretches on both become one zone. Segments running side by side
163
+ * (within about 18 degrees of parallel or antiparallel, e.g. the two directions of a street) only conflict closer
164
+ * than `parallelClearance`. Returns the number of zones. Call it after adding the network's paths and before the
165
+ * first tick; paths added later have no zones. Defaults 3 and 2 m (bodies about 1.8 m wide; a rigid body cuts the
166
+ * inside of a corner, hence the margin).
167
+ */
168
+ buildZones(options?: {
169
+ clearance?: number;
170
+ parallelClearance?: number;
171
+ }): number;
172
+ get zoneCount(): number;
173
+ /** Zone stretches of a path, metres along it. */
174
+ zonesOf(path: number): {
175
+ from: number;
176
+ to: number;
177
+ zone: number;
178
+ }[];
179
+ /** Known moving obstacles (a replayed schedule). Not state: set it again after setting the simulation up anew. */
180
+ setKnownObstacles(fn: KnownObstacles | null): void;
181
+ /** Body of an entity along its path: rear and front distance (mm), and half the width. For `Interlock`. */
182
+ body(row: number): [number, number, number];
183
+ /** The system: one tick of movement. Register it with `sim.addSystem(name, movers.system)`. */
184
+ readonly system: (sim: Simulation) => void;
185
+ private move;
186
+ /** Free distance (mm) each entity may cover before it gets closer than its gap to the entity ahead on its lane. */
187
+ private computeFollow;
188
+ /** Is anybody but `self` anchored on `lane` between `from` and `to` (mm from the segment start)? */
189
+ private laneTaken;
190
+ /** Limits of the extended modes, folded into `follow`: obstacles, known obstacles, zones, areas, agents. */
191
+ private limits;
192
+ /**
193
+ * First distance along the path in [from, to] (mm) where the body of row `r` would touch one of the capsules, or
194
+ * -1. Capsules the body is in already are left out, so an entity inside one can leave it.
195
+ */
196
+ private sweep;
197
+ /**
198
+ * Zones: who holds what, and how far everybody else may go. A holder keeps its zone while the zone's stretch is
199
+ * still ahead or under its body; then the zone is free. A free zone goes to the requester that has waited longest
200
+ * (then the lowest id), and only when the lane behind the zone has room for it (it must not stop inside).
201
+ */
202
+ private zoneRequests;
203
+ /** Room on the lane right behind a zone stretch ending at `s1` (mm along the row's path) for the whole body. */
204
+ private exitFree;
205
+ /**
206
+ * Agents: local avoidance on integer positions. Neighbours come from a spatial hash of 2 m cells; every decision
207
+ * uses the positions at the start of the tick (a Jacobi step), so the result does not depend on the row order.
208
+ */
209
+ private agents;
210
+ /**
211
+ * Extraction: writes every entity's interpolated transform into `out` (`TRANSFORM_STRIDE` floats each, in row
212
+ * order; `table.ids` gives the id of each row) and returns the count. `alpha` is the fraction between the last two
213
+ * ticks. This is the only way the image reads movement; it does not change the simulation.
214
+ */
215
+ extract(alpha: number, out: Float32Array): number;
216
+ private offsetX;
217
+ private offsetZ;
218
+ /**
219
+ * Extraction with the turn rate and state as well (`POSE_STRIDE` floats per entity, row order). The turn rate is
220
+ * the path curvature around the position times the interpolated speed. Does not change the simulation.
221
+ */
222
+ extractPose(alpha: number, out: Float32Array): number;
223
+ save(w: ByteWriter): void;
224
+ load(r: ByteReader): void;
225
+ }
226
+ /** Squared distance from a point to the segment a–b (integer mm in, float out; IEEE operations only). */
227
+ export declare function capsuleDist2(x: number, z: number, ax: number, az: number, bx: number, bz: number): number;
228
+ export {};