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,459 @@
1
+ // Nested reference frames. A frame is an origin and a rotation given in its parent frame; frames form a hierarchy
2
+ // (a whole system at the top, a moving body below it, a patch of the body's surface below that). Every position is
3
+ // kept in the frame it is naturally small or exact in, as 64-bit numbers on the CPU. Only a difference to the eye,
4
+ // taken in 64 bits, ever becomes a 32-bit float for the GPU (`relativeMatrix`, `relativePoints`), so an object next
5
+ // to the eye keeps its precision however far the frames are from the top origin.
6
+ //
7
+ // A conversion between two frames walks up to their lowest common frame and down again, so numbers of the far
8
+ // levels never enter a conversion between neighbours. Frames may move: a frame can carry the velocity of its origin
9
+ // and its angular velocity, and `convertState` and `reparent` account for both.
10
+ //
11
+ // All arithmetic is + − × ÷ and `Math.sqrt`, rotations come from the reproducible sine and cosine of `trig.ts`, so
12
+ // the same inputs give the same bits on every machine.
13
+ import { detAsin, detAtan2, detSinCosTurns, RAD_PER_TURN } from './trig.js';
14
+ export function quatIdentity() {
15
+ return [0, 0, 0, 1];
16
+ }
17
+ /** Rotation by `turns` (1 = 360°) about a unit axis, right-handed. */
18
+ export function quatAxisTurns(axis, turns) {
19
+ const [s, c] = detSinCosTurns((turns - Math.floor(turns)) * 0.5);
20
+ return [axis[0] * s, axis[1] * s, axis[2] * s, c];
21
+ }
22
+ /** The rotation "first `b`, then `a`". */
23
+ export function quatMul(a, b) {
24
+ return [
25
+ a[3] * b[0] + a[0] * b[3] + a[1] * b[2] - a[2] * b[1],
26
+ a[3] * b[1] - a[0] * b[2] + a[1] * b[3] + a[2] * b[0],
27
+ a[3] * b[2] + a[0] * b[1] - a[1] * b[0] + a[2] * b[3],
28
+ a[3] * b[3] - a[0] * b[0] - a[1] * b[1] - a[2] * b[2],
29
+ ];
30
+ }
31
+ /** The opposite rotation of a unit quaternion. */
32
+ export function quatConj(q) {
33
+ return [-q[0], -q[1], -q[2], q[3]];
34
+ }
35
+ export function quatNormalize(q) {
36
+ const l = Math.sqrt(q[0] * q[0] + q[1] * q[1] + q[2] * q[2] + q[3] * q[3]) || 1;
37
+ return [q[0] / l, q[1] / l, q[2] / l, q[3] / l];
38
+ }
39
+ /** Turns a vector by a unit quaternion. `out` may be the same array as `v`. */
40
+ export function quatRotate(q, v, out = [0, 0, 0]) {
41
+ const x = q[0];
42
+ const y = q[1];
43
+ const z = q[2];
44
+ const w = q[3];
45
+ const vx = v[0];
46
+ const vy = v[1];
47
+ const vz = v[2];
48
+ const tx = 2 * (y * vz - z * vy);
49
+ const ty = 2 * (z * vx - x * vz);
50
+ const tz = 2 * (x * vy - y * vx);
51
+ out[0] = vx + w * tx + (y * tz - z * ty);
52
+ out[1] = vy + w * ty + (z * tx - x * tz);
53
+ out[2] = vz + w * tz + (x * ty - y * tx);
54
+ return out;
55
+ }
56
+ /** Rotation whose turned x, y and z axes are the given unit, mutually perpendicular, right-handed vectors. */
57
+ export function quatFromAxes(x, y, z) {
58
+ const m00 = x[0];
59
+ const m10 = x[1];
60
+ const m20 = x[2];
61
+ const m01 = y[0];
62
+ const m11 = y[1];
63
+ const m21 = y[2];
64
+ const m02 = z[0];
65
+ const m12 = z[1];
66
+ const m22 = z[2];
67
+ const trace = m00 + m11 + m22;
68
+ let q;
69
+ if (trace > 0) {
70
+ const s = Math.sqrt(trace + 1) * 2;
71
+ q = [(m21 - m12) / s, (m02 - m20) / s, (m10 - m01) / s, s / 4];
72
+ }
73
+ else if (m00 > m11 && m00 > m22) {
74
+ const s = Math.sqrt(1 + m00 - m11 - m22) * 2;
75
+ q = [s / 4, (m01 + m10) / s, (m02 + m20) / s, (m21 - m12) / s];
76
+ }
77
+ else if (m11 > m22) {
78
+ const s = Math.sqrt(1 + m11 - m00 - m22) * 2;
79
+ q = [(m01 + m10) / s, s / 4, (m12 + m21) / s, (m02 - m20) / s];
80
+ }
81
+ else {
82
+ const s = Math.sqrt(1 + m22 - m00 - m11) * 2;
83
+ q = [(m02 + m20) / s, (m12 + m21) / s, s / 4, (m10 - m01) / s];
84
+ }
85
+ return quatNormalize(q);
86
+ }
87
+ /** Parent of a top frame. */
88
+ export const FRAME_NONE = -1;
89
+ // Record of one frame: origin 3, rotation 4, velocity of the origin 3, angular velocity 3 (all in the parent).
90
+ const STRIDE = 13;
91
+ const AT_ROT = 3;
92
+ const AT_VEL = 7;
93
+ const AT_SPIN = 10;
94
+ /**
95
+ * A hierarchy of frames. A frame is a small integer id; ids are given out in order and never reused. A top frame
96
+ * (parent `FRAME_NONE`) has no pose. Frames under different top frames cannot be converted to each other.
97
+ */
98
+ export class FrameSet {
99
+ parents = [];
100
+ names = [];
101
+ data = new Float64Array(8 * STRIDE);
102
+ get count() {
103
+ return this.parents.length;
104
+ }
105
+ /** Adds a frame under `parent` (a top frame when omitted) and returns its id. */
106
+ add(name, parent = FRAME_NONE, pose) {
107
+ if (parent !== FRAME_NONE)
108
+ this.check(parent);
109
+ const id = this.parents.length;
110
+ if ((id + 1) * STRIDE > this.data.length) {
111
+ const grown = new Float64Array(this.data.length * 2);
112
+ grown.set(this.data);
113
+ this.data = grown;
114
+ }
115
+ this.parents.push(parent);
116
+ this.names.push(name);
117
+ this.data[id * STRIDE + AT_ROT + 3] = 1;
118
+ if (pose?.origin)
119
+ this.setOrigin(id, pose.origin);
120
+ if (pose?.rotation)
121
+ this.setRotation(id, pose.rotation);
122
+ return id;
123
+ }
124
+ check(id) {
125
+ if (!Number.isInteger(id) || id < 0 || id >= this.parents.length)
126
+ throw new Error(`frames: no frame ${id}`);
127
+ }
128
+ name(id) {
129
+ this.check(id);
130
+ return this.names[id];
131
+ }
132
+ /** Id of the first frame with this name, or `FRAME_NONE`. */
133
+ find(name) {
134
+ return this.names.indexOf(name);
135
+ }
136
+ /** Parent of a frame, `FRAME_NONE` for a top frame. */
137
+ parent(id) {
138
+ this.check(id);
139
+ return this.parents[id];
140
+ }
141
+ /** Number of frames above this one (0 for a top frame). */
142
+ depth(id) {
143
+ this.check(id);
144
+ let d = 0;
145
+ for (let f = this.parents[id]; f !== FRAME_NONE; f = this.parents[f])
146
+ d++;
147
+ return d;
148
+ }
149
+ /** Origin of the frame in its parent (metres, 64-bit). */
150
+ setOrigin(id, origin) {
151
+ this.check(id);
152
+ const at = id * STRIDE;
153
+ this.data[at] = origin[0];
154
+ this.data[at + 1] = origin[1];
155
+ this.data[at + 2] = origin[2];
156
+ }
157
+ /** Rotation of the frame in its parent (a unit quaternion). */
158
+ setRotation(id, rotation) {
159
+ this.check(id);
160
+ const at = id * STRIDE + AT_ROT;
161
+ this.data[at] = rotation[0];
162
+ this.data[at + 1] = rotation[1];
163
+ this.data[at + 2] = rotation[2];
164
+ this.data[at + 3] = rotation[3];
165
+ }
166
+ setPose(id, pose) {
167
+ this.setOrigin(id, pose.origin);
168
+ this.setRotation(id, pose.rotation);
169
+ }
170
+ /**
171
+ * How the frame moves in its parent: velocity of its origin (m/s) and its angular velocity (rad/s, the vector along
172
+ * the turning axis), both in parent coordinates. Only `convertState` and `reparent` read it; a frame that is moved
173
+ * by `setOrigin` alone counts as standing.
174
+ */
175
+ setMotion(id, velocity, spin = [0, 0, 0]) {
176
+ this.check(id);
177
+ const at = id * STRIDE;
178
+ for (let k = 0; k < 3; k++) {
179
+ this.data[at + AT_VEL + k] = velocity[k];
180
+ this.data[at + AT_SPIN + k] = spin[k];
181
+ }
182
+ }
183
+ /** Pose of the frame in its parent (a copy). */
184
+ pose(id) {
185
+ this.check(id);
186
+ const d = this.data;
187
+ const at = id * STRIDE;
188
+ return { origin: [d[at], d[at + 1], d[at + 2]], rotation: [d[at + 3], d[at + 4], d[at + 5], d[at + 6]] };
189
+ }
190
+ /** Velocity of the frame's origin in its parent. */
191
+ velocity(id) {
192
+ this.check(id);
193
+ const at = id * STRIDE + AT_VEL;
194
+ return [this.data[at], this.data[at + 1], this.data[at + 2]];
195
+ }
196
+ /** Angular velocity of the frame in its parent. */
197
+ spin(id) {
198
+ this.check(id);
199
+ const at = id * STRIDE + AT_SPIN;
200
+ return [this.data[at], this.data[at + 1], this.data[at + 2]];
201
+ }
202
+ /** The deepest frame that both frames lie in or under (either of them when one is above the other). */
203
+ commonAncestor(a, b) {
204
+ let da = this.depth(a);
205
+ let db = this.depth(b);
206
+ let fa = a;
207
+ let fb = b;
208
+ for (; da > db; da--)
209
+ fa = this.parents[fa];
210
+ for (; db > da; db--)
211
+ fb = this.parents[fb];
212
+ while (fa !== fb) {
213
+ fa = this.parents[fa];
214
+ fb = this.parents[fb];
215
+ if (fa === FRAME_NONE || fb === FRAME_NONE)
216
+ return FRAME_NONE;
217
+ }
218
+ return fa;
219
+ }
220
+ /** One level up: from the coordinates of frame `f` to those of its parent. */
221
+ up(f, s) {
222
+ const d = this.data;
223
+ const at = f * STRIDE;
224
+ const r = [d[at + 3], d[at + 4], d[at + 5], d[at + 6]];
225
+ const wx = d[at + AT_SPIN];
226
+ const wy = d[at + AT_SPIN + 1];
227
+ const wz = d[at + AT_SPIN + 2];
228
+ quatRotate(r, s.p, s.p);
229
+ quatRotate(r, s.v, s.v);
230
+ quatRotate(r, s.w, s.w);
231
+ const px = s.p[0];
232
+ const py = s.p[1];
233
+ const pz = s.p[2];
234
+ s.v[0] += d[at + AT_VEL] + (wy * pz - wz * py);
235
+ s.v[1] += d[at + AT_VEL + 1] + (wz * px - wx * pz);
236
+ s.v[2] += d[at + AT_VEL + 2] + (wx * py - wy * px);
237
+ s.p[0] = d[at] + px;
238
+ s.p[1] = d[at + 1] + py;
239
+ s.p[2] = d[at + 2] + pz;
240
+ s.w[0] += wx;
241
+ s.w[1] += wy;
242
+ s.w[2] += wz;
243
+ s.q = quatMul(r, s.q);
244
+ }
245
+ /** One level down: from the coordinates of the parent of frame `f` to those of `f`. */
246
+ down(f, s) {
247
+ const d = this.data;
248
+ const at = f * STRIDE;
249
+ const inv = [-d[at + 3], -d[at + 4], -d[at + 5], d[at + 6]];
250
+ const wx = d[at + AT_SPIN];
251
+ const wy = d[at + AT_SPIN + 1];
252
+ const wz = d[at + AT_SPIN + 2];
253
+ const px = s.p[0] - d[at];
254
+ const py = s.p[1] - d[at + 1];
255
+ const pz = s.p[2] - d[at + 2];
256
+ s.v[0] -= d[at + AT_VEL] + (wy * pz - wz * py);
257
+ s.v[1] -= d[at + AT_VEL + 1] + (wz * px - wx * pz);
258
+ s.v[2] -= d[at + AT_VEL + 2] + (wx * py - wy * px);
259
+ s.p[0] = px;
260
+ s.p[1] = py;
261
+ s.p[2] = pz;
262
+ s.w[0] -= wx;
263
+ s.w[1] -= wy;
264
+ s.w[2] -= wz;
265
+ quatRotate(inv, s.p, s.p);
266
+ quatRotate(inv, s.v, s.v);
267
+ quatRotate(inv, s.w, s.w);
268
+ s.q = quatMul(inv, s.q);
269
+ }
270
+ /** Carries a point with its velocity, orientation and angular velocity from frame `from` to frame `to`. */
271
+ carry(s, from, to) {
272
+ const top = this.commonAncestor(from, to);
273
+ if (top === FRAME_NONE)
274
+ throw new Error(`frames: "${this.names[from]}" and "${this.names[to]}" have no common frame`);
275
+ for (let f = from; f !== top; f = this.parents[f])
276
+ this.up(f, s);
277
+ const chain = [];
278
+ for (let f = to; f !== top; f = this.parents[f])
279
+ chain.push(f);
280
+ for (let i = chain.length - 1; i >= 0; i--)
281
+ this.down(chain[i], s);
282
+ }
283
+ /** A point given in frame `from`, in the coordinates of frame `to` (64-bit). */
284
+ convertPoint(p, from, to, out = [0, 0, 0]) {
285
+ const s = { p: [p[0], p[1], p[2]], v: [0, 0, 0], q: [0, 0, 0, 1], w: [0, 0, 0] };
286
+ this.carry(s, from, to);
287
+ out[0] = s.p[0];
288
+ out[1] = s.p[1];
289
+ out[2] = s.p[2];
290
+ return out;
291
+ }
292
+ /** A direction (or any difference of two points) given in frame `from`, in the coordinates of frame `to`. */
293
+ convertDirection(d, from, to, out = [0, 0, 0]) {
294
+ return quatRotate(this.convertRotation([0, 0, 0, 1], from, to), d, out);
295
+ }
296
+ /** An orientation given in frame `from`, in the coordinates of frame `to`. */
297
+ convertRotation(q, from, to) {
298
+ const s = { p: [0, 0, 0], v: [0, 0, 0], q: [q[0], q[1], q[2], q[3]], w: [0, 0, 0] };
299
+ this.carry(s, from, to);
300
+ return quatNormalize(s.q);
301
+ }
302
+ /**
303
+ * A point and its velocity given in (and relative to) frame `from`, in and relative to frame `to`. Uses the motion
304
+ * of the frames on the way (`setMotion`): a point standing on a turning frame moves when seen from its parent.
305
+ */
306
+ convertState(position, velocity, from, to) {
307
+ const s = { p: [position[0], position[1], position[2]], v: [velocity[0], velocity[1], velocity[2]], q: [0, 0, 0, 1], w: [0, 0, 0] };
308
+ this.carry(s, from, to);
309
+ return { position: s.p, velocity: s.v };
310
+ }
311
+ /** Pose of frame `from` in frame `to`: a point p of `from` is at `origin + rotation · p` in `to`. */
312
+ relativePose(from, to) {
313
+ const s = { p: [0, 0, 0], v: [0, 0, 0], q: [0, 0, 0, 1], w: [0, 0, 0] };
314
+ this.carry(s, from, to);
315
+ return { origin: s.p, rotation: quatNormalize(s.q) };
316
+ }
317
+ /**
318
+ * Unit direction and distance from the point `at` of frame `frame` to the origin of frame `target`, in the
319
+ * coordinates of `frame`. With a light at the origin of `target` this is the direction toward the light.
320
+ */
321
+ directionTo(target, frame, at = [0, 0, 0]) {
322
+ const p = this.convertPoint([0, 0, 0], target, frame);
323
+ const x = p[0] - at[0];
324
+ const y = p[1] - at[1];
325
+ const z = p[2] - at[2];
326
+ const distance = Math.sqrt(x * x + y * y + z * z);
327
+ return { direction: distance > 0 ? [x / distance, y / distance, z / distance] : [0, 1, 0], distance };
328
+ }
329
+ /**
330
+ * Moves a frame under another parent without moving it: its pose, velocity and angular velocity are rewritten so
331
+ * that everything in it stays where it was. Both parents must lie under the same top frame, and the new parent
332
+ * must not be the frame itself or one of the frames below it. Do it on a simulation step, never between steps.
333
+ */
334
+ reparent(id, parent) {
335
+ this.check(id);
336
+ this.check(parent);
337
+ const old = this.parents[id];
338
+ if (old === parent)
339
+ return;
340
+ if (old === FRAME_NONE)
341
+ throw new Error(`frames: "${this.names[id]}" is a top frame and cannot get a parent`);
342
+ for (let f = parent; f !== FRAME_NONE; f = this.parents[f]) {
343
+ if (f === id)
344
+ throw new Error(`frames: "${this.names[parent]}" lies under "${this.names[id]}"`);
345
+ }
346
+ const pose = this.pose(id);
347
+ const s = { p: pose.origin, v: this.velocity(id), q: pose.rotation, w: this.spin(id) };
348
+ this.carry(s, old, parent);
349
+ this.parents[id] = parent;
350
+ this.setOrigin(id, s.p);
351
+ this.setRotation(id, quatNormalize(s.q));
352
+ this.setMotion(id, s.v, s.w);
353
+ }
354
+ /**
355
+ * 32-bit digest of every bit of every frame (parents, poses, motion). Two runs that agree here agree exactly; use
356
+ * it to compare a stepped run with a jump in time, or one machine with another.
357
+ */
358
+ fingerprint() {
359
+ const n = this.parents.length;
360
+ const view = new DataView(this.data.buffer, this.data.byteOffset, n * STRIDE * 8);
361
+ let h = 0x811c9dc5 ^ n;
362
+ for (let i = 0; i < n; i++)
363
+ h = Math.imul(h ^ (this.parents[i] + 1), 0x01000193);
364
+ for (let i = 0; i < view.byteLength; i += 4) {
365
+ h = Math.imul(h ^ view.getUint32(i, true), 0x01000193);
366
+ h ^= h >>> 15;
367
+ }
368
+ h = Math.imul(h ^ (h >>> 16), 0x85ebca6b);
369
+ h = Math.imul(h ^ (h >>> 13), 0xc2b2ae35);
370
+ return (h ^ (h >>> 16)) >>> 0;
371
+ }
372
+ }
373
+ /**
374
+ * Model matrix for the GPU (4×4, column-major, 32-bit): takes the local coordinates of a frame to coordinates
375
+ * relative to the eye. `pose` is the frame in the frame the image is drawn in (`FrameSet.relativePose`), `eye` a
376
+ * point of that drawing frame (the camera or a render origin near it). The translation is the 64-bit difference
377
+ * `pose.origin − eye` and only then rounded, so it is small and exact near the eye.
378
+ */
379
+ export function relativeMatrix(pose, eye, out = new Float32Array(16)) {
380
+ const [x, y, z, w] = pose.rotation;
381
+ out[0] = 1 - 2 * (y * y + z * z);
382
+ out[1] = 2 * (x * y + w * z);
383
+ out[2] = 2 * (x * z - w * y);
384
+ out[3] = 0;
385
+ out[4] = 2 * (x * y - w * z);
386
+ out[5] = 1 - 2 * (x * x + z * z);
387
+ out[6] = 2 * (y * z + w * x);
388
+ out[7] = 0;
389
+ out[8] = 2 * (x * z + w * y);
390
+ out[9] = 2 * (y * z - w * x);
391
+ out[10] = 1 - 2 * (x * x + y * y);
392
+ out[11] = 0;
393
+ out[12] = pose.origin[0] - eye[0];
394
+ out[13] = pose.origin[1] - eye[1];
395
+ out[14] = pose.origin[2] - eye[2];
396
+ out[15] = 1;
397
+ return out;
398
+ }
399
+ /**
400
+ * 64-bit points (x, y, z triples) to 32-bit positions relative to the eye. With a `pose` the points are local to that
401
+ * frame and are first placed by it; with `null` they already are in the frame of the eye. The whole sum is done in
402
+ * 64 bits and rounded once.
403
+ */
404
+ export function relativePoints(points, pose, eye, out = new Float32Array(points.length)) {
405
+ const p = [0, 0, 0];
406
+ const ox = (pose ? pose.origin[0] : 0) - eye[0];
407
+ const oy = (pose ? pose.origin[1] : 0) - eye[1];
408
+ const oz = (pose ? pose.origin[2] : 0) - eye[2];
409
+ for (let i = 0; i + 2 < points.length; i += 3) {
410
+ p[0] = points[i];
411
+ p[1] = points[i + 1];
412
+ p[2] = points[i + 2];
413
+ if (pose)
414
+ quatRotate(pose.rotation, p, p);
415
+ out[i] = p[0] + ox;
416
+ out[i + 1] = p[1] + oy;
417
+ out[i + 2] = p[2] + oz;
418
+ }
419
+ return out;
420
+ }
421
+ const DEG_PER_RAD = 360 / RAD_PER_TURN;
422
+ /**
423
+ * Unit direction of a point of a sphere from latitude and longitude in degrees. +y is the pole of positive latitude;
424
+ * longitude 0 is +x and grows toward −z, which is the way a frame with a positive rotation about +y turns (east).
425
+ */
426
+ export function directionFromDeg(latitudeDeg, longitudeDeg) {
427
+ const [sinLat, cosLat] = detSinCosTurns(latitudeDeg / 360);
428
+ const [sinLon, cosLon] = detSinCosTurns(longitudeDeg / 360);
429
+ return [cosLat * cosLon, sinLat, -cosLat * sinLon];
430
+ }
431
+ /** Latitude (−90 … 90) and longitude (−180 … 180) in degrees of a direction; the inverse of `directionFromDeg`. */
432
+ export function directionToDeg(dir) {
433
+ const l = Math.sqrt(dir[0] * dir[0] + dir[1] * dir[1] + dir[2] * dir[2]) || 1;
434
+ return { latitudeDeg: detAsin(dir[1] / l) * DEG_PER_RAD, longitudeDeg: detAtan2(-dir[2] / l, dir[0] / l) * DEG_PER_RAD };
435
+ }
436
+ /**
437
+ * Pose of a frame that touches a sphere around the parent's origin: its origin is `distance` along `up`, its +y is
438
+ * `up`, its +x points east (about the parent's +y) and its +z south, the axes of a flat map. At the pole of the
439
+ * parent's +y the axes are those of the parent.
440
+ */
441
+ export function tangentPose(up, distance) {
442
+ const l = Math.sqrt(up[0] * up[0] + up[1] * up[1] + up[2] * up[2]) || 1;
443
+ const u = [up[0] / l, up[1] / l, up[2] / l];
444
+ // East = (parent +y) × up; at either pole it is undefined and +x is taken.
445
+ let ex = u[2];
446
+ let ez = -u[0];
447
+ const el = Math.sqrt(ex * ex + ez * ez);
448
+ if (el < 1e-12) {
449
+ ex = 1;
450
+ ez = 0;
451
+ }
452
+ else {
453
+ ex /= el;
454
+ ez /= el;
455
+ }
456
+ // South = east × up.
457
+ const south = [-ez * u[1], ez * u[0] - ex * u[2], ex * u[1]];
458
+ return { origin: [u[0] * distance, u[1] * distance, u[2] * distance], rotation: quatFromAxes([ex, 0, ez], u, south) };
459
+ }
@@ -0,0 +1,21 @@
1
+ export { DEG, add, clamp, cross, crossInto, dot, lerp, normalize, orthoMatrix, scale, smoothstep } from './math.ts';
2
+ export type { OrthoFrame, RGB, Vec3 } from './math.ts';
3
+ export { MAT34_FLOATS, mat34Copy, mat34Determinant, mat34Direction, mat34FromQuat, mat34Identity, mat34Invert, mat34Multiply, mat34Normal, mat34Point, mat34RotationAxis, mat34RotationX, mat34RotationY, mat34RotationZ, mat34Scaling, mat34Translation, } from './mat34.ts';
4
+ export type { Mat34, Vec3Out } from './mat34.ts';
5
+ export { boxInVolume, depthViewProj, distanceToBox, newCornerRays, newOrthoFrame, snapRenderOrigin, toRenderSpace } from './view.ts';
6
+ export type { Box3, CullBox, CullFrustum, CullVolume, DepthMode, DepthProjection, OriginAxes, Ray, View } from './view.ts';
7
+ export { primitiveCount, texelBytes } from './data.ts';
8
+ export type { InstanceBounds, InstanceData, MeshData, Primitive, ScalarType, TextureData, TextureFormat, TextureSampling, VertexAttrib, VertexLayout } from './data.ts';
9
+ export type { BakeDesc, BakeTarget, BlendFactor, BlendSpec, CullMode, DrawState, MaterialDesc, PassName, ShaderSource, UniformValue, Uniforms } from './material.ts';
10
+ export type { EnvSlot, FogLayer, FrameEnvironment, FrameField, FrameRegion, LightMode } from './env-slot.ts';
11
+ export { DAMAGE, PART_FLAG, PART_ROLE, RUBBLE, entryDir, entryRung, entryVariant, packEntry } from './destructible.ts';
12
+ export type { ConvexPiece, DamageEntry, DamageRung, DestructibleMaterial, DestructionEvent, PartRole, RubbleArchetype, RubbleFootprint, StructureBond, StructureDesc, StructurePart, StructureState } from './destructible.ts';
13
+ export { RIG_ATTRIBS, RIG_BEND_AXIS, RIG_FINISH, RIG_INSTANCE_FLOATS, RIG_INSTANCE_LAYOUT, RIG_MOTION, RIG_VERTEX_FLOATS, RIG_VERTEX_LAYOUT, packRgb, rigExtended, writeRigInstance } from './rig.ts';
14
+ export type { RigDesc, RigFinish, RigInstance, RigMotion, RigPart, RigSegment, RigShape } from './rig.ts';
15
+ export { Progress } from './progress.ts';
16
+ export type { ProgressReport, ProgressStage } from './progress.ts';
17
+ export { RAD_PER_TURN, detAcos, detAsin, detAtan, detAtan2, detCos, detCosTurns, detSin, detSinCos, detSinCosTurns, detSinTurns } from './trig.ts';
18
+ export { FRAME_NONE, FrameSet, directionFromDeg, directionToDeg, quatAxisTurns, quatConj, quatFromAxes, quatIdentity, quatMul, quatNormalize, quatRotate, relativeMatrix, relativePoints, tangentPose } from './frames.ts';
19
+ export type { FrameBearing, FramePose, FrameState, Quat } from './frames.ts';
20
+ export { radialHeight, radialUpAt, toFramePlane, upFrame } from './up.ts';
21
+ export type { RadialUp, UpFrame } from './up.ts';
@@ -0,0 +1,11 @@
1
+ // Layer 0, base: types and the smallest vector and matrix math. No browser, no GPU, no time.
2
+ export { DEG, add, clamp, cross, crossInto, dot, lerp, normalize, orthoMatrix, scale, smoothstep } from './math.js';
3
+ export { MAT34_FLOATS, mat34Copy, mat34Determinant, mat34Direction, mat34FromQuat, mat34Identity, mat34Invert, mat34Multiply, mat34Normal, mat34Point, mat34RotationAxis, mat34RotationX, mat34RotationY, mat34RotationZ, mat34Scaling, mat34Translation, } from './mat34.js';
4
+ export { boxInVolume, depthViewProj, distanceToBox, newCornerRays, newOrthoFrame, snapRenderOrigin, toRenderSpace } from './view.js';
5
+ export { primitiveCount, texelBytes } from './data.js';
6
+ export { DAMAGE, PART_FLAG, PART_ROLE, RUBBLE, entryDir, entryRung, entryVariant, packEntry } from './destructible.js';
7
+ export { RIG_ATTRIBS, RIG_BEND_AXIS, RIG_FINISH, RIG_INSTANCE_FLOATS, RIG_INSTANCE_LAYOUT, RIG_MOTION, RIG_VERTEX_FLOATS, RIG_VERTEX_LAYOUT, packRgb, rigExtended, writeRigInstance } from './rig.js';
8
+ export { Progress } from './progress.js';
9
+ export { RAD_PER_TURN, detAcos, detAsin, detAtan, detAtan2, detCos, detCosTurns, detSin, detSinCos, detSinCosTurns, detSinTurns } from './trig.js';
10
+ export { FRAME_NONE, FrameSet, directionFromDeg, directionToDeg, quatAxisTurns, quatConj, quatFromAxes, quatIdentity, quatMul, quatNormalize, quatRotate, relativeMatrix, relativePoints, tangentPose } from './frames.js';
11
+ export { radialHeight, radialUpAt, toFramePlane, upFrame } from './up.js';
@@ -0,0 +1,46 @@
1
+ import type { Vec3 } from './math.ts';
2
+ /** A 3 × 4 affine matrix, 12 numbers column by column (see the file comment). */
3
+ export type Mat34 = Float32Array | Float64Array;
4
+ /** Something three numbers can be written into: a `Vec3`, a typed array, a plain array. */
5
+ export type Vec3Out = {
6
+ [index: number]: number;
7
+ };
8
+ /** Floats of one matrix. */
9
+ export declare const MAT34_FLOATS = 12;
10
+ /** The identity. */
11
+ export declare function mat34Identity<T extends Mat34 = Float64Array>(out?: T): T;
12
+ /** Copy of `m`. */
13
+ export declare function mat34Copy<T extends Mat34 = Float64Array>(m: ArrayLike<number>, out?: T): T;
14
+ /** A move by (x, y, z). */
15
+ export declare function mat34Translation<T extends Mat34 = Float64Array>(x: number, y: number, z: number, out?: T): T;
16
+ /** Scaling along the axes; a negative factor mirrors (the determinant turns negative). */
17
+ export declare function mat34Scaling<T extends Mat34 = Float64Array>(sx: number, sy: number, sz: number, out?: T): T;
18
+ /** Rotation about +x. */
19
+ export declare function mat34RotationX<T extends Mat34 = Float64Array>(rad: number, out?: T): T;
20
+ /** Rotation about +y. */
21
+ export declare function mat34RotationY<T extends Mat34 = Float64Array>(rad: number, out?: T): T;
22
+ /** Rotation about +z. */
23
+ export declare function mat34RotationZ<T extends Mat34 = Float64Array>(rad: number, out?: T): T;
24
+ /** Rotation about the axis (ax, ay, az) through the origin; the axis need not be unit. A zero axis gives the identity. */
25
+ export declare function mat34RotationAxis<T extends Mat34 = Float64Array>(ax: number, ay: number, az: number, rad: number, out?: T): T;
26
+ /** Rotation of the unit quaternion `q` = [x, y, z, w], then a move by (tx, ty, tz) (default none). */
27
+ export declare function mat34FromQuat<T extends Mat34 = Float64Array>(q: ArrayLike<number>, out?: T, tx?: number, ty?: number, tz?: number): T;
28
+ /**
29
+ * `a` after `b`: the matrix that first applies `b`, then `a` (a · b). `out` may be `a` or `b`. A transform stack
30
+ * pushes with `mat34Multiply(parent, local, out)`.
31
+ */
32
+ export declare function mat34Multiply<T extends Mat34 = Float64Array>(a: ArrayLike<number>, b: ArrayLike<number>, out?: T): T;
33
+ /** Determinant of the linear part: negative for a mirroring matrix (the winding of its triangles flips), 0 when flat. */
34
+ export declare function mat34Determinant(m: ArrayLike<number>): number;
35
+ /** The inverse of `m`, or null (and `out` untouched) when the linear part is singular. */
36
+ export declare function mat34Invert<T extends Mat34 = Float64Array>(m: ArrayLike<number>, out?: T): T | null;
37
+ /** The point (x, y, z) moved by `m` (linear part and translation). */
38
+ export declare function mat34Point<O extends Vec3Out = Vec3>(m: ArrayLike<number>, x: number, y: number, z: number, out?: O): O;
39
+ /** The direction (x, y, z) turned by the linear part only (no translation, not normalised). */
40
+ export declare function mat34Direction<O extends Vec3Out = Vec3>(m: ArrayLike<number>, x: number, y: number, z: number, out?: O): O;
41
+ /**
42
+ * The surface normal (x, y, z) carried by `m`: the cofactor matrix (the inverse transpose up to the determinant) times
43
+ * the normal, unit length, its sign kept for a mirroring matrix so the normal still points out of the mirrored
44
+ * surface. The same rule as `instanceNormal` in `INSTANCE_SET_GLSL`. A zero result stays zero.
45
+ */
46
+ export declare function mat34Normal<O extends Vec3Out = Vec3>(m: ArrayLike<number>, x: number, y: number, z: number, out?: O): O;