wallhammer-web 0.0.0-stage → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (408) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +88 -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,173 @@
1
+ // Affine 3 × 4 matrices: a linear part and a translation, stored column by column in 12 numbers
2
+ // [c0x, c0y, c0z, c1x, c1y, c1z, c2x, c2y, c2z, tx, ty, tz]. This is exactly the first 12 floats of an instance
3
+ // record (`writeInstance` in render), so a matrix built here is written into a record as it is.
4
+ //
5
+ // Every function takes its output as the last argument `out` and returns it; without `out` a new Float64Array
6
+ // (or a new [x, y, z] for points and directions) is made, which is meant for setup, not for every frame. `out`
7
+ // may be the same array as an input everywhere. Angles are radians; rotations are right-handed (counter-clockwise
8
+ // looking down the axis toward the origin). The quaternion layout is [x, y, z, w], as `Quat` of frames.
9
+ /** Floats of one matrix. */
10
+ export const MAT34_FLOATS = 12;
11
+ function target(out) {
12
+ return out ?? new Float64Array(12);
13
+ }
14
+ function setAll(o, a, b, c, d, e, f, g, h, i, x, y, z) {
15
+ o[0] = a;
16
+ o[1] = b;
17
+ o[2] = c;
18
+ o[3] = d;
19
+ o[4] = e;
20
+ o[5] = f;
21
+ o[6] = g;
22
+ o[7] = h;
23
+ o[8] = i;
24
+ o[9] = x;
25
+ o[10] = y;
26
+ o[11] = z;
27
+ return o;
28
+ }
29
+ /** The identity. */
30
+ export function mat34Identity(out) {
31
+ return setAll(target(out), 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0);
32
+ }
33
+ /** Copy of `m`. */
34
+ export function mat34Copy(m, out) {
35
+ const o = target(out);
36
+ for (let k = 0; k < 12; k++)
37
+ o[k] = m[k];
38
+ return o;
39
+ }
40
+ /** A move by (x, y, z). */
41
+ export function mat34Translation(x, y, z, out) {
42
+ return setAll(target(out), 1, 0, 0, 0, 1, 0, 0, 0, 1, x, y, z);
43
+ }
44
+ /** Scaling along the axes; a negative factor mirrors (the determinant turns negative). */
45
+ export function mat34Scaling(sx, sy, sz, out) {
46
+ return setAll(target(out), sx, 0, 0, 0, sy, 0, 0, 0, sz, 0, 0, 0);
47
+ }
48
+ /** Rotation about +x. */
49
+ export function mat34RotationX(rad, out) {
50
+ const c = Math.cos(rad);
51
+ const s = Math.sin(rad);
52
+ return setAll(target(out), 1, 0, 0, 0, c, s, 0, -s, c, 0, 0, 0);
53
+ }
54
+ /** Rotation about +y. */
55
+ export function mat34RotationY(rad, out) {
56
+ const c = Math.cos(rad);
57
+ const s = Math.sin(rad);
58
+ return setAll(target(out), c, 0, -s, 0, 1, 0, s, 0, c, 0, 0, 0);
59
+ }
60
+ /** Rotation about +z. */
61
+ export function mat34RotationZ(rad, out) {
62
+ const c = Math.cos(rad);
63
+ const s = Math.sin(rad);
64
+ return setAll(target(out), c, s, 0, -s, c, 0, 0, 0, 1, 0, 0, 0);
65
+ }
66
+ /** Rotation about the axis (ax, ay, az) through the origin; the axis need not be unit. A zero axis gives the identity. */
67
+ export function mat34RotationAxis(ax, ay, az, rad, out) {
68
+ const l = Math.sqrt(ax * ax + ay * ay + az * az);
69
+ if (!(l > 0))
70
+ return mat34Identity(out);
71
+ const x = ax / l;
72
+ const y = ay / l;
73
+ const z = az / l;
74
+ const c = Math.cos(rad);
75
+ const s = Math.sin(rad);
76
+ const t = 1 - c;
77
+ return setAll(target(out), t * x * x + c, t * x * y + s * z, t * x * z - s * y, t * x * y - s * z, t * y * y + c, t * y * z + s * x, t * x * z + s * y, t * y * z - s * x, t * z * z + c, 0, 0, 0);
78
+ }
79
+ /** Rotation of the unit quaternion `q` = [x, y, z, w], then a move by (tx, ty, tz) (default none). */
80
+ export function mat34FromQuat(q, out, tx = 0, ty = 0, tz = 0) {
81
+ const x = q[0];
82
+ const y = q[1];
83
+ const z = q[2];
84
+ const w = q[3];
85
+ const xx = x * x;
86
+ const yy = y * y;
87
+ const zz = z * z;
88
+ const xy = x * y;
89
+ const xz = x * z;
90
+ const yz = y * z;
91
+ const wx = w * x;
92
+ const wy = w * y;
93
+ const wz = w * z;
94
+ return setAll(target(out), 1 - 2 * (yy + zz), 2 * (xy + wz), 2 * (xz - wy), 2 * (xy - wz), 1 - 2 * (xx + zz), 2 * (yz + wx), 2 * (xz + wy), 2 * (yz - wx), 1 - 2 * (xx + yy), tx, ty, tz);
95
+ }
96
+ /**
97
+ * `a` after `b`: the matrix that first applies `b`, then `a` (a · b). `out` may be `a` or `b`. A transform stack
98
+ * pushes with `mat34Multiply(parent, local, out)`.
99
+ */
100
+ export function mat34Multiply(a, b, out) {
101
+ const a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5], a6 = a[6], a7 = a[7], a8 = a[8], a9 = a[9], a10 = a[10], a11 = a[11];
102
+ const b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5], b6 = b[6], b7 = b[7], b8 = b[8], b9 = b[9], b10 = b[10], b11 = b[11];
103
+ return setAll(target(out), a0 * b0 + a3 * b1 + a6 * b2, a1 * b0 + a4 * b1 + a7 * b2, a2 * b0 + a5 * b1 + a8 * b2, a0 * b3 + a3 * b4 + a6 * b5, a1 * b3 + a4 * b4 + a7 * b5, a2 * b3 + a5 * b4 + a8 * b5, a0 * b6 + a3 * b7 + a6 * b8, a1 * b6 + a4 * b7 + a7 * b8, a2 * b6 + a5 * b7 + a8 * b8, a0 * b9 + a3 * b10 + a6 * b11 + a9, a1 * b9 + a4 * b10 + a7 * b11 + a10, a2 * b9 + a5 * b10 + a8 * b11 + a11);
104
+ }
105
+ /** Determinant of the linear part: negative for a mirroring matrix (the winding of its triangles flips), 0 when flat. */
106
+ export function mat34Determinant(m) {
107
+ const a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5], g = m[6], h = m[7], i = m[8];
108
+ return a * (e * i - f * h) - d * (b * i - c * h) + g * (b * f - c * e);
109
+ }
110
+ /** The inverse of `m`, or null (and `out` untouched) when the linear part is singular. */
111
+ export function mat34Invert(m, out) {
112
+ const a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5], g = m[6], h = m[7], i = m[8];
113
+ const x = m[9], y = m[10], z = m[11];
114
+ const c00 = e * i - f * h;
115
+ const c01 = c * h - b * i;
116
+ const c02 = b * f - c * e;
117
+ const det = a * c00 + d * c01 + g * c02;
118
+ if (det === 0 || !Number.isFinite(det))
119
+ return null;
120
+ const k = 1 / det;
121
+ const r0 = c00 * k, r1 = c01 * k, r2 = c02 * k;
122
+ const r3 = (f * g - d * i) * k, r4 = (a * i - c * g) * k, r5 = (c * d - a * f) * k;
123
+ const r6 = (d * h - e * g) * k, r7 = (b * g - a * h) * k, r8 = (a * e - b * d) * k;
124
+ return setAll(target(out), r0, r1, r2, r3, r4, r5, r6, r7, r8, -(r0 * x + r3 * y + r6 * z), -(r1 * x + r4 * y + r7 * z), -(r2 * x + r5 * y + r8 * z));
125
+ }
126
+ /** The point (x, y, z) moved by `m` (linear part and translation). */
127
+ export function mat34Point(m, x, y, z, out) {
128
+ const o = out ?? [0, 0, 0];
129
+ const px = m[0] * x + m[3] * y + m[6] * z + m[9];
130
+ const py = m[1] * x + m[4] * y + m[7] * z + m[10];
131
+ const pz = m[2] * x + m[5] * y + m[8] * z + m[11];
132
+ o[0] = px;
133
+ o[1] = py;
134
+ o[2] = pz;
135
+ return o;
136
+ }
137
+ /** The direction (x, y, z) turned by the linear part only (no translation, not normalised). */
138
+ export function mat34Direction(m, x, y, z, out) {
139
+ const o = out ?? [0, 0, 0];
140
+ const px = m[0] * x + m[3] * y + m[6] * z;
141
+ const py = m[1] * x + m[4] * y + m[7] * z;
142
+ const pz = m[2] * x + m[5] * y + m[8] * z;
143
+ o[0] = px;
144
+ o[1] = py;
145
+ o[2] = pz;
146
+ return o;
147
+ }
148
+ /**
149
+ * The surface normal (x, y, z) carried by `m`: the cofactor matrix (the inverse transpose up to the determinant) times
150
+ * the normal, unit length, its sign kept for a mirroring matrix so the normal still points out of the mirrored
151
+ * surface. The same rule as `instanceNormal` in `INSTANCE_SET_GLSL`. A zero result stays zero.
152
+ */
153
+ export function mat34Normal(m, x, y, z, out) {
154
+ const o = out ?? [0, 0, 0];
155
+ const a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5], g = m[6], h = m[7], i = m[8];
156
+ // Columns of the cofactor matrix: cross(c1, c2), cross(c2, c0), cross(c0, c1).
157
+ const k0x = e * i - f * h, k0y = f * g - d * i, k0z = d * h - e * g;
158
+ const k1x = h * c - i * b, k1y = i * a - g * c, k1z = g * b - h * a;
159
+ const k2x = b * f - c * e, k2y = c * d - a * f, k2z = a * e - b * d;
160
+ let nx = k0x * x + k1x * y + k2x * z;
161
+ let ny = k0y * x + k1y * y + k2y * z;
162
+ let nz = k0z * x + k1z * y + k2z * z;
163
+ const det = a * k0x + b * k0y + c * k0z;
164
+ const l = Math.sqrt(nx * nx + ny * ny + nz * nz);
165
+ const s = l > 0 ? (det < 0 ? -1 : 1) / l : 0;
166
+ nx *= s;
167
+ ny *= s;
168
+ nz *= s;
169
+ o[0] = nx;
170
+ o[1] = ny;
171
+ o[2] = nz;
172
+ return o;
173
+ }
@@ -0,0 +1,87 @@
1
+ import type { TextureData, TextureSampling } from './data.ts';
2
+ /**
3
+ * - `shadow`: depth from the light into the shadow map (only when it is refitted)
4
+ * - `color`: the normal image
5
+ * - `data`: replaces `color` when the renderer is in data mode (flat debugging views)
6
+ * - `overlay`: after `color`, screen-space effects; skipped in data mode
7
+ */
8
+ export type PassName = 'shadow' | 'color' | 'data' | 'overlay';
9
+ export type BlendFactor = 'zero' | 'one' | 'src-alpha' | 'one-minus-src-alpha';
10
+ /** Blend equation `src * srcFactor + dst * dstFactor`, with optional separate factors for alpha. */
11
+ export interface BlendSpec {
12
+ src: BlendFactor;
13
+ dst: BlendFactor;
14
+ srcAlpha?: BlendFactor;
15
+ dstAlpha?: BlendFactor;
16
+ }
17
+ /** Faces skipped by a draw. */
18
+ export type CullMode = 'none' | 'back' | 'front';
19
+ /** Fixed-function state of a draw. Fields left out keep their current value. */
20
+ export interface DrawState {
21
+ depthTest?: boolean;
22
+ depthFunc?: 'less' | 'lequal';
23
+ depthWrite?: boolean;
24
+ /** True culls back faces, false culls nothing. `cull`, when given in the same state, wins over it. */
25
+ cullBack?: boolean;
26
+ /**
27
+ * Which faces are not drawn: none, the back faces (counter-clockwise is front) or the front faces (for example an
28
+ * outline hull drawn from the inside of an enlarged copy). Wins over `cullBack` in the same state object.
29
+ */
30
+ cull?: CullMode;
31
+ /** `null` = no blending. */
32
+ blend?: BlendSpec | null;
33
+ /** Multisample coverage from fragment alpha. */
34
+ alphaToCoverage?: boolean;
35
+ /** Depth offset `[factor, units]`, `null` = off. */
36
+ polygonOffset?: readonly [number, number] | null;
37
+ }
38
+ /** Value of one uniform, tagged by its GLSL type. */
39
+ export type UniformValue = {
40
+ readonly int: number;
41
+ } | {
42
+ readonly float: number;
43
+ } | {
44
+ readonly vec2: readonly [number, number];
45
+ } | {
46
+ readonly vec3: readonly [number, number, number];
47
+ } | {
48
+ readonly vec4: readonly [number, number, number, number];
49
+ } | {
50
+ readonly ivec4: readonly [number, number, number, number];
51
+ } | {
52
+ readonly mat4: Float32Array;
53
+ };
54
+ export type Uniforms = Record<string, UniformValue>;
55
+ export interface ShaderSource {
56
+ vs: string;
57
+ fs: string;
58
+ }
59
+ /** A program per pass. `'depth'` is the renderer's plain depth program (position attribute `a_pos`). */
60
+ export interface MaterialDesc {
61
+ name: string;
62
+ /** Fixed attribute locations shared by every program of the material and by the meshes drawn with it. */
63
+ attribs: Readonly<Record<string, number>>;
64
+ passes: Partial<Record<PassName, ShaderSource | 'depth'>>;
65
+ /** Extra draw state per pass, on top of the pass base state. */
66
+ state?: Partial<Record<PassName, DrawState>>;
67
+ }
68
+ /** Output of a bake: an RGBA8 texture of the bake's size. */
69
+ export type BakeTarget = {
70
+ format: 'rgba8';
71
+ } & TextureSampling;
72
+ /**
73
+ * A texture bake: one fragment shader run over a full-screen triangle into one or more targets (MRT, `location = i`).
74
+ * Inputs are bound in order to the units 0, 1, …; the shader reads them with `texelFetch` or `texture`.
75
+ */
76
+ export interface BakeDesc {
77
+ name: string;
78
+ width: number;
79
+ height: number;
80
+ fs: string;
81
+ inputs: readonly {
82
+ sampler: string;
83
+ texture: TextureData;
84
+ }[];
85
+ uniforms?: Uniforms;
86
+ targets: readonly BakeTarget[];
87
+ }
@@ -0,0 +1,6 @@
1
+ // How something is drawn, as a plain description: shaders per pass, fixed draw state, uniforms and samplers.
2
+ // Content packages describe materials and texture bakes with these types; the render module compiles and runs them.
3
+ // Shader sources may contain include lines (`#include <name>` on a line of its own), resolved by the renderer:
4
+ // `header` (version, precision, the Frame and Palette blocks), `noise` (integer-hash noise) and whatever the
5
+ // renderer's owner registered (for example lighting from the environment).
6
+ export {};
@@ -0,0 +1,27 @@
1
+ export type Vec3 = [number, number, number];
2
+ /** Colour as three numbers 0–1. */
3
+ export type RGB = readonly [number, number, number];
4
+ export declare const DEG: number;
5
+ export declare function dot(a: Vec3, b: Vec3): number;
6
+ export declare function cross(a: Vec3, b: Vec3): Vec3;
7
+ /** `cross` written into `out` (which may not be `a` or `b`); returns `out`. */
8
+ export declare function crossInto(a: Vec3, b: Vec3, out: Vec3): Vec3;
9
+ export declare function normalize(a: Vec3): Vec3;
10
+ export declare function scale(a: Vec3, s: number): Vec3;
11
+ export declare function add(a: Vec3, b: Vec3): Vec3;
12
+ export declare function clamp(v: number, lo: number, hi: number): number;
13
+ export declare function lerp(a: number, b: number, t: number): number;
14
+ export declare function smoothstep(e0: number, e1: number, x: number): number;
15
+ /** Orthographic camera with no perspective, given by three axes. */
16
+ export interface OrthoFrame {
17
+ right: Vec3;
18
+ up: Vec3;
19
+ /** View direction, from the camera into the scene. */
20
+ forward: Vec3;
21
+ }
22
+ /**
23
+ * World → clip space matrix for orthographic projection.
24
+ * Point p lands at x = (right·p − cx) / halfW, y = (up·p − cy) / halfH, z = (forward·p − cz) / halfD.
25
+ * With `out` (16 floats) the matrix is written there and `out` is returned.
26
+ */
27
+ export declare function orthoMatrix(f: OrthoFrame, cx: number, cy: number, cz: number, halfW: number, halfH: number, halfD: number, out?: Float32Array): Float32Array;
@@ -0,0 +1,60 @@
1
+ // The smallest necessary vector math. Matrices are 4×4 column-major, as WebGL wants them.
2
+ export const DEG = Math.PI / 180;
3
+ export function dot(a, b) {
4
+ return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
5
+ }
6
+ export function cross(a, b) {
7
+ return [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
8
+ }
9
+ /** `cross` written into `out` (which may not be `a` or `b`); returns `out`. */
10
+ export function crossInto(a, b, out) {
11
+ out[0] = a[1] * b[2] - a[2] * b[1];
12
+ out[1] = a[2] * b[0] - a[0] * b[2];
13
+ out[2] = a[0] * b[1] - a[1] * b[0];
14
+ return out;
15
+ }
16
+ export function normalize(a) {
17
+ const l = Math.hypot(a[0], a[1], a[2]) || 1;
18
+ return [a[0] / l, a[1] / l, a[2] / l];
19
+ }
20
+ export function scale(a, s) {
21
+ return [a[0] * s, a[1] * s, a[2] * s];
22
+ }
23
+ export function add(a, b) {
24
+ return [a[0] + b[0], a[1] + b[1], a[2] + b[2]];
25
+ }
26
+ export function clamp(v, lo, hi) {
27
+ return v < lo ? lo : v > hi ? hi : v;
28
+ }
29
+ export function lerp(a, b, t) {
30
+ return a + (b - a) * t;
31
+ }
32
+ export function smoothstep(e0, e1, x) {
33
+ const t = clamp((x - e0) / (e1 - e0), 0, 1);
34
+ return t * t * (3 - 2 * t);
35
+ }
36
+ /**
37
+ * World → clip space matrix for orthographic projection.
38
+ * Point p lands at x = (right·p − cx) / halfW, y = (up·p − cy) / halfH, z = (forward·p − cz) / halfD.
39
+ * With `out` (16 floats) the matrix is written there and `out` is returned.
40
+ */
41
+ export function orthoMatrix(f, cx, cy, cz, halfW, halfH, halfD, out) {
42
+ const m = out ?? new Float32Array(16);
43
+ if (out)
44
+ m.fill(0);
45
+ const { right: r, up: u, forward: w } = f;
46
+ m[0] = r[0] / halfW;
47
+ m[4] = r[1] / halfW;
48
+ m[8] = r[2] / halfW;
49
+ m[12] = -cx / halfW;
50
+ m[1] = u[0] / halfH;
51
+ m[5] = u[1] / halfH;
52
+ m[9] = u[2] / halfH;
53
+ m[13] = -cy / halfH;
54
+ m[2] = w[0] / halfD;
55
+ m[6] = w[1] / halfD;
56
+ m[10] = w[2] / halfD;
57
+ m[14] = -cz / halfD;
58
+ m[15] = 1;
59
+ return m;
60
+ }
@@ -0,0 +1,38 @@
1
+ /** One stage: a key for the code, a label for the user, a weight against the other stages. */
2
+ export interface ProgressStage {
3
+ key: string;
4
+ label: string;
5
+ weight: number;
6
+ }
7
+ /** What a progress shows now. */
8
+ export interface ProgressReport {
9
+ /** Share of the weighted work done, 0–1. */
10
+ fraction: number;
11
+ /** Key and label of the first stage not complete; the last stage when all are. */
12
+ stage: string;
13
+ label: string;
14
+ /** Units done and total of that stage. */
15
+ units: number;
16
+ of: number;
17
+ done: boolean;
18
+ }
19
+ export declare class Progress {
20
+ private readonly stages;
21
+ private readonly listeners;
22
+ constructor(stages: readonly ProgressStage[]);
23
+ /** Sets the number of units of a stage (default 1). Zero units make the stage complete at once. */
24
+ total(key: string, units: number): void;
25
+ /** Marks `units` more units of a stage done. */
26
+ advance(key: string, units?: number): void;
27
+ /** Marks a stage complete. */
28
+ complete(key: string): void;
29
+ /** Marks every stage complete. */
30
+ finish(): void;
31
+ /** Advances a stage by one unit as each promise settles; the stage total becomes the number of promises. */
32
+ track<T>(key: string, promises: readonly Promise<T>[]): Promise<T[]>;
33
+ get report(): ProgressReport;
34
+ /** Calls `fn` with the report now and after every change; returns the function that stops it. */
35
+ subscribe(fn: (r: ProgressReport) => void): () => void;
36
+ private get;
37
+ private emit;
38
+ }
@@ -0,0 +1,81 @@
1
+ // Progress of a long piece of work made of named stages (loading a map: data, worker jobs, shader programs, uploads).
2
+ // Each stage has a weight and a number of units; whoever does the work advances it, whoever shows it subscribes.
3
+ // No DOM and no clock here: an app turns the report into a bar or a line of text.
4
+ //
5
+ // const p = new Progress([{ key: 'data', label: 'Data', weight: 1 }, { key: 'jobs', label: 'Pieces', weight: 4 }]);
6
+ // p.total('jobs', 120);
7
+ // p.advance('jobs'); // one of 120 done
8
+ // p.report // { fraction, stage: 'data', label: 'Data', done: false }
9
+ export class Progress {
10
+ stages;
11
+ listeners = new Set();
12
+ constructor(stages) {
13
+ if (stages.length === 0)
14
+ throw new Error('A progress needs at least one stage');
15
+ this.stages = stages.map((stage) => ({ stage, total: 1, done: 0 }));
16
+ }
17
+ /** Sets the number of units of a stage (default 1). Zero units make the stage complete at once. */
18
+ total(key, units) {
19
+ const s = this.get(key);
20
+ s.total = Math.max(0, units);
21
+ s.done = Math.min(s.done, s.total);
22
+ this.emit();
23
+ }
24
+ /** Marks `units` more units of a stage done. */
25
+ advance(key, units = 1) {
26
+ const s = this.get(key);
27
+ s.done = Math.min(s.total, s.done + units);
28
+ this.emit();
29
+ }
30
+ /** Marks a stage complete. */
31
+ complete(key) {
32
+ const s = this.get(key);
33
+ s.done = s.total;
34
+ this.emit();
35
+ }
36
+ /** Marks every stage complete. */
37
+ finish() {
38
+ for (const s of this.stages)
39
+ s.done = s.total;
40
+ this.emit();
41
+ }
42
+ /** Advances a stage by one unit as each promise settles; the stage total becomes the number of promises. */
43
+ track(key, promises) {
44
+ this.total(key, promises.length);
45
+ return Promise.all(promises.map((p) => p.finally(() => {
46
+ this.advance(key);
47
+ })));
48
+ }
49
+ get report() {
50
+ let sum = 0;
51
+ let done = 0;
52
+ let current = null;
53
+ for (const s of this.stages) {
54
+ sum += s.stage.weight;
55
+ done += s.total > 0 ? (s.stage.weight * s.done) / s.total : s.stage.weight;
56
+ if (!current && s.done < s.total)
57
+ current = s;
58
+ }
59
+ const at = current ?? this.stages[this.stages.length - 1];
60
+ return { fraction: sum > 0 ? done / sum : 1, stage: at.stage.key, label: at.stage.label, units: at.done, of: at.total, done: current === null };
61
+ }
62
+ /** Calls `fn` with the report now and after every change; returns the function that stops it. */
63
+ subscribe(fn) {
64
+ this.listeners.add(fn);
65
+ fn(this.report);
66
+ return () => this.listeners.delete(fn);
67
+ }
68
+ get(key) {
69
+ const s = this.stages.find((x) => x.stage.key === key);
70
+ if (!s)
71
+ throw new Error(`Unknown progress stage: ${key}`);
72
+ return s;
73
+ }
74
+ emit() {
75
+ if (this.listeners.size === 0)
76
+ return;
77
+ const r = this.report;
78
+ for (const fn of this.listeners)
79
+ fn(r);
80
+ }
81
+ }
@@ -0,0 +1,177 @@
1
+ import type { VertexLayout } from './data.ts';
2
+ /**
3
+ * How a part moves, about its pivot (local axes: x right, y up, z forward, origin on the ground under the segment
4
+ * anchor):
5
+ * - `fixed`: moves with the segment body (bob, roll, sway)
6
+ * - `spin`: turns about the x axis by distance / `amount` (a roller of radius `amount`); not sprung
7
+ * - `spin-steer`: like `spin`, and turns about y toward the curve by atan(base · curvature) (`RigDesc.steerBase`)
8
+ * - `limb`: a leg of length `amount` swinging about x through the pivot in the gait; the foot keeps still on the
9
+ * ground during the stance half, `phase` 0 or 0.5 picks the side (any phase with `RigDesc.gait` 'free')
10
+ * - `swing`: swings about x in the gait by up to `amount` radians (arms, something carried)
11
+ * - `look`: turns about y while standing, slowly, up to `amount` radians
12
+ * - `wobble`: small noise about x and y with time and distance, up to `amount` radians
13
+ * - `bend`: a link of a chain; the links of one chain share their `pivot` (the root). Every vertex turns about the
14
+ * root, about the part's `axis`, by `amount` (radians per metre) × its rest distance from the root × a wave that
15
+ * travels along the chain with the gait (`phase`: lag in cycles per metre), and slowly while standing
16
+ */
17
+ export type RigMotion = 'fixed' | 'spin' | 'spin-steer' | 'limb' | 'swing' | 'look' | 'wobble' | 'bend';
18
+ export declare const RIG_MOTION: Readonly<Record<RigMotion, number>>;
19
+ /** Index of a `bend` axis; the mesh writes the motion kind `RIG_MOTION.bend + RIG_BEND_AXIS[axis]`. */
20
+ export declare const RIG_BEND_AXIS: Readonly<Record<'x' | 'y' | 'z', number>>;
21
+ /**
22
+ * How a part's surface reads in the image. Lamps light up with `RigLayer.lamps`; `glow` is glass with a lit interior
23
+ * at night; `tiles` is matte with a 0.5 m grid of joints in world space on upward faces (a paved top that lines up
24
+ * across instances).
25
+ */
26
+ export type RigFinish = 'matte' | 'glass' | 'lamp-front' | 'lamp-rear' | 'glow' | 'tiles';
27
+ export declare const RIG_FINISH: Readonly<Record<RigFinish, number>>;
28
+ /** Shape of a part, around its own centre before it is placed. */
29
+ export type RigShape = {
30
+ kind: 'box';
31
+ size: readonly [number, number, number];
32
+ }
33
+ /** Upright frustum: radius at the bottom and top, height, sides; `depth` squashes it front to back. */
34
+ | {
35
+ kind: 'frustum';
36
+ r0: number;
37
+ r1: number;
38
+ height: number;
39
+ sides: number;
40
+ depth?: number;
41
+ cap?: boolean;
42
+ }
43
+ /** Cylinder lying along x (rollers): radius, width, sides. */
44
+ | {
45
+ kind: 'roller';
46
+ radius: number;
47
+ width: number;
48
+ sides: number;
49
+ }
50
+ /** Thin rod from the centre along a local direction: length and thickness. */
51
+ | {
52
+ kind: 'rod';
53
+ dir: readonly [number, number, number];
54
+ length: number;
55
+ thickness: number;
56
+ };
57
+ export interface RigPart {
58
+ shape: RigShape;
59
+ /** Where the shape's centre sits (box, roller) or its foot (frustum, rod start), segment-local metres. */
60
+ at: readonly [number, number, number];
61
+ /** The point it moves about; default `at`. */
62
+ pivot?: readonly [number, number, number];
63
+ motion?: RigMotion;
64
+ amount?: number;
65
+ /** Gait phase offset 0–1 (`limb`, `swing`). */
66
+ phase?: number;
67
+ /** 0 the leading segment, 1 the trailing one. */
68
+ segment?: 0 | 1;
69
+ /** Colour: an instance colour slot 0–3 times `tint`, or a fixed colour when `slot` is missing. */
70
+ slot?: 0 | 1 | 2 | 3;
71
+ tint?: readonly [number, number, number];
72
+ finish?: RigFinish;
73
+ /** Drawn only when the instance has this variant bit set (0–7). */
74
+ variant?: number;
75
+ /** Left out of the far level of detail. */
76
+ nearOnly?: boolean;
77
+ /** `bend` only: the axis the link turns about (local axes of the rig). Default 'y'. */
78
+ axis?: 'x' | 'y' | 'z';
79
+ }
80
+ export interface RigSegment {
81
+ /** Contact shadow under the segment: half width, half length, centre offset forward (metres). */
82
+ shadow: readonly [number, number, number];
83
+ }
84
+ export interface RigDesc {
85
+ name: string;
86
+ parts: readonly RigPart[];
87
+ /** One or two segments; the second follows the same path behind (the app places it). */
88
+ segments: readonly RigSegment[];
89
+ /** Gait cycle length in metres (two steps) at scale 1. Default 1.4. */
90
+ stride?: number;
91
+ /** Distance between the steering and the fixed axle, metres (`spin-steer`). */
92
+ steerBase?: number;
93
+ /** Body roll per (speed × turn rate), radians per m/s², and its limit. Positive leans out of the curve. */
94
+ roll?: number;
95
+ rollLimit?: number;
96
+ /** Suspension bob amplitude in metres while moving. */
97
+ bob?: number;
98
+ /** Below this size on screen (CSS pixels for the rig height) the far level of detail is used; below `hidePx` none. */
99
+ farPx?: number;
100
+ hidePx?: number;
101
+ /** Height of the rig in metres at scale 1, for the screen size and culling. */
102
+ height: number;
103
+ /** Reach from the anchor, metres, for culling. */
104
+ radius: number;
105
+ /**
106
+ * How the `limb` parts keep their end points on the ground. 'pair' (default): two stance phases, the body dips by
107
+ * the geometry of the first limb, `phase` 0 or 0.5. 'free': every limb plants its own end point for any `phase`
108
+ * and `amount`, aimed at it and stretched along its length; the body dips by `dip`.
109
+ */
110
+ gait?: 'pair' | 'free';
111
+ /** 'free' only: body dip per step in metres at scale 1, twice per cycle. Default 0. */
112
+ dip?: number;
113
+ /** 'free' only: the speeds between which the gait fades in, m/s at scale 1. Default [0.15, 0.9]. */
114
+ walkSpeed?: readonly [number, number];
115
+ }
116
+ /**
117
+ * True when a description needs the extended pose (a 'free' gait or any `bend` part); such kinds are drawn by a
118
+ * second program, every other kind by the same program as before these options existed.
119
+ */
120
+ export declare function rigExtended(desc: RigDesc): boolean;
121
+ /** Vertex of a rig mesh: position, normal, pivot, motion (kind, amount, segment, colour slot), colour, extra (phase, variant, near only). */
122
+ export declare const RIG_VERTEX_LAYOUT: VertexLayout;
123
+ export declare const RIG_VERTEX_FLOATS = 19;
124
+ /**
125
+ * One rig instance, `RIG_INSTANCE_FLOATS` floats:
126
+ * - 0–3: leading segment anchor x, y, z, slope (rise per metre forward)
127
+ * - 4–7: leading direction x, z, trailing direction x, z
128
+ * - 8–11: trailing segment anchor x, y, z, slope
129
+ * - 12–15: distance travelled (m), speed (m/s), turn rate (rad/s, positive right), seed 0–1
130
+ * - 16–19: state (0 moving, 1 standing, 2 parked; kept for the owner, no shader of the engine reads it), height scale,
131
+ * width scale, variant bits
132
+ * - 20–23: four colours, each 0xRRGGBB as a float
133
+ */
134
+ export declare const RIG_INSTANCE_FLOATS = 24;
135
+ export declare const RIG_INSTANCE_LAYOUT: VertexLayout;
136
+ export declare const RIG_ATTRIBS: Readonly<Record<string, number>>;
137
+ /** Packs an RGB colour (0–1 per channel) into one float for the instance record. */
138
+ export declare function packRgb(r: number, g: number, b: number): number;
139
+ /**
140
+ * One instance as named fields, for `writeRigInstance`. Reuse one object for every instance of a frame. A rig of one
141
+ * segment leaves the trailing fields at the leading values (or anything: they are not read).
142
+ */
143
+ export interface RigInstance {
144
+ x: number;
145
+ y: number;
146
+ z: number;
147
+ /** Rise per metre forward along the heading. */
148
+ slope: number;
149
+ dirX: number;
150
+ dirZ: number;
151
+ /** Trailing segment: anchor, slope and heading. */
152
+ x1: number;
153
+ y1: number;
154
+ z1: number;
155
+ slope1: number;
156
+ dirX1: number;
157
+ dirZ1: number;
158
+ /** Distance travelled in metres (gait and wheel phase), speed m/s, turn rate rad/s (positive right). */
159
+ distance: number;
160
+ speed: number;
161
+ turnRate: number;
162
+ /** 0–1, varies idle motion between instances. */
163
+ seed: number;
164
+ /**
165
+ * 0 moving, 1 standing, 2 parked. Stored in the record for the owner (and a game material); no shader of the engine
166
+ * reads it: the pose follows from speed and distance alone.
167
+ */
168
+ state: number;
169
+ heightScale: number;
170
+ widthScale: number;
171
+ /** Bit i set = parts with `variant: i` are present. */
172
+ variants: number;
173
+ /** Colours of the four slots, each from `packRgb`. */
174
+ colors: readonly [number, number, number, number];
175
+ }
176
+ /** Writes instance `index` into a record buffer of `RIG_INSTANCE_FLOATS` floats per instance. */
177
+ export declare function writeRigInstance(out: Float32Array, index: number, r: RigInstance): void;