@pibbl/core 0.0.1 → 0.0.3-alpha.109.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 (683) hide show
  1. package/README.md +1 -1
  2. package/THIRD_PARTY_NOTICES.txt +81 -0
  3. package/dist/features/machines/animation.d.ts +64 -0
  4. package/dist/features/machines/animation.js +55 -0
  5. package/dist/features/machines/animation.js.map +7 -0
  6. package/dist/features/machines/animation.mjs +1 -0
  7. package/dist/features/machines/assign.d.ts +16 -0
  8. package/dist/features/machines/assign.js +15 -0
  9. package/dist/features/machines/assign.js.map +7 -0
  10. package/dist/features/machines/callback.d.ts +9 -0
  11. package/dist/features/machines/callback.js +7 -0
  12. package/dist/features/machines/callback.js.map +7 -0
  13. package/dist/features/machines/hook.d.ts +30 -0
  14. package/dist/features/machines/hook.js +37 -0
  15. package/dist/features/machines/hook.js.map +7 -0
  16. package/dist/features/machines/index.d.ts +6 -0
  17. package/dist/features/machines/index.js +12 -0
  18. package/dist/features/machines/index.js.map +7 -0
  19. package/dist/features/machines/index.mjs +1 -0
  20. package/dist/features/machines/runtime.d.ts +18 -0
  21. package/dist/features/machines/runtime.js +363 -0
  22. package/dist/features/machines/runtime.js.map +7 -0
  23. package/dist/features/machines/types.d.ts +164 -0
  24. package/dist/features/physics/2d-geometry.d.ts +3 -3
  25. package/dist/features/physics/2d-geometry.js.map +1 -1
  26. package/dist/features/physics/2d-testing.d.ts +1 -1
  27. package/dist/features/physics/2d-testing.js +2 -2
  28. package/dist/features/physics/2d-testing.js.map +2 -2
  29. package/dist/features/physics/2d.d.ts +115 -62
  30. package/dist/features/physics/2d.js +59 -28
  31. package/dist/features/physics/2d.js.map +2 -2
  32. package/dist/features/physics/lib/2d/canvas/components.js +25 -21
  33. package/dist/features/physics/lib/2d/canvas/components.js.map +2 -2
  34. package/dist/features/physics/lib/2d/canvas/presentation.js +1 -2
  35. package/dist/features/physics/lib/2d/canvas/presentation.js.map +2 -2
  36. package/dist/features/physics/lib/2d/collision/casts.js +4 -2
  37. package/dist/features/physics/lib/2d/collision/casts.js.map +2 -2
  38. package/dist/features/physics/lib/2d/query-types.d.ts +6 -0
  39. package/dist/features/physics/lib/2d/runtime/controller.d.ts +7 -6
  40. package/dist/features/physics/lib/2d/runtime/controller.js +1 -1
  41. package/dist/features/physics/lib/2d/runtime/controller.js.map +2 -2
  42. package/dist/features/physics/lib/2d/runtime/obstacles.js +9 -11
  43. package/dist/features/physics/lib/2d/runtime/obstacles.js.map +2 -2
  44. package/dist/features/physics/lib/2d/shapes.js +8 -9
  45. package/dist/features/physics/lib/2d/shapes.js.map +2 -2
  46. package/dist/features/physics/lib/2d/types.d.ts +8 -30
  47. package/dist/features/physics/lib/2d/world/queries.d.ts +7 -6
  48. package/dist/features/physics/lib/2d/world/queries.js.map +2 -2
  49. package/dist/features/physics/lib/2d/world/rapier.js +22 -26
  50. package/dist/features/physics/lib/2d/world/rapier.js.map +2 -2
  51. package/dist/features/sprites/formats/aseprite.d.ts +5 -0
  52. package/dist/features/sprites/formats/texture-packer.d.ts +5 -0
  53. package/dist/features/sprites/index.d.ts +6 -0
  54. package/dist/features/sprites/loader.d.ts +25 -0
  55. package/dist/features/sprites/loader.js +6 -3
  56. package/dist/features/sprites/loader.js.map +2 -2
  57. package/dist/features/sprites/model.d.ts +75 -0
  58. package/dist/features/sprites/sprite.d.ts +22 -0
  59. package/dist/features/textures/index.d.ts +12 -2
  60. package/dist/features/textures/index.js +33 -1
  61. package/dist/features/textures/index.js.map +2 -2
  62. package/dist/features/textures/lib/chemical-field.d.ts +56 -0
  63. package/dist/features/textures/lib/chemical-field.js +154 -0
  64. package/dist/features/textures/lib/chemical-field.js.map +7 -0
  65. package/dist/features/textures/lib/chemical-recipes.d.ts +119 -0
  66. package/dist/features/textures/lib/chemical-recipes.js +275 -0
  67. package/dist/features/textures/lib/chemical-recipes.js.map +7 -0
  68. package/dist/features/textures/lib/definitions.d.ts +3 -18
  69. package/dist/features/textures/lib/definitions.js +17 -24
  70. package/dist/features/textures/lib/definitions.js.map +2 -2
  71. package/dist/features/textures/lib/geometric-patterns.d.ts +149 -0
  72. package/dist/features/textures/lib/geometric-patterns.js +305 -0
  73. package/dist/features/textures/lib/geometric-patterns.js.map +7 -0
  74. package/dist/features/textures/lib/gray-scott.d.ts +55 -0
  75. package/dist/features/textures/lib/gray-scott.js +37 -0
  76. package/dist/features/textures/lib/gray-scott.js.map +7 -0
  77. package/dist/features/textures/lib/palette.js +1 -3
  78. package/dist/features/textures/lib/palette.js.map +2 -2
  79. package/dist/features/textures/lib/patterns.d.ts +123 -0
  80. package/dist/features/textures/lib/patterns.js +344 -0
  81. package/dist/features/textures/lib/patterns.js.map +7 -0
  82. package/dist/features/textures/lib/rain-drops.js +2 -1
  83. package/dist/features/textures/lib/rain-drops.js.map +2 -2
  84. package/dist/features/textures/lib/reaction-diffusion.d.ts +3 -2
  85. package/dist/features/textures/lib/reaction-diffusion.js +9 -20
  86. package/dist/features/textures/lib/reaction-diffusion.js.map +2 -2
  87. package/dist/features/textures/lib/simulation.d.ts +10 -4
  88. package/dist/features/textures/lib/simulation.js +23 -13
  89. package/dist/features/textures/lib/simulation.js.map +2 -2
  90. package/dist/features/textures/lib/wasm/electric.js +8 -1
  91. package/dist/features/textures/lib/wasm/electric.js.map +2 -2
  92. package/dist/features/textures/lib/water-surface.js +1 -3
  93. package/dist/features/textures/lib/water-surface.js.map +2 -2
  94. package/dist/features/viz/index.d.ts +92 -5
  95. package/dist/features/viz/index.js +202 -4
  96. package/dist/features/viz/index.js.map +2 -2
  97. package/dist/features/viz/inspection/bar.d.ts +79 -0
  98. package/dist/features/viz/inspection/bar.js +49 -0
  99. package/dist/features/viz/inspection/bar.js.map +7 -0
  100. package/dist/features/viz/inspection/candle.d.ts +156 -0
  101. package/dist/features/viz/inspection/candle.js +120 -0
  102. package/dist/features/viz/inspection/candle.js.map +7 -0
  103. package/dist/features/viz/inspection/capture-types.d.ts +65 -0
  104. package/dist/features/viz/inspection/capture.d.ts +16 -0
  105. package/dist/features/viz/inspection/capture.js +49 -0
  106. package/dist/features/viz/inspection/capture.js.map +7 -0
  107. package/dist/features/viz/inspection/handler.d.ts +36 -0
  108. package/dist/features/viz/inspection/handler.js +91 -0
  109. package/dist/features/viz/inspection/handler.js.map +7 -0
  110. package/dist/features/viz/inspection/ohlc-bar.d.ts +132 -0
  111. package/dist/features/viz/inspection/ohlc-bar.js +118 -0
  112. package/dist/features/viz/inspection/ohlc-bar.js.map +7 -0
  113. package/dist/features/viz/inspection/owned-ref.d.ts +16 -0
  114. package/dist/features/viz/inspection/owned-ref.js +99 -0
  115. package/dist/features/viz/inspection/owned-ref.js.map +7 -0
  116. package/dist/features/viz/inspection/painted-point.d.ts +22 -0
  117. package/dist/features/viz/inspection/painted-point.js +29 -0
  118. package/dist/features/viz/inspection/painted-point.js.map +7 -0
  119. package/dist/features/viz/inspection/queries.d.ts +100 -0
  120. package/dist/features/viz/inspection/queries.js +192 -0
  121. package/dist/features/viz/inspection/queries.js.map +7 -0
  122. package/dist/features/viz/inspection/query-types.d.ts +177 -0
  123. package/dist/features/viz/inspection/volume.d.ts +104 -0
  124. package/dist/features/viz/inspection/volume.js +95 -0
  125. package/dist/features/viz/inspection/volume.js.map +7 -0
  126. package/dist/features/viz/inspection.d.ts +19 -0
  127. package/dist/features/viz/inspection.js +54 -0
  128. package/dist/features/viz/inspection.js.map +7 -0
  129. package/dist/features/viz/inspection.mjs +1 -0
  130. package/dist/features/viz/lib/area-series.d.ts +62 -0
  131. package/dist/features/viz/lib/area-series.js +120 -0
  132. package/dist/features/viz/lib/area-series.js.map +7 -0
  133. package/dist/features/viz/lib/axis-labels.d.ts +2 -0
  134. package/dist/features/viz/lib/axis-labels.js +41 -0
  135. package/dist/features/viz/lib/axis-labels.js.map +7 -0
  136. package/dist/features/viz/lib/axis-title.d.ts +23 -0
  137. package/dist/features/viz/lib/axis-title.js +24 -0
  138. package/dist/features/viz/lib/axis-title.js.map +7 -0
  139. package/dist/features/viz/lib/axis.d.ts +1 -1
  140. package/dist/features/viz/lib/axis.js +50 -50
  141. package/dist/features/viz/lib/axis.js.map +2 -2
  142. package/dist/features/viz/lib/bar-scale.d.ts +7 -0
  143. package/dist/features/viz/lib/bar-scale.js +34 -0
  144. package/dist/features/viz/lib/bar-scale.js.map +7 -0
  145. package/dist/features/viz/lib/bar-series.d.ts +3 -1
  146. package/dist/features/viz/lib/bar-series.js +21 -5
  147. package/dist/features/viz/lib/bar-series.js.map +2 -2
  148. package/dist/features/viz/lib/baseline-series.d.ts +55 -0
  149. package/dist/features/viz/lib/baseline-series.js +136 -0
  150. package/dist/features/viz/lib/baseline-series.js.map +7 -0
  151. package/dist/features/viz/lib/candlestick-series.d.ts +62 -0
  152. package/dist/features/viz/lib/candlestick-series.js +150 -0
  153. package/dist/features/viz/lib/candlestick-series.js.map +7 -0
  154. package/dist/features/viz/lib/censored-point-series.d.ts +71 -0
  155. package/dist/features/viz/lib/censored-point-series.js +129 -0
  156. package/dist/features/viz/lib/censored-point-series.js.map +7 -0
  157. package/dist/features/viz/lib/chart-lines.d.ts +41 -0
  158. package/dist/features/viz/lib/chart-lines.js +32 -0
  159. package/dist/features/viz/lib/chart-lines.js.map +7 -0
  160. package/dist/features/viz/lib/color-context.d.ts +4 -0
  161. package/dist/features/viz/lib/color-context.js +41 -0
  162. package/dist/features/viz/lib/color-context.js.map +7 -0
  163. package/dist/features/viz/lib/color-math.d.ts +4 -0
  164. package/dist/features/viz/lib/color-math.js +31 -0
  165. package/dist/features/viz/lib/color-math.js.map +7 -0
  166. package/dist/features/viz/lib/color-types.d.ts +53 -0
  167. package/dist/features/viz/lib/curve-definition.d.ts +49 -0
  168. package/dist/features/viz/lib/curve-definition.js +142 -0
  169. package/dist/features/viz/lib/curve-definition.js.map +7 -0
  170. package/dist/features/viz/lib/diverging-color-scale.d.ts +11 -0
  171. package/dist/features/viz/lib/diverging-color-scale.js +51 -0
  172. package/dist/features/viz/lib/diverging-color-scale.js.map +7 -0
  173. package/dist/features/viz/lib/domain-navigation.d.ts +40 -0
  174. package/dist/features/viz/lib/domain-navigation.js +77 -0
  175. package/dist/features/viz/lib/domain-navigation.js.map +7 -0
  176. package/dist/features/viz/lib/editable-chart-elements.d.ts +178 -0
  177. package/dist/features/viz/lib/editable-chart-elements.js +733 -0
  178. package/dist/features/viz/lib/editable-chart-elements.js.map +7 -0
  179. package/dist/features/viz/lib/financial-aggregation.d.ts +127 -0
  180. package/dist/features/viz/lib/financial-aggregation.js +116 -0
  181. package/dist/features/viz/lib/financial-aggregation.js.map +7 -0
  182. package/dist/features/viz/lib/financial-autoscale.d.ts +64 -0
  183. package/dist/features/viz/lib/financial-autoscale.js +61 -0
  184. package/dist/features/viz/lib/financial-autoscale.js.map +7 -0
  185. package/dist/features/viz/lib/financial-comparison.d.ts +62 -0
  186. package/dist/features/viz/lib/financial-comparison.js +98 -0
  187. package/dist/features/viz/lib/financial-comparison.js.map +7 -0
  188. package/dist/features/viz/lib/financial-geometry.d.ts +77 -0
  189. package/dist/features/viz/lib/financial-geometry.js +67 -0
  190. package/dist/features/viz/lib/financial-geometry.js.map +7 -0
  191. package/dist/features/viz/lib/financial-indicators.d.ts +114 -0
  192. package/dist/features/viz/lib/financial-indicators.js +135 -0
  193. package/dist/features/viz/lib/financial-indicators.js.map +7 -0
  194. package/dist/features/viz/lib/financial-oscillators.d.ts +171 -0
  195. package/dist/features/viz/lib/financial-oscillators.js +265 -0
  196. package/dist/features/viz/lib/financial-oscillators.js.map +7 -0
  197. package/dist/features/viz/lib/graph/bipartite.d.ts +14 -0
  198. package/dist/features/viz/lib/graph/bipartite.js +250 -0
  199. package/dist/features/viz/lib/graph/bipartite.js.map +7 -0
  200. package/dist/features/viz/lib/graph/chord.d.ts +44 -0
  201. package/dist/features/viz/lib/graph/chord.js +348 -0
  202. package/dist/features/viz/lib/graph/chord.js.map +7 -0
  203. package/dist/features/viz/lib/graph/dependency.d.ts +26 -0
  204. package/dist/features/viz/lib/graph/dependency.js +140 -0
  205. package/dist/features/viz/lib/graph/dependency.js.map +7 -0
  206. package/dist/features/viz/lib/graph/force.d.ts +28 -0
  207. package/dist/features/viz/lib/graph/force.js +580 -0
  208. package/dist/features/viz/lib/graph/force.js.map +7 -0
  209. package/dist/features/viz/lib/graph/hierarchy.d.ts +21 -0
  210. package/dist/features/viz/lib/graph/hierarchy.js +112 -0
  211. package/dist/features/viz/lib/graph/hierarchy.js.map +7 -0
  212. package/dist/features/viz/lib/graph/icicle.d.ts +16 -0
  213. package/dist/features/viz/lib/graph/icicle.js +153 -0
  214. package/dist/features/viz/lib/graph/icicle.js.map +7 -0
  215. package/dist/features/viz/lib/graph/matrix.d.ts +30 -0
  216. package/dist/features/viz/lib/graph/matrix.js +243 -0
  217. package/dist/features/viz/lib/graph/matrix.js.map +7 -0
  218. package/dist/features/viz/lib/graph/neighborhood.d.ts +11 -0
  219. package/dist/features/viz/lib/graph/neighborhood.js +281 -0
  220. package/dist/features/viz/lib/graph/neighborhood.js.map +7 -0
  221. package/dist/features/viz/lib/graph/routes.d.ts +35 -0
  222. package/dist/features/viz/lib/graph/routes.js +101 -0
  223. package/dist/features/viz/lib/graph/routes.js.map +7 -0
  224. package/dist/features/viz/lib/graph/sankey.d.ts +44 -0
  225. package/dist/features/viz/lib/graph/sankey.js +341 -0
  226. package/dist/features/viz/lib/graph/sankey.js.map +7 -0
  227. package/dist/features/viz/lib/graph/shared.d.ts +59 -0
  228. package/dist/features/viz/lib/graph/shared.js +301 -0
  229. package/dist/features/viz/lib/graph/shared.js.map +7 -0
  230. package/dist/features/viz/lib/graph/tree.d.ts +11 -0
  231. package/dist/features/viz/lib/graph/tree.js +232 -0
  232. package/dist/features/viz/lib/graph/tree.js.map +7 -0
  233. package/dist/features/viz/lib/graph/treemap.d.ts +20 -0
  234. package/dist/features/viz/lib/graph/treemap.js +227 -0
  235. package/dist/features/viz/lib/graph/treemap.js.map +7 -0
  236. package/dist/features/viz/lib/graph/types.d.ts +1097 -0
  237. package/dist/features/viz/lib/hover-card.js +8 -9
  238. package/dist/features/viz/lib/hover-card.js.map +2 -2
  239. package/dist/features/viz/lib/hover-data.d.ts +1 -1
  240. package/dist/features/viz/lib/hover-data.js +6 -3
  241. package/dist/features/viz/lib/hover-data.js.map +2 -2
  242. package/dist/features/viz/lib/hover-types.d.ts +5 -5
  243. package/dist/features/viz/lib/interval-band-series.d.ts +49 -0
  244. package/dist/features/viz/lib/interval-band-series.js +136 -0
  245. package/dist/features/viz/lib/interval-band-series.js.map +7 -0
  246. package/dist/features/viz/lib/interval-diamond-series.d.ts +43 -0
  247. package/dist/features/viz/lib/interval-diamond-series.js +122 -0
  248. package/dist/features/viz/lib/interval-diamond-series.js.map +7 -0
  249. package/dist/features/viz/lib/interval-series.d.ts +79 -0
  250. package/dist/features/viz/lib/interval-series.js +158 -0
  251. package/dist/features/viz/lib/interval-series.js.map +7 -0
  252. package/dist/features/viz/lib/layout-pie.js +9 -13
  253. package/dist/features/viz/lib/layout-pie.js.map +2 -2
  254. package/dist/features/viz/lib/line-series.d.ts +1 -1
  255. package/dist/features/viz/lib/line-series.js +47 -28
  256. package/dist/features/viz/lib/line-series.js.map +2 -2
  257. package/dist/features/viz/lib/linear-scale-component.d.ts +7 -0
  258. package/dist/features/viz/lib/linear-scale-component.js +18 -0
  259. package/dist/features/viz/lib/linear-scale-component.js.map +7 -0
  260. package/dist/features/viz/lib/linear-scale.js +1 -1
  261. package/dist/features/viz/lib/linear-scale.js.map +2 -2
  262. package/dist/features/viz/lib/log-scale-component.d.ts +7 -0
  263. package/dist/features/viz/lib/log-scale-component.js +19 -0
  264. package/dist/features/viz/lib/log-scale-component.js.map +7 -0
  265. package/dist/features/viz/lib/log-scale.d.ts +2 -0
  266. package/dist/features/viz/lib/log-scale.js +53 -0
  267. package/dist/features/viz/lib/log-scale.js.map +7 -0
  268. package/dist/features/viz/lib/monotone-curve.d.ts +11 -0
  269. package/dist/features/viz/lib/monotone-curve.js +63 -0
  270. package/dist/features/viz/lib/monotone-curve.js.map +7 -0
  271. package/dist/features/viz/lib/nearest.d.ts +9 -9
  272. package/dist/features/viz/lib/nearest.js.map +1 -1
  273. package/dist/features/viz/lib/numeric-range-interpolation.d.ts +15 -0
  274. package/dist/features/viz/lib/numeric-range-interpolation.js +36 -0
  275. package/dist/features/viz/lib/numeric-range-interpolation.js.map +7 -0
  276. package/dist/features/viz/lib/numeric-ticks.d.ts +38 -0
  277. package/dist/features/viz/lib/numeric-ticks.js +54 -0
  278. package/dist/features/viz/lib/numeric-ticks.js.map +7 -0
  279. package/dist/features/viz/lib/ohlc-bar-series.d.ts +55 -0
  280. package/dist/features/viz/lib/ohlc-bar-series.js +168 -0
  281. package/dist/features/viz/lib/ohlc-bar-series.js.map +7 -0
  282. package/dist/features/viz/lib/paired-series.d.ts +44 -0
  283. package/dist/features/viz/lib/paired-series.js +93 -0
  284. package/dist/features/viz/lib/paired-series.js.map +7 -0
  285. package/dist/features/viz/lib/pie-layout.js +2 -1
  286. package/dist/features/viz/lib/pie-layout.js.map +2 -2
  287. package/dist/features/viz/lib/plot-series.js +11 -6
  288. package/dist/features/viz/lib/plot-series.js.map +2 -2
  289. package/dist/features/viz/lib/plot-types.d.ts +4 -3
  290. package/dist/features/viz/lib/point-scale-component.d.ts +7 -0
  291. package/dist/features/viz/lib/point-scale-component.js +19 -0
  292. package/dist/features/viz/lib/point-scale-component.js.map +7 -0
  293. package/dist/features/viz/lib/point-scale.d.ts +2 -0
  294. package/dist/features/viz/lib/point-scale.js +45 -0
  295. package/dist/features/viz/lib/point-scale.js.map +7 -0
  296. package/dist/features/viz/lib/point-series.d.ts +1 -1
  297. package/dist/features/viz/lib/point-series.js +36 -9
  298. package/dist/features/viz/lib/point-series.js.map +2 -2
  299. package/dist/features/viz/lib/point-types.d.ts +5 -2
  300. package/dist/features/viz/lib/reference-band.d.ts +16 -0
  301. package/dist/features/viz/lib/reference-band.js +30 -0
  302. package/dist/features/viz/lib/reference-band.js.map +7 -0
  303. package/dist/features/viz/lib/scale-adjust.js +9 -4
  304. package/dist/features/viz/lib/scale-adjust.js.map +2 -2
  305. package/dist/features/viz/lib/scale-context.d.ts +5 -4
  306. package/dist/features/viz/lib/scale-context.js +15 -11
  307. package/dist/features/viz/lib/scale-context.js.map +2 -2
  308. package/dist/features/viz/lib/scale-provider.d.ts +2 -0
  309. package/dist/features/viz/lib/scale-provider.js +13 -0
  310. package/dist/features/viz/lib/scale-provider.js.map +7 -0
  311. package/dist/features/viz/lib/scale-ticks.d.ts +5 -0
  312. package/dist/features/viz/lib/scale-ticks.js +64 -0
  313. package/dist/features/viz/lib/scale-ticks.js.map +7 -0
  314. package/dist/features/viz/lib/scale-view.d.ts +4 -0
  315. package/dist/features/viz/lib/scale-view.js +21 -0
  316. package/dist/features/viz/lib/scale-view.js.map +7 -0
  317. package/dist/features/viz/lib/sequential-color-scale.d.ts +11 -0
  318. package/dist/features/viz/lib/sequential-color-scale.js +49 -0
  319. package/dist/features/viz/lib/sequential-color-scale.js.map +7 -0
  320. package/dist/features/viz/lib/series-position.d.ts +12 -0
  321. package/dist/features/viz/lib/series-position.js +44 -0
  322. package/dist/features/viz/lib/series-position.js.map +7 -0
  323. package/dist/features/viz/lib/step-curves.d.ts +19 -0
  324. package/dist/features/viz/lib/step-curves.js +53 -0
  325. package/dist/features/viz/lib/step-curves.js.map +7 -0
  326. package/dist/features/viz/lib/symlog-scale-component.d.ts +7 -0
  327. package/dist/features/viz/lib/symlog-scale-component.js +19 -0
  328. package/dist/features/viz/lib/symlog-scale-component.js.map +7 -0
  329. package/dist/features/viz/lib/symlog-scale.d.ts +2 -0
  330. package/dist/features/viz/lib/symlog-scale.js +38 -0
  331. package/dist/features/viz/lib/symlog-scale.js.map +7 -0
  332. package/dist/features/viz/lib/threshold-color-scale.d.ts +43 -0
  333. package/dist/features/viz/lib/threshold-color-scale.js +59 -0
  334. package/dist/features/viz/lib/threshold-color-scale.js.map +7 -0
  335. package/dist/features/viz/lib/trading-time-mapping.d.ts +32 -0
  336. package/dist/features/viz/lib/trading-time-mapping.js +89 -0
  337. package/dist/features/viz/lib/trading-time-mapping.js.map +7 -0
  338. package/dist/features/viz/lib/trading-time-scale.d.ts +83 -0
  339. package/dist/features/viz/lib/trading-time-scale.js +96 -0
  340. package/dist/features/viz/lib/trading-time-scale.js.map +7 -0
  341. package/dist/features/viz/lib/trajectory-series.d.ts +71 -0
  342. package/dist/features/viz/lib/trajectory-series.js +111 -0
  343. package/dist/features/viz/lib/trajectory-series.js.map +7 -0
  344. package/dist/features/viz/lib/types.d.ts +114 -21
  345. package/dist/features/viz/lib/use-bar-scale.d.ts +8 -0
  346. package/dist/features/viz/lib/use-bar-scale.js +9 -0
  347. package/dist/features/viz/lib/use-bar-scale.js.map +7 -0
  348. package/dist/features/viz/lib/use-continuous-scale.d.ts +8 -0
  349. package/dist/features/viz/lib/use-continuous-scale.js +14 -0
  350. package/dist/features/viz/lib/use-continuous-scale.js.map +7 -0
  351. package/dist/features/viz/lib/use-linear-scale.d.ts +8 -0
  352. package/dist/features/viz/lib/use-linear-scale.js +9 -0
  353. package/dist/features/viz/lib/use-linear-scale.js.map +7 -0
  354. package/dist/features/viz/lib/use-log-scale.d.ts +8 -0
  355. package/dist/features/viz/lib/use-log-scale.js +9 -0
  356. package/dist/features/viz/lib/use-log-scale.js.map +7 -0
  357. package/dist/features/viz/lib/use-point-scale.d.ts +8 -0
  358. package/dist/features/viz/lib/use-point-scale.js +9 -0
  359. package/dist/features/viz/lib/use-point-scale.js.map +7 -0
  360. package/dist/features/viz/lib/use-symlog-scale.d.ts +8 -0
  361. package/dist/features/viz/lib/use-symlog-scale.js +9 -0
  362. package/dist/features/viz/lib/use-symlog-scale.js.map +7 -0
  363. package/dist/features/viz/lib/use-utc-scale.d.ts +8 -0
  364. package/dist/features/viz/lib/use-utc-scale.js +9 -0
  365. package/dist/features/viz/lib/use-utc-scale.js.map +7 -0
  366. package/dist/features/viz/lib/utc-labels.d.ts +12 -0
  367. package/dist/features/viz/lib/utc-labels.js +27 -0
  368. package/dist/features/viz/lib/utc-labels.js.map +7 -0
  369. package/dist/features/viz/lib/utc-scale-component.d.ts +7 -0
  370. package/dist/features/viz/lib/utc-scale-component.js +18 -0
  371. package/dist/features/viz/lib/utc-scale-component.js.map +7 -0
  372. package/dist/features/viz/lib/utc-scale.d.ts +21 -0
  373. package/dist/features/viz/lib/utc-scale.js +124 -0
  374. package/dist/features/viz/lib/utc-scale.js.map +7 -0
  375. package/dist/features/viz/lib/volume-series.d.ts +59 -0
  376. package/dist/features/viz/lib/volume-series.js +117 -0
  377. package/dist/features/viz/lib/volume-series.js.map +7 -0
  378. package/dist/features/viz/lib/weighted-point-series.d.ts +71 -0
  379. package/dist/features/viz/lib/weighted-point-series.js +169 -0
  380. package/dist/features/viz/lib/weighted-point-series.js.map +7 -0
  381. package/dist/filters/backdrop-contrast-gpu.d.ts +5 -0
  382. package/dist/filters/backdrop-contrast-gpu.js +33 -0
  383. package/dist/filters/backdrop-contrast-gpu.js.map +7 -0
  384. package/dist/filters/backdrop-contrast.d.ts +21 -0
  385. package/dist/filters/backdrop-contrast.js +61 -0
  386. package/dist/filters/backdrop-contrast.js.map +7 -0
  387. package/dist/filters/displacement.js +1 -1
  388. package/dist/filters/displacement.js.map +2 -2
  389. package/dist/filters/emboss-gpu.d.ts +4 -0
  390. package/dist/filters/emboss-gpu.js +39 -0
  391. package/dist/filters/emboss-gpu.js.map +7 -0
  392. package/dist/filters/emboss.d.ts +32 -0
  393. package/dist/filters/emboss.js +104 -0
  394. package/dist/filters/emboss.js.map +7 -0
  395. package/dist/filters/filter-executor.d.ts +11 -4
  396. package/dist/filters/filter-executor.js +104 -49
  397. package/dist/filters/filter-executor.js.map +2 -2
  398. package/dist/filters/reflected-light.js +1 -1
  399. package/dist/filters/reflected-light.js.map +2 -2
  400. package/dist/filters/reflection-gpu.d.ts +3 -1
  401. package/dist/filters/reflection-gpu.js +5 -2
  402. package/dist/filters/reflection-gpu.js.map +2 -2
  403. package/dist/filters/render-backdrop-contrast-boundary.d.ts +31 -0
  404. package/dist/filters/render-backdrop-contrast-boundary.js +116 -0
  405. package/dist/filters/render-backdrop-contrast-boundary.js.map +7 -0
  406. package/dist/filters/render-emboss-boundary.d.ts +13 -0
  407. package/dist/filters/render-emboss-boundary.js +131 -0
  408. package/dist/filters/render-emboss-boundary.js.map +7 -0
  409. package/dist/filters.d.ts +9 -5
  410. package/dist/filters.js +4 -0
  411. package/dist/filters.js.map +2 -2
  412. package/dist/index.d.ts +10 -6
  413. package/dist/index.js +18 -2
  414. package/dist/index.js.map +2 -2
  415. package/dist/internal.d.ts +4 -0
  416. package/dist/internal.js +6 -0
  417. package/dist/internal.js.map +2 -2
  418. package/dist/layout-kernel.d.ts +12 -0
  419. package/dist/layout-kernel.js +11 -0
  420. package/dist/layout-kernel.js.map +7 -0
  421. package/dist/layout-kernel.mjs +1 -0
  422. package/dist/lib/animation/definition.d.ts +5 -3
  423. package/dist/lib/animation/definition.js +29 -4
  424. package/dist/lib/animation/definition.js.map +2 -2
  425. package/dist/lib/animation/playback.d.ts +8 -0
  426. package/dist/lib/animation/playback.js +33 -11
  427. package/dist/lib/animation/playback.js.map +2 -2
  428. package/dist/lib/animation/spring.d.ts +3 -1
  429. package/dist/lib/animation/spring.js.map +2 -2
  430. package/dist/lib/animation/types.d.ts +29 -73
  431. package/dist/lib/backend/types.d.ts +13 -1
  432. package/dist/lib/backend/types.js.map +2 -2
  433. package/dist/lib/components/arc-geometry.js +2 -1
  434. package/dist/lib/components/arc-geometry.js.map +2 -2
  435. package/dist/lib/components/g.js +2 -0
  436. package/dist/lib/components/g.js.map +2 -2
  437. package/dist/lib/components/html-box.js +2 -1
  438. package/dist/lib/components/html-box.js.map +2 -2
  439. package/dist/lib/components/img.js +3 -3
  440. package/dist/lib/components/img.js.map +2 -2
  441. package/dist/lib/components/layer.js +98 -16
  442. package/dist/lib/components/layer.js.map +3 -3
  443. package/dist/lib/components/text.d.ts +16 -0
  444. package/dist/lib/components/text.js +131 -24
  445. package/dist/lib/components/text.js.map +2 -2
  446. package/dist/lib/define-primitive.d.ts +4 -2
  447. package/dist/lib/define-primitive.js +3 -1
  448. package/dist/lib/define-primitive.js.map +2 -2
  449. package/dist/lib/element/metadata.d.ts +9 -0
  450. package/dist/lib/element/metadata.js +19 -0
  451. package/dist/lib/element/metadata.js.map +2 -2
  452. package/dist/lib/element/resolve-primitive-inputs.d.ts +2 -0
  453. package/dist/lib/element/resolve-primitive-inputs.js +17 -4
  454. package/dist/lib/element/resolve-primitive-inputs.js.map +2 -2
  455. package/dist/lib/events/event-facade.d.ts +18 -0
  456. package/dist/lib/events/event-facade.js +28 -2
  457. package/dist/lib/events/event-facade.js.map +2 -2
  458. package/dist/lib/events/hit-test.js +2 -1
  459. package/dist/lib/events/hit-test.js.map +2 -2
  460. package/dist/lib/events/propagation.d.ts +2 -1
  461. package/dist/lib/events/propagation.js +22 -16
  462. package/dist/lib/events/propagation.js.map +2 -2
  463. package/dist/lib/events/registrations.d.ts +10 -0
  464. package/dist/lib/events/registrations.js +160 -5
  465. package/dist/lib/events/registrations.js.map +2 -2
  466. package/dist/lib/execute-render.js +25 -1
  467. package/dist/lib/execute-render.js.map +2 -2
  468. package/dist/lib/filter/filter-region.js +3 -10
  469. package/dist/lib/filter/filter-region.js.map +2 -2
  470. package/dist/lib/focus/focus-manager.d.ts +8 -1
  471. package/dist/lib/focus/focus-manager.js +87 -43
  472. package/dist/lib/focus/focus-manager.js.map +2 -2
  473. package/dist/lib/focus/geometry.d.ts +2 -0
  474. package/dist/lib/focus/geometry.js +6 -0
  475. package/dist/lib/focus/geometry.js.map +2 -2
  476. package/dist/lib/geometry/path-bend-guide.js +1 -1
  477. package/dist/lib/geometry/path-bend-guide.js.map +2 -2
  478. package/dist/lib/geometry/path-geometry.js +12 -11
  479. package/dist/lib/geometry/path-geometry.js.map +2 -2
  480. package/dist/lib/geometry/path-transforms.js +17 -21
  481. package/dist/lib/geometry/path-transforms.js.map +2 -2
  482. package/dist/lib/geometry/path-warp-bezier.js +3 -1
  483. package/dist/lib/geometry/path-warp-bezier.js.map +2 -2
  484. package/dist/lib/geometry/path-warp.js +1 -1
  485. package/dist/lib/geometry/path-warp.js.map +2 -2
  486. package/dist/lib/global-state.js +2 -0
  487. package/dist/lib/global-state.js.map +2 -2
  488. package/dist/lib/hooks/use-animated-value.d.ts +11 -21
  489. package/dist/lib/hooks/use-animated-value.js +23 -70
  490. package/dist/lib/hooks/use-animated-value.js.map +3 -3
  491. package/dist/lib/hooks/use-playback.js +1 -0
  492. package/dist/lib/hooks/use-playback.js.map +2 -2
  493. package/dist/lib/html/html-events.d.ts +32 -0
  494. package/dist/lib/html/html-events.js +179 -0
  495. package/dist/lib/html/html-events.js.map +7 -0
  496. package/dist/lib/html/html-service.d.ts +8 -2
  497. package/dist/lib/html/html-service.js +198 -65
  498. package/dist/lib/html/html-service.js.map +2 -2
  499. package/dist/lib/html/overlay-config.js +7 -6
  500. package/dist/lib/html/overlay-config.js.map +2 -2
  501. package/dist/lib/html/types.d.ts +29 -2
  502. package/dist/lib/layout/absolute.d.ts +11 -5
  503. package/dist/lib/layout/absolute.js +329 -55
  504. package/dist/lib/layout/absolute.js.map +3 -3
  505. package/dist/lib/layout/allocation-checkpoint-owner.d.ts +11 -0
  506. package/dist/lib/layout/allocation-checkpoint-owner.js +86 -0
  507. package/dist/lib/layout/allocation-checkpoint-owner.js.map +7 -0
  508. package/dist/lib/layout/allocation-checkpoint.d.ts +53 -0
  509. package/dist/lib/layout/allocation-checkpoint.js +463 -0
  510. package/dist/lib/layout/allocation-checkpoint.js.map +7 -0
  511. package/dist/lib/layout/allocation-dependencies.d.ts +30 -0
  512. package/dist/lib/layout/allocation-dependencies.js +90 -0
  513. package/dist/lib/layout/allocation-dependencies.js.map +7 -0
  514. package/dist/lib/layout/allocation-revision.d.ts +13 -0
  515. package/dist/lib/layout/allocation-revision.js +67 -0
  516. package/dist/lib/layout/allocation-revision.js.map +7 -0
  517. package/dist/lib/layout/box-insets.d.ts +17 -0
  518. package/dist/lib/layout/box-insets.js +138 -0
  519. package/dist/lib/layout/box-insets.js.map +7 -0
  520. package/dist/lib/layout/box-sizing.d.ts +16 -0
  521. package/dist/lib/layout/box-sizing.js +77 -0
  522. package/dist/lib/layout/box-sizing.js.map +7 -0
  523. package/dist/lib/layout/box.js +42 -12
  524. package/dist/lib/layout/box.js.map +2 -2
  525. package/dist/lib/layout/canvas-measurement.d.ts +13 -0
  526. package/dist/lib/layout/canvas-measurement.js +57 -0
  527. package/dist/lib/layout/canvas-measurement.js.map +7 -0
  528. package/dist/lib/layout/context.d.ts +35 -6
  529. package/dist/lib/layout/context.js +72 -3
  530. package/dist/lib/layout/context.js.map +2 -2
  531. package/dist/lib/layout/define-layout-component.d.ts +23 -0
  532. package/dist/lib/layout/define-layout-component.js +84 -0
  533. package/dist/lib/layout/define-layout-component.js.map +7 -0
  534. package/dist/lib/layout/flex-allocation-cache.d.ts +42 -0
  535. package/dist/lib/layout/flex-baseline-mode.d.ts +2 -0
  536. package/dist/lib/layout/flex-baseline-mode.js +7 -0
  537. package/dist/lib/layout/flex-baseline-mode.js.map +7 -0
  538. package/dist/lib/layout/flex.d.ts +50 -15
  539. package/dist/lib/layout/flex.js +2124 -195
  540. package/dist/lib/layout/flex.js.map +3 -3
  541. package/dist/lib/layout/flow.js +225 -49
  542. package/dist/lib/layout/flow.js.map +2 -2
  543. package/dist/lib/layout/geometry-publication.d.ts +53 -0
  544. package/dist/lib/layout/geometry-publication.js +244 -0
  545. package/dist/lib/layout/geometry-publication.js.map +7 -0
  546. package/dist/lib/layout/grid-kernel.d.ts +63 -0
  547. package/dist/lib/layout/grid-kernel.js +168 -0
  548. package/dist/lib/layout/grid-kernel.js.map +7 -0
  549. package/dist/lib/layout/grid.d.ts +63 -4
  550. package/dist/lib/layout/grid.js +767 -171
  551. package/dist/lib/layout/grid.js.map +3 -3
  552. package/dist/lib/layout/measure.d.ts +55 -3
  553. package/dist/lib/layout/measure.js +448 -15
  554. package/dist/lib/layout/measure.js.map +2 -2
  555. package/dist/lib/layout/overlay.js +81 -23
  556. package/dist/lib/layout/overlay.js.map +2 -2
  557. package/dist/lib/layout/participation.d.ts +27 -0
  558. package/dist/lib/layout/participation.js +188 -0
  559. package/dist/lib/layout/participation.js.map +7 -0
  560. package/dist/lib/layout/place-child.js +1 -1
  561. package/dist/lib/layout/place-child.js.map +2 -2
  562. package/dist/lib/layout/positioning-diagnostics.d.ts +1 -1
  563. package/dist/lib/layout/positioning-diagnostics.js +13 -2
  564. package/dist/lib/layout/positioning-diagnostics.js.map +2 -2
  565. package/dist/lib/layout/prepared-root.d.ts +121 -0
  566. package/dist/lib/layout/prepared-root.js +360 -0
  567. package/dist/lib/layout/prepared-root.js.map +7 -0
  568. package/dist/lib/layout/standalone-kernel.d.ts +60 -0
  569. package/dist/lib/layout/standalone-kernel.js +722 -0
  570. package/dist/lib/layout/standalone-kernel.js.map +7 -0
  571. package/dist/lib/layout/topology.d.ts +21 -0
  572. package/dist/lib/layout/topology.js +113 -0
  573. package/dist/lib/layout/topology.js.map +7 -0
  574. package/dist/lib/layout/types.d.ts +5 -0
  575. package/dist/lib/layout/wasm/artifact.d.ts +1 -0
  576. package/dist/lib/layout/wasm/artifact.js +5 -0
  577. package/dist/lib/layout/wasm/artifact.js.map +7 -0
  578. package/dist/lib/layout/wasm/bytes.d.ts +1 -0
  579. package/dist/lib/layout/wasm/bytes.js +5 -0
  580. package/dist/lib/layout/wasm/bytes.js.map +7 -0
  581. package/dist/lib/layout/wasm/embedded.d.ts +2 -0
  582. package/dist/lib/layout/wasm/embedded.js +12 -0
  583. package/dist/lib/layout/wasm/embedded.js.map +7 -0
  584. package/dist/lib/layout/wasm/layout.wasm +0 -0
  585. package/dist/lib/layout/wasm/module.d.ts +8 -0
  586. package/dist/lib/layout/wasm/module.js +70 -0
  587. package/dist/lib/layout/wasm/module.js.map +7 -0
  588. package/dist/lib/layout/wasm/region.d.ts +267 -0
  589. package/dist/lib/layout/wasm/region.js +1018 -0
  590. package/dist/lib/layout/wasm/region.js.map +7 -0
  591. package/dist/lib/manipulation/controller.js +4 -7
  592. package/dist/lib/manipulation/controller.js.map +2 -2
  593. package/dist/lib/manipulation/frame.js +1 -1
  594. package/dist/lib/manipulation/frame.js.map +2 -2
  595. package/dist/lib/manipulation/handles.js +32 -33
  596. package/dist/lib/manipulation/handles.js.map +2 -2
  597. package/dist/lib/manipulation/solve.js +12 -10
  598. package/dist/lib/manipulation/solve.js.map +2 -2
  599. package/dist/lib/mount-pibbl.js +1 -0
  600. package/dist/lib/mount-pibbl.js.map +2 -2
  601. package/dist/lib/mount-prepared-pibbl.d.ts +5 -0
  602. package/dist/lib/mount-prepared-pibbl.js +29 -0
  603. package/dist/lib/mount-prepared-pibbl.js.map +7 -0
  604. package/dist/lib/mount-request.d.ts +8 -0
  605. package/dist/lib/mount-request.js +41 -0
  606. package/dist/lib/mount-request.js.map +7 -0
  607. package/dist/lib/pibbl.d.ts +21 -13
  608. package/dist/lib/pibbl.js +18 -16
  609. package/dist/lib/pibbl.js.map +2 -2
  610. package/dist/lib/recording/recording.d.ts +43 -0
  611. package/dist/lib/recording/recording.js +555 -0
  612. package/dist/lib/recording/recording.js.map +7 -0
  613. package/dist/lib/recording/types.d.ts +118 -0
  614. package/dist/lib/recording/wasm-bytes.d.ts +1 -0
  615. package/dist/lib/recording/wasm-bytes.js +5 -0
  616. package/dist/lib/recording/wasm-bytes.js.map +7 -0
  617. package/dist/lib/recording/worker-source.d.ts +1 -0
  618. package/dist/lib/recording/worker-source.js +5 -0
  619. package/dist/lib/recording/worker-source.js.map +7 -0
  620. package/dist/lib/render-layer/controller.d.ts +9 -3
  621. package/dist/lib/render-layer/controller.js +259 -110
  622. package/dist/lib/render-layer/controller.js.map +2 -2
  623. package/dist/lib/render-transaction.d.ts +12 -2
  624. package/dist/lib/render-transaction.js +69 -1
  625. package/dist/lib/render-transaction.js.map +2 -2
  626. package/dist/lib/render.js +32 -8
  627. package/dist/lib/render.js.map +2 -2
  628. package/dist/lib/scheduler/realm-scheduler.d.ts +2 -0
  629. package/dist/lib/scheduler/realm-scheduler.js +55 -26
  630. package/dist/lib/scheduler/realm-scheduler.js.map +2 -2
  631. package/dist/lib/scheduler/renderer-participant.js +1 -0
  632. package/dist/lib/scheduler/renderer-participant.js.map +2 -2
  633. package/dist/lib/series-inspection-frame.d.ts +18 -0
  634. package/dist/lib/series-inspection-frame.js +70 -0
  635. package/dist/lib/series-inspection-frame.js.map +7 -0
  636. package/dist/lib/signals/edge.d.ts +7 -4
  637. package/dist/lib/signals/edge.js +25 -3
  638. package/dist/lib/signals/edge.js.map +2 -2
  639. package/dist/lib/signals/graph.d.ts +16 -2
  640. package/dist/lib/signals/graph.js +54 -12
  641. package/dist/lib/signals/graph.js.map +2 -2
  642. package/dist/lib/signals/input-provision.d.ts +15 -0
  643. package/dist/lib/signals/input-provision.js +53 -3
  644. package/dist/lib/signals/input-provision.js.map +2 -2
  645. package/dist/lib/signals/render-consumer.d.ts +3 -0
  646. package/dist/lib/signals/render-consumer.js +22 -14
  647. package/dist/lib/signals/render-consumer.js.map +2 -2
  648. package/dist/lib/style/positioning.d.ts +50 -2
  649. package/dist/lib/style/positioning.js +28 -4
  650. package/dist/lib/style/positioning.js.map +2 -2
  651. package/dist/lib/style/resolve-built-in.d.ts +4 -3
  652. package/dist/lib/style/resolve-built-in.js +17 -3
  653. package/dist/lib/style/resolve-built-in.js.map +2 -2
  654. package/dist/lib/style/resolve-dispatch.d.ts +3 -0
  655. package/dist/lib/style/resolve-dispatch.js +77 -4
  656. package/dist/lib/style/resolve-dispatch.js.map +2 -2
  657. package/dist/lib/style/resolve-length.d.ts +2 -0
  658. package/dist/lib/style/resolve-length.js +13 -9
  659. package/dist/lib/style/resolve-length.js.map +2 -2
  660. package/dist/lib/style/sizing-length.d.ts +51 -0
  661. package/dist/lib/style/sizing-length.js +77 -0
  662. package/dist/lib/style/sizing-length.js.map +7 -0
  663. package/dist/lib/style/types.d.ts +63 -25
  664. package/dist/lib/surface/root-surface.js +10 -6
  665. package/dist/lib/surface/root-surface.js.map +2 -2
  666. package/dist/lib/textures/texture.js +10 -8
  667. package/dist/lib/textures/texture.js.map +2 -2
  668. package/dist/lib/transitions/capture.js +4 -1
  669. package/dist/lib/transitions/capture.js.map +2 -2
  670. package/dist/lib/transitions/embers-physics.js +17 -10
  671. package/dist/lib/transitions/embers-physics.js.map +2 -2
  672. package/dist/lib/types.d.ts +110 -1
  673. package/dist/sync.d.ts +16 -0
  674. package/dist/sync.js +13 -0
  675. package/dist/sync.js.map +7 -0
  676. package/dist/sync.mjs +1 -0
  677. package/package.json +43 -6
  678. package/dist/features/viz/lib/scale.d.ts +0 -11
  679. package/dist/features/viz/lib/scale.js +0 -80
  680. package/dist/features/viz/lib/scale.js.map +0 -7
  681. package/dist/features/viz/lib/use-scale.d.ts +0 -20
  682. package/dist/features/viz/lib/use-scale.js +0 -10
  683. package/dist/features/viz/lib/use-scale.js.map +0 -7
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/features/physics/lib/2d/shapes.ts"],
4
- "sourcesContent": ["import type {\n PibblPhysicsAabb2D,\n PibblPhysicsMassProperties2D,\n PibblPhysicsPose2D,\n PibblPhysicsShape2D,\n PibblPhysicsTransform2D,\n PibblPhysicsVector2,\n} from '../../2d-geometry.js';\nimport {\n copyFiniteVector2,\n requireFiniteNumber,\n requireNonnegativeNumber,\n requirePositiveNumber,\n} from '../shared/validation.js';\nimport {\n CURVE_FLATTENING_MAX_DEPTH,\n CURVE_FLATTENING_TOLERANCE,\n IDENTITY_POSE_2D,\n canonicalizeContour2D,\n cleanZero,\n composePose2D,\n copyPose2D,\n freezeBounds2D,\n polygonMassData2D,\n transformPointInto,\n triangulateContour2D,\n type InternalPose2D,\n} from './math.js';\nimport { DEGREES_TO_RADIANS, GEOMETRY_EPSILON } from './numeric-policy.js';\nimport {\n createShape2D,\n requireShapeRecord2D,\n type CapsuleLeaf2D,\n type ConvexLeaf2D,\n type PolygonLeaf2D,\n} from './shape-records.js';\n\nconst FULL_TURN_RADIANS = Math.PI * 2;\n\n/**\n * Creates an immutable circle collision shape without initializing a physics world.\n *\n * @param input - Circle radius and optional center. See {@link PibblPhysicsVector2}.\n * @returns An immutable circle collision shape. See {@link PibblPhysicsShape2D}.\n *\n * @see {@link PibblPhysicsVector2}\n * @see {@link PibblPhysicsShape2D}\n */\nexport function circleShape2D(\n input: Readonly<{ radius: number; center?: PibblPhysicsVector2 }>,\n): PibblPhysicsShape2D {\n const radius = requirePositiveNumber(input.radius, 'circle.radius');\n const center = ownedVector(input.center ?? [0, 0], 'circle.center');\n const area = Math.PI * radius * radius;\n return createShapeFromLeaves(\n [Object.freeze({ kind: 'circle', center, radius, canonicalLeafIndex: 0 })],\n area,\n center[0]!,\n center[1]!,\n area * radius * radius / 2,\n );\n}\n\n/**\n * Creates an immutable ellipse collision shape without initializing a physics world.\n *\n * @param input - Ellipse radii, optional center, and rotation in degrees. See\n * {@link PibblPhysicsVector2} .\n * @returns An immutable ellipse collision shape. See {@link PibblPhysicsShape2D}.\n *\n * @see {@link PibblPhysicsVector2}\n * @see {@link PibblPhysicsShape2D}\n */\nexport function ellipseShape2D(\n input: Readonly<{\n radiusX: number;\n radiusY: number;\n center?: PibblPhysicsVector2;\n rotationDegrees?: number;\n }>,\n): PibblPhysicsShape2D {\n const radiusX = requirePositiveNumber(input.radiusX, 'ellipse.radiusX');\n const radiusY = requirePositiveNumber(input.radiusY, 'ellipse.radiusY');\n const center = ownedVector(input.center ?? [0, 0], 'ellipse.center');\n const rotationRadians =\n requireFiniteNumber(input.rotationDegrees ?? 0, 'ellipse.rotationDegrees') *\n DEGREES_TO_RADIANS;\n const area = Math.PI * radiusX * radiusY;\n return createShapeFromLeaves(\n [Object.freeze({ kind: 'ellipse', center, radiusX, radiusY, rotationRadians, canonicalLeafIndex: 0 })],\n area,\n center[0]!,\n center[1]!,\n area * (radiusX * radiusX + radiusY * radiusY) / 4,\n );\n}\n\n/**\n * Creates an immutable box collision shape without initializing a physics world.\n *\n * @param input - Box width, height, and optional center. See {@link PibblPhysicsVector2}.\n * @returns An immutable box collision shape. See {@link PibblPhysicsShape2D}.\n *\n * @see {@link PibblPhysicsVector2}\n * @see {@link PibblPhysicsShape2D}\n */\nexport function boxShape2D(\n input: Readonly<{\n width: number;\n height: number;\n center?: PibblPhysicsVector2;\n }>,\n): PibblPhysicsShape2D {\n const width = requirePositiveNumber(input.width, 'box.width');\n const height = requirePositiveNumber(input.height, 'box.height');\n const center = ownedVector(input.center ?? [0, 0], 'box.center');\n const area = width * height;\n return createShapeFromLeaves(\n [Object.freeze({ kind: 'box', center, halfWidth: width / 2, halfHeight: height / 2, canonicalLeafIndex: 0 })],\n area,\n center[0]!,\n center[1]!,\n area * (width * width + height * height) / 12,\n );\n}\n\n/**\n * Creates an immutable rounded box collision shape without initializing a physics world.\n *\n * @param input - Box dimensions, center, and uniform or per-corner radii. See\n * {@link PibblPhysicsVector2} .\n * @returns An immutable rounded-box collision shape. See {@link PibblPhysicsShape2D}.\n *\n * @see {@link PibblPhysicsVector2}\n * @see {@link PibblPhysicsShape2D}\n */\nexport function roundedBoxShape2D(\n input: Readonly<{\n width: number;\n height: number;\n radius:\n | number\n | readonly [\n topLeft: number,\n topRight: number,\n bottomRight: number,\n bottomLeft: number,\n ];\n center?: PibblPhysicsVector2;\n }>,\n): PibblPhysicsShape2D {\n const width = requirePositiveNumber(input.width, 'roundedBox.width');\n const height = requirePositiveNumber(input.height, 'roundedBox.height');\n const center = ownedVector(input.center ?? [0, 0], 'roundedBox.center');\n const sourceRadii = typeof input.radius === 'number'\n ? [input.radius, input.radius, input.radius, input.radius] as const\n : input.radius;\n const radii = new Float64Array(4);\n const maximum = Math.min(width, height) / 2;\n for (let index = 0; index < radii.length; index += 1) {\n const radius = requireNonnegativeNumber(\n sourceRadii[index]!,\n `roundedBox.radius[${index}]`,\n );\n if (radius > maximum) {\n throw new RangeError(\n `roundedBox.radius[${index}] must not exceed ${String(maximum)}; received ${String(radius)}.`,\n );\n }\n radii[index] = radius;\n }\n const contour = roundedBoxContour(width / 2, height / 2, radii, center);\n const mass = polygonMassData2D(contour);\n return createShapeFromLeaves(\n [Object.freeze({\n kind: 'rounded-box',\n center,\n halfWidth: width / 2,\n halfHeight: height / 2,\n radii,\n canonicalLeafIndex: 0,\n })],\n mass.area,\n mass.centroidX,\n mass.centroidY,\n mass.unitInertia,\n );\n}\n\n/**\n * Creates an immutable capsule collision shape without initializing a physics world.\n *\n * @param input - Capsule centerline endpoints and radius. See {@link PibblPhysicsVector2}.\n * @returns An immutable capsule collision shape. See {@link PibblPhysicsShape2D}.\n *\n * @see {@link PibblPhysicsVector2}\n * @see {@link PibblPhysicsShape2D}\n */\nexport function capsuleShape2D(\n input: Readonly<{\n start: PibblPhysicsVector2;\n end: PibblPhysicsVector2;\n radius: number;\n }>,\n): PibblPhysicsShape2D {\n const start = ownedVector(input.start, 'capsule.start');\n const end = ownedVector(input.end, 'capsule.end');\n const radius = requirePositiveNumber(input.radius, 'capsule.radius');\n const leaf: CapsuleLeaf2D = Object.freeze({\n kind: 'capsule', start, end, radius, canonicalLeafIndex: 0,\n });\n const mass = capsuleMassData(start, end, radius);\n return createShapeFromLeaves(\n [leaf],\n mass.area,\n mass.centroidX,\n mass.centroidY,\n mass.unitInertia,\n );\n}\n\n/**\n * Creates an immutable arc collision shape without initializing a physics world.\n *\n * @param input - Arc center, radius, angular endpoints in radians, sweep direction, and thickness.\n * See {@link PibblPhysicsVector2} .\n * @returns An immutable thick-arc collision shape. See {@link PibblPhysicsShape2D}.\n *\n * @see {@link PibblPhysicsVector2}\n * @see {@link PibblPhysicsShape2D}\n */\nexport function arcShape2D(\n input: Readonly<{\n center?: PibblPhysicsVector2;\n radius: number;\n startAngleRadians: number;\n endAngleRadians: number;\n counterclockwise?: boolean;\n thickness: number;\n }>,\n): PibblPhysicsShape2D {\n const center = ownedVector(input.center ?? [0, 0], 'arc.center');\n const radius = requirePositiveNumber(input.radius, 'arc.radius');\n const startAngle = requireFiniteNumber(input.startAngleRadians, 'arc.startAngleRadians');\n const endAngle = requireFiniteNumber(input.endAngleRadians, 'arc.endAngleRadians');\n const thickness = requirePositiveNumber(input.thickness, 'arc.thickness');\n const points = flattenCircularSweep(\n center[0]!, center[1]!, radius, startAngle, endAngle, input.counterclockwise === true,\n );\n return chainFromOwnedPoints(points, false, thickness / 2);\n}\n\n/**\n * Creates an immutable wedge collision shape without initializing a physics world.\n *\n * @param input - Wedge center, radius, angular endpoints in radians, and sweep direction. See\n * {@link PibblPhysicsVector2} .\n * @returns An immutable wedge collision shape. See {@link PibblPhysicsShape2D}.\n *\n * @see {@link PibblPhysicsVector2}\n * @see {@link PibblPhysicsShape2D}\n */\nexport function wedgeShape2D(\n input: Readonly<{\n center?: PibblPhysicsVector2;\n radius: number;\n startAngleRadians: number;\n endAngleRadians: number;\n counterclockwise?: boolean;\n }>,\n): PibblPhysicsShape2D {\n const center = ownedVector(input.center ?? [0, 0], 'wedge.center');\n const radius = requirePositiveNumber(input.radius, 'wedge.radius');\n const startAngle = requireFiniteNumber(input.startAngleRadians, 'wedge.startAngleRadians');\n const endAngle = requireFiniteNumber(input.endAngleRadians, 'wedge.endAngleRadians');\n const points = flattenCircularSweep(\n center[0]!, center[1]!, radius, startAngle, endAngle, input.counterclockwise === true,\n );\n const sweep = directedSweep(startAngle, endAngle, input.counterclockwise === true);\n if (Math.abs(sweep) <= GEOMETRY_EPSILON) {\n throw new RangeError('wedge angles must describe a nonzero sweep.');\n }\n const contourSource: PibblPhysicsVector2[] = Math.abs(sweep) >= FULL_TURN_RADIANS\n ? points.slice(0, -1).map(asReadonlyVector)\n : [asReadonlyVector(center), ...points.map(asReadonlyVector)];\n const contour = canonicalizeContour2D(contourSource, {\n strictlyConvex: false,\n path: 'wedge.contour',\n });\n const triangles = triangulateContour2D(contour);\n const leaves = triangles.map<PolygonLeaf2D>((vertices, canonicalLeafIndex) =>\n Object.freeze({ kind: 'polygon', vertices, canonicalLeafIndex }),\n );\n const mass = aggregateLeafMass(leaves);\n return createShapeFromLeaves(\n leaves,\n mass.area,\n mass.centroidX,\n mass.centroidY,\n mass.unitInertia,\n );\n}\n\n/**\n * Creates an immutable segment collision shape without initializing a physics world.\n *\n * @param input - Segment endpoints. See {@link PibblPhysicsVector2}.\n * @returns An immutable line-segment collision shape. See {@link PibblPhysicsShape2D}.\n *\n * @see {@link PibblPhysicsVector2}\n * @see {@link PibblPhysicsShape2D}\n */\nexport function segmentShape2D(\n input: Readonly<{ start: PibblPhysicsVector2; end: PibblPhysicsVector2 }>,\n): PibblPhysicsShape2D {\n const start = ownedVector(input.start, 'segment.start');\n const end = ownedVector(input.end, 'segment.end');\n return createShapeFromLeaves(\n [Object.freeze({ kind: 'segment', start, end, canonicalLeafIndex: 0 })],\n 0,\n (start[0]! + end[0]!) / 2,\n (start[1]! + end[1]!) / 2,\n 0,\n );\n}\n\n/**\n * Creates an immutable chain collision shape without initializing a physics world.\n *\n * @param input - Ordered chain points, closure policy, and optional radius. See\n * {@link PibblPhysicsVector2} .\n * @returns An immutable chain collision shape. See {@link PibblPhysicsShape2D}.\n *\n * @see {@link PibblPhysicsVector2}\n * @see {@link PibblPhysicsShape2D}\n */\nexport function chainShape2D(\n input: Readonly<{\n points: readonly PibblPhysicsVector2[];\n closed?: boolean;\n radius?: number;\n }>,\n): PibblPhysicsShape2D {\n if (input.points.length < 2) {\n throw new RangeError('chain.points must contain at least two points.');\n }\n const points = input.points.map((point, index) =>\n ownedVector(point, `chain.points[${index}]`),\n );\n const radius = requireNonnegativeNumber(input.radius ?? 0, 'chain.radius');\n return chainFromOwnedPoints(points, input.closed === true, radius);\n}\n\n/**\n * Creates an immutable polygon collision shape without initializing a physics world.\n *\n * @param input - Ordered polygon vertices. See {@link PibblPhysicsVector2}.\n * @returns An immutable polygon collision shape. See {@link PibblPhysicsShape2D}.\n *\n * @see {@link PibblPhysicsVector2}\n * @see {@link PibblPhysicsShape2D}\n */\nexport function polygonShape2D(\n input: Readonly<{ points: readonly PibblPhysicsVector2[] }>,\n): PibblPhysicsShape2D {\n const vertices = canonicalizeContour2D(input.points, {\n strictlyConvex: true,\n path: 'polygon.points',\n });\n const mass = polygonMassData2D(vertices);\n return createShapeFromLeaves(\n [Object.freeze({ kind: 'polygon', vertices, canonicalLeafIndex: 0 })],\n mass.area,\n mass.centroidX,\n mass.centroidY,\n mass.unitInertia,\n );\n}\n\n/**\n * Computes axis-aligned bounds for an immutable shape at an optional pose.\n *\n * @param shape - Shape whose bounds are needed. See {@link PibblPhysicsShape2D}.\n * @param pose - Optional pose at which to evaluate the shape. See {@link PibblPhysicsPose2D}.\n * @returns Axis-aligned bounds of the posed shape. See {@link PibblPhysicsAabb2D}.\n *\n * @see {@link PibblPhysicsShape2D}\n * @see {@link PibblPhysicsPose2D}\n * @see {@link PibblPhysicsAabb2D}\n */\nexport function boundsOfShape2D(\n shape: PibblPhysicsShape2D,\n pose?: PibblPhysicsPose2D,\n): PibblPhysicsAabb2D {\n const record = requireShapeRecord2D(shape);\n const outerPose = copyPose2D(pose, 'pose');\n return boundsForLeaves(record.leaves, composePose2D(outerPose, record.localPose));\n}\n\n/**\n * Computes shape area, centroid, mass, and rotational inertia at the requested density.\n *\n * @param shape - Shape whose mass properties are needed. See {@link PibblPhysicsShape2D}.\n * @param options - Optional material density.\n * @returns Mass, center of mass, and inertia for the shape. See {@link PibblPhysicsMassProperties2D}\n * .\n *\n * @see {@link PibblPhysicsShape2D}\n * @see {@link PibblPhysicsMassProperties2D}\n */\nexport function massProperties2D(\n shape: PibblPhysicsShape2D,\n options?: Readonly<{ density?: number }>,\n): PibblPhysicsMassProperties2D {\n const record = requireShapeRecord2D(shape);\n const density = requirePositiveNumber(options?.density ?? 1, 'options.density');\n const transformedCentroid = new Float64Array(2);\n transformPointInto(\n transformedCentroid,\n 0,\n record.centroidX,\n record.centroidY,\n record.localPose,\n );\n return Object.freeze({\n area: cleanZero(record.area),\n centroid: Object.freeze([\n cleanZero(transformedCentroid[0]!),\n cleanZero(transformedCentroid[1]!),\n ] as const),\n mass: cleanZero(record.area * density),\n rotationalInertia: cleanZero(record.unitInertia * density),\n });\n}\n\n/**\n * Returns independent shape geometry transformed by a rigid 2D pose.\n *\n * @param shape - Source shape; it is not modified. See {@link PibblPhysicsShape2D}.\n * @param transform - Transform to apply to the shape. See {@link PibblPhysicsTransform2D}.\n * @returns A shape containing the transformed geometry. See {@link PibblPhysicsShape2D}.\n *\n * @see {@link PibblPhysicsShape2D}\n * @see {@link PibblPhysicsTransform2D}\n */\nexport function transformShape2D(\n shape: PibblPhysicsShape2D,\n transform: PibblPhysicsTransform2D,\n): PibblPhysicsShape2D {\n const source = requireShapeRecord2D(shape);\n const localPose = composePose2D(copyPose2D(transform, 'transform'), source.localPose);\n const localBounds = mutableBoundsForLeaves(source.leaves, localPose);\n return createShape2D({\n leaves: source.leaves,\n localPose,\n localBounds,\n area: source.area,\n centroidX: source.centroidX,\n centroidY: source.centroidY,\n unitInertia: source.unitInertia,\n });\n}\n\nfunction createShapeFromLeaves(\n leaves: readonly ConvexLeaf2D[],\n area: number,\n centroidX: number,\n centroidY: number,\n unitInertia: number,\n): PibblPhysicsShape2D {\n return createShape2D({\n leaves,\n localBounds: mutableBoundsForLeaves(leaves, IDENTITY_POSE_2D),\n area,\n centroidX,\n centroidY,\n unitInertia: Math.max(0, unitInertia),\n });\n}\n\nfunction chainFromOwnedPoints(\n points: readonly Float64Array[],\n closed: boolean,\n radius: number,\n): PibblPhysicsShape2D {\n const segmentCount = points.length === 1 ? 0 : points.length - 1 + (closed ? 1 : 0);\n const leaves: ConvexLeaf2D[] = [];\n for (let index = 0; index < segmentCount; index += 1) {\n const start = points[index]!;\n const end = points[(index + 1) % points.length]!;\n leaves.push(Object.freeze(radius === 0\n ? { kind: 'segment', start, end, canonicalLeafIndex: index }\n : { kind: 'capsule', start, end, radius, canonicalLeafIndex: index }));\n }\n if (leaves.length === 0) {\n const point = points[0]!;\n const area = Math.PI * radius * radius;\n leaves.push(Object.freeze({\n kind: 'circle', center: point, radius, canonicalLeafIndex: 0,\n }));\n return createShapeFromLeaves(\n leaves,\n area,\n point[0]!,\n point[1]!,\n area * radius * radius / 2,\n );\n }\n if (radius > 0) {\n const mass = aggregateLeafMass(leaves);\n return createShapeFromLeaves(\n leaves,\n mass.area,\n mass.centroidX,\n mass.centroidY,\n mass.unitInertia,\n );\n }\n const centroid = lineCentroid(points, closed);\n return createShapeFromLeaves(leaves, 0, centroid[0], centroid[1], 0);\n}\n\nfunction boundsForLeaves(\n leaves: readonly ConvexLeaf2D[],\n pose: InternalPose2D,\n): PibblPhysicsAabb2D {\n const bounds = mutableBoundsForLeaves(leaves, pose);\n return freezeBounds2D(bounds[0]!, bounds[1]!, bounds[2]!, bounds[3]!);\n}\n\nfunction mutableBoundsForLeaves(\n leaves: readonly ConvexLeaf2D[],\n pose: InternalPose2D,\n): Float64Array {\n const result = new Float64Array([\n Number.POSITIVE_INFINITY,\n Number.POSITIVE_INFINITY,\n Number.NEGATIVE_INFINITY,\n Number.NEGATIVE_INFINITY,\n ]);\n const point = new Float64Array(2);\n const include = (x: number, y: number, radius = 0): void => {\n transformPointInto(point, 0, x, y, pose);\n result[0] = Math.min(result[0]!, point[0]! - radius);\n result[1] = Math.min(result[1]!, point[1]! - radius);\n result[2] = Math.max(result[2]!, point[0]! + radius);\n result[3] = Math.max(result[3]!, point[1]! + radius);\n };\n for (const leaf of leaves) {\n switch (leaf.kind) {\n case 'circle':\n include(leaf.center[0]!, leaf.center[1]!, leaf.radius);\n break;\n case 'ellipse': {\n transformPointInto(point, 0, leaf.center[0]!, leaf.center[1]!, pose);\n const angle = pose.rotationRadians + leaf.rotationRadians;\n const cosine = Math.cos(angle);\n const sine = Math.sin(angle);\n const extentX = Math.hypot(leaf.radiusX * cosine, leaf.radiusY * sine);\n const extentY = Math.hypot(leaf.radiusX * sine, leaf.radiusY * cosine);\n result[0] = Math.min(result[0]!, point[0]! - extentX);\n result[1] = Math.min(result[1]!, point[1]! - extentY);\n result[2] = Math.max(result[2]!, point[0]! + extentX);\n result[3] = Math.max(result[3]!, point[1]! + extentY);\n break;\n }\n case 'box':\n includeBoxCorners(leaf.center, leaf.halfWidth, leaf.halfHeight, pose, result, point);\n break;\n case 'rounded-box':\n includeRoundedBoxBounds(leaf, pose, result, point);\n break;\n case 'capsule':\n include(leaf.start[0]!, leaf.start[1]!, leaf.radius);\n include(leaf.end[0]!, leaf.end[1]!, leaf.radius);\n break;\n case 'segment':\n include(leaf.start[0]!, leaf.start[1]!);\n include(leaf.end[0]!, leaf.end[1]!);\n break;\n case 'polygon':\n for (let offset = 0; offset < leaf.vertices.length; offset += 2) {\n include(leaf.vertices[offset]!, leaf.vertices[offset + 1]!);\n }\n break;\n }\n }\n return result;\n}\n\nfunction includeBoxCorners(\n center: Float64Array,\n halfWidth: number,\n halfHeight: number,\n pose: InternalPose2D,\n bounds: Float64Array,\n point: Float64Array,\n): void {\n for (const xSign of [-1, 1]) {\n for (const ySign of [-1, 1]) {\n transformPointInto(\n point,\n 0,\n center[0]! + xSign * halfWidth,\n center[1]! + ySign * halfHeight,\n pose,\n );\n bounds[0] = Math.min(bounds[0]!, point[0]!);\n bounds[1] = Math.min(bounds[1]!, point[1]!);\n bounds[2] = Math.max(bounds[2]!, point[0]!);\n bounds[3] = Math.max(bounds[3]!, point[1]!);\n }\n }\n}\n\nfunction includeRoundedBoxBounds(\n leaf: Extract<ConvexLeaf2D, { kind: 'rounded-box' }>,\n pose: InternalPose2D,\n bounds: Float64Array,\n point: Float64Array,\n): void {\n const xSigns = [-1, 1, 1, -1] as const;\n const ySigns = [-1, -1, 1, 1] as const;\n for (let index = 0; index < 4; index += 1) {\n const radius = leaf.radii[index]!;\n transformPointInto(\n point,\n 0,\n leaf.center[0]! + xSigns[index]! * (leaf.halfWidth - radius),\n leaf.center[1]! + ySigns[index]! * (leaf.halfHeight - radius),\n pose,\n );\n bounds[0] = Math.min(bounds[0]!, point[0]! - radius);\n bounds[1] = Math.min(bounds[1]!, point[1]! - radius);\n bounds[2] = Math.max(bounds[2]!, point[0]! + radius);\n bounds[3] = Math.max(bounds[3]!, point[1]! + radius);\n }\n}\n\nfunction aggregateLeafMass(leaves: readonly ConvexLeaf2D[]): Readonly<{\n area: number;\n centroidX: number;\n centroidY: number;\n unitInertia: number;\n}> {\n const entries = leaves.map(leafMassData);\n const area = entries.reduce((sum, entry) => sum + entry.area, 0);\n if (area === 0) {\n return Object.freeze({ area: 0, centroidX: 0, centroidY: 0, unitInertia: 0 });\n }\n const centroidX = entries.reduce((sum, entry) => sum + entry.area * entry.centroidX, 0) / area;\n const centroidY = entries.reduce((sum, entry) => sum + entry.area * entry.centroidY, 0) / area;\n const unitInertia = entries.reduce((sum, entry) => {\n const dx = entry.centroidX - centroidX;\n const dy = entry.centroidY - centroidY;\n return sum + entry.unitInertia + entry.area * (dx * dx + dy * dy);\n }, 0);\n return Object.freeze({ area, centroidX, centroidY, unitInertia });\n}\n\nfunction leafMassData(leaf: ConvexLeaf2D): Readonly<{\n area: number;\n centroidX: number;\n centroidY: number;\n unitInertia: number;\n}> {\n switch (leaf.kind) {\n case 'circle': {\n const area = Math.PI * leaf.radius * leaf.radius;\n return { area, centroidX: leaf.center[0]!, centroidY: leaf.center[1]!, unitInertia: area * leaf.radius * leaf.radius / 2 };\n }\n case 'ellipse': {\n const area = Math.PI * leaf.radiusX * leaf.radiusY;\n return { area, centroidX: leaf.center[0]!, centroidY: leaf.center[1]!, unitInertia: area * (leaf.radiusX * leaf.radiusX + leaf.radiusY * leaf.radiusY) / 4 };\n }\n case 'box': {\n const width = leaf.halfWidth * 2;\n const height = leaf.halfHeight * 2;\n const area = width * height;\n return { area, centroidX: leaf.center[0]!, centroidY: leaf.center[1]!, unitInertia: area * (width * width + height * height) / 12 };\n }\n case 'capsule':\n return capsuleMassData(leaf.start, leaf.end, leaf.radius);\n case 'polygon':\n return polygonMassData2D(leaf.vertices);\n case 'segment':\n return { area: 0, centroidX: (leaf.start[0]! + leaf.end[0]!) / 2, centroidY: (leaf.start[1]! + leaf.end[1]!) / 2, unitInertia: 0 };\n case 'rounded-box': {\n const contour = roundedBoxContour(leaf.halfWidth, leaf.halfHeight, leaf.radii, leaf.center);\n return polygonMassData2D(contour);\n }\n }\n}\n\nfunction capsuleMassData(\n start: Float64Array,\n end: Float64Array,\n radius: number,\n): Readonly<{ area: number; centroidX: number; centroidY: number; unitInertia: number }> {\n const dx = end[0]! - start[0]!;\n const dy = end[1]! - start[1]!;\n const length = Math.hypot(dx, dy);\n const rectangleArea = 2 * radius * length;\n const circleArea = Math.PI * radius * radius;\n const area = rectangleArea + circleArea;\n const rectangleInertia = rectangleArea * (length * length + 4 * radius * radius) / 12;\n const capsInertia =\n Math.PI * radius ** 4 / 2 +\n circleArea * length * length / 4 +\n 4 * length * radius ** 3 / 3;\n return Object.freeze({\n area,\n centroidX: (start[0]! + end[0]!) / 2,\n centroidY: (start[1]! + end[1]!) / 2,\n unitInertia: rectangleInertia + capsInertia,\n });\n}\n\nfunction lineCentroid(\n points: readonly Float64Array[],\n closed: boolean,\n): readonly [number, number] {\n const segmentCount = points.length - 1 + (closed ? 1 : 0);\n let totalLength = 0;\n let weightedX = 0;\n let weightedY = 0;\n for (let index = 0; index < segmentCount; index += 1) {\n const start = points[index]!;\n const end = points[(index + 1) % points.length]!;\n const length = Math.hypot(end[0]! - start[0]!, end[1]! - start[1]!);\n totalLength += length;\n weightedX += length * (start[0]! + end[0]!) / 2;\n weightedY += length * (start[1]! + end[1]!) / 2;\n }\n if (totalLength > 0) {\n return [weightedX / totalLength, weightedY / totalLength];\n }\n return [points.reduce((sum, point) => sum + point[0]!, 0) / points.length, points.reduce((sum, point) => sum + point[1]!, 0) / points.length];\n}\n\nfunction roundedBoxContour(\n halfWidth: number,\n halfHeight: number,\n radii: Float64Array,\n center: Float64Array,\n): Float64Array {\n const points: Float64Array[] = [];\n const cornerData = [\n [halfWidth - radii[1]!, -halfHeight + radii[1]!, -Math.PI / 2, 0, radii[1]!],\n [halfWidth - radii[2]!, halfHeight - radii[2]!, 0, Math.PI / 2, radii[2]!],\n [-halfWidth + radii[3]!, halfHeight - radii[3]!, Math.PI / 2, Math.PI, radii[3]!],\n [-halfWidth + radii[0]!, -halfHeight + radii[0]!, Math.PI, 3 * Math.PI / 2, radii[0]!],\n ] as const;\n for (const [x, y, start, end, radius] of cornerData) {\n const cornerPoints = radius === 0\n ? [new Float64Array([center[0]! + x, center[1]! + y])]\n : flattenCircularSweep(center[0]! + x, center[1]! + y, radius, start, end, false);\n points.push(...cornerPoints);\n }\n return canonicalizeContour2D(points.map(asReadonlyVector), {\n strictlyConvex: false,\n path: 'roundedBox.contour',\n });\n}\n\nfunction flattenCircularSweep(\n centerX: number,\n centerY: number,\n radius: number,\n startAngle: number,\n endAngle: number,\n counterclockwise: boolean,\n): Float64Array[] {\n const sweep = directedSweep(startAngle, endAngle, counterclockwise);\n const points = [pointOnCircle(centerX, centerY, radius, startAngle)];\n appendFlattenedArc(points, centerX, centerY, radius, startAngle, startAngle + sweep, 0);\n if (Math.abs(sweep) >= FULL_TURN_RADIANS) {\n points[points.length - 1] = new Float64Array(points[0]!);\n }\n return points;\n}\n\nfunction appendFlattenedArc(\n output: Float64Array[],\n centerX: number,\n centerY: number,\n radius: number,\n startAngle: number,\n endAngle: number,\n depth: number,\n): void {\n const middleAngle = (startAngle + endAngle) / 2;\n const halfSweep = Math.abs(endAngle - startAngle) / 2;\n const chordError = radius * (1 - Math.cos(halfSweep));\n if (\n chordError <= CURVE_FLATTENING_TOLERANCE ||\n depth >= CURVE_FLATTENING_MAX_DEPTH\n ) {\n output.push(pointOnCircle(centerX, centerY, radius, endAngle));\n return;\n }\n appendFlattenedArc(output, centerX, centerY, radius, startAngle, middleAngle, depth + 1);\n appendFlattenedArc(output, centerX, centerY, radius, middleAngle, endAngle, depth + 1);\n}\n\nfunction directedSweep(\n startAngle: number,\n endAngle: number,\n counterclockwise: boolean,\n): number {\n const raw = endAngle - startAngle;\n if (Math.abs(raw) >= FULL_TURN_RADIANS) {\n return counterclockwise ? -FULL_TURN_RADIANS : FULL_TURN_RADIANS;\n }\n if (counterclockwise) {\n const magnitude = ((-raw % FULL_TURN_RADIANS) + FULL_TURN_RADIANS) % FULL_TURN_RADIANS;\n return -magnitude;\n }\n return ((raw % FULL_TURN_RADIANS) + FULL_TURN_RADIANS) % FULL_TURN_RADIANS;\n}\n\nfunction pointOnCircle(\n centerX: number,\n centerY: number,\n radius: number,\n angle: number,\n): Float64Array {\n return new Float64Array([\n centerX + radius * Math.cos(angle),\n centerY + radius * Math.sin(angle),\n ]);\n}\n\nfunction ownedVector(value: PibblPhysicsVector2, path: string): Float64Array {\n const copied = copyFiniteVector2(value, path);\n return new Float64Array(copied);\n}\n\nfunction asReadonlyVector(value: Float64Array): PibblPhysicsVector2 {\n return [value[0]!, value[1]!] as const;\n}\n"],
5
- "mappings": "AAQA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,oBAAoB,wBAAwB;AACrD;AAAA,EACE;AAAA,EACA;AAAA,OAIK;AAEP,MAAM,oBAAoB,KAAK,KAAK;AAW7B,SAAS,cACd,OACqB;AACrB,QAAM,SAAS,sBAAsB,MAAM,QAAQ,eAAe;AAClE,QAAM,SAAS,YAAY,MAAM,UAAU,CAAC,GAAG,CAAC,GAAG,eAAe;AAClE,QAAM,OAAO,KAAK,KAAK,SAAS;AAChC,SAAO;AAAA,IACL,CAAC,OAAO,OAAO,EAAE,MAAM,UAAU,QAAQ,QAAQ,oBAAoB,EAAE,CAAC,CAAC;AAAA,IACzE;AAAA,IACA,OAAO,CAAC;AAAA,IACR,OAAO,CAAC;AAAA,IACR,OAAO,SAAS,SAAS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ACA,UACA,kBACQ;AACR,QAAM,MAAM,WAAW;AACvB,MAAI,KAAK,IAAI,GAAG,KAAK,mBAAmB;AACtC,WAAO,mBAAmB,CAAC,oBAAoB;AAAA,EACjD;AACA,MAAI,kBAAkB;AACpB,UAAM,aAAc,CAAC,MAAM,oBAAqB,qBAAqB;AACrE,WAAO,CAAC;AAAA,EACV;AACA,UAAS,MAAM,oBAAqB,qBAAqB;AAC3D;AAEA,SAAS,cACP,SACA,SACA,QACA,OACc;AACd,SAAO,IAAI,aAAa;AAAA,IACtB,UAAU,SAAS,KAAK,IAAI,KAAK;AAAA,IACjC,UAAU,SAAS,KAAK,IAAI,KAAK;AAAA,EACnC,CAAC;AACH;AAEA,SAAS,YAAY,OAA4B,MAA4B;AAC3E,QAAM,SAAS,kBAAkB,OAAO,IAAI;AAC5C,SAAO,IAAI,aAAa,MAAM;AAChC;AAEA,SAAS,iBAAiB,OAA0C;AAClE,SAAO,CAAC,MAAM,CAAC,GAAI,MAAM,CAAC,CAAE;AAC9B;",
4
+ "sourcesContent": ["import type {\n PibblPhysicsAabb2D,\n PibblPhysicsMassProperties2D,\n PibblPhysicsPose2D,\n PibblPhysicsShape2D,\n PibblPhysicsTransform2D,\n PibblPhysicsVector2,\n} from '../../2d-geometry.js';\nimport {\n copyFiniteVector2,\n requireFiniteNumber,\n requireNonnegativeNumber,\n requirePositiveNumber,\n} from '../shared/validation.js';\nimport {\n CURVE_FLATTENING_MAX_DEPTH,\n CURVE_FLATTENING_TOLERANCE,\n IDENTITY_POSE_2D,\n canonicalizeContour2D,\n cleanZero,\n composePose2D,\n copyPose2D,\n freezeBounds2D,\n polygonMassData2D,\n transformPointInto,\n triangulateContour2D,\n type InternalPose2D,\n} from './math.js';\nimport { DEGREES_TO_RADIANS, GEOMETRY_EPSILON } from './numeric-policy.js';\nimport {\n createShape2D,\n requireShapeRecord2D,\n type CapsuleLeaf2D,\n type ConvexLeaf2D,\n type PolygonLeaf2D,\n} from './shape-records.js';\n\nconst FULL_TURN_RADIANS = Math.PI * 2;\n\n/**\n * Creates an immutable circle collision shape without initializing a physics world.\n *\n * @param input - Circle radius and optional center. See {@link PibblPhysicsVector2}.\n * @returns An immutable circle collision shape. See {@link PibblPhysicsShape2D}.\n *\n * @see {@link PibblPhysicsVector2}\n * @see {@link PibblPhysicsShape2D}\n */\nexport function circleShape2D(\n input: Readonly<{ radius: number; center?: PibblPhysicsVector2 }>,\n): PibblPhysicsShape2D {\n const radius = requirePositiveNumber(input.radius, 'circle.radius');\n const center = ownedVector(input.center ?? [0, 0], 'circle.center');\n const area = Math.PI * radius * radius;\n return createShapeFromLeaves(\n [Object.freeze({ kind: 'circle', center, radius, canonicalLeafIndex: 0 })],\n area,\n center[0]!,\n center[1]!,\n area * radius * radius / 2,\n );\n}\n\n/**\n * Creates an immutable ellipse collision shape without initializing a physics world.\n *\n * @param input - Ellipse radii, optional center, and rotation in degrees. See\n * {@link PibblPhysicsVector2} .\n * @returns An immutable ellipse collision shape. See {@link PibblPhysicsShape2D}.\n *\n * @see {@link PibblPhysicsVector2}\n * @see {@link PibblPhysicsShape2D}\n */\nexport function ellipseShape2D(\n input: Readonly<{\n radiusX: number;\n radiusY: number;\n center?: PibblPhysicsVector2;\n rotationDegrees?: number;\n }>,\n): PibblPhysicsShape2D {\n const radiusX = requirePositiveNumber(input.radiusX, 'ellipse.radiusX');\n const radiusY = requirePositiveNumber(input.radiusY, 'ellipse.radiusY');\n const center = ownedVector(input.center ?? [0, 0], 'ellipse.center');\n const rotationRadians =\n requireFiniteNumber(input.rotationDegrees ?? 0, 'ellipse.rotationDegrees') *\n DEGREES_TO_RADIANS;\n const area = Math.PI * radiusX * radiusY;\n return createShapeFromLeaves(\n [Object.freeze({ kind: 'ellipse', center, radiusX, radiusY, rotationRadians, canonicalLeafIndex: 0 })],\n area,\n center[0]!,\n center[1]!,\n area * (radiusX * radiusX + radiusY * radiusY) / 4,\n );\n}\n\n/**\n * Creates an immutable box collision shape without initializing a physics world.\n *\n * @param input - Box width, height, and optional center. See {@link PibblPhysicsVector2}.\n * @returns An immutable box collision shape. See {@link PibblPhysicsShape2D}.\n *\n * @see {@link PibblPhysicsVector2}\n * @see {@link PibblPhysicsShape2D}\n */\nexport function boxShape2D(\n input: Readonly<{\n width: number;\n height: number;\n center?: PibblPhysicsVector2;\n }>,\n): PibblPhysicsShape2D {\n const width = requirePositiveNumber(input.width, 'box.width');\n const height = requirePositiveNumber(input.height, 'box.height');\n const center = ownedVector(input.center ?? [0, 0], 'box.center');\n const area = width * height;\n return createShapeFromLeaves(\n [Object.freeze({ kind: 'box', center, halfWidth: width / 2, halfHeight: height / 2, canonicalLeafIndex: 0 })],\n area,\n center[0]!,\n center[1]!,\n area * (width * width + height * height) / 12,\n );\n}\n\n/**\n * Creates an immutable rounded box collision shape without initializing a physics world.\n *\n * @param input - Box dimensions, center, and uniform or per-corner radii. See\n * {@link PibblPhysicsVector2} .\n * @returns An immutable rounded-box collision shape. See {@link PibblPhysicsShape2D}.\n *\n * @see {@link PibblPhysicsVector2}\n * @see {@link PibblPhysicsShape2D}\n */\nexport function roundedBoxShape2D(\n input: Readonly<{\n width: number;\n height: number;\n radius:\n | number\n | readonly [\n topLeft: number,\n topRight: number,\n bottomRight: number,\n bottomLeft: number,\n ];\n center?: PibblPhysicsVector2;\n }>,\n): PibblPhysicsShape2D {\n const width = requirePositiveNumber(input.width, 'roundedBox.width');\n const height = requirePositiveNumber(input.height, 'roundedBox.height');\n const center = ownedVector(input.center ?? [0, 0], 'roundedBox.center');\n const sourceRadii = typeof input.radius === 'number'\n ? [input.radius, input.radius, input.radius, input.radius] as const\n : input.radius;\n const radii = new Float64Array(4);\n const maximum = Math.min(width, height) / 2;\n for (let index = 0; index < radii.length; index += 1) {\n const radius = requireNonnegativeNumber(\n sourceRadii[index]!,\n `roundedBox.radius[${index}]`,\n );\n if (radius > maximum) {\n throw new RangeError(\n `roundedBox.radius[${index}] must not exceed ${String(maximum)}; received ${String(radius)}.`,\n );\n }\n radii[index] = radius;\n }\n const contour = roundedBoxContour(width / 2, height / 2, radii, center);\n const mass = polygonMassData2D(contour);\n return createShapeFromLeaves(\n [Object.freeze({\n kind: 'rounded-box',\n center,\n halfWidth: width / 2,\n halfHeight: height / 2,\n radii,\n canonicalLeafIndex: 0,\n })],\n mass.area,\n mass.centroidX,\n mass.centroidY,\n mass.unitInertia,\n );\n}\n\n/**\n * Creates an immutable capsule collision shape without initializing a physics world.\n *\n * @param input - Capsule centerline endpoints and radius. See {@link PibblPhysicsVector2}.\n * @returns An immutable capsule collision shape. See {@link PibblPhysicsShape2D}.\n *\n * @see {@link PibblPhysicsVector2}\n * @see {@link PibblPhysicsShape2D}\n */\nexport function capsuleShape2D(\n input: Readonly<{\n start: PibblPhysicsVector2;\n end: PibblPhysicsVector2;\n radius: number;\n }>,\n): PibblPhysicsShape2D {\n const start = ownedVector(input.start, 'capsule.start');\n const end = ownedVector(input.end, 'capsule.end');\n const radius = requirePositiveNumber(input.radius, 'capsule.radius');\n const leaf: CapsuleLeaf2D = Object.freeze({\n kind: 'capsule', start, end, radius, canonicalLeafIndex: 0,\n });\n const mass = capsuleMassData(start, end, radius);\n return createShapeFromLeaves(\n [leaf],\n mass.area,\n mass.centroidX,\n mass.centroidY,\n mass.unitInertia,\n );\n}\n\n/**\n * Creates an immutable arc collision shape without initializing a physics world.\n *\n * @param input - Arc center, radius, angular endpoints in radians, sweep direction, and thickness.\n * See {@link PibblPhysicsVector2} .\n * @returns An immutable thick-arc collision shape. See {@link PibblPhysicsShape2D}.\n *\n * @see {@link PibblPhysicsVector2}\n * @see {@link PibblPhysicsShape2D}\n */\nexport function arcShape2D(\n input: Readonly<{\n center?: PibblPhysicsVector2;\n radius: number;\n startAngleRadians: number;\n endAngleRadians: number;\n counterclockwise?: boolean;\n thickness: number;\n }>,\n): PibblPhysicsShape2D {\n const center = ownedVector(input.center ?? [0, 0], 'arc.center');\n const radius = requirePositiveNumber(input.radius, 'arc.radius');\n const startAngle = requireFiniteNumber(input.startAngleRadians, 'arc.startAngleRadians');\n const endAngle = requireFiniteNumber(input.endAngleRadians, 'arc.endAngleRadians');\n const thickness = requirePositiveNumber(input.thickness, 'arc.thickness');\n const points = flattenCircularSweep(\n center[0]!, center[1]!, radius, startAngle, endAngle, input.counterclockwise === true,\n );\n return chainFromOwnedPoints(points, false, thickness / 2);\n}\n\n/**\n * Creates an immutable wedge collision shape without initializing a physics world.\n *\n * @param input - Wedge center, radius, angular endpoints in radians, and sweep direction. See\n * {@link PibblPhysicsVector2} .\n * @returns An immutable wedge collision shape. See {@link PibblPhysicsShape2D}.\n *\n * @see {@link PibblPhysicsVector2}\n * @see {@link PibblPhysicsShape2D}\n */\nexport function wedgeShape2D(\n input: Readonly<{\n center?: PibblPhysicsVector2;\n radius: number;\n startAngleRadians: number;\n endAngleRadians: number;\n counterclockwise?: boolean;\n }>,\n): PibblPhysicsShape2D {\n const center = ownedVector(input.center ?? [0, 0], 'wedge.center');\n const radius = requirePositiveNumber(input.radius, 'wedge.radius');\n const startAngle = requireFiniteNumber(input.startAngleRadians, 'wedge.startAngleRadians');\n const endAngle = requireFiniteNumber(input.endAngleRadians, 'wedge.endAngleRadians');\n const points = flattenCircularSweep(\n center[0]!, center[1]!, radius, startAngle, endAngle, input.counterclockwise === true,\n );\n const sweep = directedSweep(startAngle, endAngle, input.counterclockwise === true);\n if (Math.abs(sweep) <= GEOMETRY_EPSILON) {\n throw new RangeError('wedge angles must describe a nonzero sweep.');\n }\n const contourSource: PibblPhysicsVector2[] = Math.abs(sweep) >= FULL_TURN_RADIANS\n ? points.slice(0, -1).map(asReadonlyVector)\n : [asReadonlyVector(center), ...points.map(asReadonlyVector)];\n const contour = canonicalizeContour2D(contourSource, {\n strictlyConvex: false,\n path: 'wedge.contour',\n });\n const triangles = triangulateContour2D(contour);\n const leaves = triangles.map<PolygonLeaf2D>((vertices, canonicalLeafIndex) =>\n Object.freeze({ kind: 'polygon', vertices, canonicalLeafIndex }),\n );\n const mass = aggregateLeafMass(leaves);\n return createShapeFromLeaves(\n leaves,\n mass.area,\n mass.centroidX,\n mass.centroidY,\n mass.unitInertia,\n );\n}\n\n/**\n * Creates an immutable segment collision shape without initializing a physics world.\n *\n * @param input - Segment endpoints. See {@link PibblPhysicsVector2}.\n * @returns An immutable line-segment collision shape. See {@link PibblPhysicsShape2D}.\n *\n * @see {@link PibblPhysicsVector2}\n * @see {@link PibblPhysicsShape2D}\n */\nexport function segmentShape2D(\n input: Readonly<{ start: PibblPhysicsVector2; end: PibblPhysicsVector2 }>,\n): PibblPhysicsShape2D {\n const start = ownedVector(input.start, 'segment.start');\n const end = ownedVector(input.end, 'segment.end');\n return createShapeFromLeaves(\n [Object.freeze({ kind: 'segment', start, end, canonicalLeafIndex: 0 })],\n 0,\n (start[0]! + end[0]!) / 2,\n (start[1]! + end[1]!) / 2,\n 0,\n );\n}\n\n/**\n * Creates an immutable chain collision shape without initializing a physics world.\n *\n * @param input - Ordered chain points, closure policy, and optional radius. See\n * {@link PibblPhysicsVector2} .\n * @returns An immutable chain collision shape. See {@link PibblPhysicsShape2D}.\n *\n * @see {@link PibblPhysicsVector2}\n * @see {@link PibblPhysicsShape2D}\n */\nexport function chainShape2D(\n input: Readonly<{\n points: readonly PibblPhysicsVector2[];\n closed?: boolean;\n radius?: number;\n }>,\n): PibblPhysicsShape2D {\n if (input.points.length < 2) {\n throw new RangeError('chain.points must contain at least two points.');\n }\n const points = input.points.map((point, index) =>\n ownedVector(point, `chain.points[${index}]`),\n );\n const radius = requireNonnegativeNumber(input.radius ?? 0, 'chain.radius');\n return chainFromOwnedPoints(points, input.closed === true, radius);\n}\n\n/**\n * Creates an immutable polygon collision shape without initializing a physics world.\n *\n * @param input - Ordered polygon vertices. See {@link PibblPhysicsVector2}.\n * @returns An immutable polygon collision shape. See {@link PibblPhysicsShape2D}.\n *\n * @see {@link PibblPhysicsVector2}\n * @see {@link PibblPhysicsShape2D}\n */\nexport function polygonShape2D(\n input: Readonly<{ points: readonly PibblPhysicsVector2[] }>,\n): PibblPhysicsShape2D {\n const vertices = canonicalizeContour2D(input.points, {\n strictlyConvex: true,\n path: 'polygon.points',\n });\n const mass = polygonMassData2D(vertices);\n return createShapeFromLeaves(\n [Object.freeze({ kind: 'polygon', vertices, canonicalLeafIndex: 0 })],\n mass.area,\n mass.centroidX,\n mass.centroidY,\n mass.unitInertia,\n );\n}\n\n/**\n * Computes axis-aligned bounds for an immutable shape at an optional pose.\n *\n * @param shape - Shape whose bounds are needed. See {@link PibblPhysicsShape2D}.\n * @param pose - Optional pose at which to evaluate the shape. See {@link PibblPhysicsPose2D}.\n * @returns Axis-aligned bounds of the posed shape. See {@link PibblPhysicsAabb2D}.\n *\n * @see {@link PibblPhysicsShape2D}\n * @see {@link PibblPhysicsPose2D}\n * @see {@link PibblPhysicsAabb2D}\n */\nexport function boundsOfShape2D(\n shape: PibblPhysicsShape2D,\n pose?: PibblPhysicsPose2D,\n): PibblPhysicsAabb2D {\n const record = requireShapeRecord2D(shape);\n const outerPose = copyPose2D(pose, 'pose');\n return boundsForLeaves(record.leaves, composePose2D(outerPose, record.localPose));\n}\n\n/**\n * Computes shape area, centroid, mass, and rotational inertia at the requested density.\n *\n * @param shape - Shape whose mass properties are needed. See {@link PibblPhysicsShape2D}.\n * @param options - Optional material density.\n * @returns Mass, center of mass, and inertia for the shape. See {@link PibblPhysicsMassProperties2D}\n * .\n *\n * @see {@link PibblPhysicsShape2D}\n * @see {@link PibblPhysicsMassProperties2D}\n */\nexport function massProperties2D(\n shape: PibblPhysicsShape2D,\n options?: Readonly<{ density?: number }>,\n): PibblPhysicsMassProperties2D {\n const record = requireShapeRecord2D(shape);\n const density = requirePositiveNumber(options?.density ?? 1, 'options.density');\n const transformedCentroid = new Float64Array(2);\n transformPointInto(\n transformedCentroid,\n 0,\n record.centroidX,\n record.centroidY,\n record.localPose,\n );\n return Object.freeze({\n area: cleanZero(record.area),\n centroid: Object.freeze([\n cleanZero(transformedCentroid[0]!),\n cleanZero(transformedCentroid[1]!),\n ] as const),\n mass: cleanZero(record.area * density),\n rotationalInertia: cleanZero(record.unitInertia * density),\n });\n}\n\n/**\n * Returns independent shape geometry transformed by a rigid 2D pose.\n *\n * @param shape - Source shape; it is not modified. See {@link PibblPhysicsShape2D}.\n * @param transform - Transform to apply to the shape. See {@link PibblPhysicsTransform2D}.\n * @returns A shape containing the transformed geometry. See {@link PibblPhysicsShape2D}.\n *\n * @see {@link PibblPhysicsShape2D}\n * @see {@link PibblPhysicsTransform2D}\n */\nexport function transformShape2D(\n shape: PibblPhysicsShape2D,\n transform: PibblPhysicsTransform2D,\n): PibblPhysicsShape2D {\n const source = requireShapeRecord2D(shape);\n const localPose = composePose2D(copyPose2D(transform, 'transform'), source.localPose);\n const localBounds = mutableBoundsForLeaves(source.leaves, localPose);\n return createShape2D({\n leaves: source.leaves,\n localPose,\n localBounds,\n area: source.area,\n centroidX: source.centroidX,\n centroidY: source.centroidY,\n unitInertia: source.unitInertia,\n });\n}\n\nfunction createShapeFromLeaves(\n leaves: readonly ConvexLeaf2D[],\n area: number,\n centroidX: number,\n centroidY: number,\n unitInertia: number,\n): PibblPhysicsShape2D {\n return createShape2D({\n leaves,\n localBounds: mutableBoundsForLeaves(leaves, IDENTITY_POSE_2D),\n area,\n centroidX,\n centroidY,\n unitInertia: Math.max(0, unitInertia),\n });\n}\n\nfunction chainFromOwnedPoints(\n points: readonly Float64Array[],\n closed: boolean,\n radius: number,\n): PibblPhysicsShape2D {\n const segmentCount = points.length === 1 ? 0 : points.length - 1 + (closed ? 1 : 0);\n const leaves: ConvexLeaf2D[] = [];\n for (let index = 0; index < segmentCount; index += 1) {\n const start = points[index]!;\n const end = points[(index + 1) % points.length]!;\n leaves.push(Object.freeze(radius === 0\n ? { kind: 'segment', start, end, canonicalLeafIndex: index }\n : { kind: 'capsule', start, end, radius, canonicalLeafIndex: index }));\n }\n if (leaves.length === 0) {\n const point = points[0]!;\n const area = Math.PI * radius * radius;\n leaves.push(Object.freeze({\n kind: 'circle', center: point, radius, canonicalLeafIndex: 0,\n }));\n return createShapeFromLeaves(\n leaves,\n area,\n point[0]!,\n point[1]!,\n area * radius * radius / 2,\n );\n }\n if (radius > 0) {\n const mass = aggregateLeafMass(leaves);\n return createShapeFromLeaves(\n leaves,\n mass.area,\n mass.centroidX,\n mass.centroidY,\n mass.unitInertia,\n );\n }\n const centroid = lineCentroid(points, closed);\n return createShapeFromLeaves(leaves, 0, centroid[0], centroid[1], 0);\n}\n\nfunction boundsForLeaves(\n leaves: readonly ConvexLeaf2D[],\n pose: InternalPose2D,\n): PibblPhysicsAabb2D {\n const bounds = mutableBoundsForLeaves(leaves, pose);\n return freezeBounds2D(bounds[0]!, bounds[1]!, bounds[2]!, bounds[3]!);\n}\n\nfunction mutableBoundsForLeaves(\n leaves: readonly ConvexLeaf2D[],\n pose: InternalPose2D,\n): Float64Array {\n const result = new Float64Array([\n Number.POSITIVE_INFINITY,\n Number.POSITIVE_INFINITY,\n Number.NEGATIVE_INFINITY,\n Number.NEGATIVE_INFINITY,\n ]);\n const point = new Float64Array(2);\n const include = (x: number, y: number, radius = 0): void => {\n transformPointInto(point, 0, x, y, pose);\n result[0] = Math.min(result[0]!, point[0]! - radius);\n result[1] = Math.min(result[1]!, point[1]! - radius);\n result[2] = Math.max(result[2]!, point[0]! + radius);\n result[3] = Math.max(result[3]!, point[1]! + radius);\n };\n for (const leaf of leaves) {\n switch (leaf.kind) {\n case 'circle':\n include(leaf.center[0]!, leaf.center[1]!, leaf.radius);\n break;\n case 'ellipse': {\n transformPointInto(point, 0, leaf.center[0]!, leaf.center[1]!, pose);\n const angle = pose.rotationRadians + leaf.rotationRadians;\n const cosine = Math.cos(angle);\n const sine = Math.sin(angle);\n const extentX = Math.hypot(leaf.radiusX * cosine, leaf.radiusY * sine);\n const extentY = Math.hypot(leaf.radiusX * sine, leaf.radiusY * cosine);\n result[0] = Math.min(result[0]!, point[0]! - extentX);\n result[1] = Math.min(result[1]!, point[1]! - extentY);\n result[2] = Math.max(result[2]!, point[0]! + extentX);\n result[3] = Math.max(result[3]!, point[1]! + extentY);\n break;\n }\n case 'box':\n includeBoxCorners(leaf.center, leaf.halfWidth, leaf.halfHeight, pose, result, point);\n break;\n case 'rounded-box':\n includeRoundedBoxBounds(leaf, pose, result, point);\n break;\n case 'capsule':\n include(leaf.start[0]!, leaf.start[1]!, leaf.radius);\n include(leaf.end[0]!, leaf.end[1]!, leaf.radius);\n break;\n case 'segment':\n include(leaf.start[0]!, leaf.start[1]!);\n include(leaf.end[0]!, leaf.end[1]!);\n break;\n case 'polygon':\n for (let offset = 0; offset < leaf.vertices.length; offset += 2) {\n include(leaf.vertices[offset]!, leaf.vertices[offset + 1]!);\n }\n break;\n }\n }\n return result;\n}\n\nfunction includeBoxCorners(\n center: Float64Array,\n halfWidth: number,\n halfHeight: number,\n pose: InternalPose2D,\n bounds: Float64Array,\n point: Float64Array,\n): void {\n for (let xSign = -1; xSign <= 1; xSign += 2) {\n for (let ySign = -1; ySign <= 1; ySign += 2) {\n transformPointInto(\n point,\n 0,\n center[0]! + xSign * halfWidth,\n center[1]! + ySign * halfHeight,\n pose,\n );\n bounds[0] = Math.min(bounds[0]!, point[0]!);\n bounds[1] = Math.min(bounds[1]!, point[1]!);\n bounds[2] = Math.max(bounds[2]!, point[0]!);\n bounds[3] = Math.max(bounds[3]!, point[1]!);\n }\n }\n}\n\nfunction includeRoundedBoxBounds(\n leaf: Extract<ConvexLeaf2D, { kind: 'rounded-box' }>,\n pose: InternalPose2D,\n bounds: Float64Array,\n point: Float64Array,\n): void {\n const xSigns = [-1, 1, 1, -1] as const;\n const ySigns = [-1, -1, 1, 1] as const;\n for (let index = 0; index < 4; index += 1) {\n const radius = leaf.radii[index]!;\n transformPointInto(\n point,\n 0,\n leaf.center[0]! + xSigns[index]! * (leaf.halfWidth - radius),\n leaf.center[1]! + ySigns[index]! * (leaf.halfHeight - radius),\n pose,\n );\n bounds[0] = Math.min(bounds[0]!, point[0]! - radius);\n bounds[1] = Math.min(bounds[1]!, point[1]! - radius);\n bounds[2] = Math.max(bounds[2]!, point[0]! + radius);\n bounds[3] = Math.max(bounds[3]!, point[1]! + radius);\n }\n}\n\nfunction aggregateLeafMass(leaves: readonly ConvexLeaf2D[]): Readonly<{\n area: number;\n centroidX: number;\n centroidY: number;\n unitInertia: number;\n}> {\n const entries = leaves.map(leafMassData);\n const area = entries.reduce((sum, entry) => sum + entry.area, 0);\n if (area === 0) {\n return Object.freeze({ area: 0, centroidX: 0, centroidY: 0, unitInertia: 0 });\n }\n const centroidX = entries.reduce((sum, entry) => sum + entry.area * entry.centroidX, 0) / area;\n const centroidY = entries.reduce((sum, entry) => sum + entry.area * entry.centroidY, 0) / area;\n const unitInertia = entries.reduce((sum, entry) => {\n const dx = entry.centroidX - centroidX;\n const dy = entry.centroidY - centroidY;\n return sum + entry.unitInertia + entry.area * (dx * dx + dy * dy);\n }, 0);\n return Object.freeze({ area, centroidX, centroidY, unitInertia });\n}\n\nfunction leafMassData(leaf: ConvexLeaf2D): Readonly<{\n area: number;\n centroidX: number;\n centroidY: number;\n unitInertia: number;\n}> {\n switch (leaf.kind) {\n case 'circle': {\n const area = Math.PI * leaf.radius * leaf.radius;\n return { area, centroidX: leaf.center[0]!, centroidY: leaf.center[1]!, unitInertia: area * leaf.radius * leaf.radius / 2 };\n }\n case 'ellipse': {\n const area = Math.PI * leaf.radiusX * leaf.radiusY;\n return { area, centroidX: leaf.center[0]!, centroidY: leaf.center[1]!, unitInertia: area * (leaf.radiusX * leaf.radiusX + leaf.radiusY * leaf.radiusY) / 4 };\n }\n case 'box': {\n const width = leaf.halfWidth * 2;\n const height = leaf.halfHeight * 2;\n const area = width * height;\n return { area, centroidX: leaf.center[0]!, centroidY: leaf.center[1]!, unitInertia: area * (width * width + height * height) / 12 };\n }\n case 'capsule':\n return capsuleMassData(leaf.start, leaf.end, leaf.radius);\n case 'polygon':\n return polygonMassData2D(leaf.vertices);\n case 'segment':\n return { area: 0, centroidX: (leaf.start[0]! + leaf.end[0]!) / 2, centroidY: (leaf.start[1]! + leaf.end[1]!) / 2, unitInertia: 0 };\n case 'rounded-box': {\n const contour = roundedBoxContour(leaf.halfWidth, leaf.halfHeight, leaf.radii, leaf.center);\n return polygonMassData2D(contour);\n }\n }\n}\n\nfunction capsuleMassData(\n start: Float64Array,\n end: Float64Array,\n radius: number,\n): Readonly<{ area: number; centroidX: number; centroidY: number; unitInertia: number }> {\n const dx = end[0]! - start[0]!;\n const dy = end[1]! - start[1]!;\n const length = Math.hypot(dx, dy);\n const rectangleArea = 2 * radius * length;\n const circleArea = Math.PI * radius * radius;\n const area = rectangleArea + circleArea;\n const rectangleInertia = rectangleArea * (length * length + 4 * radius * radius) / 12;\n const capsInertia =\n Math.PI * radius ** 4 / 2 +\n circleArea * length * length / 4 +\n 4 * length * radius ** 3 / 3;\n return Object.freeze({\n area,\n centroidX: (start[0]! + end[0]!) / 2,\n centroidY: (start[1]! + end[1]!) / 2,\n unitInertia: rectangleInertia + capsInertia,\n });\n}\n\nfunction lineCentroid(\n points: readonly Float64Array[],\n closed: boolean,\n): readonly [number, number] {\n const segmentCount = points.length - 1 + (closed ? 1 : 0);\n let totalLength = 0;\n let weightedX = 0;\n let weightedY = 0;\n for (let index = 0; index < segmentCount; index += 1) {\n const start = points[index]!;\n const end = points[(index + 1) % points.length]!;\n const length = Math.hypot(end[0]! - start[0]!, end[1]! - start[1]!);\n totalLength += length;\n weightedX += length * (start[0]! + end[0]!) / 2;\n weightedY += length * (start[1]! + end[1]!) / 2;\n }\n if (totalLength > 0) {\n return [weightedX / totalLength, weightedY / totalLength];\n }\n return [points.reduce((sum, point) => sum + point[0]!, 0) / points.length, points.reduce((sum, point) => sum + point[1]!, 0) / points.length];\n}\n\nfunction roundedBoxContour(\n halfWidth: number,\n halfHeight: number,\n radii: Float64Array,\n center: Float64Array,\n): Float64Array {\n const points: Float64Array[] = [];\n for (let corner = 0; corner < 4; corner++) {\n const radius = radii[(corner + 1) % 4]!;\n const x = corner < 2 ? halfWidth - radius : -halfWidth + radius;\n const y = corner === 0 || corner === 3 ? -halfHeight + radius : halfHeight - radius;\n const start = (corner - 1) * Math.PI / 2;\n const end = corner * Math.PI / 2;\n const cornerPoints = radius === 0\n ? [new Float64Array([center[0]! + x, center[1]! + y])]\n : flattenCircularSweep(center[0]! + x, center[1]! + y, radius, start, end, false);\n points.push(...cornerPoints);\n }\n return canonicalizeContour2D(points.map(asReadonlyVector), {\n strictlyConvex: false,\n path: 'roundedBox.contour',\n });\n}\n\nfunction flattenCircularSweep(\n centerX: number,\n centerY: number,\n radius: number,\n startAngle: number,\n endAngle: number,\n counterclockwise: boolean,\n): Float64Array[] {\n const sweep = directedSweep(startAngle, endAngle, counterclockwise);\n const points = [pointOnCircle(centerX, centerY, radius, startAngle)];\n appendFlattenedArc(points, centerX, centerY, radius, startAngle, startAngle + sweep, 0);\n if (Math.abs(sweep) >= FULL_TURN_RADIANS) {\n points[points.length - 1] = new Float64Array(points[0]!);\n }\n return points;\n}\n\nfunction appendFlattenedArc(\n output: Float64Array[],\n centerX: number,\n centerY: number,\n radius: number,\n startAngle: number,\n endAngle: number,\n depth: number,\n): void {\n const middleAngle = (startAngle + endAngle) / 2;\n const halfSweep = Math.abs(endAngle - startAngle) / 2;\n const chordError = radius * (1 - Math.cos(halfSweep));\n if (\n chordError <= CURVE_FLATTENING_TOLERANCE ||\n depth >= CURVE_FLATTENING_MAX_DEPTH\n ) {\n output.push(pointOnCircle(centerX, centerY, radius, endAngle));\n return;\n }\n appendFlattenedArc(output, centerX, centerY, radius, startAngle, middleAngle, depth + 1);\n appendFlattenedArc(output, centerX, centerY, radius, middleAngle, endAngle, depth + 1);\n}\n\nfunction directedSweep(\n startAngle: number,\n endAngle: number,\n counterclockwise: boolean,\n): number {\n const raw = endAngle - startAngle;\n if (Math.abs(raw) >= FULL_TURN_RADIANS) {\n return counterclockwise ? -FULL_TURN_RADIANS : FULL_TURN_RADIANS;\n }\n if (counterclockwise) {\n const magnitude = ((-raw % FULL_TURN_RADIANS) + FULL_TURN_RADIANS) % FULL_TURN_RADIANS;\n return -magnitude;\n }\n return ((raw % FULL_TURN_RADIANS) + FULL_TURN_RADIANS) % FULL_TURN_RADIANS;\n}\n\nfunction pointOnCircle(\n centerX: number,\n centerY: number,\n radius: number,\n angle: number,\n): Float64Array {\n return new Float64Array([\n centerX + radius * Math.cos(angle),\n centerY + radius * Math.sin(angle),\n ]);\n}\n\nfunction ownedVector(value: PibblPhysicsVector2, path: string): Float64Array {\n const copied = copyFiniteVector2(value, path);\n return new Float64Array(copied);\n}\n\nfunction asReadonlyVector(value: Float64Array): PibblPhysicsVector2 {\n return [value[0]!, value[1]!] as const;\n}\n"],
5
+ "mappings": "AAQA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,oBAAoB,wBAAwB;AACrD;AAAA,EACE;AAAA,EACA;AAAA,OAIK;AAEP,MAAM,oBAAoB,KAAK,KAAK;AAW7B,SAAS,cACd,OACqB;AACrB,QAAM,SAAS,sBAAsB,MAAM,QAAQ,eAAe;AAClE,QAAM,SAAS,YAAY,MAAM,UAAU,CAAC,GAAG,CAAC,GAAG,eAAe;AAClE,QAAM,OAAO,KAAK,KAAK,SAAS;AAChC,SAAO;AAAA,IACL,CAAC,OAAO,OAAO,EAAE,MAAM,UAAU,QAAQ,QAAQ,oBAAoB,EAAE,CAAC,CAAC;AAAA,IACzE;AAAA,IACA,OAAO,CAAC;AAAA,IACR,OAAO,CAAC;AAAA,IACR,OAAO,SAAS,SAAS;AAAA,EAC3B;AACF;AAYO,SAAS,eACd,OAMqB;AACrB,QAAM,UAAU,sBAAsB,MAAM,SAAS,iBAAiB;AACtE,QAAM,UAAU,sBAAsB,MAAM,SAAS,iBAAiB;AACtE,QAAM,SA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AC;AACH;AAEA,SAAS,YAAY,OAA4B,MAA4B;AAC3E,QAAM,SAAS,kBAAkB,OAAO,IAAI;AAC5C,SAAO,IAAI,aAAa,MAAM;AAChC;AAEA,SAAS,iBAAiB,OAA0C;AAClE,SAAO,CAAC,MAAM,CAAC,GAAI,MAAM,CAAC,CAAE;AAC9B;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  import type { collider2D, dynamicBody2D, kinematicBody2D, staticBody2D } from "./runtime/descriptors.js";
2
2
  import type { PhysicsWorld2D, pibblPhysicsWorld2D } from "./runtime/world-component.js";
3
3
  import type { Capsule2D, Chain2D, PhysicsShape2D, Segment2D } from "./canvas/components.js";
4
- import type { overlapShape2D, queryAabb2D, raycast2D, shapeCast2D } from "../../2d.js";
4
+ import type { findShapeOverlap2D, findAabbMatch2D, raycastClosest2D, shapeCastClosest2D } from "../../2d.js";
5
5
  import type { BoxStyle, PibblEventHandlers, PibblEventParticipationOptions, PibblNodeInput, CursorStyle, LayoutBox, LayoutItemStyle, PaintStyle, Signal, SignalValue, SystemStyle } from "@pibbl/core";
6
6
  import type { PibblPhysicsAabb2D, PibblPhysicsContactPoint2D, PibblPhysicsShape2D, PibblPhysicsShapeHit2D, PibblPhysicsVector2 } from "../../2d-geometry.js";
7
7
  /**
@@ -523,8 +523,8 @@ declare const worldHandle2DBrand: unique symbol;
523
523
  *
524
524
  * @see {@link Signal}
525
525
  * @see {@link pibblPhysicsWorld2D}
526
- * @see {@link raycast2D}
527
- * @see {@link shapeCast2D}
526
+ * @see {@link raycastClosest2D}
527
+ * @see {@link shapeCastClosest2D}
528
528
  */
529
529
  export interface PibblPhysicsWorldHandle2D {
530
530
  readonly [worldHandle2DBrand]: true;
@@ -532,27 +532,13 @@ export interface PibblPhysicsWorldHandle2D {
532
532
  readonly revision: Signal<number>;
533
533
  }
534
534
  /**
535
- * Whether a query returns its closest match, any-match boolean, or all matches.
535
+ * Sensor policy, collision filtering, and body/collider exclusions for world queries.
536
536
  *
537
- * @see {@link PibblPhysicsQueryOptions2D}
538
- * @see {@link PibblPhysicsQueryResult2D}
539
- * @see {@link raycast2D}
540
- */
541
- export type PibblPhysicsQueryMode = "closest" | "any" | "all";
542
- /**
543
- * Result mode, sensor policy, collision filtering, and body/collider exclusions for world queries.
544
- *
545
- * @see {@link PibblPhysicsQueryMode}
546
537
  * @see {@link PibblPhysicsCollisionFilter}
547
538
  * @see {@link PibblPhysicsBodyHandle2D}
548
539
  * @see {@link PibblPhysicsColliderHandle2D}
549
540
  */
550
- export interface PibblPhysicsQueryOptions2D<Mode extends PibblPhysicsQueryMode = "closest"> {
551
- /**
552
- * Selects the supported mapping, placement, or result policy. See
553
- * {@link PibblPhysicsQueryOptions2D}.
554
- */
555
- readonly mode?: Mode;
541
+ export interface PibblPhysicsQueryOptions2D {
556
542
  /**
557
543
  * Selects `"include"` , `"exclude"` , `"only"` for sensors. See {@link PibblPhysicsQueryOptions2D}
558
544
  * .
@@ -574,7 +560,7 @@ export interface PibblPhysicsQueryOptions2D<Mode extends PibblPhysicsQueryMode =
574
560
  * @see {@link PibblPhysicsShapeHit2D}
575
561
  * @see {@link PibblPhysicsBodyHandle2D}
576
562
  * @see {@link PibblPhysicsColliderHandle2D}
577
- * @see {@link raycast2D}
563
+ * @see {@link raycastClosest2D}
578
564
  */
579
565
  export interface PibblPhysicsQueryHit2D extends PibblPhysicsShapeHit2D {
580
566
  /** Body identity associated with this event or result. See {@link PibblPhysicsBodyHandle2D}. */
@@ -599,8 +585,8 @@ export interface PibblPhysicsQueryHit2D extends PibblPhysicsShapeHit2D {
599
585
  *
600
586
  * @see {@link PibblPhysicsBodyHandle2D}
601
587
  * @see {@link PibblPhysicsColliderHandle2D}
602
- * @see {@link overlapShape2D}
603
- * @see {@link queryAabb2D}
588
+ * @see {@link findShapeOverlap2D}
589
+ * @see {@link findAabbMatch2D}
604
590
  */
605
591
  export interface PibblPhysicsQueryMatch2D {
606
592
  /** Body identity associated with this event or result. See {@link PibblPhysicsBodyHandle2D}. */
@@ -620,14 +606,6 @@ export interface PibblPhysicsQueryMatch2D {
620
606
  */
621
607
  readonly tag: unknown;
622
608
  }
623
- /**
624
- * Selects a boolean, readonly result list, or nullable closest result from the query mode.
625
- *
626
- * @see {@link PibblPhysicsQueryMode}
627
- * @see {@link raycast2D}
628
- * @see {@link shapeCast2D}
629
- */
630
- export type PibblPhysicsQueryResult2D<Mode extends PibblPhysicsQueryMode, Result> = Mode extends "any" ? boolean : Mode extends "all" ? readonly Result[] : Result | null;
631
609
  /**
632
610
  * Bodies, colliders, contact geometry, impulse, tags, and tick for a collision event.
633
611
  *
@@ -1,5 +1,6 @@
1
+ import type { QueryMode, QueryOptions, QueryResult } from '../query-types.js';
1
2
  import { type PibblPhysicsAabb2D, type PibblPhysicsPose2D, type PibblPhysicsRay2D, type PibblPhysicsShape2D, type PibblPhysicsVector2 } from "../../../2d-geometry.js";
2
- import type { PibblPhysicsBodyHandle2D, PibblPhysicsColliderHandle2D, PibblPhysicsQueryHit2D, PibblPhysicsQueryMatch2D, PibblPhysicsQueryMode, PibblPhysicsQueryOptions2D, PibblPhysicsQueryResult2D } from "../types.js";
3
+ import type { PibblPhysicsBodyHandle2D, PibblPhysicsColliderHandle2D, PibblPhysicsQueryHit2D, PibblPhysicsQueryMatch2D } from "../types.js";
3
4
  import type { DynamicAabbBroadPhase2D } from "./broad-phase.js";
4
5
  import type { BodyStore2D, ColliderStore2D } from "./storage.js";
5
6
  interface HandleIdentity2D {
@@ -34,11 +35,11 @@ export declare class CommittedWorldQueries2D {
34
35
  private readonly shapeShells;
35
36
  constructor(options: CommittedWorldQueriesOptions2D);
36
37
  invalidate(): void;
37
- raycast<Mode extends PibblPhysicsQueryMode = "closest">(worldGeneration: number, ray: PibblPhysicsRay2D, queryOptions?: PibblPhysicsQueryOptions2D<Mode>): PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryHit2D>;
38
- shapeCast<Mode extends PibblPhysicsQueryMode = "closest">(worldGeneration: number, shape: PibblPhysicsShape2D, from: PibblPhysicsPose2D, translation: PibblPhysicsVector2, queryOptions?: PibblPhysicsQueryOptions2D<Mode>): PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryHit2D>;
39
- overlapShape<Mode extends PibblPhysicsQueryMode = "closest">(worldGeneration: number, shape: PibblPhysicsShape2D, pose: PibblPhysicsPose2D, queryOptions?: PibblPhysicsQueryOptions2D<Mode>): PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryMatch2D>;
40
- queryAabb<Mode extends PibblPhysicsQueryMode = "closest">(worldGeneration: number, bounds: PibblPhysicsAabb2D, queryOptions?: PibblPhysicsQueryOptions2D<Mode>): PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryMatch2D>;
41
- queryPoint<Mode extends PibblPhysicsQueryMode = "closest">(worldGeneration: number, point: PibblPhysicsVector2, queryOptions?: PibblPhysicsQueryOptions2D<Mode>): PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryMatch2D>;
38
+ raycast<Mode extends QueryMode = "closest">(worldGeneration: number, ray: PibblPhysicsRay2D, queryOptions?: QueryOptions<Mode>): QueryResult<Mode, PibblPhysicsQueryHit2D>;
39
+ shapeCast<Mode extends QueryMode = "closest">(worldGeneration: number, shape: PibblPhysicsShape2D, from: PibblPhysicsPose2D, translation: PibblPhysicsVector2, queryOptions?: QueryOptions<Mode>): QueryResult<Mode, PibblPhysicsQueryHit2D>;
40
+ overlapShape<Mode extends QueryMode = "closest">(worldGeneration: number, shape: PibblPhysicsShape2D, pose: PibblPhysicsPose2D, queryOptions?: QueryOptions<Mode>): QueryResult<Mode, PibblPhysicsQueryMatch2D>;
41
+ queryAabb<Mode extends QueryMode = "closest">(worldGeneration: number, bounds: PibblPhysicsAabb2D, queryOptions?: QueryOptions<Mode>): QueryResult<Mode, PibblPhysicsQueryMatch2D>;
42
+ queryPoint<Mode extends QueryMode = "closest">(worldGeneration: number, point: PibblPhysicsVector2, queryOptions?: QueryOptions<Mode>): QueryResult<Mode, PibblPhysicsQueryMatch2D>;
42
43
  private runMatchQuery;
43
44
  private prepareOptions;
44
45
  private isUsable;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/features/physics/lib/2d/world/queries.ts"],
4
- "sourcesContent": ["import {\n boundsOfShape2D,\n type PibblPhysicsAabb2D,\n type PibblPhysicsPose2D,\n type PibblPhysicsRay2D,\n type PibblPhysicsShape2D,\n type PibblPhysicsVector2,\n} from \"../../../2d-geometry.js\";\nimport { copyFiniteVector2, requireNonnegativeNumber } from \"../../shared/validation.js\";\nimport { containsPointInShape2D, overlapPreparedShapes2D } from \"../collision/pairs.js\";\nimport { raycastShape2D, shapeCastAgainstShape2D } from \"../collision/casts.js\";\nimport { RADIANS_TO_DEGREES } from \"../numeric-policy.js\";\nimport { createShape2D, type ShapeRecord2D } from \"../shape-records.js\";\nimport type {\n PibblPhysicsBodyHandle2D,\n PibblPhysicsColliderHandle2D,\n PibblPhysicsCollisionFilter,\n PibblPhysicsQueryHit2D,\n PibblPhysicsQueryMatch2D,\n PibblPhysicsQueryMode,\n PibblPhysicsQueryOptions2D,\n PibblPhysicsQueryResult2D,\n} from \"../types.js\";\nimport type { DynamicAabbBroadPhase2D } from \"./broad-phase.js\";\nimport { collisionFiltersAllow2D } from \"./ccd.js\";\nimport { COLLIDER_SENSOR_2D } from \"./contact-cache.js\";\nimport type { BodyStore2D, ColliderStore2D } from \"./storage.js\";\n\ninterface HandleIdentity2D {\n readonly index: number;\n readonly generation: number;\n}\n\nexport interface CommittedWorldQueriesOptions2D {\n readonly generation: number;\n readonly bodies: BodyStore2D;\n readonly colliders: ColliderStore2D;\n readonly broadPhase: DynamicAabbBroadPhase2D;\n readonly materializeBody: (index: number, generation: number) => PibblPhysicsBodyHandle2D;\n readonly materializeCollider: (index: number, generation: number) => PibblPhysicsColliderHandle2D;\n readonly resolveBody: (handle: PibblPhysicsBodyHandle2D) => HandleIdentity2D | null;\n readonly resolveCollider: (handle: PibblPhysicsColliderHandle2D) => HandleIdentity2D | null;\n}\n\ninterface PreparedQueryOptions2D {\n readonly mode: PibblPhysicsQueryMode;\n readonly sensors: \"include\" | \"exclude\" | \"only\";\n readonly collisionFilter: PibblPhysicsCollisionFilter | null;\n readonly excludeBody: HandleIdentity2D | null;\n readonly excludeCollider: HandleIdentity2D | null;\n readonly valid: boolean;\n}\n\nexport class CommittedWorldQueries2D {\n private active = true;\n private candidateProxies: Int32Array;\n private hitColliderIndices: Int32Array;\n private hitColliderGenerations: Uint32Array;\n private hitBodyIndices: Int32Array;\n private hitBodyGenerations: Uint32Array;\n private hitPointX: Float64Array;\n private hitPointY: Float64Array;\n private hitNormalX: Float64Array;\n private hitNormalY: Float64Array;\n private hitDistances: Float64Array;\n private hitTimes: Float64Array;\n private hitCount = 0;\n private readonly shapeShells = new WeakMap<ShapeRecord2D, PibblPhysicsShape2D>();\n\n constructor(private readonly options: CommittedWorldQueriesOptions2D) {\n const capacity = normalizedCapacity(options.broadPhase.proxyCapacity);\n this.candidateProxies = new Int32Array(capacity);\n this.hitColliderIndices = new Int32Array(capacity);\n this.hitColliderGenerations = new Uint32Array(capacity);\n this.hitBodyIndices = new Int32Array(capacity);\n this.hitBodyGenerations = new Uint32Array(capacity);\n this.hitPointX = new Float64Array(capacity);\n this.hitPointY = new Float64Array(capacity);\n this.hitNormalX = new Float64Array(capacity);\n this.hitNormalY = new Float64Array(capacity);\n this.hitDistances = new Float64Array(capacity);\n this.hitTimes = new Float64Array(capacity);\n }\n\n invalidate(): void {\n this.active = false;\n this.hitCount = 0;\n }\n\n raycast<Mode extends PibblPhysicsQueryMode = \"closest\">(\n worldGeneration: number,\n ray: PibblPhysicsRay2D,\n queryOptions?: PibblPhysicsQueryOptions2D<Mode>,\n ): PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryHit2D> {\n const prepared = this.prepareOptions(queryOptions);\n if (!this.isUsable(worldGeneration, prepared)) return emptyResult(prepared.mode);\n const origin = copyFiniteVector2(ray.origin, \"ray.origin\");\n const direction = copyFiniteVector2(ray.direction, \"ray.direction\");\n const directionLength = Math.hypot(direction[0], direction[1]);\n if (directionLength === 0) throw new RangeError(\"ray.direction must be non-zero.\");\n const maxDistance = requireNonnegativeNumber(ray.maxDistance, \"ray.maxDistance\");\n const endX = origin[0] + (direction[0] / directionLength) * maxDistance;\n const endY = origin[1] + (direction[1] / directionLength) * maxDistance;\n this.beginQuery();\n const candidateCount = this.queryCandidates(\n Math.min(origin[0], endX),\n Math.min(origin[1], endY),\n Math.max(origin[0], endX),\n Math.max(origin[1], endY),\n );\n for (let candidate = 0; candidate < candidateCount; candidate += 1) {\n const collider = this.semanticColliderAt(candidate, prepared);\n if (collider === null) continue;\n const hit = raycastShape2D(collider.shape, collider.pose, ray);\n if (hit === null) continue;\n if (prepared.mode === \"any\") return true as PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryHit2D>;\n this.appendHit(collider, hit.point, hit.normal, hit.distance, hit.timeOfImpact);\n }\n return this.finishHits<Mode>(prepared.mode);\n }\n\n shapeCast<Mode extends PibblPhysicsQueryMode = \"closest\">(\n worldGeneration: number,\n shape: PibblPhysicsShape2D,\n from: PibblPhysicsPose2D,\n translation: PibblPhysicsVector2,\n queryOptions?: PibblPhysicsQueryOptions2D<Mode>,\n ): PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryHit2D> {\n const prepared = this.prepareOptions(queryOptions);\n if (!this.isUsable(worldGeneration, prepared)) return emptyResult(prepared.mode);\n const copiedTranslation = copyFiniteVector2(translation, \"translation\");\n const start = boundsOfShape2D(shape, from);\n const end = boundsOfShape2D(shape, {\n position: [from.position[0] + copiedTranslation[0], from.position[1] + copiedTranslation[1]],\n rotationDegrees: from.rotationDegrees,\n });\n this.beginQuery();\n const candidateCount = this.queryCandidates(\n Math.min(start.min[0], end.min[0]),\n Math.min(start.min[1], end.min[1]),\n Math.max(start.max[0], end.max[0]),\n Math.max(start.max[1], end.max[1]),\n );\n for (let candidate = 0; candidate < candidateCount; candidate += 1) {\n const collider = this.semanticColliderAt(candidate, prepared);\n if (collider === null) continue;\n const hit = shapeCastAgainstShape2D(shape, from, copiedTranslation, collider.shape, collider.pose);\n if (hit === null) continue;\n if (prepared.mode === \"any\") return true as PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryHit2D>;\n this.appendHit(collider, hit.point, hit.normal, hit.distance, hit.timeOfImpact);\n }\n return this.finishHits<Mode>(prepared.mode);\n }\n\n overlapShape<Mode extends PibblPhysicsQueryMode = \"closest\">(\n worldGeneration: number,\n shape: PibblPhysicsShape2D,\n pose: PibblPhysicsPose2D,\n queryOptions?: PibblPhysicsQueryOptions2D<Mode>,\n ): PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryMatch2D> {\n const bounds = this.isGenerationLive(worldGeneration) ? boundsOfShape2D(shape, pose) : null;\n return this.runMatchQuery(worldGeneration, bounds, queryOptions, (collider) =>\n overlapPreparedShapes2D(shape, pose, collider.shape, collider.pose),\n );\n }\n\n queryAabb<Mode extends PibblPhysicsQueryMode = \"closest\">(\n worldGeneration: number,\n bounds: PibblPhysicsAabb2D,\n queryOptions?: PibblPhysicsQueryOptions2D<Mode>,\n ): PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryMatch2D> {\n if (!this.isGenerationLive(worldGeneration)) {\n return emptyResult(modeOf(queryOptions));\n }\n const copied = copyAabb(bounds);\n return this.runMatchQuery(worldGeneration, copied, queryOptions, (collider) => {\n const colliderBounds = boundsOfShape2D(collider.shape, collider.pose);\n return aabbsOverlap(copied, colliderBounds);\n });\n }\n\n queryPoint<Mode extends PibblPhysicsQueryMode = \"closest\">(\n worldGeneration: number,\n point: PibblPhysicsVector2,\n queryOptions?: PibblPhysicsQueryOptions2D<Mode>,\n ): PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryMatch2D> {\n if (!this.isGenerationLive(worldGeneration)) {\n return emptyResult(modeOf(queryOptions));\n }\n const copied = copyFiniteVector2(point, \"point\");\n const bounds = Object.freeze({ min: copied, max: copied });\n return this.runMatchQuery(worldGeneration, bounds, queryOptions, (collider) =>\n containsPointInShape2D(collider.shape, collider.pose, copied),\n );\n }\n\n private runMatchQuery<Mode extends PibblPhysicsQueryMode>(\n worldGeneration: number,\n bounds: PibblPhysicsAabb2D | null,\n queryOptions: PibblPhysicsQueryOptions2D<Mode> | undefined,\n matches: (collider: SemanticCollider2D) => boolean,\n ): PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryMatch2D> {\n const prepared = this.prepareOptions(queryOptions);\n if (bounds === null || !this.isUsable(worldGeneration, prepared)) {\n return emptyResult(prepared.mode);\n }\n this.beginQuery();\n const candidateCount = this.queryCandidates(bounds.min[0], bounds.min[1], bounds.max[0], bounds.max[1]);\n for (let candidate = 0; candidate < candidateCount; candidate += 1) {\n const collider = this.semanticColliderAt(candidate, prepared);\n if (collider === null || !matches(collider)) continue;\n if (prepared.mode === \"any\") {\n return true as PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryMatch2D>;\n }\n this.appendMatch(collider);\n }\n return this.finishMatches<Mode>(prepared.mode);\n }\n\n private prepareOptions<Mode extends PibblPhysicsQueryMode>(\n queryOptions: PibblPhysicsQueryOptions2D<Mode> | undefined,\n ): PreparedQueryOptions2D {\n const mode = modeOf(queryOptions);\n const sensors = queryOptions?.sensors ?? \"include\";\n if (sensors !== \"include\" && sensors !== \"exclude\" && sensors !== \"only\") {\n throw new RangeError(\"query sensors must be include, exclude, or only.\");\n }\n const excludeBody =\n queryOptions?.excludeBody === undefined ? null : this.options.resolveBody(queryOptions.excludeBody);\n const excludeCollider =\n queryOptions?.excludeCollider === undefined ? null : this.options.resolveCollider(queryOptions.excludeCollider);\n const validBody =\n queryOptions?.excludeBody === undefined ||\n (excludeBody !== null && this.options.bodies.has(excludeBody.index, excludeBody.generation));\n const validCollider =\n queryOptions?.excludeCollider === undefined ||\n (excludeCollider !== null && this.options.colliders.has(excludeCollider.index, excludeCollider.generation));\n return {\n mode,\n sensors,\n collisionFilter: queryOptions?.collisionFilter ?? null,\n excludeBody,\n excludeCollider,\n valid: validBody && validCollider,\n };\n }\n\n private isUsable(worldGeneration: number, prepared: PreparedQueryOptions2D): boolean {\n return this.isGenerationLive(worldGeneration) && prepared.valid;\n }\n\n private isGenerationLive(worldGeneration: number): boolean {\n return this.active && worldGeneration === this.options.generation;\n }\n\n private beginQuery(): void {\n this.hitCount = 0;\n this.ensureCapacity(this.options.broadPhase.proxyCapacity);\n }\n\n private queryCandidates(minX: number, minY: number, maxX: number, maxY: number): number {\n return this.options.broadPhase.queryAabbInto(\n minX,\n minY,\n maxX,\n maxY,\n this.candidateProxies,\n 0,\n this.candidateProxies.length,\n );\n }\n\n private semanticColliderAt(candidate: number, prepared: PreparedQueryOptions2D): SemanticCollider2D | null {\n const proxy = this.candidateProxies[candidate]!;\n const colliderIndex = this.options.broadPhase.proxyColliderIndices[proxy]!;\n const colliderGeneration = this.options.broadPhase.proxyColliderGenerations[proxy]!;\n const { colliders, bodies } = this.options;\n if (!colliders.has(colliderIndex, colliderGeneration)) return null;\n const bodyIndex = colliders.bodyIndices[colliderIndex]!;\n const bodyGeneration = colliders.bodyGenerations[colliderIndex]!;\n if (!bodies.has(bodyIndex, bodyGeneration)) return null;\n if (sameIdentity(prepared.excludeBody, bodyIndex, bodyGeneration)) return null;\n if (sameIdentity(prepared.excludeCollider, colliderIndex, colliderGeneration)) return null;\n const sensor = (colliders.flags[colliderIndex]! & COLLIDER_SENSOR_2D) !== 0;\n if (prepared.sensors === \"exclude\" && sensor) return null;\n if (prepared.sensors === \"only\" && !sensor) return null;\n if (\n prepared.collisionFilter !== null &&\n !collisionFiltersAllow2D(prepared.collisionFilter, colliders.filters[colliderIndex])\n )\n return null;\n const record = colliders.shapes[colliderIndex];\n if (record === null) return null;\n return {\n colliderIndex,\n colliderGeneration,\n bodyIndex,\n bodyGeneration,\n shape: this.shapeShell(record),\n pose: publicBodyOriginPose(bodies, bodyIndex),\n };\n }\n\n private appendHit(\n collider: SemanticCollider2D,\n point: PibblPhysicsVector2,\n normal: PibblPhysicsVector2,\n distance: number,\n time: number,\n ): void {\n const target = this.hitCount;\n this.writeIdentity(target, collider);\n this.hitPointX[target] = point[0];\n this.hitPointY[target] = point[1];\n this.hitNormalX[target] = normal[0];\n this.hitNormalY[target] = normal[1];\n this.hitDistances[target] = distance;\n this.hitTimes[target] = time;\n this.hitCount += 1;\n }\n\n private appendMatch(collider: SemanticCollider2D): void {\n this.writeIdentity(this.hitCount, collider);\n this.hitCount += 1;\n }\n\n private writeIdentity(target: number, collider: SemanticCollider2D): void {\n this.hitColliderIndices[target] = collider.colliderIndex;\n this.hitColliderGenerations[target] = collider.colliderGeneration;\n this.hitBodyIndices[target] = collider.bodyIndex;\n this.hitBodyGenerations[target] = collider.bodyGeneration;\n }\n\n private finishHits<Mode extends PibblPhysicsQueryMode>(\n mode: PibblPhysicsQueryMode,\n ): PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryHit2D> {\n this.sortHits(true);\n if (mode === \"any\") {\n return false as PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryHit2D>;\n }\n if (mode === \"closest\") {\n return (this.hitCount === 0 ? null : this.materializeHit(0)) as PibblPhysicsQueryResult2D<\n Mode,\n PibblPhysicsQueryHit2D\n >;\n }\n const results: PibblPhysicsQueryHit2D[] = [];\n for (let index = 0; index < this.hitCount; index += 1) {\n results.push(this.materializeHit(index));\n }\n return Object.freeze(results) as PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryHit2D>;\n }\n\n private finishMatches<Mode extends PibblPhysicsQueryMode>(\n mode: PibblPhysicsQueryMode,\n ): PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryMatch2D> {\n this.sortHits(false);\n if (mode === \"any\") {\n return false as PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryMatch2D>;\n }\n if (mode === \"closest\") {\n return (this.hitCount === 0 ? null : this.materializeMatch(0)) as PibblPhysicsQueryResult2D<\n Mode,\n PibblPhysicsQueryMatch2D\n >;\n }\n const results: PibblPhysicsQueryMatch2D[] = [];\n for (let index = 0; index < this.hitCount; index += 1) {\n results.push(this.materializeMatch(index));\n }\n return Object.freeze(results) as PibblPhysicsQueryResult2D<Mode, PibblPhysicsQueryMatch2D>;\n }\n\n private materializeHit(index: number): PibblPhysicsQueryHit2D {\n return Object.freeze({\n ...this.materializeMatch(index),\n point: freezeVector(this.hitPointX[index]!, this.hitPointY[index]!),\n normal: freezeVector(this.hitNormalX[index]!, this.hitNormalY[index]!),\n distance: this.hitDistances[index]!,\n timeOfImpact: this.hitTimes[index]!,\n });\n }\n\n private materializeMatch(index: number): PibblPhysicsQueryMatch2D {\n const bodyIndex = this.hitBodyIndices[index]!;\n const bodyGeneration = this.hitBodyGenerations[index]!;\n const colliderIndex = this.hitColliderIndices[index]!;\n const colliderGeneration = this.hitColliderGenerations[index]!;\n return Object.freeze({\n body: this.options.materializeBody(bodyIndex, bodyGeneration),\n collider: this.options.materializeCollider(colliderIndex, colliderGeneration),\n bodyGeneration,\n colliderGeneration,\n tag: this.options.colliders.tags[colliderIndex],\n });\n }\n\n private sortHits(withDistance: boolean): void {\n for (let index = 1; index < this.hitCount; index += 1) {\n let current = index;\n while (current > 0 && this.compareHits(current, current - 1, withDistance) < 0) {\n this.swapHits(current, current - 1, withDistance);\n current -= 1;\n }\n }\n }\n\n private compareHits(first: number, second: number, withDistance: boolean): number {\n if (withDistance) {\n const time = this.hitTimes[first]! - this.hitTimes[second]!;\n if (time !== 0) return time;\n const distance = this.hitDistances[first]! - this.hitDistances[second]!;\n if (distance !== 0) return distance;\n }\n return (\n this.hitColliderIndices[first]! - this.hitColliderIndices[second]! ||\n this.hitColliderGenerations[first]! - this.hitColliderGenerations[second]!\n );\n }\n\n private swapHits(first: number, second: number, withDistance: boolean): void {\n swapInt32(this.hitColliderIndices, first, second);\n swapUint32(this.hitColliderGenerations, first, second);\n swapInt32(this.hitBodyIndices, first, second);\n swapUint32(this.hitBodyGenerations, first, second);\n if (!withDistance) return;\n swapFloat64(this.hitPointX, first, second);\n swapFloat64(this.hitPointY, first, second);\n swapFloat64(this.hitNormalX, first, second);\n swapFloat64(this.hitNormalY, first, second);\n swapFloat64(this.hitDistances, first, second);\n swapFloat64(this.hitTimes, first, second);\n }\n\n private shapeShell(record: ShapeRecord2D): PibblPhysicsShape2D {\n let shell = this.shapeShells.get(record);\n if (shell === undefined) {\n shell = createShape2D(record);\n this.shapeShells.set(record, shell);\n }\n return shell;\n }\n\n private ensureCapacity(required: number): void {\n if (required <= this.candidateProxies.length) return;\n const capacity = normalizedCapacity(required);\n this.candidateProxies = growInt32(this.candidateProxies, capacity);\n this.hitColliderIndices = growInt32(this.hitColliderIndices, capacity);\n this.hitColliderGenerations = growUint32(this.hitColliderGenerations, capacity);\n this.hitBodyIndices = growInt32(this.hitBodyIndices, capacity);\n this.hitBodyGenerations = growUint32(this.hitBodyGenerations, capacity);\n this.hitPointX = growFloat64(this.hitPointX, capacity);\n this.hitPointY = growFloat64(this.hitPointY, capacity);\n this.hitNormalX = growFloat64(this.hitNormalX, capacity);\n this.hitNormalY = growFloat64(this.hitNormalY, capacity);\n this.hitDistances = growFloat64(this.hitDistances, capacity);\n this.hitTimes = growFloat64(this.hitTimes, capacity);\n }\n}\n\ninterface SemanticCollider2D {\n readonly colliderIndex: number;\n readonly colliderGeneration: number;\n readonly bodyIndex: number;\n readonly bodyGeneration: number;\n readonly shape: PibblPhysicsShape2D;\n readonly pose: PibblPhysicsPose2D;\n}\n\nfunction modeOf<Mode extends PibblPhysicsQueryMode>(\n options: PibblPhysicsQueryOptions2D<Mode> | undefined,\n): PibblPhysicsQueryMode {\n const mode = options?.mode ?? \"closest\";\n if (mode !== \"closest\" && mode !== \"any\" && mode !== \"all\") {\n throw new RangeError(\"query mode must be closest, any, or all.\");\n }\n return mode;\n}\n\nfunction emptyResult<Mode extends PibblPhysicsQueryMode, Result>(\n mode: PibblPhysicsQueryMode,\n): PibblPhysicsQueryResult2D<Mode, Result> {\n return (mode === \"any\" ? false : mode === \"all\" ? Object.freeze([]) : null) as PibblPhysicsQueryResult2D<Mode, Result>;\n}\n\nfunction sameIdentity(identity: HandleIdentity2D | null, index: number, generation: number): boolean {\n return identity !== null && identity.index === index && identity.generation === generation;\n}\n\nfunction publicPose(x: number, y: number, rotationRadians: number): PibblPhysicsPose2D {\n return {\n position: [x, y],\n rotationDegrees: rotationRadians * RADIANS_TO_DEGREES,\n };\n}\n\nfunction publicBodyOriginPose(\n bodies: BodyStore2D,\n index: number,\n): PibblPhysicsPose2D {\n const rotationRadians = bodies.rotationRadians[index]!;\n const cosine = Math.cos(rotationRadians);\n const sine = Math.sin(rotationRadians);\n const localCenterX = bodies.localCenterX[index]!;\n const localCenterY = bodies.localCenterY[index]!;\n return publicPose(\n bodies.positionX[index]! - cosine * localCenterX + sine * localCenterY,\n bodies.positionY[index]! - sine * localCenterX - cosine * localCenterY,\n rotationRadians,\n );\n}\n\nfunction copyAabb(bounds: PibblPhysicsAabb2D): PibblPhysicsAabb2D {\n const min = copyFiniteVector2(bounds.min, \"bounds.min\");\n const max = copyFiniteVector2(bounds.max, \"bounds.max\");\n if (min[0] > max[0] || min[1] > max[1]) {\n throw new RangeError(\"bounds.min must not exceed bounds.max.\");\n }\n return Object.freeze({ min, max });\n}\n\nfunction aabbsOverlap(first: PibblPhysicsAabb2D, second: PibblPhysicsAabb2D): boolean {\n return (\n first.min[0] <= second.max[0] &&\n first.max[0] >= second.min[0] &&\n first.min[1] <= second.max[1] &&\n first.max[1] >= second.min[1]\n );\n}\n\nfunction freezeVector(x: number, y: number): PibblPhysicsVector2 {\n return Object.freeze([x, y] as const);\n}\n\nfunction normalizedCapacity(required: number): number {\n let capacity = 1;\n while (capacity < required) capacity *= 2;\n return capacity;\n}\n\nfunction growInt32(source: Int32Array, capacity: number): Int32Array {\n const result = new Int32Array(capacity);\n result.set(source);\n return result;\n}\n\nfunction growUint32(source: Uint32Array, capacity: number): Uint32Array {\n const result = new Uint32Array(capacity);\n result.set(source);\n return result;\n}\n\nfunction growFloat64(source: Float64Array, capacity: number): Float64Array {\n const result = new Float64Array(capacity);\n result.set(source);\n return result;\n}\n\nfunction swapInt32(values: Int32Array, first: number, second: number): void {\n const value = values[first]!;\n values[first] = values[second]!;\n values[second] = value;\n}\n\nfunction swapUint32(values: Uint32Array, first: number, second: number): void {\n const value = values[first]!;\n values[first] = values[second]!;\n values[second] = value;\n}\n\nfunction swapFloat64(values: Float64Array, first: number, second: number): void {\n const value = values[first]!;\n values[first] = values[second]!;\n values[second] = value;\n}\n"],
5
- "mappings": "AAAA;AAAA,EACE;AAAA,OAMK;AACP,SAAS,mBAAmB,gCAAgC;AAC5D,SAAS,wBAAwB,+BAA+B;AAChE,SAAS,gBAAgB,+BAA+B;AACxD,SAAS,0BAA0B;AACnC,SAAS,qBAAyC;AAYlD,SAAS,+BAA+B;AACxC,SAAS,0BAA0B;AA4B5B,MAAM,wBAAwB;AAAA,EAgBnC,YAA6B,SAAyC;AAAzC;AAC3B,UAAM,WAAW,mBAAmB,QAAQ,WAAW,aAAa;AACpE,SAAK,mBAAmB,IAAI,WAAW,QAAQ;AAC/C,SAAK,qBAAqB,IAAI,WAAW,QAAQ;AACjD,SAAK,yBAAyB,IAAI,YAAY,QAAQ;AACtD,SAAK,iBAAiB,IAAI,WAAW,QAAQ;AAC7C,SAAK,qBAAqB,IAAI,YAAY,QAAQ;AAClD,SAAK,YAAY,IAAI,aAAa,QAAQ;AAC1C,SAAK,YAAY,IAAI,aAAa,QAAQ;AAC1C,SAAK,aAAa,IAAI,aAAa,QAAQ;AAC3C,SAAK,aAAa,IAAI,aAAa,QAAQ;AAC3C,SAAK,eAAe,IAAI,aAAa,QAAQ;AAC7C,SAAK,WAAW,IAAI,aAAa,QAAQ;AAAA,EAC3C;AAAA,EAb6B;AAAA,EAfrB,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAA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AAI;AACnB;AAEA,SAAS,WAAW,QAAqB,OAAe,QAAsB;AAC5E,QAAM,QAAQ,OAAO,KAAK;AAC1B,SAAO,KAAK,IAAI,OAAO,MAAM;AAC7B,SAAO,MAAM,IAAI;AACnB;AAEA,SAAS,YAAY,QAAsB,OAAe,QAAsB;AAC9E,QAAM,QAAQ,OAAO,KAAK;AAC1B,SAAO,KAAK,IAAI,OAAO,MAAM;AAC7B,SAAO,MAAM,IAAI;AACnB;",
4
+ "sourcesContent": ["import type { QueryMode, QueryOptions, QueryResult } from '../query-types.js';\nimport {\n boundsOfShape2D,\n type PibblPhysicsAabb2D,\n type PibblPhysicsPose2D,\n type PibblPhysicsRay2D,\n type PibblPhysicsShape2D,\n type PibblPhysicsVector2,\n} from \"../../../2d-geometry.js\";\nimport { copyFiniteVector2, requireNonnegativeNumber } from \"../../shared/validation.js\";\nimport { containsPointInShape2D, overlapPreparedShapes2D } from \"../collision/pairs.js\";\nimport { raycastShape2D, shapeCastAgainstShape2D } from \"../collision/casts.js\";\nimport { RADIANS_TO_DEGREES } from \"../numeric-policy.js\";\nimport { createShape2D, type ShapeRecord2D } from \"../shape-records.js\";\nimport type {\n PibblPhysicsBodyHandle2D,\n PibblPhysicsColliderHandle2D,\n PibblPhysicsCollisionFilter,\n PibblPhysicsQueryHit2D,\n PibblPhysicsQueryMatch2D,\n} from \"../types.js\";\nimport type { DynamicAabbBroadPhase2D } from \"./broad-phase.js\";\nimport { collisionFiltersAllow2D } from \"./ccd.js\";\nimport { COLLIDER_SENSOR_2D } from \"./contact-cache.js\";\nimport type { BodyStore2D, ColliderStore2D } from \"./storage.js\";\n\ninterface HandleIdentity2D {\n readonly index: number;\n readonly generation: number;\n}\n\nexport interface CommittedWorldQueriesOptions2D {\n readonly generation: number;\n readonly bodies: BodyStore2D;\n readonly colliders: ColliderStore2D;\n readonly broadPhase: DynamicAabbBroadPhase2D;\n readonly materializeBody: (index: number, generation: number) => PibblPhysicsBodyHandle2D;\n readonly materializeCollider: (index: number, generation: number) => PibblPhysicsColliderHandle2D;\n readonly resolveBody: (handle: PibblPhysicsBodyHandle2D) => HandleIdentity2D | null;\n readonly resolveCollider: (handle: PibblPhysicsColliderHandle2D) => HandleIdentity2D | null;\n}\n\ninterface PreparedQueryOptions2D {\n readonly mode: QueryMode;\n readonly sensors: \"include\" | \"exclude\" | \"only\";\n readonly collisionFilter: PibblPhysicsCollisionFilter | null;\n readonly excludeBody: HandleIdentity2D | null;\n readonly excludeCollider: HandleIdentity2D | null;\n readonly valid: boolean;\n}\n\nexport class CommittedWorldQueries2D {\n private active = true;\n private candidateProxies: Int32Array;\n private hitColliderIndices: Int32Array;\n private hitColliderGenerations: Uint32Array;\n private hitBodyIndices: Int32Array;\n private hitBodyGenerations: Uint32Array;\n private hitPointX: Float64Array;\n private hitPointY: Float64Array;\n private hitNormalX: Float64Array;\n private hitNormalY: Float64Array;\n private hitDistances: Float64Array;\n private hitTimes: Float64Array;\n private hitCount = 0;\n private readonly shapeShells = new WeakMap<ShapeRecord2D, PibblPhysicsShape2D>();\n\n constructor(private readonly options: CommittedWorldQueriesOptions2D) {\n const capacity = normalizedCapacity(options.broadPhase.proxyCapacity);\n this.candidateProxies = new Int32Array(capacity);\n this.hitColliderIndices = new Int32Array(capacity);\n this.hitColliderGenerations = new Uint32Array(capacity);\n this.hitBodyIndices = new Int32Array(capacity);\n this.hitBodyGenerations = new Uint32Array(capacity);\n this.hitPointX = new Float64Array(capacity);\n this.hitPointY = new Float64Array(capacity);\n this.hitNormalX = new Float64Array(capacity);\n this.hitNormalY = new Float64Array(capacity);\n this.hitDistances = new Float64Array(capacity);\n this.hitTimes = new Float64Array(capacity);\n }\n\n invalidate(): void {\n this.active = false;\n this.hitCount = 0;\n }\n\n raycast<Mode extends QueryMode = \"closest\">(\n worldGeneration: number,\n ray: PibblPhysicsRay2D,\n queryOptions?: QueryOptions<Mode>,\n ): QueryResult<Mode, PibblPhysicsQueryHit2D> {\n const prepared = this.prepareOptions(queryOptions);\n if (!this.isUsable(worldGeneration, prepared)) return emptyResult(prepared.mode);\n const origin = copyFiniteVector2(ray.origin, \"ray.origin\");\n const direction = copyFiniteVector2(ray.direction, \"ray.direction\");\n const directionLength = Math.hypot(direction[0], direction[1]);\n if (directionLength === 0) throw new RangeError(\"ray.direction must be non-zero.\");\n const maxDistance = requireNonnegativeNumber(ray.maxDistance, \"ray.maxDistance\");\n const endX = origin[0] + (direction[0] / directionLength) * maxDistance;\n const endY = origin[1] + (direction[1] / directionLength) * maxDistance;\n this.beginQuery();\n const candidateCount = this.queryCandidates(\n Math.min(origin[0], endX),\n Math.min(origin[1], endY),\n Math.max(origin[0], endX),\n Math.max(origin[1], endY),\n );\n for (let candidate = 0; candidate < candidateCount; candidate += 1) {\n const collider = this.semanticColliderAt(candidate, prepared);\n if (collider === null) continue;\n const hit = raycastShape2D(collider.shape, collider.pose, ray);\n if (hit === null) continue;\n if (prepared.mode === \"any\") return true as QueryResult<Mode, PibblPhysicsQueryHit2D>;\n this.appendHit(collider, hit.point, hit.normal, hit.distance, hit.timeOfImpact);\n }\n return this.finishHits<Mode>(prepared.mode);\n }\n\n shapeCast<Mode extends QueryMode = \"closest\">(\n worldGeneration: number,\n shape: PibblPhysicsShape2D,\n from: PibblPhysicsPose2D,\n translation: PibblPhysicsVector2,\n queryOptions?: QueryOptions<Mode>,\n ): QueryResult<Mode, PibblPhysicsQueryHit2D> {\n const prepared = this.prepareOptions(queryOptions);\n if (!this.isUsable(worldGeneration, prepared)) return emptyResult(prepared.mode);\n const copiedTranslation = copyFiniteVector2(translation, \"translation\");\n const start = boundsOfShape2D(shape, from);\n const end = boundsOfShape2D(shape, {\n position: [from.position[0] + copiedTranslation[0], from.position[1] + copiedTranslation[1]],\n rotationDegrees: from.rotationDegrees,\n });\n this.beginQuery();\n const candidateCount = this.queryCandidates(\n Math.min(start.min[0], end.min[0]),\n Math.min(start.min[1], end.min[1]),\n Math.max(start.max[0], end.max[0]),\n Math.max(start.max[1], end.max[1]),\n );\n for (let candidate = 0; candidate < candidateCount; candidate += 1) {\n const collider = this.semanticColliderAt(candidate, prepared);\n if (collider === null) continue;\n const hit = shapeCastAgainstShape2D(shape, from, copiedTranslation, collider.shape, collider.pose);\n if (hit === null) continue;\n if (prepared.mode === \"any\") return true as QueryResult<Mode, PibblPhysicsQueryHit2D>;\n this.appendHit(collider, hit.point, hit.normal, hit.distance, hit.timeOfImpact);\n }\n return this.finishHits<Mode>(prepared.mode);\n }\n\n overlapShape<Mode extends QueryMode = \"closest\">(\n worldGeneration: number,\n shape: PibblPhysicsShape2D,\n pose: PibblPhysicsPose2D,\n queryOptions?: QueryOptions<Mode>,\n ): QueryResult<Mode, PibblPhysicsQueryMatch2D> {\n const bounds = this.isGenerationLive(worldGeneration) ? boundsOfShape2D(shape, pose) : null;\n return this.runMatchQuery(worldGeneration, bounds, queryOptions, (collider) =>\n overlapPreparedShapes2D(shape, pose, collider.shape, collider.pose),\n );\n }\n\n queryAabb<Mode extends QueryMode = \"closest\">(\n worldGeneration: number,\n bounds: PibblPhysicsAabb2D,\n queryOptions?: QueryOptions<Mode>,\n ): QueryResult<Mode, PibblPhysicsQueryMatch2D> {\n if (!this.isGenerationLive(worldGeneration)) {\n return emptyResult(modeOf(queryOptions));\n }\n const copied = copyAabb(bounds);\n return this.runMatchQuery(worldGeneration, copied, queryOptions, (collider) => {\n const colliderBounds = boundsOfShape2D(collider.shape, collider.pose);\n return aabbsOverlap(copied, colliderBounds);\n });\n }\n\n queryPoint<Mode extends QueryMode = \"closest\">(\n worldGeneration: number,\n point: PibblPhysicsVector2,\n queryOptions?: QueryOptions<Mode>,\n ): QueryResult<Mode, PibblPhysicsQueryMatch2D> {\n if (!this.isGenerationLive(worldGeneration)) {\n return emptyResult(modeOf(queryOptions));\n }\n const copied = copyFiniteVector2(point, \"point\");\n const bounds = Object.freeze({ min: copied, max: copied });\n return this.runMatchQuery(worldGeneration, bounds, queryOptions, (collider) =>\n containsPointInShape2D(collider.shape, collider.pose, copied),\n );\n }\n\n private runMatchQuery<Mode extends QueryMode>(\n worldGeneration: number,\n bounds: PibblPhysicsAabb2D | null,\n queryOptions: QueryOptions<Mode> | undefined,\n matches: (collider: SemanticCollider2D) => boolean,\n ): QueryResult<Mode, PibblPhysicsQueryMatch2D> {\n const prepared = this.prepareOptions(queryOptions);\n if (bounds === null || !this.isUsable(worldGeneration, prepared)) {\n return emptyResult(prepared.mode);\n }\n this.beginQuery();\n const candidateCount = this.queryCandidates(bounds.min[0], bounds.min[1], bounds.max[0], bounds.max[1]);\n for (let candidate = 0; candidate < candidateCount; candidate += 1) {\n const collider = this.semanticColliderAt(candidate, prepared);\n if (collider === null || !matches(collider)) continue;\n if (prepared.mode === \"any\") {\n return true as QueryResult<Mode, PibblPhysicsQueryMatch2D>;\n }\n this.appendMatch(collider);\n }\n return this.finishMatches<Mode>(prepared.mode);\n }\n\n private prepareOptions<Mode extends QueryMode>(\n queryOptions: QueryOptions<Mode> | undefined,\n ): PreparedQueryOptions2D {\n const mode = modeOf(queryOptions);\n const sensors = queryOptions?.sensors ?? \"include\";\n if (sensors !== \"include\" && sensors !== \"exclude\" && sensors !== \"only\") {\n throw new RangeError(\"query sensors must be include, exclude, or only.\");\n }\n const excludeBody =\n queryOptions?.excludeBody === undefined ? null : this.options.resolveBody(queryOptions.excludeBody);\n const excludeCollider =\n queryOptions?.excludeCollider === undefined ? null : this.options.resolveCollider(queryOptions.excludeCollider);\n const validBody =\n queryOptions?.excludeBody === undefined ||\n (excludeBody !== null && this.options.bodies.has(excludeBody.index, excludeBody.generation));\n const validCollider =\n queryOptions?.excludeCollider === undefined ||\n (excludeCollider !== null && this.options.colliders.has(excludeCollider.index, excludeCollider.generation));\n return {\n mode,\n sensors,\n collisionFilter: queryOptions?.collisionFilter ?? null,\n excludeBody,\n excludeCollider,\n valid: validBody && validCollider,\n };\n }\n\n private isUsable(worldGeneration: number, prepared: PreparedQueryOptions2D): boolean {\n return this.isGenerationLive(worldGeneration) && prepared.valid;\n }\n\n private isGenerationLive(worldGeneration: number): boolean {\n return this.active && worldGeneration === this.options.generation;\n }\n\n private beginQuery(): void {\n this.hitCount = 0;\n this.ensureCapacity(this.options.broadPhase.proxyCapacity);\n }\n\n private queryCandidates(minX: number, minY: number, maxX: number, maxY: number): number {\n return this.options.broadPhase.queryAabbInto(\n minX,\n minY,\n maxX,\n maxY,\n this.candidateProxies,\n 0,\n this.candidateProxies.length,\n );\n }\n\n private semanticColliderAt(candidate: number, prepared: PreparedQueryOptions2D): SemanticCollider2D | null {\n const proxy = this.candidateProxies[candidate]!;\n const colliderIndex = this.options.broadPhase.proxyColliderIndices[proxy]!;\n const colliderGeneration = this.options.broadPhase.proxyColliderGenerations[proxy]!;\n const { colliders, bodies } = this.options;\n if (!colliders.has(colliderIndex, colliderGeneration)) return null;\n const bodyIndex = colliders.bodyIndices[colliderIndex]!;\n const bodyGeneration = colliders.bodyGenerations[colliderIndex]!;\n if (!bodies.has(bodyIndex, bodyGeneration)) return null;\n if (sameIdentity(prepared.excludeBody, bodyIndex, bodyGeneration)) return null;\n if (sameIdentity(prepared.excludeCollider, colliderIndex, colliderGeneration)) return null;\n const sensor = (colliders.flags[colliderIndex]! & COLLIDER_SENSOR_2D) !== 0;\n if (prepared.sensors === \"exclude\" && sensor) return null;\n if (prepared.sensors === \"only\" && !sensor) return null;\n if (\n prepared.collisionFilter !== null &&\n !collisionFiltersAllow2D(prepared.collisionFilter, colliders.filters[colliderIndex])\n )\n return null;\n const record = colliders.shapes[colliderIndex];\n if (record === null) return null;\n return {\n colliderIndex,\n colliderGeneration,\n bodyIndex,\n bodyGeneration,\n shape: this.shapeShell(record),\n pose: publicBodyOriginPose(bodies, bodyIndex),\n };\n }\n\n private appendHit(\n collider: SemanticCollider2D,\n point: PibblPhysicsVector2,\n normal: PibblPhysicsVector2,\n distance: number,\n time: number,\n ): void {\n const target = this.hitCount;\n this.writeIdentity(target, collider);\n this.hitPointX[target] = point[0];\n this.hitPointY[target] = point[1];\n this.hitNormalX[target] = normal[0];\n this.hitNormalY[target] = normal[1];\n this.hitDistances[target] = distance;\n this.hitTimes[target] = time;\n this.hitCount += 1;\n }\n\n private appendMatch(collider: SemanticCollider2D): void {\n this.writeIdentity(this.hitCount, collider);\n this.hitCount += 1;\n }\n\n private writeIdentity(target: number, collider: SemanticCollider2D): void {\n this.hitColliderIndices[target] = collider.colliderIndex;\n this.hitColliderGenerations[target] = collider.colliderGeneration;\n this.hitBodyIndices[target] = collider.bodyIndex;\n this.hitBodyGenerations[target] = collider.bodyGeneration;\n }\n\n private finishHits<Mode extends QueryMode>(\n mode: QueryMode,\n ): QueryResult<Mode, PibblPhysicsQueryHit2D> {\n this.sortHits(true);\n if (mode === \"any\") {\n return false as QueryResult<Mode, PibblPhysicsQueryHit2D>;\n }\n if (mode === \"closest\") {\n return (this.hitCount === 0 ? null : this.materializeHit(0)) as QueryResult<\n Mode,\n PibblPhysicsQueryHit2D\n >;\n }\n const results: PibblPhysicsQueryHit2D[] = [];\n for (let index = 0; index < this.hitCount; index += 1) {\n results.push(this.materializeHit(index));\n }\n return Object.freeze(results) as QueryResult<Mode, PibblPhysicsQueryHit2D>;\n }\n\n private finishMatches<Mode extends QueryMode>(\n mode: QueryMode,\n ): QueryResult<Mode, PibblPhysicsQueryMatch2D> {\n this.sortHits(false);\n if (mode === \"any\") {\n return false as QueryResult<Mode, PibblPhysicsQueryMatch2D>;\n }\n if (mode === \"closest\") {\n return (this.hitCount === 0 ? null : this.materializeMatch(0)) as QueryResult<\n Mode,\n PibblPhysicsQueryMatch2D\n >;\n }\n const results: PibblPhysicsQueryMatch2D[] = [];\n for (let index = 0; index < this.hitCount; index += 1) {\n results.push(this.materializeMatch(index));\n }\n return Object.freeze(results) as QueryResult<Mode, PibblPhysicsQueryMatch2D>;\n }\n\n private materializeHit(index: number): PibblPhysicsQueryHit2D {\n return Object.freeze({\n ...this.materializeMatch(index),\n point: freezeVector(this.hitPointX[index]!, this.hitPointY[index]!),\n normal: freezeVector(this.hitNormalX[index]!, this.hitNormalY[index]!),\n distance: this.hitDistances[index]!,\n timeOfImpact: this.hitTimes[index]!,\n });\n }\n\n private materializeMatch(index: number): PibblPhysicsQueryMatch2D {\n const bodyIndex = this.hitBodyIndices[index]!;\n const bodyGeneration = this.hitBodyGenerations[index]!;\n const colliderIndex = this.hitColliderIndices[index]!;\n const colliderGeneration = this.hitColliderGenerations[index]!;\n return Object.freeze({\n body: this.options.materializeBody(bodyIndex, bodyGeneration),\n collider: this.options.materializeCollider(colliderIndex, colliderGeneration),\n bodyGeneration,\n colliderGeneration,\n tag: this.options.colliders.tags[colliderIndex],\n });\n }\n\n private sortHits(withDistance: boolean): void {\n for (let index = 1; index < this.hitCount; index += 1) {\n let current = index;\n while (current > 0 && this.compareHits(current, current - 1, withDistance) < 0) {\n this.swapHits(current, current - 1, withDistance);\n current -= 1;\n }\n }\n }\n\n private compareHits(first: number, second: number, withDistance: boolean): number {\n if (withDistance) {\n const time = this.hitTimes[first]! - this.hitTimes[second]!;\n if (time !== 0) return time;\n const distance = this.hitDistances[first]! - this.hitDistances[second]!;\n if (distance !== 0) return distance;\n }\n return (\n this.hitColliderIndices[first]! - this.hitColliderIndices[second]! ||\n this.hitColliderGenerations[first]! - this.hitColliderGenerations[second]!\n );\n }\n\n private swapHits(first: number, second: number, withDistance: boolean): void {\n swapInt32(this.hitColliderIndices, first, second);\n swapUint32(this.hitColliderGenerations, first, second);\n swapInt32(this.hitBodyIndices, first, second);\n swapUint32(this.hitBodyGenerations, first, second);\n if (!withDistance) return;\n swapFloat64(this.hitPointX, first, second);\n swapFloat64(this.hitPointY, first, second);\n swapFloat64(this.hitNormalX, first, second);\n swapFloat64(this.hitNormalY, first, second);\n swapFloat64(this.hitDistances, first, second);\n swapFloat64(this.hitTimes, first, second);\n }\n\n private shapeShell(record: ShapeRecord2D): PibblPhysicsShape2D {\n let shell = this.shapeShells.get(record);\n if (shell === undefined) {\n shell = createShape2D(record);\n this.shapeShells.set(record, shell);\n }\n return shell;\n }\n\n private ensureCapacity(required: number): void {\n if (required <= this.candidateProxies.length) return;\n const capacity = normalizedCapacity(required);\n this.candidateProxies = growInt32(this.candidateProxies, capacity);\n this.hitColliderIndices = growInt32(this.hitColliderIndices, capacity);\n this.hitColliderGenerations = growUint32(this.hitColliderGenerations, capacity);\n this.hitBodyIndices = growInt32(this.hitBodyIndices, capacity);\n this.hitBodyGenerations = growUint32(this.hitBodyGenerations, capacity);\n this.hitPointX = growFloat64(this.hitPointX, capacity);\n this.hitPointY = growFloat64(this.hitPointY, capacity);\n this.hitNormalX = growFloat64(this.hitNormalX, capacity);\n this.hitNormalY = growFloat64(this.hitNormalY, capacity);\n this.hitDistances = growFloat64(this.hitDistances, capacity);\n this.hitTimes = growFloat64(this.hitTimes, capacity);\n }\n}\n\ninterface SemanticCollider2D {\n readonly colliderIndex: number;\n readonly colliderGeneration: number;\n readonly bodyIndex: number;\n readonly bodyGeneration: number;\n readonly shape: PibblPhysicsShape2D;\n readonly pose: PibblPhysicsPose2D;\n}\n\nfunction modeOf<Mode extends QueryMode>(\n options: QueryOptions<Mode> | undefined,\n): QueryMode {\n const mode = options?.mode ?? \"closest\";\n if (mode !== \"closest\" && mode !== \"any\" && mode !== \"all\") {\n throw new RangeError(\"query mode must be closest, any, or all.\");\n }\n return mode;\n}\n\nfunction emptyResult<Mode extends QueryMode, Result>(\n mode: QueryMode,\n): QueryResult<Mode, Result> {\n return (mode === \"any\" ? false : mode === \"all\" ? Object.freeze([]) : null) as QueryResult<Mode, Result>;\n}\n\nfunction sameIdentity(identity: HandleIdentity2D | null, index: number, generation: number): boolean {\n return identity !== null && identity.index === index && identity.generation === generation;\n}\n\nfunction publicPose(x: number, y: number, rotationRadians: number): PibblPhysicsPose2D {\n return {\n position: [x, y],\n rotationDegrees: rotationRadians * RADIANS_TO_DEGREES,\n };\n}\n\nfunction publicBodyOriginPose(\n bodies: BodyStore2D,\n index: number,\n): PibblPhysicsPose2D {\n const rotationRadians = bodies.rotationRadians[index]!;\n const cosine = Math.cos(rotationRadians);\n const sine = Math.sin(rotationRadians);\n const localCenterX = bodies.localCenterX[index]!;\n const localCenterY = bodies.localCenterY[index]!;\n return publicPose(\n bodies.positionX[index]! - cosine * localCenterX + sine * localCenterY,\n bodies.positionY[index]! - sine * localCenterX - cosine * localCenterY,\n rotationRadians,\n );\n}\n\nfunction copyAabb(bounds: PibblPhysicsAabb2D): PibblPhysicsAabb2D {\n const min = copyFiniteVector2(bounds.min, \"bounds.min\");\n const max = copyFiniteVector2(bounds.max, \"bounds.max\");\n if (min[0] > max[0] || min[1] > max[1]) {\n throw new RangeError(\"bounds.min must not exceed bounds.max.\");\n }\n return Object.freeze({ min, max });\n}\n\nfunction aabbsOverlap(first: PibblPhysicsAabb2D, second: PibblPhysicsAabb2D): boolean {\n return (\n first.min[0] <= second.max[0] &&\n first.max[0] >= second.min[0] &&\n first.min[1] <= second.max[1] &&\n first.max[1] >= second.min[1]\n );\n}\n\nfunction freezeVector(x: number, y: number): PibblPhysicsVector2 {\n return Object.freeze([x, y] as const);\n}\n\nfunction normalizedCapacity(required: number): number {\n let capacity = 1;\n while (capacity < required) capacity *= 2;\n return capacity;\n}\n\nfunction growInt32(source: Int32Array, capacity: number): Int32Array {\n const result = new Int32Array(capacity);\n result.set(source);\n return result;\n}\n\nfunction growUint32(source: Uint32Array, capacity: number): Uint32Array {\n const result = new Uint32Array(capacity);\n result.set(source);\n return result;\n}\n\nfunction growFloat64(source: Float64Array, capacity: number): Float64Array {\n const result = new Float64Array(capacity);\n result.set(source);\n return result;\n}\n\nfunction swapInt32(values: Int32Array, first: number, second: number): void {\n const value = values[first]!;\n values[first] = values[second]!;\n values[second] = value;\n}\n\nfunction swapUint32(values: Uint32Array, first: number, second: number): void {\n const value = values[first]!;\n values[first] = values[second]!;\n values[second] = value;\n}\n\nfunction swapFloat64(values: Float64Array, first: number, second: number): void {\n const value = values[first]!;\n values[first] = values[second]!;\n values[second] = value;\n}\n"],
5
+ "mappings": "AACA;AAAA,EACE;AA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igidBody(binding.handle);
138
138
  const position = body.translation();
139
139
  const velocity = body.linvel();
140
- for (const value of [
141
- position.x,
142
- position.y,
143
- velocity.x,
144
- velocity.y,
145
- body.rotation(),
146
- body.angvel()
147
- ])
148
- validateEngineNumber(value);
140
+ validateEngineNumber(position.x);
141
+ validateEngineNumber(position.y);
142
+ validateEngineNumber(velocity.x);
143
+ validateEngineNumber(velocity.y);
144
+ validateEngineNumber(body.rotation());
145
+ validateEngineNumber(body.angvel());
149
146
  const target = kinematicTargets.get(index);
150
147
  bodies.positionX[index] = target?.x ?? logicalValue(position.x, bodies.positionX[index]);
151
148
  bodies.positionY[index] = target?.y ?? logicalValue(position.y, bodies.positionY[index]);
@@ -326,21 +323,18 @@ class RapierSimulation2D {
326
323
  const generation = bodies.generations[index];
327
324
  if (!bodies.has(index, generation)) continue;
328
325
  const flags = bodies.flags[index];
329
- for (const value of [
330
- bodies.positionX[index] / SCALE,
331
- bodies.positionY[index] / SCALE,
332
- bodies.linearVelocityX[index] / SCALE,
333
- bodies.linearVelocityY[index] / SCALE,
334
- bodies.rotationRadians[index],
335
- bodies.angularVelocity[index],
336
- bodies.forceX[index] / SCALE,
337
- bodies.forceY[index] / SCALE,
338
- bodies.torque[index] / (SCALE * SCALE),
339
- bodies.gravityScale[index],
340
- bodies.linearDamping[index],
341
- bodies.angularDamping[index]
342
- ])
343
- validateEngineNumber(value);
326
+ validateEngineNumber(bodies.positionX[index] / SCALE);
327
+ validateEngineNumber(bodies.positionY[index] / SCALE);
328
+ validateEngineNumber(bodies.linearVelocityX[index] / SCALE);
329
+ validateEngineNumber(bodies.linearVelocityY[index] / SCALE);
330
+ validateEngineNumber(bodies.rotationRadians[index]);
331
+ validateEngineNumber(bodies.angularVelocity[index]);
332
+ validateEngineNumber(bodies.forceX[index] / SCALE);
333
+ validateEngineNumber(bodies.forceY[index] / SCALE);
334
+ validateEngineNumber(bodies.torque[index] / (SCALE * SCALE));
335
+ validateEngineNumber(bodies.gravityScale[index]);
336
+ validateEngineNumber(bodies.linearDamping[index]);
337
+ validateEngineNumber(bodies.angularDamping[index]);
344
338
  if (bodies.inverseMass[index] > 0)
345
339
  validateEngineNumber(1 / bodies.inverseMass[index]);
346
340
  if (bodies.inverseInertia[index] > 0)
@@ -533,8 +527,10 @@ function leafDescriptor(leaf, shape, centerX, centerY) {
533
527
  else if (typeof value === "number")
534
528
  validateEngineNumber(key === "rotationRadians" ? value : value / SCALE);
535
529
  }
536
- for (const value of [shape.localPose.x, shape.localPose.y, centerX, centerY])
537
- validateEngineNumber(value / SCALE);
530
+ validateEngineNumber(shape.localPose.x / SCALE);
531
+ validateEngineNumber(shape.localPose.y / SCALE);
532
+ validateEngineNumber(centerX / SCALE);
533
+ validateEngineNumber(centerY / SCALE);
538
534
  let desc;
539
535
  let x = 0, y = 0, angle = 0;
540
536
  if (leaf.kind === "circle") {