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,123 @@
1
+ # Getting started
2
+
3
+ This page runs the existing examples, then builds a small scene from nothing. Read [Concepts](concepts.md) next.
4
+
5
+ ## Run what exists
6
+
7
+ Everything runs in Docker. Node is not needed on the host. From the repository root:
8
+
9
+ ```sh
10
+ docker compose up -d
11
+ docker compose ps
12
+ ```
13
+
14
+ | Service | URL | What it is |
15
+ | --- | --- | --- |
16
+ | `dev` | http://localhost:5281 | Installs the workspace dependencies, serves every example and stays up for the checks. `/` lists the examples, `/<name>/` opens the one in `examples/<name>`. Another host port: `EXAMPLES_PORT`. |
17
+
18
+ The `dev` service is healthy once the dependencies are installed and the example server answers (`tools/serve/serve.ts`). Every example keeps its own Vite dev server with live reload, started on the first request for it; source edits reload the page, and the dev servers poll the mounted files (`WH_POLL=1`).
19
+
20
+ Logs:
21
+
22
+ ```sh
23
+ docker compose logs --tail 50 dev
24
+ ```
25
+
26
+ Run any workspace command inside the `dev` container. The workspace root is `/app`, which is the repository root on the host:
27
+
28
+ ```sh
29
+ docker compose exec -T dev sh -c 'cd /app && pnpm typecheck'
30
+ ```
31
+
32
+ To use the engine in a project of your own, install the published package (`npm install wallhammer-web`) and import its entries (`wallhammer-web/runtime`, `wallhammer-web/render`, …) from code built by a bundler such as Vite.
33
+
34
+ ## The smallest scene
35
+
36
+ `createEngine` (in `wallhammer-web/runtime`) builds the device, the renderer, the environment, the Frame block and the frame loop in the right order. You add layers and start it.
37
+
38
+ The scene below is a noise hill under a sun. It uses one generator (`heightFieldMesh`), one material and one `MeshLayer`.
39
+
40
+ ```ts
41
+ import { HEIGHT_FIELD_ATTRIBS, HeightField, PerspectiveOrbitRig, definePalette, heightFieldMesh, streamSeed, valueNoise2 } from 'wallhammer-web';
42
+ import type { MaterialDesc } from 'wallhammer-web/base';
43
+ import { MeshLayer } from 'wallhammer-web/render';
44
+ import { createEngine } from 'wallhammer-web/runtime';
45
+
46
+ // 1. Data. A generator is a pure function of its input and a seed.
47
+ const SIZE_M = 128;
48
+ const STEP_M = 2;
49
+ const n = SIZE_M / STEP_M + 1;
50
+ const seed = streamSeed('demo', 'ground');
51
+ const heights = new Float32Array(n * n);
52
+ for (let j = 0; j < n; j++) {
53
+ for (let i = 0; i < n; i++) heights[j * n + i] = 12 * valueNoise2(i * STEP_M, j * STEP_M, 40, seed);
54
+ }
55
+ const field = new HeightField(STEP_M, n, n, heights);
56
+
57
+ // 2. A material: attribute locations and GLSL per pass. 'depth' uses the shared shadow programs.
58
+ const GROUND: MaterialDesc = {
59
+ name: 'ground',
60
+ attribs: HEIGHT_FIELD_ATTRIBS,
61
+ passes: {
62
+ shadow: 'depth',
63
+ color: {
64
+ vs: `#include <header>
65
+ in vec3 a_pos;
66
+ in vec4 a_normal;
67
+ out vec3 v_world;
68
+ out vec3 v_normal;
69
+ void main() {
70
+ v_world = a_pos;
71
+ v_normal = a_normal.xyz;
72
+ gl_Position = u_viewProj * vec4(a_pos, 1.0);
73
+ }`,
74
+ fs: `#include <header>
75
+ #include <noise>
76
+ #include <lighting>
77
+ in vec3 v_world;
78
+ in vec3 v_normal;
79
+ out vec4 o_color;
80
+ void main() {
81
+ vec3 n = normalize(v_normal);
82
+ float sun = sunVisibility(v_world, n, 1.0);
83
+ vec3 c = toDisplay(vec3(0.45, 0.47, 0.3) * lightOn(n, sun, 1.0));
84
+ o_color = vec4(applyFog(c, v_world), 1.0);
85
+ }`,
86
+ },
87
+ },
88
+ };
89
+
90
+ // 3. The engine.
91
+ const engine = createEngine({
92
+ canvas: document.querySelector<HTMLCanvasElement>('canvas')!,
93
+ view: new PerspectiveOrbitRig({ fovYDeg: 45, minDistance: 20, maxDistance: 400 }, { yawDeg: 30, pitchDeg: 30, distance: 180 }),
94
+ palette: definePalette({ sky: '#8fb2c9' }),
95
+ background: [0.56, 0.7, 0.79],
96
+ environment: { mode: 'day', hour: 15 },
97
+ orbitControls: true,
98
+ });
99
+ const { renderer, view } = engine;
100
+ view.target = [SIZE_M / 2, 0, SIZE_M / 2];
101
+ renderer.bounds = { min: [0, field.minY - 4, 0], max: [SIZE_M, field.maxY, SIZE_M] };
102
+
103
+ // 4. Upload through the renderer and add a layer.
104
+ const material = renderer.material(GROUND);
105
+ engine.add(new MeshLayer({ material, mesh: renderer.createMesh(heightFieldMesh(field, field.minY - 4), material) }));
106
+ engine.start();
107
+ ```
108
+
109
+ Things to notice:
110
+
111
+ - `renderer.bounds` must be set. With `bounds = null` the renderer draws only the background. The shadow map is fitted to the bounds.
112
+ - Every shader starts with `#include <header>`. It adds `#version 300 es`, precision, the Frame uniform block and the palette block. `#include <lighting>` adds `sunVisibility`, `lightOn`, `applyFog` and `toDisplay`. It needs `<noise>` before it, because includes do not nest. See [Rendering](rendering.md#shader-includes).
113
+ - `HEIGHT_FIELD_ATTRIBS` fixes the attribute locations that the mesh layout and the material share.
114
+ - The engine draws on demand. It redraws on input, on resize and while a clock runs. Call `engine.invalidate()` after you change something yourself.
115
+
116
+ ## Where to look next
117
+
118
+ - [Recipes](recipes.md) has short, checked samples for the common extensions; [Draw moving copies with instance sets](recipes.md#draw-moving-copies-with-instance-sets) shows `instanceSet`, `writeInstance`, `pushInstance` and `InstanceSetLayer` with their material.
119
+ - `examples/minimal-3d/src/main.ts` is the same pattern with instancing, an environment slot, the sky and the simulation.
120
+ - `examples/endless/src/main.ts` streams an endless world.
121
+ - `examples/planet/src/main.ts` joins the sphere world, the atmosphere and the free camera in one flight ([The planet example](planet.md)).
122
+ - `examples/system/src/main.ts` adds a system of bodies and hands the camera from the frame of one body to the next ([The system example](system.md)).
123
+ - `examples/destruction/src/main.ts` uses `gen-arch` and `sim/destruction`.
@@ -0,0 +1,50 @@
1
+ # Headless use
2
+
3
+ Much of the engine runs in plain Node, without a browser or a GPU. The golden test and the bake script of the endless example rely on this.
4
+
5
+ ## What runs in Node
6
+
7
+ | Module | In Node? | Notes |
8
+ | --- | --- | --- |
9
+ | `base`, `core`, `gen-core` | yes | |
10
+ | `gen-mesh`, `gen-tex` | yes | They return data. |
11
+ | `gen-arch`, `gen-ground`, `gen-vegetation` | yes | They return data and `BakeDesc`s. A bake itself needs the GPU. |
12
+ | `env` | yes | `Environment`, `assembleFrameBlock`, sun position, sky values. |
13
+ | `world` | yes | Picking, `StreamingManager`, providers, WHC1 encoding. |
14
+ | `sim`, `sim/destruction` | yes | Enforced: `sim` may import only `base`, `core`, `gen-core`. |
15
+ | `camera` | yes | Rigs are math. |
16
+ | `runtime` | partly | `createHeadlessEngine` only. `createEngine`, `StreamedWorld` and the layers need a canvas. |
17
+ | `platform`, `gpu`, `render`, `tools` | no | Browser or WebGL. |
18
+
19
+ Node 22.18 or newer runs the `.ts` sources directly (type stripping). The workspace uses this: `node tools/golden/golden.ts`. Import engine sources by relative path from tools inside the workspace, as the golden test does, or by the package name from a workspace package that depends on `wallhammer-web`.
20
+
21
+ ## `createHeadlessEngine`
22
+
23
+ The same mediator without canvas and GPU. It steps the simulation and the environment clocks.
24
+
25
+ <!-- check: wrap -->
26
+ ```ts
27
+ import { Simulation } from 'wallhammer-web/sim';
28
+ import { createHeadlessEngine } from 'wallhammer-web/runtime';
29
+
30
+ const sim = new Simulation({ seed: 'test' });
31
+ const engine = createHeadlessEngine({ sim, environment: { animate: false } });
32
+ engine.onExtract((alpha) => {
33
+ // read interpolated state here, as a renderer would
34
+ });
35
+ for (let i = 0; i < 100; i++) engine.frame(1 / 60); // returns how many ticks ran
36
+ const hash = engine.sim.stateHash();
37
+ engine.dispose();
38
+ ```
39
+
40
+ Members: `sim`, `env`, `onInput`, `onExtract`, `system`, `command`, `frame(realSeconds)`, `extract()`, `dispose()`. It produces no image.
41
+
42
+ `tools/golden/engine/sim-scenario.ts` uses it to prove that different frame patterns (many short frames, few long ones) give the same simulation.
43
+
44
+ ## What needs a GPU
45
+
46
+ - Any image, including bakes (`renderer.bake`, for example the `gen-ground` ground bake).
47
+ - Shader compile errors. Type checks and golden hashes do not compile GLSL. A broken shader shows only in the browser console.
48
+ - Shadow fitting, culling by `InstancedLayer`, the data view.
49
+
50
+ To check those, open the page or take a screenshot ([Tools](tools.md#screenshots)).
package/docs/motion.md ADDED
@@ -0,0 +1,160 @@
1
+ # Motion
2
+
3
+ `wallhammer-web/motion` (layer 2, imports nothing but itself) moves skeletons on the CPU: poses as data, blending, a motion graph of states and layers, events at named points of a motion, and two post steps (a two-bone reach and ends kept on the ground). It holds **no motion of its own**: every pose comes from a function the game writes, a `MotionSource`. Nothing reads the clock or `Math.random`; the same calls give the same poses.
4
+
5
+ The pieces, in the order a frame uses them:
6
+
7
+ 1. `Skeleton`: bones with a parent and a joint offset in the parent's frame. `Pose`: per bone a rotation (quaternion x, y, z, w) and an offset added to the joint. `boneMask` picks bones (with their descendants by default) for a layer or a blend.
8
+ 2. `MotionSource`: `sample(out, t, input)` writes a pose at time or phase `t`; optional `duration`, `loop`, `marks`, `speed`, `unit`.
9
+ 3. `MotionGraph`: per figure, a few hundred bytes of state over a shared `MotionGraphDef`. `setParam`, `trigger`, `update(dt)`, `evaluate(pose)`, `drainEvents(fn)`, `setState`, `save`/`restore`.
10
+ 4. `solvePose(skeleton, pose, root, world)`: 3 × 4 world matrices, 12 floats per bone, column by column (the first 12 floats of an instance record).
11
+ 5. Post steps on the solved pose: `reachTwoBone`, `fitToGround`.
12
+ 6. Drawing: `BoneInstances` of `wallhammer-web/render` writes the matrices into instance records; or the game writes them anywhere else.
13
+
14
+ ## Writing a source
15
+
16
+ A source is a pure function of `t` (and of the input object the game gives the graph). The example skeleton here is made up: a base, a link and a tip.
17
+
18
+ <!-- check: wrap -->
19
+ ```ts
20
+ import { Pose, Skeleton, setBoneAxisAngle } from 'wallhammer-web/motion';
21
+ import type { MotionSource } from 'wallhammer-web/motion';
22
+
23
+ const chain = new Skeleton([
24
+ { name: 'base', parent: -1, joint: [0, 0, 0] },
25
+ { name: 'link', parent: 0, joint: [0, 0.6, 0] },
26
+ { name: 'tip', parent: 1, joint: [0, 0.5, 0] },
27
+ ]);
28
+ const LINK = chain.index('link');
29
+ const TIP = chain.index('tip');
30
+
31
+ /** Swings the link back and forth once a second; the tip follows half as far. `t` is seconds into the pass. */
32
+ const swing: MotionSource = {
33
+ duration: 1,
34
+ marks: [{ name: 'apex', at: 0.25 }],
35
+ sample(out: Pose, t: number) {
36
+ const a = 0.6 * Math.sin(2 * Math.PI * t);
37
+ setBoneAxisAngle(out, LINK, 0, 0, 1, a);
38
+ setBoneAxisAngle(out, TIP, 0, 0, 1, 0.5 * a);
39
+ },
40
+ };
41
+
42
+ /** Holds still, bent a little. */
43
+ const rest: MotionSource = { sample: (out) => setBoneAxisAngle(out, LINK, 0, 0, 1, 0.2) };
44
+ ```
45
+
46
+ `sample` gets a pose reset to the rest pose (identity rotations, zero offsets) and writes only the bones it moves. `unit: 'phase'` gives `t` as the share 0–1 of one pass instead of seconds. `speed: [min, ideal, max]` lets one state hold several sources weighted by a parameter (below). `loop: false` holds the end.
47
+
48
+ ## A graph with two states and a layer
49
+
50
+ <!-- check: wrap -->
51
+ ```ts
52
+ import { MotionGraph, Pose, Skeleton, boneMask, compileMotionGraph, setBoneAxisAngle, solvePose } from 'wallhammer-web/motion';
53
+ import type { MotionSource } from 'wallhammer-web/motion';
54
+ declare const chain: Skeleton;
55
+ declare const swing: MotionSource;
56
+ declare const rest: MotionSource;
57
+
58
+ const tilt: MotionSource = { sample: (out, t) => setBoneAxisAngle(out, 0, 1, 0, 0, 0.1 * Math.sin(t)) };
59
+
60
+ const def = compileMotionGraph({
61
+ skeleton: chain,
62
+ params: { moving: 0, tilt: 1 },
63
+ layers: [
64
+ {
65
+ name: 'main',
66
+ states: [
67
+ { name: 'rest', source: rest },
68
+ { name: 'swing', source: swing },
69
+ ],
70
+ transitions: [
71
+ { from: 'rest', to: 'swing', seconds: 0.3, when: [{ param: 'moving', op: '>', value: 0.5 }] },
72
+ { from: 'swing', to: 'rest', seconds: 0.45, ease: 'smooth', when: [{ param: 'moving', op: '<=', value: 0.5 }] },
73
+ ],
74
+ },
75
+ // Added on top, only on the base and below, with a weight read from a parameter.
76
+ { name: 'lean', mode: 'additive', mask: boneMask(chain, ['base']), weight: 'tilt', states: [{ name: 'tilt', source: tilt }] },
77
+ ],
78
+ });
79
+
80
+ // One description, any number of figures.
81
+ const graph = new MotionGraph(def);
82
+ const pose = new Pose(chain);
83
+ const world = new Float32Array(chain.count * 12);
84
+ const root = new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1, 4, 0, 2]); // the figure's place: a 3 × 4 matrix
85
+
86
+ function frame(dt: number, moving: boolean): void {
87
+ graph.setParam('moving', moving ? 1 : 0);
88
+ graph.update(dt);
89
+ graph.evaluate(pose);
90
+ solvePose(chain, pose, root, world);
91
+ }
92
+ ```
93
+
94
+ What the graph does:
95
+
96
+ - **Layers** are evaluated in order. An `override` layer blends its pose over what is below by its weight (and mask); an `additive` layer adds its pose (a rotation in the bone's frame, an offset) scaled by its weight. A state with no source passes the layer below through (override) or adds nothing (additive).
97
+ - **Transitions** are checked in order every `update`: `from` a state or `'*'`, all `when` conditions true, the `trigger` set, or `after` passes of the current state. The new state fades in over `seconds` (`'linear'` or `'smooth'`); a transition taken while another still fades adds a third state at weight 0, so nothing jumps. At most `maxBlend` (4) states are active per layer; when a fifth is needed the one with the least weight is dropped.
98
+ - **Triggers** (`graph.trigger(name)`) last one `update`: a trigger no transition takes is gone afterwards.
99
+ - **Phase**: a state advances by `dt × rate / duration` (`rate` a number or a parameter's name). `drive: { param, per }` sets the phase from a parameter instead, `param / per` (a distance travelled and a stride: the phase never slides). `sync: 'group'` makes a state entered from another of the same group start at its phase.
100
+ - **Several sources in one state** with `by: 'param'`: every source names its `speed` range; the weights come from where the parameter lies between the ideal speeds (`speedWeights`), always summing to 1, and the phase advances by the weighted rates, so loops of different lengths stay in step.
101
+ - `save()` gives the state as bytes (`byteLength`), `restore(bytes)` continues the same run exactly; `reset()` starts over.
102
+ - `setState(state, layer?, time?)` puts a layer straight into one state, `time` seconds into it (no fade, no events): for a figure that starts or comes back into view in the middle of something, so many figures do not all begin their loops together.
103
+
104
+ ## Events from marks
105
+
106
+ <!-- check: wrap -->
107
+ ```ts
108
+ import type { MotionEventKind, MotionGraph } from 'wallhammer-web/motion';
109
+ declare const graph: MotionGraph;
110
+ declare function flash(): void;
111
+
112
+ let apexes = 0;
113
+ function onEvent(kind: MotionEventKind, name: string, state: string, layer: string): void {
114
+ if (kind === 'mark' && name === 'apex' && state === 'swing' && layer === 'main') {
115
+ apexes++;
116
+ flash();
117
+ }
118
+ }
119
+
120
+ function afterUpdate(): void {
121
+ graph.drainEvents(onEvent); // marks, 'enter' and 'leave', in the order they happened
122
+ }
123
+ ```
124
+
125
+ A mark is reported every time the phase of the newest state of a layer crosses it, in either direction, in order, however large `dt` is (a loop passed three times in one update gives its marks three times). A phase that lands exactly on a mark reports it once. Events wait until `drainEvents`; more than `maxEvents` (32) are counted in `droppedEvents`.
126
+
127
+ ## Reaching and the ground
128
+
129
+ `reachTwoBone(skeleton, pose, root, world, { upper, lower, end }, target, weight?, pole?)` turns two bones so that the `end` joint lies on `target` (as far as the chain reaches; it then points at it) and returns the distance left. `bend` names the axis a straight chain bends about; `pole` a point the middle joint turns toward. `fitToGround(…, chains, { heightAt, planeY, lower? })` moves every chain end by the ground height under it and reaches it, lowering the bone `lower` by the deepest drop. Both re-solve the bones below the chain, so `world` stays in step with `pose`.
130
+
131
+ ## Writing to instances
132
+
133
+ A figure drawn as rigid parts keeps one record per part in an instance set. `BoneInstances` (in `wallhammer-web/render`) holds the table bone → set, record and an optional fixed matrix of the part in the bone's frame, and writes world · part into the first 12 floats of every record without allocating.
134
+
135
+ <!-- check: wrap -->
136
+ ```ts
137
+ import type { MeshData } from 'wallhammer-web/base';
138
+ import { BoneInstances, instanceSet } from 'wallhammer-web/render';
139
+ declare const rod: MeshData;
140
+ declare const world: Float32Array; // from solvePose
141
+
142
+ // The set goes into an `InstanceSetLayer` as any other (Instance sets in the rendering guide).
143
+ const set = instanceSet(rod, 3, { name: 'parts' });
144
+ set.count = 3;
145
+ const parts = new BoneInstances([
146
+ { bone: 0, set, record: 0 },
147
+ { bone: 1, set, record: 1, local: [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.25, 0] }, // the part's middle, a quarter metre up the bone
148
+ { bone: 2, set, record: 2 },
149
+ ]);
150
+
151
+ function draw(): void {
152
+ parts.write(world); // marks the set dirty
153
+ }
154
+ ```
155
+
156
+ `write(world, first)` reads bone `first + bone`, so one array may hold the bones of many figures. `hide()` collapses every part.
157
+
158
+ Rigs posed in the vertex shader ([Rigs](rigs.md)) are a different path: no skeleton on the CPU, closed-form gait from the instance record. Motion is for figures the game poses itself.
159
+
160
+ `pnpm check:motion` (`tools/motion/check.ts`) runs the module on made-up bone chains without a browser ([Tools](tools.md)).
package/docs/planet.md ADDED
@@ -0,0 +1,152 @@
1
+ # The planet example
2
+
3
+ `examples/planet` is one scene that uses the engine's large-scale options together: a flight from the surface of a small planet up to where the whole sphere is in view, and back. It imports only the engine. The terrain, the objects, the materials and the flight are files of the example.
4
+
5
+ Read [World streaming](streaming.md) first; this page only says how the parts are joined.
6
+
7
+ ## Run
8
+
9
+ ```sh
10
+ docker compose up -d
11
+ ```
12
+
13
+ Open <http://127.0.0.1:5281/planet/>. The `dev` service serves it with the other examples; the port comes from `EXAMPLES_PORT`. Press `F` to start the flight, or open `#fly=1` to start it as soon as the start view has loaded.
14
+
15
+ | Key | What |
16
+ | --- | --- |
17
+ | `F` | Start the flight, or stop it where it is. `Escape` stops it too. |
18
+ | `W` `A` `S` `D`, `E` `Q`, `Shift`, drag, wheel | The free camera: fly along the view, up and down, faster, look around, change the speed. |
19
+ | `1`, `2` | Jump to the top of the flight, and back to the surface. |
20
+ | `[`, `]` | Move the hour by half an hour. |
21
+ | `L` | Tint every cell by its quadtree level. |
22
+ | `B` | Measure a frame of the current view with the graphics work finished. |
23
+ | `H` | Hide the panel. The line at the bottom stays. |
24
+
25
+ The line at the bottom shows the height above the surface, the speed, the patches drawn (of those loaded), the time of a frame and the GPU memory. The README of the example lists the keys of the URL hash.
26
+
27
+ ## What the scene is made of
28
+
29
+ | Part | Engine | In the example |
30
+ | --- | --- | --- |
31
+ | The shape | `SphereWorld` of `wallhammer-web/world`, radius 100 km, six quadtrees of levels 0 to 11 ([A sphere world](streaming.md#a-sphere-world)) | `SHAPE` in `world.ts` |
32
+ | The terrain | `spherePatchMesh` and `fractalNoise3` of `wallhammer-web/gen-core` | `groundHeight`, `surfaceColor`, `generatePlanetCell` in `world.ts`; the seed is the example's own |
33
+ | Levels without a jump | `morph: true` of `StreamedWorld` and `SPHERE_PATCH_GLSL` ([Blending between levels](streaming.md#blending-between-levels)) | the vertex shaders in `shaders.ts` |
34
+ | Objects that hand over to the surface | `coverFade`, `coverKeep` of `wallhammer-web/core` ([Content beyond its levels](streaming.md#content-beyond-its-levels)) | trees and rocks from level 10 on; coarser cells carry their look in the surface |
35
+ | The air | `atmosphereFor(radius, height)` passed to `createEngine` ([The atmosphere](rendering.md#the-atmosphere)) | a shell 30 km thick; `#atm=0` switches it off, key `R` compares with the reference quality; the materials take the air at their vertices (`atmosphereAir`) |
36
+ | The sun | `env.observer` with `sphereSunDirection` | set every frame for the place under the camera |
37
+ | Up | `radialUp` of the renderer ([Local up](rendering.md#local-up)) | `SHAPE.radial` |
38
+ | The camera | `FreeRig` with `bindFreeInput` ([Cameras and views](cameras.md)) | up to 40 km/s; the speed follows the height |
39
+ | Precision | `originAxes: 'all'` of `StreamedWorld` and the depth mode `reversed` or `logarithmic` ([Depth modes](rendering.md#depth-modes)) | `#depth=logarithmic` switches the mode |
40
+ | Memory | `gpuCeilingBytes` of `StreamedWorld` ([A ceiling of GPU memory](streaming.md#a-ceiling-of-gpu-memory)) and the horizon test | 560 MB by default, `#gpu=` changes it |
41
+
42
+ The joining code is short. This is its skeleton; the names declared at the top are the content's part.
43
+
44
+ <!-- check: wrap -->
45
+ ```ts
46
+ import { definePalette } from 'wallhammer-web';
47
+ import type { MaterialDesc } from 'wallhammer-web/base';
48
+ import { FreeRig } from 'wallhammer-web/camera';
49
+ import { atmosphereFor, sphereSunDirection } from 'wallhammer-web/env';
50
+ import { bindFreeInput } from 'wallhammer-web/platform';
51
+ import { SphereWorld } from 'wallhammer-web/world';
52
+ import type { CellProvider, StreamingConfig } from 'wallhammer-web/world';
53
+ import { StreamedWorld, createEngine, viewerTickets } from 'wallhammer-web/runtime';
54
+
55
+ declare const canvas: HTMLCanvasElement;
56
+ declare const provider: CellProvider;
57
+ declare const config: StreamingConfig;
58
+ declare const terrainDesc: MaterialDesc;
59
+ /** Height of the visible surface under a world position, above the base sphere. */
60
+ declare const surfaceUnder: (p: readonly [number, number, number]) => number;
61
+
62
+ const RADIUS_M = 100_000;
63
+ const DAY_OF_YEAR = 172;
64
+ const shape = new SphereWorld(RADIUS_M);
65
+
66
+ // The camera takes up from the shape and keeps itself above the surface.
67
+ const rig = new FreeRig(
68
+ { fovYDeg: 50, maxPitchDeg: 90, minClearance: 2, minSpeed: 5, maxSpeed: 40_000 },
69
+ { shape, heightAbove: (p) => shape.altitude(p) - surfaceUnder(p) },
70
+ { position: [0, RADIUS_M + 500, 0], yawDeg: 0, pitchDeg: 3 },
71
+ );
72
+
73
+ const engine = createEngine({
74
+ canvas,
75
+ view: rig,
76
+ palette: definePalette({ sky: '#05070c' }),
77
+ background: [0.02, 0.027, 0.047],
78
+ renderer: { depth: 'reversed', radialUp: shape.radial },
79
+ environment: { mode: 'day', site: { latitudeDeg: 0, longitudeDeg: 0, dayOfYear: DAY_OF_YEAR, utcOffsetHours: 0 }, hour: 9, weather: {} },
80
+ atmosphere: atmosphereFor(RADIUS_M, 30_000),
81
+ });
82
+
83
+ const world = new StreamedWorld({
84
+ renderer: engine.renderer,
85
+ config,
86
+ provider,
87
+ originAxes: 'all',
88
+ morph: true,
89
+ horizon: { center: shape.centerM, radiusM: RADIUS_M },
90
+ gpuCeilingBytes: 560 * 1024 * 1024,
91
+ materials: { terrain: engine.renderer.material(terrainDesc) },
92
+ onActivity: () => engine.invalidate(),
93
+ });
94
+ engine.add(world);
95
+
96
+ const input = bindFreeInput(engine.canvas, rig, { onChange: () => engine.invalidate() });
97
+ // Before the streaming step of every frame: move, then hand the camera to the world.
98
+ engine.renderer.beforeFrame.unshift(() => {
99
+ input.step();
100
+ const p = rig.position;
101
+ const eye: [number, number, number] = [p[0], p[1], p[2]];
102
+ engine.env.observer = { up: shape.directionOf(eye), sunDir: sphereSunDirection(DAY_OF_YEAR, engine.env.day.time) };
103
+ world.setFocus(eye);
104
+ rig.origin = [world.origin[0], world.origin[1], world.origin[2]];
105
+ world.setEye(eye);
106
+ world.setTickets(viewerTickets({ eye, altitude: rig.clearance, forward: rig.axes().forward, velocity: rig.velocity, pixelsPerRadian: 1158 }));
107
+ });
108
+ engine.start();
109
+ ```
110
+
111
+ ### The strips
112
+
113
+ `strips.ts` lays one strip 50 km long over an edge of the cube and forks it at its far end into two lines of 6 and 4 km, with the engine's strip tools ([Strips along a surface](generators.md#strips-along-a-surface)). `planetStrips(seed)` searches the route from the seed: 64 candidates, each a point on an edge of the cube and a heading 50°–70° to it, the first with land under 80 % of its points and nothing above 1800 m; the grade is the ground smoothed along the line, at most 6 m from it. `generatePlanetStripCell` is `generatePlanetCell` through its hooks (`buildPlanetCell`): the ground cut and filled with `stripCarve`, no objects and no cover on the shoulders, the shoulders tinted as bare ground, and the strip mesh as a second mesh of material `strip` (domain version 2). The page shows the strips by default and starts on the main line; `#strip=0` is the page without them, its generator, worker and materials. `window.__wh.presets()` adds views from orbit, over the edge of the cube, with level tints, from 900 m, from the surface and over the node.
114
+
115
+ ### The weather
116
+
117
+ The planet keeps one cloud cover for the whole sphere (`weather.cloudCover`), the same density of cloud shadow everywhere. A cover that changes with the place, clouds drawn as a shell over their shadows and rain or snow along the local down are the engine's [cloud cover by place](rendering.md#cloud-cover-by-place); the system example uses them on Hearth ([The system example](system.md#the-plan-of-a-world)). Adding `cloudFieldSlot` to this page would change its lighting include and so its pictures.
118
+
119
+ ## The flight
120
+
121
+ `flight.ts` holds the flight as a pure function: `flightPose(plan, radiusM, t)` returns the height, the vertical speed, the pitch and the turn of the view `t` seconds after the start. Nothing in it depends on the frame rate, so the flight is the same on every run and the way down mirrors the way up.
122
+
123
+ - The height grows as a power of the progress, from 3 m to about 260 km. Every doubling of the height takes the same time, so the streaming has the same work per second all the way.
124
+ - The progress eases in and out with no speed and no acceleration at either end.
125
+ - The view starts a little under the horizon, keeps the horizon in the picture while it sinks, and ends straight down with the sphere in the middle.
126
+ - The top lies a quarter above `wholeSphereHeight(radius, air, fov)`, the least height from which the whole sphere with its air fits the view.
127
+
128
+ The page drives the camera from the pose with `rig.setState` and sets `rig.velocity` for the speed it shows. The ticket ahead of the camera that `viewerTickets` makes of the velocity changes nothing on a way straight up or down: it stands over the same point at the same height as the camera's own ticket. A stalled frame moves the flight by at most a tenth of a second.
129
+
130
+ ## The budget
131
+
132
+ The example is built for a frame under 8 ms and under 600 MB of GPU memory at 1920×1080.
133
+
134
+ - **Cells.** At most 900 cells are wanted at a time (`maxCells`); with less the tolerance grows evenly instead of leaving holes. A patch is 32 × 32 quads.
135
+ - **Memory.** `gpuCeilingBytes` counts everything the device holds (cells, shadow map, targets, tables of the air). Over the ceiling the least needed cells leave.
136
+ - **Shadows.** One map of 4096² for the nearest 4 km.
137
+
138
+ The panel shows a report of the last flight: the time between frames (mean and worst, a stalled frame with its full length), the refresh interval of the display as the flight saw it and the number of frames that missed a refresh (`refreshMs`, `framesMissed`), the main thread's part of a frame and how often it alone was above 8 ms (`cpuOverBudget`), the peaks of GPU memory, patches and holes, and one frame at the landing measured with `renderer.benchmark`, which waits for the graphics work. The time between frames cannot fall under the refresh interval of the display, so it is compared with that interval and not with the budget: on a display of 120 Hz or more a flight without a missed refresh stayed near the budget all the way, on a slower one only the measured frame says how much room there is. A script reads the same numbers from `window.__wh.flightReport()`. To measure along the flight it holds a pose with `window.__wh.setFlight(seconds)` (the flight then starts where the camera stands, so call it at the start view), waits for `window.__wh.settled()` and calls `window.__wh.measureFrame()`.
139
+
140
+ ## Checks
141
+
142
+ The flight is checked without a browser, in the `dev` container:
143
+
144
+ ```sh
145
+ docker compose exec -T dev sh -c 'cd /app/examples/planet && pnpm verify'
146
+ ```
147
+
148
+ `scripts/verify.ts` checks the generator, the pose function and the streaming along the flight with the real generator: the sphere is covered exactly once at every step, a child is never requested before its parent, the budget of cells holds, and the estimate of GPU memory stays under 600 MB. `flight-check.ts` does the flying; it feeds the `StreamingManager` of `wallhammer-web/world` with the tickets of every step and finishes a fixed number of jobs per step in place of the workers.
149
+
150
+ The golden test of the examples (`tools/golden/golden.ts`) holds two recipes of the example: "planet example cells" and "planet example flight" ([Tools](tools.md)).
151
+
152
+ What these checks cannot see is the picture: the shaders, the look of the air and the frame time need a browser with a GPU.