@luma.gl/graph 10.0.0-beta.1 → 10.0.0-beta.2

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 (327) hide show
  1. package/dist/experimental-models.cjs +21 -0
  2. package/dist/experimental-models.d.ts +2 -0
  3. package/dist/experimental-models.d.ts.map +1 -0
  4. package/dist/experimental-models.js +5 -0
  5. package/dist/experimental-models.js.map +1 -0
  6. package/dist/experimental-simulation.cjs +21 -0
  7. package/dist/experimental-simulation.d.ts +2 -0
  8. package/dist/experimental-simulation.d.ts.map +1 -0
  9. package/dist/experimental-simulation.js +5 -0
  10. package/dist/experimental-simulation.js.map +1 -0
  11. package/dist/gpu-dataframe/gpu-data-frame-query.cjs +7 -3
  12. package/dist/gpu-dataframe/gpu-data-frame-query.d.ts.map +1 -1
  13. package/dist/gpu-dataframe/gpu-data-frame-query.js +14 -4
  14. package/dist/gpu-dataframe/gpu-data-frame-query.js.map +1 -1
  15. package/dist/gpu-dataframe/gpu-expression-shader.cjs +87 -5
  16. package/dist/gpu-dataframe/gpu-expression-shader.d.ts +2 -1
  17. package/dist/gpu-dataframe/gpu-expression-shader.d.ts.map +1 -1
  18. package/dist/gpu-dataframe/gpu-expression-shader.js +101 -5
  19. package/dist/gpu-dataframe/gpu-expression-shader.js.map +1 -1
  20. package/dist/gpu-dataframe/gpu-expression.cjs +86 -0
  21. package/dist/gpu-dataframe/gpu-expression.d.ts +23 -2
  22. package/dist/gpu-dataframe/gpu-expression.d.ts.map +1 -1
  23. package/dist/gpu-dataframe/gpu-expression.js +81 -0
  24. package/dist/gpu-dataframe/gpu-expression.js.map +1 -1
  25. package/dist/gpu-dataframe/gpu-global-aggregation-compiler.cjs +0 -1
  26. package/dist/gpu-dataframe/gpu-global-aggregation-compiler.d.ts.map +1 -1
  27. package/dist/gpu-dataframe/gpu-global-aggregation-compiler.js +0 -1
  28. package/dist/gpu-dataframe/gpu-global-aggregation-compiler.js.map +1 -1
  29. package/dist/gpu-dataframe/gpu-global-aggregation-query.cjs +2 -2
  30. package/dist/gpu-dataframe/gpu-global-aggregation-query.d.ts.map +1 -1
  31. package/dist/gpu-dataframe/gpu-global-aggregation-query.js +5 -3
  32. package/dist/gpu-dataframe/gpu-global-aggregation-query.js.map +1 -1
  33. package/dist/gpu-dataframe/gpu-global-sort-compiler.cjs +23 -11
  34. package/dist/gpu-dataframe/gpu-global-sort-compiler.d.ts +1 -1
  35. package/dist/gpu-dataframe/gpu-global-sort-compiler.d.ts.map +1 -1
  36. package/dist/gpu-dataframe/gpu-global-sort-compiler.js +24 -12
  37. package/dist/gpu-dataframe/gpu-global-sort-compiler.js.map +1 -1
  38. package/dist/gpu-dataframe/gpu-group-aggregation-compiler.cjs +0 -1
  39. package/dist/gpu-dataframe/gpu-group-aggregation-compiler.d.ts.map +1 -1
  40. package/dist/gpu-dataframe/gpu-group-aggregation-compiler.js +0 -1
  41. package/dist/gpu-dataframe/gpu-group-aggregation-compiler.js.map +1 -1
  42. package/dist/gpu-dataframe/gpu-group-by-query.cjs +2 -2
  43. package/dist/gpu-dataframe/gpu-group-by-query.js +5 -3
  44. package/dist/gpu-dataframe/gpu-group-by-query.js.map +1 -1
  45. package/dist/gpu-dataframe/gpu-histogram-compiler.cjs +0 -1
  46. package/dist/gpu-dataframe/gpu-histogram-compiler.d.ts.map +1 -1
  47. package/dist/gpu-dataframe/gpu-histogram-compiler.js +0 -1
  48. package/dist/gpu-dataframe/gpu-histogram-compiler.js.map +1 -1
  49. package/dist/gpu-dataframe/gpu-join-compiler.cjs +0 -2
  50. package/dist/gpu-dataframe/gpu-join-compiler.d.ts.map +1 -1
  51. package/dist/gpu-dataframe/gpu-join-compiler.js +0 -2
  52. package/dist/gpu-dataframe/gpu-join-compiler.js.map +1 -1
  53. package/dist/gpu-dataframe/gpu-query-compiler.cjs +3 -1
  54. package/dist/gpu-dataframe/gpu-query-compiler.d.ts +0 -1
  55. package/dist/gpu-dataframe/gpu-query-compiler.d.ts.map +1 -1
  56. package/dist/gpu-dataframe/gpu-query-compiler.js +3 -1
  57. package/dist/gpu-dataframe/gpu-query-compiler.js.map +1 -1
  58. package/dist/gpu-dataframe/gpu-sort-compiler.cjs +0 -1
  59. package/dist/gpu-dataframe/gpu-sort-compiler.d.ts.map +1 -1
  60. package/dist/gpu-dataframe/gpu-sort-compiler.js +0 -1
  61. package/dist/gpu-dataframe/gpu-sort-compiler.js.map +1 -1
  62. package/dist/gpu-dataframe/gpu-sort-query.cjs +13 -5
  63. package/dist/gpu-dataframe/gpu-sort-query.d.ts +4 -1
  64. package/dist/gpu-dataframe/gpu-sort-query.d.ts.map +1 -1
  65. package/dist/gpu-dataframe/gpu-sort-query.js +14 -5
  66. package/dist/gpu-dataframe/gpu-sort-query.js.map +1 -1
  67. package/dist/gpu-dataframe/index.cjs +8 -0
  68. package/dist/gpu-dataframe/index.cjs.map +2 -2
  69. package/dist/gpu-dataframe/index.d.ts +2 -2
  70. package/dist/gpu-dataframe/index.d.ts.map +1 -1
  71. package/dist/gpu-dataframe/index.js +1 -1
  72. package/dist/gpu-dataframe/index.js.map +1 -1
  73. package/dist/gpu-dataframe/portable-expression.cjs +68 -4
  74. package/dist/gpu-dataframe/portable-expression.d.ts +3 -1
  75. package/dist/gpu-dataframe/portable-expression.d.ts.map +1 -1
  76. package/dist/gpu-dataframe/portable-expression.js +69 -5
  77. package/dist/gpu-dataframe/portable-expression.js.map +1 -1
  78. package/dist/gpu-dggs-benchmarks.cjs +21 -0
  79. package/dist/gpu-dggs-benchmarks.d.ts +2 -0
  80. package/dist/gpu-dggs-benchmarks.d.ts.map +1 -0
  81. package/dist/gpu-dggs-benchmarks.js +5 -0
  82. package/dist/gpu-dggs-benchmarks.js.map +1 -0
  83. package/dist/gpu-graph-algorithms-benchmarks.cjs +21 -0
  84. package/dist/gpu-graph-algorithms-benchmarks.d.ts +2 -0
  85. package/dist/gpu-graph-algorithms-benchmarks.d.ts.map +1 -0
  86. package/dist/gpu-graph-algorithms-benchmarks.js +5 -0
  87. package/dist/gpu-graph-algorithms-benchmarks.js.map +1 -0
  88. package/dist/gpu-physics/gpu-physics-ensemble-terrain.cjs +116 -0
  89. package/dist/gpu-physics/gpu-physics-ensemble-terrain.d.ts +42 -0
  90. package/dist/gpu-physics/gpu-physics-ensemble-terrain.d.ts.map +1 -0
  91. package/dist/gpu-physics/gpu-physics-ensemble-terrain.js +90 -0
  92. package/dist/gpu-physics/gpu-physics-ensemble-terrain.js.map +1 -0
  93. package/dist/gpu-physics/gpu-physics-ensemble.cjs +97 -5
  94. package/dist/gpu-physics/gpu-physics-ensemble.d.ts +31 -2
  95. package/dist/gpu-physics/gpu-physics-ensemble.d.ts.map +1 -1
  96. package/dist/gpu-physics/gpu-physics-ensemble.js +99 -3
  97. package/dist/gpu-physics/gpu-physics-ensemble.js.map +1 -1
  98. package/dist/gpu-physics/gpu-rigid-body-world.cjs +483 -152
  99. package/dist/gpu-physics/gpu-rigid-body-world.d.ts +64 -3
  100. package/dist/gpu-physics/gpu-rigid-body-world.d.ts.map +1 -1
  101. package/dist/gpu-physics/gpu-rigid-body-world.js +523 -161
  102. package/dist/gpu-physics/gpu-rigid-body-world.js.map +1 -1
  103. package/dist/gpu-physics/index.cjs +23 -2
  104. package/dist/gpu-physics/index.cjs.map +3 -3
  105. package/dist/gpu-physics/index.d.ts +8 -2
  106. package/dist/gpu-physics/index.d.ts.map +1 -1
  107. package/dist/gpu-physics/index.js +6 -1
  108. package/dist/gpu-physics/index.js.map +1 -1
  109. package/dist/gpu-physics/rigid-body-bounds-shaders.cjs +21 -8
  110. package/dist/gpu-physics/rigid-body-bounds-shaders.d.ts +2 -1
  111. package/dist/gpu-physics/rigid-body-bounds-shaders.d.ts.map +1 -1
  112. package/dist/gpu-physics/rigid-body-bounds-shaders.js +15 -1
  113. package/dist/gpu-physics/rigid-body-bounds-shaders.js.map +1 -1
  114. package/dist/gpu-physics/rigid-body-convex-shaders.cjs +3 -2
  115. package/dist/gpu-physics/rigid-body-convex-shaders.d.ts +1 -1
  116. package/dist/gpu-physics/rigid-body-convex-shaders.d.ts.map +1 -1
  117. package/dist/gpu-physics/rigid-body-convex-shaders.js +3 -2
  118. package/dist/gpu-physics/rigid-body-convex-shaders.js.map +1 -1
  119. package/dist/gpu-physics/rigid-body-ensemble-reset.cjs +36 -7
  120. package/dist/gpu-physics/rigid-body-ensemble-reset.d.ts +1 -1
  121. package/dist/gpu-physics/rigid-body-ensemble-reset.d.ts.map +1 -1
  122. package/dist/gpu-physics/rigid-body-ensemble-reset.js +42 -7
  123. package/dist/gpu-physics/rigid-body-ensemble-reset.js.map +1 -1
  124. package/dist/gpu-physics/rigid-body-ensemble-transaction.cjs +23 -1
  125. package/dist/gpu-physics/rigid-body-ensemble-transaction.d.ts +4 -1
  126. package/dist/gpu-physics/rigid-body-ensemble-transaction.d.ts.map +1 -1
  127. package/dist/gpu-physics/rigid-body-ensemble-transaction.js +25 -1
  128. package/dist/gpu-physics/rigid-body-ensemble-transaction.js.map +1 -1
  129. package/dist/gpu-physics/rigid-body-geometry.cjs +41 -4
  130. package/dist/gpu-physics/rigid-body-geometry.d.ts +10 -1
  131. package/dist/gpu-physics/rigid-body-geometry.d.ts.map +1 -1
  132. package/dist/gpu-physics/rigid-body-geometry.js +44 -3
  133. package/dist/gpu-physics/rigid-body-geometry.js.map +1 -1
  134. package/dist/gpu-physics/rigid-body-height-field-shader.cjs +80 -0
  135. package/dist/gpu-physics/rigid-body-height-field-shader.d.ts +3 -0
  136. package/dist/gpu-physics/rigid-body-height-field-shader.d.ts.map +1 -0
  137. package/dist/gpu-physics/rigid-body-height-field-shader.js +56 -0
  138. package/dist/gpu-physics/rigid-body-height-field-shader.js.map +1 -0
  139. package/dist/gpu-physics/rigid-body-height-field.cjs +166 -0
  140. package/dist/gpu-physics/rigid-body-height-field.d.ts +55 -0
  141. package/dist/gpu-physics/rigid-body-height-field.d.ts.map +1 -0
  142. package/dist/gpu-physics/rigid-body-height-field.js +184 -0
  143. package/dist/gpu-physics/rigid-body-height-field.js.map +1 -0
  144. package/dist/gpu-physics/rigid-body-mesh-query-shaders.cjs +4 -2
  145. package/dist/gpu-physics/rigid-body-mesh-query-shaders.d.ts +1 -1
  146. package/dist/gpu-physics/rigid-body-mesh-query-shaders.d.ts.map +1 -1
  147. package/dist/gpu-physics/rigid-body-mesh-query-shaders.js +4 -2
  148. package/dist/gpu-physics/rigid-body-mesh-query-shaders.js.map +1 -1
  149. package/dist/gpu-physics/rigid-body-mesh.cjs +72 -17
  150. package/dist/gpu-physics/rigid-body-mesh.d.ts +3 -0
  151. package/dist/gpu-physics/rigid-body-mesh.d.ts.map +1 -1
  152. package/dist/gpu-physics/rigid-body-mesh.js +76 -20
  153. package/dist/gpu-physics/rigid-body-mesh.js.map +1 -1
  154. package/dist/gpu-physics/rigid-body-properties.cjs +4 -4
  155. package/dist/gpu-physics/rigid-body-properties.d.ts +6 -0
  156. package/dist/gpu-physics/rigid-body-properties.d.ts.map +1 -1
  157. package/dist/gpu-physics/rigid-body-properties.js +1 -1
  158. package/dist/gpu-physics/rigid-body-properties.js.map +1 -1
  159. package/dist/gpu-physics/rigid-body-publication.cjs +2 -2
  160. package/dist/gpu-physics/rigid-body-publication.js +1 -1
  161. package/dist/gpu-physics/rigid-body-publication.js.map +1 -1
  162. package/dist/gpu-physics/rigid-body-query-geometry.cjs +22 -4
  163. package/dist/gpu-physics/rigid-body-query-geometry.d.ts +1 -1
  164. package/dist/gpu-physics/rigid-body-query-geometry.d.ts.map +1 -1
  165. package/dist/gpu-physics/rigid-body-query-geometry.js +22 -4
  166. package/dist/gpu-physics/rigid-body-query-geometry.js.map +1 -1
  167. package/dist/gpu-physics/rigid-body-shaders.cjs +11 -5
  168. package/dist/gpu-physics/rigid-body-shaders.d.ts +1 -1
  169. package/dist/gpu-physics/rigid-body-shaders.d.ts.map +1 -1
  170. package/dist/gpu-physics/rigid-body-shaders.js +14 -6
  171. package/dist/gpu-physics/rigid-body-shaders.js.map +1 -1
  172. package/dist/gpu-physics/rigid-body-shape-properties.cjs +2 -0
  173. package/dist/gpu-physics/rigid-body-shape-properties.d.ts.map +1 -1
  174. package/dist/gpu-physics/rigid-body-shape-properties.js +2 -0
  175. package/dist/gpu-physics/rigid-body-shape-properties.js.map +1 -1
  176. package/dist/gpu-physics/rigid-body-terrain-atlas.cjs +287 -0
  177. package/dist/gpu-physics/rigid-body-terrain-atlas.d.ts +87 -0
  178. package/dist/gpu-physics/rigid-body-terrain-atlas.d.ts.map +1 -0
  179. package/dist/gpu-physics/rigid-body-terrain-atlas.js +275 -0
  180. package/dist/gpu-physics/rigid-body-terrain-atlas.js.map +1 -0
  181. package/dist/gpu-physics/rigid-body-terrain-lod.cjs +240 -0
  182. package/dist/gpu-physics/rigid-body-terrain-lod.d.ts +76 -0
  183. package/dist/gpu-physics/rigid-body-terrain-lod.d.ts.map +1 -0
  184. package/dist/gpu-physics/rigid-body-terrain-lod.js +247 -0
  185. package/dist/gpu-physics/rigid-body-terrain-lod.js.map +1 -0
  186. package/dist/gpu-physics/rigid-body-terrain-stitch.cjs +215 -0
  187. package/dist/gpu-physics/rigid-body-terrain-stitch.d.ts +25 -0
  188. package/dist/gpu-physics/rigid-body-terrain-stitch.d.ts.map +1 -0
  189. package/dist/gpu-physics/rigid-body-terrain-stitch.js +218 -0
  190. package/dist/gpu-physics/rigid-body-terrain-stitch.js.map +1 -0
  191. package/dist/gpu-physics/rigid-body-terrain-stream.cjs +263 -0
  192. package/dist/gpu-physics/rigid-body-terrain-stream.d.ts +97 -0
  193. package/dist/gpu-physics/rigid-body-terrain-stream.d.ts.map +1 -0
  194. package/dist/gpu-physics/rigid-body-terrain-stream.js +250 -0
  195. package/dist/gpu-physics/rigid-body-terrain-stream.js.map +1 -0
  196. package/dist/gpu-physics/rigid-body-triggers.cjs +1 -0
  197. package/dist/gpu-physics/rigid-body-triggers.d.ts.map +1 -1
  198. package/dist/gpu-physics/rigid-body-triggers.js +1 -0
  199. package/dist/gpu-physics/rigid-body-triggers.js.map +1 -1
  200. package/dist/gpu-physics/rigid-body-vehicle.cjs +99 -44
  201. package/dist/gpu-physics/rigid-body-vehicle.d.ts +15 -3
  202. package/dist/gpu-physics/rigid-body-vehicle.d.ts.map +1 -1
  203. package/dist/gpu-physics/rigid-body-vehicle.js +93 -40
  204. package/dist/gpu-physics/rigid-body-vehicle.js.map +1 -1
  205. package/dist/gpu-project/cpu-geometry-pipelines.d.ts +1 -1
  206. package/dist/gpu-project/cpu-projection-operation.d.ts +1 -1
  207. package/dist/gpu-project/crs.cjs.map +2 -2
  208. package/dist/gpu-project/crs.d.ts +1 -1
  209. package/dist/gpu-project/projection-crs-benchmark.cjs +2 -2
  210. package/dist/gpu-project/projection-crs-benchmark.d.ts +1 -1
  211. package/dist/gpu-project/projection-crs-benchmark.js +1 -1
  212. package/dist/gpu-project/projection-crs-input.cjs +7 -7
  213. package/dist/gpu-project/projection-crs-input.d.ts +1 -1
  214. package/dist/gpu-project/projection-crs-input.js +4 -4
  215. package/dist/gpu-project/projection-engine.d.ts +2 -2
  216. package/dist/gpu-project-benchmarks.cjs +21 -0
  217. package/dist/gpu-project-benchmarks.d.ts +2 -0
  218. package/dist/gpu-project-benchmarks.d.ts.map +1 -0
  219. package/dist/gpu-project-benchmarks.js +5 -0
  220. package/dist/gpu-project-benchmarks.js.map +1 -0
  221. package/dist/gpu-project-crs.cjs +21 -0
  222. package/dist/gpu-project-crs.d.ts +2 -0
  223. package/dist/gpu-project-crs.d.ts.map +1 -0
  224. package/dist/gpu-project-crs.js +5 -0
  225. package/dist/gpu-project-crs.js.map +1 -0
  226. package/dist/gpu-project-geoarrow.cjs +21 -0
  227. package/dist/gpu-project-geoarrow.d.ts +2 -0
  228. package/dist/gpu-project-geoarrow.d.ts.map +1 -0
  229. package/dist/gpu-project-geoarrow.js +5 -0
  230. package/dist/gpu-project-geoarrow.js.map +1 -0
  231. package/dist/gpu-project-graph.cjs +21 -0
  232. package/dist/gpu-project-graph.d.ts +2 -0
  233. package/dist/gpu-project-graph.d.ts.map +1 -0
  234. package/dist/gpu-project-graph.js +5 -0
  235. package/dist/gpu-project-graph.js.map +1 -0
  236. package/dist/gpu-simple-graph/gpu-simple-graph-transfer.d.ts +1 -1
  237. package/dist/gpu-simple-graph/gpu-simple-graph-transfer.d.ts.map +1 -1
  238. package/dist/gpu-simple-graph/gpu-simple-graph-value.d.ts +1 -1
  239. package/dist/gpu-simple-graph/gpu-simple-graph-value.d.ts.map +1 -1
  240. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.d.ts +1 -1
  241. package/dist/gpu-simple-graph/operation/gpu-data-evaluator.d.ts.map +1 -1
  242. package/dist/gpu-simple-graph/operation/operation.d.ts +1 -1
  243. package/dist/gpu-simple-graph/operation/operation.d.ts.map +1 -1
  244. package/dist/gpu-simple-graph-cpu.cjs +21 -0
  245. package/dist/gpu-simple-graph-cpu.d.ts +2 -0
  246. package/dist/gpu-simple-graph-cpu.d.ts.map +1 -0
  247. package/dist/gpu-simple-graph-cpu.js +5 -0
  248. package/dist/gpu-simple-graph-cpu.js.map +1 -0
  249. package/dist/gpu-simple-graph-webgl.cjs +21 -0
  250. package/dist/gpu-simple-graph-webgl.d.ts +2 -0
  251. package/dist/gpu-simple-graph-webgl.d.ts.map +1 -0
  252. package/dist/gpu-simple-graph-webgl.js +5 -0
  253. package/dist/gpu-simple-graph-webgl.js.map +1 -0
  254. package/dist/gpu-simple-graph-webgpu.cjs +21 -0
  255. package/dist/gpu-simple-graph-webgpu.d.ts +2 -0
  256. package/dist/gpu-simple-graph-webgpu.d.ts.map +1 -0
  257. package/dist/gpu-simple-graph-webgpu.js +5 -0
  258. package/dist/gpu-simple-graph-webgpu.js.map +1 -0
  259. package/dist/gpu-sql/gpu-sql.cjs +76 -122
  260. package/dist/gpu-sql/gpu-sql.d.ts.map +1 -1
  261. package/dist/gpu-sql/gpu-sql.js +99 -130
  262. package/dist/gpu-sql/gpu-sql.js.map +1 -1
  263. package/dist/gpu-sql/index.cjs.map +2 -2
  264. package/package.json +19 -19
  265. package/src/experimental-models.ts +5 -0
  266. package/src/experimental-simulation.ts +5 -0
  267. package/src/gpu-dataframe/gpu-data-frame-query.ts +18 -5
  268. package/src/gpu-dataframe/gpu-expression-shader.ts +128 -7
  269. package/src/gpu-dataframe/gpu-expression.ts +124 -1
  270. package/src/gpu-dataframe/gpu-global-aggregation-compiler.ts +0 -1
  271. package/src/gpu-dataframe/gpu-global-aggregation-query.ts +5 -3
  272. package/src/gpu-dataframe/gpu-global-sort-compiler.ts +26 -12
  273. package/src/gpu-dataframe/gpu-group-aggregation-compiler.ts +0 -1
  274. package/src/gpu-dataframe/gpu-group-by-query.ts +5 -3
  275. package/src/gpu-dataframe/gpu-histogram-compiler.ts +0 -1
  276. package/src/gpu-dataframe/gpu-join-compiler.ts +0 -2
  277. package/src/gpu-dataframe/gpu-query-compiler.ts +3 -3
  278. package/src/gpu-dataframe/gpu-sort-compiler.ts +0 -1
  279. package/src/gpu-dataframe/gpu-sort-query.ts +31 -5
  280. package/src/gpu-dataframe/index.ts +15 -2
  281. package/src/gpu-dataframe/portable-expression.ts +81 -4
  282. package/src/gpu-dggs-benchmarks.ts +5 -0
  283. package/src/gpu-graph-algorithms-benchmarks.ts +5 -0
  284. package/src/gpu-physics/gpu-physics-ensemble-terrain.ts +114 -0
  285. package/src/gpu-physics/gpu-physics-ensemble.ts +147 -4
  286. package/src/gpu-physics/gpu-rigid-body-world.ts +668 -198
  287. package/src/gpu-physics/index.ts +37 -0
  288. package/src/gpu-physics/rigid-body-bounds-shaders.ts +16 -1
  289. package/src/gpu-physics/rigid-body-convex-shaders.ts +3 -2
  290. package/src/gpu-physics/rigid-body-ensemble-reset.ts +48 -8
  291. package/src/gpu-physics/rigid-body-ensemble-transaction.ts +34 -1
  292. package/src/gpu-physics/rigid-body-geometry.ts +49 -4
  293. package/src/gpu-physics/rigid-body-height-field-shader.ts +56 -0
  294. package/src/gpu-physics/rigid-body-height-field.ts +257 -0
  295. package/src/gpu-physics/rigid-body-mesh-query-shaders.ts +4 -2
  296. package/src/gpu-physics/rigid-body-mesh.ts +97 -26
  297. package/src/gpu-physics/rigid-body-properties.ts +5 -2
  298. package/src/gpu-physics/rigid-body-publication.ts +1 -1
  299. package/src/gpu-physics/rigid-body-query-geometry.ts +22 -4
  300. package/src/gpu-physics/rigid-body-shaders.ts +17 -6
  301. package/src/gpu-physics/rigid-body-shape-properties.ts +2 -0
  302. package/src/gpu-physics/rigid-body-terrain-atlas.ts +378 -0
  303. package/src/gpu-physics/rigid-body-terrain-lod.ts +332 -0
  304. package/src/gpu-physics/rigid-body-terrain-stitch.ts +286 -0
  305. package/src/gpu-physics/rigid-body-terrain-stream.ts +323 -0
  306. package/src/gpu-physics/rigid-body-triggers.ts +1 -0
  307. package/src/gpu-physics/rigid-body-vehicle.ts +108 -41
  308. package/src/gpu-project/README.md +2 -2
  309. package/src/gpu-project/cpu-geometry-pipelines.ts +1 -1
  310. package/src/gpu-project/cpu-projection-operation.ts +1 -1
  311. package/src/gpu-project/crs.ts +2 -2
  312. package/src/gpu-project/projection-crs-benchmark.ts +2 -2
  313. package/src/gpu-project/projection-crs-input.ts +4 -4
  314. package/src/gpu-project/projection-engine.ts +2 -2
  315. package/src/gpu-project-benchmarks.ts +5 -0
  316. package/src/gpu-project-crs.ts +5 -0
  317. package/src/gpu-project-geoarrow.ts +5 -0
  318. package/src/gpu-project-graph.ts +5 -0
  319. package/src/gpu-simple-graph/gpu-simple-graph-transfer.ts +1 -1
  320. package/src/gpu-simple-graph/gpu-simple-graph-value.ts +1 -1
  321. package/src/gpu-simple-graph/operation/gpu-data-evaluator.ts +1 -1
  322. package/src/gpu-simple-graph/operation/operation.ts +1 -1
  323. package/src/gpu-simple-graph/operations/swizzle.ts +1 -1
  324. package/src/gpu-simple-graph-cpu.ts +5 -0
  325. package/src/gpu-simple-graph-webgl.ts +5 -0
  326. package/src/gpu-simple-graph-webgpu.ts +5 -0
  327. package/src/gpu-sql/gpu-sql.ts +150 -152
@@ -23,9 +23,11 @@ module.exports = __toCommonJS(gpu_rigid_body_world_exports);
23
23
  var import_bound_kernel = require("../gpu-core/utils/bound-kernel.cjs");
24
24
  var import_core = require("@luma.gl/core");
25
25
  var import_rigid_body_origin = require("./rigid-body-origin.cjs");
26
+ var import_rigid_body_height_field = require("./rigid-body-height-field.cjs");
26
27
  var import_rigid_body_shape_properties = require("./rigid-body-shape-properties.cjs");
27
28
  var import_rigid_body_ensemble_shaders = require("./rigid-body-ensemble-shaders.cjs");
28
29
  var import_rigid_body_ensemble_reset = require("./rigid-body-ensemble-reset.cjs");
30
+ var import_rigid_body_terrain_atlas = require("./rigid-body-terrain-atlas.cjs");
29
31
  var import_rigid_body_geometry = require("./rigid-body-geometry.cjs");
30
32
  var import_rigid_body_properties = require("./rigid-body-properties.cjs");
31
33
  var import_gpu_command_node = require("../gpu-core/gpu-command-node.cjs");
@@ -72,6 +74,12 @@ class GPURigidBodyWorld {
72
74
  eventRead = null;
73
75
  queryComputation = null;
74
76
  queryReduction = null;
77
+ /** Chassis definitions in GPU storage order. */
78
+ vehicles;
79
+ /** Whether any chassis has more than one terrain candidate. */
80
+ multiSurfaceVehicles;
81
+ /** Number of vehicles in each equal-sized ensemble partition, or zero for a standalone world. */
82
+ vehiclesPerInstance;
75
83
  vehicleBuffer = null;
76
84
  querySettings = null;
77
85
  querySelection = null;
@@ -80,9 +88,23 @@ class GPURigidBodyWorld {
80
88
  targets = null;
81
89
  simulationStatistics = null;
82
90
  colliders;
91
+ bodyColliderStarts;
92
+ ensembleTerrainSlots;
83
93
  props;
84
94
  ownedBuffers = [];
95
+ allocationPlan;
85
96
  ensembleBuffer = null;
97
+ /** Byte offsets of writable fixed-dimension height fields in the world metadata buffer. */
98
+ heightFieldSlots = /* @__PURE__ */ new Map();
99
+ /** Float32-exact edit stamp, restored together with the contact cache. */
100
+ terrainRevision = 1;
101
+ terrainWake = null;
102
+ /** Page ownership and live lease counts for an opt-in fused atlas. */
103
+ terrainAtlas;
104
+ /** Start of the shared atlas in the GPU metadata buffer, measured in 32-bit words. */
105
+ terrainAtlasWord = 0;
106
+ /** Start of the shader geometry region in the GPU metadata buffer, measured in 32-bit words. */
107
+ terrainGeometryWord = 0;
86
108
  ensembleResetOrigin;
87
109
  ensembleReset;
88
110
  initialEnsembleBodies;
@@ -99,7 +121,7 @@ class GPURigidBodyWorld {
99
121
  gpuCheckpoints = /* @__PURE__ */ new Set();
100
122
  broadPhaseCounters = null;
101
123
  constructor(props) {
102
- var _a, _b, _c, _d, _e;
124
+ var _a, _b, _c, _d, _e, _f;
103
125
  for (const damping of [props.linearDamping ?? 0, props.angularDamping ?? 0]) {
104
126
  if (!Number.isFinite(damping) || damping < 0)
105
127
  throw new Error("Invalid damping");
@@ -148,6 +170,8 @@ class GPURigidBodyWorld {
148
170
  throw new Error("Supply shape or colliders");
149
171
  const shapes = body.colliders ?? (body.shape ? [{ shape: body.shape }] : []);
150
172
  for (const collider of shapes) {
173
+ if (collider.shape.type === "height-field" && (body.mode ?? (body.mass === 0 ? "static" : "dynamic")) !== "static")
174
+ throw new Error("Height fields require static bodies");
151
175
  const properties = (0, import_rigid_body_shape_properties.getRigidBodyShapeProperties)(collider.shape);
152
176
  if (!Number.isFinite(properties.volume) || !properties.center.every(Number.isFinite) || !properties.tensor.every(Number.isFinite))
153
177
  throw new Error("Invalid shape properties");
@@ -205,7 +229,7 @@ class GPURigidBodyWorld {
205
229
  if (!["all-pairs", "hierarchical-grid"].includes(this.broadPhase) || !Number.isSafeInteger(this.maximumPairs) || this.maximumPairs < 1 || this.maximumPairs > 1073741824 || this.broadPhase === "hierarchical-grid" && (this.maximumPairs & this.maximumPairs - 1) !== 0)
206
230
  throw new Error("Invalid rigid-body pair capacity");
207
231
  if (props.continuous) {
208
- if (props.failurePolicy !== "rollback" || !Number.isInteger(props.continuous.maximumImpacts ?? 4) || (props.continuous.maximumImpacts ?? 4) < 1 || (props.continuous.maximumImpacts ?? 4) > 16 || !["sphere-static", "convex"].includes(props.continuous.mode ?? "sphere-static") || !Number.isSafeInteger(props.continuous.maximumCandidates ?? this.maximumPairs) || (props.continuous.maximumCandidates ?? this.maximumPairs) < 1 || (props.continuous.maximumCandidates ?? this.maximumPairs) > 1073741824 || props.continuous.mode === "convex" && (Boolean((_d = props.joints) == null ? void 0 : _d.length) || colliders.some((collider) => ["plane", "triangle-mesh"].includes(collider.shape.type))))
232
+ if (props.failurePolicy !== "rollback" || !Number.isInteger(props.continuous.maximumImpacts ?? 4) || (props.continuous.maximumImpacts ?? 4) < 1 || (props.continuous.maximumImpacts ?? 4) > 16 || !["sphere-static", "convex"].includes(props.continuous.mode ?? "sphere-static") || !Number.isSafeInteger(props.continuous.maximumCandidates ?? this.maximumPairs) || (props.continuous.maximumCandidates ?? this.maximumPairs) < 1 || (props.continuous.maximumCandidates ?? this.maximumPairs) > 1073741824 || props.continuous.mode === "convex" && (Boolean((_d = props.joints) == null ? void 0 : _d.length) || colliders.some((collider) => ["plane", "triangle-mesh", "height-field"].includes(collider.shape.type))))
209
233
  throw new Error("Invalid continuous settings");
210
234
  for (const index of props.continuous.bodies) {
211
235
  const body = props.bodies[index];
@@ -222,20 +246,69 @@ class GPURigidBodyWorld {
222
246
  const definitions = structuredClone({ colliders, props });
223
247
  this.props = definitions.props;
224
248
  this.colliders = definitions.colliders;
225
- const vehicle = this.props.vehicle;
226
- if (vehicle) {
227
- const terrain = this.colliders[vehicle.terrainCollider];
249
+ this.ensembleTerrainSlots = new Set(this.props.ensembleTerrainSlots);
250
+ if (this.ensembleTerrainSlots.size && (!this.props.ensembleBodiesPerInstance || [...this.ensembleTerrainSlots].some((index) => {
251
+ var _a2;
252
+ return ((_a2 = this.colliders[index]) == null ? void 0 : _a2.shape.type) !== "height-field";
253
+ })))
254
+ throw new Error("Invalid ensemble terrain slots");
255
+ if (this.props.ensembleTerrainAtlas) {
256
+ this.terrainAtlas = new import_rigid_body_terrain_atlas.RigidBodyTerrainAtlas(this.props.ensembleTerrainAtlas, Array.from(this.ensembleTerrainSlots, (collider) => {
257
+ const shape = this.colliders[collider].shape;
258
+ if (shape.type !== "height-field")
259
+ throw new Error("Invalid ensemble terrain slot");
260
+ return { collider, width: shape.field.width, height: shape.field.height };
261
+ }));
262
+ }
263
+ this.bodyColliderStarts = new Uint32Array(this.count + 1);
264
+ let colliderIndex = 0;
265
+ for (let body = 0; body < this.count; body++) {
266
+ this.bodyColliderStarts[body] = colliderIndex;
267
+ while (((_f = this.colliders[colliderIndex]) == null ? void 0 : _f.body) === body)
268
+ colliderIndex++;
269
+ }
270
+ this.bodyColliderStarts[this.count] = colliderIndex;
271
+ if (this.props.vehicle && this.props.vehicles)
272
+ throw new Error("Choose vehicle or vehicles");
273
+ this.vehicles = this.props.vehicles ?? (this.props.vehicle ? [this.props.vehicle] : []);
274
+ this.multiSurfaceVehicles = this.vehicles.some((vehicle) => {
275
+ var _a2;
276
+ return (_a2 = vehicle.additionalTerrainColliders) == null ? void 0 : _a2.length;
277
+ });
278
+ const bodiesPerInstance = props.ensembleBodiesPerInstance;
279
+ const collidersPerInstance = props.collisionPartitionSize;
280
+ this.vehiclesPerInstance = bodiesPerInstance ? this.vehicles.length / (this.count / bodiesPerInstance) : 0;
281
+ if (!Number.isInteger(this.vehiclesPerInstance))
282
+ throw new Error("Invalid ensemble vehicle layout");
283
+ const vehicleChassis = /* @__PURE__ */ new Set();
284
+ for (const [vehicleIndex, vehicle] of this.vehicles.entries()) {
285
+ const instance = bodiesPerInstance ? Math.floor(vehicleIndex / this.vehiclesPerInstance) : 0;
286
+ const terrainIndices = [
287
+ vehicle.terrainCollider,
288
+ ...vehicle.additionalTerrainColliders ?? []
289
+ ];
228
290
  const chassis = this.props.bodies[vehicle.chassis];
229
- const ground = terrain && this.props.bodies[terrain.body];
230
- if (!chassis || !ground || vehicle.chassis === terrain.body || (chassis.mode ?? (chassis.mass === 0 ? "static" : "dynamic")) !== "dynamic" || (ground.mode ?? (ground.mass === 0 ? "static" : "dynamic")) !== "static" || vehicle.wheels.length !== 4 || this.props.failurePolicy === "rollback" || this.props.ensembleBodiesPerInstance || ![vehicle.radius, vehicle.travel, vehicle.springRate, vehicle.wheelInertia].every((value) => Number.isFinite(value) && value > 0) || ![vehicle.damping, vehicle.grip, vehicle.motorTorque, vehicle.brakeTorque].every((value) => Number.isFinite(value) && value >= 0) || vehicle.wheels.some((wheel) => wheel.mount.length !== 3 || !wheel.mount.every(Number.isFinite)))
291
+ if (!chassis || vehicleChassis.has(vehicle.chassis) || terrainIndices.length > 4 || new Set(terrainIndices).size !== terrainIndices.length || terrainIndices.some((colliderIndex2) => {
292
+ const collider = this.colliders[colliderIndex2];
293
+ const ground = collider && this.props.bodies[collider.body];
294
+ return !ground || collider.isTrigger || this.getBodyMode(collider.body) !== "static" || bodiesPerInstance && Math.floor(colliderIndex2 / collidersPerInstance) !== instance;
295
+ }) || (chassis.mode ?? (chassis.mass === 0 ? "static" : "dynamic")) !== "dynamic" || vehicle.wheels.length !== 4 || bodiesPerInstance && Math.floor(vehicle.chassis / bodiesPerInstance) !== instance || ![vehicle.radius, vehicle.travel, vehicle.springRate, vehicle.wheelInertia].every((value) => Number.isFinite(value) && value > 0) || ![vehicle.damping, vehicle.grip, vehicle.motorTorque, vehicle.brakeTorque].every((value) => Number.isFinite(value) && value >= 0) || vehicle.steeringWheelbase !== void 0 && (!Number.isFinite(Math.fround(vehicle.steeringWheelbase)) || vehicle.steeringWheelbase <= 0) || !Number.isFinite(Math.fround(vehicle.antiRollRate ?? 0)) || (vehicle.antiRollRate ?? 0) < 0 || vehicle.slipGain !== void 0 && (vehicle.slipGain.length !== 2 || !vehicle.slipGain.every((gain) => Number.isFinite(Math.fround(gain)) && gain >= 0)) || vehicle.wheels.some((wheel) => wheel.mount.length !== 3 || !wheel.mount.every(Number.isFinite)))
231
296
  throw new Error("Invalid vehicle configuration");
297
+ vehicleChassis.add(vehicle.chassis);
232
298
  }
233
299
  if (props.ensembleBodiesPerInstance)
234
300
  this.initialEnsembleBodies = this.props.bodies.slice(0, props.ensembleBodiesPerInstance);
235
301
  }
302
+ /** Allocation size including optional immutable terrain rows after the wheel state. */
303
+ getVehicleByteLength() {
304
+ return this.vehicles.length * (import_rigid_body_vehicle.VEHICLE_STRIDE + (this.multiSurfaceVehicles ? import_rigid_body_vehicle.VEHICLE_TERRAIN_ROW_SIZE : 0));
305
+ }
236
306
  getStorageLayout() {
237
- var _a, _b, _c;
238
- const packed = (0, import_rigid_body_geometry.packRigidBodyShapes)(this.colliders);
307
+ var _a, _b, _c, _d;
308
+ const packed = (0, import_rigid_body_geometry.packRigidBodyShapes)(this.colliders, Boolean(this.props.ensembleBodiesPerInstance), this.ensembleTerrainSlots, Boolean(this.terrainAtlas));
309
+ const geometryWords = packed.geometry.length + (((_a = this.terrainAtlas) == null ? void 0 : _a.wordLength) ?? 0);
310
+ if (this.terrainAtlas && geometryWords >= 2 ** 26)
311
+ throw new Error("Terrain atlas exceeds address capacity");
239
312
  const sparse = this.broadPhase === "hierarchical-grid";
240
313
  const extended = this.colliders.some((collider) => collider.shape.type !== "sphere" && collider.shape.type !== "box" || collider.isTrigger && collider.shape.type !== "sphere");
241
314
  const parallel = this.solver === "parallel";
@@ -244,11 +317,20 @@ class GPURigidBodyWorld {
244
317
  sparse,
245
318
  extended,
246
319
  parallel,
247
- ...(0, import_rigid_body_capacity.getRigidBodyStorageLayout)(this.count, this.colliderStorageCount, this.maximumPairs, packed.geometry.length, sparse, extended, parallel, this.props.eventCapacity ?? 0, this.props.enableQueries ?? false, this.props.failurePolicy === "rollback", Boolean(this.props.continuous), ((_a = this.props.joints) == null ? void 0 : _a.length) ?? 0, this.props.ensembleBodiesPerInstance ? this.count / this.props.ensembleBodiesPerInstance : 0)
320
+ ...(0, import_rigid_body_capacity.getRigidBodyStorageLayout)(this.count, this.colliderStorageCount, this.maximumPairs, geometryWords, sparse, extended, parallel, this.props.eventCapacity ?? 0, this.props.enableQueries ?? false, this.props.failurePolicy === "rollback", Boolean(this.props.continuous), ((_b = this.props.joints) == null ? void 0 : _b.length) ?? 0, this.props.ensembleBodiesPerInstance ? this.count / this.props.ensembleBodiesPerInstance : 0)
248
321
  };
249
- if (this.props.vehicle)
250
- storage.buffers.push({ name: "vehicle", byteLength: 512, uniform: false });
251
- if (((_b = this.props.continuous) == null ? void 0 : _b.mode) === "convex") {
322
+ if (this.vehicles.length) {
323
+ const byteLength = this.getVehicleByteLength();
324
+ storage.buffers.push({ name: "vehicle", byteLength, uniform: false });
325
+ if (this.props.failurePolicy === "rollback") {
326
+ storage.buffers.push({
327
+ name: this.vehiclesPerInstance ? "checkpoint-vehicles" : "checkpoint-7",
328
+ byteLength: this.vehiclesPerInstance ? this.vehicles.length * import_rigid_body_vehicle.VEHICLE_STRIDE : byteLength,
329
+ uniform: false
330
+ });
331
+ }
332
+ }
333
+ if (((_c = this.props.continuous) == null ? void 0 : _c.mode) === "convex") {
252
334
  storage.buffers = storage.buffers.filter((buffer) => buffer.name !== "continuous-previous");
253
335
  storage.buffers.push({ name: "continuous-dispatch", byteLength: 16, uniform: false });
254
336
  storage.buffers.push({
@@ -259,7 +341,7 @@ class GPURigidBodyWorld {
259
341
  }
260
342
  if (this.props.publicationBounds || this.props.publishPoses)
261
343
  storage.buffers.push({ name: "pose-metadata", byteLength: this.count * 48, uniform: false }, { name: "pose-matrices", byteLength: this.count * 64, uniform: false }, { name: "pose-bounds", byteLength: this.count * 32, uniform: false });
262
- const triggerLayout = ((_c = this.props.triggers) == null ? void 0 : _c.length) ? (0, import_rigid_body_triggers.makeRigidBodyTriggerLayout)(this.props.triggers, this.colliders) : void 0;
344
+ const triggerLayout = ((_d = this.props.triggers) == null ? void 0 : _d.length) ? (0, import_rigid_body_triggers.makeRigidBodyTriggerLayout)(this.props.triggers, this.colliders) : void 0;
263
345
  if (triggerLayout)
264
346
  storage.buffers.push({ name: "trigger-previous", byteLength: this.colliderStorageCount * 16, uniform: false }, { name: "trigger-groups", byteLength: triggerLayout.groups.byteLength, uniform: false }, { name: "trigger-pairs", byteLength: triggerLayout.pairs.byteLength, uniform: false }, {
265
347
  name: "trigger-samples",
@@ -292,7 +374,7 @@ class GPURigidBodyWorld {
292
374
  if (!this.device || !this.ensembleBuffer || this.destroyed)
293
375
  throw new Error("World has no ensemble scheduler");
294
376
  this.ensembleResetOrigin ??= this.origin;
295
- this.ensembleReset ??= (0, import_rigid_body_ensemble_reset.makeEnsembleReset)(this.device, this.id, this.ownedBuffers, this.count, this.props.ensembleBodiesPerInstance, this.props.collisionPartitionSize, this.maximumPairs);
377
+ this.ensembleReset ??= (0, import_rigid_body_ensemble_reset.makeEnsembleReset)(this.device, this.id, this.ownedBuffers, this.count, this.props.ensembleBodiesPerInstance, this.props.collisionPartitionSize, this.maximumPairs, this.vehiclesPerInstance, this.ensembleTerrainSlots);
296
378
  return this.ensembleReset.byteLength;
297
379
  }
298
380
  resetEnsembleInstance(instance) {
@@ -303,32 +385,35 @@ class GPURigidBodyWorld {
303
385
  const colliderStart = instance * this.props.collisionPartitionSize;
304
386
  let colliderIndex = colliderStart;
305
387
  const restored = this.initialEnsembleBodies.map((body) => {
306
- if (body.shape) {
307
- const current = this.colliders[colliderIndex++].shape;
388
+ const { shape, colliders, ...properties } = body;
389
+ const resetCollider = (definition) => {
390
+ var _a;
391
+ const index = colliderIndex++;
392
+ const { body: _, ...current } = this.colliders[index];
393
+ if (this.ensembleTerrainSlots.has(index))
394
+ return current;
308
395
  return {
309
- ...body,
310
- shape: body.shape.type === "convex-hull" || body.shape.type === "triangle-mesh" ? current : body.shape
396
+ ...definition,
397
+ shape: definition.shape.type === "convex-hull" || definition.shape.type === "triangle-mesh" ? current.shape : definition.shape,
398
+ excludedColliders: (_a = definition.excludedColliders) == null ? void 0 : _a.map((index2) => index2 + colliderStart)
311
399
  };
312
- }
313
- return {
314
- ...body,
315
- colliders: body.colliders.map((collider) => {
316
- var _a;
317
- const current = this.colliders[colliderIndex++].shape;
318
- return {
319
- ...collider,
320
- shape: collider.shape.type === "convex-hull" || collider.shape.type === "triangle-mesh" ? current : collider.shape,
321
- excludedColliders: (_a = collider.excludedColliders) == null ? void 0 : _a.map((index) => index + colliderStart)
322
- };
323
- })
324
400
  };
401
+ if (shape && !this.ensembleTerrainSlots.has(colliderIndex))
402
+ return { ...body, shape: resetCollider({ shape }).shape };
403
+ return { ...properties, colliders: (colliders ?? [{ shape }]).map(resetCollider) };
325
404
  });
326
- const definitions = [...this.props.bodies];
405
+ const definitions = this.props.bodies;
327
406
  definitions.splice(bodyStart, restored.length, ...restored);
328
- this.props.bodies = definitions;
329
- for (let collider = colliderStart; collider < colliderStart + this.props.collisionPartitionSize; collider++)
330
- this.colliderShapeScales.delete(collider);
331
- this.restoreColliderDefinitions();
407
+ this.restoreColliderDefinitions(bodyStart, bodyStart + restored.length);
408
+ const metadata = this.ownedBuffers.find((buffer) => buffer.id === `${this.id}-bodies`);
409
+ for (let index = colliderStart; index < colliderIndex; index++) {
410
+ this.colliderShapeScales.delete(index);
411
+ if (!this.ensembleTerrainSlots.has(index))
412
+ continue;
413
+ const collider = this.colliders[index];
414
+ const center = definitions[collider.body].centerOfMass ?? [0, 0, 0];
415
+ metadata.write(new Float32Array((collider.position ?? [0, 0, 0]).map((value, axis) => value - center[axis])), this.count * 48 + index * 96 + 16);
416
+ }
332
417
  this.ensembleReset.reset(instance, this.origin.map((value, axis) => value - this.ensembleResetOrigin[axis]));
333
418
  this.ensembleBuffer.write(new Uint32Array([0, 0, 0, 0, 1, 1]), (16 + instance * 8 + 1) * 4);
334
419
  if (this.encodePosePublication) {
@@ -373,6 +458,7 @@ class GPURigidBodyWorld {
373
458
  claimedContacts,
374
459
  journaledContacts,
375
460
  bodySnapshotBytes: activeBodies * 80,
461
+ vehicleSnapshotBytes: activeInstances * this.vehiclesPerInstance * import_rigid_body_vehicle.VEHICLE_STRIDE,
376
462
  contactSnapshotBytes: journaledContacts * 416,
377
463
  allocatorSnapshotBytes: (8 + activeInstances * 2 + journaledContacts * 3) * 4,
378
464
  residentInstances: this.count / this.props.ensembleBodiesPerInstance,
@@ -386,7 +472,7 @@ class GPURigidBodyWorld {
386
472
  }
387
473
  /** Allocation preflight without GPU allocation. Graph scratch and driver overhead are separate. */
388
474
  getCapacityInfo() {
389
- const { buffers } = this.getStorageLayout();
475
+ const buffers = this.allocationPlan ? this.allocationPlan.map((buffer) => ({ ...buffer })) : this.getStorageLayout().buffers;
390
476
  return {
391
477
  bodyCount: this.count,
392
478
  colliderCount: this.colliderCount,
@@ -405,11 +491,14 @@ class GPURigidBodyWorld {
405
491
  throw new Error("Rigid-body pair dispatch exceeds device limits");
406
492
  if (((_a = this.props.continuous) == null ? void 0 : _a.mode) === "convex" && Math.max(Math.ceil((this.props.continuous.maximumCandidates ?? this.maximumPairs) / 64), Math.ceil(2 ** Math.ceil(Math.log2(Math.max(1, this.colliders.length))) / 64)) > graph.device.limits.maxComputeWorkgroupsPerDimension)
407
493
  throw new Error("Continuous candidate dispatch exceeds device limits");
494
+ if (!this.vehiclesPerInstance && this.vehicles.length > graph.device.limits.maxComputeWorkgroupsPerDimension)
495
+ throw new Error("Vehicle dispatch exceeds device limits");
408
496
  for (const buffer of allocationPlan) {
409
497
  const bindingLimit = buffer.uniform ? graph.device.limits.maxUniformBufferBindingSize : graph.device.limits.maxStorageBufferBindingSize;
410
498
  if (buffer.byteLength > Math.min(graph.device.limits.maxBufferSize, bindingLimit))
411
499
  throw new Error(`Rigid-body ${buffer.name} storage exceeds device limits`);
412
500
  }
501
+ this.allocationPlan = allocationPlan;
413
502
  this.device = graph.device;
414
503
  const allocate = (name, data, uniform = false) => {
415
504
  const buffer = graph.device.createBuffer({
@@ -431,6 +520,29 @@ class GPURigidBodyWorld {
431
520
  } : void 0;
432
521
  const metadata = new Float32Array(metadataLength);
433
522
  metadata.set(packed.geometry, geometryOffset);
523
+ if (this.terrainAtlas) {
524
+ this.terrainGeometryWord = geometryOffset;
525
+ this.terrainAtlasWord = geometryOffset + packed.geometry.length;
526
+ const { wordsByCollider, uploads } = this.terrainAtlas.bind(Array.from(packed.atlasFields, ([collider, field]) => ({
527
+ collider,
528
+ data: new Float32Array(field.data)
529
+ })));
530
+ for (const { word, data } of uploads)
531
+ metadata.set(data, this.terrainAtlasWord + word);
532
+ for (const [collider, word] of wordsByCollider) {
533
+ const field = packed.atlasFields.get(collider);
534
+ const address = (packed.geometry.length + word) / 4;
535
+ const shape = packed.shapes[collider];
536
+ shape.padding[0] = address;
537
+ shape.padding[3] = field.triangleCount;
538
+ shape.policies[0] = address + field.nodeOffset;
539
+ shape.policies[1] = field.nodeCount;
540
+ }
541
+ }
542
+ this.heightFieldSlots = new Map(Array.from(packed.heightFields, ([collider, offset]) => [
543
+ collider,
544
+ (geometryOffset + offset * 4) * 4
545
+ ]));
434
546
  const bodyColliders = Array.from({ length: this.count }, () => []);
435
547
  if (this.colliderCount)
436
548
  for (const collider of this.colliders)
@@ -488,7 +600,10 @@ class GPURigidBodyWorld {
488
600
  (material == null ? void 0 : material.restitutionCombine) ? policies.indexOf(material.restitutionCombine) : 4,
489
601
  (material == null ? void 0 : material.frictionCombine) ? policies.indexOf(material.frictionCombine) : 4,
490
602
  ...shape.policies,
491
- ...shape.padding
603
+ shape.padding[0],
604
+ shape.padding[1],
605
+ this.ensembleTerrainSlots.has(index) ? 1 : shape.padding[2],
606
+ shape.padding[3]
492
607
  ], this.count * 12 + index * 24);
493
608
  }
494
609
  const exclusionOffset = this.count * 12 + this.colliderStorageCount * 24;
@@ -586,7 +701,7 @@ class GPURigidBodyWorld {
586
701
  byteLength: objectAttributes.byteLength,
587
702
  usage: import_core.Buffer.STORAGE
588
703
  }, objectAttributes), { format: "uint32", length: this.colliderStorageCount }) : void 0;
589
- const source = (0, import_rigid_body_shaders.getRigidBodyShader)(this.count, this.props.iterations ?? 16, this.colliderStorageCount, extended, sparseLayout, parallel, this.props.maximumMeshTraversalTestsPerPair ?? 65536, (0, import_rigid_body_joints.getRigidBodyJointShader)(this.props.joints ?? [], this.props.bodies), Boolean((_d = this.props.joints) == null ? void 0 : _d.length), this.props.linearDamping ?? 0, this.props.angularDamping ?? 0, ((_e = this.props.joints) == null ? void 0 : _e.length) ?? 0, this.props.compactContacts ?? true, this.props.collisionPartitionSize, this.props.ensembleBodiesPerInstance, this.props.parallelContactSolver === "block");
704
+ const source = (0, import_rigid_body_shaders.getRigidBodyShader)(this.count, this.props.iterations ?? 16, this.colliderStorageCount, extended, sparseLayout, parallel, this.props.maximumMeshTraversalTestsPerPair ?? 65536, (0, import_rigid_body_joints.getRigidBodyJointShader)(this.props.joints ?? [], this.props.bodies), Boolean((_d = this.props.joints) == null ? void 0 : _d.length), this.props.linearDamping ?? 0, this.props.angularDamping ?? 0, ((_e = this.props.joints) == null ? void 0 : _e.length) ?? 0, this.props.compactContacts ?? true, this.props.collisionPartitionSize, this.props.ensembleBodiesPerInstance, this.props.parallelContactSolver === "block", this.colliders.some((collider) => collider.shape.type === "height-field"));
590
705
  const parallelBindings = {
591
706
  parallelReset: ["parallelState"],
592
707
  parallelResetCounters: ["parallelState"],
@@ -656,29 +771,6 @@ class GPURigidBodyWorld {
656
771
  }
657
772
  this.simulationStatistics = allocate("simulation-statistics", 64);
658
773
  const statisticsResource = graph.importBuffer({ id: `${this.id}-statistics`, byteLength: 64, usage: import_core.Buffer.STORAGE }, this.simulationStatistics);
659
- const checkpointStates = [
660
- "positions",
661
- "orientations",
662
- "velocities",
663
- "angularVelocities",
664
- "sleepStates",
665
- "targets"
666
- ].map((name) => {
667
- const binding = bindings.find((binding2) => binding2.name === name);
668
- return { buffer: binding.buffer, resource: binding.resource };
669
- });
670
- const restoreCheckpoint = this.props.failurePolicy === "rollback" ? this.ensembleBuffer ? (0, import_rigid_body_ensemble_transaction.addEnsembleCheckpoint)(graph, this.id, checkpointStates, { buffer: this.simulationStatistics, resource: statisticsResource }, bindings.find((binding) => binding.name === "ensemble"), bindings.find((binding) => binding.name === "manifolds"), this.props.ensembleBodiesPerInstance, this.maximumPairs, allocate) : (0, import_rigid_body_transaction.addRigidBodyCheckpoint)(graph, this.id, [
671
- "positions",
672
- "orientations",
673
- "velocities",
674
- "angularVelocities",
675
- "sleepStates",
676
- "targets",
677
- ...this.ensembleBuffer ? [] : ["manifolds"]
678
- ].map((name) => {
679
- const binding = bindings.find((binding2) => binding2.name === name);
680
- return { buffer: binding.buffer, resource: binding.resource };
681
- }), { buffer: this.simulationStatistics, resource: statisticsResource }, allocate) : void 0;
682
774
  const continuousSelection = new Uint32Array(this.count);
683
775
  for (const body of ((_g = this.props.continuous) == null ? void 0 : _g.bodies) ?? [])
684
776
  continuousSelection[body] = this.colliders.findIndex((collider) => collider.body === body) + 1;
@@ -713,45 +805,66 @@ class GPURigidBodyWorld {
713
805
  parallelMarkSleep: "Identify islands whose bodies are quiet enough to sleep.",
714
806
  parallelSleep: "Put quiet constraint islands to sleep."
715
807
  };
716
- const vehicle = this.props.vehicle;
717
- if (vehicle) {
718
- const data = new Float32Array(128);
719
- data.set([
720
- vehicle.radius,
721
- vehicle.travel,
722
- vehicle.springRate,
723
- vehicle.damping,
724
- vehicle.grip,
725
- vehicle.motorTorque,
726
- vehicle.brakeTorque,
727
- vehicle.wheelInertia
728
- ], 4);
729
- new Uint32Array(data.buffer).set([vehicle.chassis, vehicle.terrainCollider], 12);
730
- vehicle.wheels.forEach((wheel, index) => {
731
- const offset = 16 + index * 12;
732
- data.set(wheel.mount, offset);
733
- data.set([Number(Boolean(wheel.steer)), Number(Boolean(wheel.drive))], offset + 4);
734
- data[offset + 10] = vehicle.travel;
808
+ let vehicleResource;
809
+ let addVehiclePass;
810
+ if (this.vehicles.length) {
811
+ const packed2 = new Float32Array(this.getVehicleByteLength() / 4);
812
+ for (const [vehicleIndex, vehicle] of this.vehicles.entries()) {
813
+ const data = packed2.subarray(vehicleIndex * import_rigid_body_vehicle.VEHICLE_STRIDE / 4, (vehicleIndex + 1) * import_rigid_body_vehicle.VEHICLE_STRIDE / 4);
735
814
  data.set([
736
- 1,
737
- 0,
738
- 0,
739
- 0,
740
- 0,
741
- 1,
742
- 0,
743
- 0,
744
- 0,
745
- 0,
746
- 1,
747
- 0,
748
- wheel.mount[0],
749
- wheel.mount[1],
750
- wheel.mount[2] - vehicle.travel,
751
- 1
752
- ], 64 + 16 * index);
753
- });
754
- this.vehicleBuffer = allocate("vehicle", data);
815
+ vehicle.radius,
816
+ vehicle.travel,
817
+ vehicle.springRate,
818
+ vehicle.damping,
819
+ vehicle.grip,
820
+ vehicle.motorTorque,
821
+ vehicle.brakeTorque,
822
+ vehicle.wheelInertia
823
+ ], 4);
824
+ new Uint32Array(data.buffer, data.byteOffset, data.length).set([vehicle.chassis, vehicle.terrainCollider], 12);
825
+ data.set([vehicle.steeringWheelbase ?? 0, vehicle.antiRollRate ?? 0], 14);
826
+ const [longitudinalGain, lateralGain] = vehicle.slipGain ?? [1.1, 1.5];
827
+ vehicle.wheels.forEach((wheel, index) => {
828
+ const offset = 16 + index * 12;
829
+ data.set([...wheel.mount, longitudinalGain + 1], offset);
830
+ data.set([Number(Boolean(wheel.steer)), Number(Boolean(wheel.drive)), lateralGain + 1], offset + 4);
831
+ data[offset + 10] = vehicle.travel;
832
+ data.set([
833
+ 1,
834
+ 0,
835
+ 0,
836
+ 0,
837
+ 0,
838
+ 1,
839
+ 0,
840
+ 0,
841
+ 0,
842
+ 0,
843
+ 1,
844
+ 0,
845
+ wheel.mount[0],
846
+ wheel.mount[1],
847
+ wheel.mount[2] - vehicle.travel,
848
+ 1
849
+ ], 64 + 16 * index);
850
+ });
851
+ }
852
+ if (this.multiSurfaceVehicles) {
853
+ const terrainRows = new Uint32Array(packed2.buffer, this.vehicles.length * import_rigid_body_vehicle.VEHICLE_STRIDE);
854
+ terrainRows.fill(4294967295);
855
+ for (const [vehicleIndex, vehicle] of this.vehicles.entries())
856
+ terrainRows.set(vehicle.additionalTerrainColliders ?? [], vehicleIndex * (import_rigid_body_vehicle.VEHICLE_TERRAIN_ROW_SIZE / 4));
857
+ }
858
+ this.vehicleBuffer = allocate("vehicle", packed2);
859
+ vehicleResource = {
860
+ buffer: this.vehicleBuffer,
861
+ resource: graph.importBuffer({
862
+ id: this.id + "-vehicle",
863
+ byteLength: packed2.byteLength,
864
+ usage: import_core.Buffer.STORAGE | import_core.Buffer.COPY_SRC
865
+ }, this.vehicleBuffer)
866
+ };
867
+ const ensembleBinding = bindings.find((binding) => binding.name === "ensemble");
755
868
  const vehicleBindings = [
756
869
  ...bindings.filter((binding) => [
757
870
  "settings",
@@ -760,45 +873,74 @@ class GPURigidBodyWorld {
760
873
  "velocities",
761
874
  "angularVelocities",
762
875
  "bodies",
763
- "sleepStates"
876
+ "sleepStates",
877
+ "ensemble"
764
878
  ].includes(binding.name)),
765
- {
766
- name: "vehicle",
767
- location: 12,
768
- buffer: this.vehicleBuffer,
769
- resource: graph.importBuffer({ id: this.id + "-vehicle", byteLength: data.byteLength, usage: import_core.Buffer.STORAGE }, this.vehicleBuffer)
770
- }
879
+ { name: "vehicle", location: 12, ...vehicleResource }
771
880
  ];
772
881
  const properties = {
773
882
  id: this.id + "-suspension",
774
- source: source + import_rigid_body_query_geometry.RIGID_BODY_QUERY_GEOMETRY_SHADER + import_rigid_body_vehicle.VEHICLE_SHADER,
883
+ source: (0, import_rigid_body_ensemble_shaders.readOnlyEnsembleShader)(source) + import_rigid_body_query_geometry.RIGID_BODY_QUERY_GEOMETRY_SHADER + (0, import_rigid_body_vehicle.getVehicleShader)(this.vehicles.length, this.multiSurfaceVehicles, this.vehiclesPerInstance),
775
884
  entryPoint: "advanceVehicle",
776
885
  shaderLayout: {
777
886
  bindings: vehicleBindings.map(({ name, location }) => name === "settings" ? { name, location, group: 0, type: "uniform" } : {
778
887
  name,
779
888
  location,
780
889
  group: 0,
781
- type: name === "bodies" ? "read-only-storage" : "storage"
890
+ type: name === "bodies" || name === "ensemble" ? "read-only-storage" : "storage"
782
891
  })
783
892
  }
784
893
  };
785
894
  const executable = (computation) => ({
786
895
  encode: ({ computePass, getBuffer }) => {
787
896
  Object.assign(computation.bindings, Object.fromEntries(vehicleBindings.map((binding) => [binding.name, getBuffer(binding.resource)])));
788
- computation.kernel.dispatch(computePass, { bindings: computation.bindings, x: 1 });
897
+ if (ensembleBinding)
898
+ computation.kernel.dispatchIndirect(computePass, {
899
+ bindings: computation.bindings,
900
+ indirectBuffer: getBuffer(ensembleBinding.resource),
901
+ indirectOffset: 16
902
+ });
903
+ else
904
+ computation.kernel.dispatch(computePass, {
905
+ bindings: computation.bindings,
906
+ x: this.vehicles.length
907
+ });
789
908
  },
790
909
  destroy: () => computation.kernel.destroy()
791
910
  });
792
- graph.addComputePass({
911
+ addVehiclePass = () => graph.addComputePass({
793
912
  id: properties.id,
794
- resources: vehicleBindings.map((binding) => ({
795
- buffer: binding.resource,
796
- usage: binding.name === "settings" ? "uniform" : binding.name === "bodies" ? "storage-read" : "storage-read-write"
797
- })),
913
+ description: "Sweep four wheels and apply suspension and tire forces per chassis.",
914
+ resources: [
915
+ ...vehicleBindings.map((binding) => ({
916
+ buffer: binding.resource,
917
+ usage: binding.name === "settings" ? "uniform" : binding.name === "bodies" || binding.name === "ensemble" ? "storage-read" : "storage-read-write"
918
+ })),
919
+ ...ensembleBinding ? [{ buffer: ensembleBinding.resource, usage: "indirect" }] : []
920
+ ],
798
921
  compile: () => executable((0, import_bound_kernel.createBoundKernel)(graph.device, properties)),
799
922
  compileAsync: async () => executable(await (0, import_bound_kernel.createBoundKernelAsync)(graph.device, properties))
800
923
  });
801
924
  }
925
+ const checkpointStates = [
926
+ "positions",
927
+ "orientations",
928
+ "velocities",
929
+ "angularVelocities",
930
+ "sleepStates",
931
+ "targets"
932
+ ].map((name) => {
933
+ const binding = bindings.find((binding2) => binding2.name === name);
934
+ return { buffer: binding.buffer, resource: binding.resource };
935
+ });
936
+ const restoreCheckpoint = this.props.failurePolicy === "rollback" ? this.ensembleBuffer ? (0, import_rigid_body_ensemble_transaction.addEnsembleCheckpoint)(graph, this.id, checkpointStates, { buffer: this.simulationStatistics, resource: statisticsResource }, bindings.find((binding) => binding.name === "ensemble"), bindings.find((binding) => binding.name === "manifolds"), this.props.ensembleBodiesPerInstance, this.maximumPairs, allocate, vehicleResource && {
937
+ state: vehicleResource,
938
+ vehiclesPerInstance: this.vehiclesPerInstance
939
+ }) : (0, import_rigid_body_transaction.addRigidBodyCheckpoint)(graph, this.id, [
940
+ ...checkpointStates,
941
+ bindings.find((binding) => binding.name === "manifolds"),
942
+ ...vehicleResource ? [vehicleResource] : []
943
+ ], { buffer: this.simulationStatistics, resource: statisticsResource }, allocate) : void 0;
802
944
  for (const entryPoint of [
803
945
  ...this.ensembleBuffer ? ["ensembleClear", "ensembleMark", "ensembleCompact", "ensembleDispatch"] : [],
804
946
  "integrate",
@@ -827,8 +969,10 @@ class GPURigidBodyWorld {
827
969
  "parallelSleep"
828
970
  ] : [...extended && ((_j = this.props.joints) == null ? void 0 : _j.length) ? ["meshCollect"] : [], "solve", "finish"]
829
971
  ]) {
830
- if (entryPoint === "integrate")
972
+ if (entryPoint === "integrate") {
831
973
  (_k = restoreCheckpoint == null ? void 0 : restoreCheckpoint.save) == null ? void 0 : _k.call(restoreCheckpoint);
974
+ addVehiclePass == null ? void 0 : addVehiclePass();
975
+ }
832
976
  if (sparse && entryPoint === "collide") {
833
977
  const bodyBinding = bindings.find((binding) => binding.name === "bodies");
834
978
  const minimumBinding = bindings.find((binding) => binding.name === "minima");
@@ -1288,6 +1432,48 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
1288
1432
  },
1289
1433
  bindings: Object.fromEntries(Object.entries(controlProperties.bindings).filter(([name]) => invalidationBindings.includes(name)))
1290
1434
  });
1435
+ if (this.heightFieldSlots.size && !this.ensembleBuffer) {
1436
+ this.terrainWake = (0, import_bound_kernel.createBoundKernel)(graph.device, {
1437
+ id: `${this.id}-terrain-wake`,
1438
+ entryPoint: "wakeTerrain",
1439
+ source: controlProperties.source + /* wgsl */
1440
+ `
1441
+ @group(0) @binding(26) var<storage,read_write> terrainSleep:array<atomic<u32>>;
1442
+ @compute @workgroup_size(64) fn wakeTerrain(@builtin(global_invocation_id) invocation:vec3u) {
1443
+ let collider=invocation.x;if(collider>=COLLIDER_COUNT){return;}
1444
+ let body=colliderBody(collider);if(!dynamic(body)){return;}
1445
+ let tile=command.bodyIndex.x;if(bodies.colliders[tile].padding.w==0.0){return;}
1446
+ if(any(abs(colliderPosition(collider)-colliderPosition(tile))>shapeWorldExtent(collider)+shapeWorldExtent(tile)+vec3f(settings.solver.x))){return;}
1447
+ // Several colliders on one sleeping body may all overlap the tile.
1448
+ for(var axis=0u;axis<4u;axis++){atomicStore(&terrainSleep[body*4u+axis],0u);}
1449
+ }`,
1450
+ shaderLayout: {
1451
+ bindings: [
1452
+ ...shaderLayout.bindings.filter((binding) => ["settings", "positions", "orientations", "bodies"].includes(binding.name)),
1453
+ { name: "command", group: 0, location: 8, type: "uniform" },
1454
+ { name: "terrainSleep", group: 0, location: 26, type: "storage" }
1455
+ ]
1456
+ },
1457
+ bindings: {
1458
+ settings: buffers.settings,
1459
+ positions: buffers.positions,
1460
+ orientations: buffers.orientations,
1461
+ bodies: buffers.bodies,
1462
+ command: this.controlSettings,
1463
+ terrainSleep: this.sleepStates
1464
+ }
1465
+ });
1466
+ }
1467
+ }
1468
+ /** Wake sleeping bodies overlapping one published terrain footprint. */
1469
+ wakeTerrainFootprint(collider) {
1470
+ const { kernel, bindings } = this.terrainWake;
1471
+ this.controlSettings.write(new Uint32Array([collider]), 48);
1472
+ const encoder = this.device.createCommandEncoder();
1473
+ const pass = encoder.beginComputePass();
1474
+ kernel.dispatch(pass, { bindings, x: Math.ceil(this.colliderStorageCount / 64) });
1475
+ pass.end();
1476
+ this.device.submit(encoder.finish());
1291
1477
  }
1292
1478
  invalidateState(pass) {
1293
1479
  var _a, _b;
@@ -1321,62 +1507,76 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
1321
1507
  return definition ? definition.mode ?? ((definition.mass ?? 1) === 0 ? "static" : "dynamic") : void 0;
1322
1508
  }
1323
1509
  /** Set signed throttle, steering angle in radians and brake fraction for upcoming substeps. */
1324
- setVehicleControls(throttle, steering, brake) {
1325
- if (!this.vehicleBuffer || this.destroyed || ![throttle, steering, brake].every(Number.isFinite))
1510
+ setVehicleControls(throttle, steering, brake, vehicleIndex = 0) {
1511
+ if (!this.vehicleBuffer || this.destroyed || !this.vehicles[vehicleIndex] || ![throttle, steering, brake].every((value) => Number.isFinite(Math.fround(value))))
1326
1512
  throw new Error("Invalid vehicle controls");
1327
1513
  this.vehicleBuffer.write(new Float32Array([
1328
1514
  Math.max(-1, Math.min(1, throttle)),
1329
1515
  steering,
1330
1516
  Math.max(0, Math.min(1, brake)),
1331
1517
  0
1332
- ]));
1518
+ ]), vehicleIndex * import_rigid_body_vehicle.VEHICLE_STRIDE);
1519
+ if (this.vehiclesPerInstance) {
1520
+ const instance = Math.floor(vehicleIndex / this.vehiclesPerInstance);
1521
+ this.ensembleBuffer.write(new Uint32Array([1]), (16 + instance * 8 + 6) * 4);
1522
+ }
1333
1523
  }
1334
1524
  /** Borrow four column-major wheel transforms relative to the chassis node, ordered by mount. */
1335
1525
  get vehicleWheelPoses() {
1336
- return this.vehicleBuffer && !this.destroyed ? { buffer: this.vehicleBuffer, byteOffset: 256, byteLength: 256 } : null;
1526
+ return this.getVehicleWheelPoses();
1527
+ }
1528
+ /** Borrow the indexed vehicle’s four chassis-local wheel poses, in mount order. */
1529
+ getVehicleWheelPoses(vehicleIndex = 0) {
1530
+ return this.vehicleBuffer && !this.destroyed && this.vehicles[vehicleIndex] ? {
1531
+ buffer: this.vehicleBuffer,
1532
+ byteOffset: vehicleIndex * import_rigid_body_vehicle.VEHICLE_STRIDE + 256,
1533
+ byteLength: 256
1534
+ } : null;
1337
1535
  }
1338
1536
  /** Transfer wheel motion between rebuilt worlds for wheels with matching chassis-local mounts. */
1339
- copyVehicleMotionFrom(previous) {
1537
+ copyVehicleMotionFrom(previous, vehicleIndex = 0, previousVehicleIndex = 0) {
1340
1538
  var _a;
1341
1539
  const sourceBuffer = previous.vehicleBuffer;
1342
1540
  const destinationBuffer = this.vehicleBuffer;
1343
- const previousVehicle = previous.props.vehicle;
1541
+ const previousVehicle = previous.vehicles[previousVehicleIndex];
1344
1542
  if (!this.device || !sourceBuffer || !destinationBuffer || !previousVehicle)
1345
1543
  return;
1346
1544
  const encoder = this.device.createCommandEncoder();
1347
- (_a = this.props.vehicle) == null ? void 0 : _a.wheels.forEach((wheel, index) => {
1545
+ (_a = this.vehicles[vehicleIndex]) == null ? void 0 : _a.wheels.forEach((wheel, index) => {
1348
1546
  const sourceIndex = previousVehicle.wheels.findIndex((source) => source.mount.every((coordinate, axis) => coordinate === wheel.mount[axis]));
1349
1547
  if (sourceIndex < 0)
1350
1548
  return;
1351
1549
  encoder.copyBufferToBuffer({
1352
1550
  sourceBuffer,
1353
1551
  destinationBuffer,
1354
- sourceOffset: 96 + sourceIndex * 48,
1355
- destinationOffset: 96 + index * 48,
1356
- size: 16
1552
+ sourceOffset: previousVehicleIndex * import_rigid_body_vehicle.VEHICLE_STRIDE + 92 + sourceIndex * 48,
1553
+ destinationOffset: vehicleIndex * import_rigid_body_vehicle.VEHICLE_STRIDE + 92 + index * 48,
1554
+ size: 20
1357
1555
  });
1358
1556
  encoder.copyBufferToBuffer({
1359
1557
  sourceBuffer,
1360
1558
  destinationBuffer,
1361
- sourceOffset: 256 + sourceIndex * 64,
1362
- destinationOffset: 256 + index * 64,
1559
+ sourceOffset: previousVehicleIndex * import_rigid_body_vehicle.VEHICLE_STRIDE + 256 + sourceIndex * 64,
1560
+ destinationOffset: vehicleIndex * import_rigid_body_vehicle.VEHICLE_STRIDE + 256 + index * 64,
1363
1561
  size: 64
1364
1562
  });
1365
1563
  });
1366
1564
  this.device.submit(encoder.finish());
1367
1565
  }
1368
1566
  /** Read wheel spin, angle, suspension length and normal load after submitted steps. */
1369
- async readVehicleWheels() {
1370
- if (!this.vehicleBuffer || this.destroyed)
1567
+ async readVehicleWheels(vehicleIndex = 0) {
1568
+ if (!this.vehicleBuffer || this.destroyed || !this.vehicles[vehicleIndex])
1371
1569
  throw new Error("Vehicle unavailable");
1372
- const values = new Float32Array((await this.vehicleBuffer.readAsync(0, 256)).buffer);
1570
+ const bytes = await this.vehicleBuffer.readAsync(vehicleIndex * import_rigid_body_vehicle.VEHICLE_STRIDE, 256);
1571
+ const values = new Float32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4);
1373
1572
  return Array.from({ length: 4 }, (_, index) => {
1374
1573
  const offset = 24 + index * 12;
1375
1574
  return {
1376
1575
  speed: values[offset],
1377
1576
  angle: values[offset + 1],
1378
1577
  length: values[offset + 2],
1379
- load: values[offset + 3]
1578
+ load: values[offset + 3],
1579
+ steering: values[offset - 1]
1380
1580
  };
1381
1581
  });
1382
1582
  }
@@ -1460,7 +1660,7 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
1460
1660
  const shape = structuredClone(edit.shape);
1461
1661
  if (edit.shapeScale && (edit.shapeScale.length !== 3 || edit.shapeScale.some((value) => !Number.isFinite(value) || value <= 0)))
1462
1662
  throw new Error("Invalid collider shape scale");
1463
- if (indices.has(edit.collider) || previous.type !== shape.type || shape.type === "convex-hull" || shape.type === "triangle-mesh")
1663
+ if (indices.has(edit.collider) || previous.type !== shape.type || shape.type === "convex-hull" || shape.type === "triangle-mesh" || shape.type === "height-field")
1464
1664
  throw new Error("Shape edit requires a topology rebuild");
1465
1665
  indices.add(edit.collider);
1466
1666
  const properties = (0, import_rigid_body_shape_properties.getRigidBodyShapeProperties)(shape);
@@ -1493,6 +1693,94 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
1493
1693
  this.setBodyParameters(body, {});
1494
1694
  }
1495
1695
  }
1696
+ /**
1697
+ * Replace or evict fixed-dimension height-field tiles between submissions.
1698
+ * Optional positions are in each collider's body-local frame. The caller owns
1699
+ * tile selection and must submit already encoded steps before editing residency.
1700
+ */
1701
+ setHeightFieldTiles(edits) {
1702
+ var _a;
1703
+ if (!edits.length)
1704
+ return;
1705
+ const metadata = this.ownedBuffers.find((buffer) => buffer.id === `${this.id}-bodies`);
1706
+ if (!metadata || this.destroyed || this.queryPending || this.eventRead || this.triggerRead)
1707
+ throw new Error("Terrain streaming requires an idle attached world");
1708
+ const seen = /* @__PURE__ */ new Set();
1709
+ const packedFields = this.terrainAtlas ? /* @__PURE__ */ new Map() : void 0;
1710
+ const replacements = edits.map(({ collider: colliderIndex, field, position }) => {
1711
+ const collider = this.colliders[colliderIndex];
1712
+ const offset = this.heightFieldSlots.get(colliderIndex);
1713
+ if (offset === void 0 && !(this.terrainAtlas && this.ensembleTerrainSlots.has(colliderIndex)) || (collider == null ? void 0 : collider.shape.type) !== "height-field" || seen.has(colliderIndex))
1714
+ throw new Error("Invalid writable height-field slot");
1715
+ seen.add(colliderIndex);
1716
+ const previous = collider.shape.field;
1717
+ if (field && (field.width !== previous.width || field.height !== previous.height))
1718
+ throw new Error("Height-field slot dimensions are fixed");
1719
+ const center = this.props.bodies[collider.body].centerOfMass ?? [0, 0, 0];
1720
+ const localOffset = position == null ? void 0 : position.map((value, axis) => value - center[axis]);
1721
+ if (position && (position.length !== 3 || !(localOffset == null ? void 0 : localOffset.every((value) => Number.isFinite(Math.fround(value))))))
1722
+ throw new Error("Invalid height-field tile position");
1723
+ let payload = field ? packedFields == null ? void 0 : packedFields.get(field) : void 0;
1724
+ if (!payload) {
1725
+ const next = field ? structuredClone(field) : { ...previous, heights: void 0, validity: void 0 };
1726
+ const packed = (0, import_rigid_body_height_field.packRigidBodyHeightField)(next);
1727
+ const data = packedFields && packed.nodeCount ? new Float32Array(packed.data) : null;
1728
+ payload = { field: next, packed, data };
1729
+ if (field)
1730
+ packedFields == null ? void 0 : packedFields.set(field, payload);
1731
+ }
1732
+ return { collider, colliderIndex, offset, position, localOffset, ...payload };
1733
+ });
1734
+ const atlas = (_a = this.terrainAtlas) == null ? void 0 : _a.bind(replacements.map(({ colliderIndex, data }) => ({ collider: colliderIndex, data })));
1735
+ if (this.terrainRevision === 16777215) {
1736
+ this.wake();
1737
+ this.terrainRevision = 1;
1738
+ }
1739
+ const revision = ++this.terrainRevision;
1740
+ for (const { word, data } of (atlas == null ? void 0 : atlas.uploads) ?? [])
1741
+ metadata.write(data, (this.terrainAtlasWord + word) * 4);
1742
+ const changedBodies = /* @__PURE__ */ new Set();
1743
+ const affectedInstances = /* @__PURE__ */ new Set();
1744
+ for (const replacement of replacements) {
1745
+ const { collider, colliderIndex, offset, field, position, localOffset, packed } = replacement;
1746
+ const base = this.count * 48 + colliderIndex * 96;
1747
+ if (this.terrainWake)
1748
+ this.wakeTerrainFootprint(colliderIndex);
1749
+ if (atlas) {
1750
+ const word = atlas.wordsByCollider.get(colliderIndex);
1751
+ const address = word === void 0 ? 0 : (this.terrainAtlasWord - this.terrainGeometryWord + word) / 4;
1752
+ metadata.write(new Float32Array([
1753
+ word === void 0 ? 0 : address + packed.nodeOffset,
1754
+ packed.nodeCount,
1755
+ address
1756
+ ]), base + 72);
1757
+ } else {
1758
+ metadata.write(new Float32Array(packed.data), offset);
1759
+ metadata.write(new Float32Array([packed.nodeCount]), base + 76);
1760
+ }
1761
+ metadata.write(new Float32Array(packed.extent), base);
1762
+ metadata.write(new Float32Array([revision, packed.triangleCount]), base + 88);
1763
+ if (position && localOffset) {
1764
+ metadata.write(new Float32Array(localOffset), base + 16);
1765
+ collider.position = [...position];
1766
+ }
1767
+ collider.shape = { type: "height-field", field };
1768
+ changedBodies.add(collider.body);
1769
+ if (this.terrainWake)
1770
+ this.wakeTerrainFootprint(colliderIndex);
1771
+ if (this.props.ensembleBodiesPerInstance)
1772
+ affectedInstances.add(Math.floor(collider.body / this.props.ensembleBodiesPerInstance));
1773
+ }
1774
+ for (const body of changedBodies)
1775
+ this.updateColliderDefinitions(body);
1776
+ for (const instance of affectedInstances)
1777
+ this.wakeEnsembleInstance(instance);
1778
+ }
1779
+ /** Shared atlas utilization, when the fused layout enabled page sharing. */
1780
+ getTerrainAtlasStats() {
1781
+ var _a;
1782
+ return (_a = this.terrainAtlas) == null ? void 0 : _a.getStats();
1783
+ }
1496
1784
  /** Change an existing collider material between submissions, invalidating cached friction. */
1497
1785
  setColliderMaterial(colliderIndex, material) {
1498
1786
  const collider = this.colliders[colliderIndex];
@@ -1552,10 +1840,8 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
1552
1840
  }
1553
1841
  updateColliderDefinitions(bodyIndex) {
1554
1842
  const { shape, colliders, ...properties } = this.props.bodies[bodyIndex];
1555
- const updated = this.colliders.filter((candidate) => candidate.body === bodyIndex).map(({ body, ...candidate }) => candidate);
1556
- const bodies = [...this.props.bodies];
1557
- bodies[bodyIndex] = { ...properties, colliders: updated };
1558
- this.props.bodies = bodies;
1843
+ const updated = this.colliders.slice(this.bodyColliderStarts[bodyIndex], this.bodyColliderStarts[bodyIndex + 1]).map(({ body, ...candidate }) => candidate);
1844
+ this.props.bodies[bodyIndex] = { ...properties, colliders: updated };
1559
1845
  }
1560
1846
  getColliderMaterial(collider) {
1561
1847
  const definition = this.colliders[collider];
@@ -1563,14 +1849,17 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
1563
1849
  throw new Error("Invalid collider");
1564
1850
  return structuredClone(definition.material ?? {});
1565
1851
  }
1566
- restoreColliderDefinitions() {
1567
- const definitions = this.props.bodies.flatMap((body) => body.colliders ?? (body.shape ? [{ shape: body.shape }] : []));
1568
- for (const [index, definition] of definitions.entries()) {
1569
- const collider = this.colliders[index];
1570
- collider.shape = definition.shape;
1571
- collider.material = definition.material;
1572
- collider.position = definition.position;
1573
- collider.orientation = definition.orientation;
1852
+ restoreColliderDefinitions(first = 0, end = this.count) {
1853
+ for (let body = first; body < end; body++) {
1854
+ const definition = this.props.bodies[body];
1855
+ const colliders = definition.colliders ?? (definition.shape ? [{ shape: definition.shape }] : []);
1856
+ for (const [index, source] of colliders.entries()) {
1857
+ const collider = this.colliders[this.bodyColliderStarts[body] + index];
1858
+ collider.shape = source.shape;
1859
+ collider.material = source.material;
1860
+ collider.position = source.position;
1861
+ collider.orientation = source.orientation;
1862
+ }
1574
1863
  }
1575
1864
  }
1576
1865
  /** Update motion properties between submissions; preserve the node pose when its COM changes. */
@@ -1597,9 +1886,12 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
1597
1886
  (0, import_rigid_body_joints.validateRigidBodyJoints)(this.props.joints, proposedBodies, this.solver);
1598
1887
  }
1599
1888
  const colliders = this.colliders.filter((collider) => collider.body === bodyIndex);
1600
- for (const collider of colliders)
1889
+ for (const collider of colliders) {
1890
+ if (collider.shape.type === "height-field" && mode !== "static")
1891
+ throw new Error("Height fields require static bodies");
1601
1892
  if ((collider.shape.type === "convex-hull" || collider.shape.type === "triangle-mesh") && mode !== "static" && mass > 0 && (!collider.shape.geometry.closed || !((0, import_rigid_body_shape_properties.getRigidBodyShapeProperties)(collider.shape).volume > 0)))
1602
1893
  throw new Error("Dynamic meshes require closed positive-volume geometry");
1894
+ }
1603
1895
  if (((_b = this.props.continuous) == null ? void 0 : _b.bodies.includes(bodyIndex)) && (mode !== "dynamic" || mass === 0 || this.props.continuous.mode !== "convex" && (colliders[0].position ?? [0, 0, 0]).some((value, axis) => value !== center[axis])))
1604
1896
  throw new Error("Mutation exceeds the continuous body envelope");
1605
1897
  const compound = (0, import_rigid_body_properties.getCompoundBodyInertia)(mass, colliders, center);
@@ -1879,6 +2171,7 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
1879
2171
  }
1880
2172
  /** Reusable same-world GPU checkpoint; copies state without CPU pose or buffer readback. */
1881
2173
  createGPUCheckpoint(options = {}) {
2174
+ var _a;
1882
2175
  if (!this.device || this.destroyed)
1883
2176
  throw new Error("Checkpoint requires an attached world");
1884
2177
  const device = this.device;
@@ -1891,6 +2184,8 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
1891
2184
  let bodyDefinitions = structuredClone(this.props.bodies);
1892
2185
  let contactCursor = 0;
1893
2186
  let triggerCursor = 0;
2187
+ let terrainRevision = this.terrainRevision;
2188
+ let terrainAtlas = (_a = this.terrainAtlas) == null ? void 0 : _a.snapshot();
1894
2189
  try {
1895
2190
  for (const buffer of checkpointBuffers)
1896
2191
  snapshots.push(device.createBuffer({
@@ -1920,6 +2215,7 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
1920
2215
  const checkpoint = {
1921
2216
  byteLength: snapshots.reduce((sum, buffer) => sum + buffer.byteLength, 0),
1922
2217
  save: () => {
2218
+ var _a2;
1923
2219
  copy(false);
1924
2220
  origin = [...this.worldOrigin];
1925
2221
  joints = structuredClone(this.props.joints);
@@ -1928,6 +2224,8 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
1928
2224
  publicationBounds = structuredClone(this.props.publicationBounds);
1929
2225
  contactCursor = this.eventCursor;
1930
2226
  triggerCursor = this.triggerCursor;
2227
+ terrainRevision = this.terrainRevision;
2228
+ terrainAtlas = (_a2 = this.terrainAtlas) == null ? void 0 : _a2.snapshot();
1931
2229
  saved = true;
1932
2230
  },
1933
2231
  restore: () => {
@@ -1942,6 +2240,9 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
1942
2240
  this.props.publicationBounds = structuredClone(publicationBounds);
1943
2241
  this.eventCursor = contactCursor;
1944
2242
  this.triggerCursor = triggerCursor;
2243
+ this.terrainRevision = terrainRevision;
2244
+ if (terrainAtlas)
2245
+ this.terrainAtlas.restore(terrainAtlas.leases, (_word, _words, page) => terrainAtlas.payloads.get(page));
1945
2246
  },
1946
2247
  destroy: () => {
1947
2248
  if (released)
@@ -1957,6 +2258,7 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
1957
2258
  }
1958
2259
  /** Stop graph submissions and controls first; includes diagnostics, caches and event history. */
1959
2260
  async captureState(options = {}) {
2261
+ var _a;
1960
2262
  if (!this.device || this.destroyed || this.queryPending || this.eventRead || this.triggerRead)
1961
2263
  throw new Error("Capture requires an idle attached world");
1962
2264
  return {
@@ -1967,6 +2269,8 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
1967
2269
  colliderShapeScales: structuredClone([...this.colliderShapeScales]),
1968
2270
  contactCursor: this.eventCursor,
1969
2271
  triggerCursor: this.triggerCursor,
2272
+ terrainRevision: this.terrainRevision,
2273
+ terrainAtlasLeases: (_a = this.terrainAtlas) == null ? void 0 : _a.getLeases(),
1970
2274
  buffers: await Promise.all(this.getSnapshotBuffers(options.includeRollbackScratch).map(async (buffer) => ({
1971
2275
  name: buffer.id.slice(this.id.length + 1),
1972
2276
  data: new Uint8Array(await buffer.readAsync())
@@ -1976,7 +2280,8 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
1976
2280
  /** Restore between submissions on the same configuration and implementation; no implicit wake. */
1977
2281
  restoreState(capture) {
1978
2282
  const checkpointBuffers = this.getSnapshotBuffers(capture.includeRollbackScratch);
1979
- if (!this.device || this.destroyed || this.queryPending || this.eventRead || this.triggerRead || capture.version !== 1 || capture.origin !== void 0 && (capture.origin.length !== 3 || !capture.origin.every(Number.isFinite)) || capture.buffers.length !== checkpointBuffers.length || serializeCaptureProps(capture.props) !== serializeCaptureProps(this.props) || ![capture.contactCursor, capture.triggerCursor].every((value) => Number.isInteger(value) && value >= 0 && value <= 4294967295))
2283
+ const terrainRevision = capture.terrainRevision ?? 1;
2284
+ if (!this.device || this.destroyed || this.queryPending || this.eventRead || this.triggerRead || capture.version !== 1 || Boolean(capture.terrainAtlasLeases) !== Boolean(this.terrainAtlas) || !Number.isInteger(terrainRevision) || terrainRevision < 1 || terrainRevision > 16777215 || capture.origin !== void 0 && (capture.origin.length !== 3 || !capture.origin.every(Number.isFinite)) || capture.buffers.length !== checkpointBuffers.length || serializeCaptureProps(capture.props) !== serializeCaptureProps(this.props) || ![capture.contactCursor, capture.triggerCursor].every((value) => Number.isInteger(value) && value >= 0 && value <= 4294967295))
1980
2285
  throw new Error("Incompatible rigid-body capture");
1981
2286
  const shapeScales = new Map(capture.colliderShapeScales ?? []);
1982
2287
  for (const [index, scale] of shapeScales) {
@@ -1989,6 +2294,26 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
1989
2294
  if (saved.name !== buffer.id.slice(this.id.length + 1) || !(saved.data instanceof Uint8Array) || saved.data.byteLength !== buffer.byteLength)
1990
2295
  throw new Error("Incompatible rigid-body capture storage");
1991
2296
  }
2297
+ if (this.terrainAtlas && capture.terrainAtlasLeases) {
2298
+ const metadata = capture.buffers.find((buffer) => buffer.name === "bodies").data;
2299
+ const view = new DataView(metadata.buffer, metadata.byteOffset, metadata.byteLength);
2300
+ const colliderBase = this.count * 48;
2301
+ let active = 0;
2302
+ for (const collider of this.ensembleTerrainSlots)
2303
+ if (view.getFloat32(colliderBase + collider * 96 + 76, true) > 0)
2304
+ active++;
2305
+ if (active !== capture.terrainAtlasLeases.length)
2306
+ throw new Error("Incomplete captured terrain atlas leases");
2307
+ this.terrainAtlas.restore(capture.terrainAtlasLeases, (word, words) => {
2308
+ const first = (this.terrainAtlasWord + word) * 4;
2309
+ return new Float32Array(metadata.slice(first, first + words * 4).buffer);
2310
+ }, (collider, word) => {
2311
+ const base = colliderBase + collider * 96;
2312
+ const address = (this.terrainAtlasWord - this.terrainGeometryWord + word) / 4;
2313
+ if (view.getFloat32(base + 76, true) <= 0 || view.getFloat32(base + 80, true) !== address)
2314
+ throw new Error("Captured terrain collider has an invalid page address");
2315
+ });
2316
+ }
1992
2317
  for (const [index, buffer] of checkpointBuffers.entries())
1993
2318
  buffer.write(capture.buffers[index].data);
1994
2319
  this.props.joints = structuredClone(capture.props.joints);
@@ -1999,6 +2324,7 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
1999
2324
  this.worldOrigin = [...capture.origin ?? [0, 0, 0]];
2000
2325
  this.eventCursor = capture.contactCursor;
2001
2326
  this.triggerCursor = capture.triggerCursor;
2327
+ this.terrainRevision = terrainRevision;
2002
2328
  }
2003
2329
  /** Stop submissions first. Reconstruct with these accepted poses and larger budgets after rollback. */
2004
2330
  async getRecoveryProps(overrides = {}) {
@@ -2088,7 +2414,7 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
2088
2414
  }
2089
2415
  /** Destroy the compiled graph and finish readbacks before destroying its world. */
2090
2416
  destroy() {
2091
- var _a, _b, _c, _d, _e;
2417
+ var _a, _b, _c, _d, _e, _f;
2092
2418
  if (this.destroyed)
2093
2419
  return;
2094
2420
  (_a = this.ensembleReset) == null ? void 0 : _a.destroy();
@@ -2097,8 +2423,9 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
2097
2423
  this.destroyed = true;
2098
2424
  (_b = this.control) == null ? void 0 : _b.kernel.destroy();
2099
2425
  (_c = this.invalidation) == null ? void 0 : _c.kernel.destroy();
2100
- (_d = this.queryComputation) == null ? void 0 : _d.kernel.destroy();
2101
- (_e = this.queryReduction) == null ? void 0 : _e.kernel.destroy();
2426
+ (_d = this.terrainWake) == null ? void 0 : _d.kernel.destroy();
2427
+ (_e = this.queryComputation) == null ? void 0 : _e.kernel.destroy();
2428
+ (_f = this.queryReduction) == null ? void 0 : _f.kernel.destroy();
2102
2429
  for (const buffer of this.ownedBuffers)
2103
2430
  buffer.destroy();
2104
2431
  this.ownedBuffers.length = 0;
@@ -2114,10 +2441,14 @@ function serializeCaptureProps(props) {
2114
2441
  ...body,
2115
2442
  shape: void 0,
2116
2443
  colliders: (body.colliders ?? [{ shape: body.shape }]).map((collider) => {
2117
- var _a2, _b, _c;
2444
+ var _a2, _b, _c, _d;
2118
2445
  return {
2119
2446
  ...collider,
2120
- shape: ((_a2 = collider.shape) == null ? void 0 : _a2.type) === "convex-hull" || ((_b = collider.shape) == null ? void 0 : _b.type) === "triangle-mesh" ? collider.shape : { type: (_c = collider.shape) == null ? void 0 : _c.type },
2447
+ shape: ((_a2 = collider.shape) == null ? void 0 : _a2.type) === "convex-hull" || ((_b = collider.shape) == null ? void 0 : _b.type) === "triangle-mesh" ? collider.shape : ((_c = collider.shape) == null ? void 0 : _c.type) === "height-field" ? {
2448
+ type: collider.shape.type,
2449
+ width: collider.shape.field.width,
2450
+ height: collider.shape.field.height
2451
+ } : { type: (_d = collider.shape) == null ? void 0 : _d.type },
2121
2452
  material: void 0,
2122
2453
  position: void 0,
2123
2454
  orientation: void 0