@woosh/meep-engine 3.43.0 → 3.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (287) hide show
  1. package/editor/prototypeEditorShell.d.ts.map +1 -1
  2. package/editor/prototypeEditorShell.js +4 -2
  3. package/package.json +1 -1
  4. package/src/engine/Clock.d.ts +15 -0
  5. package/src/engine/Clock.d.ts.map +1 -1
  6. package/src/engine/Clock.js +29 -5
  7. package/src/engine/Engine.d.ts.map +1 -1
  8. package/src/engine/Engine.js +11 -19
  9. package/src/engine/graphics/ecs/mesh-v2/MeshSkin.d.ts +57 -0
  10. package/src/engine/graphics/ecs/mesh-v2/MeshSkin.d.ts.map +1 -0
  11. package/src/engine/graphics/ecs/mesh-v2/MeshSkin.js +84 -0
  12. package/src/engine/graphics3/AnimationGraphSystem.d.ts +23 -13
  13. package/src/engine/graphics3/AnimationGraphSystem.d.ts.map +1 -1
  14. package/src/engine/graphics3/AnimationGraphSystem.js +61 -64
  15. package/src/engine/graphics3/AnimationSystem.d.ts +24 -15
  16. package/src/engine/graphics3/AnimationSystem.d.ts.map +1 -1
  17. package/src/engine/graphics3/AnimationSystem.js +67 -61
  18. package/src/engine/graphics3/MeshSkinSystem.d.ts +56 -0
  19. package/src/engine/graphics3/MeshSkinSystem.d.ts.map +1 -0
  20. package/src/engine/graphics3/MeshSkinSystem.js +317 -0
  21. package/src/engine/graphics3/MeshSystem.d.ts +15 -35
  22. package/src/engine/graphics3/MeshSystem.d.ts.map +1 -1
  23. package/src/engine/graphics3/MeshSystem.js +21 -298
  24. package/src/engine/graphics3/RowChains.d.ts +76 -0
  25. package/src/engine/graphics3/RowChains.d.ts.map +1 -0
  26. package/src/engine/graphics3/RowChains.js +347 -0
  27. package/src/engine/graphics3/ShadedGeometrySystem.d.ts +6 -0
  28. package/src/engine/graphics3/ShadedGeometrySystem.d.ts.map +1 -1
  29. package/src/engine/graphics3/ShadedGeometrySystem.js +329 -309
  30. package/src/engine/graphics3/animation/AnimationClips.d.ts +56 -0
  31. package/src/engine/graphics3/animation/AnimationClips.d.ts.map +1 -0
  32. package/src/engine/graphics3/animation/AnimationClips.js +79 -0
  33. package/src/engine/graphics3/animation/ClipListPlayer.d.ts +13 -14
  34. package/src/engine/graphics3/animation/ClipListPlayer.d.ts.map +1 -1
  35. package/src/engine/graphics3/animation/ClipListPlayer.js +262 -263
  36. package/src/engine/graphics3/animation/write_clip_playback.d.ts +3 -3
  37. package/src/engine/graphics3/animation/write_clip_playback.js +4 -4
  38. package/src/engine/graphics3/pose/query_entity_node_world_pose.d.ts +5 -0
  39. package/src/engine/graphics3/pose/query_entity_node_world_pose.d.ts.map +1 -1
  40. package/src/engine/graphics3/pose/query_entity_node_world_pose.js +80 -75
  41. package/src/engine/graphics3/prefab/PrefabInstance.d.ts +4 -24
  42. package/src/engine/graphics3/prefab/PrefabInstance.d.ts.map +1 -1
  43. package/src/engine/graphics3/prefab/PrefabInstance.js +60 -80
  44. package/src/engine/graphics3/prefab/prefab_instantiate.d.ts +16 -3
  45. package/src/engine/graphics3/prefab/prefab_instantiate.d.ts.map +1 -1
  46. package/src/engine/graphics3/prefab/prefab_instantiate.js +49 -12
  47. package/src/engine/graphics3/prefab/prefab_place.d.ts +31 -17
  48. package/src/engine/graphics3/prefab/prefab_place.d.ts.map +1 -1
  49. package/src/engine/graphics3/prefab/prefab_place.js +175 -130
  50. package/src/engine/graphics3/register_clips.d.ts +64 -0
  51. package/src/engine/graphics3/register_clips.d.ts.map +1 -0
  52. package/src/engine/graphics3/register_clips.js +114 -0
  53. package/src/engine/physics/cloth/MEASUREMENTS.md +795 -0
  54. package/src/engine/physics/cloth/PLAN.md +339 -9
  55. package/src/engine/physics/cloth/build/ClothProxy.d.ts +113 -61
  56. package/src/engine/physics/cloth/build/ClothProxy.d.ts.map +1 -1
  57. package/src/engine/physics/cloth/build/ClothProxy.js +142 -77
  58. package/src/engine/physics/cloth/build/cloth_bind_in_frame.d.ts +22 -0
  59. package/src/engine/physics/cloth/build/cloth_bind_in_frame.d.ts.map +1 -0
  60. package/src/engine/physics/cloth/build/cloth_bind_in_frame.js +75 -0
  61. package/src/engine/physics/cloth/build/cloth_proxy_from_joints.d.ts +43 -30
  62. package/src/engine/physics/cloth/build/cloth_proxy_from_joints.d.ts.map +1 -1
  63. package/src/engine/physics/cloth/build/cloth_proxy_from_joints.js +357 -284
  64. package/src/engine/physics/cloth/build/cloth_proxy_from_mesh.d.ts +62 -0
  65. package/src/engine/physics/cloth/build/cloth_proxy_from_mesh.d.ts.map +1 -0
  66. package/src/engine/physics/cloth/build/cloth_proxy_from_mesh.js +280 -0
  67. package/src/engine/physics/cloth/collider/cloth_collider_sdf.d.ts +1 -1
  68. package/src/engine/physics/cloth/collider/cloth_collider_sdf.js +1 -1
  69. package/src/engine/physics/cloth/ecs/Cloth.d.ts +17 -9
  70. package/src/engine/physics/cloth/ecs/Cloth.d.ts.map +1 -1
  71. package/src/engine/physics/cloth/ecs/Cloth.js +220 -212
  72. package/src/engine/physics/cloth/ecs/ClothDynamicsFlags.js +6 -0
  73. package/src/engine/physics/cloth/ecs/ClothHold.d.ts +91 -0
  74. package/src/engine/physics/cloth/ecs/ClothHold.d.ts.map +1 -0
  75. package/src/engine/physics/cloth/ecs/ClothHold.js +103 -0
  76. package/src/engine/physics/cloth/ecs/ClothInstance.d.ts +254 -48
  77. package/src/engine/physics/cloth/ecs/ClothInstance.d.ts.map +1 -1
  78. package/src/engine/physics/cloth/ecs/ClothInstance.js +277 -47
  79. package/src/engine/physics/cloth/ecs/ClothPin.d.ts +73 -0
  80. package/src/engine/physics/cloth/ecs/ClothPin.d.ts.map +1 -0
  81. package/src/engine/physics/cloth/ecs/ClothPin.js +92 -0
  82. package/src/engine/physics/cloth/ecs/ClothPinSerializationAdapter.d.ts +36 -0
  83. package/src/engine/physics/cloth/ecs/ClothPinSerializationAdapter.d.ts.map +1 -0
  84. package/src/engine/physics/cloth/ecs/ClothPinSerializationAdapter.js +61 -0
  85. package/src/engine/physics/cloth/ecs/ClothRig.d.ts +23 -17
  86. package/src/engine/physics/cloth/ecs/ClothRig.d.ts.map +1 -1
  87. package/src/engine/physics/cloth/ecs/ClothRig.js +29 -27
  88. package/src/engine/physics/cloth/ecs/ClothSystem.d.ts +12 -14
  89. package/src/engine/physics/cloth/ecs/ClothSystem.d.ts.map +1 -1
  90. package/src/engine/physics/cloth/ecs/ClothSystem.js +20 -15
  91. package/src/engine/physics/cloth/ecs/ClothWorld.d.ts +57 -36
  92. package/src/engine/physics/cloth/ecs/ClothWorld.d.ts.map +1 -1
  93. package/src/engine/physics/cloth/ecs/ClothWorld.js +816 -179
  94. package/src/engine/physics/cloth/ecs/WorkerClothSystem.d.ts +12 -13
  95. package/src/engine/physics/cloth/ecs/WorkerClothSystem.d.ts.map +1 -1
  96. package/src/engine/physics/cloth/ecs/WorkerClothSystem.js +20 -14
  97. package/src/engine/physics/cloth/ecs/cloth_build_rows.d.ts +63 -11
  98. package/src/engine/physics/cloth/ecs/cloth_build_rows.d.ts.map +1 -1
  99. package/src/engine/physics/cloth/ecs/cloth_build_rows.js +321 -84
  100. package/src/engine/physics/cloth/ecs/cloth_dynamics_map.d.ts +9 -7
  101. package/src/engine/physics/cloth/ecs/cloth_dynamics_map.d.ts.map +1 -1
  102. package/src/engine/physics/cloth/ecs/cloth_dynamics_map.js +9 -7
  103. package/src/engine/physics/cloth/ecs/cloth_gather_colliders.d.ts +3 -3
  104. package/src/engine/physics/cloth/ecs/cloth_gather_colliders.js +30 -30
  105. package/src/engine/physics/cloth/ecs/cloth_geodesic.d.ts +37 -0
  106. package/src/engine/physics/cloth/ecs/cloth_geodesic.d.ts.map +1 -0
  107. package/src/engine/physics/cloth/ecs/cloth_geodesic.js +142 -0
  108. package/src/engine/physics/cloth/ecs/cloth_holds.d.ts +97 -0
  109. package/src/engine/physics/cloth/ecs/cloth_holds.d.ts.map +1 -0
  110. package/src/engine/physics/cloth/ecs/cloth_holds.js +608 -0
  111. package/src/engine/physics/cloth/ecs/cloth_reconstruct_pose.d.ts +2 -2
  112. package/src/engine/physics/cloth/ecs/cloth_reconstruct_pose.d.ts.map +1 -1
  113. package/src/engine/physics/cloth/ecs/cloth_reconstruct_pose.js +160 -9
  114. package/src/engine/physics/cloth/ecs/cloth_seed_rig.d.ts +17 -22
  115. package/src/engine/physics/cloth/ecs/cloth_seed_rig.d.ts.map +1 -1
  116. package/src/engine/physics/cloth/ecs/cloth_seed_rig.js +55 -117
  117. package/src/engine/physics/cloth/ecs/cloth_seed_subtree.d.ts +21 -6
  118. package/src/engine/physics/cloth/ecs/cloth_seed_subtree.d.ts.map +1 -1
  119. package/src/engine/physics/cloth/ecs/cloth_seed_subtree.js +44 -15
  120. package/src/engine/physics/cloth/ecs/cloth_write_back.d.ts +5 -0
  121. package/src/engine/physics/cloth/ecs/cloth_write_back.d.ts.map +1 -1
  122. package/src/engine/physics/cloth/ecs/cloth_write_back.js +60 -16
  123. package/src/engine/physics/cloth/ecs/cloth_write_back_rig.d.ts.map +1 -1
  124. package/src/engine/physics/cloth/ecs/cloth_write_back_rig.js +65 -58
  125. package/src/engine/physics/cloth/playground/collide_main.js +1 -1
  126. package/src/engine/physics/cloth/playground/garment_build.d.ts.map +1 -1
  127. package/src/engine/physics/cloth/playground/garment_build.js +17 -5
  128. package/src/engine/physics/cloth/playground/garment_main.js +1 -1
  129. package/src/engine/physics/cloth/playground/rig_build.d.ts.map +1 -1
  130. package/src/engine/physics/cloth/playground/rig_build.js +302 -296
  131. package/src/engine/physics/cloth/solver/ClothState.d.ts +45 -7
  132. package/src/engine/physics/cloth/solver/ClothState.d.ts.map +1 -1
  133. package/src/engine/physics/cloth/solver/ClothState.js +63 -7
  134. package/src/engine/physics/cloth/solver/cloth_contact_find.d.ts +6 -1
  135. package/src/engine/physics/cloth/solver/cloth_contact_find.d.ts.map +1 -1
  136. package/src/engine/physics/cloth/solver/cloth_contact_find.js +7 -2
  137. package/src/engine/physics/cloth/solver/cloth_hold_line.d.ts +114 -0
  138. package/src/engine/physics/cloth/solver/cloth_hold_line.d.ts.map +1 -0
  139. package/src/engine/physics/cloth/solver/cloth_hold_line.js +362 -0
  140. package/src/engine/physics/cloth/solver/cloth_self_find.d.ts +6 -2
  141. package/src/engine/physics/cloth/solver/cloth_self_find.d.ts.map +1 -1
  142. package/src/engine/physics/cloth/solver/cloth_self_find.js +13 -13
  143. package/src/engine/physics/cloth/solver/cloth_solver_constants.d.ts +24 -12
  144. package/src/engine/physics/cloth/solver/cloth_solver_constants.d.ts.map +1 -1
  145. package/src/engine/physics/cloth/solver/cloth_solver_constants.js +24 -12
  146. package/src/engine/physics/cloth/solver/cloth_step.d.ts +16 -0
  147. package/src/engine/physics/cloth/solver/cloth_step.d.ts.map +1 -1
  148. package/src/engine/physics/cloth/solver/cloth_step.js +183 -20
  149. package/src/engine/physics/cloth/solver/cloth_step_instance.d.ts +1 -0
  150. package/src/engine/physics/cloth/solver/cloth_step_instance.d.ts.map +1 -1
  151. package/src/engine/physics/cloth/solver/cloth_step_instance.js +10 -3
  152. package/src/engine/physics/cloth/solver/constraint/cloth_leash_row.d.ts +1 -1
  153. package/src/engine/physics/cloth/solver/constraint/cloth_leash_row.d.ts.map +1 -1
  154. package/src/engine/physics/cloth/solver/constraint/cloth_leash_row.js +353 -346
  155. package/src/engine/physics/cloth/solver/constraint/cloth_self_row.d.ts +7 -5
  156. package/src/engine/physics/cloth/solver/constraint/cloth_self_row.d.ts.map +1 -1
  157. package/src/engine/physics/cloth/solver/constraint/cloth_self_row.js +7 -5
  158. package/src/engine/physics/cloth/wind/cloth_sample_air.d.ts +9 -9
  159. package/src/engine/physics/cloth/wind/cloth_sample_air.d.ts.map +1 -1
  160. package/src/engine/physics/cloth/wind/cloth_sample_air.js +26 -26
  161. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  162. package/src/engine/simulation/Ticker.d.ts +13 -0
  163. package/src/engine/simulation/Ticker.d.ts.map +1 -1
  164. package/src/engine/simulation/Ticker.js +43 -8
  165. package/src/shade/RENDERER_CONTRACT.md +8 -2
  166. package/src/shade/playground/mesh_row_ceiling/main.js +2 -1
  167. package/src/shade/playground/skinned_blas_refit/main.d.ts.map +1 -1
  168. package/src/shade/playground/skinned_blas_refit/main.js +11 -19
  169. package/src/shade/playground/skinned_blas_refit/place_character.d.ts +6 -3
  170. package/src/shade/playground/skinned_blas_refit/place_character.d.ts.map +1 -1
  171. package/src/shade/playground/skinned_blas_refit/place_character.js +90 -90
  172. package/src/shade/playground/skinned_mesh_soup/main.d.ts.map +1 -1
  173. package/src/shade/playground/skinned_mesh_soup/main.js +502 -509
  174. package/src/shade/playground/texture_encode/README.md +129 -109
  175. package/src/shade/playground/texture_encode/main.js +1430 -1430
  176. package/src/shade/renderer/animation/GPUAnimationManager.d.ts +45 -14
  177. package/src/shade/renderer/animation/GPUAnimationManager.d.ts.map +1 -1
  178. package/src/shade/renderer/animation/GPUAnimationManager.js +316 -64
  179. package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.d.ts +5 -0
  180. package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.d.ts.map +1 -1
  181. package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.js +11 -1
  182. package/src/shade/renderer/geometry/BoxGeometry.d.ts +1 -11
  183. package/src/shade/renderer/geometry/BoxGeometry.d.ts.map +1 -1
  184. package/src/shade/renderer/geometry/BoxGeometry.js +6 -13
  185. package/src/shade/renderer/geometry/CapsuleGeometry.d.ts +19 -0
  186. package/src/shade/renderer/geometry/CapsuleGeometry.d.ts.map +1 -0
  187. package/src/shade/renderer/geometry/CapsuleGeometry.js +24 -0
  188. package/src/shade/renderer/geometry/ConeGeometry.d.ts +20 -0
  189. package/src/shade/renderer/geometry/ConeGeometry.d.ts.map +1 -0
  190. package/src/shade/renderer/geometry/ConeGeometry.js +33 -0
  191. package/src/shade/renderer/geometry/CylinderGeometry.d.ts +21 -0
  192. package/src/shade/renderer/geometry/CylinderGeometry.d.ts.map +1 -0
  193. package/src/shade/renderer/geometry/CylinderGeometry.js +35 -0
  194. package/src/shade/renderer/geometry/PlaneGeometry.d.ts +17 -0
  195. package/src/shade/renderer/geometry/PlaneGeometry.d.ts.map +1 -0
  196. package/src/shade/renderer/geometry/PlaneGeometry.js +22 -0
  197. package/src/shade/renderer/geometry/TorusGeometry.d.ts +18 -0
  198. package/src/shade/renderer/geometry/TorusGeometry.d.ts.map +1 -0
  199. package/src/shade/renderer/geometry/TorusGeometry.js +23 -0
  200. package/src/shade/renderer/geometry/UVSphereGeometry.d.ts +21 -0
  201. package/src/shade/renderer/geometry/UVSphereGeometry.d.ts.map +1 -0
  202. package/src/shade/renderer/geometry/UVSphereGeometry.js +34 -0
  203. package/src/shade/renderer/geometry/primitives/make_capsule_geometry.d.ts +19 -0
  204. package/src/shade/renderer/geometry/primitives/make_capsule_geometry.d.ts.map +1 -0
  205. package/src/shade/renderer/geometry/primitives/make_capsule_geometry.js +205 -0
  206. package/src/shade/renderer/geometry/primitives/make_cone_geometry.d.ts +21 -0
  207. package/src/shade/renderer/geometry/primitives/make_cone_geometry.d.ts.map +1 -0
  208. package/src/shade/renderer/geometry/primitives/make_cone_geometry.js +36 -0
  209. package/src/shade/renderer/geometry/primitives/make_cylinder_geometry.d.ts +1 -1
  210. package/src/shade/renderer/geometry/primitives/make_cylinder_geometry.d.ts.map +1 -1
  211. package/src/shade/renderer/geometry/primitives/make_cylinder_geometry.js +44 -9
  212. package/src/shade/renderer/geometry/primitives/make_uv_sphere_geometry.d.ts +20 -0
  213. package/src/shade/renderer/geometry/primitives/make_uv_sphere_geometry.d.ts.map +1 -0
  214. package/src/shade/renderer/geometry/primitives/make_uv_sphere_geometry.js +190 -0
  215. package/src/shade/renderer/geometry/virtual/runtime/graph_vgeo_expand_instances_to_meshlets.d.ts.map +1 -1
  216. package/src/shade/renderer/geometry/virtual/runtime/graph_vgeo_expand_instances_to_meshlets.js +7 -2
  217. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/graph_prefix_scan_csdldf.d.ts +26 -8
  218. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/graph_prefix_scan_csdldf.d.ts.map +1 -1
  219. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/graph_prefix_scan_csdldf.js +56 -39
  220. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/shader_prefix_scan_csdldf.d.ts +7 -0
  221. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/shader_prefix_scan_csdldf.d.ts.map +1 -1
  222. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/shader_prefix_scan_csdldf.js +46 -4
  223. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/test_prefix_sum.d.ts.map +1 -1
  224. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/test_prefix_sum.js +4 -2
  225. package/src/shade/renderer/gpu_primitive/sort/defs.d.ts +2 -2
  226. package/src/shade/renderer/gpu_primitive/sort/defs.js +79 -79
  227. package/src/shade/renderer/gpu_primitive/sort/graph_radix_sort.d.ts +1 -1
  228. package/src/shade/renderer/gpu_primitive/sort/graph_radix_sort.d.ts.map +1 -1
  229. package/src/shade/renderer/gpu_primitive/sort/graph_radix_sort.js +7 -3
  230. package/src/shade/renderer/particles/GPUParticleSystem.js +1 -1
  231. package/src/shade/renderer/particles/coherence/graph_particle_bucket.d.ts +4 -3
  232. package/src/shade/renderer/particles/coherence/graph_particle_bucket.d.ts.map +1 -1
  233. package/src/shade/renderer/particles/coherence/graph_particle_bucket.js +200 -194
  234. package/src/shade/renderer/particles/graph_particles.d.ts.map +1 -1
  235. package/src/shade/renderer/particles/graph_particles.js +6 -2
  236. package/src/shade/renderer/particles/warmup/graph_particle_warmup.d.ts.map +1 -1
  237. package/src/shade/renderer/particles/warmup/graph_particle_warmup.js +334 -329
  238. package/src/shade/renderer/rasterize/bucket/prepare_meshlet_draw_commands_by_material.d.ts.map +1 -1
  239. package/src/shade/renderer/rasterize/bucket/prepare_meshlet_draw_commands_by_material.js +7 -2
  240. package/src/shade/renderer/rasterize/expand/mesh/graph_expand_meshes_to_meshlets.d.ts.map +1 -1
  241. package/src/shade/renderer/rasterize/expand/mesh/graph_expand_meshes_to_meshlets.js +16 -4
  242. package/src/shade/renderer/texture/COMPRESSED_TEXTURE_PLAN_2026_09_01.md +2444 -2345
  243. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgb.d.ts.map +1 -1
  244. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgb.js +312 -310
  245. package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.d.ts +3 -3
  246. package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.d.ts.map +1 -1
  247. package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.js +383 -375
  248. package/src/shade/renderer/texture/encode/chunk_bc6h_encode_block_mode11.d.ts.map +1 -1
  249. package/src/shade/renderer/texture/encode/chunk_bc6h_encode_block_mode11.js +349 -346
  250. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.d.ts +58 -0
  251. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.d.ts.map +1 -0
  252. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.js +536 -0
  253. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.d.ts +21 -7
  254. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.d.ts.map +1 -1
  255. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.js +291 -327
  256. package/src/shade/renderer/texture/encode/chunk_bc7_pack_mode1.d.ts +25 -0
  257. package/src/shade/renderer/texture/encode/chunk_bc7_pack_mode1.d.ts.map +1 -0
  258. package/src/shade/renderer/texture/encode/chunk_bc7_pack_mode1.js +99 -0
  259. package/src/shade/renderer/texture/encode/chunk_bc7_pack_mode6.d.ts +5 -3
  260. package/src/shade/renderer/texture/encode/chunk_bc7_pack_mode6.d.ts.map +1 -1
  261. package/src/shade/renderer/texture/encode/chunk_bc7_pack_mode6.js +47 -71
  262. package/src/shade/renderer/texture/encode/chunk_bc7_partition_2.d.ts +10 -0
  263. package/src/shade/renderer/texture/encode/chunk_bc7_partition_2.d.ts.map +1 -0
  264. package/src/shade/renderer/texture/encode/chunk_bc7_partition_2.js +50 -0
  265. package/src/shade/renderer/texture/encode/shader_texture_encode_bc7.d.ts +4 -5
  266. package/src/shade/renderer/texture/encode/shader_texture_encode_bc7.d.ts.map +1 -1
  267. package/src/shade/renderer/texture/encode/shader_texture_encode_bc7.js +7 -8
  268. package/src/shade/renderer/water/chunk_water_transport.d.ts.map +1 -1
  269. package/src/shade/renderer/water/chunk_water_transport.js +7 -5
  270. package/src/shade/renderer/water/medium/GPUWaterBodies.d.ts.map +1 -1
  271. package/src/shade/renderer/water/medium/GPUWaterBodies.js +8 -2
  272. package/src/shade/renderer/water/optics/chunk_water_receiver_downwelling.d.ts +3 -2
  273. package/src/shade/renderer/water/optics/chunk_water_receiver_downwelling.d.ts.map +1 -1
  274. package/src/shade/renderer/water/optics/chunk_water_receiver_downwelling.js +3 -2
  275. package/src/shade/renderer/water/shader_water.d.ts.map +1 -1
  276. package/src/shade/renderer/water/shader_water.js +3 -1
  277. package/src/shade/renderer/water/surface/GPUWaterSurface.d.ts.map +1 -1
  278. package/src/shade/renderer/water/surface/GPUWaterSurface.js +3 -1
  279. package/src/shade/renderer/water/surface/graph_water_tessellation.d.ts.map +1 -1
  280. package/src/shade/renderer/water/surface/graph_water_tessellation.js +11 -4
  281. package/src/shade/renderer/water/surface/particles/GPUWaterParticles.d.ts.map +1 -1
  282. package/src/shade/renderer/water/surface/particles/GPUWaterParticles.js +37 -20
  283. package/src/shade/wgsl/validate_wgsl_source.d.ts.map +1 -1
  284. package/src/shade/wgsl/validate_wgsl_source.js +74 -3
  285. package/src/engine/graphics3/register_instance_animation.d.ts +0 -114
  286. package/src/engine/graphics3/register_instance_animation.d.ts.map +0 -1
  287. package/src/engine/graphics3/register_instance_animation.js +0 -201
@@ -517,16 +517,26 @@ export class GPUMeshSkinningContext {
517
517
  * registrations (which would otherwise try to look up the freed
518
518
  * skin's matrix offset on the next bindings upload and assert).
519
519
  *
520
+ * **A mesh bound before its clone exists is forgotten too.** It has no binding record yet, only
521
+ * its skin, and keeping that skin past this call would leave the entity naming a freed id: the
522
+ * next skin to take the id would deform it, and binding it to a skin of its own would be refused
523
+ * as a rebind.
524
+ *
520
525
  * @param {number} skin_id
521
526
  */
522
527
  unbind_all_by_skin(skin_id) {
523
528
  for (let i = this.#bindings.length - 1; i >= 0; i--) {
524
529
  const b = this.#bindings[i];
525
530
  if (b.skin_id === skin_id) {
526
- this.#skin_by_entity.delete(b.entity);
527
531
  this.#drop_binding_at(i);
528
532
  }
529
533
  }
534
+
535
+ for (const [entity, bound] of this.#skin_by_entity) {
536
+ if (bound === skin_id) {
537
+ this.#skin_by_entity.delete(entity);
538
+ }
539
+ }
530
540
  }
531
541
 
532
542
  /**
@@ -11,16 +11,6 @@ export class BoxGeometry extends MeshletGeometry {
11
11
  */
12
12
  constructor(width?: number, height?: number, depth?: number);
13
13
  }
14
- /**
15
- */
16
- export class PlaneGeometry extends MeshletGeometry {
17
- /**
18
- * @param {number} [width]
19
- * @param {number} [height]
20
- * @param {number} [widthSegments]
21
- * @param {number} [heightSegments]
22
- */
23
- constructor(width?: number, height?: number, widthSegments?: number, heightSegments?: number);
24
- }
14
+ export { PlaneGeometry } from "./PlaneGeometry.js";
25
15
  import { MeshletGeometry } from "./MeshletGeometry.js";
26
16
  //# sourceMappingURL=BoxGeometry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BoxGeometry.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/geometry/BoxGeometry.js"],"names":[],"mappings":"AAKA;;;;GAIG;AACH;IACI;;;;OAIG;IACH,oBAJW,MAAM,WACN,MAAM,UACN,MAAM,EAKhB;CACJ;AAED;GACG;AACH;IACI;;;;;OAKG;IACH,oBALW,MAAM,WACN,MAAM,kBACN,MAAM,mBACN,MAAM,EAKhB;CACJ;gCAlC+B,sBAAsB"}
1
+ {"version":3,"file":"BoxGeometry.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/geometry/BoxGeometry.js"],"names":[],"mappings":"AAIA;;;;GAIG;AACH;IACI;;;;OAIG;IACH,oBAJW,MAAM,WACN,MAAM,UACN,MAAM,EAKhB;CACJ;;gCAlB+B,sBAAsB"}
@@ -1,7 +1,6 @@
1
1
  import { meshlet_geometry_build_from_geometry } from "./meshlet_geometry_build_from_geometry.js";
2
2
  import { MeshletGeometry } from "./MeshletGeometry.js";
3
3
  import { make_box_geometry } from "./primitives/make_box_geometry.js";
4
- import { make_plane_geometry } from "./primitives/make_plane_geometry.js";
5
4
 
6
5
  /**
7
6
  * Axis-aligned box, ready to render. Constructs a regular triangulated
@@ -20,17 +19,11 @@ export class BoxGeometry extends MeshletGeometry {
20
19
  }
21
20
  }
22
21
 
23
- /**
24
- */
25
- export class PlaneGeometry extends MeshletGeometry {
22
+ export {
23
+ // The tag goes on the specifier, inside the braces: on the statement, TypeScript never sees it.
26
24
  /**
27
- * @param {number} [width]
28
- * @param {number} [height]
29
- * @param {number} [widthSegments]
30
- * @param {number} [heightSegments]
25
+ * @deprecated `PlaneGeometry` moved to its own module, one class per file like every other
26
+ * primitive. Import {@link PlaneGeometry} from "./PlaneGeometry.js" instead.
31
27
  */
32
- constructor(width = 1, height = 1, widthSegments = 1, heightSegments = 1) {
33
- super();
34
- meshlet_geometry_build_from_geometry(make_plane_geometry(width, height, widthSegments, heightSegments), this);
35
- }
36
- }
28
+ PlaneGeometry
29
+ } from "./PlaneGeometry.js";
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Capsule along the Y axis, ready to render: the same shape a `CapsuleShape3D` of the same radius
3
+ * and height describes. Constructs a regular triangulated `Geometry` and immediately converts it to
4
+ * the meshlet representation the renderer consumes.
5
+ *
6
+ * @see make_capsule_geometry
7
+ */
8
+ export class CapsuleGeometry extends MeshletGeometry {
9
+ /**
10
+ * @param {number} [radius]
11
+ * @param {number} [height] length of the straight section, not counting the caps
12
+ * @param {number} [capSegments] segments from each pole to the equator
13
+ * @param {number} [radialSegments] segments around the axis
14
+ * @param {number} [heightSegments] segments along the straight section
15
+ */
16
+ constructor(radius?: number, height?: number, capSegments?: number, radialSegments?: number, heightSegments?: number);
17
+ }
18
+ import { MeshletGeometry } from "./MeshletGeometry.js";
19
+ //# sourceMappingURL=CapsuleGeometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CapsuleGeometry.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/geometry/CapsuleGeometry.js"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH;IACI;;;;;;OAMG;IACH,qBANW,MAAM,WACN,MAAM,gBACN,MAAM,mBACN,MAAM,mBACN,MAAM,EAKhB;CACJ;gCAtB+B,sBAAsB"}
@@ -0,0 +1,24 @@
1
+ import { meshlet_geometry_build_from_geometry } from "./meshlet_geometry_build_from_geometry.js";
2
+ import { MeshletGeometry } from "./MeshletGeometry.js";
3
+ import { make_capsule_geometry } from "./primitives/make_capsule_geometry.js";
4
+
5
+ /**
6
+ * Capsule along the Y axis, ready to render: the same shape a `CapsuleShape3D` of the same radius
7
+ * and height describes. Constructs a regular triangulated `Geometry` and immediately converts it to
8
+ * the meshlet representation the renderer consumes.
9
+ *
10
+ * @see make_capsule_geometry
11
+ */
12
+ export class CapsuleGeometry extends MeshletGeometry {
13
+ /**
14
+ * @param {number} [radius]
15
+ * @param {number} [height] length of the straight section, not counting the caps
16
+ * @param {number} [capSegments] segments from each pole to the equator
17
+ * @param {number} [radialSegments] segments around the axis
18
+ * @param {number} [heightSegments] segments along the straight section
19
+ */
20
+ constructor(radius = 1, height = 1, capSegments = 4, radialSegments = 8, heightSegments = 1) {
21
+ super();
22
+ meshlet_geometry_build_from_geometry(make_capsule_geometry(radius, height, capSegments, radialSegments, heightSegments), this);
23
+ }
24
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Cone along the Y axis with its apex at the top, ready to render. Constructs a regular triangulated
3
+ * `Geometry` and immediately converts it to the meshlet representation the renderer consumes.
4
+ *
5
+ * @see make_cone_geometry
6
+ */
7
+ export class ConeGeometry extends MeshletGeometry {
8
+ /**
9
+ * @param {number} [radius] radius of the base
10
+ * @param {number} [height]
11
+ * @param {number} [radialSegments] segments around the axis
12
+ * @param {number} [heightSegments] segments along the axis
13
+ * @param {boolean} [openEnded] leave the base off
14
+ * @param {number} [thetaStart]
15
+ * @param {number} [thetaLength] how much of the turn to build, in radians
16
+ */
17
+ constructor(radius?: number, height?: number, radialSegments?: number, heightSegments?: number, openEnded?: boolean, thetaStart?: number, thetaLength?: number);
18
+ }
19
+ import { MeshletGeometry } from "./MeshletGeometry.js";
20
+ //# sourceMappingURL=ConeGeometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConeGeometry.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/geometry/ConeGeometry.js"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH;IACI;;;;;;;;OAQG;IACH,qBARW,MAAM,WACN,MAAM,mBACN,MAAM,mBACN,MAAM,cACN,OAAO,eACP,MAAM,gBACN,MAAM,EAahB;CACJ;gCA/B+B,sBAAsB"}
@@ -0,0 +1,33 @@
1
+ import { meshlet_geometry_build_from_geometry } from "./meshlet_geometry_build_from_geometry.js";
2
+ import { MeshletGeometry } from "./MeshletGeometry.js";
3
+ import { make_cone_geometry } from "./primitives/make_cone_geometry.js";
4
+
5
+ /**
6
+ * Cone along the Y axis with its apex at the top, ready to render. Constructs a regular triangulated
7
+ * `Geometry` and immediately converts it to the meshlet representation the renderer consumes.
8
+ *
9
+ * @see make_cone_geometry
10
+ */
11
+ export class ConeGeometry extends MeshletGeometry {
12
+ /**
13
+ * @param {number} [radius] radius of the base
14
+ * @param {number} [height]
15
+ * @param {number} [radialSegments] segments around the axis
16
+ * @param {number} [heightSegments] segments along the axis
17
+ * @param {boolean} [openEnded] leave the base off
18
+ * @param {number} [thetaStart]
19
+ * @param {number} [thetaLength] how much of the turn to build, in radians
20
+ */
21
+ constructor(
22
+ radius = 1,
23
+ height = 1,
24
+ radialSegments = 8,
25
+ heightSegments = 1,
26
+ openEnded = false,
27
+ thetaStart = 0,
28
+ thetaLength = Math.PI * 2
29
+ ) {
30
+ super();
31
+ meshlet_geometry_build_from_geometry(make_cone_geometry(radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength), this);
32
+ }
33
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Cylinder along the Y axis, ready to render. Constructs a regular triangulated `Geometry` and
3
+ * immediately converts it to the meshlet representation the renderer consumes.
4
+ *
5
+ * @see make_cylinder_geometry
6
+ */
7
+ export class CylinderGeometry extends MeshletGeometry {
8
+ /**
9
+ * @param {number} [radiusTop]
10
+ * @param {number} [radiusBottom]
11
+ * @param {number} [height]
12
+ * @param {number} [radialSegments] segments around the axis
13
+ * @param {number} [heightSegments] segments along the axis
14
+ * @param {boolean} [openEnded] leave the caps off
15
+ * @param {number} [thetaStart]
16
+ * @param {number} [thetaLength] how much of the turn to build, in radians
17
+ */
18
+ constructor(radiusTop?: number, radiusBottom?: number, height?: number, radialSegments?: number, heightSegments?: number, openEnded?: boolean, thetaStart?: number, thetaLength?: number);
19
+ }
20
+ import { MeshletGeometry } from "./MeshletGeometry.js";
21
+ //# sourceMappingURL=CylinderGeometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CylinderGeometry.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/geometry/CylinderGeometry.js"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH;IACI;;;;;;;;;OASG;IACH,wBATW,MAAM,iBACN,MAAM,WACN,MAAM,mBACN,MAAM,mBACN,MAAM,cACN,OAAO,eACP,MAAM,gBACN,MAAM,EAchB;CACJ;gCAjC+B,sBAAsB"}
@@ -0,0 +1,35 @@
1
+ import { meshlet_geometry_build_from_geometry } from "./meshlet_geometry_build_from_geometry.js";
2
+ import { MeshletGeometry } from "./MeshletGeometry.js";
3
+ import { make_cylinder_geometry } from "./primitives/make_cylinder_geometry.js";
4
+
5
+ /**
6
+ * Cylinder along the Y axis, ready to render. Constructs a regular triangulated `Geometry` and
7
+ * immediately converts it to the meshlet representation the renderer consumes.
8
+ *
9
+ * @see make_cylinder_geometry
10
+ */
11
+ export class CylinderGeometry extends MeshletGeometry {
12
+ /**
13
+ * @param {number} [radiusTop]
14
+ * @param {number} [radiusBottom]
15
+ * @param {number} [height]
16
+ * @param {number} [radialSegments] segments around the axis
17
+ * @param {number} [heightSegments] segments along the axis
18
+ * @param {boolean} [openEnded] leave the caps off
19
+ * @param {number} [thetaStart]
20
+ * @param {number} [thetaLength] how much of the turn to build, in radians
21
+ */
22
+ constructor(
23
+ radiusTop = 1,
24
+ radiusBottom = 1,
25
+ height = 1,
26
+ radialSegments = 8,
27
+ heightSegments = 1,
28
+ openEnded = false,
29
+ thetaStart = 0,
30
+ thetaLength = Math.PI * 2
31
+ ) {
32
+ super();
33
+ meshlet_geometry_build_from_geometry(make_cylinder_geometry(radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength), this);
34
+ }
35
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Plane in the XY plane facing +Z, ready to render. Constructs a regular triangulated `Geometry`
3
+ * and immediately converts it to the meshlet representation the renderer consumes.
4
+ *
5
+ * @see make_plane_geometry
6
+ */
7
+ export class PlaneGeometry extends MeshletGeometry {
8
+ /**
9
+ * @param {number} [width]
10
+ * @param {number} [height]
11
+ * @param {number} [widthSegments]
12
+ * @param {number} [heightSegments]
13
+ */
14
+ constructor(width?: number, height?: number, widthSegments?: number, heightSegments?: number);
15
+ }
16
+ import { MeshletGeometry } from "./MeshletGeometry.js";
17
+ //# sourceMappingURL=PlaneGeometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlaneGeometry.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/geometry/PlaneGeometry.js"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH;IACI;;;;;OAKG;IACH,oBALW,MAAM,WACN,MAAM,kBACN,MAAM,mBACN,MAAM,EAKhB;CACJ;gCApB+B,sBAAsB"}
@@ -0,0 +1,22 @@
1
+ import { meshlet_geometry_build_from_geometry } from "./meshlet_geometry_build_from_geometry.js";
2
+ import { MeshletGeometry } from "./MeshletGeometry.js";
3
+ import { make_plane_geometry } from "./primitives/make_plane_geometry.js";
4
+
5
+ /**
6
+ * Plane in the XY plane facing +Z, ready to render. Constructs a regular triangulated `Geometry`
7
+ * and immediately converts it to the meshlet representation the renderer consumes.
8
+ *
9
+ * @see make_plane_geometry
10
+ */
11
+ export class PlaneGeometry extends MeshletGeometry {
12
+ /**
13
+ * @param {number} [width]
14
+ * @param {number} [height]
15
+ * @param {number} [widthSegments]
16
+ * @param {number} [heightSegments]
17
+ */
18
+ constructor(width = 1, height = 1, widthSegments = 1, heightSegments = 1) {
19
+ super();
20
+ meshlet_geometry_build_from_geometry(make_plane_geometry(width, height, widthSegments, heightSegments), this);
21
+ }
22
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Torus in the XY plane with its hole along Z, ready to render. Constructs a regular triangulated
3
+ * `Geometry` and immediately converts it to the meshlet representation the renderer consumes.
4
+ *
5
+ * @see make_torus_geometry
6
+ */
7
+ export class TorusGeometry extends MeshletGeometry {
8
+ /**
9
+ * @param {number} [radius] distance from the centre of the hole to the centre of the tube
10
+ * @param {number} [tube] radius of the tube itself
11
+ * @param {number} [radialSegments] segments around the tube
12
+ * @param {number} [tubularSegments] segments around the ring
13
+ * @param {number} [arc] how much of the ring to build, in radians
14
+ */
15
+ constructor(radius?: number, tube?: number, radialSegments?: number, tubularSegments?: number, arc?: number);
16
+ }
17
+ import { MeshletGeometry } from "./MeshletGeometry.js";
18
+ //# sourceMappingURL=TorusGeometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TorusGeometry.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/geometry/TorusGeometry.js"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH;IACI;;;;;;OAMG;IACH,qBANW,MAAM,SACN,MAAM,mBACN,MAAM,oBACN,MAAM,QACN,MAAM,EAKhB;CACJ;gCArB+B,sBAAsB"}
@@ -0,0 +1,23 @@
1
+ import { meshlet_geometry_build_from_geometry } from "./meshlet_geometry_build_from_geometry.js";
2
+ import { MeshletGeometry } from "./MeshletGeometry.js";
3
+ import { make_torus_geometry } from "./primitives/make_torus_geometry.js";
4
+
5
+ /**
6
+ * Torus in the XY plane with its hole along Z, ready to render. Constructs a regular triangulated
7
+ * `Geometry` and immediately converts it to the meshlet representation the renderer consumes.
8
+ *
9
+ * @see make_torus_geometry
10
+ */
11
+ export class TorusGeometry extends MeshletGeometry {
12
+ /**
13
+ * @param {number} [radius] distance from the centre of the hole to the centre of the tube
14
+ * @param {number} [tube] radius of the tube itself
15
+ * @param {number} [radialSegments] segments around the tube
16
+ * @param {number} [tubularSegments] segments around the ring
17
+ * @param {number} [arc] how much of the ring to build, in radians
18
+ */
19
+ constructor(radius = 1, tube = 0.4, radialSegments = 8, tubularSegments = 6, arc = Math.PI * 2) {
20
+ super();
21
+ meshlet_geometry_build_from_geometry(make_torus_geometry(radius, tube, radialSegments, tubularSegments, arc), this);
22
+ }
23
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Sphere of rings and meridians with its poles on the Y axis, ready to render. Constructs a regular
3
+ * triangulated `Geometry` and immediately converts it to the meshlet representation the renderer
4
+ * consumes.
5
+ *
6
+ * @see make_uv_sphere_geometry
7
+ */
8
+ export class UVSphereGeometry extends MeshletGeometry {
9
+ /**
10
+ * @param {number} [radius]
11
+ * @param {number} [widthSegments] segments around the axis, at least 3
12
+ * @param {number} [heightSegments] segments from pole to pole, at least 2
13
+ * @param {number} [phiStart]
14
+ * @param {number} [phiLength] how much of the turn about the axis to build, in radians
15
+ * @param {number} [thetaStart] where to start, in radians down from the north pole
16
+ * @param {number} [thetaLength] how far toward the south pole to build, in radians
17
+ */
18
+ constructor(radius?: number, widthSegments?: number, heightSegments?: number, phiStart?: number, phiLength?: number, thetaStart?: number, thetaLength?: number);
19
+ }
20
+ import { MeshletGeometry } from "./MeshletGeometry.js";
21
+ //# sourceMappingURL=UVSphereGeometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UVSphereGeometry.d.ts","sourceRoot":"","sources":["../../../../../src/shade/renderer/geometry/UVSphereGeometry.js"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH;IACI;;;;;;;;OAQG;IACH,qBARW,MAAM,kBACN,MAAM,mBACN,MAAM,aACN,MAAM,cACN,MAAM,eACN,MAAM,gBACN,MAAM,EAahB;CACJ;gCAhC+B,sBAAsB"}
@@ -0,0 +1,34 @@
1
+ import { meshlet_geometry_build_from_geometry } from "./meshlet_geometry_build_from_geometry.js";
2
+ import { MeshletGeometry } from "./MeshletGeometry.js";
3
+ import { make_uv_sphere_geometry } from "./primitives/make_uv_sphere_geometry.js";
4
+
5
+ /**
6
+ * Sphere of rings and meridians with its poles on the Y axis, ready to render. Constructs a regular
7
+ * triangulated `Geometry` and immediately converts it to the meshlet representation the renderer
8
+ * consumes.
9
+ *
10
+ * @see make_uv_sphere_geometry
11
+ */
12
+ export class UVSphereGeometry extends MeshletGeometry {
13
+ /**
14
+ * @param {number} [radius]
15
+ * @param {number} [widthSegments] segments around the axis, at least 3
16
+ * @param {number} [heightSegments] segments from pole to pole, at least 2
17
+ * @param {number} [phiStart]
18
+ * @param {number} [phiLength] how much of the turn about the axis to build, in radians
19
+ * @param {number} [thetaStart] where to start, in radians down from the north pole
20
+ * @param {number} [thetaLength] how far toward the south pole to build, in radians
21
+ */
22
+ constructor(
23
+ radius = 1,
24
+ widthSegments = 32,
25
+ heightSegments = 16,
26
+ phiStart = 0,
27
+ phiLength = Math.PI * 2,
28
+ thetaStart = 0,
29
+ thetaLength = Math.PI
30
+ ) {
31
+ super();
32
+ meshlet_geometry_build_from_geometry(make_uv_sphere_geometry(radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength), this);
33
+ }
34
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * A capsule along the Y axis, centred on the origin: a cylinder of length `height` closed by two
3
+ * hemispheres of `radius`, so the whole body spans `height + 2 * radius`. That is the same shape
4
+ * `CapsuleShape3D` describes for the same two numbers, so a collider and its mesh agree.
5
+ *
6
+ * The texture coordinates wrap `u` once around the axis and run `v` from the south pole (0) to the
7
+ * north pole (1) by arc length along the profile, so a texture is not stretched over the caps
8
+ * relative to the straight section.
9
+ *
10
+ * @param {number} [radius]
11
+ * @param {number} [height] length of the straight section, not counting the caps
12
+ * @param {number} [capSegments] segments from each pole to the equator, at least 1
13
+ * @param {number} [radialSegments] segments around the axis, at least 3
14
+ * @param {number} [heightSegments] segments along the straight section, at least 1 unless `height` is zero
15
+ * @returns {Geometry}
16
+ */
17
+ export function make_capsule_geometry(radius?: number, height?: number, capSegments?: number, radialSegments?: number, heightSegments?: number): Geometry;
18
+ import { Geometry } from "../Geometry.js";
19
+ //# sourceMappingURL=make_capsule_geometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"make_capsule_geometry.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/geometry/primitives/make_capsule_geometry.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AACH,+CAPW,MAAM,WACN,MAAM,gBACN,MAAM,mBACN,MAAM,mBACN,MAAM,GACJ,QAAQ,CA0LpB;yBA3MwB,gBAAgB"}
@@ -0,0 +1,205 @@
1
+ import { Attribute } from "../Attribute.js";
2
+ import { Geometry } from "../Geometry.js";
3
+ import { StandardAttributes } from "../StandardAttributes.js";
4
+
5
+ /**
6
+ * A capsule along the Y axis, centred on the origin: a cylinder of length `height` closed by two
7
+ * hemispheres of `radius`, so the whole body spans `height + 2 * radius`. That is the same shape
8
+ * `CapsuleShape3D` describes for the same two numbers, so a collider and its mesh agree.
9
+ *
10
+ * The texture coordinates wrap `u` once around the axis and run `v` from the south pole (0) to the
11
+ * north pole (1) by arc length along the profile, so a texture is not stretched over the caps
12
+ * relative to the straight section.
13
+ *
14
+ * @param {number} [radius]
15
+ * @param {number} [height] length of the straight section, not counting the caps
16
+ * @param {number} [capSegments] segments from each pole to the equator, at least 1
17
+ * @param {number} [radialSegments] segments around the axis, at least 3
18
+ * @param {number} [heightSegments] segments along the straight section, at least 1 unless `height` is zero
19
+ * @returns {Geometry}
20
+ */
21
+ export function make_capsule_geometry(radius = 1, height = 1, capSegments = 4, radialSegments = 8, heightSegments = 1) {
22
+
23
+ /*
24
+ A port of three's `CapsuleGeometry` onto `Geometry`: the same parameterisation, the same
25
+ arc-length texture coordinates and the same winding, writing meep attributes instead of three
26
+ ones. It departs at the poles, see below.
27
+
28
+ Derived from three.js (https://github.com/mrdoob/three.js), Copyright (c) 2010-2024 three.js authors, MIT licence.
29
+ */
30
+
31
+ const geo = new Geometry();
32
+
33
+ geo.name = "Capsule";
34
+
35
+ // segments
36
+
37
+ height = Math.max(0, height);
38
+ capSegments = Math.max(1, Math.floor(capSegments));
39
+ radialSegments = Math.max(3, Math.floor(radialSegments));
40
+
41
+ // a straight section of no length would be bands of no area, so then there is none and the two
42
+ // caps meet at a single equator, which is a sphere
43
+ heightSegments = height > 0 ? Math.max(1, Math.floor(heightSegments)) : 0;
44
+
45
+ // buffers
46
+
47
+ const indices = [];
48
+ const vertices = [];
49
+ const normals = [];
50
+ const uvs = [];
51
+
52
+ // helper variables
53
+
54
+ const halfHeight = height / 2;
55
+ const capArcLength = (Math.PI / 2) * radius;
56
+ const totalArcLength = 2 * capArcLength + height;
57
+
58
+ // rows run from the south pole up to the north pole; the two equators belong to the straight
59
+ // section, so both of its ends sit exactly at +-halfHeight with a level normal
60
+ const lastRow = capSegments * 2 + heightSegments;
61
+
62
+ let index = 0;
63
+ const grid = [];
64
+
65
+ // generate vertices, normals and uvs
66
+
67
+ for (let iy = 0; iy <= lastRow; iy++) {
68
+
69
+ // the profile: the outward normal in the (radial, Y) half plane, the row's height and its
70
+ // arc length from the south pole
71
+
72
+ let normalRadial;
73
+ let normalY;
74
+ let profileY;
75
+ let arcLength;
76
+
77
+ if (iy < capSegments) {
78
+
79
+ // southern cap, the angle measured up from the south pole
80
+
81
+ const angle = (iy / capSegments) * (Math.PI / 2);
82
+
83
+ normalRadial = Math.sin(angle);
84
+ normalY = -Math.cos(angle);
85
+ profileY = -halfHeight + radius * normalY;
86
+ arcLength = angle * radius;
87
+
88
+ } else if (iy <= capSegments + heightSegments) {
89
+
90
+ // straight section
91
+
92
+ const t = heightSegments > 0 ? (iy - capSegments) / heightSegments : 0;
93
+
94
+ normalRadial = 1;
95
+ normalY = 0;
96
+ profileY = -halfHeight + t * height;
97
+ arcLength = capArcLength + t * height;
98
+
99
+ } else {
100
+
101
+ // northern cap, the angle measured down from the north pole, so that the pole itself is
102
+ // an angle of exactly zero rather than a `Math.cos(Math.PI / 2)` that is not
103
+
104
+ const angle = ((lastRow - iy) / capSegments) * (Math.PI / 2);
105
+
106
+ normalRadial = Math.sin(angle);
107
+ normalY = Math.cos(angle);
108
+ profileY = halfHeight + radius * normalY;
109
+ arcLength = totalArcLength - angle * radius;
110
+
111
+ }
112
+
113
+ const profileRadius = radius * normalRadial;
114
+
115
+ const v = arcLength / totalArcLength;
116
+
117
+ // A ring at a pole is a single point. Three's grid still gives it a vertex per meridian,
118
+ // which puts two corners of every polar triangle on the same point. Here a pole holds one
119
+ // vertex per segment, turned to the middle of that segment, and each segment draws just the
120
+ // one triangle that has area; see `make_uv_sphere_geometry`, which does the same.
121
+ const pole = iy === 0 || iy === lastRow;
122
+
123
+ const rowVertexCount = pole ? radialSegments : radialSegments + 1;
124
+ const uOffset = pole ? 0.5 : 0;
125
+
126
+ const verticesRow = [];
127
+
128
+ for (let ix = 0; ix < rowVertexCount; ix++) {
129
+
130
+ const u = (ix + uOffset) / radialSegments;
131
+
132
+ const theta = u * Math.PI * 2;
133
+
134
+ const sinTheta = Math.sin(theta);
135
+ const cosTheta = Math.cos(theta);
136
+
137
+ // vertex
138
+
139
+ vertices.push(-profileRadius * cosTheta, profileY, profileRadius * sinTheta);
140
+
141
+ // normal, from the profile's angles rather than by normalising, so it is unit length by
142
+ // construction and stays defined at radius zero
143
+
144
+ normals.push(-normalRadial * cosTheta, normalY, normalRadial * sinTheta);
145
+
146
+ // uv
147
+
148
+ uvs.push(u, v);
149
+
150
+ verticesRow.push(index++);
151
+
152
+ }
153
+
154
+ grid.push(verticesRow);
155
+
156
+ }
157
+
158
+ // indices
159
+
160
+ for (let iy = 1; iy <= lastRow; iy++) {
161
+
162
+ const lower = grid[iy - 1];
163
+ const upper = grid[iy];
164
+
165
+ for (let ix = 0; ix < radialSegments; ix++) {
166
+
167
+ if (iy === 1) {
168
+
169
+ // the segment's south pole vertex stands in for both lower corners
170
+
171
+ indices.push(lower[ix], upper[ix + 1], upper[ix]);
172
+
173
+ } else if (iy === lastRow) {
174
+
175
+ // the segment's north pole vertex stands in for both upper corners
176
+
177
+ indices.push(lower[ix], lower[ix + 1], upper[ix]);
178
+
179
+ } else {
180
+
181
+ const i1 = lower[ix];
182
+ const i2 = lower[ix + 1];
183
+ const i3 = upper[ix];
184
+ const i4 = upper[ix + 1];
185
+
186
+ // faces
187
+
188
+ indices.push(i1, i2, i3);
189
+ indices.push(i2, i4, i3);
190
+
191
+ }
192
+
193
+ }
194
+
195
+ }
196
+
197
+ // build geometry
198
+
199
+ geo.index = Attribute.from(new Uint32Array(indices), 1, 'index');
200
+ geo.addAttribute(Attribute.from(new Float32Array(vertices), 3, StandardAttributes.Position));
201
+ geo.addAttribute(Attribute.from(new Float32Array(normals), 3, StandardAttributes.Normal));
202
+ geo.addAttribute(Attribute.from(new Float32Array(uvs), 2, StandardAttributes.TextureCoordinates0));
203
+
204
+ return geo;
205
+ }