@woosh/meep-engine 3.42.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 (345) hide show
  1. package/editor/prototypeEditorShell.d.ts.map +1 -1
  2. package/editor/prototypeEditorShell.js +4 -2
  3. package/package.json +91 -96
  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/playground/vgeo_runtime/README.md +5 -4
  177. package/src/shade/renderer/Renderer.d.ts.map +1 -1
  178. package/src/shade/renderer/Renderer.js +6 -5
  179. package/src/shade/renderer/animation/GPUAnimationManager.d.ts +45 -14
  180. package/src/shade/renderer/animation/GPUAnimationManager.d.ts.map +1 -1
  181. package/src/shade/renderer/animation/GPUAnimationManager.js +316 -64
  182. package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.d.ts +5 -0
  183. package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.d.ts.map +1 -1
  184. package/src/shade/renderer/animation/skinning/GPUMeshSkinningContext.js +11 -1
  185. package/src/shade/renderer/atmosphere/GPUSky.d.ts +12 -0
  186. package/src/shade/renderer/atmosphere/GPUSky.d.ts.map +1 -1
  187. package/src/shade/renderer/atmosphere/GPUSky.js +162 -147
  188. package/src/shade/renderer/geometry/BoxGeometry.d.ts +1 -11
  189. package/src/shade/renderer/geometry/BoxGeometry.d.ts.map +1 -1
  190. package/src/shade/renderer/geometry/BoxGeometry.js +6 -13
  191. package/src/shade/renderer/geometry/CapsuleGeometry.d.ts +19 -0
  192. package/src/shade/renderer/geometry/CapsuleGeometry.d.ts.map +1 -0
  193. package/src/shade/renderer/geometry/CapsuleGeometry.js +24 -0
  194. package/src/shade/renderer/geometry/ConeGeometry.d.ts +20 -0
  195. package/src/shade/renderer/geometry/ConeGeometry.d.ts.map +1 -0
  196. package/src/shade/renderer/geometry/ConeGeometry.js +33 -0
  197. package/src/shade/renderer/geometry/CylinderGeometry.d.ts +21 -0
  198. package/src/shade/renderer/geometry/CylinderGeometry.d.ts.map +1 -0
  199. package/src/shade/renderer/geometry/CylinderGeometry.js +35 -0
  200. package/src/shade/renderer/geometry/PlaneGeometry.d.ts +17 -0
  201. package/src/shade/renderer/geometry/PlaneGeometry.d.ts.map +1 -0
  202. package/src/shade/renderer/geometry/PlaneGeometry.js +22 -0
  203. package/src/shade/renderer/geometry/TorusGeometry.d.ts +18 -0
  204. package/src/shade/renderer/geometry/TorusGeometry.d.ts.map +1 -0
  205. package/src/shade/renderer/geometry/TorusGeometry.js +23 -0
  206. package/src/shade/renderer/geometry/UVSphereGeometry.d.ts +21 -0
  207. package/src/shade/renderer/geometry/UVSphereGeometry.d.ts.map +1 -0
  208. package/src/shade/renderer/geometry/UVSphereGeometry.js +34 -0
  209. package/src/shade/renderer/geometry/primitives/make_capsule_geometry.d.ts +19 -0
  210. package/src/shade/renderer/geometry/primitives/make_capsule_geometry.d.ts.map +1 -0
  211. package/src/shade/renderer/geometry/primitives/make_capsule_geometry.js +205 -0
  212. package/src/shade/renderer/geometry/primitives/make_cone_geometry.d.ts +21 -0
  213. package/src/shade/renderer/geometry/primitives/make_cone_geometry.d.ts.map +1 -0
  214. package/src/shade/renderer/geometry/primitives/make_cone_geometry.js +36 -0
  215. package/src/shade/renderer/geometry/primitives/make_cylinder_geometry.d.ts +1 -1
  216. package/src/shade/renderer/geometry/primitives/make_cylinder_geometry.d.ts.map +1 -1
  217. package/src/shade/renderer/geometry/primitives/make_cylinder_geometry.js +44 -9
  218. package/src/shade/renderer/geometry/primitives/make_uv_sphere_geometry.d.ts +20 -0
  219. package/src/shade/renderer/geometry/primitives/make_uv_sphere_geometry.d.ts.map +1 -0
  220. package/src/shade/renderer/geometry/primitives/make_uv_sphere_geometry.js +190 -0
  221. package/src/shade/renderer/geometry/virtual/runtime/graph_vgeo_expand_instances_to_meshlets.d.ts.map +1 -1
  222. package/src/shade/renderer/geometry/virtual/runtime/graph_vgeo_expand_instances_to_meshlets.js +7 -2
  223. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/graph_prefix_scan_csdldf.d.ts +26 -8
  224. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/graph_prefix_scan_csdldf.d.ts.map +1 -1
  225. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/graph_prefix_scan_csdldf.js +56 -39
  226. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/shader_prefix_scan_csdldf.d.ts +7 -0
  227. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/shader_prefix_scan_csdldf.d.ts.map +1 -1
  228. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/shader_prefix_scan_csdldf.js +46 -4
  229. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/test_prefix_sum.d.ts.map +1 -1
  230. package/src/shade/renderer/gpu_primitive/prefix_sum/v1/test_prefix_sum.js +4 -2
  231. package/src/shade/renderer/gpu_primitive/sort/defs.d.ts +2 -2
  232. package/src/shade/renderer/gpu_primitive/sort/defs.js +79 -79
  233. package/src/shade/renderer/gpu_primitive/sort/graph_radix_sort.d.ts +1 -1
  234. package/src/shade/renderer/gpu_primitive/sort/graph_radix_sort.d.ts.map +1 -1
  235. package/src/shade/renderer/gpu_primitive/sort/graph_radix_sort.js +7 -3
  236. package/src/shade/renderer/lightmap/bake/shader_lightmap_denoise_sh.d.ts.map +1 -1
  237. package/src/shade/renderer/lightmap/bake/shader_lightmap_denoise_sh.js +10 -3
  238. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
  239. package/src/shade/renderer/particles/DESIGN.md +13 -9
  240. package/src/shade/renderer/particles/GPUParticleSystem.js +1 -1
  241. package/src/shade/renderer/particles/coherence/graph_particle_bucket.d.ts +4 -3
  242. package/src/shade/renderer/particles/coherence/graph_particle_bucket.d.ts.map +1 -1
  243. package/src/shade/renderer/particles/coherence/graph_particle_bucket.js +200 -194
  244. package/src/shade/renderer/particles/graph_particles.d.ts.map +1 -1
  245. package/src/shade/renderer/particles/graph_particles.js +6 -2
  246. package/src/shade/renderer/particles/shaders/chunk_particle_lighting.d.ts +1 -1
  247. package/src/shade/renderer/particles/shaders/chunk_particle_lighting.js +1 -1
  248. package/src/shade/renderer/particles/warmup/graph_particle_warmup.d.ts.map +1 -1
  249. package/src/shade/renderer/particles/warmup/graph_particle_warmup.js +334 -329
  250. package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
  251. package/src/shade/renderer/rasterize/bucket/prepare_meshlet_draw_commands_by_material.d.ts.map +1 -1
  252. package/src/shade/renderer/rasterize/bucket/prepare_meshlet_draw_commands_by_material.js +7 -2
  253. package/src/shade/renderer/rasterize/expand/mesh/graph_expand_meshes_to_meshlets.d.ts.map +1 -1
  254. package/src/shade/renderer/rasterize/expand/mesh/graph_expand_meshes_to_meshlets.js +16 -4
  255. package/src/shade/renderer/rasterize/native/avboit/AVBOITSideChannel.d.ts +3 -2
  256. package/src/shade/renderer/rasterize/native/avboit/AVBOITSideChannel.d.ts.map +1 -1
  257. package/src/shade/renderer/rasterize/native/avboit/AVBOITSideChannel.js +3 -2
  258. package/src/shade/renderer/scene/GPUSceneContext.d.ts +9 -1
  259. package/src/shade/renderer/scene/GPUSceneContext.d.ts.map +1 -1
  260. package/src/shade/renderer/scene/GPUSceneContext.js +23 -1
  261. package/src/shade/renderer/texture/COMPRESSED_TEXTURE_PLAN_2026_09_01.md +2444 -2345
  262. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgb.d.ts.map +1 -1
  263. package/src/shade/renderer/texture/encode/chunk_astc_encode_block_4x4_rgb.js +312 -310
  264. package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.d.ts +3 -3
  265. package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.d.ts.map +1 -1
  266. package/src/shade/renderer/texture/encode/chunk_bc1_encode_block.js +383 -375
  267. package/src/shade/renderer/texture/encode/chunk_bc6h_encode_block_mode11.d.ts.map +1 -1
  268. package/src/shade/renderer/texture/encode/chunk_bc6h_encode_block_mode11.js +349 -346
  269. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.d.ts +58 -0
  270. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.d.ts.map +1 -0
  271. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block.js +536 -0
  272. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.d.ts +21 -7
  273. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.d.ts.map +1 -1
  274. package/src/shade/renderer/texture/encode/chunk_bc7_encode_block_mode6.js +291 -327
  275. package/src/shade/renderer/texture/encode/chunk_bc7_pack_mode1.d.ts +25 -0
  276. package/src/shade/renderer/texture/encode/chunk_bc7_pack_mode1.d.ts.map +1 -0
  277. package/src/shade/renderer/texture/encode/chunk_bc7_pack_mode1.js +99 -0
  278. package/src/shade/renderer/texture/encode/chunk_bc7_pack_mode6.d.ts +5 -3
  279. package/src/shade/renderer/texture/encode/chunk_bc7_pack_mode6.d.ts.map +1 -1
  280. package/src/shade/renderer/texture/encode/chunk_bc7_pack_mode6.js +47 -71
  281. package/src/shade/renderer/texture/encode/chunk_bc7_partition_2.d.ts +10 -0
  282. package/src/shade/renderer/texture/encode/chunk_bc7_partition_2.d.ts.map +1 -0
  283. package/src/shade/renderer/texture/encode/chunk_bc7_partition_2.js +50 -0
  284. package/src/shade/renderer/texture/encode/shader_texture_encode_bc7.d.ts +4 -5
  285. package/src/shade/renderer/texture/encode/shader_texture_encode_bc7.d.ts.map +1 -1
  286. package/src/shade/renderer/texture/encode/shader_texture_encode_bc7.js +7 -8
  287. package/src/shade/renderer/volumetrics/GPUViewVolumetrics.d.ts +4 -1
  288. package/src/shade/renderer/volumetrics/GPUViewVolumetrics.d.ts.map +1 -1
  289. package/src/shade/renderer/volumetrics/GPUViewVolumetrics.js +74 -3
  290. package/src/shade/renderer/volumetrics/NOTES.md +1023 -957
  291. package/src/shade/renderer/volumetrics/chunk_volumetrics_irradiance_sh.d.ts +5 -4
  292. package/src/shade/renderer/volumetrics/chunk_volumetrics_irradiance_sh.d.ts.map +1 -1
  293. package/src/shade/renderer/volumetrics/chunk_volumetrics_irradiance_sh.js +5 -4
  294. package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_gi.d.ts +1 -1
  295. package/src/shade/renderer/volumetrics/gi/chunk_volumetrics_gi.js +1 -1
  296. package/src/shade/renderer/volumetrics/gi/graph_build_froxel_gi.d.ts +1 -1
  297. package/src/shade/renderer/volumetrics/gi/graph_build_froxel_gi.js +1 -1
  298. package/src/shade/renderer/volumetrics/graph_build_froxel_irradiance.d.ts +41 -0
  299. package/src/shade/renderer/volumetrics/graph_build_froxel_irradiance.d.ts.map +1 -0
  300. package/src/shade/renderer/volumetrics/graph_build_froxel_irradiance.js +112 -0
  301. package/src/shade/renderer/volumetrics/graph_build_volumetrics.d.ts +9 -23
  302. package/src/shade/renderer/volumetrics/graph_build_volumetrics.d.ts.map +1 -1
  303. package/src/shade/renderer/volumetrics/graph_build_volumetrics.js +18 -126
  304. package/src/shade/renderer/volumetrics/shader_volumetrics_build_irradiance.d.ts +22 -0
  305. package/src/shade/renderer/volumetrics/shader_volumetrics_build_irradiance.d.ts.map +1 -0
  306. package/src/shade/renderer/volumetrics/shader_volumetrics_build_irradiance.js +228 -0
  307. package/src/shade/renderer/volumetrics/shader_volumetrics_build_lighting.d.ts.map +1 -1
  308. package/src/shade/renderer/volumetrics/shader_volumetrics_build_lighting.js +0 -53
  309. package/src/shade/renderer/water/chunk_water_transport.d.ts.map +1 -1
  310. package/src/shade/renderer/water/chunk_water_transport.js +7 -5
  311. package/src/shade/renderer/water/medium/GPUWaterBodies.d.ts.map +1 -1
  312. package/src/shade/renderer/water/medium/GPUWaterBodies.js +8 -2
  313. package/src/shade/renderer/water/optics/chunk_water_receiver_downwelling.d.ts +3 -2
  314. package/src/shade/renderer/water/optics/chunk_water_receiver_downwelling.d.ts.map +1 -1
  315. package/src/shade/renderer/water/optics/chunk_water_receiver_downwelling.js +3 -2
  316. package/src/shade/renderer/water/shader_water.d.ts.map +1 -1
  317. package/src/shade/renderer/water/shader_water.js +3 -1
  318. package/src/shade/renderer/water/surface/GPUWaterSurface.d.ts.map +1 -1
  319. package/src/shade/renderer/water/surface/GPUWaterSurface.js +3 -1
  320. package/src/shade/renderer/water/surface/chunk_water_surface_sample.d.ts +4 -3
  321. package/src/shade/renderer/water/surface/chunk_water_surface_sample.d.ts.map +1 -1
  322. package/src/shade/renderer/water/surface/chunk_water_surface_sample.js +17 -7
  323. package/src/shade/renderer/water/surface/graph_water_tessellation.d.ts.map +1 -1
  324. package/src/shade/renderer/water/surface/graph_water_tessellation.js +11 -4
  325. package/src/shade/renderer/water/surface/particles/GPUWaterParticles.d.ts.map +1 -1
  326. package/src/shade/renderer/water/surface/particles/GPUWaterParticles.js +93 -30
  327. package/src/shade/renderer/water/surface/particles/WATER_PARTICLE_STRUCT.d.ts.map +1 -1
  328. package/src/shade/renderer/water/surface/particles/WATER_PARTICLE_STRUCT.js +13 -5
  329. package/src/shade/renderer/water/surface/particles/chunk_water_particle.d.ts +29 -8
  330. package/src/shade/renderer/water/surface/particles/chunk_water_particle.d.ts.map +1 -1
  331. package/src/shade/renderer/water/surface/particles/chunk_water_particle.js +155 -30
  332. package/src/shade/renderer/water/surface/particles/chunk_water_particle_step.d.ts +6 -1
  333. package/src/shade/renderer/water/surface/particles/chunk_water_particle_step.d.ts.map +1 -1
  334. package/src/shade/renderer/water/surface/particles/chunk_water_particle_step.js +157 -39
  335. package/src/shade/renderer/water/surface/particles/shader_water_particles.d.ts +91 -21
  336. package/src/shade/renderer/water/surface/particles/shader_water_particles.d.ts.map +1 -1
  337. package/src/shade/renderer/water/surface/particles/shader_water_particles.js +442 -70
  338. package/src/shade/wgsl/emulator/WGSLJavaScriptCompiler.js +11 -3
  339. package/src/shade/wgsl/emulator/WGSLLanguageCore.d.ts.map +1 -1
  340. package/src/shade/wgsl/emulator/WGSLLanguageCore.js +3 -0
  341. package/src/shade/wgsl/validate_wgsl_source.d.ts.map +1 -1
  342. package/src/shade/wgsl/validate_wgsl_source.js +74 -3
  343. package/src/engine/graphics3/register_instance_animation.d.ts +0 -114
  344. package/src/engine/graphics3/register_instance_animation.d.ts.map +0 -1
  345. package/src/engine/graphics3/register_instance_animation.js +0 -201
@@ -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
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @typedef {import("../Geometry.js").Geometry} Geometry
3
+ */
4
+ /**
5
+ * The axis runs along Y with the apex at the top, and the body is centred on the origin.
6
+ *
7
+ * A cone is a cylinder whose top radius is zero, exactly as three's `ConeGeometry` is, so this is
8
+ * {@link make_cylinder_geometry} under its own name; the apex handling lives there.
9
+ *
10
+ * @param {number} [radius] radius of the base
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 base off, which makes the surface a hollow shell rather than a solid
15
+ * @param {number} [thetaStart]
16
+ * @param {number} [thetaLength] how much of the turn to build, in radians
17
+ * @returns {Geometry}
18
+ */
19
+ export function make_cone_geometry(radius?: number, height?: number, radialSegments?: number, heightSegments?: number, openEnded?: boolean, thetaStart?: number, thetaLength?: number): Geometry;
20
+ export type Geometry = import("../Geometry.js").Geometry;
21
+ //# sourceMappingURL=make_cone_geometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"make_cone_geometry.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/geometry/primitives/make_cone_geometry.js"],"names":[],"mappings":"AAEA;;GAEG;AAEH;;;;;;;;;;;;;;GAcG;AACH,4CATW,MAAM,WACN,MAAM,mBACN,MAAM,mBACN,MAAM,cACN,OAAO,eACP,MAAM,gBACN,MAAM,GACJ,QAAQ,CAgBpB;uBAhCY,OAAO,gBAAgB,EAAE,QAAQ"}
@@ -0,0 +1,36 @@
1
+ import { make_cylinder_geometry } from "./make_cylinder_geometry.js";
2
+
3
+ /**
4
+ * @typedef {import("../Geometry.js").Geometry} Geometry
5
+ */
6
+
7
+ /**
8
+ * The axis runs along Y with the apex at the top, and the body is centred on the origin.
9
+ *
10
+ * A cone is a cylinder whose top radius is zero, exactly as three's `ConeGeometry` is, so this is
11
+ * {@link make_cylinder_geometry} under its own name; the apex handling lives there.
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, which makes the surface a hollow shell rather than a solid
18
+ * @param {number} [thetaStart]
19
+ * @param {number} [thetaLength] how much of the turn to build, in radians
20
+ * @returns {Geometry}
21
+ */
22
+ export function make_cone_geometry(
23
+ radius = 1,
24
+ height = 1,
25
+ radialSegments = 8,
26
+ heightSegments = 1,
27
+ openEnded = false,
28
+ thetaStart = 0,
29
+ thetaLength = Math.PI * 2
30
+ ) {
31
+ const geo = make_cylinder_geometry(0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength);
32
+
33
+ geo.name = "Cone";
34
+
35
+ return geo;
36
+ }
@@ -4,7 +4,7 @@
4
4
  * `Geometry` carries no multi-material groups, so the torso and the two caps are one index run
5
5
  * rather than three; three's cylinder splits them only to address a material array.
6
6
  *
7
- * @param {number} [radiusTop]
7
+ * @param {number} [radiusTop] zero makes a cone, which is what `make_cone_geometry` does
8
8
  * @param {number} [radiusBottom]
9
9
  * @param {number} [height]
10
10
  * @param {number} [radialSegments] segments around the axis
@@ -1 +1 @@
1
- {"version":3,"file":"make_cylinder_geometry.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/geometry/primitives/make_cylinder_geometry.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AACH,mDAVW,MAAM,iBACN,MAAM,WACN,MAAM,mBACN,MAAM,mBACN,MAAM,cACN,OAAO,eACP,MAAM,gBACN,MAAM,GACJ,QAAQ,CA6NpB;yBA9OwB,gBAAgB"}
1
+ {"version":3,"file":"make_cylinder_geometry.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/geometry/primitives/make_cylinder_geometry.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AACH,mDAVW,MAAM,iBACN,MAAM,WACN,MAAM,mBACN,MAAM,mBACN,MAAM,cACN,OAAO,eACP,MAAM,gBACN,MAAM,GACJ,QAAQ,CAgQpB;yBAjRwB,gBAAgB"}
@@ -8,7 +8,7 @@ import { StandardAttributes } from "../StandardAttributes.js";
8
8
  * `Geometry` carries no multi-material groups, so the torso and the two caps are one index run
9
9
  * rather than three; three's cylinder splits them only to address a material array.
10
10
  *
11
- * @param {number} [radiusTop]
11
+ * @param {number} [radiusTop] zero makes a cone, which is what `make_cone_geometry` does
12
12
  * @param {number} [radiusBottom]
13
13
  * @param {number} [height]
14
14
  * @param {number} [radialSegments] segments around the axis
@@ -31,7 +31,8 @@ export function make_cylinder_geometry(
31
31
 
32
32
  /*
33
33
  A port of three's `CylinderGeometry` onto `Geometry`: the same parameterisation and the same
34
- winding, writing meep attributes instead of three ones.
34
+ winding, writing meep attributes instead of three ones. It departs at a cone's apex, see
35
+ `generateTorso`.
35
36
 
36
37
  Derived from three.js (https://github.com/mrdoob/three.js), Copyright (c) 2010-2024 three.js authors, MIT licence.
37
38
  */
@@ -56,6 +57,7 @@ export function make_cylinder_geometry(
56
57
 
57
58
  let index = 0;
58
59
  const indexArray = [];
60
+ const apexRows = [];
59
61
  const halfHeight = height / 2;
60
62
 
61
63
  // generate geometry
@@ -98,9 +100,21 @@ export function make_cylinder_geometry(
98
100
 
99
101
  const radius = v * (radiusBottom - radiusTop) + radiusTop;
100
102
 
101
- for (let x = 0; x <= radialSegments; x++) {
103
+ // A row of zero radius is a cone's apex, where three's grid would put two corners of
104
+ // every segment's upper triangle on the same point and lean the other one's apex normal
105
+ // toward one edge. Instead the apex holds one vertex per segment, turned to the middle of
106
+ // that segment, and each segment draws just the one triangle that has area. The `u` is
107
+ // offset the same way, as three's own sphere does at its poles.
108
+ const apex = radius === 0;
102
109
 
103
- const u = x / radialSegments;
110
+ apexRows.push(apex);
111
+
112
+ const rowVertexCount = apex ? radialSegments : radialSegments + 1;
113
+ const uOffset = apex ? 0.5 : 0;
114
+
115
+ for (let x = 0; x < rowVertexCount; x++) {
116
+
117
+ const u = (x + uOffset) / radialSegments;
104
118
 
105
119
  const theta = u * thetaLength + thetaStart;
106
120
 
@@ -143,13 +157,34 @@ export function make_cylinder_geometry(
143
157
 
144
158
  const a = indexArray[y][x];
145
159
  const b = indexArray[y + 1][x];
146
- const c = indexArray[y + 1][x + 1];
147
- const d = indexArray[y][x + 1];
148
160
 
149
- // faces
161
+ if (apexRows[y] && apexRows[y + 1]) {
162
+
163
+ // both rows on the axis, so the band has no area
164
+
165
+ } else if (apexRows[y]) {
166
+
167
+ // `a` is the segment's apex vertex and stands in for `d` as well
168
+
169
+ indices.push(b, indexArray[y + 1][x + 1], a);
170
+
171
+ } else if (apexRows[y + 1]) {
172
+
173
+ // `b` is the segment's apex vertex and stands in for `c` as well
174
+
175
+ indices.push(a, b, indexArray[y][x + 1]);
176
+
177
+ } else {
178
+
179
+ const c = indexArray[y + 1][x + 1];
180
+ const d = indexArray[y][x + 1];
181
+
182
+ // faces
183
+
184
+ indices.push(a, b, d);
185
+ indices.push(b, c, d);
150
186
 
151
- indices.push(a, b, d);
152
- indices.push(b, c, d);
187
+ }
153
188
 
154
189
  }
155
190
 
@@ -0,0 +1,20 @@
1
+ /**
2
+ * A sphere of rings of latitude and meridians of longitude, centred on the origin with its poles on
3
+ * the Y axis. The texture coordinates are equirectangular: `u` runs once around the axis and `v`
4
+ * from the south pole (0) to the north pole (1).
5
+ *
6
+ * The two angular intervals cut a partial sphere: `phi` turns about the Y axis and `theta` runs
7
+ * down from the north pole, so a `thetaLength` of `Math.PI / 2` is a dome.
8
+ *
9
+ * @param {number} [radius]
10
+ * @param {number} [widthSegments] segments around the axis, at least 3
11
+ * @param {number} [heightSegments] segments from pole to pole, at least 2
12
+ * @param {number} [phiStart]
13
+ * @param {number} [phiLength] how much of the turn about the axis to build, in radians
14
+ * @param {number} [thetaStart] where to start, in radians down from the north pole
15
+ * @param {number} [thetaLength] how far toward the south pole to build, in radians; stops at the pole
16
+ * @returns {Geometry}
17
+ */
18
+ export function make_uv_sphere_geometry(radius?: number, widthSegments?: number, heightSegments?: number, phiStart?: number, phiLength?: number, thetaStart?: number, thetaLength?: number): Geometry;
19
+ import { Geometry } from "../Geometry.js";
20
+ //# sourceMappingURL=make_uv_sphere_geometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"make_uv_sphere_geometry.d.ts","sourceRoot":"","sources":["../../../../../../src/shade/renderer/geometry/primitives/make_uv_sphere_geometry.js"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;;GAgBG;AACH,iDATW,MAAM,kBACN,MAAM,mBACN,MAAM,aACN,MAAM,cACN,MAAM,eACN,MAAM,gBACN,MAAM,GACJ,QAAQ,CAkKpB;yBA5LwB,gBAAgB"}
@@ -0,0 +1,190 @@
1
+ import { Attribute } from "../Attribute.js";
2
+ import { Geometry } from "../Geometry.js";
3
+ import { StandardAttributes } from "../StandardAttributes.js";
4
+
5
+ /**
6
+ * How far short of `Math.PI`, in radians, a theta interval may end and still close at the south
7
+ * pole: four ulps of pi, room for the rounding of a sum of two or three rounded angles.
8
+ *
9
+ * @type {number}
10
+ */
11
+ const SOUTH_POLE_TOLERANCE = 8 * Number.EPSILON;
12
+
13
+ /**
14
+ * A sphere of rings of latitude and meridians of longitude, centred on the origin with its poles on
15
+ * the Y axis. The texture coordinates are equirectangular: `u` runs once around the axis and `v`
16
+ * from the south pole (0) to the north pole (1).
17
+ *
18
+ * The two angular intervals cut a partial sphere: `phi` turns about the Y axis and `theta` runs
19
+ * down from the north pole, so a `thetaLength` of `Math.PI / 2` is a dome.
20
+ *
21
+ * @param {number} [radius]
22
+ * @param {number} [widthSegments] segments around the axis, at least 3
23
+ * @param {number} [heightSegments] segments from pole to pole, at least 2
24
+ * @param {number} [phiStart]
25
+ * @param {number} [phiLength] how much of the turn about the axis to build, in radians
26
+ * @param {number} [thetaStart] where to start, in radians down from the north pole
27
+ * @param {number} [thetaLength] how far toward the south pole to build, in radians; stops at the pole
28
+ * @returns {Geometry}
29
+ */
30
+ export function make_uv_sphere_geometry(
31
+ radius = 1,
32
+ widthSegments = 32,
33
+ heightSegments = 16,
34
+ phiStart = 0,
35
+ phiLength = Math.PI * 2,
36
+ thetaStart = 0,
37
+ thetaLength = Math.PI
38
+ ) {
39
+
40
+ /*
41
+ A port of three's `SphereGeometry` onto `Geometry`: the same parameterisation and the same
42
+ winding, writing meep attributes instead of three ones. It departs at the poles, see below.
43
+
44
+ Derived from three.js (https://github.com/mrdoob/three.js), Copyright (c) 2010-2024 three.js authors, MIT licence.
45
+ */
46
+
47
+ const geo = new Geometry();
48
+
49
+ geo.name = "UVSphere";
50
+
51
+ // segments
52
+
53
+ widthSegments = Math.max(3, Math.floor(widthSegments));
54
+ heightSegments = Math.max(2, Math.floor(heightSegments));
55
+
56
+ // three clamps only its triangle selection to the south pole; clamping the rows too keeps a
57
+ // long `thetaLength` from folding the last band back over the sphere
58
+ let thetaEnd = Math.min(thetaStart + thetaLength, Math.PI);
59
+
60
+ // an interval meant to end at the pole is the sum of two rounded angles, and lands short of
61
+ // `Math.PI` often enough (`Math.PI / 6 + Math.PI / 6 * 5` is an ulp short) that within a few
62
+ // ulps it is taken to mean the pole
63
+ if (Math.PI - thetaEnd <= SOUTH_POLE_TOLERANCE) {
64
+ thetaEnd = Math.PI;
65
+ }
66
+
67
+ // A ring at a pole is a single point. Three's grid still gives it a vertex per meridian, which
68
+ // puts two corners of every polar triangle on the same point. Here a pole holds one vertex per
69
+ // segment, turned to the middle of that segment, and each segment draws just the one triangle
70
+ // that has area. A pole's normal is the axis whichever way it is turned, so only its `u` moves.
71
+ const northPole = thetaStart === 0;
72
+ const southPole = thetaEnd === Math.PI;
73
+
74
+ // buffers
75
+
76
+ const indices = [];
77
+ const vertices = [];
78
+ const normals = [];
79
+ const uvs = [];
80
+
81
+ // helper variables
82
+
83
+ let index = 0;
84
+ const grid = [];
85
+
86
+ // generate vertices, normals and uvs
87
+
88
+ for (let iy = 0; iy <= heightSegments; iy++) {
89
+
90
+ const verticesRow = [];
91
+
92
+ const v = iy / heightSegments;
93
+
94
+ const atNorthPole = iy === 0 && northPole;
95
+ const atSouthPole = iy === heightSegments && southPole;
96
+ const pole = atNorthPole || atSouthPole;
97
+
98
+ // `Math.sin(Math.PI)` is not zero, so a pole is put on the axis rather than computed onto it
99
+
100
+ const theta = thetaStart + v * (thetaEnd - thetaStart);
101
+
102
+ const sinTheta = pole ? 0 : Math.sin(theta);
103
+ const cosTheta = atNorthPole ? 1 : (atSouthPole ? -1 : Math.cos(theta));
104
+
105
+ const rowVertexCount = pole ? widthSegments : widthSegments + 1;
106
+ const uOffset = pole ? 0.5 : 0;
107
+
108
+ for (let ix = 0; ix < rowVertexCount; ix++) {
109
+
110
+ const u = (ix + uOffset) / widthSegments;
111
+
112
+ const phi = phiStart + u * phiLength;
113
+
114
+ // normal, the direction from the centre, which is what the vertex is scaled from; taking
115
+ // it from the angles rather than normalising the vertex keeps it defined at radius zero
116
+
117
+ const normal_x = -Math.cos(phi) * sinTheta;
118
+ const normal_y = cosTheta;
119
+ const normal_z = Math.sin(phi) * sinTheta;
120
+
121
+ normals.push(normal_x, normal_y, normal_z);
122
+
123
+ // vertex
124
+
125
+ vertices.push(radius * normal_x, radius * normal_y, radius * normal_z);
126
+
127
+ // uv
128
+
129
+ uvs.push(u, 1 - v);
130
+
131
+ verticesRow.push(index++);
132
+
133
+ }
134
+
135
+ grid.push(verticesRow);
136
+
137
+ }
138
+
139
+ // indices
140
+
141
+ for (let iy = 0; iy < heightSegments; iy++) {
142
+
143
+ const upper = grid[iy];
144
+ const lower = grid[iy + 1];
145
+
146
+ // at least two segments from pole to pole, so a band never has a pole on both sides
147
+ const upperIsPole = iy === 0 && northPole;
148
+ const lowerIsPole = iy + 1 === heightSegments && southPole;
149
+
150
+ for (let ix = 0; ix < widthSegments; ix++) {
151
+
152
+ if (upperIsPole) {
153
+
154
+ // the segment's pole vertex stands in for both upper corners
155
+
156
+ indices.push(upper[ix], lower[ix], lower[ix + 1]);
157
+
158
+ } else if (lowerIsPole) {
159
+
160
+ // the segment's pole vertex stands in for both lower corners
161
+
162
+ indices.push(upper[ix + 1], upper[ix], lower[ix]);
163
+
164
+ } else {
165
+
166
+ const a = upper[ix + 1];
167
+ const b = upper[ix];
168
+ const c = lower[ix];
169
+ const d = lower[ix + 1];
170
+
171
+ // faces
172
+
173
+ indices.push(a, b, d);
174
+ indices.push(b, c, d);
175
+
176
+ }
177
+
178
+ }
179
+
180
+ }
181
+
182
+ // build geometry
183
+
184
+ geo.index = Attribute.from(new Uint32Array(indices), 1, 'index');
185
+ geo.addAttribute(Attribute.from(new Float32Array(vertices), 3, StandardAttributes.Position));
186
+ geo.addAttribute(Attribute.from(new Float32Array(normals), 3, StandardAttributes.Normal));
187
+ geo.addAttribute(Attribute.from(new Float32Array(uvs), 2, StandardAttributes.TextureCoordinates0));
188
+
189
+ return geo;
190
+ }